Explorar o código

Merge remote-tracking branch 'origin/master'

wangbo %!s(int64=4) %!d(string=hai) anos
pai
achega
8154ce7010

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

@@ -69,6 +69,15 @@ public class DayMonthYearReportController {
         IPage<DevicePressReportAttributeDto> iPage = new Page<>(pageNum, pageSize);
         iPage = reportService.getDevicePressReportByDeviceIds(iPage,ids,year,month,day,reportType,type);
         Pagination<DevicePressReportAttributeDto> pages = new Pagination<>(iPage);
+        for(DevicePressReportAttributeDto item : pages.getList())
+        {
+            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);
     }
 
@@ -87,6 +96,28 @@ public class DayMonthYearReportController {
         IPage<DeviceWaterReportAttributeDto> iPage = new Page<>(pageNum, pageSize);
         iPage = reportService.getDevicWaterReportByDeviceIds(iPage,ids,year,month,day,reportType);
         Pagination<DeviceWaterReportAttributeDto> pages = new Pagination<>(iPage);
+        for(DeviceWaterReportAttributeDto item : pages.getList())
+        {
+            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()==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()==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()==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()==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);
     }
 }

+ 0 - 5
sms_water/src/main/java/com/huaxu/dto/DevicePressReportAttributeDto.java

@@ -26,18 +26,13 @@ public class DevicePressReportAttributeDto implements Serializable {
     private Date collectDate;
 
     @ApiModelProperty(value = "最小值")
-    @JsonSerialize(using = Object6Serialize.class)
     private Double minValue;
     @ApiModelProperty(value = "最大值")
-    @JsonSerialize(using = Object6Serialize.class)
     private Double maxValue;
     @ApiModelProperty(value = "平均值")
-    @JsonSerialize(using = Object6Serialize.class)
     private Double avgValue;
     @ApiModelProperty(value = "合计值")
-    @JsonSerialize(using = Object6Serialize.class)
     private Double sumValue;
     @ApiModelProperty(value = "最新值")
-    @JsonSerialize(using = Object6Serialize.class)
     private Double latestValue;
 }

+ 0 - 15
sms_water/src/main/java/com/huaxu/dto/DeviceWaterReportAttributeDto.java

@@ -23,52 +23,37 @@ public class DeviceWaterReportAttributeDto implements Serializable {
     private Date collectDate;
 
     @ApiModelProperty(value = "PH最小值")
-    @JsonSerialize(using = Object6Serialize.class)
     private Double minPHValue;
     @ApiModelProperty(value = "PH最大值")
-    @JsonSerialize(using = Object6Serialize.class)
     private Double maxPHValue;
     @ApiModelProperty(value = "PH平均值")
-    @JsonSerialize(using = Object6Serialize.class)
     private Double avgPHValue;
     @ApiModelProperty(value = "PH合计值")
-    @JsonSerialize(using = Object6Serialize.class)
     private Double sumPHValue;
     @ApiModelProperty(value = "PH最新值")
-    @JsonSerialize(using = Object6Serialize.class)
     private Double latestPHValue;
 
 
     @ApiModelProperty(value = "CL最小值")
-    @JsonSerialize(using = Object6Serialize.class)
     private Double minCLValue;
     @ApiModelProperty(value = "CL最大值")
-    @JsonSerialize(using = Object6Serialize.class)
     private Double maxCLValue;
     @ApiModelProperty(value = "CL平均值")
-    @JsonSerialize(using = Object6Serialize.class)
     private Double avgCLValue;
     @ApiModelProperty(value = "CL合计值")
-    @JsonSerialize(using = Object6Serialize.class)
     private Double sumCLValue;
     @ApiModelProperty(value = "CL最新值")
-    @JsonSerialize(using = Object6Serialize.class)
     private Double latestCLValue;
 
     @ApiModelProperty(value = "Qu最小值")
-    @JsonSerialize(using = Object6Serialize.class)
     private Double minQuValue;
     @ApiModelProperty(value = "Qu最大值")
-    @JsonSerialize(using = Object6Serialize.class)
     private Double maxQuValue;
     @ApiModelProperty(value = "Qu平均值")
-    @JsonSerialize(using = Object6Serialize.class)
     private Double avgQuValue;
     @ApiModelProperty(value = "Qu合计值")
-    @JsonSerialize(using = Object6Serialize.class)
     private Double sumQuValue;
     @ApiModelProperty(value = "Qu最新值")
-    @JsonSerialize(using = Object6Serialize.class)
     private Double latestQuValue;
 
 }

