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
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
package cn.ksource.web.controller.wechat.ewyw;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
 
import org.springframework.beans.factory.annotation.Autowired;
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.GG_RECORD;
import cn.ksource.beans.SC_WORKFLOW_CI_HEALTH;
import cn.ksource.beans.SC_WORKFLOW_CI_HEALTH_CIDETAIL;
import cn.ksource.beans.SC_WORKFLOW_CI_REMIND;
import cn.ksource.beans.SC_WORKFLOW_ITEM_HEALTH_CIDETAIL;
import cn.ksource.beans.WORKFLOW_BASE;
import cn.ksource.beans.WORKFLOW_NODE;
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.util.TreeUtil;
import cn.ksource.core.web.SysInfo;
import cn.ksource.core.web.SysInfoMsg;
import cn.ksource.core.web.WebUtil;
import cn.ksource.core.workflow.WorkflowCoreService;
import cn.ksource.web.Constants;
import cn.ksource.web.SysConstants;
import cn.ksource.web.facade.health.HealthFacade;
import cn.ksource.web.facade.health.HealthFacadeImpl;
import cn.ksource.web.facade.incident.IncidentFacade;
import cn.ksource.web.facade.wechat.ewyw.EwHealthFacade;
import cn.ksource.web.service.record.RecordService;
import cn.ksource.web.service.workFlowSupport.WorkFlowSupportService;
 
@Controller
@RequestMapping("/ewyw/ewHealth")
public class EwHealthController {
    @Autowired
    EwHealthFacade ewHealthFacade;
    @Autowired
    HealthFacade healthFacade;
    @Autowired
    IncidentFacade incidentFacade;
    @Autowired
    WorkFlowSupportService workFlowSupportService;
    @Autowired
    RecordService recordService;
    @Autowired
    WorkflowCoreService workflowCoreService;
    /**
     * 跳转到我的健康检查工单页面
     */
    @RequestMapping("ewMyHealth.html")
    public ModelAndView ewMyHealth(HttpServletRequest request) {
        ModelAndView modelAndView = new ModelAndView("/business/wechat/ewyw/ewHealth/ewMyHealth");
        //查询工单状态
        Map<String, String> state = Constants.mapWORKFLOW_BASE_WFSTATE_PART;
        List status = new ArrayList();
        for (Map.Entry<String, String> entry : state.entrySet()) {  
            String key = entry.getKey();
            String value = entry.getValue();
            Map map = new HashMap();
            map.put("state", key);
            map.put("stateName", value);
            status.add(map);
        }
        
        modelAndView.addObject("status", status);
        
        return modelAndView;
    }
    /**
     * 查询我的健康检查工单列表
     */
    @RequestMapping(value="ewMyHealthData.html",method=RequestMethod.POST)
    public ModelAndView eMyHealthData(HttpServletRequest request) {
        ModelAndView modelAndView = new ModelAndView("/business/wechat/ewyw/ewHealth/ewMyHealthData");
        List list = ewHealthFacade.ewMyHealthData(request);
        modelAndView.addObject("orderList", list);
        String flowstate = request.getParameter("flowstate");
        modelAndView.addObject("flowstate", flowstate);
        return modelAndView;
    }
    
    /**
     * 查询我的健康检查工单总数量
     */
    @RequestMapping(value="ewMyHealthCount.html",method=RequestMethod.POST)
    public void worderCount(HttpServletRequest request,HttpServletResponse response) {
        int count = ewHealthFacade.ewMyHealthCount(request);
        WebUtil.write(response, String.valueOf(count));
    }
 
    /**
     * 健康检查工单详情
     */
    @RequestMapping("ewHealthInfo.html")
    public ModelAndView ewHealthInfo(HttpServletRequest request,HttpServletResponse response) {
        ModelAndView modelAndView = new ModelAndView("/business/wechat/ewyw/ewHealth/ewHealthInfo");
        //查询健康检查基本信息
        String orderId = request.getParameter("orderId");
        String flowId = new String();
        if(StringUtil.notEmpty(orderId)) {
            SC_WORKFLOW_CI_HEALTH health = new SC_WORKFLOW_CI_HEALTH(orderId).getInstanceById();
            flowId = health.getFlow_id();
        }
        
        //通过工单编号查询工单基本信息
        Map baseMsg =  healthFacade.getHealthInfo(orderId);
        
        modelAndView.addObject("baseMsg", baseMsg);
        modelAndView.addObject("orderId", orderId);
        modelAndView.addObject("flowId", flowId);
        
        return modelAndView;
    }
    
