zhuguifei
2026-03-10 58402bd5e762361363a0f7d7907153c77dbb819f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
package com.shlanbao.tzsc.pms.equ.wcplan.controller;
 
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
 
import com.shlanbao.tzsc.base.mapping.EqmWheelCovelParam;
import com.shlanbao.tzsc.base.mapping.EqmWheelCovelPlan;
import com.shlanbao.tzsc.base.mapping.EqmWheelCovelPlanInfo;
import com.shlanbao.tzsc.base.mapping.MdEquipment;
import com.shlanbao.tzsc.base.mapping.MdShift;
import com.shlanbao.tzsc.base.mapping.SysUser;
import com.shlanbao.tzsc.base.model.DataGrid;
import com.shlanbao.tzsc.base.model.Json;
import com.shlanbao.tzsc.base.model.PageParams;
import com.shlanbao.tzsc.base.model.SessionInfo;
import com.shlanbao.tzsc.pms.equ.lubricate.beans.EqmBubricantfBean;
import com.shlanbao.tzsc.pms.equ.lubricate.service.EqmLubricantPlanServiceI;
import com.shlanbao.tzsc.pms.equ.sbglplan.beans.EquipmentsBean;
import com.shlanbao.tzsc.pms.equ.sbglplan.service.EqmPlanServiceI;
import com.shlanbao.tzsc.pms.equ.wcplan.beans.BatchWCPlan;
import com.shlanbao.tzsc.pms.equ.wcplan.beans.EqmWheelCalendar;
import com.shlanbao.tzsc.pms.equ.wcplan.beans.EqmWheelCovelPlanBean;
import com.shlanbao.tzsc.pms.equ.wcplan.service.EqmWheelCovelPlanServiceI;
import com.shlanbao.tzsc.utils.tools.DateUtil;
 
@Controller
@RequestMapping("/pms/wcp")
public class EqmWheelCovelPlanController {
    @Autowired
    private EqmWheelCovelPlanServiceI eqmWheelCovelPlanService;
    @Autowired
    private EqmLubricantPlanServiceI eqmLubricantPlanServiceI;
    @Autowired
    private EqmPlanServiceI eqmPlanService;
    @Autowired
    private EqmWheelCovelPlanServiceI eqmWheelCovelPlanServiceI;
 
    /** 工单实际反馈  */
    @ResponseBody
    @RequestMapping("/orderResult")
    public Json orderResult(String ids,HttpSession session,Integer type){
        Json json = new Json();
        try {
            eqmWheelCovelPlanServiceI.orderResult(ids, type);
            json.setSuccess(true);
            json.setMsg("反馈成功!");
        } catch (Exception e) {
            e.printStackTrace();
            json.setMsg("反馈失败!");
        }
        return json;
    }
    /** 工单实际反馈  */
    @ResponseBody
    @RequestMapping("/orderResultToCounter")
    public Json orderResultToCounter(String ids,HttpSession session,Integer type){
        Json json = new Json();
        try {
            eqmWheelCovelPlanServiceI.orderResultToCounter(ids, type);
            json.setSuccess(true);
            json.setMsg("反馈成功!");
        } catch (Exception e) {
            e.printStackTrace();
            json.setMsg("反馈失败!");
        }
        return json;
    }
 
    /** 工单实际反馈统计员撤销  */
    @ResponseBody
    @RequestMapping("/revokeCounter")
    public Json revokeCounter(String ids,HttpSession session,Integer type){
        Json json = new Json();
        try {
            eqmWheelCovelPlanServiceI.revokeCounter(ids, type);
            json.setSuccess(true);
            json.setMsg("撤销成功!");
        } catch (Exception e) {
            e.printStackTrace();
            json.setMsg("撤销失败!");
        }
        return json;
    }
    /** 发射机工单结果反馈  */
    @ResponseBody
    @RequestMapping("/orderResultFSJ")
    public Json orderResultFSJ(String ids,HttpSession session,Integer type){
        Json json = new Json();
        try {
            eqmWheelCovelPlanServiceI.orderResultFSJ(ids, type);
            json.setSuccess(true);
            json.setMsg("反馈成功!");
        } catch (Exception e) {
            e.printStackTrace();
            json.setMsg("反馈失败!");
        }
        return json;
    }
    @ResponseBody
    @RequestMapping("/orderCounterFSJ")
    public Json orderCounterFSJ(String ids,HttpSession session,Integer type){
        Json json = new Json();
        try {
            eqmWheelCovelPlanServiceI.orderCounterFSJ(ids, type);
            json.setSuccess(true);
            json.setMsg("反馈成功!");
        } catch (Exception e) {
            e.printStackTrace();
            json.setMsg("反馈失败!");
        }
        return json;
    }
 
