Browse Source

ICC 动态缓存+静态数据

hanqingsong 1 year ago
parent
commit
fb4fc0673a

+ 1 - 0
src/main/java/com/unissoft/intrusion/GetIntrusionController.java

@@ -18,6 +18,7 @@ public class GetIntrusionController {
18
     @Resource
18
     @Resource
19
     private GetIntrusionService getIntrusionService;
19
     private GetIntrusionService getIntrusionService;
20
 
20
 
21
+    // 底代码业务平台获取海康摄像头异常信息接口
21
     @GetMapping("/pullIntrusion")
22
     @GetMapping("/pullIntrusion")
22
     public Object pullIntrusion() {
23
     public Object pullIntrusion() {
23
         return getIntrusionService.pullIntrusion();
24
         return getIntrusionService.pullIntrusion();

+ 10 - 2
src/main/java/com/unissoft/intrusion/IntrusionController.java

@@ -1,15 +1,17 @@
1
 package com.unissoft.intrusion;
1
 package com.unissoft.intrusion;
2
 
2
 
3
 import lombok.extern.slf4j.Slf4j;
3
 import lombok.extern.slf4j.Slf4j;
4
+import org.springframework.web.bind.annotation.GetMapping;
4
 import org.springframework.web.bind.annotation.PostMapping;
5
 import org.springframework.web.bind.annotation.PostMapping;
6
+import org.springframework.web.bind.annotation.RequestParam;
5
 import org.springframework.web.bind.annotation.RestController;
7
 import org.springframework.web.bind.annotation.RestController;
6
 
8
 
7
 import javax.annotation.Resource;
9
 import javax.annotation.Resource;
8
-import java.util.Date;
10
+import java.util.Map;
9
 
11
 
10
 /**
12
 /**
11
  * @author qingsong.han
13
  * @author qingsong.han
12
- * @description: 接收库点摄像头信息并推送到业务平台
14
+ * @description: 接收库点摄像头信息
13
  * @create 2022-11-07 10:19
15
  * @create 2022-11-07 10:19
14
  */
16
  */
15
 @Slf4j
17
 @Slf4j
@@ -18,9 +20,15 @@ public class IntrusionController {
18
     @Resource
20
     @Resource
19
     private IntrusionService intrusionService;
21
     private IntrusionService intrusionService;
20
 
22
 
23
+    // 接收库点海康摄像头异常信息
21
     @PostMapping("/pushIntrusion")
24
     @PostMapping("/pushIntrusion")
22
     public void pushIntrusion(Integer sAlarmType, String alarmNow, String deviceIP, String orgCode) {
25
     public void pushIntrusion(Integer sAlarmType, String alarmNow, String deviceIP, String orgCode) {
23
         intrusionService.pushIntrusion(sAlarmType, alarmNow, deviceIP, orgCode);
26
         intrusionService.pushIntrusion(sAlarmType, alarmNow, deviceIP, orgCode);
24
     }
27
     }
25
 
28
 
29
+    // 修改ICC通道号编码接口ICC_CHANNEL_CODE key:value(IP:channelCode)
30
+    @GetMapping("/editChannelCode")
31
+    public void editChannelCode(@RequestParam Map<String, String> channelCodes) {
32
+        intrusionService.editChannelCode(channelCodes);
33
+    }
26
 }
34
 }

+ 22 - 2
src/main/java/com/unissoft/intrusion/IntrusionService.java

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

+ 1 - 1
src/main/resources/application.yml

@@ -10,7 +10,7 @@ spring:
10
     time-zone: GMT+8
10
     time-zone: GMT+8
11
   # dev: 开发环境,prod: 生产环境(线上)
11
   # dev: 开发环境,prod: 生产环境(线上)
12
   profiles:
12
   profiles:
13
-    active: dev
13
+    active: prod
14
 ---
14
 ---
15
 spring:
15
 spring:
16
   profiles: dev
16
   profiles: dev