    /**
     * 健康检查工单详情(进行中)
     */
    @RequestMapping("ewHealthInfoCl.html")
    public ModelAndView ewHealthInfoCl(HttpServletRequest request,HttpServletResponse response) {
        ModelAndView modelAndView = new ModelAndView("/business/wechat/ewyw/ewHealth/ewHealthInfoCl");
        //查询健康检查基本信息
        String orderId = request.getParameter("orderId");
        String flowId = new String();
        if(StringUtil.notEmpty(orderId)) {
            SC_WORKFLOW_CI_HEALTH health = new SC_WORKFLOW_CI_HEALTH(orderId).getInstanceById();
            flowId = health.getFlow_id();
        }
        
        //通过工单编号查询工单基本信息
        Map baseMsg =  healthFacade.getHealthInfo(orderId);
        
        //得到当前节点
        Map user = WebUtil.getWywEngineerLoginUser(request);
        String userId = ConvertUtil.obj2StrBlank(user.get("ID"));
        String nodeId=healthFacade.queryNodeidByFlowId(flowId,userId);
        WORKFLOW_NODE node = new WORKFLOW_NODE(nodeId).getInstanceById();
        String nodeTemplateId = node.getNode_template_id();
        modelAndView.addObject("nodeTemplateId", nodeTemplateId);
        modelAndView.addObject("nodeId", nodeId);
        modelAndView.addObject("baseMsg", baseMsg);
        modelAndView.addObject("orderId", orderId);
        modelAndView.addObject("flowId", flowId);
        
        //判断如果是当前是工程师处理节点,
        if(nodeTemplateId.equals(Constants.HEALTH_PATROL)){
            
            if(!StringUtil.notEmpty(flowId)) {
                SC_WORKFLOW_CI_HEALTH health = new SC_WORKFLOW_CI_HEALTH(orderId).getInstanceById();
                flowId = health.getFlow_id();
            }
            
            //是否已响应
            if(StringUtil.isNotBlank(nodeId)){
                modelAndView.addObject("isAdmin",node.getIs_admin());
                if(node.getFlowstate()==1){
                    modelAndView.addObject("isAnswer","true");
                }
                //是否可发送到下一环节
                WORKFLOW_BASE base = new WORKFLOW_BASE(flowId).getInstanceById();
                boolean isCanFinish = workflowCoreService.isCanToNextNode(base, new WORKFLOW_NODE(nodeId).getInstanceById());
                modelAndView.addObject("isCanFinish",isCanFinish);
            }
 
        }
        
        return modelAndView;
    }
    