    /**设备保养记录反馈*/
    @ResponseBody
    @RequestMapping("/dasSendEquipmentWorkOrderResult")
    public Json dasSendEquipmentWorkOrderResult(String type,String ids,HttpSession session){
        Json json = new Json();
        try {
            int flag=eqmWheelCovelPlanServiceI.dasSendEquipmentWorkOrderResult(type,ids);
            if(flag==1){
                json.setSuccess(true);
                json.setMsg("反馈成功!");
            }else{
                json.setMsg("反馈失败!");
            }
        } catch (Exception e) {
            e.printStackTrace();
            json.setMsg("反馈失败!");
        }
        return json;
    }
 
    /**
     * [功能说明]:批量删除
     *
     * */
    @ResponseBody
    @RequestMapping("/deleteEqmWheelCovelById")
    public Json deleteEqmWheelCovelById(String type,String ids,HttpSession session){
        Json json = new Json();
        try {
            eqmWheelCovelPlanServiceI.deleteEqmWheelCovelById(type,ids);
            json.setSuccess(true);
            json.setMsg("删除成功!");
        } catch (Exception e) {
            json.setMsg("删除失败!");
        }
        return json;
    }
 
 
 
 
    @RequestMapping("/goToAddWCPlan")
    public String goToAddWCPlan(HttpServletRequest request,String id){
        //取得一个轮保的计划编号
        long randNo= System.currentTimeMillis();
        request.setAttribute("randNo", randNo);
        return "/pms/equ/wcplan/addWCPlan";
    }
 
    @RequestMapping("/goToQueryWCPlan")
    public String goToQueryWCPlan(HttpServletRequest request,String id){
        return "/pms/equ/wcplan/queryWCPlan";
    }
    @ResponseBody
    @RequestMapping("/auditing")
    public Json auditing(String id,String status){
        Json json = new Json();
        try {
            eqmWheelCovelPlanService.updateWCPlanStatus(id, status);
            json.setMsg("操作成功!");
            json.setSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            json.setMsg("操作失败!");
            json.setSuccess(false);
        }
        return json;
    }
 
