|
@@ -1,13 +1,12 @@
|
|
|
package org.jeecg.modules.homePageData.service.impl;
|
|
|
|
|
|
import org.jeecg.common.util.oConvertUtils;
|
|
|
-import org.jeecg.modules.deviceLesm.entity.*;
|
|
|
+import org.jeecg.modules.deviceLesm.entity.DeviceRegion;
|
|
|
+import org.jeecg.modules.deviceLesm.entity.DeviceRegionInformation;
|
|
|
import org.jeecg.modules.deviceLesm.mapper.DevicePointMapper;
|
|
|
-import org.jeecg.modules.deviceLesm.service.IDeviceInformationService;
|
|
|
import org.jeecg.modules.deviceLesm.service.IDeviceRegionService;
|
|
|
import org.jeecg.modules.gatherData.entity.FpgMiddleTwoData;
|
|
|
import org.jeecg.modules.gatherData.mapper.FpgGatherDataMapper;
|
|
|
-import org.jeecg.modules.deviceLesm.entity.DeviceRegion;
|
|
|
import org.jeecg.modules.homePageData.entity.LeanEventWarnInfoResult;
|
|
|
import org.jeecg.modules.homePageData.mapper.LeanEventWarnInfoMapper;
|
|
|
import org.jeecg.modules.homePageData.service.IHomePageDataService;
|
|
@@ -15,6 +14,7 @@ import org.jeecg.modules.systemConfig.peaksAndValleysTimeConfig.entity.PeaksAndV
|
|
|
import org.jeecg.modules.systemConfig.peaksAndValleysTimeConfig.service.IPeaksAndValleysTimeConfigService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
@@ -117,15 +117,25 @@ public class HomePageDataServiceImpl implements IHomePageDataService {
|
|
|
devices.add(map);
|
|
|
});
|
|
|
}
|
|
|
+ // 先计算一次总和
|
|
|
+ int total = online.get() + offline.get();
|
|
|
res.put("res", devices);
|
|
|
res.put("deviceTotal", online.get() + offline.get());
|
|
|
- res.put("online", online.get() * 100 / (online.get() + offline.get()) + "%");
|
|
|
- res.put("offline", offline.get() * 100 / (online.get() + offline.get()) + "%");
|
|
|
+ res.put("online", calculateRate(online.get(), total) + "%");
|
|
|
+ res.put("offline", calculateRate(offline.get(), total) + "%");
|
|
|
res.put("onlineSum", online.get());
|
|
|
res.put("offlineSum", offline.get());
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
+ private static String calculateRate(int value, int total) {
|
|
|
+ if (value == 0 || total == 0) {
|
|
|
+ return "0";
|
|
|
+ } else {
|
|
|
+ return value * 100 / total + "";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<Map<String, String>> illegalMetering() {
|
|
|
List<DeviceRegion> list = deviceRegionService.list();
|