|
|
@@ -6,8 +6,13 @@ import com.unissoft.utils.RedisUtil;
|
|
6
|
6
|
import lombok.Data;
|
|
7
|
7
|
import lombok.extern.slf4j.Slf4j;
|
|
8
|
8
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
9
|
+import org.springframework.http.HttpEntity;
|
|
|
10
|
+import org.springframework.http.HttpMethod;
|
|
9
|
11
|
import org.springframework.stereotype.Component;
|
|
10
|
12
|
import org.springframework.stereotype.Service;
|
|
|
13
|
+import org.springframework.util.LinkedMultiValueMap;
|
|
|
14
|
+import org.springframework.util.MultiValueMap;
|
|
|
15
|
+import org.springframework.web.client.RestTemplate;
|
|
11
|
16
|
|
|
12
|
17
|
import javax.annotation.Resource;
|
|
13
|
18
|
import java.util.Date;
|
|
|
@@ -26,7 +31,7 @@ public interface IntrusionService {
|
|
26
|
31
|
// 报警类型
|
|
27
|
32
|
private Integer sAlarmType;
|
|
28
|
33
|
// 报警时间
|
|
29
|
|
- private Date alarmNow;
|
|
|
34
|
+ private String alarmNow;
|
|
30
|
35
|
// 设备ip
|
|
31
|
36
|
private String deviceIP;
|
|
32
|
37
|
// 机构编码
|
|
|
@@ -39,8 +44,13 @@ public interface IntrusionService {
|
|
39
|
44
|
class IntrusionServiceImpl implements IntrusionService {
|
|
40
|
45
|
@Resource
|
|
41
|
46
|
private RedisUtil redisUtil;
|
|
|
47
|
+ @Resource
|
|
|
48
|
+ private RestTemplate restTemplate;
|
|
42
|
49
|
@Value("${spring.redis.ten-minutes}")
|
|
43
|
50
|
private long tenMinutes;
|
|
|
51
|
+ // 推送地址
|
|
|
52
|
+ @Value("${address.pushToIntrusion}")
|
|
|
53
|
+ private String pushToIntrusion;
|
|
44
|
54
|
@Resource
|
|
45
|
55
|
private IntrusionModel intrusionModel;
|
|
46
|
56
|
|
|
|
@@ -51,12 +61,14 @@ public interface IntrusionService {
|
|
51
|
61
|
// key 存在丢弃报警数据,不上报
|
|
52
|
62
|
log.info("Don't up!-> sAlarmType: {} alarmNow: {} deviceIP: {} orgCode: {}", sAlarmType, alarmNow, deviceIP, orgCode);
|
|
53
|
63
|
} else {
|
|
54
|
|
- // TODO 上报数据-接口
|
|
|
64
|
+ // 上报数据-接口
|
|
55
|
65
|
log.info("Up it!-> sAlarmType: {} alarmNow: {} deviceIP: {} orgCode: {}", sAlarmType, alarmNow, deviceIP, orgCode);
|
|
56
|
66
|
intrusionModel.setDeviceIP(deviceIP);
|
|
57
|
67
|
intrusionModel.setSAlarmType(sAlarmType);
|
|
58
|
|
- intrusionModel.setAlarmNow(DateUtils.stringToData(alarmNow));
|
|
|
68
|
+ intrusionModel.setAlarmNow(alarmNow);
|
|
59
|
69
|
intrusionModel.setOrgCode(orgCode);
|
|
|
70
|
+ HttpEntity<IntrusionModel> httpEntity = new HttpEntity<>(intrusionModel);
|
|
|
71
|
+ restTemplate.exchange(pushToIntrusion, HttpMethod.POST, httpEntity, Object.class);
|
|
60
|
72
|
// 设置缓存
|
|
61
|
73
|
redisUtil.set(deviceIP, JSON.toJSONString(intrusionModel), tenMinutes);
|
|
62
|
74
|
}
|