Explorar el Código

处理无数据展示及排序情况

wangchenghong hace 3 años
padre
commit
5945e188dd

+ 19 - 8
src/main/java/com/persagy/apm/energy/report/centermiddleware/service/impl/ICenterMiddlewareWebServiceImp.java

@@ -117,6 +117,8 @@ public class ICenterMiddlewareWebServiceImp implements ICenterMiddlewareWebServi
                     dateGraphItemVO.setValue(eer);
                     dateGraphItemVOList.add(dateGraphItemVO);
                 }
+                log.info("项目:"+pjId+"allCoolingCapacity:"+allCoolingCapacity);
+                log.info("项目:"+pjId+"allPowerConsumption:"+allPowerConsumption);
                 Double allEer = null;
                 if (allCoolingCapacity != null && allPowerConsumption != null && allPowerConsumption != 0.0) {
                     allEer = allCoolingCapacity / allPowerConsumption;
@@ -137,12 +139,22 @@ public class ICenterMiddlewareWebServiceImp implements ICenterMiddlewareWebServi
     }
 
     private List<Date> getMaxOrMinDateList(List<DateGraphItemVO> dateGraphItemVOList, Integer orderType) {
+        if (CollectionUtils.isEmpty(dateGraphItemVOList)) {
+            return new ArrayList<>();
+        }
+        List<DateGraphItemVO> dataList = new ArrayList<>();
+        for (DateGraphItemVO vo : dateGraphItemVOList) {
+            if (vo.getValue() == null) {
+                continue;
+            }
+            dataList.add(vo);
+        }
         Map<String, Integer> sortMap = new HashMap<>();
         sortMap.put("value", orderType);
-        DataUtils.sort(dateGraphItemVOList, sortMap);
+        DataUtils.sort(dataList, sortMap);
         List<Date> resultList = new ArrayList<>();
         Double maxOrMinData = null;
-        for (DateGraphItemVO vo : dateGraphItemVOList) {
+        for (DateGraphItemVO vo : dataList) {
             if (vo.getValue() == null) {
                 continue;
             }
@@ -242,14 +254,13 @@ public class ICenterMiddlewareWebServiceImp implements ICenterMiddlewareWebServi
                         Double currentDayCoolData = day_coolDataMap.get(date);
                         Double nextDayCoolData = day_coolDataMap.get(DateUtils.getDayOff(date, 1));
                         Double allCool = dataMap.get(date);
-                        if (allCool == null) {
-                            allCool = 0.0;
-                        }
-                        Double cool = 0.0;
                         if (currentDayCoolData != null && nextDayCoolData != null) {
-                            cool = nextDayCoolData - currentDayCoolData;
+                            if (allCool == null) {
+                                allCool = 0.0;
+                            }
+                            Double cool = nextDayCoolData - currentDayCoolData;
+                            allCool = allCool + cool;
                         }
-                        allCool = allCool + cool;
                         dataMap.put(date, allCool);
                     }
                 }