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
package cn.ksource.web.controller.business.pages.incident;
 
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 cn.ksource.beans.SC_WORKFLOW_INCIDENT_TEMPLATE;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
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.WORKFLOW_BASE;
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.NumberUtil;
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.facade.customermanage.CustomerManageFacade;
import cn.ksource.web.facade.incident.IncidentFacade;
import cn.ksource.web.facade.order.OrderFacade;
import cn.ksource.web.service.DataDictionaryService;
 
/**
 * 日常运维--事件管理控制器
 *
 * @author sxj
 * @note:
 * @date June 28, 2016 10:35:44 AM
 */
@Controller
@RequestMapping("/business/pages/incidentTemplate")
public class IncidentTemplateController {
 
    @Autowired
    private IncidentFacade incidentFacade;
 
    @Autowired
    private DataDictionaryService dataDictionaryService;
 
    @Autowired
    private OrderFacade orderFacade;
 
    @Resource
    private CustomerManageFacade customerFacade;
 
    /**
     * 跳转到我的事件列表
     */
    @RequestMapping("myIncident.html")
    public ModelAndView myIncident(HttpServletRequest request) {
        ModelAndView view = new ModelAndView("/business/pages/incidentTemplate/myIncident");
 
        Map num = orderFacade.queryOrderCountByCate(request, Constants.WORKFLOW_BASE_BUSINESS_TYPE_INCIDENT.toString());
 
        view.addObject("num", num);
 
 
        //查询事件类型数据字典
        List types = dataDictionaryService.getDataDictionaryByCategoryKey(Constants.INCIDENT_TYPE);
 
        view.addObject("types", types);
        //查询该加盟商的事件优先级
        List<Map> eventPri = dataDictionaryService.getDataDictionaryByCategoryKey(Constants.EVENT_PRI);
        view.addObject("eventPri", eventPri);
        //查询事件影响度数据字典
        List<Map> eventDg = dataDictionaryService.getDataDictionaryByCategoryKey(Constants.EVENT_EFFECT_DG);
        view.addObject("eventDg", eventDg);
        //客户列表
        List<Map> cusList = incidentFacade.getCustomerList();
        view.addObject("customers", cusList);
        //查询事件来源数据字典
        List<Map> froms = dataDictionaryService.getDataDictionaryByCategoryKey(Constants.INCIDENT_SOURCE);
        view.addObject("froms", froms);
 
        //定义参数Map
        Map<String, String> params = ParamsMapUtil.getParameterMap(request);
        params.put("userId", WebUtil.getLoginedUserId(request));
        params.put("type", "2");
        Map map = incidentFacade.getOrderNum(params);
 
        view.addObject("data", map);
        return view;
    }
 
 
    /**
     * 查询我的事件列表
     */
    @RequestMapping("myIncidentData.html")
    public ModelAndView myIncidentData(HttpServletRequest request, PageInfo pageInfo) {
        ModelAndView modelAndView = new ModelAndView("/business/pages/incidentTemplate/myIncidentData");
        //定义参数Map
        Map<String, String> params = ParamsMapUtil.getParameterMap(request);
        params.put("userId", WebUtil.getLoginedUserId(request));
        PageInfo info = incidentFacade.queryMyIncidentData1(pageInfo, params);
        modelAndView.addObject("orders", info);
        return modelAndView;
    }
 
    /**
     * 查询我的事件数量
     */
    @RequestMapping("myIncidentCount.html")
    public void myIncidentCount(HttpServletRequest request, HttpServletResponse response) {
        //定义参数Map
        Map<String, String> params = ParamsMapUtil.getParameterMap(request);
        params.put("userId", WebUtil.getLoginedUserId(request));
        int count = incidentFacade.queryMyIncidentCount1(params);
        WebUtil.write(response, String.valueOf(count));
    }
 
    /**
     * 跳转到我的事件列表
     */
    @RequestMapping("modelList.html")
    public ModelAndView modelList(HttpServletRequest request) {
        ModelAndView view = new ModelAndView("/business/pages/incidentTemplate/modelList");
 
        Map num = orderFacade.queryOrderCountByCate(request, Constants.WORKFLOW_BASE_BUSINESS_TYPE_INCIDENT.toString());
 
        view.addObject("num", num);
 
 
        //查询事件类型数据字典
        List types = dataDictionaryService.getDataDictionaryByCategoryKey(Constants.INCIDENT_TYPE);
 
        view.addObject("types", types);
        //查询该加盟商的事件优先级
        List<Map> eventPri = dataDictionaryService.getDataDictionaryByCategoryKey(Constants.EVENT_PRI);
        view.addObject("eventPri", eventPri);
        //查询事件影响度数据字典
        List<Map> eventDg = dataDictionaryService.getDataDictionaryByCategoryKey(Constants.EVENT_EFFECT_DG);
        view.addObject("eventDg", eventDg);
        //客户列表
        List<Map> cusList = incidentFacade.getCustomerList();
        view.addObject("customers", cusList);
        //查询事件来源数据字典
        List<Map> froms = dataDictionaryService.getDataDictionaryByCategoryKey(Constants.INCIDENT_SOURCE);
        view.addObject("froms", froms);
 
        //定义参数Map
        Map<String, String> params = ParamsMapUtil.getParameterMap(request);
        params.put("userId", WebUtil.getLoginedUserId(request));
        params.put("type", "2");
        Map map = incidentFacade.getOrderNum(params);
 
        view.addObject("data", map);
        return view;
    }
    /**
     * 查询我的事件列表
     */
    @RequestMapping("incidentData.html")
    public ModelAndView incidentData(HttpServletRequest request, PageInfo pageInfo) {
        ModelAndView modelAndView = new ModelAndView("/business/pages/incidentTemplate/incidentData");
        //定义参数Map
        Map<String, String> params = ParamsMapUtil.getParameterMap(request);
        params.put("userId", WebUtil.getLoginedUserId(request));
        PageInfo info = incidentFacade.queryMyIncidentData1(pageInfo, params);
        modelAndView.addObject("orders", info);
        return modelAndView;
    }
    /**
     * 跳转到工程师添加事件页面
     */
    @RequestMapping("engineerAddIncident.html")
    public ModelAndView engineerAddIncident(HttpServletRequest request) {
        ModelAndView view = new ModelAndView("/business/pages/incidentTemplate/engineerAddIncident");
        String repair = request.getParameter("repair");
 
        //查询事件类型数据字典
        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"));
        }
        //事件来源为一键报修
        if (!StringUtil.isEmpty(repair)) {
            view.addObject("fromId", Constants.INCIDENT_SOURCE_REPAIR_KEY);
            view.addObject("fromName", Constants.INCIDENT_SOURCE_REPAIR_VALUE);
        }
 
