فهرست منبع

北向通道处理代码修改提交

jingyuanchao 1 سال پیش
والد
کامیت
a5347546a9

+ 7 - 19
soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/api/service/impl/IotDvrChannelServiceImpl.java

@@ -83,7 +83,7 @@ public class IotDvrChannelServiceImpl extends ServiceImpl<IotDvrChannelMapper, I
         if (org != null) {
             //制作一个随时变化的key
             Boolean flag = redisTemplate.hasKey(CacheConstants.CHANNEL_KEY);
-            if (!flag) {
+            if (Boolean.FALSE.equals(flag)) {
                 //判断是否存在这个key
                 this.redisTemplate.opsForValue().set(CacheConstants.CHANNEL_KEY, UK);
             } else {
@@ -161,7 +161,6 @@ public class IotDvrChannelServiceImpl extends ServiceImpl<IotDvrChannelMapper, I
             redisTemplate.expire(UK + CacheConstants.AFTER_DATA, 1, TimeUnit.HOURS);
         }
         northErrorService.saveErrorData(errors);
-
         return ReceiveErrorDto.success();
     }
 
@@ -192,12 +191,7 @@ public class IotDvrChannelServiceImpl extends ServiceImpl<IotDvrChannelMapper, I
     public void channelCacheDeal() {
         try {
             Boolean flag = redisTemplate.hasKey(CacheConstants.CHANNEL_KEY);
-            if (!flag) {
-                return;
-            }
-
-            Boolean isData = this.redisTemplate.hasKey(CacheConstants.CHANNEL_KEY);
-            if (!isData) {
+            if (Boolean.FALSE.equals(flag)) {
                 return;
             }
 
@@ -205,22 +199,16 @@ public class IotDvrChannelServiceImpl extends ServiceImpl<IotDvrChannelMapper, I
 
             ListOperations<String, EquipmentOrgVo> lso = this.redisTemplate.opsForList();
             List<EquipmentOrgVo> list = lso.range(UK, 0, -1);
-            int voSize = list.size();
-            if (voSize > 0) {
-                lso.trim(UK, voSize, -1L);
+            if (ObjectUtil.isEmpty(list)) {
+                return;
             }
-
+            lso.trim(UK, list.size(), -1L);
             ListOperations<String, IotDvrChannel> cso = this.redisTemplate.opsForList();
             List<IotDvrChannel> devices = cso.range(UK + RedisKey.AFTER_DATA, 0, -1);
-            int devSize = devices.size();
-            if (devSize > 0) {
-                cso.trim(UK + RedisKey.AFTER_DATA, devSize, -1L);
-            }
-
-            if (list.size() == 0) {
+            if (ObjectUtil.isEmpty(devices)) {
                 return;
             }
-
+            cso.trim(UK + RedisKey.AFTER_DATA, devices.size(), -1L);
             //获取要进行批量处理的通道信息,并通过主机code,通道id,机构id进行去重
             List<IotDvrChannel> devis = devices.stream().collect(Collectors.collectingAndThen(
                     Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getChannelCode() + ";" + o.getHostCode() + ";" + o.getOrgId()))), ArrayList::new));