AlarmStatisticsController.java
6.5 KB
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
package com.skua.modules.controller;
import com.google.common.collect.Lists;
import com.skua.modules.alarmtmp.service.AlarmRecordHistoryService;
import com.skua.modules.alarmtmp.vo.AlarmStatisticsTypeVO;
import com.skua.modules.alarmtmp.vo.AlarmStatisticsVO;
import com.skua.core.api.vo.Result;
import com.skua.core.aspect.annotation.AutoLog;
import com.skua.modules.system.service.ISysDictService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* @Description 报警统计控制层
* @Date 2020-12-16 17:08
* @Param
* @return
**/
@Slf4j
@RestController
@RequestMapping("/alarm/statistics")
@Api(tags = "报警统计页面")
public class AlarmStatisticsController {
@Autowired
private AlarmRecordHistoryService alarmRecordHistoryService;
@Autowired
private ISysDictService sysDictService;
/**
* 报警处理情况分页列表查询
*/
@AutoLog(value = "报警处理情况列表查询")
@ApiOperation(value = "报警处理情况列表查询", notes = "报警处理情况列表查询")
@GetMapping(value = "/getAlarmDealList")
public Result<List<AlarmStatisticsVO>> getAlarmDealList(String startTime, String endTime, String departId) {
Result<List<AlarmStatisticsVO>> result = new Result<>();
List<AlarmStatisticsVO> data = Lists.newArrayList();
DecimalFormat df = new DecimalFormat("#.##%");
String[] split = departId.split(",");
List<String> ids = Arrays.asList(split);
//获取全部报警工单
List<Map<String, Object>> allData = alarmRecordHistoryService.getAlarmRecordHistoryAll(startTime, endTime, ids);
if (allData != null) {
AlarmStatisticsVO alarmStatisticsVO = null;
String id = "";
Map<String, Object> map = null;
Map<String, Object> map1 = null;
Long pfjs = 0l;
Long wcjs = 0l;
Long pftotal = 0l;
Long wctotal = 0l;
Long total = 0l;
//获取字典里的派单及时时间间隔
String pfTime = sysDictService.queryDictTextByKey("alarm_msg_time", "pftime");
String wcTime = sysDictService.queryDictTextByKey("alarm_msg_time", "wctime");
for (Map<String, Object> allDatum : allData) {
alarmStatisticsVO = new AlarmStatisticsVO();
pfjs = 0l;
wcjs = 0l;
pftotal = 0l;
wctotal = 0l;
id = (String) allDatum.get("depart_id");
total= (Long) allDatum.getOrDefault("count", "0");
// 工单派发率 派发及时率
map = alarmRecordHistoryService.getAlarmRecordHistoryPf(startTime, endTime, id, pfTime);
if (map != null) {
pfjs = (Long) map.getOrDefault("pfjs", "0");
pftotal = (Long) map.getOrDefault("pftotal", "0");
}
//工单完成率 完成及时率
map1 = alarmRecordHistoryService.getAlarmRecordHistoryWc(startTime, endTime, id, wcTime);
if (map1 != null) {
wcjs = (Long)map1.getOrDefault("wcjs", "0");
wctotal = (Long)map1.getOrDefault("wctotal", "0");
}
alarmStatisticsVO.setTotal(total.toString());
alarmStatisticsVO.setDepartId(id);
alarmStatisticsVO.setDepartName((String) allDatum.get("depart_name"));
alarmStatisticsVO.setGdpfl(total==0?df.format(0):df.format(pfjs/total.doubleValue()));
alarmStatisticsVO.setGdwcl(total==0?df.format(0):df.format(wcjs/total.doubleValue()));
alarmStatisticsVO.setPfjsl(pftotal==0?df.format(0):df.format(pfjs/pftotal.doubleValue()));
alarmStatisticsVO.setWcjsl(pftotal==0?df.format(0):df.format(wcjs/wctotal.doubleValue()));
data.add(alarmStatisticsVO);
}
}
result.setResult(data);
result.setSuccess(true);
return result;
}
/**
* 报警处理情况分页列表查询
*/
@AutoLog(value = "报警类型分布查询")
@ApiOperation(value = "报警类型分布查询", notes = "报警类型分布查询")
@GetMapping(value = "/getAlarmTypeList")
public Result<List<AlarmStatisticsTypeVO>> getAlarmTypeList(String startTime, String endTime, String departId) {
Result<List<AlarmStatisticsTypeVO>> result = new Result<>();
String[] split = departId.split(",");
List<String> ids = Arrays.asList(split);
//按类型分布
List<AlarmStatisticsTypeVO> allData = alarmRecordHistoryService.getAlarmTypeList(startTime, endTime, ids);
if(allData==null||allData.size()<2){
if(allData.size()==1) {
AlarmStatisticsTypeVO alarmStatisticsTypeVO=allData.get(0);
if("数据报警".equals(alarmStatisticsTypeVO.getName())){
allData.add(new AlarmStatisticsTypeVO("故障报警","0"));
}else{
allData.add(new AlarmStatisticsTypeVO("数据报警","0"));
}
}else if(allData.size()==0){
allData.add(new AlarmStatisticsTypeVO("故障报警","0"));
allData.add(new AlarmStatisticsTypeVO("数据报警","0"));
}
}
result.setResult(allData);
result.setSuccess(true);
return result;
}
/**
* 报警处理情况分页列表查询
*/
@AutoLog(value = "报警及派单趋势查询")
@ApiOperation(value = "报警及派单趋势查询", notes = "报警及派单趋势查询")
@GetMapping(value = "/getAlarmTrendList")
public Result<List<Map<String,Object>>> getAlarmTrendList(String startTime, String endTime, String departId) {
Result<List<Map<String,Object>>> result = new Result<>();
String[] split = departId.split(",");
List<String> ids = Arrays.asList(split);
//按类型分布
List<Map<String,Object>> allData = alarmRecordHistoryService.getAlarmTrendList(startTime, endTime, ids);
result.setResult(allData);
result.setSuccess(true);
return result;
}
}