cy
2022-06-21 129904537f66509f97b285e7eb4f42b3dc349dd0
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
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
package cn.ksource.web.controller.business.pages.rcxj;
 
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
 
import cn.ksource.beans.CI_DAILY_PATROL;
import cn.ksource.beans.FlowRecord;
import cn.ksource.core.page.PageInfo;
import cn.ksource.core.util.ConvertUtil;
import cn.ksource.core.util.DateUtil;
import cn.ksource.core.util.JsonUtil;
import cn.ksource.core.util.ParamsMapUtil;
import cn.ksource.core.util.StringUtil;
import cn.ksource.core.web.SysInfo;
import cn.ksource.core.web.WebUtil;
import cn.ksource.web.Constants;
import cn.ksource.web.facade.JsglFacade;
import cn.ksource.web.facade.customermanage.CustomerManageFacade;
import cn.ksource.web.facade.rcxj.RcxjFacade;
import cn.ksource.web.service.file.FileService;
 
@RequestMapping("/business/pages/rcxj")
@SuppressWarnings({"rawtypes"})
@Controller
public class RcxjController {
    @Resource
    private CustomerManageFacade customerFacade;
    @Resource
    private RcxjFacade rcxjFacade;
    @Resource
    private JsglFacade jsglFacade;
    @Resource
    private FileService fileService;
 
    /**
     * 我的日常巡检列表
     *
     * @param model
     * @param request
     * @return
     * @author chenlong
     */
    @RequestMapping("myRcxjList.html")
    public String healthPlanList(Model model, HttpServletRequest request) {
 
        long month = DateUtil.getCurrentDate6();
        long monthFirstDate = ConvertUtil.obj2Long(month + "01");
        Long defaultDate = DateUtil.getCurrentDate8();
        model.addAttribute("defaultDate", defaultDate);
        model.addAttribute("monthFirstDate", monthFirstDate);
        List<Map> cusList = customerFacade.getCusList();
        model.addAttribute("cusList", cusList);
        return "/business/pages/rcxj/myRcxjList";
    }
 
 
    @RequestMapping("myRcxjData.html")
    public String healthPlanData(PageInfo pageInfo, Model model, HttpServletRequest request) {
        Map<String, String> params = ParamsMapUtil.getParameterMap(request);
        params.put("userId", WebUtil.getUserId(request));
        pageInfo = rcxjFacade.getRcxjData(pageInfo, params);
        model.addAttribute("pageInfo", pageInfo);
        return "/business/pages/rcxj/myRcxjData";
    }
 
    @RequestMapping("myRcxjCount.html")
    public void myRcxjCount(Model model, HttpServletRequest request, HttpServletResponse response) {
        Map<String, String> params = ParamsMapUtil.getParameterMap(request);
        params.put("userId", WebUtil.getUserId(request));
        WebUtil.write(response, rcxjFacade.getRcxjCount(params).toString());
    }
 
    /**
     * 添加,编辑日常巡检
     *
     * @param model
     * @param request
     * @return
     * @author chenlong
     */
    @RequestMapping(value = "editRcxj.html", method = RequestMethod.GET)
    public String editRcxj(Model model, HttpServletRequest request) {
        String id = request.getParameter("id");
        Map info = new HashMap();
        List<Map> cusList = customerFacade.getCusList();
        model.addAttribute("cusList", cusList);
        if (StringUtil.isNotBlank(id)) {
            info = rcxjFacade.getRcxjById(id);
            List<Map> fileList = fileService.getFileList(id);
            info.put("fileList", fileList);
            List patrolCiList = rcxjFacade.getPatrolCiList(id);
            model.addAttribute("patrolCiList", patrolCiList);
            List<Map> linkOrderList = rcxjFacade.getLinkOrderList(id);
            model.addAttribute("linkOrderList", linkOrderList);
        }
        model.addAttribute("info", info);
        info.put("user_name", WebUtil.getUserName(request));
 
        return "/business/pages/rcxj/editRcxj";
    }
 
