|
|
@@ -2,6 +2,7 @@ package com.unissoft.intrusion;
|
|
2
|
2
|
|
|
3
|
3
|
import com.alibaba.fastjson.JSON;
|
|
4
|
4
|
import com.unissoft.common.DateUtils;
|
|
|
5
|
+import com.unissoft.common.MyConstant;
|
|
5
|
6
|
import com.unissoft.utils.RedisUtil;
|
|
6
|
7
|
import lombok.Data;
|
|
7
|
8
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -29,7 +30,7 @@ public interface IntrusionService {
|
|
29
|
30
|
@Component
|
|
30
|
31
|
class IntrusionModel {
|
|
31
|
32
|
// 报警类型
|
|
32
|
|
- private Integer sAlarmType;
|
|
|
33
|
+ private Integer alarmType;
|
|
33
|
34
|
// 报警时间
|
|
34
|
35
|
private String alarmNow;
|
|
35
|
36
|
// 设备ip
|
|
|
@@ -44,19 +45,19 @@ public interface IntrusionService {
|
|
44
|
45
|
class IntrusionServiceImpl implements IntrusionService {
|
|
45
|
46
|
@Resource
|
|
46
|
47
|
private RedisUtil redisUtil;
|
|
47
|
|
- @Resource
|
|
48
|
|
- private RestTemplate restTemplate;
|
|
|
48
|
+ /*@Resource
|
|
|
49
|
+ private RestTemplate restTemplate;*/
|
|
|
50
|
+ // 推送地址
|
|
|
51
|
+ /*@Value("${address.pushToIntrusion}")
|
|
|
52
|
+ private String pushToIntrusion;*/
|
|
49
|
53
|
@Value("${spring.redis.ten-minutes}")
|
|
50
|
54
|
private long tenMinutes;
|
|
51
|
|
- // 推送地址
|
|
52
|
|
- @Value("${address.pushToIntrusion}")
|
|
53
|
|
- private String pushToIntrusion;
|
|
54
|
55
|
@Resource
|
|
55
|
56
|
private IntrusionModel intrusionModel;
|
|
56
|
57
|
|
|
57
|
58
|
@Override
|
|
58
|
59
|
public void pushIntrusion(Integer sAlarmType, String alarmNow, String deviceIP, String orgCode) {
|
|
59
|
|
- // redis key
|
|
|
60
|
+ /*// redis key
|
|
60
|
61
|
if (redisUtil.hasKey(deviceIP)) {
|
|
61
|
62
|
// key 存在丢弃报警数据,不上报
|
|
62
|
63
|
log.info("Don't up!-> sAlarmType: {} alarmNow: {} deviceIP: {} orgCode: {}", sAlarmType, alarmNow, deviceIP, orgCode);
|
|
|
@@ -71,7 +72,17 @@ public interface IntrusionService {
|
|
71
|
72
|
restTemplate.exchange(pushToIntrusion, HttpMethod.POST, httpEntity, Object.class);
|
|
72
|
73
|
// 设置缓存
|
|
73
|
74
|
redisUtil.set(deviceIP, JSON.toJSONString(intrusionModel), tenMinutes);
|
|
74
|
|
- }
|
|
|
75
|
+ }*/
|
|
|
76
|
+ // TODO 物联网到业务平台推送数据网络不通,修改为业务平台主动获取数据
|
|
|
77
|
+ // 上报数据-接口
|
|
|
78
|
+
|
|
|
79
|
+ intrusionModel.setDeviceIP(deviceIP);
|
|
|
80
|
+ intrusionModel.setAlarmType(sAlarmType);
|
|
|
81
|
+ intrusionModel.setAlarmNow(alarmNow);
|
|
|
82
|
+ intrusionModel.setOrgCode(orgCode);
|
|
|
83
|
+ // 设置异常闯入设备数据-hashCode
|
|
|
84
|
+ redisUtil.hset(MyConstant.INTRUSION_ALARM_IP, deviceIP, intrusionModel, tenMinutes);
|
|
|
85
|
+ log.info("Up it!-> sAlarmType: {} alarmNow: {} deviceIP: {} orgCode: {}", sAlarmType, alarmNow, deviceIP, orgCode);
|
|
75
|
86
|
}
|
|
76
|
87
|
}
|
|
77
|
88
|
}
|