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
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.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
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.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
 
import cn.ksource.beans.SC_WORKFLOW_INCIDENT;
import cn.ksource.beans.SC_WORKFLOW_INCIDENT_LOCAL;
import cn.ksource.core.dao.SqlParameter;
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.SysInfoMsg;
import cn.ksource.core.web.WebUtil;
import cn.ksource.web.Constants;
import cn.ksource.web.SysConstants;
import cn.ksource.web.facade.wechat.ewyw.EwZcFacade;
import cn.ksource.web.facade.zc.ZcywFacade;
import cn.ksource.web.service.DataDictionaryService;
 
@Controller
@RequestMapping("/ewyw/ewzc")
public class EwZcController {
 
    @Resource(name="ewZcFacade")
    private EwZcFacade ewZcFacade;
    
    @Autowired
    private DataDictionaryService dataDictionaryService;
    
    @Resource(name="zcywFacade")
    private ZcywFacade zcywFacade;
    
    @RequestMapping("ewMyzc.html")
    public ModelAndView ewMyzc(HttpServletRequest request) {
        ModelAndView modelAndView = new ModelAndView("/business/wechat/ewyw/ewzc/ewMyzc");
        
        //查询工单状态
        Map<String, String> state = Constants.mapWORKFLOW_BASE_WFSTATE;
        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="ewMyZcData.html",method=RequestMethod.POST)
    public ModelAndView ewMyZcData(HttpServletRequest request,PageInfo pageInfo) {
        ModelAndView modelAndView = new ModelAndView("/business/wechat/ewyw/ewzc/ewMyZcData");
        Map<String, String> params = ParamsMapUtil.getParameterMap(request);
        params.put("userId", WebUtil.getEngineerUserId(request));
        String flowstate = params.get("flowstate");
        if("end".equals(flowstate)||"close".equals(flowstate)){
            if("end".equals(flowstate)){
                params.put("status", "2");
            }else{
                params.put("status", "3");
            }
        }
        PageInfo list = zcywFacade.queryMyZcywData(pageInfo,params);
        modelAndView.addObject("orderList", list);
        
        modelAndView.addObject("flowstate", flowstate);
        return modelAndView;
    }
    
    /**
     * 查询我的事件工单总数量
     */
    @RequestMapping(value="ewMyZcCount.html",method=RequestMethod.POST)
    public void ewMyZcCount(HttpServletRequest request,HttpServletResponse response) {
        Map<String, String> params = ParamsMapUtil.getParameterMap(request);
        params.put("userId", WebUtil.getEngineerUserId(request));
        String flowstate = params.get("flowstate");
        if("end".equals(flowstate)||"close".equals(flowstate)){
            if("end".equals(flowstate)){
                params.put("status", "2");
            }else{
                params.put("status", "3");
            }
        }
        int count = zcywFacade.queryMyZcywCount(params);
        WebUtil.write(response, String.valueOf(count));
    }
    
    /**
     * 驻场事件工单响应
     * @param request
     * @param response
     */
    @RequestMapping("answerZc.html")
    public void answerZc(HttpServletRequest request,HttpServletResponse response) {
        Map<String, String> params = ParamsMapUtil.getParameterMap(request);
        Map user = WebUtil.getEngineerMsg(request);
        params.put("ID", ConvertUtil.obj2StrBlank(user.get("ID")));
        params.put("ZSXM", ConvertUtil.obj2StrBlank(user.get("ZSXM")));
        String result = ewZcFacade.doOrderConfirm(params);
        WebUtil.write(response, result);
    }
    /**
     * 事件工单详情
     */
    @RequestMapping("ewZcInfoCl.html")
    public ModelAndView ewZcInfoCl(HttpServletRequest request,HttpServletResponse response) {
        ModelAndView modelAndView = new ModelAndView("/business/wechat/ewyw/ewzc/ewZcInfoCl");
        
        //查询事件基本信息
        String orderId = request.getParameter("orderId");
        String flowId = new String();
        if(StringUtil.notEmpty(orderId)) {
            SC_WORKFLOW_INCIDENT_LOCAL incident = new SC_WORKFLOW_INCIDENT_LOCAL(orderId).getInstanceById();
            flowId = incident.getFlow_id();
        }
        
        //通过工单编号查询工单基本信息
        Map baseMsg = zcywFacade.queryIncidentLocalBaseMsg(orderId);
        
        modelAndView.addObject("baseMsg", baseMsg);
        modelAndView.addObject("orderId", orderId);
        modelAndView.addObject("flowId", flowId);
        
        return modelAndView;
    }
    