    @RequestMapping(value = "editRcxj.html", method = RequestMethod.POST)
    public ModelAndView doEditRcxj(CI_DAILY_PATROL report, Model model, HttpServletRequest request) {
        Map<String, String> params = ParamsMapUtil.getParameterMap(request);
        params.put("user_id", WebUtil.getUserId(request));
        CI_DAILY_PATROL ss=rcxjFacade.savePatrol(report, params);
        fileService.uploadFile(request,ss.getId(),null,Constants.FILE_STATE_SHTG,null);
        return WebUtil.sysInfoPage(request, "操作成功!",
                "",
                SysInfo.Success, "/business/pages/rcxj/myRcxjList.html");
    }
 
    /**
     * 巡检项列表
     *
     * @param model
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("itemresult.html")
    public String itemresult(Model model, HttpServletRequest request, HttpServletResponse response) {
        Map<String, String> params = ParamsMapUtil.getParameterMap(request);
        List<Map> ciList = rcxjFacade.getCiItemList(params);
        model.addAttribute("ciList", ciList);
        return "/business/pages/rcxj/itemresult";
    }
 
    /**
     * 通用巡检项
     *
     * @param model
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("commonPatrolItem.html")
    public String commonPatrolItem(Model model, HttpServletRequest request, HttpServletResponse response) {
        String cusId = request.getParameter("cusId");
        String orderId = request.getParameter("orderId");
        List<Map> categoryList = rcxjFacade.getCommonPatrolItem(cusId, orderId);
        model.addAttribute("categoryList", categoryList);
        return "/business/pages/rcxj/commonPatrolItem";
    }
 
    /**
     * 通用巡检项(只读)
     *
     * @param model
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("commonPatrolItem_read.html")
    public String commonPatrolItem_read(Model model, HttpServletRequest request, HttpServletResponse response) {
        String cusId = request.getParameter("cusId");
        String orderId = request.getParameter("orderId");
        List<Map> categoryList = rcxjFacade.getCommonPatrolItem(cusId, orderId);
        model.addAttribute("categoryList", categoryList);
        return "/business/pages/rcxj/commonPatrolItem_read";
    }
 
    /**
     * 巡检设备列表
     *
     * @param model
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("patrolCiList.html")
    public String patrolCiList(Model model, HttpServletRequest request, HttpServletResponse response) {
        Map<String, String> params = ParamsMapUtil.getParameterMap(request);
        List<Map> ciList = rcxjFacade.getPatrolCiList(params);
        model.addAttribute("ciList", ciList);
        return "/business/pages/rcxj/patrolCiList";
    }
 
    /**
     * 详情首页
     *
     * @param model
     * @param request
     * @return
     * @author chenlong
     */
    @RequestMapping("rcxjIndex.html")
    public String rcxjIndex(Model model, HttpServletRequest request) {
        String patrolDate = request.getParameter("patrolDate");
        String orderId = request.getParameter("orderId");
        String userId = request.getParameter("userId");
        Map<String, String> params = ParamsMapUtil.getParameterMap(request);
        int currentYear = Integer.valueOf(patrolDate.substring(0, 4));
        int currentMonth = Integer.valueOf(patrolDate.substring(4, 6));
        int currentDay = Integer.valueOf(patrolDate.substring(6, 8));
 
        String warnString = rcxjFacade.getMonthWarnDate(params);
        if (StringUtil.isBlank(warnString)) {
            warnString = "";
        }
        String hasReportDate = rcxjFacade.getHasReportDate(params);
        if (StringUtil.isBlank(hasReportDate)) {
            hasReportDate = "";
        }
 
        Calendar cal = Calendar.getInstance();
        Map calendar = getCalendar(currentYear, currentMonth);
        calendar.put("warnString", warnString);
        calendar.put("hasReportDate", hasReportDate);
 
        model.addAttribute("currentYear", String.valueOf(currentYear))
                .addAttribute("currentMonth", String.valueOf(currentMonth))
                .addAttribute("currentDay", String.valueOf(currentDay))
                .addAttribute("orderId", orderId)
                .addAttribute("patrolDate", patrolDate)
                .addAttribute("userId", userId)
                .addAttribute("calendar", calendar);
        return "/business/pages/rcxj/rcxjIndex";
    }
 
