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
package cn.ksource.web.controller.tj;
 
import cn.ksource.core.util.ConvertUtil;
import cn.ksource.core.util.DateUtil;
import cn.ksource.core.util.JsonUtil;
import cn.ksource.core.util.NumberUtil;
import cn.ksource.core.util.ParamsMapUtil;
import cn.ksource.core.util.StringUtil;
import cn.ksource.core.web.WebUtil;
import cn.ksource.web.Constants;
import cn.ksource.web.facade.customermanage.CustomerManageFacade;
import cn.ksource.web.facade.tj.IncidentStatisFacade;
import cn.ksource.web.facade.tj.LocalStatisFacade;
import cn.ksource.web.service.DataDictionaryService;
 
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.servlet.ModelAndView;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
@Controller
@RequestMapping("/business/pages/tj/localStatis")
public class LocalStatisController {
 
    @Resource
    private LocalStatisFacade localStatisFacade;
    
    @Resource
    private CustomerManageFacade customerFacade;
    @Autowired
    private IncidentStatisFacade incidentStatisFacade;
    @Autowired
    private DataDictionaryService dataDictionaryService;
    
    /**
     * 统计模板
     */
    @RequestMapping("localTemplate.html")
    public ModelAndView localType(HttpServletRequest request,HttpServletResponse response) {
        ModelAndView modelAndView = new ModelAndView("/business/pages/tj/localStatis/localTemplate");
        return modelAndView;
    }
    
    /**
     * 统计模板
     */
    @RequestMapping("localzctj.html")
    public ModelAndView localzctj(HttpServletRequest request,HttpServletResponse response) {
        ModelAndView modelAndView = new ModelAndView("/business/pages/tj/localStatis/localzctj");
        //获取当前查询类型
        String queryType = request.getParameter("queryType");
        if(StringUtil.isBlank(queryType)){
            queryType = "1";
        }
        String focus = request.getParameter("focus");
        if(StringUtil.isBlank(focus)){
            focus = "LOCAL_TYPE";
        }
        String charTitle = "";
        if(queryType.equals("1")){
            charTitle="驻场类型";
        }else if(queryType.equals("2")){
            charTitle="驻场来源";
        }else if(queryType.equals("3")){
            charTitle="驻场取消方式";
        }else if(queryType.equals("4")){
            charTitle="驻场优先级";
        }else if(queryType.equals("5")){
            charTitle="驻场影响度";
        }else if(queryType.equals("6")){
            charTitle="驻场服务级别";
        }else if(queryType.equals("7")){
            charTitle="驻场响应超时";
        }else if(queryType.equals("8")){
            charTitle="驻场处理超时";
        }
        
        
        //获取当前session中的客户信息
        List cusList = customerFacade.getCusList();
        modelAndView.addObject("cusList", cusList);
        
        long month = DateUtil.getCurrentDate6();
        
        long monthFirstDate = ConvertUtil.obj2Long(month+"01");
        
        String beginTime = DateUtil.format("yyyy-MM-dd", monthFirstDate);
        String endTime = DateUtil.getToday("yyyy-MM-dd");
        
        
        modelAndView.addObject("beginTime", beginTime.replaceAll("-", ""));
        modelAndView.addObject("endTime",  endTime.replaceAll("-", ""));
        
        
        int beginMonth = DateUtil.getYear();
        String endMonth = DateUtil.getToday("yyyyMM");
        modelAndView.addObject("beginMonth", beginMonth+"01");
        modelAndView.addObject("endMonth", endMonth);
        modelAndView.addObject("queryType", queryType);
        modelAndView.addObject("focus", focus);
        modelAndView.addObject("charTitle", charTitle);
        return modelAndView;
    }
    
    
    /**
     * 查询驻场类型统计占比
     */
    @RequestMapping("localTemplatePie.html")
    public void localTemplatePie(HttpServletRequest request,HttpServletResponse response) {
        List attitude = localStatisFacade.localTypePie(request);
        WebUtil.write(response, JsonUtil.list2Json(attitude));
    }
    
    
    /**
     * 查询驻场类型时间走势
     */
    @RequestMapping("localTemplateLine.html")
    public void localTemplateLine(HttpServletRequest request,HttpServletResponse response) {
        Map scoreLine = localStatisFacade.localTypeLine(request);
        WebUtil.write(response, JsonUtil.map2Json(scoreLine));
    }
    
