Browse Source

优化计算逻辑

shaohongbo 3 years ago
parent
commit
2d2013824b

+ 5 - 16
src/main/java/com/persagy/apm/diagnose/indicatorrecord/service/impl/MonitorIndicatorRecordServiceImpl.java

@@ -205,21 +205,14 @@ public class MonitorIndicatorRecordServiceImpl implements IMonitorIndicatorRecor
     /**
      * 判断项目是否已经被计算
      *
-     * @param projectId
-     * @param projectIndicatorCompute
-     * @return
      */
     private Boolean checkProjectIsCalcd(String projectId, ProjectIndicatorCompute projectIndicatorCompute) {
         Object redisComputeRound = redisUtil.hget(DiAgnoseConst.RedisConstants.TargetComputeTime, projectId);
-        if (redisComputeRound != null && projectIndicatorCompute != null
-                && projectIndicatorCompute.getComputeRound() < Long.parseLong(redisComputeRound.toString())) {
-            return true;
-        }
-        return false;
+        return redisComputeRound != null && projectIndicatorCompute != null
+                && projectIndicatorCompute.getComputeRound() < Long.parseLong(redisComputeRound.toString());
     }
 
     /**
-     * @throws
      * @title getObjIdAndInfoCodeFromRules
      * @description 通过报警条件获取所有对象及其监控点位, objId_infoCode
      * @author leifeng
@@ -408,10 +401,10 @@ public class MonitorIndicatorRecordServiceImpl implements IMonitorIndicatorRecor
      * 清除所有iot数据发送时间
      *
      * @author lixing
-     * @version V1.0 2021/12/18 12:36 下午
      */
     private void clearAllIotDataSendTime() {
         Set<Object> keys = redisTemplate.keys("ALL-PROJECT_ITEM_SEND_TIME*");
+        assert keys != null;
         redisTemplate.delete(keys);
     }
 
@@ -419,7 +412,6 @@ public class MonitorIndicatorRecordServiceImpl implements IMonitorIndicatorRecor
      * 删除报警条件状态缓存
      *
      * @author lixing
-     * @version V1.0 2021/12/18 12:31 下午
      */
     private void cleanEqdxAlarmConditionState() {
         Cursor<Map.Entry<Object, Object>> entryCursor = redisTemplate.opsForHash().scan(
@@ -428,7 +420,7 @@ public class MonitorIndicatorRecordServiceImpl implements IMonitorIndicatorRecor
                         .count(10000).build());
 
         while (entryCursor.hasNext()) {
-            Map.Entry next = entryCursor.next();
+            Map.Entry<Object, Object> next = entryCursor.next();
 
             String key = next.getKey().toString();
 
@@ -499,7 +491,6 @@ public class MonitorIndicatorRecordServiceImpl implements IMonitorIndicatorRecor
     }
 
     /**
-     * @throws
      * @title getTimekeyAndRecordListGteLt
      * @description 查询该时间段的需要发送的指标数据, key为时间字符串
      * @author leifeng
@@ -528,7 +519,6 @@ public class MonitorIndicatorRecordServiceImpl implements IMonitorIndicatorRecor
     }
 
     /**
-     * @throws
      * @title getObjIdAlarmItemCodeAndInfoCodes
      * @description 获取对象报警类型及监控指标list, key为objId_itemCode
      * @author leifeng
@@ -600,7 +590,7 @@ public class MonitorIndicatorRecordServiceImpl implements IMonitorIndicatorRecor
      * @return: com.persagy.apm.diagnose.indicatorrecord.model.dto.ConfigItemDataSendTimeDTO
      */
     private ConfigItemDataSendTimeDTO getConfigItemSendTimeDTO(ProjectDTO projectDTO, String objIdAndAlarmItemCode) throws Exception {
-        ConfigItemDataSendTimeDTO sendTimeDTO = null;
+        ConfigItemDataSendTimeDTO sendTimeDTO;
         Object obj = redisUtil.get(getRedisSendDataKey(projectDTO.getProjectId(), objIdAndAlarmItemCode));
         if (null != obj) {
             sendTimeDTO = JSONUtil.toBean(obj.toString(), ConfigItemDataSendTimeDTO.class);
@@ -611,7 +601,6 @@ public class MonitorIndicatorRecordServiceImpl implements IMonitorIndicatorRecor
     }
 
     /**
-     * @throws
      * @title getRedisSendDataKey
      * @description 获取发数时间redis key
      * @author leifeng