    /**
     * 获取日历数据
     *
     * @param year
     * @param month
     * @return
     * @author chenlong
     */
    public Map getCalendar(int year, int month) {
        Map map = new HashMap();
        Calendar cal = Calendar.getInstance();
        cal.clear();
        cal.set(Calendar.YEAR, year);
        cal.set(Calendar.MONTH, month - 1);//Java月份才0开始算
        cal.set(Calendar.DAY_OF_MONTH, 1);
        //获取当月天数
        int monthDays = cal.getActualMaximum(Calendar.DATE);
        //获取当前月第一天是星期几
        int firstWeekDay = cal.get(Calendar.DAY_OF_WEEK) - 1;
        map.put("monthDays", monthDays);
        map.put("firstWeekDay", firstWeekDay);
        return map;
    }
 
    /**
     * 获取日历
     *
     * @param request
     * @param response
     * @author chenlong
     */
    @RequestMapping("getCalendarData.html")
    public void getCalendarData(HttpServletRequest request, HttpServletResponse response) {
        Map<String, String> params = ParamsMapUtil.getParameterMap(request);
        int year = Integer.parseInt(request.getParameter("year"));
        int month = Integer.parseInt(request.getParameter("month"));
        Map calendar = getCalendar(year, month);
        String warnString = rcxjFacade.getMonthWarnDate(params);
        if (StringUtil.isBlank(warnString)) {
            warnString = "";
        }
        calendar.put("warnString", warnString);
        String hasReportDate = rcxjFacade.getHasReportDate(params);
        if (StringUtil.isBlank(hasReportDate)) {
            hasReportDate = "";
        }
        calendar.put("hasReportDate", hasReportDate);
        WebUtil.write(response, JsonUtil.map2Json(calendar));
    }
 
    /**
     * 获取巡检报告
     *
     * @param model
     * @param request
     * @return
     * @author chenlong
     */
    @RequestMapping("rcxjReport.html")
    public String rcxjReport(Model model, HttpServletRequest request) {
        String orderId = request.getParameter("orderId");
        Map info = rcxjFacade.getRcxjById(orderId);
        List<Map> fileList = fileService.getFileList(orderId);
        info.put("fileList", fileList);
        //List ciList = rcxjFacade.getPatrolCiList(orderId);
        List<Map> commonList = rcxjFacade.getCommonPatrolItem(ConvertUtil.obj2StrBlank(info.get("cus_id")), orderId);
        model.addAttribute("info", info);
        //model.addAttribute("ciList", ciList);
        model.addAttribute("commonList", commonList);
        Map<String, String> params = new HashMap<String, String>();
        params.put("orderId", orderId);
        params.put("cusId", ConvertUtil.obj2StrBlank(info.get("CUS_ID")));
        params.put("subCusId", ConvertUtil.obj2StrBlank(info.get("SUB_CUS_ID")));
        params.put("errflag", "1");
        List<Map> ciList = rcxjFacade.getCiItemList(params);
        Map shInfo = rcxjFacade.getShInfoById(orderId);
        model.addAttribute("ciList", ciList);
        model.addAttribute("shInfo", shInfo);
        List<Map> linkOrderList = rcxjFacade.getLinkOrderList(orderId);
        model.addAttribute("linkOrderList", linkOrderList);
 
        return "/business/pages/rcxj/rcxjReport";
    }
 
    /**
     * 获取当天工单
     *
     * @param request
     * @param response
     * @author chenlong
     */
    @RequestMapping("getCurOrders.html")
    public void getCurOrders(HttpServletRequest request, HttpServletResponse response) {
        String userId = request.getParameter("userId");
        String patrolDate = request.getParameter("patrolDate");
        Map<String, String> params = new HashMap<String, String>();
        params.put("userId", userId);
        params.put("patrolDate", patrolDate);
        List<Map> list = rcxjFacade.getCurDateOrders(params);
        WebUtil.write(response, JsonUtil.list2Json(list));
    }
 
/*    *//**
     * 提交审核
     *
     * @param
     * @param request
     * @return
     * @author chenlong
     *//*
    @RequestMapping(value = "comitSh.html", method = RequestMethod.GET)
    public String comitSh(Model model, HttpServletRequest request) {
        String id = request.getParameter("id");
        Map info = rcxjFacade.getRcxjById(id);
        Map cus = customerFacade.getPartnerCostomerById(info.get("CUS_ID").toString());
        model.addAttribute("cus", cus);
        return "/business/pages/rcxj/comitSh";
    }*/
 