    /**
     * 事件工单详情
     */
    @RequestMapping("ewZcInfo.html")
    public ModelAndView ewZcInfo(HttpServletRequest request,HttpServletResponse response) {
        ModelAndView modelAndView = new ModelAndView("/business/wechat/ewyw/ewzc/ewZcInfo");
        
        //查询事件基本信息
        String orderId = request.getParameter("orderId");
        String flowId = new String();
        if(StringUtil.notEmpty(orderId)) {
            SC_WORKFLOW_INCIDENT_LOCAL incident = new SC_WORKFLOW_INCIDENT_LOCAL(orderId).getInstanceById();
            flowId = incident.getFlow_id();
        }
        
        //通过工单编号查询工单基本信息
        Map baseMsg = zcywFacade.queryIncidentLocalBaseMsg(orderId);
        
        modelAndView.addObject("baseMsg", baseMsg);
        modelAndView.addObject("orderId", orderId);
        modelAndView.addObject("flowId", flowId);
        
        return modelAndView;
    }
    
    /**
     * 跳转到所有事件工单页面
     */
    @RequestMapping("ewzc.html")
    public ModelAndView ewzc(HttpServletRequest request,HttpServletResponse response) {
        ModelAndView modelAndView = new ModelAndView("/business/wechat/ewyw/ewzc/ewzc");
        //查询工单状态
        Map<String, String> state = Constants.mapWORKFLOW_BASE_WFSTATE;
        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);
        
