|
@@ -13,10 +13,13 @@ import org.springframework.stereotype.Component;
|
13
|
13
|
import org.springframework.stereotype.Service;
|
14
|
14
|
import org.springframework.util.LinkedMultiValueMap;
|
15
|
15
|
import org.springframework.util.MultiValueMap;
|
|
16
|
+import org.springframework.util.StringUtils;
|
16
|
17
|
import org.springframework.web.client.RestTemplate;
|
17
|
18
|
|
18
|
19
|
import javax.annotation.Resource;
|
19
|
20
|
import java.util.Date;
|
|
21
|
+import java.util.HashMap;
|
|
22
|
+import java.util.Map;
|
20
|
23
|
|
21
|
24
|
/**
|
22
|
25
|
* @author qingsong.han
|
|
@@ -26,6 +29,8 @@ import java.util.Date;
|
26
|
29
|
public interface IntrusionService {
|
27
|
30
|
void pushIntrusion(Integer sAlarmType, String alarmNow, String deviceIP, String orgCode);
|
28
|
31
|
|
|
32
|
+ void editChannelCode(Map<String, String> channelCodes);
|
|
33
|
+
|
29
|
34
|
@Data
|
30
|
35
|
@Component
|
31
|
36
|
class IntrusionModel {
|
|
@@ -37,7 +42,7 @@ public interface IntrusionService {
|
37
|
42
|
private String deviceIP;
|
38
|
43
|
// 机构编码
|
39
|
44
|
private String orgCode;
|
40
|
|
- // 通道号
|
|
45
|
+ // ICC通道号
|
41
|
46
|
private String channelCode;
|
42
|
47
|
}
|
43
|
48
|
|
|
@@ -83,13 +88,20 @@ public interface IntrusionService {
|
83
|
88
|
intrusionModel.setAlarmNow(alarmNow);
|
84
|
89
|
intrusionModel.setOrgCode(orgCode);
|
85
|
90
|
// 添加通道号
|
86
|
|
- intrusionModel.setChannelCode(getChannelCode(deviceIP));
|
|
91
|
+ intrusionModel.setChannelCode(this.getChannelCode(deviceIP));
|
87
|
92
|
// 设置异常闯入设备数据-hashCode
|
88
|
93
|
redisUtil.hset(MyConstant.INTRUSION_ALARM_IP, deviceIP, intrusionModel, tenMinutes);
|
89
|
94
|
log.info("Up it!-> sAlarmType: {} alarmNow: {} deviceIP: {} orgCode: {}", sAlarmType, alarmNow, deviceIP, orgCode);
|
90
|
95
|
}
|
91
|
96
|
|
92
|
97
|
private String getChannelCode(String deviceIP) {
|
|
98
|
+ String channelCode = redisUtil.hget(MyConstant.ICC_CHANNEL_CODE, deviceIP).toString();
|
|
99
|
+ if (StringUtils.isEmpty(channelCode))
|
|
100
|
+ channelCode = this.staticChannelCode(deviceIP);
|
|
101
|
+ return channelCode;
|
|
102
|
+ }
|
|
103
|
+
|
|
104
|
+ private String staticChannelCode(String deviceIP) {
|
93
|
105
|
switch (deviceIP) {
|
94
|
106
|
case "192.168.193.16":
|
95
|
107
|
return "1000377$1$0$0";
|
|
@@ -123,6 +135,14 @@ public interface IntrusionService {
|
123
|
135
|
return "";
|
124
|
136
|
}
|
125
|
137
|
}
|
|
138
|
+
|
|
139
|
+ @Override
|
|
140
|
+ public void editChannelCode(Map<String, String> channelCodes) {
|
|
141
|
+ channelCodes.forEach((ip, code) ->
|
|
142
|
+ redisUtil.hset(MyConstant.ICC_CHANNEL_CODE, ip, code)
|
|
143
|
+ );
|
|
144
|
+ }
|
|
145
|
+
|
126
|
146
|
}
|
127
|
147
|
|
128
|
148
|
|