AlarmConfigNewController.java
8.7 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
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
package com.skua.modules.controller;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.skua.modules.alarmtmp.entity.AlarmDataSame;
import com.skua.modules.alarmtmp.entity.AlarmRuleLevelConfigTemplate;
import com.skua.modules.alarmtmp.service.*;
import com.skua.core.api.vo.Result;
import com.skua.core.aspect.annotation.AutoLog;
import com.skua.core.util.DateUtils;
import com.skua.modules.system.datestandard.entity.SysMonitorMetricInfo;
import com.skua.modules.system.datestandard.service.ISysMonitorMetricInfoService;
import com.skua.modules.system.service.IPgService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.text.ParseException;
import java.util.*;
/**
* @Description
* @Date 2020-12-16 17:08
* @Param
* @return
**/
@Slf4j
@RestController
@RequestMapping("/alarm/configNew")
@Api(tags = "关联报警配置")
public class AlarmConfigNewController {
@Autowired
private AlarmRecordHistoryService alarmRecordHistoryService;
@Autowired
private AlarmRuleConfigService alarmRuleConfigService;
@Autowired
private IAlarmRuleLevelConfigTemplateService alarmRuleLevelConfigTemplateService;
@Autowired
private AlarmLevelStandardConfigService alarmLevelStandardConfigService;
@Autowired
private IPgService pgService;
@Autowired
private IAlarmDataSameService alarmDataSameService;
@Autowired
private ISysMonitorMetricInfoService sysMonitorMetricInfoService;
private List<String> getDateRange(String startTime, String endTime) {
ArrayList rs = new ArrayList();
try {
String pattern = "yyyy-MM-dd HH";
Calendar sc = Calendar.getInstance();
Calendar ec = Calendar.getInstance();
sc.setTime(DateUtils.parse(startTime, pattern));
ec.setTime(DateUtils.parse(endTime, pattern));
while (sc.compareTo(ec) < 1) {
rs.add(DateUtils.format(sc.getTime(), pattern));
sc.add(Calendar.HOUR_OF_DAY, 1);
}
} catch (ParseException var8) {
var8.printStackTrace();
}
return rs;
}
/**
* <pre>
* 报警配置同步更新采集数据标签分类变更数据
* </pre>
* @return
* @author Li Yuanyuan, 2023年3月27日 上午9:40:52
* @Description: 采集数据标签不和机构有关联关系,数据标签分类变更,直接影响所有机构配置规则变更,这里直接批量更新
*/
@AutoLog(value = "同步更新报警配置类型")
@ApiOperation(value = "同步更新报警配置类型", notes = "同步更新报警配置类型")
@GetMapping(value = "/updateAlarmRuleType")
public Result<String> updateAlarmRuleType(){
Result<String> result = new Result<>();
alarmRuleConfigService.updateAlarmRuleTypeFormMetricDict();
result.setMessage("更新报警类型成功");
result.setSuccess(true);
return result;
}
/**
* 仪表和设备短信报警配置
*/
@AutoLog(value = "仪表和设备短信报警配置")
@ApiOperation(value = "仪表和设备短信报警配置", notes = "仪表和设备短信报警配置")
@GetMapping(value = "/getAlarmConfigTemplateByType")
public Result<Map<String, Object>> getAlarmConfigTemplateByType(String type, String departId) {
Result<Map<String, Object>> result = new Result<>();
Map<String, Object> data = alarmRuleConfigService.getAlarmConfigTemplateByType(type, departId);
result.setResult(data);
result.setSuccess(true);
return result;
}
/**
* 一键配置报警(未配置过的)
*/
@AutoLog(value = "总一键配仪表和设备报警")
@ApiOperation(value = "总一键配仪表和设备报警", notes = "总一键配仪表和设备报警")
@GetMapping(value = "/totalAddAllAlarmConfigByType")
public Result totalAddAllAlarmConfigByType() {
Result result = new Result<>();
alarmRuleConfigService.totalAddAllAlarmConfigByType();
result.setMessage("一键配置成功");
result.setSuccess(true);
return result;
}
/**
* 仪表和设备短信报警配置修改
*/
@AutoLog(value = "仪表和设备短信报警配置修改")
@ApiOperation(value = "仪表和设备短信报警配置修改", notes = "仪表和设备短信报警配置修改")
@PostMapping(value = "/updAlarmConfigTemplateByType")
public Result updAlarmConfigTemplateByType(@RequestBody AlarmRuleLevelConfigTemplate alarmRuleLevelConfigTemplate) {
Result result = new Result<>();
alarmRuleConfigService.updAlarmConfigTemplateByType(alarmRuleLevelConfigTemplate);
result.setMessage("修改成功");
result.setSuccess(true);
return result;
}
/**
* 关联报警配置添加和编辑
*/
@AutoLog(value = "关联报警配置添加和编辑")
@ApiOperation(value = "关联报警配置添加和编辑", notes = "关联报警配置添加和编辑")
@PostMapping(value = "/addGlAlarmConfigTemplate")
public Result addGlAlarmConfigTemplate(@RequestBody AlarmRuleLevelConfigTemplate alarmRuleLevelConfigTemplate) {
Result result = new Result<>();
//自定义报警模板类型默认使用6
alarmRuleLevelConfigTemplate.setAlarmTemplateType("6");
alarmRuleLevelConfigTemplate.setAlarmTemplateName(alarmRuleLevelConfigTemplate.getZexpression());
if (StringUtils.isNotBlank(alarmRuleLevelConfigTemplate.getExpression())) {
alarmRuleLevelConfigTemplateService.saveOrUpdate(alarmRuleLevelConfigTemplate);
} else {
if (StringUtils.isNotBlank(alarmRuleLevelConfigTemplate.getId())) {
alarmRuleLevelConfigTemplateService.removeById(alarmRuleLevelConfigTemplate.getId());
}
}
result.setMessage("操作成功");
result.setSuccess(true);
return result;
}
/**
* 根据设备点查询点表是否配置运行点、故障点和停止点
*/
@AutoLog(value = "根据设备点查询点表是否配置运行点、故障点和停止点")
@ApiOperation(value = "根据设备点查询点表是否配置运行点、故障点和停止点", notes = "根据设备点查询点表是否配置运行点、故障点和停止点")
@GetMapping(value = "/getEquipStatus")
public Result<List<Map<String, Object>>> getEquipStatus(String equipId) {
Result<List<Map<String, Object>>> result = new Result<>();
result.setResult(alarmRuleConfigService.getEquipStatus(equipId));
result.setMessage("操作成功");
result.setSuccess(true);
return result;
}
/**
* type 0仪表 1设备 2质量 3关联
* status 0停用 1启用
* anType
*
* @return com.skua.core.api.vo.Result
* @Description 一键启用停用
* @Date 2021-08-26 15:11
* @Param [type, status, departId, anType]
**/
@AutoLog(value = "一键启用停用")
@ApiOperation(value = "一键启用停用", notes = "一键启用停用")
@GetMapping(value = "/startAndEnd")
public Result startAndEnd(String type, String status, String departId, String anType) {
Result result = new Result<>();
alarmRuleConfigService.startAndEnd(type, status, departId, anType);
result.setMessage("操作成功");
result.setSuccess(true);
return result;
}
/**
* @Description 启用停用
* @Date 2021-08-26 15:11
**/
@AutoLog(value = "列表启用停用")
@ApiOperation(value = "列表启用停用", notes = "列表启用停用")
@GetMapping(value = "/updConfigStatus")
public Result updConfigStatus(String id, String departId, String anType, String status) {
Result result = new Result<>();
alarmRuleConfigService.updConfigStatus(id, departId, anType, status);
result.setMessage("操作成功");
result.setSuccess(true);
return result;
}
/**
* 根据类型查询关联报警指标
*/
@AutoLog(value = "根据类型查询关联报警指标")
@ApiOperation(value = "根据类型查询关联报警指标", notes = "根据类型查询关联报警指标")
@GetMapping(value = "/getMonitorByType")
public Result<List<Map<String, Object>>> getMonitorByType(String type, String departId) {
Result<List<Map<String, Object>>> result = new Result<>();
List<Map<String, Object>> data = alarmRuleConfigService.getMonitorByType(type, departId);
result.setSuccess(true);
result.setResult(data);
return result;
}
}