RemoteAlarmService.java
3.79 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
package cn.com.glsx.admin.modules.remote;
import cn.com.glsx.admin.modules.utils.StringUtil;
import cn.com.glsx.alarm.api.AlarmFeignClient;
import cn.com.glsx.alarm.services.model.*;
import cn.hutool.core.collection.CollectionUtil;
import com.glsx.plat.core.web.R;
import com.google.common.collect.Lists;
import com.google.gson.reflect.TypeToken;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* AlarmFeignClient 服务的处理层
*
* @author yll
*/
@Slf4j
@Service
public class RemoteAlarmService {
@Autowired
private AlarmFeignClient alarmFeignClient;
public Integer getPowerOffAlertCount(List<String> sns, String startTime, String endTime) {
Integer powerOffAlertCount = 0;
if (CollectionUtil.isEmpty(sns)) {
return powerOffAlertCount;
}
PowerOffBo powerOffBo = new PowerOffBo();
powerOffBo.setSns(sns);
powerOffBo.setStartTime(startTime);
powerOffBo.setEndTime(endTime);
R<Integer> powerOffAlertCountR = alarmFeignClient.getPowerOffAlertCount(powerOffBo);
powerOffAlertCount = powerOffAlertCountR.getData(Integer.class);
if (powerOffAlertCount == null) {
powerOffAlertCount = 0;
}
return powerOffAlertCount;
}
public Integer getTearDownAlarmCount(List<String> sns, String startTime, String endTime) {
Integer tearDownAlarmCount = 0;
if (CollectionUtil.isEmpty(sns)) {
return tearDownAlarmCount;
}
TearDownBo tearDownBo = new TearDownBo();
tearDownBo.setSns(sns);
tearDownBo.setStartTime(startTime);
tearDownBo.setEndTime(endTime);
R<Integer> tearDownAlarmCountR = alarmFeignClient.getTearDownAlarmCount(tearDownBo);
tearDownAlarmCount = tearDownAlarmCountR.getData(Integer.class);
if (tearDownAlarmCount == null) {
tearDownAlarmCount = 0;
}
return tearDownAlarmCount;
}
/**
* 通过设备号获取报警类型获取报警数据
*
* @param sn 设备号
* @return 最近一条报警数据
*/
public List<CommonAlarmDto> listCommonAlarmDtoBySn(String sn, Integer alarmType) {
CommonAlarmBo commonAlarmBo = new CommonAlarmBo();
commonAlarmBo.setSnList(Lists.newArrayList(sn));
// 只展示生效
commonAlarmBo.setDelflag(0);
commonAlarmBo.setAlarmType(alarmType);
R<List<CommonAlarmDto>> searchR = alarmFeignClient.getTheLastThreeAlarms(commonAlarmBo);
if (searchR.getCode() != 200 || !searchR.getMessage().equalsIgnoreCase("success")) {
log.info(sn + "find fial.code:" + searchR.getCode() + ";message:" + searchR.getMessage());
return null;
}
List<CommonAlarmDto> alarmList = searchR.getDataList(new TypeToken<List<CommonAlarmDto>>() {
}.getType());
return alarmList;
}
/**
* 通过设备号统计警情数量
*
* @param snList 设备号集合
* @param alarmType 警情类型
* @return 警情数量
*/
public Integer countAlarmRec(List<String> snList, Integer alarmType) {
Integer countAlarmRecCount = 0;
if (CollectionUtil.isEmpty(snList)) {
return countAlarmRecCount;
}
AlarmTrackRecQueryDTO alarmTrackRecQueryDTO = new AlarmTrackRecQueryDTO();
alarmTrackRecQueryDTO.setSns(snList);
alarmTrackRecQueryDTO.setAlarmType(alarmType);
R<Integer> countAlarmRecR = alarmFeignClient.countAlarmRec(alarmTrackRecQueryDTO);
countAlarmRecCount = countAlarmRecR.getData(Integer.class);
if (countAlarmRecCount == null) {
countAlarmRecCount = 0;
}
return countAlarmRecCount;
}
}