    /**
     * 驻场发生时间
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("localHappenTime.html")
    public ModelAndView localRole(HttpServletRequest request,HttpServletResponse response) {
        ModelAndView modelAndView = new ModelAndView("/business/pages/tj/localStatis/localHappenTime");
        //获取当前session中的客户信息
        List cusList = customerFacade.getCusList();
        modelAndView.addObject("cusList", cusList);
        modelAndView.addObject("selDay", DateUtil.getCurrentDate8());
        return modelAndView;
    }
    
    /**
     * 查询驻场类型时间走势
     */
    @RequestMapping("localHappenTimeLine.html")
    public void localHappenTimeLine(HttpServletRequest request,HttpServletResponse response) {
        Map scoreLine = localStatisFacade.localTimeLine(request);
        WebUtil.write(response, JsonUtil.map2Json(scoreLine));
    }
 
    
    
    @RequestMapping("localTotalChartIndex.html")
    public ModelAndView localTotalChartIndex(HttpServletRequest request,HttpServletResponse response) {
        ModelAndView modelAndView = new ModelAndView("/business/pages/tj/localStatis/localTotalChartIndex");
        //获取当前session中的客户信息
        List cusList = customerFacade.getCusList();
        
        long month = DateUtil.getCurrentDate6();
        long monthFirstDate = ConvertUtil.obj2Long(month+"01");
        String beginTime = DateUtil.format("yyyy-MM-dd", monthFirstDate);
        String endTime = DateUtil.getToday("yyyy-MM-dd");
        modelAndView.addObject("beginTime", beginTime.replaceAll("-", ""));
        modelAndView.addObject("endTime",  endTime.replaceAll("-", ""));
        modelAndView.addObject("cusList", cusList);
        return modelAndView;
    }
    
    
    @RequestMapping("localTotalChart.html")
    public ModelAndView localTotalChart(HttpServletRequest request,HttpServletResponse response) {
        ModelAndView modelAndView = new ModelAndView("/business/pages/tj/localStatis/localTotalChart");
        //获取当前session中的客户信息
        String cusId = request.getParameter("cusId");
        String cusName = request.getParameter("cusName");
        String beginTime = request.getParameter("beginDay");
        String endTime = request.getParameter("endDay");
        Map resMap = localStatisFacade.localTotalChart(cusId,cusName,beginTime,endTime);
        List<Map> typeList = (List<Map>)resMap.get("typeList"); 
        List<Map> sourceList = (List<Map>)resMap.get("sourceList");
        List<Map> closeList = (List<Map>)resMap.get("closeList");
        List<Map> priList = (List<Map>)resMap.get("priList");
        List<Map> effectList = (List<Map>)resMap.get("effectList");
        List<Map> levelList = (List<Map>)resMap.get("levelList");
        List<Map> timeoutList = (List<Map>)resMap.get("timeoutList");
        List<Map> resolveList = (List<Map>)resMap.get("resolveList");
        List<Map> stateList = (List<Map>)resMap.get("stateList");
        List<Map> resList = (List<Map>)resMap.get("resList");
        modelAndView.addObject("typeList",typeList);
        modelAndView.addObject("sourceList",sourceList);
        modelAndView.addObject("closeList",closeList);
        modelAndView.addObject("priList",priList);
        modelAndView.addObject("effectList",effectList);
        modelAndView.addObject("levelList",levelList);
        modelAndView.addObject("timeoutList",timeoutList);
        modelAndView.addObject("resolveList",resolveList);
        modelAndView.addObject("stateList",stateList);
        modelAndView.addObject("resList",resList);
        modelAndView.addObject("cusName",cusName);
        return modelAndView;
    }
    
    
    
    
    /**
     * 跳转到办公网络保修统计页面
     * @param request
     * @return
     * @author 李云鹏
     */
    @RequestMapping("localStatisIndex.html")
    public ModelAndView incidentStatisIndex(HttpServletRequest request){
        List cusList = customerFacade.getCusList();
        ModelAndView modelAndView = new ModelAndView("/business/pages/tj/localStatis/localStatisIndex");
        long month = DateUtil.getCurrentDate6();
        long monthFirstDate = ConvertUtil.obj2Long(month+"01");
        String beginTime = DateUtil.format("yyyy-MM-dd", monthFirstDate);
        String endTime = DateUtil.getToday("yyyy-MM-dd");
        modelAndView.addObject("beginTime", beginTime.replaceAll("-", ""));
        modelAndView.addObject("endTime",  endTime.replaceAll("-", ""));
        modelAndView.addObject("cusList", cusList);
        Map param=new HashMap();
        param.put("type", "1");
        List<Map> userList=incidentStatisFacade.getGcsList(param);
        modelAndView.addObject("userList", userList);
        //查询事件类型数据字典
        List<Map> types = dataDictionaryService.getDataDictionaryByCategoryKey(Constants.INCIDENT_TYPE);
        modelAndView.addObject("types", types);
        return modelAndView;
    }
    /**
     * 办公网络保修统计
     * @param request
     * @return
     * @author 李云鹏
     */
    @RequestMapping("localStatis.html")
    public ModelAndView incidentStatis(HttpServletRequest request){
        ModelAndView modelAndView=new ModelAndView("/business/pages/tj/localStatis/localStatis");
        String cusId = request.getParameter("cusId");
        String beginTime = request.getParameter("beginDay");
        String endTime = request.getParameter("endDay");
        String subCustomerId=request.getParameter("sub_customer_id");
        String wfstate=request.getParameter("wfstate");
        String jjrId=request.getParameter("jjrId");
        List<Map> incidentList=localStatisFacade.queryLocalIncidentStatis(cusId,subCustomerId,beginTime,endTime,wfstate,jjrId);
        if(incidentList!=null && incidentList.size()>0){
            for(Map map:incidentList){
                //map.put("STATE", Constants.getmapSC_WORKFLOW_RELEASE_STATE(map.get("STATE").toString()));
                //查询要求响应时间和实际响应时间
                long create_time = ConvertUtil.obj2Long(map.get("CREATE_TIME"));
                String answer_time = ConvertUtil.obj2StrBlank(map.get("ANSWER_TIME"));
                if(!StringUtil.notEmpty(answer_time)) {
                    answer_time =  DateUtil.getCurrentDate14().toString();
                }
                long seconds = DateUtil.getSecondsFormDate2Date(create_time, ConvertUtil.obj2Long(answer_time));
                //将秒转化为分钟
                double sjxysj = NumberUtil.div(ConvertUtil.obj2Double(seconds), ConvertUtil.obj2Double(60), 1);
                double xycs=NumberUtil.sub(sjxysj, ConvertUtil.obj2Double(map.get("REQUEST_ANSWER_TIME")));
                if(xycs>0){
                    map.put("xycssj", xycs);
                }
                //处理超时操作
                //1.判断当前工单有没有解决时间,如果有解决时间 说明已完成,如果没有解决时间 说明未完成
                String resolveTime = ConvertUtil.obj2StrBlank(map.get("RESOLVE_TIME"));
                if(!StringUtil.notEmpty(resolveTime)) {
                    resolveTime = DateUtil.getCurrentDate14().toString();
                }
                //计算第解决时间和创建事件的事件差 将时间差转化为小时
                long jjSeconds = DateUtil.getSecondsFormDate2Date(create_time, ConvertUtil.obj2Long(resolveTime));
                //将秒转化为小时
                double sjjjsj = NumberUtil.div(ConvertUtil.obj2Double(jjSeconds), ConvertUtil.obj2Double(3600), 2);
                double clcssj=NumberUtil.sub(sjjjsj, ConvertUtil.obj2Double(map.get("REQUEST_DEAL_TIME")));
                if(clcssj>0){
                    map.put("clcssj", clcssj);
                }
            }
        }
        if(incidentList!=null && incidentList.size()>0){
            for(Map map:incidentList){
                map.put("STATE", Constants.mapSC_WORKFLOW_INCIDENT_LOCAL_STATE_Label((map.get("STATE").toString())));
            }
        }
        modelAndView.addObject("incidentList",incidentList);
        modelAndView.addObject("beginTime",request.getParameter("beginDay"));
        modelAndView.addObject("endTime",request.getParameter("endDay"));
        modelAndView.addObject("cusName",request.getParameter("cusName"));
        
        return modelAndView;
    }
    /**
     * 初始化页面数据
     * @author gaofazhan
     * @param request
     * @param model
     */
    private void initModel(HttpServletRequest request,Model model){
        //获取当前session中的客户信息
        List cusList = customerFacade.getCusList();
        model.addAttribute("cusList", cusList);
        long month = DateUtil.getCurrentDate6();
        long monthFirstDate = ConvertUtil.obj2Long(month+"01");
        String beginTime = DateUtil.format("yyyy-MM-dd", monthFirstDate);
        String endTime = DateUtil.getToday("yyyy-MM-dd");
        model.addAttribute("beginTime", beginTime.replaceAll("-", ""));
        model.addAttribute("endTime",  endTime.replaceAll("-", ""));
        int beginMonth = DateUtil.getYear();
        String endMonth = DateUtil.getToday("yyyyMM");
        model.addAttribute("beginMonth", beginMonth+"01");
        model.addAttribute("endMonth", endMonth);
    }
    /**
     * 驻场事件达成率统计
     */
    @RequestMapping("localStatisDcl.html")
    public ModelAndView localStatisDcl(Model model,HttpServletRequest request) {
        ModelAndView modelAndView = new ModelAndView("/business/pages/tj/localStatis/localStatisDcl");
        initModel(request, model);
        return modelAndView;
    }
    /**
     * 跳转到驻场事件达成率信息页面
     */
    @RequestMapping("localStatisDclStatis.html")
    public ModelAndView incidentDclStatis(HttpServletRequest request) {
        ModelAndView modelAndView = new ModelAndView("/business/pages/tj/localStatis/localStatisDclStatis");
        String cusId = request.getParameter("cusId");
        String beginTime = request.getParameter("beginTime");
        String endTime = request.getParameter("endTime");
        String subCustomerId = request.getParameter("sub_customer_id");
        List<Map> reports = localStatisFacade.queryIncidentDclStatis(cusId,subCustomerId,beginTime,endTime);
        
        modelAndView.addObject("reports", reports);
        String cusName = request.getParameter("cusName");
        modelAndView.addObject("cusName", cusName);
        
        return modelAndView;
    }
    /**
     * 驻场事件关闭原因
     * @return
     */
    @RequestMapping("localCloseReport.html")
    public String localCloseReport(Model model,HttpServletRequest request){
        initModel(request, model);
        return "/business/pages/tj/localStatis/localCloseReport";
    }
    /**
     * 驻场事件关闭原因数据
     * @param model
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("localCloseReportData.html")
    public String localCloseReportData(Model model,HttpServletRequest request,HttpServletResponse response){
        String cusId = request.getParameter("cusId");
        String beginDay = request.getParameter("beginDay");
        String endDay = request.getParameter("endDay");
        Map report = localStatisFacade.queryCloseReport(cusId,beginDay,endDay);
        model.addAttribute("report", report);
        return "/business/pages/tj/localStatis/localCloseReportData";
    }
    /**
     * 驻场事件类型
     * @return
     */
    @RequestMapping("localTypeReport.html")
    public String incidentTypeReport(Model model,HttpServletRequest request){
        initModel(request, model);
        return "/business/pages/tj/localStatis/localTypeReport";
    }
    /**
     * 驻场事件类型数据
     * @param model
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("localTypeReportData.html")
    public String localTypeReportData(Model model,HttpServletRequest request,HttpServletResponse response){
        String cusId = request.getParameter("cusId");
        String beginDay = request.getParameter("beginDay");
        String endDay = request.getParameter("endDay");
        Map report = localStatisFacade.queryTypeReport(cusId,beginDay,endDay);
        model.addAttribute("report", report);
        return "/business/pages/tj/localStatis/localTypeReportData";
    }
    /**
     * 驻场事件处理时长
     * @return
     */
    @RequestMapping("localDealTimeReport.html")
    public String localDealTimeReport(Model model,HttpServletRequest request){
        initModel(request, model);
        return "/business/pages/tj/localStatis/localDealTimeReport";
    }
    @RequestMapping("localDealTimeReportData.html")
    public String localDealTimeReportData(Model model,HttpServletRequest request,HttpServletResponse response){
        String cusId = request.getParameter("cusId");
        String beginDay = request.getParameter("beginDay");
        String endDay = request.getParameter("endDay");
        Map report = localStatisFacade.queryDealTimeReport(cusId,beginDay,endDay);
        model.addAttribute("report", report);
        return "/business/pages/tj/localStatis/localDealTimeReportData";
    }
    /**
     * 驻场事件处理情况
     * @return
     */
    @RequestMapping("localDealSatuationReport.html")
    public String localDealSatuationReport(Model model,HttpServletRequest request){
        initModel(request, model);
        return "/business/pages/tj/localStatis/localDealSatuationReport";
    }
    @RequestMapping("localDealSatuatioReportData.html")
    public String localDealSatuatioReportData(Model model,HttpServletRequest request,HttpServletResponse response){
        String cusId = request.getParameter("cusId");
        String beginDay = request.getParameter("beginDay");
        String endDay = request.getParameter("endDay");
        Map report = localStatisFacade.queryDealSituationReport(cusId,beginDay,endDay);
        model.addAttribute("report", report);
        return "/business/pages/tj/localStatis/localDealSatuatioReportData";
    }
    /**
     * 驻场事件处理情况
     * @return
     */
    @RequestMapping("localDealDayReport.html")
    public String localDealDayReport(Model model,HttpServletRequest request){
        initModel(request, model);
        return "/business/pages/tj/localStatis/localDealDayReport";
    }
    @RequestMapping("localDealDayReportData.html")
    public String localDealDayReportData(Model model,HttpServletRequest request,HttpServletResponse response){
        Map param=ParamsMapUtil.getParameterMap(request);
        Map report = localStatisFacade.queryDealDayReport(param);
        model.addAttribute("report", report);
        return "/business/pages/tj/localStatis/localDealDayReportData";
    }
}