+ 3 - 0
sms_water/src/main/java/com/huaxu/entity/DayReportEntity.java

@@ -121,6 +121,9 @@ public class DayReportEntity{
     /** 最新值 */
     @ApiModelProperty(value = "最新值")
     private Double latestValue;
+    /** 最新值 */
+    @ApiModelProperty(value = "初始值")
+    private Double firstValue;
 
     /** 采集时间 */
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8")

+ 6 - 4
sms_water/src/main/java/com/huaxu/service/DayReportService.java

@@ -139,16 +139,18 @@ public class DayReportService extends ServiceImpl<DayReportMapper, DayReportEnti
     }
     //计算固定的参数项
     private void calcUsage(ReportDto item, List<ReportDto> reportDtos) {
+        if(item==null||reportDtos.size()==0)
+            return;
         //固定参数项
         int index = -1;
         for (int i = 0; i < reportDtos.size(); i++) {
             if (reportDtos.get(i).getHour().equals(item.getHour()))
                 index = i;
         }
-        item.setYieldWaterUsage(reportDtos.get(index).getYieldWaterUsage());
-        item.setIntakeWaterUsage(reportDtos.get(index).getIntakeWaterUsage());
-        item.setPowerUsage(reportDtos.get(index).getPowerUsage());
-        item.setDrugUsage(reportDtos.get(index).getDrugUsage());
+        item.setYieldWaterUsage(reportDtos!=null&&reportDtos.get(index)!=null? reportDtos.get(index).getYieldWaterUsage():0);
+        item.setIntakeWaterUsage(reportDtos!=null&&reportDtos.get(index)!=null?reportDtos.get(index).getIntakeWaterUsage():0);
+        item.setPowerUsage(reportDtos!=null&&reportDtos.get(index)!=null?reportDtos.get(index).getPowerUsage():0);
+        item.setDrugUsage(reportDtos!=null&&reportDtos.get(index)!=null?reportDtos.get(index).getDrugUsage():0);
 //        if (index != -1) {
 //            if ((index + 2) <= reportDtos.size()) {
 //                item.setYieldWaterUsage(reportDtos.get(index).getYieldWaterUsage() - reportDtos.get(index + 1).getYieldWaterUsage());

+ 6 - 4
sms_water/src/main/java/com/huaxu/service/MonthReportService.java

@@ -133,16 +133,18 @@ public class MonthReportService extends ServiceImpl<MonthReportMapper, MonthRepo
 
     //计算固定的参数项
     private void calcUsage(ReportDto item, List<ReportDto> reportDtos) {
+        if(item==null||reportDtos.size()==0)
+            return;
         //固定参数项
         int index = -1;
         for (int i = 0; i < reportDtos.size(); i++) {
             if (reportDtos.get(i).getDay().equals(item.getDay()))
                 index = i;
         }
-        item.setYieldWaterUsage(reportDtos.get(index).getYieldWaterUsage());
-        item.setIntakeWaterUsage(reportDtos.get(index).getIntakeWaterUsage());
-        item.setPowerUsage(reportDtos.get(index).getPowerUsage());
-        item.setDrugUsage(reportDtos.get(index).getDrugUsage());
+        item.setYieldWaterUsage(reportDtos!=null&&reportDtos.get(index)!=null? reportDtos.get(index).getYieldWaterUsage():0);
+        item.setIntakeWaterUsage(reportDtos!=null&&reportDtos.get(index)!=null?reportDtos.get(index).getIntakeWaterUsage():0);
+        item.setPowerUsage(reportDtos!=null&&reportDtos.get(index)!=null?reportDtos.get(index).getPowerUsage():0);
+        item.setDrugUsage(reportDtos!=null&&reportDtos.get(index)!=null?reportDtos.get(index).getDrugUsage():0);
 //        if (index != -1) {
 //            if ((index + 2) <= reportDtos.size()) {
 //                item.setYieldWaterUsage(reportDtos.get(index).getYieldWaterUsage() - reportDtos.get(index + 1).getYieldWaterUsage());

+ 29 - 2
sms_water/src/main/java/com/huaxu/service/SecSupplyService.java

@@ -190,11 +190,12 @@ public class SecSupplyService {
 
         WaterPieStateDto waterPieStateDto4 = new WaterPieStateDto();
         waterPieStateDto4.setNormalCount(listTotal.get(0).getTotalCount()- listAlarmTotal.get(0).getNbnormalCount());
-        waterPieStateDto4.setNbnormalCount(listTotal.get(0).getNbnormalCount());
+        waterPieStateDto4.setNbnormalCount(listAlarmTotal.get(0).getNbnormalCount());
         waterPieStateDto4.setPercentage((double) (Math.round((Double.valueOf(listTotal.get(0).getTotalCount()- listAlarmTotal.get(0).getNbnormalCount())/Double.valueOf(listTotal.get(0).getTotalCount()))*100)));
         waterPieDto.setWaterQuality(waterPieStateDto4);
 
 
+
         List<ParmTypeCountDto> list = deviceParmService.findAlarmCount(deviceParmEntity);
         //余氯11 浊度9  PH8  cod 15   15,8,9,11,18,19
         for(ParmTypeCountDto item : list)
@@ -209,7 +210,7 @@ public class SecSupplyService {
                     waterPieStateDto1.setPercentage((double) (Math.round((Double.valueOf(listTotal.get(0).getTotalCount()- item.getNbnormalCount())/Double.valueOf(listTotal.get(0).getTotalCount()))*100)));
                     waterPieDto.setPh(waterPieStateDto1);
                     break;
-                case 9:
+                case 10:
                     WaterPieStateDto waterPieStateDto2 = new WaterPieStateDto();
                     waterPieStateDto2.setNormalCount(listTotal.get(0).getTotalCount()- item.getNbnormalCount());
                     waterPieStateDto2.setNbnormalCount(item.getNbnormalCount());
@@ -227,6 +228,32 @@ public class SecSupplyService {
             }
         }
 
+        if(waterPieDto.getPh()==null)
+        {
+            WaterPieStateDto waterPieStateDto1 = new WaterPieStateDto();
+            waterPieStateDto1.setNormalCount(listTotal.get(0).getTotalCount());
+            waterPieStateDto1.setNbnormalCount(0);
+            DecimalFormat df1 = new DecimalFormat("#.00");
+            waterPieStateDto1.setPercentage((double) (Math.round((Double.valueOf(listTotal.get(0).getTotalCount())/Double.valueOf(listTotal.get(0).getTotalCount()))*100)));
+            waterPieDto.setPh(waterPieStateDto1);
+        }
+        if(waterPieDto.getTurbidity()==null)
+        {
+            WaterPieStateDto waterPieStateDto2 = new WaterPieStateDto();
+            waterPieStateDto2.setNormalCount(listTotal.get(0).getTotalCount());
+            waterPieStateDto2.setNbnormalCount(0);
+            DecimalFormat df2 = new DecimalFormat("#.00");
+            waterPieStateDto2.setPercentage((double) (Math.round((Double.valueOf(listTotal.get(0).getTotalCount())/Double.valueOf(listTotal.get(0).getTotalCount()))*100)));
+            waterPieDto.setTurbidity(waterPieStateDto2);
+        }
+        if(waterPieDto.getResidualChlorine()==null)
+        {
+            WaterPieStateDto waterPieStateDto3 = new WaterPieStateDto();
+            waterPieStateDto3.setNormalCount(listTotal.get(0).getTotalCount());
+            waterPieStateDto3.setNbnormalCount(0);
+            waterPieStateDto3.setPercentage((double) (Math.round((Double.valueOf(listTotal.get(0).getTotalCount())/Double.valueOf(listTotal.get(0).getTotalCount()))*100)));
+            waterPieDto.setResidualChlorine(waterPieStateDto3);
+        }
         return waterPieDto;
     }
 }

+ 7 - 4
sms_water/src/main/java/com/huaxu/service/YearReportService.java

@@ -133,16 +133,19 @@ public class YearReportService extends ServiceImpl<YearReportMapper, YearReportE
     }
     //计算固定的参数项
     private void calcUsage(ReportDto item, List<ReportDto> reportDtos) {
+        if(item==null||reportDtos.size()==0)
+            return;
         //固定参数项
         int index = -1;
         for (int i = 0; i < reportDtos.size(); i++) {
             if (reportDtos.get(i).getMonth().equals(item.getMonth()))
                 index = i;
         }
-        item.setYieldWaterUsage(reportDtos.get(index).getYieldWaterUsage());
-        item.setIntakeWaterUsage(reportDtos.get(index).getIntakeWaterUsage());
-        item.setPowerUsage(reportDtos.get(index).getPowerUsage());
-        item.setDrugUsage(reportDtos.get(index).getDrugUsage());
+
+        item.setYieldWaterUsage(reportDtos!=null&&reportDtos.get(index)!=null? reportDtos.get(index).getYieldWaterUsage():0);
+        item.setIntakeWaterUsage(reportDtos!=null&&reportDtos.get(index)!=null?reportDtos.get(index).getIntakeWaterUsage():0);
+        item.setPowerUsage(reportDtos!=null&&reportDtos.get(index)!=null?reportDtos.get(index).getPowerUsage():0);
+        item.setDrugUsage(reportDtos!=null&&reportDtos.get(index)!=null?reportDtos.get(index).getDrugUsage():0);
 //        if (index != -1) {
 //            if ((index + 2) <= reportDtos.size()) {
 //                item.setYieldWaterUsage(reportDtos.get(index).getYieldWaterUsage() - reportDtos.get(index + 1).getYieldWaterUsage());

+ 9 - 3
sms_water/src/main/java/com/huaxu/service/impl/MonitorDataServiceImpl.java

@@ -140,6 +140,7 @@ public class MonitorDataServiceImpl implements MonitorDataService , Initializing
                         .max("$dataValues.dataValue").as("maxValue")
                         .avg("$dataValues.dataValue").as("avgValue")
 //                        .sum("$dataValues.dataValue").as("sumValue")
+                        .first("$dataValues.dataValue").as("firstValue")
                         .last("$dataValues.dataValue").as("latestValue")
                         .last("$collectDate").as("collectDate")
                         .count().as("countNum")
@@ -164,9 +165,14 @@ public class MonitorDataServiceImpl implements MonitorDataService , Initializing
         if(hourDatas.size()>0){
             //计算累计值
             for(DayReportEntity dayReportEntity : hourDatas){
-                if(dayReportEntity.getLatestValue()!=null && lastHourDataMap.containsKey(dayReportEntity.getMapkey())
-                        && lastHourDataMap.get(dayReportEntity.getMapkey()).getLatestValue() != null){
-                    dayReportEntity.setSumValue(new BigDecimal(dayReportEntity.getLatestValue().toString()).subtract(new BigDecimal(lastHourDataMap.get(dayReportEntity.getMapkey()).getLatestValue().toString())).doubleValue());
+                if(dayReportEntity.getLatestValue()!=null && lastHourDataMap.containsKey(dayReportEntity.getMapkey())){
+                    //上一个小时有值
+                    if(  lastHourDataMap.get(dayReportEntity.getMapkey()).getLatestValue() != null){
+                        dayReportEntity.setSumValue(new BigDecimal(dayReportEntity.getLatestValue().toString()).subtract(new BigDecimal(lastHourDataMap.get(dayReportEntity.getMapkey()).getLatestValue().toString())).doubleValue());
+                    }else if(dayReportEntity.getFirstValue() != null){//上一个小时没有值,取本小时的初始值
+                        dayReportEntity.setSumValue(new BigDecimal(dayReportEntity.getLatestValue().toString()).subtract(new BigDecimal(dayReportEntity.getFirstValue().toString())).doubleValue());
+                    }
+
                 }
             }
             monitorDataMapper.batchInsertDayReport(hourDatas);

+ 13 - 2
sms_water/src/main/java/com/huaxu/service/impl/OnlineMonitorImpl.java

@@ -96,8 +96,6 @@ public class OnlineMonitorImpl implements OnlineMonitorService {
                     Double d2= monitorDataCollectDto.getSceneTypeName().equals("水源")?(o2.getIntakeWaterUsage()==null?0d:o2.getIntakeWaterUsage()):(o2.getYieldWaterUsage()==null?0d:o2.getYieldWaterUsage());
                     if(d1>d2){
                         return -1;
-                    }else if(d1.equals(d1)) {
-                        return 0;
                     }
                     return 0;
                 }
@@ -251,6 +249,19 @@ public class OnlineMonitorImpl implements OnlineMonitorService {
 
         List<MonitorDataCollectDto> result=onlineMonitorMapper.statsDeviceParm(onlineDataDto);
         GetCalMonitorData(result,result);
+        //去掉没有数据的值
+        result.removeIf(r->r.getYieldWaterUsage() == null);
+        //按水量倒序排序
+        result.sort(new Comparator<MonitorDataCollectDto>() {
+            @Override
+            public int compare(MonitorDataCollectDto o1, MonitorDataCollectDto o2) {
+                if(o1.getYieldWaterUsage()!=null&&o2.getYieldWaterUsage()!=null&&
+                        o1.getYieldWaterUsage()>o2.getYieldWaterUsage()){
+                    return -1;
+                }
+                return 0;
+            }
+        });
         return result;
     }
     /**

+ 6 - 0
sms_water/src/main/resources/mapper/DayReportMapper.xml

@@ -177,6 +177,12 @@
                 #{dramaId.id}
             </foreach>
         </if>
+        <if test="report.parentSceneIds != null">
+           and  a.PARENT_SCENE_ID in
+            <foreach collection="report.parentSceneIds" item="dramaId" open="(" close=")" separator=",">
+                #{dramaId}
+            </foreach>
+        </if>
         <if test="report.year != null ">and c.`YEAR`=#{report.year}</if>
         <if test="report.month != null ">and c.`MONTH`=#{report.month}</if>
         <if test="report.day != null ">and c.`DAY`=#{report.day}</if>

+ 2 - 2
sms_water/src/main/resources/mapper/DeviceParmMapper.xml

@@ -255,12 +255,12 @@
         </foreach>
     </select>
     <select id="findAlarmCount" resultType="com.huaxu.dto.ParmTypeCountDto">
-        select tab.parmType,sum(tab.nbnormalCount) as "nbnormalCount" from(
+        select tab.parmType,sum(ifnull(tab.nbnormalCount,0)) as "nbnormalCount" from(
         select  b.PARENT_SCENE_ID,b.PARM_TYPE as "parmType",
         case when count(c.id)>0 then 1 else 0 end  as "nbnormalCount"
         from sms_device_scene a
         INNER JOIN sms_device_parm b on a.DEVICE_ID=b.DEVICE_ID
-               and a.PARENT_SCENE_ID=b.PARENT_SCENE_ID and b.PARM_TYPE in (15,8,9,11,18,19) and b.`STATUS`=1
+               and a.PARENT_SCENE_ID=b.PARENT_SCENE_ID and b.PARM_TYPE in (15,8,10,11,18,19) and b.`STATUS`=1
         LEFT JOIN  sms_alarm_details c on c.PARENT_SCENE_ID=b.PARENT_SCENE_ID
                and c.ATTRIBUTE_ID=b.ATTRIBUTE_ID and c.STATE=1
         where a.PARENT_SCENE_ID in

+ 6 - 0
sms_water/src/main/resources/mapper/MonthReportMapper.xml

@@ -174,6 +174,12 @@
                 #{dramaId.id}
             </foreach>
         </if>
+        <if test="report.parentSceneIds != null">
+            and  a.PARENT_SCENE_ID in
+            <foreach collection="report.parentSceneIds" item="dramaId" open="(" close=")" separator=",">
+                #{dramaId}
+            </foreach>
+        </if>
         <if test="report.year != null ">and c.`YEAR`=#{report.year}</if>
         <if test="report.month != null ">and c.`MONTH`=#{report.month}</if>
         <if test="report.parentSceneId != null ">and c.PARENT_SCENE_ID=#{report.parentSceneId}</if>

+ 1 - 1
sms_water/src/main/resources/mapper/OnlineMonitorMapper.xml

@@ -207,7 +207,7 @@
     <!--查询地图参数数据-->
     <select id="selectMapParam" resultMap="monitorDataMap">
         select
-        <include refid="Base_Column_List"/>
+        <include refid="Base_Column_List"/>,if (t7.alarm_count>0, 1, 0) scene_state
         from sms_scene t1
         <include refid="sceneDeviceJoins"/>
         <include refid="sceneAlarmJoins"/>

+ 6 - 0
sms_water/src/main/resources/mapper/YearReportMapper.xml

@@ -171,6 +171,12 @@
                 #{dramaId.id}
             </foreach>
         </if>
+        <if test="report.parentSceneIds != null > 0">
+            and  a.PARENT_SCENE_ID in
+            <foreach collection="report.parentSceneIds" item="dramaId" open="(" close=")" separator=",">
+                #{dramaId}
+            </foreach>
+        </if>
         <if test="report.year != null ">and c.`YEAR`=#{report.year}</if>
         <if test="report.month != null ">and c.`MONTH`=#{report.month}</if>
         <if test="report.parentSceneId != null ">and a.PARENT_SCENE_ID=#{report.parentSceneId}</if>