        //查询该加盟商的事件优先级
        List<Map> eventPri = dataDictionaryService.getDataDictionaryByCategoryKey(Constants.EVENT_PRI);
        modelAndView.addObject("eventPri", eventPri);
        return modelAndView;
    }
    
    /**
     * 查询我的事件工单列表
     */
    @RequestMapping(value="ewZcData.html",method=RequestMethod.POST)
    public ModelAndView ewZcData(HttpServletRequest request,PageInfo pageInfo) {
        ModelAndView modelAndView = new ModelAndView("/business/wechat/ewyw/ewzc/ewZcData");
        Map<String, String> params = ParamsMapUtil.getParameterMap(request);
        PageInfo list = ewZcFacade.eZcData(pageInfo,params);
        modelAndView.addObject("orderList", list);
        String flowstate = request.getParameter("flowstate");
        modelAndView.addObject("flowstate", flowstate);
        return modelAndView;
    }
    
    /**
     * 查询我的事件工单总数量
     */
    @RequestMapping(value="ewZcCount.html",method=RequestMethod.POST)
    public void ewZcCount(HttpServletRequest request,HttpServletResponse response) {
        Map<String, String> params = ParamsMapUtil.getParameterMap(request);
        int count = ewZcFacade.eZcCount(params);
        WebUtil.write(response, String.valueOf(count));
    }
    
    /**
     * 工单完成时的驻场运维事件处理报告
     */
    @RequestMapping("ewzcywFinishReport.html")
    public ModelAndView wcReport(HttpServletRequest request) {
        ModelAndView modelAndView = new ModelAndView("/business/wechat/ewyw/ewzc/ewzcywFinishReport");
        String orderId  = request.getParameter("orderId");
        Map report = zcywFacade.queryWcReport(orderId);
        modelAndView.addObject("report", report);
        return modelAndView;
    }
    
    
    /**
     * 工单关闭时的驻场运维事件处理报告
     */
    @RequestMapping("ewzcywCloseReport.html")
    public ModelAndView closeReport(HttpServletRequest request) {
        ModelAndView modelAndView = new ModelAndView("/business/wechat/ewyw/ewzc/ewzcywFinishReport");
        String orderId  = request.getParameter("orderId");
        Map report = zcywFacade.queryCloseReport(orderId);
        modelAndView.addObject("report", report);
        return modelAndView;
    }
    @RequestMapping("ewzcUsers.html")
    public ModelAndView ewzcUsers(HttpServletRequest request){
        ModelAndView view=new ModelAndView("/business/wechat/ewyw/ewzc/ewzcUsers");
        List users = zcywFacade.queryAllZcry(request);
        view.addObject("users", users);
        view.addObject("flowId", request.getParameter("flowId"));
        view.addObject("seltype", request.getParameter("seltype"));
        return view;
    }
    /**
     * 分派任务
     */
    @RequestMapping("zcDispatchTask.html")
    public void zcDispatchTask(HttpServletRequest request,HttpServletResponse response) {
        Map map = zcywFacade.saveDispatchTask(request);
        request.getSession().setAttribute(SysConstants.SJTIPSESSION, map);
        WebUtil.write(response, "1");
    }
    /**
     * 跳转到提示页面
     */
    @RequestMapping("ewZcoption.html")
    public ModelAndView ewZcoption(HttpServletRequest request,HttpServletResponse response) {
        ModelAndView view = new ModelAndView("/business/wechat/ewyw/ewzc/ewZcoption");
        Map resultMap = new HashMap();
        Object obj = request.getSession().getAttribute(SysConstants.SJTIPSESSION);
        if(null!=obj) {
            resultMap = (Map)obj;
            String result = ConvertUtil.obj2StrBlank(resultMap.get("result"));
            String nouser = ConvertUtil.obj2StrBlank(resultMap.get("nouser"));
            
            view.addObject("result", result);
            view.addObject("nouser", nouser);
            SysInfoMsg msg = (SysInfoMsg)resultMap.get("msg");
            view.addObject("msg", msg);
            request.getSession().removeAttribute(SysConstants.SJTIPSESSION);
        }
        
        return view;
    }
    /**
     * 关闭事件
     * 跳转到结束任务页面
     * */
    @RequestMapping(value="ewZcEndTask.html",method=RequestMethod.GET)
    public ModelAndView ewEndTask(HttpServletRequest request) {
        ModelAndView modelAndView = new ModelAndView("/business/wechat/ewyw/ewzc/ewZcEndTask");
        String orderId = request.getParameter("orderId");
        //查询解决方式数据字典
        List reasons = dataDictionaryService.getDataDictionaryByCategoryKey(Constants.RESOLVE_WAY);
        modelAndView.addObject("reasons", reasons);
        modelAndView.addObject("incidentId", orderId);
        return modelAndView;
    }
    /**
     * 结束任务
     * */
    @RequestMapping(value="ewZcEndTask.html",method=RequestMethod.POST)
    public void ewZcEndTask(HttpServletRequest request,HttpServletResponse response) {
        zcywFacade.doEndTask(request);
        String orderId = request.getParameter("incidentId");
        SqlParameter map = new SqlParameter("orderId",orderId).addValue("bustype", Constants.WORKFLOW_BASE_BUSINESS_TYPE_INCIDENT_LOCAL);
        /*ModelAndView modelAndView = new ModelAndView("/business/wechat/ewyw/ewIncident/ewEndTaskLink");
        modelAndView.addObject("orderId", orderId);
        modelAndView.addObject("bustype", Constants.WORKFLOW_BASE_BUSINESS_TYPE_INCIDENT);*/
        map.addValue("result", "1");
        WebUtil.write(response, JsonUtil.map2Json(map));
    }
    /**
     * 跳转到关闭原因界面
     */
    @RequestMapping("ewzcCloseReason.html")
    public ModelAndView ewzcCloseReason(HttpServletRequest request,HttpServletResponse response) {
        ModelAndView modelAndView = new ModelAndView("/business/wechat/ewyw/ewzc/ewzcCloseReason");
        String orderId = request.getParameter("orderId");
        //查询关闭原因数据字典
        List reasons = dataDictionaryService.getDataDictionaryByCategoryKey(Constants.CLOSE_REASON);
        modelAndView.addObject("reasons", reasons);
        modelAndView.addObject("incidentId", orderId);
        return modelAndView;
    }
    
    /**
     * 关闭事件提交
     */
    @RequestMapping(value="ewzcCloseReason.html",method=RequestMethod.POST)
    public void doCloseReason(HttpServletRequest request,HttpServletResponse response) {
        zcywFacade.doCloseReason(request);
        WebUtil.write(response, "1");
    }
    /**
     * 创建事件
     */
    @SuppressWarnings({ "unchecked", "rawtypes" })
    @RequestMapping("ewzcAdd.html")
    public ModelAndView ewAddIncident(HttpServletRequest request) {
        ModelAndView view = new ModelAndView("/business/wechat/ewyw/ewzc/ewzcAdd");
        String add = request.getParameter("add");
        if("1".equals(add)){
            request.getSession().removeAttribute(SysConstants.LOCALSESSION);
        }
        
        //查询出该驻场人员的总客户,和下级客户,项目
        Map result = ewZcFacade.queryZcMsg(request);
        view.addObject("msg", result);
        
        //查询事件类型数据字典
        List<Map> types = dataDictionaryService.getDataDictionaryByCategoryKey(Constants.INCIDENT_TYPE);
        //取得事件类型的第一条数据
        if(null!=types && types.size()>0) {
            Map type = types.get(0);
            view.addObject("typeId", type.get("DATAKEY"));
            view.addObject("typeName", type.get("DATAVALUE"));
        }
        //查询申报方式数据字典
        List<Map> ways = dataDictionaryService.getDataDictionaryByCategoryKey(Constants.INCIDENT_APPLY_TYPE);
        //取得申报方式的第一条数据
        if(null!=ways && ways.size()>0) {
            Map way = ways.get(0);
            view.addObject("wayId", way.get("DATAKEY"));
            view.addObject("wayName", way.get("DATAVALUE"));
        }
        //查询事件来源数据字典
        List<Map> froms = dataDictionaryService.getDataDictionaryByCategoryKey(Constants.INCIDENT_SOURCE);
        //取得事件来源的第一条数据
        if(null!=froms && froms.size()>0) {
            Map from = froms.get(0);
            view.addObject("fromId", from.get("DATAKEY"));
            view.addObject("fromName", from.get("DATAVALUE"));
        }
        
        
        //查询事件影响力
        view.addObject("types", types);
        view.addObject("ways", ways);
        view.addObject("froms", froms);
        Map resultMap = new HashMap();
        resultMap.put("happen_time",  DateUtil.getCurrentDate14());
        Object obj = request.getSession().getAttribute(SysConstants.LOCALSESSION);
        if(null!=obj) {
            resultMap = (Map)obj;
        }
        
        String customerId=ConvertUtil.obj2Str(result.get("customerId"));
        String customerName=ConvertUtil.obj2Str(result.get("customerName"));
        String subCustomerId=ConvertUtil.obj2Str(result.get("subCustomerId"));
        String subCustomerName=ConvertUtil.obj2Str(result.get("subCustomerName"));
        resultMap.put("customer_id", customerId);
        resultMap.put("customer_name", customerName);
        if(StringUtil.isEmpty(subCustomerId)){
            resultMap.put("sub_customer_id", customerId);
            resultMap.put("sub_customer_name", customerName);
        }else{
            resultMap.put("sub_customer_id", subCustomerId);
            resultMap.put("sub_customer_name", subCustomerName);
        }
        
        view.addObject("resultMap", resultMap);
        Map selectMap = new HashMap();
        Object obj1 = request.getSession().getAttribute(SysConstants.SELECTUSERSESSION);
        if(null!=obj) {
            selectMap = (Map)obj1;
        }
        view.addObject("selectMap", selectMap);
        return view;
    }
    /**
     * 保存事件信息
     */
    @SuppressWarnings("unchecked")
    @RequestMapping("savetempLocal.html")
    public void savetempincident(HttpServletRequest request,HttpServletResponse response) {
        String name = request.getParameter("name");
        String repair = request.getParameter("repair");
        String descrip = request.getParameter("descrip");
        String contact_phone = request.getParameter("contact_phone");
        String contact_name = request.getParameter("contact_name");
        String keshi = request.getParameter("keshi");
        String apply_type_id = request.getParameter("apply_type_id");
        String type_id = request.getParameter("type_id");
        String source_id = request.getParameter("source_id");
        String happen_time = request.getParameter("happen_time");
        String[] devices = request.getParameterValues("devices");
        List<Map> deviceList = new ArrayList<Map>();
        if(devices != null){
            if(devices.length  > 0){
                for(int i=0;i<devices.length;i++){
                    if(!StringUtil.isEmpty(devices[i])){
                        String[] devicemap = devices[i].split("&");
                        Map map = new HashMap();
                        map.put("deivceId", devicemap[0]);
                        map.put("searchcode", devicemap[1]);
                        map.put("ciname", devicemap[2]);
                        map.put("position", devicemap[3]);
                        map.put("lv_name", devicemap[4]);
                        deviceList.add(map);
                    }
                    
                }
            }
        }
        
        
        String[] orders = request.getParameterValues("orders");
        List<Map> orderList = new ArrayList<Map>();
        if(orders != null){
            if(orders.length > 0){
                for(int i=0;i<orders.length;i++){
                    if(!StringUtil.isEmpty(orders[i])){
                        String[] ordermap = orders[i].split("&");
                        Map map = new HashMap();
                        map.put("orderId", ordermap[0]);
                        map.put("businesstype", ordermap[1]);
                        map.put("order_code", ordermap[2]);
                        map.put("wfname", ordermap[3]);
                        map.put("customer_name", ordermap[4]);
                        map.put("createtime", ordermap[5]);
                        map.put("creatername", ordermap[6]);
                        orderList.add(map);
                    }
                    
                }
            }
        }
        
        Map resultMap = new HashMap();
        Object obj = request.getSession().getAttribute(SysConstants.LOCALSESSION);
        if(null!=obj) {
            resultMap = (Map)obj;
            resultMap.put("name", name);
            resultMap.put("descrip", descrip);
            resultMap.put("contact_phone", contact_phone);
            resultMap.put("contact_name", contact_name);
            resultMap.put("keshi", keshi);
            resultMap.put("apply_type_id", apply_type_id);
            resultMap.put("apply_type_name", dataDictionaryService.getDataDictionaryByKey(apply_type_id).get("DATAVALUE"));
            
            resultMap.put("type_id", type_id);
            resultMap.put("type_name", dataDictionaryService.getDataDictionaryByKey(type_id).get("DATAVALUE"));
            resultMap.put("source_id", source_id);
            resultMap.put("source_name", dataDictionaryService.getDataDictionaryByKey(source_id).get("DATAVALUE"));
            resultMap.put("happen_time", happen_time);
            resultMap.put("repair", repair);
            
            resultMap.put("deviceList", deviceList);
            resultMap.put("orderList", orderList);
            request.getSession().setAttribute(SysConstants.LOCALSESSION, resultMap);
        }else{
            resultMap.put("name", name);
            resultMap.put("descrip", descrip);
            resultMap.put("contact_phone", contact_phone);
            resultMap.put("contact_name", contact_name);
            resultMap.put("keshi", keshi);
            resultMap.put("apply_type_id", apply_type_id);
            resultMap.put("apply_type_name", dataDictionaryService.getDataDictionaryByKey(apply_type_id).get("DATAVALUE"));
            
            resultMap.put("type_id", type_id);
            resultMap.put("type_name", dataDictionaryService.getDataDictionaryByKey(type_id).get("DATAVALUE"));
            resultMap.put("source_id", source_id);
            resultMap.put("source_name", dataDictionaryService.getDataDictionaryByKey(source_id).get("DATAVALUE"));
            resultMap.put("happen_time", happen_time);
            resultMap.put("repair", repair);
            resultMap.put("deviceList", deviceList);
            resultMap.put("orderList", orderList);
            request.getSession().setAttribute(SysConstants.LOCALSESSION, resultMap);
        }
        WebUtil.write(response, "1");
    }
    /**
     * 驻场创建事件提交
     * @param request
     * @param response
     * @return
     */
    @SuppressWarnings({ "unchecked", "rawtypes" })
    @RequestMapping(value="saveLocal.html", method=RequestMethod.POST)
    public void saveLocal(HttpServletRequest request, HttpServletResponse response,SC_WORKFLOW_INCIDENT_LOCAL sc_workflow_incident_local) {
        Object obj = request.getSession().getAttribute(SysConstants.LOCALSESSION);
        if(null!=obj){
            Map map=(Map)obj;
            sc_workflow_incident_local=localEntity(map, sc_workflow_incident_local);
//            resultMap.put("deviceList", deviceList);
            String deviceLists=ConvertUtil.obj2Str(map.get("deviceList"));
            if(StringUtil.notEmpty(deviceLists)){
                List<Map> deviceList=(List<Map>)(map.get("deviceList"));
                String str="";
                for(Map mapa:deviceList){
                    str+=ConvertUtil.obj2Str(mapa.get("deivceId"))+",";
                }
                map.put("deviceId", str);
            }else{
                map.put("deviceId", "");
            }
            
            String orderLists=ConvertUtil.obj2Str(map.get("orderList"));
            if(StringUtil.notEmpty(orderLists)){
                List<Map> orderList=(List<Map>)(map.get("orderList"));
                String str="";
                for(Map mapb:orderList){
                    str+=ConvertUtil.obj2Str(mapb.get("orderId"))+",";
                }
                map.put("orderId", str);
            }else{
                map.put("orderId", "");
            }
//            resultMap.put("orderList", orderList);
            Map resulta = ewZcFacade.queryZcMsg(request);
            String customerId=ConvertUtil.obj2Str(resulta.get("customerId"));
            String customerName=ConvertUtil.obj2Str(resulta.get("customerName"));
            String subCustomerId=ConvertUtil.obj2Str(resulta.get("subCustomerId"));
            String subCustomerName=ConvertUtil.obj2Str(resulta.get("subCustomerName"));
            sc_workflow_incident_local.setCustomer_id(customerId);
            sc_workflow_incident_local.setCustomer_name(customerName);
            if(StringUtil.isEmpty(subCustomerId)){
                sc_workflow_incident_local.setSub_customer_id(customerId);
                sc_workflow_incident_local.setSub_customer_name(customerName);
            }else{
                sc_workflow_incident_local.setSub_customer_id(subCustomerId);
                sc_workflow_incident_local.setSub_customer_name(subCustomerName);
            }
            
            map.put("type", "1");
            
            Map result = ewZcFacade.saveZcyw(map, request, sc_workflow_incident_local);
            String incidentId = ConvertUtil.obj2StrBlank(result.get("incidentId"));
            SysInfoMsg mapc=new SysInfoMsg();
            String selectUser = request.getParameter("userMsg");
            if(StringUtil.notEmpty(selectUser)) {
                String[] userMsg = selectUser.split("-");
                if(userMsg.length==2) {
                    mapc.setDealUserName(userMsg[1]);
                }
            } 
            result.put("msg", mapc);
            request.getSession().setAttribute(SysConstants.SJTIPSESSION, result);
            request.getSession().removeAttribute(SysConstants.LOCALSESSION);
            request.getSession().removeAttribute(SysConstants.SELECTUSERSESSION);
            WebUtil.write(response, incidentId);
        }else{
            WebUtil.write(response, "");
        }
    }
    
    /**
     * 关闭事件
     * 跳转到结束任务页面
     * */
    @RequestMapping(value="ewzcSolution.html",method=RequestMethod.GET)
    public ModelAndView ewzcSolution(HttpServletRequest request) {
        ModelAndView modelAndView = new ModelAndView("/business/wechat/ewyw/ewzc/ewzcSolution");
        List reasons = dataDictionaryService.getDataDictionaryByCategoryKey(Constants.RESOLVE_WAY);
        modelAndView.addObject("reasons", reasons);
        return modelAndView;
    }
    /**
     * 驻场创建事件提交并解决
     * @param request
     * @param response
     * @return
     */
    @SuppressWarnings({ "unchecked", "rawtypes" })
    @RequestMapping(value="saveLocalSolution.html", method=RequestMethod.POST)
    public void saveLocalSolution(HttpServletRequest request, HttpServletResponse response,SC_WORKFLOW_INCIDENT_LOCAL sc_workflow_incident_local) {
        Object obj = request.getSession().getAttribute(SysConstants.LOCALSESSION);
        if(null!=obj){
            Map map=(Map)obj;
            sc_workflow_incident_local=localEntity(map, sc_workflow_incident_local);
//            resultMap.put("deviceList", deviceList);
            String deviceLists=ConvertUtil.obj2Str(map.get("deviceList"));
            if(StringUtil.notEmpty(deviceLists)){
                List<Map> deviceList=(List<Map>)(map.get("deviceList"));
                String str="";
                for(Map mapa:deviceList){
                    str+=ConvertUtil.obj2Str(mapa.get("deivceId"))+",";
                }
                map.put("deviceId", str);
            }else{
                map.put("deviceId", "");
            }
            
            String orderLists=ConvertUtil.obj2Str(map.get("orderList"));
            if(StringUtil.notEmpty(orderLists)){
                List<Map> orderList=(List<Map>)(map.get("orderList"));
                String str="";
                for(Map mapb:orderList){
                    str+=ConvertUtil.obj2Str(mapb.get("orderId"))+",";
                }
                map.put("orderId", str);
            }else{
                map.put("orderId", "");
            }
//            resultMap.put("orderList", orderList);
            Map resulta = ewZcFacade.queryZcMsg(request);
            String customerId=ConvertUtil.obj2Str(resulta.get("customerId"));
            String customerName=ConvertUtil.obj2Str(resulta.get("customerName"));
            String subCustomerId=ConvertUtil.obj2Str(resulta.get("subCustomerId"));
            String subCustomerName=ConvertUtil.obj2Str(resulta.get("subCustomerName"));
            sc_workflow_incident_local.setCustomer_id(customerId);
            sc_workflow_incident_local.setCustomer_name(customerName);
            if(StringUtil.isEmpty(subCustomerId)){
                sc_workflow_incident_local.setSub_customer_id(customerId);
                sc_workflow_incident_local.setSub_customer_name(customerName);
            }else{
                sc_workflow_incident_local.setSub_customer_id(subCustomerId);
                sc_workflow_incident_local.setSub_customer_name(subCustomerName);
            }
            
            map.put("type", "2");
            
            Map result = ewZcFacade.saveZcyw(map, request, sc_workflow_incident_local);
            String incidentId = ConvertUtil.obj2StrBlank(result.get("incidentId"));
            request.getSession().removeAttribute(SysConstants.LOCALSESSION);
            request.getSession().removeAttribute(SysConstants.SELECTUSERSESSION);
            ewZcFacade.doEndTask(request, incidentId);
            SqlParameter mapg = new SqlParameter("orderId",incidentId).addValue("bustype", Constants.WORKFLOW_BASE_BUSINESS_TYPE_INCIDENT_LOCAL);
            mapg.addValue("result", "1");
            WebUtil.write(response, JsonUtil.map2Json(mapg));
        }else{
            WebUtil.write(response, "");
        }
    }
    /**
     * 跳转到关闭原因界面
     */
    @RequestMapping("ewzcClose.html")
    public ModelAndView ewzcClose(HttpServletRequest request,HttpServletResponse response) {
        ModelAndView modelAndView = new ModelAndView("/business/wechat/ewyw/ewzc/ewzcClose");
        //查询关闭原因数据字典
        List reasons = dataDictionaryService.getDataDictionaryByCategoryKey(Constants.CLOSE_REASON);
        modelAndView.addObject("reasons", reasons);
        return modelAndView;
    }
    /**
     * 驻场创建事件提交并解决
     * @param request
     * @param response
     * @return
     */
    @SuppressWarnings({ "unchecked", "rawtypes" })
    @RequestMapping(value="saveLocalClose.html", method=RequestMethod.POST)
    public void saveLocalClose(HttpServletRequest request, HttpServletResponse response,SC_WORKFLOW_INCIDENT_LOCAL sc_workflow_incident_local) {
        Object obj = request.getSession().getAttribute(SysConstants.LOCALSESSION);
        if(null!=obj){
            Map map=(Map)obj;
            sc_workflow_incident_local=localEntity(map, sc_workflow_incident_local);
//            resultMap.put("deviceList", deviceList);
            String deviceLists=ConvertUtil.obj2Str(map.get("deviceList"));
            if(StringUtil.notEmpty(deviceLists)){
                List<Map> deviceList=(List<Map>)(map.get("deviceList"));
                String str="";
                for(Map mapa:deviceList){
                    str+=ConvertUtil.obj2Str(mapa.get("deivceId"))+",";
                }
                map.put("deviceId", str);
            }else{
                map.put("deviceId", "");
            }
            
            String orderLists=ConvertUtil.obj2Str(map.get("orderList"));
            if(StringUtil.notEmpty(orderLists)){
                List<Map> orderList=(List<Map>)(map.get("orderList"));
                String str="";
                for(Map mapb:orderList){
                    str+=ConvertUtil.obj2Str(mapb.get("orderId"))+",";
                }
                map.put("orderId", str);
            }else{
                map.put("orderId", "");
            }
//            resultMap.put("orderList", orderList);
            Map resulta = ewZcFacade.queryZcMsg(request);
            String customerId=ConvertUtil.obj2Str(resulta.get("customerId"));
            String customerName=ConvertUtil.obj2Str(resulta.get("customerName"));
            String subCustomerId=ConvertUtil.obj2Str(resulta.get("subCustomerId"));
            String subCustomerName=ConvertUtil.obj2Str(resulta.get("subCustomerName"));
            sc_workflow_incident_local.setCustomer_id(customerId);
            sc_workflow_incident_local.setCustomer_name(customerName);
            if(StringUtil.isEmpty(subCustomerId)){
                sc_workflow_incident_local.setSub_customer_id(customerId);
                sc_workflow_incident_local.setSub_customer_name(customerName);
            }else{
                sc_workflow_incident_local.setSub_customer_id(subCustomerId);
                sc_workflow_incident_local.setSub_customer_name(subCustomerName);
            }
            
            map.put("type", "3");
            
            Map result = ewZcFacade.saveZcyw(map, request, sc_workflow_incident_local);
            String incidentId = ConvertUtil.obj2StrBlank(result.get("incidentId"));
            request.getSession().removeAttribute(SysConstants.LOCALSESSION);
            request.getSession().removeAttribute(SysConstants.SELECTUSERSESSION);
            ewZcFacade.doCloseReason(request, incidentId);
            WebUtil.write(response, "1");
        }else{
            WebUtil.write(response, "");
        }
    }
    @SuppressWarnings({ "rawtypes" })
    private SC_WORKFLOW_INCIDENT_LOCAL localEntity(Map map,SC_WORKFLOW_INCIDENT_LOCAL sc_workflow_incident_local){
        sc_workflow_incident_local.setName(ConvertUtil.obj2Str(map.get("name")));
        sc_workflow_incident_local.setDescrip(ConvertUtil.obj2Str(map.get("descrip")));
        sc_workflow_incident_local.setContact_phone(ConvertUtil.obj2Str(map.get("contact_phone")));
        sc_workflow_incident_local.setContact_name(ConvertUtil.obj2Str(map.get("contact_name")));
        sc_workflow_incident_local.setKeshi(ConvertUtil.obj2Str(map.get("keshi")));
        sc_workflow_incident_local.setApply_type_id(ConvertUtil.obj2Str(map.get("apply_type_id")));
        sc_workflow_incident_local.setApply_type_name(ConvertUtil.obj2Str(map.get("apply_type_name")));
        sc_workflow_incident_local.setType_id(ConvertUtil.obj2Str(map.get("type_id")));
        sc_workflow_incident_local.setType_name(ConvertUtil.obj2Str(map.get("type_name")));
        sc_workflow_incident_local.setSource_id(ConvertUtil.obj2Str(map.get("source_id")));
        sc_workflow_incident_local.setSource_name(ConvertUtil.obj2Str(map.get("source_name")));
        String happen_time = ConvertUtil.obj2Str(map.get("happen_time")).replaceAll("\\s*", "");;
        happen_time = happen_time.replace("-", "").replace(" ", "").replace(":", "");
        sc_workflow_incident_local.setHappen_time(ConvertUtil.obj2Long(happen_time+"00"));
        sc_workflow_incident_local.setSla_id(ConvertUtil.obj2Str(map.get("slaId")));
        sc_workflow_incident_local.setSla_name(ConvertUtil.obj2Str(map.get("slaName")));
        sc_workflow_incident_local.setPriority_id(ConvertUtil.obj2Str(map.get("priority_id")));
        sc_workflow_incident_local.setPriority_name(ConvertUtil.obj2Str(dataDictionaryService.getDataDictionaryByKey(ConvertUtil.obj2Str(map.get("priority_id"))).get("DATAVALUE")));
        sc_workflow_incident_local.setInfluence_id(ConvertUtil.obj2Str(map.get("influence_id")));
        sc_workflow_incident_local.setInfluence_name(ConvertUtil.obj2Str(dataDictionaryService.getDataDictionaryByKey(ConvertUtil.obj2Str(map.get("influence_id"))).get("DATAVALUE")));
        sc_workflow_incident_local.setRequest_answer_time(ConvertUtil.obj2Long(map.get("request_answer_time")));
        sc_workflow_incident_local.setRequest_deal_time(ConvertUtil.obj2Long(map.get("request_deal_time")));
        return sc_workflow_incident_local;
    }
}