    @RequestMapping(value = "comitSh.html")
    public void doComitSh(FlowRecord flowRecord, HttpServletResponse response, HttpServletRequest request) {
        String id = request.getParameter("id");
        Map info = rcxjFacade.getRcxjById(id);
        Map cus = customerFacade.getPartnerCostomerById(info.get("CUS_ID").toString());
 
        Map<String, String> params = ParamsMapUtil.getParameterMap(request);
        params.put("busId", id);
        params.put("id", id);
        if(StringUtil.notEmpty(ConvertUtil.obj2Str(cus.get("ywjl_id")))){
            params.put("cus_id", cus.get("ywjl_id").toString());
            params.put("cus_name", cus.get("ywjl_name").toString());
        }else{
            params.put("cus_id", "");
            params.put("cus_name", "");
        }
 
        flowRecord.setDealId(WebUtil.getUserId(request));
        flowRecord.setDealName(WebUtil.getUserName(request));
        flowRecord.setTemplateKey(Constants.RCXJ_FLOW_XZ);
        params.put("state", Constants.RCXJ_FLOW_DSH.toString());
        rcxjFacade.doToNext(params, flowRecord);
        WebUtil.write(response, "1");
    }
 
 
    /**
     * 日常巡检审核列表
     *
     * @param model
     * @param request
     * @return
     * @author chenlong
     */
    @RequestMapping("rcxjShList.html")
    public String rcxjShList(Model model, HttpServletRequest request) {
        List<Map> cusList = customerFacade.getCusList();
        long month = DateUtil.getCurrentDate6();
        long beginDate = ConvertUtil.obj2Long(month + "01");
        model.addAttribute("cusList", cusList);
        model.addAttribute("beginDate", beginDate);
        return "/business/pages/rcxj/rcxjShList";
    }
 
    @RequestMapping("rcxjShData.html")
    public String rcxjShData(PageInfo pageInfo, Model model, HttpServletRequest request) {
        Map<String, String> params = ParamsMapUtil.getParameterMap(request);
        if (params.get("flag").equals("1")) {
            params.put("curId", WebUtil.getUserId(request));
            params.put("fstate", Constants.RCXJ_FLOW_DSH.toString());
        } else {
            params.put("templateKey", Constants.CFG_FLOW_DSH.toString());
            params.put("dealId", WebUtil.getUserId(request));
        }
        pageInfo = rcxjFacade.getRcxjData(pageInfo, params);
        model.addAttribute("pageInfo", pageInfo);
        return "/business/pages/rcxj/rcxjShData";
    }
 
    @RequestMapping("rcxjShCount.html")
    public void rcxjShCount(Model model, HttpServletRequest request, HttpServletResponse response) {
        Map<String, String> params = ParamsMapUtil.getParameterMap(request);
        if (params.get("flag").equals("1")) {
            params.put("curId", WebUtil.getUserId(request));
            params.put("fstate", Constants.RCXJ_FLOW_DSH.toString());
        } else {
            params.put("templateKey", Constants.CFG_FLOW_DSH.toString());
            params.put("dealId", WebUtil.getUserId(request));
        }
        WebUtil.write(response, rcxjFacade.getRcxjCount(params).toString());
    }
 