    /**
     * 跳转到基本信息(健康检查-人员指派)
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value="ewDispatchHealthInfo.html",method=RequestMethod.GET)
    public String ewDispatchHealthInfo(Model model,HttpServletRequest request,HttpServletResponse response) {
        String orderId = request.getParameter("orderId");
        //基本信息
        if(StringUtil.isNotBlank(orderId)){
            Map health = healthFacade.getHealthInfo(orderId);
            model.addAttribute("info",health);
        }
        /*
        //需要查询设备peikezhan
        List<Map> ciList = healthFacade.getPatrolCiList(orderId);
        //查询该工单下的指标list
        List<Map> itemList = healthFacade.getPatrolIteamsList(orderId);
        //拼装设备和指标tree
        TreeUtil treeUtil = new TreeUtil();
        List treelist=treeUtil.createTreeByCate(ciList, itemList);
        model.addAttribute("ciList",treelist);
        */
        model.addAttribute("flowId", request.getParameter("flowId"));
        model.addAttribute("nodeId", request.getParameter("nodeId"));
        //得到缓存数据
        Map tempData =  (Map) request.getSession().getAttribute(SysConstants.JKJCRYFPSESSIONTEMP);
        model.addAttribute("tempData", tempData);
        return "/business/wechat/ewyw/ewHealth/ewDispatchHealthInfo";
    }
    
    /**
     * 跳转到基本信息(健康检查-人员指派),提交信息
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value="ewDispatchHealthInfo.html",method=RequestMethod.POST)
    public void ewDispatchHealthSubmit(HttpServletRequest request,HttpServletResponse response) {
        Map<String, String> params = ParamsMapUtil.getParameterMap(request);
        request.getSession().setAttribute(SysConstants.JKJCRYFPSESSION, params);
        WebUtil.write(response, "1");
    }
    /**
     * 离开基本信息页面,保存临时数据
     * @author lixiang
     * */
    @RequestMapping(value="saveTempData.html",method=RequestMethod.POST)
    public void saveTempData(HttpServletRequest request,HttpServletResponse response) {
        Map<String, String> params = ParamsMapUtil.getParameterMap(request);
        request.getSession().setAttribute(SysConstants.JKJCRYFPSESSIONTEMP, params);
        System.out.println("离开页面缓存数据:"+params);
        WebUtil.write(response, "1");
    }
    
    /**
     * 跳转到人员分派界面
     * @author lx
     * */
    @RequestMapping("ryfpSelectJkjc.html")
    public ModelAndView ryfpSelectJkjc(HttpServletRequest request){
        ModelAndView view = new ModelAndView("/business/wechat/ewyw/ewHealth/ryfpSelectJkjc");
        List<Map> resList = workFlowSupportService.getAllExecutors();
        view.addObject("resList",resList);
        return view;
        
    }
    
 
    
    /**
     * 人员分派
     * @author lx
     * */
    @RequestMapping("saveRyfp.html")
    public void saveRyfp(HttpServletRequest request,HttpServletResponse response){
        String[] ciIdAry = request.getParameterValues("ciId");
        Map<String, String> param = ParamsMapUtil.getParameterMap(request);
        Map user = WebUtil.getWywEngineerLoginUser(request);
        
        //得到session中缓存的信息
        HttpSession session =  request.getSession();
        Map<String, String> info = (Map<String, String>) session.getAttribute(SysConstants.JKJCRYFPSESSION);
        //清除这个session信息 
        session.removeAttribute(SysConstants.JKJCRYFPSESSION);
        //清除缓存session
        session.removeAttribute(SysConstants.JKJCRYFPSESSIONTEMP);
        
        SC_WORKFLOW_CI_HEALTH health = new SC_WORKFLOW_CI_HEALTH();
        //需要转换时间的格式
        String plan_time = info.get("plan_time").replaceAll("-", "");
        health.setPlan_time(ConvertUtil.obj2Long(plan_time)).setContacts_name(ConvertUtil.obj2Str(info.get("contacts_name")))
        .setContacts_tel(ConvertUtil.obj2Str(info.get("contacts_tel")));
        //将剩余参数放入param中
        param.put("nodeId", info.get("nodeId"));
        param.put("orderId", info.get("orderId"));
        param.put("flowId", info.get("flowId"));
        
        Map msg = ewHealthFacade.doDispatch(health,param,request);
        String flowId = info.get("flowId");
        String nodeId = info.get("nodeId");
        String userId = ConvertUtil.obj2Str(user.get("ID"));
        String userName = ConvertUtil.obj2Str(user.get("ZSXM"));
        GG_RECORD record = new GG_RECORD();
        record.setDeal_content("指派人员:"+userName+"进行了人员指派");
        record.setDeal_time(DateUtil.getCurrentDate14());
        record.setDeal_user_id(userId);
        record.setDeal_user_name(userName);
        record.setBusiness_id(flowId);
        record.setNode_id(nodeId);
        recordService.addRecord(record);
        
        //将结果信息放入session中
        session.setAttribute(SysConstants.SJTIPSESSION, msg);
        WebUtil.write(response, "1");
        
    }
    
    /**
     * 关闭例行维护流程
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value="ewCloseWorkFlow.html",method=RequestMethod.GET)
    public ModelAndView ewCloseWorkFlow(HttpServletRequest request,HttpServletResponse response){
        Map<String, String> param = ParamsMapUtil.getParameterMap(request);
        String orderId = param.get("orderId");
        String nodeId = param.get("nodeId");
        String flowId = param.get("flowId");
        ModelAndView view = new ModelAndView("/business/wechat/ewyw/ewHealth/ewCloseWorkFlow");
        return view.addObject("orderId",orderId)
                    .addObject("nodeId",nodeId).addObject("flowId", flowId);
    }
    
    /**
     * 关闭提交
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value="ewCloseWorkFlow.html",method=RequestMethod.POST)
    public void ewCloseWorkFlowSubmit(HttpServletRequest request,HttpServletResponse response){
        ewHealthFacade.doCloseWrokFlow(request);
        WebUtil.write(response, "1");
    }
    
    /**
     * 基本信息(只读)
     * @param model
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("ewHealthDealInfo.html")
    public String ewHealthDealInfo(Model model,HttpServletRequest request, HttpServletResponse response) {
        String orderId = request.getParameter("orderId");
        Map health = healthFacade.getHealthInfo(orderId);
        model.addAttribute("info", health);
        return "/business/wechat/ewyw/ewHealth/ewHealthDealInfo";
    }
    
    /**
     * 工程师提交页面
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("ewEngineerCommit.html")
    public String ewEngineerCommit(Model model,HttpServletRequest request, HttpServletResponse response) {
        String orderId = request.getParameter("orderId");
        String isAdmin = request.getParameter("isAdmin");
        if(isAdmin!=null&&isAdmin.equals("1")){
            List<Map> commonList = healthFacade.getCommonPatrolItem(orderId);
            model.addAttribute("commonList", commonList);
        }
        return "/business/wechat/ewyw/ewHealth/ewEngineerCommit";
    }
    
    /**
     * 获取环节未执行人列表
     * @param request
     * @param response
     */
    @RequestMapping("ewGetNotDealList.html")
    public void ewGetNotDealList(HttpServletRequest request, HttpServletResponse response){
        String flowId = request.getParameter("flowId");
        List<Map> list = workFlowSupportService.getNotDealList(flowId);
        WebUtil.write(response, JsonUtil.list2Json(list));
    }
    
    /**
     * 保存工程师巡检信息
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("doEngineerPatrol.html")
    public String doEngineerPatrol(HttpServletRequest request, HttpServletResponse response) {
        Map msg = ewHealthFacade.doSendToManager(request);
        String flowId = request.getParameter("flowId");
        String nodeId = request.getParameter("nodeId");
        Map user = WebUtil.getWywEngineerLoginUser(request);
        String userId= ConvertUtil.obj2Str(user.get("ID"));
        String userName=ConvertUtil.obj2Str(user.get("ZSXM"));
        GG_RECORD record = new GG_RECORD();
        record.setDeal_content("工程师巡检:"+userName+"进行了巡检");
        record.setDeal_time(DateUtil.getCurrentDate14());
        record.setDeal_user_id(userId);
        record.setDeal_user_name(userName);
        record.setBusiness_id(flowId);
        record.setNode_id(nodeId);
        recordService.addRecord(record);
        
        //将结果信息放入session中
        request.getSession().setAttribute(SysConstants.SJTIPSESSION, msg);
        return "redirect:/ewyw/ewIncident/ewoption.html?wt=3";  
        
    }
    
    /**
     * 项目经理审批提交页面
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("ewApproveCommit.html")
    public String ewApproveCommit(HttpServletRequest request, HttpServletResponse response) {
        return "business/wechat/ewyw/ewHealth/ewApproveCommit";
    }
    /**
     * 结束流程
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("doEndHealthFlow.html")
    public void doEndHealthFlow(HttpServletRequest request, HttpServletResponse response) {
        ewHealthFacade.doEndHealthFlow(request);
        String flowId = request.getParameter("flowId");
        String nodeId = request.getParameter("nodeId");
        Map user = WebUtil.getWywEngineerLoginUser(request);
        String userId= ConvertUtil.obj2Str(user.get("ID"));
        String userName=ConvertUtil.obj2Str(user.get("ZSXM"));
        GG_RECORD record = new GG_RECORD();
        record.setDeal_content("流程结束:"+userName+"进行了巡检审核");
        record.setDeal_time(DateUtil.getCurrentDate14());
        record.setDeal_user_id(userId);
        record.setDeal_user_name(userName);
        record.setBusiness_id(flowId);
        record.setNode_id(nodeId);
        recordService.addRecord(record);
        
        Map msg = new HashMap();
        msg.put("result", "1");
        //将结果信息放入session中
        request.getSession().setAttribute(SysConstants.SJTIPSESSION, msg);
        WebUtil.write(response, "1");
    }
    
    /**
     * 回退
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value="ewHealthSendback.html",method=RequestMethod.GET)
    public ModelAndView ewHealthSendback(HttpServletRequest request,HttpServletResponse response){
        ModelAndView view = new ModelAndView("/business/wechat/ewyw/ewHealth/ewHealthSendback");
        String orderId = request.getParameter("orderId");
        String nodeId = request.getParameter("nodeId");
        String flowId = request.getParameter("flowId");
        String lastNodeTemplateId = "";
        lastNodeTemplateId = Constants.HEALTH_PATROL;
        view.addObject("lastNodeTemplateId",lastNodeTemplateId);
        view.addObject("orderId",orderId);
        view.addObject("flowId",flowId);
        view.addObject("nodeId",nodeId);
        
        return view;
    }
    
    /**
     * 回退提交
     * */
    @RequestMapping(value="ewHealthSendback.html",method=RequestMethod.POST)
    public void doHealthSendback(HttpServletRequest request,HttpServletResponse response){
        Map msg = ewHealthFacade.doSendback(request);
        String flowId = request.getParameter("flowId");
        String nodeId = request.getParameter("nodeId");
        Map user = WebUtil.getWywEngineerLoginUser(request);
        String userId= ConvertUtil.obj2Str(user.get("ID"));
        String userName=ConvertUtil.obj2Str(user.get("ZSXM"));
        GG_RECORD record = new GG_RECORD();
        record.setDeal_content("回退:"+userName+"进行了回退操作");
        record.setDeal_time(DateUtil.getCurrentDate14());
        record.setDeal_user_id(userId);
        record.setDeal_user_name(userName);
        record.setBusiness_id(flowId);
        record.setNode_id(nodeId);
        recordService.addRecord(record);
        
        request.getSession().setAttribute(SysConstants.SJTIPSESSION, msg);
        WebUtil.write(response, "1");
    }
    
    /**
     * 跳转到巡检配置页面
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("ewHealthCiList.html")
    public ModelAndView ewHealthCiList(HttpServletRequest request,HttpServletResponse response) {
        ModelAndView view = new ModelAndView("/business/wechat/ewyw/ewHealth/ewHealthCiList");
        String orderId = request.getParameter("orderId");
        List<Map> nodeList = healthFacade.getCiPatrolItem(orderId);
        view.addObject("orderId",orderId);
        view.addObject("nodeList", nodeList);
        return view;
    }
    
    /**
     * 跳转到巡检配置页面(进行中)
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("ewHealthCiListCl.html")
    public ModelAndView ewHealthCiListCl(HttpServletRequest request,HttpServletResponse response) {
        ModelAndView view = new ModelAndView("/business/wechat/ewyw/ewHealth/ewHealthCiListCl");
        String orderId = request.getParameter("orderId");
        String nodeTemplateId = request.getParameter("nodeTemplateId");
        //基本信息
        if(StringUtil.isNotBlank(orderId)){
            Map health = healthFacade.getHealthInfo(orderId);
            view.addObject("info",health);
        }
        //需要查询设备peikezhan
        List<Map> ciList = healthFacade.getPatrolCiList(orderId);
        //查询该工单下的指标list
        List<Map> itemList = healthFacade.getPatrolIteamsList(orderId);
        //拼装设备和指标tree
        TreeUtil treeUtil = new TreeUtil();
        List treelist=treeUtil.createTreeByCate(ciList, itemList);
        
        view.addObject("orderId",orderId);
        view.addObject("flowId", request.getParameter("flowId"));
        view.addObject("nodeId", request.getParameter("nodeId"));
        view.addObject("nodeTemplateId", nodeTemplateId);
        //不同节点显示不同数据
        view.addObject("ciList",treelist);
        List<Map> nodeList = healthFacade.getCiPatrolItem(orderId);
        view.addObject("nodeList", nodeList);
        return view;
    }
    
    /**
     * 跳转到增加巡检设备页面
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value="ewAddCiDialog.html",method=RequestMethod.GET)
    public ModelAndView ewAddCiDialog(HttpServletRequest request, HttpServletResponse response) {
        ModelAndView view = new ModelAndView("/business/wechat/ewyw/ewHealth/ewAddCiDialog");
        //查询设备
        List<Map> ciList = healthFacade.getHealthCiList(request);
        //查询该客户的所有可选item进行匹配
        List<Map> itemsList=healthFacade.getAllItemOfCus(request);
        TreeUtil treeUtil = new TreeUtil();
        List treeList=treeUtil.createTreeByLvlId(ciList, itemsList);
        view.addObject("ciList",treeList);
        view.addObject("orderId", request.getParameter("orderId"));
        view.addObject("ciIds", request.getParameter("ciIds"));
        view.addObject("items", request.getParameter("items"));
        return view;
    }
    
    @RequestMapping(value="ewAddCiDialog.html",method=RequestMethod.POST)
    public void ewAddCiDialogSave(HttpServletRequest request, HttpServletResponse response) {
        String orderId = request.getParameter("orderId");
        String[] ciIdAry = request.getParameter("cilist").split(",");
        String items = request.getParameter("items");
        List itemlist = JsonUtil.json2List(items);
        //添加巡检设备和指标(edit by peikezhan 2016.07.14)
        HealthFacade impl = new HealthFacadeImpl();
        ewHealthFacade.addPatrolCi(orderId,ciIdAry,itemlist);
        WebUtil.write(response, "1");
    }
    
    /**
     * 查询设备下的item
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("ewSelectItem.html")
    public ModelAndView selectItem(HttpServletRequest request, HttpServletResponse response) {
        Map<String, String> params = ParamsMapUtil.getParameterMap(request);
        ModelAndView view = new ModelAndView("/business/wechat/ewyw/ewHealth/ewSelectItem");
        //查询该客户的所有可选item进行匹配
        Map itemMap=healthFacade.getAllItemOfDevice(params);
        view.addObject("itemMap",itemMap);
        
        //所有配置及指标信息,为了隐藏显示
            String orderId = request.getParameter("orderId");
            //基本信息
            if(StringUtil.isNotBlank(orderId)){
                Map health = healthFacade.getHealthInfo(orderId);
                view.addObject("info",health);
            }
            //需要查询设备peikezhan
            List<Map> ciList = healthFacade.getPatrolCiList(orderId);
            //查询该工单下的指标list
            List<Map> itemList = healthFacade.getPatrolIteamsList(orderId);
            //拼装设备和指标tree
            TreeUtil treeUtil = new TreeUtil();
            List treelist=treeUtil.createTreeByCate(ciList, itemList);
            view.addObject("orderId",orderId);
            view.addObject("ciList",treelist);
        return view;
    }
    
    /**
     * 工程师设备巡检(填写备注)
     * @param model
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value="ewHealthCiPatrol.html",method=RequestMethod.GET)
    public String ewHealthCiPatrol(Model model,HttpServletRequest request, HttpServletResponse response) {
        String patrolCiId = request.getParameter("patrolCiId");
        SC_WORKFLOW_CI_HEALTH_CIDETAIL info = new SC_WORKFLOW_CI_HEALTH_CIDETAIL(patrolCiId).getInstanceById();
        model.addAttribute("info", info);
        model.addAttribute("patrolCiId", patrolCiId);
        model.addAttribute("orderId", request.getParameter("orderId"));
        return "/business/wechat/ewyw/ewHealth/ewHealthCiPatrol";
    }
    @RequestMapping(value="ewHealthCiPatrol.html",method=RequestMethod.POST)
    public void doHealthCiPatrol(SC_WORKFLOW_CI_HEALTH_CIDETAIL ciItem,HttpServletRequest request, HttpServletResponse response) {
        String patrolCiId = request.getParameter("patrolCiId");
        
        Map user =     WebUtil.getWywEngineerLoginUser(request);
        ciItem.setId(patrolCiId)
            .setUser_id(user.get("ID").toString())
            .setUser_name(user.get("ZSXM").toString())
            .update();
        WebUtil.write(response, "1");
    }
    
    /**
     *工程师指标巡检
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value="ewHealthItemPatrol.html",method=RequestMethod.GET)
    public String ewHealthItemPatrol(Model model,HttpServletRequest request, HttpServletResponse response) {
        String patrolItemId = request.getParameter("patrolItemId");
        String orderId = request.getParameter("orderId");
        Map info = healthFacade.getPatrolItemInfo(patrolItemId);
        model.addAttribute("info", info);
        model.addAttribute("patrolItemId", patrolItemId);
        model.addAttribute("orderId", orderId);
        return "/business/wechat/ewyw/ewHealth/ewHealthItemPatrol";
    }
    /**
     * 工程师指标巡检
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value="ewHealthItemPatrol.html",method=RequestMethod.POST)
    public void doHealthItemPatrol(SC_WORKFLOW_ITEM_HEALTH_CIDETAIL ciItem,HttpServletRequest request, HttpServletResponse response) {
        String patrolItemId = request.getParameter("patrolItemId");
        
        Map user =     WebUtil.getWywEngineerLoginUser(request);
        ciItem.setId(patrolItemId)
            .setUser_id(user.get("ID").toString())
            .setUser_name(user.get("ZSXM").toString())
            .update();
        WebUtil.write(response, "1");
    }
    
    /**
     *工程师指标巡检详情
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value="ewHealthItemPatrolRead.html",method=RequestMethod.GET)
    public String ewHealthItemPatrolRead(Model model,HttpServletRequest request, HttpServletResponse response) {
        String patrolItemId = request.getParameter("patrolItemId");
        Map info = healthFacade.getPatrolItemInfo(patrolItemId);
        model.addAttribute("info", info);
        return "/business/wechat/ewyw/ewHealth/ewHealthItemPatrolRead";
    }
    /**
     *工程师配置巡检详情
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value="ewHealthCiPatrolRead.html",method=RequestMethod.GET)
    public String healthCiPatrolRead(Model model,HttpServletRequest request, HttpServletResponse response) {
        String patrolCiId = request.getParameter("patrolCiId");
        SC_WORKFLOW_CI_HEALTH_CIDETAIL info = new SC_WORKFLOW_CI_HEALTH_CIDETAIL(patrolCiId).getInstanceById();
        model.addAttribute("info", info);
        return "/business/wechat/ewyw/ewHealth/ewHealthCiPatrolRead";
    }
    
    /**
     * 健康检查工单响应
     * @param request
     * @param response
     */
    @RequestMapping("answerHealth.html")
    public void answerHealth(HttpServletRequest request,HttpServletResponse response) {
        String result = ewHealthFacade.doOrderConfirm(request);
        WebUtil.write(response, result);
    }
    /**
     * 跳转到我的健康检查日历页面
     */
    @RequestMapping("ewMyHealthCheck.html")
    public String ewMyHealthCheck(Model model,HttpServletRequest request) {
        
        //查询当前年前五年和后五年
        int year = DateUtil.getYear();
        List years = new ArrayList();
        for(int i=5; i>=0; i--) {
            int preYear = year-i;
            years.add(preYear);
        }
        
        for(int i=1; i<5; i++) {
            int nextYear = year+i;
            years.add(nextYear);
        }
        
        model.addAttribute("years", years);
        
        model.addAttribute("year", DateUtil.getToday("yyyy"));
        model.addAttribute("month", DateUtil.getToday("MM"));
        
        List months = new ArrayList();
        for(int i=1; i<=12; i++) {
            if(i<10) {
                months.add("0"+i);
            } else {
                months.add(i);
            }
        }
        model.addAttribute("months", months);
        return "/business/wechat/ewyw/ewHealth/ewMyHealthCheck";
    }
    /**
     * 查询健康检查日历
     */
    @SuppressWarnings("unchecked")
    @RequestMapping("ewMyHealthCal.html")
    public String eMyDailyCal(Model model,HttpServletRequest request,HttpServletResponse response) {
        
        String year = request.getParameter("year");
        String month = request.getParameter("month");
        
        Map result = ewHealthFacade.queryHealthCalandar(request);
        List list = (List)result.get("monthDays");
        List weekDays = (List)result.get("weekDays");
        model.addAttribute("calandars", list);
        model.addAttribute("weeks", weekDays);
        
        
        Long[] dates = DateUtil.getDateFromMonth(ConvertUtil.obj2Int(year),ConvertUtil.obj2Int(month));
        List<Map> healths  = ewHealthFacade.ewMyHealthData(request);
        model.addAttribute("orderList", healths);
        return "/business/wechat/ewyw/ewHealth/ewMyHealthCal";
    }
    /**
     * 根据日期获取我的例行维护列表
     * @author chenlong
     * @param model
     * @param request
     * @return
     */
    @RequestMapping("ewMyHealthByDate.html")    
    public String ewMyHealthByDate(Model model,HttpServletRequest request){
        initProSelector(model,request);
        return "/business/wechat/ewyw/ewHealth/ewMyHealthByDate";
    }
    /**
     * 根据日期获取所有例行维护列表
     * @author chenlong
     * @param model
     * @param request
     * @return
     */
    @RequestMapping("ewHealthByDate.html")
    public String ewHealthByDate(Model model,HttpServletRequest request){
        initProSelector(model,request);
        return "/business/wechat/ewyw/ewHealth/ewHealthByDate";
    }
    
    /**
     * 初始化项目选择下拉框
     * @author chenlong
     * @param model
     * @param request
     */
    private void initProSelector(Model model,HttpServletRequest request){
        //客户列表
        List<Map> customers = incidentFacade.getCustomerList();    
        model.addAttribute("customers",customers);
    }
    /**
     * 健康检查报告
     * @author chenlong
     * @param model
     * @param request
     * @return
     */
    @RequestMapping("ewHealthReport.html")
    public String ewHealthReport(Model model,HttpServletRequest request){
        String orderId = request.getParameter("orderId");
        String flowId = request.getParameter("flowId");
        Map healthInfo = healthFacade.getHealthReportInfo(orderId,flowId);
        model.addAttribute("healthInfo", healthInfo);
        return "/business/wechat/ewyw/ewHealth/ewHealthReport";
    }
    //*********************************************运维管理******************************************************
    /**
     * 跳转到所有健康检查工单页面
     */
    @RequestMapping("ewHealth.html")
    public ModelAndView ewHealth(HttpServletRequest request,HttpServletResponse response) {
        ModelAndView modelAndView = new ModelAndView("/business/wechat/ewyw/ewHealth/ewHealth");
        //查询工单状态
        Map<String, String> state = Constants.mapWORKFLOW_BASE_WFSTATE_PART;
        List status = new ArrayList();
        for (Map.Entry<String, String> entry : state.entrySet()) {  
            String key = entry.getKey();
            String value = entry.getValue();
            Map map = new HashMap();
            map.put("state", key);
            map.put("stateName", value);
            status.add(map);
        }
        //查询健康检查所有环节
        Map<String, String> node = Constants.healthNode;
        List nodes = new ArrayList();
        for (Map.Entry<String, String> entry : node.entrySet()) {  
            String key = entry.getKey();
            String value = entry.getValue();
            Map map = new HashMap();
            map.put("nodeId", key);
            map.put("nodeName", value);
            nodes.add(map);
        }
        modelAndView.addObject("nodes", nodes);
        modelAndView.addObject("status", status);
        return modelAndView;
    }
    
    
    /**
     * 查询工单列表
     */
    @RequestMapping(value="ewHealthData.html",method=RequestMethod.POST)
    public ModelAndView eHealthData(HttpServletRequest request) {
        ModelAndView modelAndView = new ModelAndView("/business/wechat/ewyw/ewHealth/ewHealthData");
        List list = ewHealthFacade.ewHealthData(request);
        modelAndView.addObject("orderList", list);
        String flowstate = request.getParameter("flowstate");
        modelAndView.addObject("flowstate", flowstate);
        return modelAndView;
    }
    
    /**
     * 查询工单总数量
     */
    @RequestMapping(value="ewHealthCount.html",method=RequestMethod.POST)
    public void eHealthCount(HttpServletRequest request,HttpServletResponse response) {
        int count = ewHealthFacade.ewHealthCount(request);
        WebUtil.write(response, String.valueOf(count));
    }
     /**
     * 跳转到健康检查日历页面
     */
    @RequestMapping("ewHealthCheck.html")
    public String ewHealthCheck(Model model,HttpServletRequest request) {
        
        //查询当前年前五年和后五年
        int year = DateUtil.getYear();
        List years = new ArrayList();
        for(int i=5; i>=0; i--) {
            int preYear = year-i;
            years.add(preYear);
        }
        
        for(int i=1; i<5; i++) {
            int nextYear = year+i;
            years.add(nextYear);
        }
        
        model.addAttribute("years", years);
        
        model.addAttribute("year", DateUtil.getToday("yyyy"));
        model.addAttribute("month", DateUtil.getToday("MM"));
        
        List months = new ArrayList();
        for(int i=1; i<=12; i++) {
            if(i<10) {
                months.add("0"+i);
            } else {
                months.add(i);
            }
        }
        model.addAttribute("months", months);
        return "/business/wechat/ewyw/ewHealth/ewHealthCheck";
    }
    /**
     * 查询健康检查日历
     */
    @RequestMapping("ewHealthCal.html")
    public String ewHealthCal(Model model,HttpServletRequest request,HttpServletResponse response) {
        
        String year = request.getParameter("year");
        String month = request.getParameter("month");
        
        Map result = ewHealthFacade.queryHealthCalandar(request);
        List list = (List)result.get("monthDays");
        List weekDays = (List)result.get("weekDays");
        model.addAttribute("calandars", list);
        model.addAttribute("weeks", weekDays);
        
        
        Long[] dates = DateUtil.getDateFromMonth(ConvertUtil.obj2Int(year),ConvertUtil.obj2Int(month));
        List<Map> healths  = ewHealthFacade.ewHealthData(request);
        model.addAttribute("orderList", healths);
        return "/business/wechat/ewyw/ewHealth/ewHealthCal";
    }
    /**
     * 查询关联设备
     */
    @RequestMapping("ewLinkDevice.html")
    public ModelAndView ewLinkDevice(HttpServletRequest request) {
        ModelAndView modelAndView = new ModelAndView("/business/wechat/ewyw/ewIncident/ewLinkDevice");
        String flowId = request.getParameter("flowId");
        List devices = ewHealthFacade.queryDevices(flowId);
        modelAndView.addObject("devices", devices);
        return modelAndView;
    }
}