shaohongbo 3 år sedan
förälder
incheckning
76c8d44a23

+ 18 - 2
src/main/java/com/persagy/apm/diagnose/indicatorrecord/service/impl/MonitorIndicatorRecordServiceImpl.java

@@ -530,7 +530,9 @@ public class MonitorIndicatorRecordServiceImpl extends ServiceImpl<MonitorIndica
                 if (CollectionUtils.isEmpty(value) || value.size() != infoCodes.size()) {
                     continue;
                 }
+                String sentValue = CollectDataUtil.buildSendParam(value);
                 AlarmWebSocketServer.sendMsgToClients(projectDTO.getProjectId(), CollectDataUtil.buildSendParam(value));
+                log.info("指标发送报表服务数据:" + projectDTO.getProjectId() + sentValue);
                 endTime = DateUtils.str2Date(dateListEntry.getKey(), DateUtils.SDF_SECOND);
             }
             configItemSendTimeDTO.setLastSendTime(endTime);
@@ -579,7 +581,7 @@ public class MonitorIndicatorRecordServiceImpl extends ServiceImpl<MonitorIndica
      * @return: com.persagy.apm.diagnose.indicatorrecord.model.dto.ConfigItemDataSendTimeDTO
      */
     private ConfigItemDataSendTimeDTO getConfigItemSendTimeDTO(ProjectDTO projectDTO, AlarmConfigItem alarmConfigItem) throws Exception {
-        ConfigItemDataSendTimeDTO sendTimeDTO = (ConfigItemDataSendTimeDTO) redisUtil.hget(RedisUtil.PROJECT_ITEM_SEND_TIME + ":" + projectDTO.getProjectId(), alarmConfigItem.getId());
+        ConfigItemDataSendTimeDTO sendTimeDTO = (ConfigItemDataSendTimeDTO) redisUtil.get(getRedisSendDataKey(projectDTO.getProjectId(), alarmConfigItem.getId()));
         if (sendTimeDTO == null) {
             sendTimeDTO = ConfigItemDataSendTimeDTO.builder().objId(alarmConfigItem.getObjId()).configItemid(alarmConfigItem.getId()).lastSendTime(getDefultStartTime()).build();
         }
@@ -587,6 +589,20 @@ public class MonitorIndicatorRecordServiceImpl extends ServiceImpl<MonitorIndica
     }
 
     /**
+     * @title getRedisSendDataKey
+     * @description 获取发数时间redis key
+     * @author leifeng
+     * @param: projectId
+     * @param: alarmConfigItemId
+     * @updateTime 2021/10/14 19:56
+     * @return: java.lang.String
+     * @throws
+     */
+    private String getRedisSendDataKey(String projectId, String alarmConfigItemId) {
+        return RedisUtil.PROJECT_ITEM_SEND_TIME + ":" + projectId + ":" + alarmConfigItemId;
+    }
+
+    /**
      * @title updateRedisConfigItemSendTimeDTO
      * @description 更新缓存中报警配置发数时间
      * @author leifeng
@@ -595,7 +611,7 @@ public class MonitorIndicatorRecordServiceImpl extends ServiceImpl<MonitorIndica
      * @updateTime 2021/9/25 20:05
      */
     private void updateRedisConfigItemSendTimeDTO(String projectId, ConfigItemDataSendTimeDTO sendTimeDTO) {
-        redisUtil.hset(RedisUtil.PROJECT_ITEM_SEND_TIME + ":" + projectId, sendTimeDTO.getConfigItemid(), sendTimeDTO, SendDataTimeKeyTime);
+        redisUtil.set(getRedisSendDataKey(projectId, sendTimeDTO.getConfigItemid()), sendTimeDTO, SendDataTimeKeyTime);
     }
 
     /**