Ver código fonte

Merge remote-tracking branch 'origin/20210223' into 20210223

wangyangyang 4 anos atrás
pai
commit
79e08a27ff

+ 28 - 62
sms_water/src/main/java/com/huaxu/controller/AppPageReportController.java

@@ -41,14 +41,14 @@ public class AppPageReportController {
     @ApiOperation(value = "App总览——生产数据(本月)")
     public AjaxMessage<Map<String,Object>> getProductionDataForMonth(
             @ApiParam(value = "公司id,总公司传空值") @RequestParam(required = false) Integer companyOrgId){
-        List<DeviceWaterSupply> supplyWaterList = appPageReportService.deviceWaterReportForMonth(companyOrgId,"水源",4,1);
+        List<DeviceWaterSupply> intakeWaterList = appPageReportService.deviceWaterReportForMonth(companyOrgId,"水源",4,1);
         List<DeviceWaterSupply> makingWaterList = appPageReportService.deviceWaterReportForMonth(companyOrgId,"水厂",3,1);
         List<DeviceWaterSupply> sellerWaterList = appPageReportService.deviceSellerWaterReportForMonth(companyOrgId,1);
         Map<String,Object> map = new HashMap<String,Object>();
-        map.put("intake", supplyWaterList);
+        map.put("intake", intakeWaterList);
         map.put("making", makingWaterList);
         map.put("seller", sellerWaterList);
-        appPageReportService.CalculationNrw(supplyWaterList,makingWaterList,sellerWaterList,map);
+        appPageReportService.CalculationNrw(intakeWaterList,makingWaterList,sellerWaterList,map);
         return new AjaxMessage<>(ResultStatus.OK,map);
     }
 
@@ -63,7 +63,6 @@ public class AppPageReportController {
     public AjaxMessage<Map<String,Object>> getProductionDataForSameYear(
             @ApiParam(value = "公司id,总公司传空值") @RequestParam(required = false) Integer companyOrgId){
         LocalDate localDate = LocalDate.now();
-
         List<DeviceWaterSupply> supplyWaterList = appPageReportService.deviceWaterReportForMonth(companyOrgId,"水源",4,localDate.getMonthValue());
         List<DeviceWaterSupply> makingWaterList = appPageReportService.deviceWaterReportForMonth(companyOrgId,"水厂",3,localDate.getMonthValue());
         List<DeviceWaterSupply> sellerWaterList = appPageReportService.deviceSellerWaterReportForMonth(companyOrgId,localDate.getMonthValue());
@@ -102,17 +101,14 @@ public class AppPageReportController {
     @ApiOperation(value = "App总览——生产数据-取水环比(本月)")
     public AjaxMessage<Object> getProductionComparisonForSameMonth(@ApiParam(value = "公司id,总公司传空值") @RequestParam(required = false) Integer companyOrgId){
         LocalDate now = LocalDate.now();
-        LocalDate last = now.minusMonths(1);
+        List<DeviceWaterSupply> intakeComparisonList = appPageReportService.deviceWaterReportForMonth(companyOrgId,"水源",4,2);
+        List<DeviceWaterSupply> makingComparisonList =  appPageReportService.deviceWaterReportForMonth(companyOrgId,"水厂",3,2);
+        List<DeviceWaterSupply> sellerComparisonList = appPageReportService.deviceSellerWaterReportForMonth(companyOrgId,2);
 
-        List<DeviceWaterSupply> sameMakingWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水源",4, now.getYear(),now.getMonthValue(),1, now.getYear(),now.getMonthValue(),now.getDayOfMonth());
-        List<DeviceWaterSupply> lastMakingWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水源",4, last.getYear(),last.getMonthValue(),1, last.getYear(),last.getMonthValue(),last.getDayOfMonth());
-        List<DeviceWaterSupply> sameSupplyWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水厂",3, now.getYear(),now.getMonthValue(),1, now.getYear(),now.getMonthValue(),now.getDayOfMonth());
-        List<DeviceWaterSupply> lastSupplyWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水厂",3, last.getYear(),last.getMonthValue(),1, last.getYear(),last.getMonthValue(),last.getDayOfMonth());
         Map<String,Object> map = new HashMap<String,Object>();
-        map.put("intakeComparison",appPageReportService.CalculationComparison(sameMakingWaterList,lastMakingWaterList));
-        map.put("makingComparison",appPageReportService.CalculationComparison(sameSupplyWaterList,lastSupplyWaterList));
-        List<DeviceWaterSupply> sameSellerWaterList = appPageReportService.deviceSellerWaterReportForMonth(companyOrgId,2);
-        map.put("sellerComparison", sameSellerWaterList.get(0).getAmount().compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO : sameSellerWaterList.get(0).getAmount().multiply(new BigDecimal(100)).divide(sameSellerWaterList.get(1).getAmount(),3));
+        map.put("intakeComparison",appPageReportService.CalculationComparison2(intakeComparisonList,1));
+        map.put("makingComparison",appPageReportService.CalculationComparison2(makingComparisonList,1));
+        map.put("sellerComparison", appPageReportService.CalculationComparison2(sellerComparisonList,1));
         return new AjaxMessage<>(ResultStatus.OK,map);
     }
 
@@ -120,27 +116,14 @@ public class AppPageReportController {
     @ApiOperation(value = "App总览——生产数据-取水环比、供水环比、售水环比(本年)")
     public AjaxMessage<Object> getProductionComparisonForSameYear(@ApiParam(value = "公司id,总公司传空值") @RequestParam(required = false) Integer companyOrgId){
         LocalDate now = LocalDate.now();
-        LocalDate last = now.minusYears(1);
-
-        List<DeviceWaterSupply> sameMakingWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水源",4, now.getYear(),1,1, now.getYear(),now.getMonthValue(),now.getDayOfMonth());
-        List<DeviceWaterSupply> lastMakingWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水源",4, last.getYear(),1,1, last.getYear(),12,31);
-        List<DeviceWaterSupply> sameSupplyWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水厂",3, now.getYear(),1,1, now.getYear(),now.getMonthValue(),now.getDayOfMonth());
-        List<DeviceWaterSupply> lastSupplyWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水厂",3, last.getYear(),1,1, last.getYear(),12,31);
-        List<DeviceWaterSupply> sellerWaterList = appPageReportService.deviceSellerWaterReportForMonth(companyOrgId,now.getMonthValue()+12);
-        BigDecimal sameSellerAmount = new BigDecimal(0);
-        BigDecimal lastSellerAmount = new BigDecimal(0);
-        for( int i =0 ;i<sellerWaterList.size(); i++){
-            if(i>=12){
-                sameSellerAmount = sameSellerAmount.add(sellerWaterList.get(i).getAmount());
-            }
-            else{
-                lastSellerAmount = lastSellerAmount.add(sellerWaterList.get(i).getAmount());
-            }
-        }
+        List<DeviceWaterSupply> intakeComparisonList = appPageReportService.deviceWaterReportForMonth(companyOrgId,"水源",4,now.getMonthValue()+12);
+        List<DeviceWaterSupply> makingComparisonList =  appPageReportService.deviceWaterReportForMonth(companyOrgId,"水厂",3,now.getMonthValue()+12);
+        List<DeviceWaterSupply> sellerComparisonList = appPageReportService.deviceSellerWaterReportForMonth(companyOrgId,now.getMonthValue()+12);
+
         Map<String,Object> map = new HashMap<String,Object>();
-        map.put("intakeComparison",appPageReportService.CalculationComparison(sameMakingWaterList,lastMakingWaterList));
-        map.put("makingComparison",appPageReportService.CalculationComparison(sameSupplyWaterList,lastSupplyWaterList));
-        map.put("sellerComparison", lastSellerAmount.compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO : sameSellerAmount.multiply(new BigDecimal(100)).divide(lastSellerAmount,3));
+        map.put("intakeComparison",appPageReportService.CalculationComparison2(intakeComparisonList,2));
+        map.put("makingComparison",appPageReportService.CalculationComparison2(makingComparisonList,2));
+        map.put("sellerComparison", appPageReportService.CalculationComparison2(sellerComparisonList,2));
         return new AjaxMessage<>(ResultStatus.OK,map);
     }
 
@@ -148,33 +131,16 @@ public class AppPageReportController {
     @ApiOperation(value = "App总览——生产数据-取水环比、供水环比、售水环比(近一年)")
     public AjaxMessage<Object> getProductionComparisonForLast12Month(@ApiParam(value = "公司id,总公司传空值") @RequestParam(required = false) Integer companyOrgId){
         LocalDate now = LocalDate.now();
-        LocalDate last = now.minusMonths(11);
-
 
-        List<DeviceWaterSupply> sameMakingWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水源",4, last.getYear(),last.getMonthValue(),last.getDayOfMonth(), now.getYear(),now.getMonthValue(),now.getDayOfMonth());
-        List<DeviceWaterSupply> sameSupplyWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水厂",3, last.getYear(),last.getMonthValue(),last.getDayOfMonth(),now.getYear(),now.getMonthValue(),now.getDayOfMonth());
-        LocalDate last2 = last.minusDays(1);
-        LocalDate last3 = last2.minusMonths(11);
-        List<DeviceWaterSupply> lastMakingWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水源",4, last3.getYear(),last2.getMonthValue(),last2.getDayOfMonth(), last.getYear(),12,31);
-        List<DeviceWaterSupply> lastSupplyWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水厂",3, last.getYear(),1,1, last.getYear(),12,31);
 
-        List<DeviceWaterSupply> sellerWaterList = appPageReportService.deviceSellerWaterReportForMonth(companyOrgId,24);
+        List<DeviceWaterSupply> intakeComparisonList = appPageReportService.deviceWaterReportForMonth(companyOrgId,"水源",4,24);
+        List<DeviceWaterSupply> makingComparisonList =  appPageReportService.deviceWaterReportForMonth(companyOrgId,"水厂",3,24);
+        List<DeviceWaterSupply> sellerComparisonList = appPageReportService.deviceSellerWaterReportForMonth(companyOrgId,24);
 
-        BigDecimal sameSellerAmount = new BigDecimal(0);
-        BigDecimal lastSellerAmount = new BigDecimal(0);
-
-        for( int i =0 ;i<sellerWaterList.size(); i++){
-            if(i>=12){
-                sameSellerAmount = sameSellerAmount.add(sellerWaterList.get(i).getAmount());
-            }
-            else{
-                lastSellerAmount = lastSellerAmount.add(sellerWaterList.get(i).getAmount());
-            }
-        }
         Map<String,Object> map = new HashMap<String,Object>();
-        map.put("intakeComparison",appPageReportService.CalculationComparison(sameMakingWaterList,lastMakingWaterList));
-        map.put("makingComparison",appPageReportService.CalculationComparison(sameSupplyWaterList,lastSupplyWaterList));
-        map.put("sellerComparison",lastSellerAmount.compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO : sameSellerAmount.multiply(new BigDecimal(100)).divide(lastSellerAmount,3));
+        map.put("intakeComparison",appPageReportService.CalculationComparison2(intakeComparisonList,3));
+        map.put("makingComparison",appPageReportService.CalculationComparison2(makingComparisonList,3));
+        map.put("sellerComparison", appPageReportService.CalculationComparison2(sellerComparisonList,3));
         return new AjaxMessage<>(ResultStatus.OK,map);
     }
 
@@ -308,8 +274,8 @@ public class AppPageReportController {
     public AjaxMessage<Object> getSellerComparisonForSameMonth(@ApiParam(value = "公司id,总公司传空值") @RequestParam(required = false) Integer companyOrgId){
 
         List<DeviceWaterSupply> sellerWaterList = appPageReportService.deviceSellerAmountReportForMonth(companyOrgId,2);
-        BigDecimal receivableComparison = sellerWaterList.get(1).getReceivableAmount().compareTo(BigDecimal.ZERO)==0 ?BigDecimal.ZERO:sellerWaterList.get(0).getReceivableAmount().multiply(new BigDecimal(100)).divide(sellerWaterList.get(1).getReceivableAmount(),3);
-        BigDecimal receivedComparison = sellerWaterList.get(1).getReceivedAmount().compareTo(BigDecimal.ZERO)==0 ?BigDecimal.ZERO:sellerWaterList.get(0).getReceivedAmount().multiply(new BigDecimal(100)).divide(sellerWaterList.get(1).getReceivedAmount(),3);
+        BigDecimal receivableComparison = sellerWaterList.get(1).getReceivableAmount().compareTo(BigDecimal.ZERO)==0 ?BigDecimal.ZERO:sellerWaterList.get(0).getReceivableAmount().subtract(sellerWaterList.get(1).getReceivableAmount()).multiply(new BigDecimal(100)).divide(sellerWaterList.get(1).getReceivableAmount(),3);
+        BigDecimal receivedComparison = sellerWaterList.get(1).getReceivedAmount().compareTo(BigDecimal.ZERO)==0 ?BigDecimal.ZERO:sellerWaterList.get(0).getReceivedAmount().subtract(sellerWaterList.get(1).getReceivedAmount()).multiply(new BigDecimal(100)).divide(sellerWaterList.get(1).getReceivedAmount(),3);
         Map<String,Object> map = new HashMap<String,Object>();
         map.put("receivableComparison",receivableComparison);
         map.put("receivedComparison",receivedComparison);
@@ -337,8 +303,8 @@ public class AppPageReportController {
             }
         }
 
-        BigDecimal receivedComparison = receivedLastYearComparison.compareTo(BigDecimal.ZERO)==0 ?BigDecimal.ZERO:receivedSameYearComparison.multiply(new BigDecimal(100)).divide(receivedLastYearComparison,3);
-        BigDecimal receivableComparison = receivableLastYearComparison.compareTo(BigDecimal.ZERO)==0 ?BigDecimal.ZERO:receivableSameYearComparison.multiply(new BigDecimal(100)).divide(receivableLastYearComparison,3);
+        BigDecimal receivedComparison = receivedLastYearComparison.compareTo(BigDecimal.ZERO)==0 ?BigDecimal.ZERO:receivedSameYearComparison.subtract(receivedLastYearComparison).multiply(new BigDecimal(100)).divide(receivedLastYearComparison,3);
+        BigDecimal receivableComparison = receivableLastYearComparison.compareTo(BigDecimal.ZERO)==0 ?BigDecimal.ZERO:receivableSameYearComparison.subtract(receivableLastYearComparison).multiply(new BigDecimal(100)).divide(receivableLastYearComparison,3);
         Map<String,Object> map = new HashMap<String,Object>();
         map.put("receivableComparison",receivableComparison);
         map.put("receivedComparison",receivedComparison);
@@ -365,8 +331,8 @@ public class AppPageReportController {
                 receivableLastYearComparison =receivableLastYearComparison.add(sellerWaterList.get(i).getReceivableAmount());
             }
         }
-        BigDecimal receivedComparison = receivedLastYearComparison.compareTo(BigDecimal.ZERO)==0 ?BigDecimal.ZERO:receivedSameYearComparison.multiply(new BigDecimal(100)).divide(receivedLastYearComparison,3);
-        BigDecimal receivableComparison = receivableLastYearComparison.compareTo(BigDecimal.ZERO)==0 ?BigDecimal.ZERO:receivableSameYearComparison.multiply(new BigDecimal(100)).divide(receivableLastYearComparison,3);
+        BigDecimal receivedComparison = receivedLastYearComparison.compareTo(BigDecimal.ZERO)==0 ?BigDecimal.ZERO:receivedSameYearComparison.subtract(receivedLastYearComparison).multiply(new BigDecimal(100)).divide(receivedLastYearComparison,3);
+        BigDecimal receivableComparison = receivableLastYearComparison.compareTo(BigDecimal.ZERO)==0 ?BigDecimal.ZERO:receivableSameYearComparison.subtract(receivableLastYearComparison).multiply(new BigDecimal(100)).divide(receivableLastYearComparison,3);
         Map<String,Object> map = new HashMap<String,Object>();
         map.put("receivableComparison",receivableComparison);
         map.put("receivedComparison",receivedComparison);

+ 10 - 0
sms_water/src/main/java/com/huaxu/controller/MonitorDataReportController.java

@@ -1,6 +1,7 @@
 package com.huaxu.controller;
 
 import com.huaxu.dto.MonitorDataChartReportDeviceDto;
+import com.huaxu.dto.MonitorDataChartReportValueDto;
 import com.huaxu.dto.generalView.*;
 import com.huaxu.entity.DeviceEntity;
 import com.huaxu.model.AjaxMessage;
@@ -16,6 +17,8 @@ import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * @description
@@ -68,9 +71,16 @@ public class MonitorDataReportController {
             List<MonitorDataChartReportDeviceDto> energy = monitorDataReportService.monitorDataEnergyReport(reportType,sceneIds,localDate.getYear(),localDate.getMonthValue(),localDate.getDayOfMonth(),sceneType);
             //水质(PH8、余氯11、浊度10)
             List<MonitorDataChartReportDeviceDto> quality = monitorDataReportService.monitorDataQualityReport(reportType,sceneIds,localDate.getYear(),localDate.getMonthValue(),localDate.getDayOfMonth());
+            // 水电耗
+            List<MonitorDataChartReportDeviceDto> consumption = monitorDataReportService.monitorWaterPowerConsumptionReport(reportType,sceneIds,localDate.getYear(),localDate.getMonthValue(),localDate.getDayOfMonth(),1);
             //报警(报警次数)
             List<MonitorDataChartReportDeviceDto> alarm = monitorDataReportService.deviceAlarmReport(reportType,sceneIds,localDate.getYear(),localDate.getMonthValue(),localDate.getDayOfMonth());
 
+            Map<String,MonitorDataChartReportDeviceDto> map = consumption.stream().collect(Collectors.toMap(MonitorDataChartReportDeviceDto::getDeviceName, a -> a,(k1, k2)->k1));
+            for (MonitorDataChartReportDeviceDto energyDto: energy) {
+                MonitorDataChartReportDeviceDto reportDeviceDto =  map.get(energyDto.getDeviceName());
+                energyDto.getAttributeData().addAll(reportDeviceDto.getAttributeData());
+            }
             reportList.add(energy);
             reportList.add(quality);
             reportList.add(alarm);

+ 0 - 5
sms_water/src/main/java/com/huaxu/dao/AppReportMonitorMapper.java

@@ -36,9 +36,4 @@ public interface AppReportMonitorMapper {
                                              @Param("permissonType")Integer permissonType,
                                              @Param("programItems")List<ProgramItem> programItems);
 
-
-
-
-
-
 }

+ 10 - 0
sms_water/src/main/java/com/huaxu/dao/HomePageReportMapper.java

@@ -48,6 +48,16 @@ public interface HomePageReportMapper {
                                                  @Param("endMonth")Integer endMonth,
                                                  @Param("endDay")Integer endDay);
 
+    List<DeviceWaterSupply> getDeviceWaterForMonth(@Param("companyOrgId")Integer companyOrgId,
+                                                 @Param("sceneType")String sceneType, @Param("parmType")Integer parmType,
+                                                 @Param("tenantId")String tenantId, @Param("userType")String userType,
+                                                 @Param("permissonType")Integer permissonType,
+                                                 @Param("programItems")List<ProgramItem> programItems,
+                                                 @Param("startYear")Integer startYear,
+                                                 @Param("startMonth")Integer startMonth,
+                                                 @Param("endYear")Integer endYear,
+                                                 @Param("endMonth")Integer endMonth);
+
     CompanyCount countSceneByType(@Param("companyOrgId")Integer companyOrgId,
                                         @Param("tenantId")String tenantId, @Param("userType")String userType,
                                         @Param("permissonType")Integer permissonType,

+ 2 - 0
sms_water/src/main/java/com/huaxu/service/AbstractReportService.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.huaxu.common.StringUtils;
 import com.huaxu.dto.*;
+import com.huaxu.util.UserUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 
 import java.util.*;
@@ -133,6 +134,7 @@ public abstract class AbstractReportService<M extends BaseMapper<T>, T> extends
             reportDto.setDeviceIds(devices);
             reportDto.setParentSceneIds(queryDto.getIds());
         }
+        reportDto.setUserId(UserUtil.getCurrentUser().getId());
         return reportDto;
     }
 

+ 3 - 1
sms_water/src/main/java/com/huaxu/service/AppPageReportService.java

@@ -21,10 +21,12 @@ public interface AppPageReportService {
     List<DeviceWaterSupply> deviceWaterReportForMonth(Integer companyOrgId,String sceneType, Integer parmType,Integer month);
 
     //App数据总览-生产数据-环比-查询时间段内的取水量供水量
-    List<DeviceWaterSupply> deviceWaterReportForDay(Integer companyOrgId, String sceneType, Integer parmType, Integer startYear, Integer startMonth, Integer startDay, Integer endYear, Integer endMonth, Integer endDay) ;
+    List<DeviceWaterSupply> deviceWaterReportForMonth(Integer companyOrgId, String sceneType, Integer parmType, Integer startYear, Integer startMonth, Integer endYear, Integer endMonth);
 
     BigDecimal CalculationComparison(List<DeviceWaterSupply> sameWaterList, List<DeviceWaterSupply> lastWaterList);
 
+    BigDecimal CalculationComparison2(List<DeviceWaterSupply> comparisonList, int type);
+
     List<Map<String,Object>> findSceneAmount(Long companyOrgId,Integer months);
 
     void CalculationNrw(List<DeviceWaterSupply> supplyWaterList, List<DeviceWaterSupply> makingWaterList,List<DeviceWaterSupply> sellerWaterList,Map<String,Object> map);

+ 2 - 1
sms_water/src/main/java/com/huaxu/service/MonitorDataReportService.java

@@ -35,7 +35,8 @@ public interface MonitorDataReportService {
     List<MonitorDataChartReportDeviceDto> monitorDataQualityReport(Integer type, List<Long>  sceneIds, Integer year, Integer month , Integer day);
     //能耗对比
     List<MonitorDataChartReportDeviceDto> monitorDataEnergyReport(Integer type, List<Long>  sceneIds, Integer year, Integer month , Integer day, Integer sceneType);
-
+    // 水电耗
+    List<MonitorDataChartReportDeviceDto> monitorWaterPowerConsumptionReport(Integer type, List<Long>  sceneIds, Integer year, Integer month , Integer day, Integer sceneType);
     List<DeviceEntity> getDeviceBySceneTypeName(String sceneTypeName);
 
     List<MonitorDataChartReportDeviceDto> monitorDataDeviceReport(Integer type, List<Long>  deviceIds, Integer searchType, Integer year, Integer month , Integer day);

+ 37 - 6
sms_water/src/main/java/com/huaxu/service/impl/AppPageReportServiceImpl.java

@@ -121,20 +121,18 @@ public class AppPageReportServiceImpl implements AppPageReportService {
     }
 
     @Override
-    public List<DeviceWaterSupply> deviceWaterReportForDay(Integer companyOrgId, String sceneType, Integer parmType, Integer startYear, Integer startMonth, Integer startDay, Integer endYear, Integer endMonth, Integer endDay) {
+    public List<DeviceWaterSupply> deviceWaterReportForMonth(Integer companyOrgId, String sceneType, Integer parmType, Integer startYear, Integer startMonth, Integer endYear, Integer endMonth) {
         LoginUser loginUser = UserUtil.getCurrentUser();
         String tenantId = loginUser.getTenantId();
-        List<DeviceWaterSupply> deviceWaterSupplyList = homePageReportMapper.getDeviceWaterForDay(companyOrgId,
+        List<DeviceWaterSupply> deviceWaterSupplyList = homePageReportMapper.getDeviceWaterForMonth(companyOrgId,
                 sceneType,parmType ,
                 tenantId,loginUser.getType(),
                 loginUser.getPermissonType(),
                 loginUser.getProgramItemList(),
                 startYear,
                 startMonth,
-                startDay,
                 endYear,
-                endMonth,
-                endDay);
+                endMonth);
         return deviceWaterSupplyList;
     }
 
@@ -183,7 +181,36 @@ public class AppPageReportServiceImpl implements AppPageReportService {
         for(DeviceWaterSupply water : lastWaterList){
             lastWaterAmount = lastWaterAmount.add(water.getAmount());
         }
-        BigDecimal comparison = lastWaterAmount.compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO : sameWaterAmount.multiply(new BigDecimal(100)).divide(lastWaterAmount,2);
+        BigDecimal comparison = lastWaterAmount.compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO : sameWaterAmount.subtract(lastWaterAmount).multiply(new BigDecimal(100)).divide(lastWaterAmount,2);
+        return comparison;
+    }
+
+    public BigDecimal CalculationComparison2(List<DeviceWaterSupply> comparisonList, int type){
+
+        BigDecimal sameWaterAmount = new BigDecimal(0);
+        BigDecimal lastWaterAmount = new BigDecimal(0);
+        for(int i =0; i<comparisonList.size(); i++){
+            if(type == 1){
+                if(i==0){
+                    lastWaterAmount = lastWaterAmount.add(comparisonList.get(0).getAmount());
+                }
+                else {
+                    sameWaterAmount = sameWaterAmount.add(comparisonList.get(1).getAmount());
+                }
+            }
+            else if(type == 2 || type ==3) {
+
+                if(i>=12){
+                    sameWaterAmount = sameWaterAmount.add(comparisonList.get(i).getAmount());
+                }
+                else{
+                    lastWaterAmount = lastWaterAmount.add(comparisonList.get(i).getAmount());
+                }
+            }
+        }
+
+
+        BigDecimal comparison = lastWaterAmount.compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO : sameWaterAmount.subtract(lastWaterAmount).multiply(new BigDecimal(100)).divide(lastWaterAmount,2);
         return comparison;
     }
 
@@ -224,10 +251,14 @@ public class AppPageReportServiceImpl implements AppPageReportService {
             if(revenue == null){
                 deviceWaterSupply.setReceivableAmount(BigDecimal.ZERO);
                 deviceWaterSupply.setReceivedAmount(BigDecimal.ZERO);
+                deviceWaterSupply.setGeneralUserAmount(BigDecimal.ZERO);
+                deviceWaterSupply.setBigUserAmount(BigDecimal.ZERO);
             }
             else{
                 deviceWaterSupply.setReceivableAmount(new BigDecimal(revenue.getReceivableTotalAmount()));
                 deviceWaterSupply.setReceivedAmount(new BigDecimal(revenue.getReceivedTotalAmount()));
+                deviceWaterSupply.setGeneralUserAmount(new BigDecimal(revenue.getGeneralUserUsage()));
+                deviceWaterSupply.setBigUserAmount(new BigDecimal(revenue.getBigUserUsage()));
             }
             deviceWaterSupplies.add(i, deviceWaterSupply);
         }

+ 55 - 0
sms_water/src/main/java/com/huaxu/service/impl/MonitorDataReportServiceImpl.java

@@ -168,6 +168,61 @@ public class MonitorDataReportServiceImpl implements MonitorDataReportService {
         return monitorDataChartReportDeviceDtos;
     }
     @Override
+    public List<MonitorDataChartReportDeviceDto> monitorWaterPowerConsumptionReport(Integer type, List<Long> sceneIds, Integer year, Integer month , Integer day, Integer sceneType) {
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        List<MonitorDataChartReportDeviceDto> monitorDataChartReportDeviceDtos = null;
+        if (type != null && type == 3){
+            monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataEnergyReportByDay(sceneType,sceneIds,year,month,day,
+                    loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
+        } else if(type != null && type == 2){
+            monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataEnergyReportByMonth(sceneType,sceneIds,year,month,
+                    loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
+        } else if(type != null && type == 1){
+            monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataEnergyReportByYear(sceneType,sceneIds,year,
+                    loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
+        }
+        if (monitorDataChartReportDeviceDtos != null) {
+            FillLoseData(monitorDataChartReportDeviceDtos,type,year,month,day);
+        }
+        for (MonitorDataChartReportDeviceDto water: monitorDataChartReportDeviceDtos) {
+            List<MonitorDataChartReportAttributeDto> newAttrDataList  = new ArrayList();
+            MonitorDataChartReportAttributeDto newAttrData = new MonitorDataChartReportAttributeDto();
+            List<MonitorDataChartReportAttributeDto> attributeDtos =  water.getAttributeData();
+            newAttrData.setAttributeName("水电耗");
+            newAttrData.setUnit("kwh/㎡");
+            if (attributeDtos.size()  == 2) {
+                MonitorDataChartReportAttributeDto attributeDto1 = attributeDtos.get(0);
+                MonitorDataChartReportAttributeDto attributeDto2 = attributeDtos.get(1);
+                Map<Integer,MonitorDataChartReportValueDto> map1 = attributeDto1.getMonitorDataChartReportValue().stream().collect(Collectors.toMap(MonitorDataChartReportValueDto::getDateLabel, a -> a,(k1, k2)->k1));
+                Map<Integer,MonitorDataChartReportValueDto> map2 = attributeDto2.getMonitorDataChartReportValue().stream().collect(Collectors.toMap(MonitorDataChartReportValueDto::getDateLabel, a -> a,(k1, k2)->k1));
+                // 耗电量
+                if ("5".equals(attributeDto1.getAttributeType())) {
+                    calculation(attributeDto1, map2);
+                    newAttrData.setMonitorDataChartReportValue(attributeDto1.getMonitorDataChartReportValue());
+                } else {
+                    calculation(attributeDto2, map1);
+                    newAttrData.setMonitorDataChartReportValue(attributeDto2.getMonitorDataChartReportValue());
+                }
+            }
+            newAttrDataList.add(newAttrData);
+            water.setAttributeData(newAttrDataList);
+        }
+        return monitorDataChartReportDeviceDtos;
+    }
+
+    private void calculation(MonitorDataChartReportAttributeDto attributeDto, Map<Integer,MonitorDataChartReportValueDto> map){
+        for (MonitorDataChartReportValueDto valueDto : attributeDto.getMonitorDataChartReportValue()) {
+            BigDecimal b1 = new BigDecimal(valueDto.getData());
+            BigDecimal b2 = new BigDecimal(map.get(valueDto.getDateLabel()).getData());
+            valueDto.setMonitorData("");
+            if (b1.compareTo(new BigDecimal(0)) == 0 || b2.compareTo(new BigDecimal(0)) == 0) {
+                valueDto.setData(0d);
+            } else {
+                valueDto.setData(b1.divide(b2, 5, RoundingMode.HALF_UP).multiply(new BigDecimal(100)).doubleValue());
+            }
+        }
+    }
+    @Override
     public List<DeviceEntity> getDeviceBySceneTypeName(String sceneTypeName){
         LoginUser loginUser = UserUtil.getCurrentUser();
         return monitorDataReportMapper.getDeviceBySceneTypeName(sceneTypeName,loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());

+ 5 - 5
sms_water/src/main/resources/mapper/HomePageReportMapper.xml

@@ -481,22 +481,22 @@
     </select>
 
 
-    <!--查询时间段内的取水量供水量(精确到天)-->
-    <select id="getDeviceWaterForDay" resultType="com.huaxu.dto.generalView.DeviceWaterSupply">
+    <!--查询时间段内的取水量供水量-->
+    <select id="getDeviceWaterForMonth" resultType="com.huaxu.dto.generalView.DeviceWaterSupply">
         select
         r.year,r.month,r.day,
         sum(r.SUM_VALUE)/10000 as "amount"
         from sms_scene_type st
         left join sms_scene s on s.SCENE_TYPE_ID =st.id
         left join sms_device_parm dp on s.id=dp.PARENT_SCENE_ID
-        left join sms_month_report r on r.DEVICE_ID= dp.DEVICE_ID and r.ATTRIBUTE_ID = dp.ATTRIBUTE_ID
+        left join sms_year_report r on r.DEVICE_ID= dp.DEVICE_ID and r.ATTRIBUTE_ID = dp.ATTRIBUTE_ID
         where  dp.`STATUS`=1  and s.ENABLE_STATE = 1 and dp.TENANT_ID=#{tenantId}
         <if test="companyOrgId != null">
             and s.COMPANY_ORG_ID = #{companyOrgId}
         </if>
         and dp.PARM_TYPE = #{parmType} and st.SCENE_TYPE_NAME = #{sceneType}
-        and r.year*365 + r.month*30 +r.day >= #{startYear}*365 + #{startMonth} *30 + #{startDay}
-        and r.year*365 + r.month*30 +r.day &lt;= #{endYear}*365 + #{endMonth} *30 + #{endDay}
+        and r.year*12 + r.month >= #{startYear}*12 + #{startMonth}
+        and r.year*12 + r.month &lt;= #{endYear}*12 + #{endMonth}
         <if test="userType!=null and userType!=-999 and userType!=-9999 and  programItems != null and programItems.size() > 0">
             <if test="permissonType == 5 or permissonType == 2">
                 and ( s.DEPT_ORG_ID in