        //客户列表
        List<Map> cusList = incidentFacade.getCustomerList();
        view.addObject("customers", cusList);
        view.addObject("customerId", (cusList.get(0)).get("ID"));
        //查询事件优先级
        List<Map> eventPri = dataDictionaryService.getDataDictionaryByCategoryKey(Constants.EVENT_PRI);
        view.addObject("eventPri", eventPri);
        //查询事件影响度数据字典
        List<Map> eventDg = dataDictionaryService.getDataDictionaryByCategoryKey(Constants.EVENT_EFFECT_DG);
        view.addObject("eventDg", eventDg);
 
        view.addObject("types", types);
        view.addObject("ways", ways);
        view.addObject("froms", froms);
 
        //定义参数Map
        Map<String, String> params = ParamsMapUtil.getParameterMap(request);
        params.put("userId", WebUtil.getLoginedUserId(request));
        params.put("type", "2");
        Map map = incidentFacade.getOrderNum(params);
        view.addObject("data", map);
 
        return view;
    }
 
    /**
     * 工程师保存事件
     */
    @RequestMapping("engineerSaveIncident.html")
    public ModelAndView engineerSaveIncident(HttpServletRequest request, HttpServletResponse response, SC_WORKFLOW_INCIDENT_TEMPLATE template) {
        try {
            incidentFacade.saveEngineerIncident1(request, template);
            return WebUtil.sysInfoPage(request, "操作成功!",
                    "",
                    SysInfo.Success, "/business/pages/incidentTemplate/myIncident.html");
        } catch (Exception e) {
            e.printStackTrace();
            return WebUtil.sysInfoPage(request, "操作失败!",
                    "",
                    SysInfo.Error, "");
        }
 
    }
 
    /**
     * 跳转到工程师添加事件页面
     */
    @RequestMapping("engineerEditIncident.html")
    public ModelAndView engineerEditIncident(HttpServletRequest request) {
        ModelAndView view = new ModelAndView("/business/pages/incidentTemplate/engineerEditIncident");
        String orderId = request.getParameter("orderId");
        if (StringUtil.notEmpty(orderId)) {
            view.addObject("info", incidentFacade.getemplate(orderId));
        }
        String repair = request.getParameter("repair");
 
        //查询事件类型数据字典
        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"));
        }
        //事件来源为一键报修
        if (!StringUtil.isEmpty(repair)) {
            view.addObject("fromId", Constants.INCIDENT_SOURCE_REPAIR_KEY);
            view.addObject("fromName", Constants.INCIDENT_SOURCE_REPAIR_VALUE);
        }
 
        //客户列表
        List<Map> cusList = incidentFacade.getCustomerList();
        view.addObject("customers", cusList);
        //查询事件优先级
        List<Map> eventPri = dataDictionaryService.getDataDictionaryByCategoryKey(Constants.EVENT_PRI);
        view.addObject("eventPri", eventPri);
        //查询事件影响度数据字典
        List<Map> eventDg = dataDictionaryService.getDataDictionaryByCategoryKey(Constants.EVENT_EFFECT_DG);
        view.addObject("eventDg", eventDg);
 
        view.addObject("types", types);
        view.addObject("ways", ways);
        view.addObject("froms", froms);
 
        //定义参数Map
        Map<String, String> params = ParamsMapUtil.getParameterMap(request);
        params.put("userId", WebUtil.getLoginedUserId(request));
        params.put("type", "2");
        Map map = incidentFacade.getOrderNum(params);
        view.addObject("data", map);
 
        return view;
    }
 
    /**
     * 删除模板
     *
     * @param request
     * @param response
     */
    @RequestMapping(value = "delTemplate.html", method = RequestMethod.GET)
    public void delTemplate(HttpServletRequest request, HttpServletResponse response) {
        String id = request.getParameter("temp_id");
        incidentFacade.doDelTemplate(id);
        WebUtil.write(response, JsonUtil.obj2Json(1));
    }
 
    /**
     * 事件模板详情
     */
    @RequestMapping("templateDetail.html")
    public ModelAndView templateDetail(HttpServletRequest request) {
        ModelAndView view = new ModelAndView("/business/pages/incidentTemplate/templateDetail");
        String orderId = request.getParameter("orderId");
        view.addObject("info", incidentFacade.getemplate(orderId));
        return view;
    }
}