فهرست منبع

修改监测指标历史采集值报错

xujiaheng 3 سال پیش
والد
کامیت
201c6689ae

+ 1 - 1
src/main/java/com/persagy/apm/alarmservice/dependency/eqdiagnose/model/MonitorIndicatorRecordListItemVO.java

@@ -22,7 +22,7 @@ public class MonitorIndicatorRecordListItemVO {
     private String monitorIndicatorId;
     
     @ApiModelProperty("时间")
-    private Date date;
+    private String date;
     
     @ApiModelProperty("值")
     private String value;

+ 13 - 8
src/main/java/com/persagy/apm/alarmservice/dependency/eqdiagnose/service/EqDiagnoseServiceImpl.java

@@ -5,10 +5,13 @@ import com.persagy.apm.alarmservice.dependency.eqdiagnose.model.MonitorIndicator
 import com.persagy.apm.alarmservice.dependency.eqdiagnose.model.QueryMonitorIndicatorRecordDTO;
 import com.persagy.apm.common.response.CommonResult;
 import com.persagy.apm.common.response.PageList;
+import com.persagy.apm.energyalarmstarter.alarmdata.utils.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -35,7 +38,7 @@ public class EqDiagnoseServiceImpl {
      * @version V1.0 2021/5/19 3:36 下午
      */
     public Map<Date, String> queryMonitorIndicatorRecord(
-            QueryMonitorIndicatorRecordDTO queryMonitorIndicatorRecordDTO) {
+            QueryMonitorIndicatorRecordDTO queryMonitorIndicatorRecordDTO) throws ParseException {
         // feign查询
         CommonResult<PageList<MonitorIndicatorRecordListItemVO>> pageListCommonResult =
                 eqDiagnoseClient.queryMonitorIndicatorRecord(queryMonitorIndicatorRecordDTO);
@@ -52,12 +55,14 @@ public class EqDiagnoseServiceImpl {
         if (CollectionUtils.isEmpty(records)) {
             return new HashMap<>(0);
         }
-        return records.stream().filter(record -> record.getDate() != null).collect(
-                Collectors.toMap(
-                        MonitorIndicatorRecordListItemVO::getDate,
-                        MonitorIndicatorRecordListItemVO::getValue
-                )
-        );
-
+        Map<Date, String> result = new HashMap<>();
+        SimpleDateFormat ft = new SimpleDateFormat(DateUtils.SDF_SECOND);
+        for (MonitorIndicatorRecordListItemVO record : records) {
+            if(record.getDate() != null){
+                Date date = ft.parse(record.getDate());
+                result.put(date,record.getValue());
+            }
+        }
+        return result;
     }
 }

+ 2 - 2
src/main/java/com/persagy/apm/alarmservice/group/monitorindicator/service/impl/MonitorIndicatorServiceImpl.java

@@ -37,6 +37,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
+import java.text.ParseException;
 import java.util.*;
 
 /**
@@ -453,7 +454,7 @@ public class MonitorIndicatorServiceImpl extends ServiceImpl<MonitorIndicatorMap
      * @version V1.0 2021/9/27 2:35 下午
      */
     private Map<String, Map<Date, String>> getIndicatorHistoryValues(
-            String objId, List<String> infoCodeList, Date startTime, Date endTime) {
+            String objId, List<String> infoCodeList, Date startTime, Date endTime) throws ParseException {
         // monitorId -> (time -> value)
         Map<String, Map<Date, String>> monitorValuesMap = new HashMap<>();
         // infoCodeList:[indicatorId]
@@ -469,7 +470,6 @@ public class MonitorIndicatorServiceImpl extends ServiceImpl<MonitorIndicatorMap
                     queryMonitorIndicatorRecord(queryMonitorIndicatorRecordDTO);
             monitorValuesMap.put(indicatorId, indicatorRecordMap);
         }
-
         return monitorValuesMap;
     }
 }