    /**
     * [功能说明]:PMS设备轮保轮保查询
     *
     * */
    @ResponseBody
    @RequestMapping("/queryWCPlan")
    public DataGrid queryWCPlan(EqmWheelCovelPlanInfo wcpBean,PageParams pageParams,HttpServletRequest request){
        try {
            DataGrid gd = eqmWheelCovelPlanService.queryWCPlan(wcpBean,pageParams);
            return gd;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
 
    @ResponseBody
    @RequestMapping("/addWCPlan")
    public Json addWCPlan(EqmWheelCovelPlanBean wcpBean,HttpSession session){
        Json json = new Json();
        SessionInfo sessionInfo = (SessionInfo) session.getAttribute("sessionInfo");
        try {
            eqmWheelCovelPlanService.addWCPlan(wcpBean, sessionInfo.getUser().getId());
            json.setMsg("操作成功!");
            json.setSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            json.setMsg("操作失败!");
            json.setSuccess(false);
        }
        return json;
    }
 
 
    @RequestMapping("/goToEditWCPlan")
    public String goToEditWCPlan(HttpServletRequest request,String id){
        try {
            request.setAttribute("wcpBean",eqmWheelCovelPlanService.getById(id));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "/pms/equ/wcplan/editWCPlan";
    }
 
    @RequestMapping("/goToCheckWCPlan")
    public String goToCheckWCPlan(HttpServletRequest request,String id){
        try {
            request.setAttribute("wcpBean",eqmWheelCovelPlanService.getById(id));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "/pms/equ/wcplan/checkWCPlan";
    }
 
    @ResponseBody
    @RequestMapping("/editWCPlan")
    public Json editWCPlan(EqmWheelCovelPlanBean wcpBean){
        Json json = new Json();
        try {
            eqmWheelCovelPlanService.editWCPlan(wcpBean);
            json.setMsg("操作成功!");
            json.setSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            json.setMsg("操作失败!");
            json.setSuccess(false);
        }
        return json;
    }
 
 
 
    @ResponseBody
    @RequestMapping("/deleteWCPlan")
    public Json deleteWCPlan(String id){
        Json json = new Json();
        try {
            eqmWheelCovelPlanService.deleteWCPlan(id);
            json.setMsg("删除设备主数据成功!");
            json.setSuccess(true);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            json.setMsg("删除设备主数据失败!");
            json.setSuccess(false);
        }
        return json;
    }
 
    @ResponseBody
    @RequestMapping("/queryWCPlanCalendar")
    public List<EqmWheelCalendar> queryWCPlanCalendar(HttpServletRequest request) throws Exception{
        String date1=request.getParameter("start");
        String date2=request.getParameter("end");
        return eqmWheelCovelPlanService.queryWCPlanCalendar(date1, date2);
    }
 
 
 
    /**
     * 设备轮保-批量添加跳转
     *
     * */
    @RequestMapping("/goToAddLubiPlan")
    public String goToAddLubiPlan()throws Exception{
        return "/pms/equ/wcplan/add_wcplan";
    }
 
    /**
     * 功能说明:设备润滑计划管理-添加
     * @author wanchanghuang
     * @time 2015年8月21日16:35:42
     *
     * */
    @ResponseBody
    @RequestMapping("/addEqmLubricatPlan")
    public Json addEqmLubricatPlan(BatchWCPlan b,HttpSession session){
         SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
         SessionInfo sessionInfo = (SessionInfo) session.getAttribute("sessionInfo");
         Json json = new Json();
         try {
            //获得两时间段的所有日期
            List<Date> dateLists=findDates(sdf.parse(b.getDate_plan1()),sdf.parse( b.getDate_plan2()));
            //获得选中的所有设备
            EqmBubricantfBean bf=new EqmBubricantfBean();
            bf.setEqp_typeId(b.getEqp_typeId());
            List<?> listMdEquipMent=eqmLubricantPlanServiceI.addEqmLubricatPlan(bf);
            EquipmentsBean equBean = new EquipmentsBean();
            equBean.setQueryEqpTypeId(b.getEqp_category());
            equBean.setQueryType("lb");
            List<?> tf= eqmPlanService.queryEqpTypeChild(b);
            Object[] t=(Object[]) tf.get(0);
 
            Map<String,String> map =eqmPlanService.querySysEqpType(b);
 
            for(Date d :dateLists){
                for(Object o:listMdEquipMent){
                    Object[] temp=(Object[]) o;
                    EqmWheelCovelPlan ep = new EqmWheelCovelPlan();
                    String planNo=DateUtil.datetoStr(new Date(),"yyyyMMddHHmmss.SSSZ")+"LB";
                    ep.setPlanNo(planNo);
                    ep.setPlanName(temp[3].toString()+"轮保");
                    SysUser addUser = new SysUser();
                    addUser.setId(sessionInfo.getUser().getId());
                    ep.setSysUserByCreateId(addUser);//创建人
                    //EQU_ID  //设备主数据
                    MdEquipment mdEquipment = new MdEquipment();//设备
                    mdEquipment.setId(temp[0].toString());//设备ID,设备主数据中的ID
                    ep.setMdEquipment(mdEquipment);
                    //ep.setEqmWheelCovelPlan(null);  //
                    ep.setScheduleDate(d);
                    ep.setScheduleEndDate(d);
                    ep.setMaintenanceLength(b.getEquipmentMinute());
                    ep.setMaintenanceContent("");
                    //班次
                    MdShift mf=new MdShift();
                    mf.setId(b.getShiftId());
                    ep.setMdShift(mf);
                    ep.setPlanner("1");
                    ep.setMaintenanceType("lb");
                    ep.setWheelCoverType("0");
                    ep.setWheelParts(t[0].toString());  //轮保部位
                    ep.setDel("0");
                    ep.setCreateDate(new Date());
                    ep.setMdMatId(b.getMatId());
                    String idf=eqmPlanService.saveWcPlanf(ep);
                    for (Map.Entry<String, String> entry : map.entrySet()) {
                        String value=entry.getValue();
                        String key=entry.getKey();
                        if(value.equals(b.getRuleId())){
                            /*EqmWheelCovelParam ecpb=new EqmWheelCovelParam();
                            EqmWheelCovelPlan tfe=new EqmWheelCovelPlan();
                            tfe.setId(idf);
                            //ecpb.setPid(tfe);
                            ecpb.setPlanTime(sdf.format(d));
                            ecpb.setEnable("0");
                            ecpb.setSetId(key);
                            //保存
                            eqmPlanService.saveWcParam(ecpb);
                            */
                        }
 
                    }
                }
 
            }
            json.setMsg("操作成功!");
            json.setSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            json.setMsg("操作失败!");
            json.setSuccess(false);
        }
        return json;
    }
 
    //获得两时间段所有时间集合
        public static List<Date> findDates(Date dBegin, Date dEnd) {
            System.out.println(dBegin+"     "+dEnd);
            List<Date> lDate = new ArrayList<Date>();
            lDate.add(dBegin);
            Calendar calBegin = Calendar.getInstance();
            // 使用给定的 Date 设置此 Calendar 的时间
            calBegin.setTime(dBegin);
            Calendar calEnd = Calendar.getInstance();
            // 使用给定的 Date 设置此 Calendar 的时间
            calEnd.setTime(dEnd);
            // 测试此日期是否在指定日期之后
            while (dEnd.after(calBegin.getTime())) {
                // 根据日历的规则,为给定的日历字段添加或减去指定的时间量
                calBegin.add(Calendar.DAY_OF_MONTH, 1);
                lDate.add(calBegin.getTime());
            }
            return lDate;
        }
        /**
         * 查询设备维保详细项,用于修改
         * @param id
         */
        @ResponseBody
        @RequestMapping("/goToEditDetailJsp")
        public void goToEditDetailJsp(String id,HttpServletRequest request){
            eqmPlanService.queryDetailById(id);
        }
}