    /**
     * 审核
     *
     * @param model
     * @param request
     * @return
     * @author chenlong
     */
    @RequestMapping(value = "rcxjSh.html", method = RequestMethod.GET)
    public String rcxjSh(Model model, HttpServletRequest request) {
        List<Map> users = jsglFacade.getUsersByRoleKey(Constants.ROLE_YWADMIN);
        model.addAttribute("users", users);
        String id = request.getParameter("id");
        Map info = rcxjFacade.getRcxjById(id);
        Map<String, String> params = new HashMap<String, String>();
        params.put("orderId", id);
        params.put("cusId", ConvertUtil.obj2StrBlank(info.get("CUS_ID")));
        params.put("subCusId", ConvertUtil.obj2StrBlank(info.get("SUB_CUS_ID")));
        List patrolCiList = rcxjFacade.getPatrolCiList(params);
        model.addAttribute("info", info);
        model.addAttribute("patrolCiList", patrolCiList);
        List<Map> categoryList = rcxjFacade.getCommonPatrolItem(info.get("cus_id").toString(), id);
        model.addAttribute("categoryList", categoryList);
 
        List<Map> linkOrderList = rcxjFacade.getLinkOrderList(id);
        model.addAttribute("linkOrderList", linkOrderList);
        return "/business/pages/rcxj/rcxjSh";
    }
 
    @RequestMapping(value = "rcxjSh.html", method = RequestMethod.POST)
    public ModelAndView doRcxjSh(FlowRecord flowRecord, Model model, HttpServletRequest request) {
        Map<String, String> params = ParamsMapUtil.getParameterMap(request);
        flowRecord.setDealId(WebUtil.getUserId(request));
        flowRecord.setDealName(WebUtil.getUserName(request));
        flowRecord.setTemplateKey(Constants.RCXJ_FLOW_DSH);
        if (params.get("flag").equals("1")) {
            params.put("state", Constants.RCXJ_FLOW_WC.toString());
        } else {
            params.put("state", Constants.RCXJ_FLOW_SB.toString());
        }
        rcxjFacade.doToNext(params, flowRecord);
        String js = "window.top.query();"
                + "window.top.hideDialog('do');";
        return WebUtil.sysInfoPage(request, "操作成功!",
                js,
                SysInfo.Success, "");
    }
 
    /**
     * 日常巡检查询列表
     *
     * @param model
     * @param request
     * @return
     * @author chenlong
     */
    @RequestMapping("rcxjCxList.html")
    public String rcxjCxList(Model model, HttpServletRequest request) {
        /*long month = DateUtil.getCurrentDate6();
        long beginDate = ConvertUtil.obj2Long(month+"01");
        long time = DateUtil.getCurrentDate8();*/
        long time = DateUtil.getCurrentDate8();
        //将当前时间提前一个月
        String month = DateUtil.beforeTime30(time);
 
        long beginDate = ConvertUtil.obj2Long(month);
        model.addAttribute("beginDate", beginDate);
        List<Map> cusList = customerFacade.getCusList();
        model.addAttribute("cusList", cusList);
        return "/business/pages/rcxj/rcxjCxList";
    }
 
    @RequestMapping("rcxjCxData.html")
    public String rcxjCxData(PageInfo pageInfo, Model model, HttpServletRequest request) {
        Map<String, String> params = ParamsMapUtil.getParameterMap(request);
        params.put("state","cx");
        pageInfo = rcxjFacade.getRcxjData(pageInfo, params);
        model.addAttribute("pageInfo", pageInfo);
        return "/business/pages/rcxj/rcxjCxData";
    }
 
    @RequestMapping("rcxjCxCount.html")
    public void rcxjCxCount(Model model, HttpServletRequest request, HttpServletResponse response) {
        Map<String, String> params = ParamsMapUtil.getParameterMap(request);
        params.put("state","cx");
        WebUtil.write(response, rcxjFacade.getRcxjCount(params).toString());
    }
 
    /**
     * 巡检详情
     *
     * @param model
     * @param request
     * @return
     * @author chenlong
     */
    @RequestMapping("patrolDetail.html")
    public String patrolDetail(Model model, HttpServletRequest request) {
        String orderId = request.getParameter("orderId");
        Map info = rcxjFacade.getRcxjById(orderId);
        Map<String, String> params = new HashMap<String, String>();
        params.put("orderId", orderId);
        params.put("cusId", ConvertUtil.obj2StrBlank(info.get("CUS_ID")));
        params.put("subCusId", ConvertUtil.obj2StrBlank(info.get("SUB_CUS_ID")));
        List<Map> ciList = rcxjFacade.getCiItemList(params);
        model.addAttribute("ciList", ciList);
        return "/business/pages/rcxj/patrolDetail";
    }
 
}