Browse Source

三位小数

wangyangyang 4 years ago
parent
commit
d063b58b89

+ 20 - 20
sms_water/src/main/java/com/huaxu/controller/DayMonthYearReportController.java

@@ -71,11 +71,11 @@ public class DayMonthYearReportController {
         Pagination<DevicePressReportAttributeDto> pages = new Pagination<>(iPage);
         for(DevicePressReportAttributeDto item : pages.getList())
         {
-            item.setAvgValue((double)Math.round(item.getAvgValue()*1000)/1000);
-            item.setMinValue((double)Math.round(item.getMinValue()*1000)/1000);
-            item.setMaxValue((double)Math.round(item.getMaxValue()*1000)/1000);
-            item.setSumValue((double)Math.round(item.getSumValue()*1000)/1000);
-            item.setLatestValue((double)Math.round(item.getLatestValue()*1000)/1000);
+            item.setAvgValue((double)Math.round(item.getAvgValue()==null?0:item.getAvgValue()*1000)/1000);
+            item.setMinValue((double)Math.round(item.getMinValue()==null?0:item.getMinValue()*1000)/1000);
+            item.setMaxValue((double)Math.round(item.getMaxValue()==null?0:item.getMaxValue()*1000)/1000);
+            item.setSumValue((double)Math.round(item.getSumValue()==null?0:item.getSumValue()*1000)/1000);
+            item.setLatestValue((double)Math.round(item.getLatestValue()==null?0:item.getLatestValue()*1000)/1000);
         }
 
         return new AjaxMessage<>(ResultStatus.OK,pages);
@@ -98,25 +98,25 @@ public class DayMonthYearReportController {
         Pagination<DeviceWaterReportAttributeDto> pages = new Pagination<>(iPage);
         for(DeviceWaterReportAttributeDto item : pages.getList())
         {
-            item.setAvgCLValue((double)Math.round(item.getAvgCLValue()*1000)/1000);
-            item.setAvgPHValue((double)Math.round(item.getAvgPHValue()*1000)/1000);
-            item.setAvgQuValue((double)Math.round(item.getAvgQuValue()*1000)/1000);
+            item.setAvgCLValue((double)Math.round(item.getAvgCLValue()==null?0:item.getAvgCLValue()*1000)/1000);
+            item.setAvgPHValue((double)Math.round(item.getAvgPHValue()==null?0:item.getAvgPHValue()*1000)/1000);
+            item.setAvgQuValue((double)Math.round(item.getAvgQuValue()==null?0:item.getAvgQuValue()*1000)/1000);
 
-            item.setMinCLValue((double)Math.round(item.getMinCLValue()*1000)/1000);
-            item.setMinPHValue((double)Math.round(item.getMinPHValue()*1000)/1000);
-            item.setMinQuValue((double)Math.round(item.getMinQuValue()*1000)/1000);
+            item.setMinCLValue((double)Math.round(item.getMinCLValue()==null?0:item.getMinCLValue()*1000)/1000);
+            item.setMinPHValue((double)Math.round(item.getMinPHValue()==null?0:item.getMinPHValue()*1000)/1000);
+            item.setMinQuValue((double)Math.round(item.getMinQuValue()==null?0:item.getMinQuValue()*1000)/1000);
 
-            item.setMaxCLValue((double)Math.round(item.getMaxCLValue()*1000)/1000);
-            item.setMaxPHValue((double)Math.round(item.getMaxPHValue()*1000)/1000);
-            item.setMaxQuValue((double)Math.round(item.getMaxQuValue()*1000)/1000);
+            item.setMaxCLValue((double)Math.round(item.getMaxCLValue()==null?0:item.getMaxCLValue()*1000)/1000);
+            item.setMaxPHValue((double)Math.round(item.getMaxPHValue()==null?0:item.getMaxPHValue()*1000)/1000);
+            item.setMaxQuValue((double)Math.round(item.getMaxQuValue()==null?0:item.getMaxQuValue()*1000)/1000);
 
-            item.setSumCLValue((double)Math.round(item.getSumCLValue()*1000)/1000);
-            item.setSumPHValue((double)Math.round(item.getSumPHValue()*1000)/1000);
-            item.setSumQuValue((double)Math.round(item.getSumQuValue()*1000)/1000);
+            item.setSumCLValue((double)Math.round(item.getSumCLValue()==null?0:item.getSumCLValue()*1000)/1000);
+            item.setSumPHValue((double)Math.round(item.getSumPHValue()==null?0:item.getSumPHValue()*1000)/1000);
+            item.setSumQuValue((double)Math.round(item.getSumQuValue()==null?0:item.getSumQuValue()*1000)/1000);
 
-            item.setLatestCLValue((double)Math.round(item.getLatestCLValue()*1000)/1000);
-            item.setLatestPHValue((double)Math.round(item.getLatestPHValue()*1000)/1000);
-            item.setLatestQuValue((double)Math.round(item.getLatestQuValue()*1000)/1000);
+            item.setLatestCLValue((double)Math.round(item.getLatestCLValue()==null?0:item.getLatestCLValue()*1000)/1000);
+            item.setLatestPHValue((double)Math.round(item.getLatestPHValue()==null?0:item.getLatestPHValue()*1000)/1000);
+            item.setLatestQuValue((double)Math.round(item.getLatestQuValue()==null?0:item.getLatestQuValue()*1000)/1000);
         }
         return new AjaxMessage<>(ResultStatus.OK,pages);
     }