Forráskód Böngészése

报表需要能自定义查询时间(水源、水厂、管网、泵站)报表、图表、对比分析

lihui007 3 éve
szülő
commit
7ccc8d1d4c
23 módosított fájl, 854 hozzáadás és 250 törlés
  1. 29 4
      common/src/main/java/com/huaxu/util/DatesUtil.java
  2. 3 1
      readme.md
  3. 10 34
      sms_water/src/main/java/com/huaxu/controller/DayMonthYearReportController.java
  4. 35 23
      sms_water/src/main/java/com/huaxu/controller/MonitorDataReportController.java
  5. 9 0
      sms_water/src/main/java/com/huaxu/dao/DayReportMapper.java
  6. 16 1
      sms_water/src/main/java/com/huaxu/dao/MonitorDataReportMapper.java
  7. 4 4
      sms_water/src/main/java/com/huaxu/dao/MonthReportMapper.java
  8. 4 4
      sms_water/src/main/java/com/huaxu/dao/YearReportMapper.java
  9. 9 0
      sms_water/src/main/java/com/huaxu/dto/ReportDto.java
  10. 51 0
      sms_water/src/main/java/com/huaxu/dto/ReportPageQueryDto.java
  11. 17 4
      sms_water/src/main/java/com/huaxu/dto/ReportQueryDto.java
  12. 60 2
      sms_water/src/main/java/com/huaxu/service/AbstractReportService.java
  13. 2 30
      sms_water/src/main/java/com/huaxu/service/DayReportService.java
  14. 9 8
      sms_water/src/main/java/com/huaxu/service/MonitorDataReportService.java
  15. 4 28
      sms_water/src/main/java/com/huaxu/service/MonthReportService.java
  16. 49 40
      sms_water/src/main/java/com/huaxu/service/ReportService.java
  17. 5 29
      sms_water/src/main/java/com/huaxu/service/YearReportService.java
  18. 138 37
      sms_water/src/main/java/com/huaxu/service/impl/MonitorDataReportServiceImpl.java
  19. 47 0
      sms_water/src/main/resources/mapper/DayReportMapper.xml
  20. 253 0
      sms_water/src/main/resources/mapper/MonitorDataReportMapper.xml
  21. 54 0
      sms_water/src/main/resources/mapper/MonthReportMapper.xml
  22. 45 0
      sms_water/src/main/resources/mapper/YearReportMapper.xml
  23. 1 1
      user_auth/src/main/java/com/huaxu/controller/ThirdPartyLoginController.java

+ 29 - 4
common/src/main/java/com/huaxu/util/DatesUtil.java

@@ -3,6 +3,9 @@ package com.huaxu.util;
 import java.sql.Timestamp;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.*;
 /*
  * 由于为了以后使用方便,所有方法的返回类型都设为了 java.utils.Date 请在使用时根据自己的需要进行日期格式化处理,如:
@@ -529,6 +532,27 @@ public class DatesUtil {
 		}
 		return null ;
 	}
+
+
+	/**
+	* @Author lihui
+	* @Description 获取月份具体天数
+	* @Date  2021/4/15
+	* @Param [timeString]
+	* @return int
+	**/
+	public static int getMouthDays(String timeString) {
+		SimpleDateFormat simpleDate = new SimpleDateFormat("yyyy-MM");
+		Calendar rightNow = Calendar.getInstance();
+		try{
+			rightNow.setTime(simpleDate.parse(timeString));
+		}catch(ParseException e){
+			e.printStackTrace();
+		}
+
+		int days = rightNow.getActualMaximum(Calendar.DAY_OF_MONTH);//根据年月 获取月份天数
+		return days;
+	}
 	public static void main(String[] args) {
 		//String d = "2019-11-14 13:10:16";
 		//System.out.println(DatesUtil.parseDate(d, DatesUtil.DATE_TIME_FORMAT));
@@ -539,9 +563,10 @@ public class DatesUtil {
 //		Set<String> iter1 = DatesUtil.betweenMonth(DatesUtil.beforeYear(1),new Date());
 //		System.out.println(JSON.toJSONString(iter));
 //		System.out.println(JSON.toJSONString(iter1));
-
-		String d = "Wed Jan 02 03:09:49 CST 2019";
-		System.out.println(DatesUtil.format(d));
-
+		LocalDate  startDate =
+				LocalDate.parse("2017-02-02 08:59:12", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+		LocalDate  endDate =
+				LocalDate.parse("2018-03-02 08:59:12", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+		System.out.println(startDate.getYear());
 	}
 }

+ 3 - 1
readme.md

@@ -22,4 +22,6 @@
 4、ALTER TABLE sms_device_parm ADD SHOW_AVG_VALUE smallint comment '是否展示平均值'
 5、ALTER TABLE sms_device_parm ADD SHOW_MAX_VALUE smallint comment '是否展示最大值'
 6、ALTER TABLE sms_device_parm ADD SHOW_SUM_VALUE smallint comment '是否展示合计值'
-7、ALTER TABLE sms_device_parm ADD SHOW_LATEST_VALUE smallint comment '是否展示最新值'
+7、ALTER TABLE sms_device_parm ADD SHOW_LATEST_VALUE smallint comment '是否展示最新值'
+### sms_month_report表添加索引
+1.ALTER TABLE sms_month_report ADD  INDEX `index_collect_date`(`COLLECT_DATE`) USING BTREE 

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

@@ -65,17 +65,9 @@ public class DayMonthYearReportController {
     @ApiOperation(value = "按年月日统计报表")
     @RequestMapping(value = "/getReportBySceneIdsNews", method = RequestMethod.POST)
     @ResponseBody
-    public AjaxMessage<Pagination<ReportDto>> getReportBySceneIdsNews(
-            @RequestParam Integer pageNum,
-            @RequestParam Integer pageSize,
-            @ApiParam(value = "场景IDS", required = true) @RequestParam(required = true) Long[] ids,
-            @ApiParam(value = "查询年", required = false) @RequestParam(required = false) Integer year ,
-            @ApiParam(value = "查询月", required = false) @RequestParam(required = false) Integer month ,
-            @ApiParam(value = "查询日", required = false) @RequestParam(required = false) Integer day ,
-            @ApiParam(value = "报表类型(0日 1月 2年)", required = true) @RequestParam(required = true) Integer reportType
-    ) {
-        IPage<ReportDto> iPage = new Page<>(pageNum, pageSize);
-        iPage = reportService.getReportBySceneIdsNew(iPage,ids,year,month,day,reportType);
+    public AjaxMessage<Pagination<ReportDto>> getReportBySceneIdsNews(@RequestBody ReportQueryDto queryDto) {
+        IPage<ReportDto> iPage = new Page<>(queryDto.getPageNum(), queryDto.getPageSize());
+        iPage = reportService.getReportBySceneIdsNew(iPage, queryDto);
         Pagination<ReportDto> pages = new Pagination<>(iPage);
         return new AjaxMessage<>(ResultStatus.OK,pages);
     }
@@ -83,18 +75,9 @@ public class DayMonthYearReportController {
     @ApiOperation(value = "按设备统计压力及流量年月日统计报表")
     @RequestMapping(value = "/getDevicePressReportByDeviceIdsNew", method = RequestMethod.POST)
     @ResponseBody
-    public AjaxMessage<Pagination<ReportDto>> getDevicePressReportByDeviceIdsNew(
-            @RequestParam Integer pageNum,
-            @RequestParam Integer pageSize,
-            @ApiParam(value = "设备IDS", required = true) @RequestParam(required = true) Long[] ids,
-            @ApiParam(value = "查询年", required = false) @RequestParam(required = false) Integer year ,
-            @ApiParam(value = "查询月", required = false) @RequestParam(required = false) Integer month ,
-            @ApiParam(value = "查询日", required = false) @RequestParam(required = false) Integer day ,
-            @ApiParam(value = "类型(1压力 2流量)", required = false) @RequestParam(required = false) Integer type ,
-            @ApiParam(value = "报表类型(0日 1月 2年)", required = true) @RequestParam(required = true) Integer reportType
-    ) {
-        IPage<ReportDto> iPage = new Page<>(pageNum, pageSize);
-        iPage = reportService.getPipeDevicePressReportByDeviceIds(iPage,ids,year,month,day,reportType,type);
+    public AjaxMessage<Pagination<ReportDto>> getDevicePressReportByDeviceIdsNew(@RequestBody ReportQueryDto queryDto) {
+        IPage<ReportDto> iPage = new Page<>(queryDto.getPageNum(), queryDto.getPageSize());
+        iPage = reportService.getPipeDevicePressReportByDeviceIds(iPage, queryDto);
         Pagination<ReportDto> pages = new Pagination<>(iPage);
         return new AjaxMessage<>(ResultStatus.OK,pages);
     }
@@ -130,17 +113,10 @@ public class DayMonthYearReportController {
     @ApiOperation(value = "按设备统计水质年月日统计报表")
     @RequestMapping(value = "/getDevicWaterReportByDeviceIdsNew", method = RequestMethod.POST)
     @ResponseBody
-    public AjaxMessage<Pagination<ReportDto>> getDevicWaterReportByDeviceIdsNew(
-            @RequestParam Integer pageNum,
-            @RequestParam Integer pageSize,
-            @ApiParam(value = "设备IDS", required = true) @RequestParam(required = true) Long[] ids,
-            @ApiParam(value = "查询年", required = false) @RequestParam(required = false) Integer year ,
-            @ApiParam(value = "查询月", required = false) @RequestParam(required = false) Integer month ,
-            @ApiParam(value = "查询日", required = false) @RequestParam(required = false) Integer day ,
-            @ApiParam(value = "报表类型(0日 1月 2年)", required = true) @RequestParam(required = true) Integer reportType
-    ) {
-        IPage<ReportDto> iPage = new Page<>(pageNum, pageSize);
-        iPage = reportService.getPipeDevicePressReportByDeviceIds(iPage,ids,year,month,day,reportType,3);
+    public AjaxMessage<Pagination<ReportDto>> getDevicWaterReportByDeviceIdsNew(@RequestBody ReportQueryDto queryDto) {
+        queryDto.setType(3);
+        IPage<ReportDto> iPage = new Page<>(queryDto.getPageNum(), queryDto.getPageSize());
+        iPage = reportService.getPipeDevicePressReportByDeviceIds(iPage,queryDto);
         Pagination<ReportDto> pages = new Pagination<>(iPage);
         return new AjaxMessage<>(ResultStatus.OK,pages);
     }

+ 35 - 23
sms_water/src/main/java/com/huaxu/controller/MonitorDataReportController.java

@@ -1,5 +1,6 @@
 package com.huaxu.controller;
 
+import com.huaxu.common.StringUtils;
 import com.huaxu.dto.MonitorDataChartReportDeviceDto;
 import com.huaxu.dto.MonitorDataChartReportValueDto;
 import com.huaxu.dto.generalView.*;
@@ -37,20 +38,26 @@ public class MonitorDataReportController {
     @ApiOperation(value = "统计分析——图表")
     public AjaxMessage<List<MonitorDataChartReportDeviceDto>> MonitorDataChartReport(
             @ApiParam(value = "场景id", required = true) @RequestParam Long sceneId,
-            @ApiParam(value = "时间", required = true) @RequestParam String reportDate,
-            @ApiParam(value = "类型,1年2月3日", required = true) @RequestParam Integer reportType
+            @ApiParam(value = "时间") @RequestParam(name = "reportDate",required = false) String reportDate,
+            @ApiParam(value = "类型,1年2月3日4自定义", required = true) @RequestParam Integer reportType,
+            @ApiParam(value = "开始时间") @RequestParam(name = "startTime",required = false) String startTime,
+            @ApiParam(value = "结束时间") @RequestParam(name = "endTime",required = false) String endTime
     ){
         LocalDate localDate = getLocalDate(reportDate, reportType);
-        if(sceneId != null){
-            if(reportType != null && reportType ==1){
-                return new AjaxMessage<>(ResultStatus.OK, monitorDataReportService.monitorDataChartReportByYear(sceneId,localDate.getYear()));
-            }else
-            if(reportType != null && reportType ==2){
-                return new AjaxMessage<>(ResultStatus.OK, monitorDataReportService.monitorDataChartReportByMonth(sceneId,localDate.getYear(),localDate.getMonthValue()));
-            }else
-            if(reportType != null && reportType ==3){
-                return new AjaxMessage<>(ResultStatus.OK, monitorDataReportService.monitorDataChartReportByDay(sceneId,localDate.getYear(),localDate.getMonthValue(),localDate.getDayOfMonth()));
-            }
+        if (sceneId == null || reportType == null){
+            return new AjaxMessage<>(ResultStatus.OK);
+        }
+        if (reportType ==1){
+            return new AjaxMessage<>(ResultStatus.OK, monitorDataReportService.monitorDataChartReportByYear(sceneId,localDate.getYear()));
+        }
+        if (reportType ==2 ){
+            return new AjaxMessage<>(ResultStatus.OK, monitorDataReportService.monitorDataChartReportByMonth(sceneId,localDate.getYear(),localDate.getMonthValue()));
+        }
+        if (reportType ==3){
+            return new AjaxMessage<>(ResultStatus.OK, monitorDataReportService.monitorDataChartReportByDay(sceneId,localDate.getYear(),localDate.getMonthValue(),localDate.getDayOfMonth()));
+        }
+        if (reportType ==4 && StringUtils.isNotEmpty(startTime) && StringUtils.isNotEmpty(endTime)){
+            return new AjaxMessage<>(ResultStatus.OK, monitorDataReportService.monthMonitorData(sceneId, startTime, endTime));
         }
         return new AjaxMessage<>(ResultStatus.OK);
     }
@@ -59,22 +66,24 @@ public class MonitorDataReportController {
     @ApiOperation(value = "统计分析——对比,按集合顺序取,能耗——水质——报警")
     public AjaxMessage<List<List<MonitorDataChartReportDeviceDto>>> MonitorDataCompareReport(
             @ApiParam(value = "场景ids", required = true) @RequestParam List<Long> sceneIds,
-            @ApiParam(value = "日期,格式:2020-12-12", required = true) @RequestParam String reportDate,
-            @ApiParam(value = "类型,1年2月3日", required = true) @RequestParam Integer reportType,
-            @ApiParam(value = "场景类型:1水源 0其他",defaultValue = "0") @RequestParam(required = false ,defaultValue = "0") Integer sceneType
+            @ApiParam(value = "日期,格式:2020-12-12") @RequestParam(name = "reportDate",required = false) String reportDate,
+            @ApiParam(value = "类型,1年2月3日4自定义", required = true) @RequestParam Integer reportType,
+            @ApiParam(value = "场景类型:1水源 0其他",defaultValue = "0") @RequestParam(required = false ,defaultValue = "0") Integer sceneType,
+            @ApiParam(value = "开始时间") @RequestParam(name = "startTime",required = false) String startTime,
+            @ApiParam(value = "结束时间") @RequestParam(name = "endTime",required = false) String endTime
     ){
         LocalDate localDate = getLocalDate(reportDate, reportType);
         List<List<MonitorDataChartReportDeviceDto>> reportList=new ArrayList<>();
         if(sceneIds != null && sceneIds.size() > 0){
 
             //能耗(供水量3、耗电量5 )(4取水量、5耗电量)
-            List<MonitorDataChartReportDeviceDto> energy = monitorDataReportService.monitorDataEnergyReport(reportType,sceneIds,localDate.getYear(),localDate.getMonthValue(),localDate.getDayOfMonth(),sceneType);
+            List<MonitorDataChartReportDeviceDto> energy = monitorDataReportService.monitorDataEnergyReport(reportType,sceneIds,localDate.getYear(),localDate.getMonthValue(),localDate.getDayOfMonth(),sceneType,startTime, endTime);
             //水质(PH8、余氯11、浊度10)
-            List<MonitorDataChartReportDeviceDto> quality = monitorDataReportService.monitorDataQualityReport(reportType,sceneIds,localDate.getYear(),localDate.getMonthValue(),localDate.getDayOfMonth());
+            List<MonitorDataChartReportDeviceDto> quality = monitorDataReportService.monitorDataQualityReport(reportType,sceneIds,localDate.getYear(),localDate.getMonthValue(),localDate.getDayOfMonth(),startTime, endTime);
             // 水电耗
-            List<MonitorDataChartReportDeviceDto> consumption = monitorDataReportService.monitorWaterPowerConsumptionReport(reportType,sceneIds,localDate.getYear(),localDate.getMonthValue(),localDate.getDayOfMonth(),1);
+            List<MonitorDataChartReportDeviceDto> consumption = monitorDataReportService.monitorWaterPowerConsumptionReport(reportType,sceneIds,localDate.getYear(),localDate.getMonthValue(),localDate.getDayOfMonth(),1, startTime, endTime);
             //报警(报警次数)
-            List<MonitorDataChartReportDeviceDto> alarm = monitorDataReportService.deviceAlarmReport(reportType,sceneIds,localDate.getYear(),localDate.getMonthValue(),localDate.getDayOfMonth());
+            List<MonitorDataChartReportDeviceDto> alarm = monitorDataReportService.deviceAlarmReport(reportType,sceneIds,localDate.getYear(),localDate.getMonthValue(),localDate.getDayOfMonth(), startTime,  endTime);
 
             Map<String,MonitorDataChartReportDeviceDto> map = consumption.stream().collect(Collectors.toMap(MonitorDataChartReportDeviceDto::getDeviceName, a -> a,(k1, k2)->k1));
             for (MonitorDataChartReportDeviceDto energyDto: energy) {
@@ -119,13 +128,16 @@ public class MonitorDataReportController {
     @ApiOperation(value = "统计分析——管网图表")
     public AjaxMessage<List<MonitorDataChartReportDeviceDto>> MonitorDataChartReportByDevice(
             @ApiParam(value = "设备id", required = true) @RequestParam List<Long> deviceIds,
-            @ApiParam(value = "时间", required = true) @RequestParam String reportDate,
-            @ApiParam(value = "日期类型,1年报2月报3日报", required = true) @RequestParam Integer reportType,
-            @ApiParam(value = "统计类型,1压力2流量3水质", required = true) @RequestParam Integer searchType
+            @ApiParam(value = "时间") @RequestParam(name = "reportDate",required = false) String reportDate,
+            @ApiParam(value = "日期类型,1年报2月报3日报4自定义", required = true) @RequestParam Integer reportType,
+            @ApiParam(value = "统计类型,1压力2流量3水质", required = true) @RequestParam Integer searchType,
+            @ApiParam(value = "开始时间") @RequestParam(name = "startTime",required = false) String startTime,
+            @ApiParam(value = "结束时间") @RequestParam(name = "endTime",required = false) String endTime
     ){
         LocalDate localDate = getLocalDate(reportDate, reportType);
         if(deviceIds != null && deviceIds.size()>0){
-            return new AjaxMessage<>(ResultStatus.OK,  monitorDataReportService.monitorDataDeviceReport(reportType,deviceIds,searchType,localDate.getYear(),localDate.getMonthValue(),localDate.getDayOfMonth()));
+            return new AjaxMessage<>(ResultStatus.OK,  monitorDataReportService.monitorDataDeviceReport(reportType,deviceIds,searchType,
+                    localDate.getYear(),localDate.getMonthValue(),localDate.getDayOfMonth(),startTime,endTime));
         }
         return new AjaxMessage<>(ResultStatus.OK);
     }

+ 9 - 0
sms_water/src/main/java/com/huaxu/dao/DayReportMapper.java

@@ -31,6 +31,15 @@ public interface DayReportMapper extends BaseMapper<DayReportEntity> {
     Page<ReportDto> findPage(IPage<ReportDto> page,
                              @Param("dayReport") DayReportEntity dayReportEntity);
 
+    /**
+     * 自定义分页查询
+     *
+     * @param page
+     * @param reportPageQueryDto 实体类
+     */
+    Page<ReportDto> findPageReprot(IPage<ReportDto> page,
+                             @Param("dayReport") ReportPageQueryDto reportPageQueryDto);
+
     DayReportEntity findDayReportById(Serializable id);
 
 

+ 16 - 1
sms_water/src/main/java/com/huaxu/dao/MonitorDataReportMapper.java

@@ -33,7 +33,10 @@ public interface MonitorDataReportMapper {
                                                                         @Param("sceneId")Long sceneId ,@Param("tenantId")String tenantId,
                                                                         @Param("userType")String userType,@Param("permissonType")Integer permissonType,
                                                                         @Param("programItems")List<ProgramItem> programItems);
-
+    List<MonitorDataChartReportDeviceDto> monthMonitorData(@Param("startTime")String startTime, @Param("endTime")String endTime,
+                                                            @Param("sceneId")Long sceneId ,@Param("tenantId")String tenantId,
+                                                                         @Param("userType")String userType,@Param("permissonType")Integer permissonType,
+                                                                         @Param("programItems")List<ProgramItem> programItems);
 
 
     List<MonitorDataChartReportDeviceDto> MonitorDataEnergyReportByDay(@Param("sceneType")Integer sceneType,@Param("sceneIds")List<Long> sceneIds,
@@ -44,6 +47,10 @@ public interface MonitorDataReportMapper {
                                                                   @Param("year")Integer year, @Param("month")Integer month,
                                                                   @Param("tenantId")String tenantId,@Param("userType")String userType,@Param("permissonType")Integer permissonType,
                                                                   @Param("programItems")List<ProgramItem> programItems);
+    List<MonitorDataChartReportDeviceDto> MonitorDataEnergyReport(@Param("sceneType")Integer sceneType, @Param("sceneIds")List<Long> sceneIds,
+                                                                         @Param("startTime")String startTime, @Param("endTime")String endTime,
+                                                                         @Param("tenantId")String tenantId,@Param("userType")String userType,@Param("permissonType")Integer permissonType,
+                                                                         @Param("programItems")List<ProgramItem> programItems);
     List<MonitorDataChartReportDeviceDto> MonitorDataEnergyReportByYear(@Param("sceneType")Integer sceneType, @Param("sceneIds")List<Long> sceneIds,
                                                                   @Param("year")Integer year,
                                                                   @Param("tenantId")String tenantId,@Param("userType")String userType,@Param("permissonType")Integer permissonType,
@@ -59,6 +66,10 @@ public interface MonitorDataReportMapper {
                                                                    @Param("year")Integer year, @Param("month")Integer month,
                                                                    @Param("tenantId")String tenantId,@Param("userType")String userType,@Param("permissonType")Integer permissonType,
                                                                    @Param("programItems")List<ProgramItem> programItems);
+    List<MonitorDataChartReportDeviceDto> MonitorDataQualityReport( @Param("sceneIds")List<Long> sceneIds,
+                                                                           @Param("startTime")String startTime, @Param("endTime")String endTime,
+                                                                           @Param("tenantId")String tenantId,@Param("userType")String userType,@Param("permissonType")Integer permissonType,
+                                                                           @Param("programItems")List<ProgramItem> programItems);
     List<MonitorDataChartReportDeviceDto> MonitorDataQualityReportByYear( @Param("sceneIds")List<Long> sceneIds,
                                                                    @Param("year")Integer year,
                                                                    @Param("tenantId")String tenantId,@Param("userType")String userType,@Param("permissonType")Integer permissonType,
@@ -83,6 +94,10 @@ public interface MonitorDataReportMapper {
                                                                                @Param("year")Integer year, @Param("month")Integer month,
                                                                                @Param("tenantId")String tenantId,@Param("userType")String userType,@Param("permissonType")Integer permissonType,
                                                                                @Param("programItems")List<ProgramItem> programItems);
+    List<MonitorDataChartReportDeviceDto> MonitorDataDeviceReport(@Param("deviceIds")List<Long> deviceIds, @Param("searchType")Integer searchType,
+                                                                         @Param("startTime")String startTime, @Param("endTime")String endTime,
+                                                                         @Param("tenantId")String tenantId,@Param("userType")String userType,@Param("permissonType")Integer permissonType,
+                                                                         @Param("programItems")List<ProgramItem> programItems);
     List<MonitorDataChartReportDeviceDto> MonitorDataDeviceReportByYear(@Param("deviceIds")List<Long> deviceIds, @Param("searchType")Integer searchType,
                                                                                @Param("year")Integer year,
                                                                                @Param("tenantId")String tenantId,@Param("userType")String userType,@Param("permissonType")Integer permissonType,

+ 4 - 4
sms_water/src/main/java/com/huaxu/dao/MonthReportMapper.java

@@ -3,10 +3,7 @@ package com.huaxu.dao;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.huaxu.dto.DevicePressReportAttributeDto;
-import com.huaxu.dto.DeviceWaterReportAttributeDto;
-import com.huaxu.dto.ReportAttributeDto;
-import com.huaxu.dto.ReportDto;
+import com.huaxu.dto.*;
 import com.huaxu.entity.DayReportEntity;
 import com.huaxu.entity.MonthReportEntity;
 import org.apache.ibatis.annotations.Mapper;
@@ -32,6 +29,9 @@ public interface MonthReportMapper extends BaseMapper<MonthReportEntity> {
      Page<ReportDto> findPage(IPage<ReportDto> page,
                               @Param("monthReport") MonthReportEntity monthReportEntity);
 
+    Page<ReportDto> findPageReprot(IPage<ReportDto> page,
+                             @Param("monthReport") ReportPageQueryDto reportPageQueryDto);
+
     MonthReportEntity findMonthReportById(Serializable id);
 
 

+ 4 - 4
sms_water/src/main/java/com/huaxu/dao/YearReportMapper.java

@@ -3,10 +3,7 @@ package com.huaxu.dao;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.huaxu.dto.DevicePressReportAttributeDto;
-import com.huaxu.dto.DeviceWaterReportAttributeDto;
-import com.huaxu.dto.ReportAttributeDto;
-import com.huaxu.dto.ReportDto;
+import com.huaxu.dto.*;
 import com.huaxu.entity.DayReportEntity;
 import com.huaxu.entity.YearReportEntity;
 import org.apache.ibatis.annotations.Mapper;
@@ -32,6 +29,9 @@ public interface YearReportMapper extends BaseMapper<YearReportEntity> {
      Page<ReportDto> findPage(IPage<ReportDto> page,
                               @Param("yearReport") YearReportEntity yearReportEntity);
 
+    Page<ReportDto> findPageReprot(IPage<ReportDto> page,
+                             @Param("yearReport") ReportPageQueryDto reportPageQueryDto);
+
     YearReportEntity findYearReportById(Serializable id);
 
 

+ 9 - 0
sms_water/src/main/java/com/huaxu/dto/ReportDto.java

@@ -70,4 +70,13 @@ public class ReportDto implements Serializable {
     @ApiModelProperty("用户ID")
     @JsonIgnore
     private Integer userId;
+
+    @ApiModelProperty("设备名字")
+    private String deviceName;
+
+    @ApiModelProperty(value = "开始时间")
+    private String startTime;
+
+    @ApiModelProperty(value = "结束时间")
+    private String endTime;
 }

+ 51 - 0
sms_water/src/main/java/com/huaxu/dto/ReportPageQueryDto.java

@@ -0,0 +1,51 @@
+package com.huaxu.dto;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @ClassName ReportPageQueryDto
+ * @Description: TODO
+ * @Author lihui
+ * @Date 2021/4/15
+ * @Version V1.0
+ **/
+@Data
+@ApiModel("报表查询参数")
+public class ReportPageQueryDto {
+
+    @ApiModelProperty("年")
+    private Integer year;
+
+    @ApiModelProperty(value = "月")
+    private Integer month;
+
+    @ApiModelProperty(value = "天")
+    private Integer day;
+
+    @ApiModelProperty(value = "租户标识")
+    private String tenantId;
+
+    @ApiModelProperty(value = "设备IDS")
+    private List<DeviceDto> deviceIds;
+
+    @ApiModelProperty(value = "报表类型")
+    private Integer type;
+
+    @ApiModelProperty(value = "报表类型")
+    private List<Integer> typeIds;
+
+    @ApiModelProperty(value = "一级场景IDS")
+    private Long[] parentSceneIds;
+
+    @ApiModelProperty(value = "开始时间")
+    private String startTime;
+
+    @ApiModelProperty(value = "结束时间")
+    private String endTime;
+}

+ 17 - 4
sms_water/src/main/java/com/huaxu/dto/ReportQueryDto.java

@@ -12,9 +12,21 @@ public class ReportQueryDto implements Serializable {
 
     private static final long serialVersionUID = 4074399088580570408L;
 
-    @ApiModelProperty("场景IDS/设备IDS")
+    @ApiModelProperty("管网传设备IDS/其他统计传场景IDS")
     private Long[] ids;
 
+    @ApiModelProperty(value = "开始时间")
+    private String startTime;
+
+    @ApiModelProperty(value = "结束时间")
+    private String endTime;
+
+    @ApiModelProperty(value = "报表类型(0日 1月 2年 3自定义)")
+    private Integer reportType;
+
+    @ApiModelProperty(value = "管网用到的字段:类型(1压力 2流量,3水质)")
+    private Integer type;
+
     @ApiModelProperty("年")
     private Integer year;
 
@@ -24,9 +36,10 @@ public class ReportQueryDto implements Serializable {
     @ApiModelProperty(value = "天")
     private Integer day;
 
-    @ApiModelProperty(value = "类型")
-    private Integer type;
-
+    @ApiModelProperty(value = "pageNum")
+    private Integer pageNum;
 
+    @ApiModelProperty(value = "pageSize")
+    private Integer pageSize;
 
 }

+ 60 - 2
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.entity.DayReportEntity;
 import com.huaxu.util.UserUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 
@@ -45,11 +46,14 @@ public abstract class AbstractReportService<M extends BaseMapper<T>, T> extends
         List<ReportTitleDto> reportTitleDtos = getReportTitle(reportDto, mapsTitle, mapsAttributeTitle);
         // 固定参数项
         List<ReportDto> reportList = findReport(reportDto);
+        int total = 0;
         // 单个属性值
         for (ReportDto item : reportPage.getRecords()) {
-            item.setCollectDate(item.getYear() + "-" + String.format("%02d", item.getMonth()) + "-" + String.format("%02d", item.getDay()) + " " + String.format("%02d", item.getHour()) + ":00");
+            item.setCollectDate(formateCollectDate(queryDto, item));
             item.setDeviceIds(devices);
-            item.setReportTitle(reportTitleDtos);
+            if (total == 0){
+                item.setReportTitle(reportTitleDtos);
+            }
             // 固定参数项
             calcUsage(item, reportList);
             //动态参数项
@@ -62,9 +66,12 @@ public abstract class AbstractReportService<M extends BaseMapper<T>, T> extends
             }
             // 获取统计维度的值
             item.setDataMapValues(getStatisticalDimensionsValue(mapsTitle, mapData, mapsAttributeTitle));
+            total  ++;
         }
     }
 
+
+
     /**
      * 查询场景下的所有设备信息
      * @param ids 场景ID
@@ -135,9 +142,39 @@ public abstract class AbstractReportService<M extends BaseMapper<T>, T> extends
             reportDto.setParentSceneIds(queryDto.getIds());
         }
         reportDto.setUserId(UserUtil.getCurrentUser().getId());
+        reportDto.setStartTime(queryDto.getStartTime());
+        reportDto.setEndTime(queryDto.getEndTime());
         return reportDto;
     }
 
+    //根据设备ID查询报表测点信息
+    protected ReportPageQueryDto getReportPageQuery(ReportQueryDto queryDto, List<DeviceDto> devices, boolean isPipe){
+        ReportPageQueryDto dto = new ReportPageQueryDto();
+        dto.setYear(queryDto.getYear());
+        dto.setMonth(queryDto.getMonth());
+        dto.setDay(queryDto.getDay());
+        dto.setTenantId(UserUtil.getCurrentUser().getTenantId());
+        dto.setDeviceIds(devices);
+        // 管网和其他有点不一样
+        if (isPipe){
+            Integer[] parmType = null;
+            if (queryDto.getType() == 1) {
+                parmType = new Integer[]{13};
+            } else if (queryDto.getType() == 2){
+                parmType = new Integer[]{14};
+            } else if (queryDto.getType() == 3){
+                parmType = new Integer[]{7, 9, 11};
+            }
+            dto.setTypeIds(Arrays.asList(parmType));
+            dto.setType(queryDto.getType());
+        } else {
+            dto.setParentSceneIds(queryDto.getIds());
+        }
+        dto.setStartTime(queryDto.getStartTime());
+        dto.setEndTime(queryDto.getEndTime());
+        return dto;
+    }
+
     /**
      * 获取报表标题
      * @param reportDto
@@ -281,6 +318,27 @@ public abstract class AbstractReportService<M extends BaseMapper<T>, T> extends
         return statisticalDimension;
     }
 
+    /**
+    * @Author lihui
+    * @Description 格式化日期
+    * @Date 16:38 2021/4/15
+    * @Param [queryDto, item]
+    * @return java.lang.String
+    **/
+    private String formateCollectDate(ReportQueryDto queryDto, ReportDto item){
+        // 0日 1月 2年
+        if (queryDto.getReportType() == 0) {
+            return item.getYear() + "-" + String.format("%02d", item.getMonth()) + "-" + String.format("%02d", item.getDay()) + " " + String.format("%02d", item.getHour()) + ":00:00";
+        }
+        if (queryDto.getReportType() == 1 || queryDto.getReportType() == 3) {
+            return item.getYear() + "-" + String.format("%02d", item.getMonth()) + "-" + String.format("%02d", item.getDay());
+        }
+        if (queryDto.getReportType() == 2) {
+            return item.getYear() + "-" + String.format("%02d", item.getMonth());
+        }
+        return null;
+    }
+
     /**
      * 查询报表
      * @param reportDto

+ 2 - 30
sms_water/src/main/java/com/huaxu/service/DayReportService.java

@@ -224,7 +224,7 @@ public class DayReportService extends AbstractReportService<DayReportMapper, Day
             return reportPage;
         }
         // 根据设备ID查询报表测点信息,查询到分页的行数
-        reportPage = dayReportMapper.findPage(page, getDayReportEntity(queryDto, devices,false));
+        reportPage = dayReportMapper.findPageReprot(page, getReportPageQuery(queryDto, devices,false));
         reportDataHandle(queryDto, devices, reportPage, false);
         return reportPage;
     }
@@ -236,7 +236,7 @@ public class DayReportService extends AbstractReportService<DayReportMapper, Day
             return reportPage;
         }
         // 根据设备ID查询报表测点信息,查询到分页的行数
-        reportPage = dayReportMapper.findPage(page, getDayReportEntity(queryDto, devices, true));
+        reportPage = dayReportMapper.findPageReprot(page, getReportPageQuery(queryDto, devices, true));
         reportDataHandle(queryDto, devices, reportPage, true);
         //查询到分页的行数
         return reportPage;
@@ -251,32 +251,4 @@ public class DayReportService extends AbstractReportService<DayReportMapper, Day
     List<ReportAttributeDto> findAttributeList(ReportDto item) {
         return dayReportMapper.findAttributeList(item);
     }
-
-    //根据设备ID查询报表测点信息
-    private DayReportEntity getDayReportEntity(ReportQueryDto queryDto, List<DeviceDto> devices, boolean isPipe){
-
-        DayReportEntity dayReportEntity = new DayReportEntity();
-        dayReportEntity.setYear(queryDto.getYear());
-        dayReportEntity.setMonth(queryDto.getMonth());
-        dayReportEntity.setDay(queryDto.getDay());
-        dayReportEntity.setTenantId(UserUtil.getCurrentUser().getTenantId());
-        dayReportEntity.setDeviceIds(devices);
-        // 管网和其他有点不一样
-        if (isPipe){
-            Integer[] parmType = null;
-            if (queryDto.getType() == 1) {
-                parmType = new Integer[]{13};
-            } else if (queryDto.getType() == 2){
-                parmType = new Integer[]{14};
-            } else if (queryDto.getType() == 3){
-                parmType = new Integer[]{7, 9, 11};
-            }
-            dayReportEntity.setTypeIds(Arrays.asList(parmType));
-            dayReportEntity.setType(queryDto.getType());
-        } else {
-            dayReportEntity.setParentSceneIds(queryDto.getIds());
-        }
-        return dayReportEntity;
-    }
-
 }

+ 9 - 8
sms_water/src/main/java/com/huaxu/service/MonitorDataReportService.java

@@ -23,23 +23,24 @@ public interface MonitorDataReportService {
 
     //日报
     List<MonitorDataChartReportDeviceDto> monitorDataChartReportByDay(Long sceneId, Integer year, Integer month , Integer day);
-    //年报
-    List<MonitorDataChartReportDeviceDto> monitorDataChartReportByMonth(Long sceneId, Integer year, Integer month );
     //月报
+    List<MonitorDataChartReportDeviceDto> monitorDataChartReportByMonth(Long sceneId, Integer year, Integer month );
+    //年报
     List<MonitorDataChartReportDeviceDto> monitorDataChartReportByYear(Long sceneId, Integer year);
-
+    //月报
+    List<MonitorDataChartReportDeviceDto> monthMonitorData(Long sceneId, String startTime, String endTime );
 
     //报警次数
-    List<MonitorDataChartReportDeviceDto> deviceAlarmReport(Integer type, List<Long>  sceneIds, Integer year, Integer month , Integer day);
+    List<MonitorDataChartReportDeviceDto> deviceAlarmReport(Integer type, List<Long>  sceneIds, Integer year, Integer month , Integer day, String startTime, String endTime);
     //水质对比
-    List<MonitorDataChartReportDeviceDto> monitorDataQualityReport(Integer type, List<Long>  sceneIds, Integer year, Integer month , Integer day);
+    List<MonitorDataChartReportDeviceDto> monitorDataQualityReport(Integer type, List<Long>  sceneIds, Integer year, Integer month , Integer day, String startTime, String endTime);
     //能耗对比
-    List<MonitorDataChartReportDeviceDto> monitorDataEnergyReport(Integer type, List<Long>  sceneIds, Integer year, Integer month , Integer day, Integer sceneType);
+    List<MonitorDataChartReportDeviceDto> monitorDataEnergyReport(Integer type, List<Long>  sceneIds, Integer year, Integer month , Integer day, Integer sceneType,String startTime, String endTime);
     // 水电耗
-    List<MonitorDataChartReportDeviceDto> monitorWaterPowerConsumptionReport(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, String startTime, String endTime);
     List<DeviceEntity> getDeviceBySceneTypeName(String sceneTypeName);
 
-    List<MonitorDataChartReportDeviceDto> monitorDataDeviceReport(Integer type, List<Long>  deviceIds, Integer searchType, Integer year, Integer month , Integer day);
+    List<MonitorDataChartReportDeviceDto> monitorDataDeviceReport(Integer type, List<Long>  deviceIds, Integer searchType, Integer year, Integer month , Integer day,String startTime, String endTime);
 
     //概览页所有数据
     GeneralViewResults monitorDataGeneralView();

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

@@ -228,6 +228,8 @@ public class MonthReportService extends AbstractReportService<MonthReportMapper,
         return monthReportMapper.findAttributeList(item);
     }
 
+
+
     public Page<ReportDto> findDevicePressPageReport(IPage<ReportDto> page,  ReportQueryDto queryDto) {
         Page<ReportDto> reportPage = new Page<>();
         List<DeviceDto> devices = devicesToList(queryDto.getIds());
@@ -235,7 +237,7 @@ public class MonthReportService extends AbstractReportService<MonthReportMapper,
             return reportPage;
         }
 
-        reportPage = monthReportMapper.findPage(page, getMonthReportEntity(queryDto, devices,true));
+        reportPage = monthReportMapper.findPageReprot(page, getReportPageQuery(queryDto, devices,true));
         reportDataHandle(queryDto, devices, reportPage, true);
         return reportPage;
     }
@@ -247,34 +249,8 @@ public class MonthReportService extends AbstractReportService<MonthReportMapper,
         if (devices.size() == 0 ){
             return reportPage;
         }
-        reportPage = monthReportMapper.findPage(page, getMonthReportEntity(queryDto, devices,false));
+        reportPage = monthReportMapper.findPageReprot(page, getReportPageQuery(queryDto, devices,false));
         reportDataHandle(queryDto, devices, reportPage, false);
         return reportPage;
     }
-
-
-
-    private MonthReportEntity getMonthReportEntity(ReportQueryDto queryDto, List<DeviceDto> devices, boolean isPipe){
-        MonthReportEntity monthReportEntity = new MonthReportEntity();
-        monthReportEntity.setYear(queryDto.getYear());
-        monthReportEntity.setMonth(queryDto.getMonth());
-        monthReportEntity.setTenantId(UserUtil.getCurrentUser().getTenantId());
-        monthReportEntity.setDeviceIds(devices);
-        // 管网和其他有点不一样
-        if (isPipe){
-            Integer[] parmType = null;
-            if (queryDto.getType() == 1) {
-                parmType = new Integer[]{13};
-            } else if (queryDto.getType() == 2){
-                parmType = new Integer[]{14};
-            } else if (queryDto.getType() == 3){
-                parmType = new Integer[]{7, 9, 11};
-            }
-            monthReportEntity.setTypeIds(Arrays.asList(parmType));
-            monthReportEntity.setType(queryDto.getType());
-        } else {
-            monthReportEntity.setParentSceneIds(queryDto.getIds());
-        }
-        return monthReportEntity;
-    }
 }

+ 49 - 40
sms_water/src/main/java/com/huaxu/service/ReportService.java

@@ -2,9 +2,12 @@ package com.huaxu.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.huaxu.common.StringUtils;
 import com.huaxu.dto.*;
 import com.huaxu.entity.SceneEntity;
+import com.huaxu.exception.ServiceException;
 import com.huaxu.model.LoginUser;
+import com.huaxu.util.DatesUtil;
 import com.huaxu.util.UserUtil;
 import com.mchange.lang.LongUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -66,37 +69,28 @@ public class ReportService {
     }
 
     /**
-     * 查询日报月报及年报表
-     *
-     * @param ids
-     * @param year
-     * @param month
-     * @param day
-     * @param reportType
-     */
-    public IPage<ReportDto> getReportBySceneIdsNew(IPage<ReportDto> page, Long[] ids, Integer year, Integer month, Integer day, Integer reportType) {
-        ReportQueryDto queryDto = new ReportQueryDto();
-        queryDto.setIds(ids);
+    * @Author lihui
+    * @Description 查询日报月报及年报表
+    * @Date 11:31 2021/4/15
+    * @Param [page, queryDto]
+    * @return com.baomidou.mybatisplus.core.metadata.IPage<com.huaxu.dto.ReportDto>
+    **/
+    public IPage<ReportDto> getReportBySceneIdsNew(IPage<ReportDto> page, ReportQueryDto queryDto) {
         Page<ReportDto> reportPage = new Page<>();
         // 日报
-        if (reportType.equals(0)) {
-            queryDto.setMonth(month);
-            queryDto.setYear(year);
-            queryDto.setDay(day);
-            //reportPage = dayReportService.findPage(page, ids, year, month, day);
+        if (queryDto.getReportType() == 0) {
             reportPage = dayReportService.findPageReport(page, queryDto);
         }
-        //月报
-        if (reportType.equals(1)) {
-            queryDto.setMonth(month);
-            queryDto.setYear(year);
-            //reportPage = monthReportService.findPage(page, ids, year, month, day);
+        // 月报或自定义时间
+        if (queryDto.getReportType() == 1  || queryDto.getReportType() == 3) {
+            formatTime(queryDto);
+            queryDto.setDay(null);
             reportPage = monthReportService.findPageReport(page, queryDto);
         }
-        //年报
-        if (reportType.equals(2)) {
-            queryDto.setYear(year);
-            //reportPage = yearReportService.findPage(page, ids, year, month, day);
+        // 年报
+        if (queryDto.getReportType() == 2) {
+            queryDto.setMonth(null);
+            queryDto.setDay(null);
             reportPage = yearReportService.findPageReport(page, queryDto);
         }
         return reportPage;
@@ -137,28 +131,23 @@ public class ReportService {
     }
 
 
-    public IPage<ReportDto> getPipeDevicePressReportByDeviceIds(IPage<ReportDto> page, Long[] ids, Integer year, Integer month, Integer day,
-                                                                Integer reportType, Integer type) {
+    public IPage<ReportDto> getPipeDevicePressReportByDeviceIds(IPage<ReportDto> page, ReportQueryDto queryDto) {
+
         Page<ReportDto> reportPage = new Page<>();
-        ReportQueryDto queryDto = new ReportQueryDto();
-        queryDto.setIds(ids);
-        queryDto.setType(type);
         // 日报
-        if (reportType.equals(0)){
-            queryDto.setMonth(month);
-            queryDto.setYear(year);
-            queryDto.setDay(day);
+        if (queryDto.getReportType() == 0){
             reportPage = dayReportService.findDevicePressPageReport(page, queryDto);
         }
-        // 月报
-        if (reportType.equals(1)){
-            queryDto.setYear(year);
-            queryDto.setMonth(month);
+        // 月报或自定义时间
+        if (queryDto.getReportType() == 1 || queryDto.getReportType() == 3){
+            formatTime(queryDto);
+            queryDto.setDay(null);
             reportPage = monthReportService.findDevicePressPageReport(page, queryDto);
         }
         // 年报
-        if (reportType.equals(2)) {
-            queryDto.setYear(year);
+        if (queryDto.getReportType() == 2) {
+            queryDto.setDay(null);
+            queryDto.setMonth(null);
             reportPage = yearReportService.findDevicePressPageReport(page, queryDto);
         }
         return reportPage;
@@ -186,4 +175,24 @@ public class ReportService {
         return deviceParmService.findAttributeNameList(reportDto);
     }
 
+    /**
+    * @Author lihui 
+    * @Description 格式化时间
+    * @Date 18:01 2021/4/15
+    * @Param [queryDto] 
+    * @return void 
+    **/
+    private void formatTime(ReportQueryDto queryDto){
+        if (queryDto.getReportType() == 1){
+            return;
+        }
+        if (StringUtils.isEmpty(queryDto.getStartTime()) || StringUtils.isEmpty(queryDto.getEndTime())) {
+            throw new ServiceException(500, "开始时间或结束时间为空");
+        }
+        queryDto.setStartTime(queryDto.getStartTime() + " 00:00:00");
+        queryDto.setEndTime(queryDto.getEndTime() + " 23:59:59");
+        queryDto.setYear(null);
+        queryDto.setMonth(null);
+    }
+
 }

+ 5 - 29
sms_water/src/main/java/com/huaxu/service/YearReportService.java

@@ -218,49 +218,25 @@ public class YearReportService extends AbstractReportService<YearReportMapper, Y
         return yearReportMapper.findAttributeList(item);
     }
 
+
     public Page<ReportDto> findDevicePressPageReport(IPage<ReportDto> page,  ReportQueryDto queryDto) {
-        Page<ReportDto> reportPage = new Page<>();
         List<DeviceDto> devices = devicesToList(queryDto.getIds());
         if (devices.size() == 0 ){
-            return reportPage;
+            return new Page<>();
         }
-        reportPage = yearReportMapper.findPage(page, getYearReportEntity(queryDto, devices, true));
+        Page<ReportDto> reportPage = yearReportMapper.findPageReprot(page, getReportPageQuery(queryDto, devices, true));
         reportDataHandle(queryDto, devices, reportPage, true);
         return reportPage;
     }
 
     public Page<ReportDto> findPageReport(IPage<ReportDto> page, ReportQueryDto queryDto) {
-        Page<ReportDto> reportPage = new Page<>();
         // 查询场景下的所有设备信息
         List<DeviceDto> devices = findDevices(queryDto.getIds());
         if (devices.size() == 0 ){
-            return reportPage;
+            return new Page<>();
         }
-        reportPage = yearReportMapper.findPage(page, getYearReportEntity(queryDto, devices, false));
+        Page<ReportDto> reportPage = yearReportMapper.findPageReprot(page, getReportPageQuery(queryDto, devices, false));
         reportDataHandle(queryDto, devices, reportPage, false);
         return reportPage;
     }
-
-    private YearReportEntity getYearReportEntity(ReportQueryDto queryDto, List<DeviceDto> devices, boolean isPipe){
-
-        YearReportEntity yearReportEntity = new YearReportEntity();
-        yearReportEntity.setYear(queryDto.getYear());
-        yearReportEntity.setTenantId(UserUtil.getCurrentUser().getTenantId());
-        yearReportEntity.setDeviceIds(devices);
-        if (isPipe){
-            Integer[] parmType = null;
-            if (queryDto.getType() == 1) {
-                parmType = new Integer[]{13};
-            } else if (queryDto.getType() == 2){
-                parmType = new Integer[]{14};
-            } else if (queryDto.getType() == 3){
-                parmType = new Integer[]{7, 9, 11};
-            }
-            yearReportEntity.setTypeIds(Arrays.asList(parmType));
-            yearReportEntity.setType(queryDto.getType());
-        } else {
-            yearReportEntity.setParentSceneIds(queryDto.getIds());
-        }
-        return yearReportEntity;
-    }
 }

+ 138 - 37
sms_water/src/main/java/com/huaxu/service/impl/MonitorDataReportServiceImpl.java

@@ -76,6 +76,33 @@ public class MonitorDataReportServiceImpl implements MonitorDataReportService {
         return monitorDataChartReportDeviceDtos;
     }
 
+    @Override
+    public List<MonitorDataChartReportDeviceDto> monthMonitorData(Long sceneId, String startTime, String endTime) {
+        startTime += " 00:00:00";
+        endTime   += " 23:59:59";
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        List<MonitorDataChartReportDeviceDto> monitorDataChartReportDeviceDtos = monitorDataReportMapper.monthMonitorData(startTime, endTime,sceneId,
+                loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
+        LocalDateTime  startDate =  LocalDateTime.parse(startTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+        LocalDateTime  endDate   =  LocalDateTime.parse(endTime,   DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+        if (startDate.getYear() == endDate.getYear()){
+            for (int i = startDate.getMonth().getValue();i <= endDate.getMonth().getValue(); i++){
+                FillLoseData(monitorDataChartReportDeviceDtos,2, startDate.getYear(), i, 1);
+            }
+        } else {
+            int start = 0;
+            int end = 0;
+            for (int i = startDate.getYear(); i <= endDate.getYear(); i++){
+                start = i == startDate.getYear() ? startDate.getMonth().getValue() : 1;
+                end   = i == endDate.getYear()   ? endDate.getMonthValue() : 12;
+                for (int m = start;m <= end; m++){
+                    FillLoseData(monitorDataChartReportDeviceDtos,2, i , m,1);
+                }
+            }
+        }
+        return monitorDataChartReportDeviceDtos;
+    }
+
     @Override
     public List<MonitorDataChartReportDeviceDto> monitorDataChartReportByYear(Long sceneId, Integer year) {
         LoginUser loginUser = UserUtil.getCurrentUser();
@@ -86,26 +113,34 @@ public class MonitorDataReportServiceImpl implements MonitorDataReportService {
     }
 
     @Override
-    public List<MonitorDataChartReportDeviceDto> deviceAlarmReport(Integer type, List<Long>  sceneIds, Integer year, Integer month , Integer day) {
+    public List<MonitorDataChartReportDeviceDto> deviceAlarmReport(Integer type, List<Long>  sceneIds, Integer year, Integer month , Integer day, String startTime, String endTime) {
         LoginUser loginUser = UserUtil.getCurrentUser();
-        LocalDate beginDate;
-        LocalDate endDate;
-        String dateType ;
-        if(type != null && type ==1){
+        LocalDate beginDate = null;
+        LocalDate endDate   = null;
+        String dateType     = null;
+        if (type == null){
+            return new ArrayList<>();
+        }
+        if (type ==1) {
             beginDate=LocalDate.of(year,1,1);
             endDate=beginDate.plusYears(1);
             dateType="month";
-        }else
-        if(type != null && type ==2){
+        }else  if(type ==2) {
             beginDate=LocalDate.of(year,month,1);
             endDate=beginDate.plusMonths(1);
             dateType="day";
-        }else
-        if(type != null && type ==3){
+        } else if(type ==3) {
             beginDate=LocalDate.of(year,month,day);
             endDate=beginDate.plusDays(1);
             dateType="hour";
-        }else{
+        } else if (type == 4){
+            startTime += " 00:00:00";
+            endTime   += " 23:59:59";
+            beginDate = LocalDate.parse(startTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+            endDate   = LocalDate.parse(endTime,   DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+            dateType="day";
+        }
+        if (beginDate == null || endDate == null){
             return new ArrayList<>();
         }
         List<MonitorDataChartReportDeviceDto> monitorDataChartReportDeviceDtos = monitorDataReportMapper.DeviceAlarmReport(dateType,sceneIds,beginDate,endDate,
@@ -116,42 +151,60 @@ public class MonitorDataReportServiceImpl implements MonitorDataReportService {
     }
 
     @Override
-    public List<MonitorDataChartReportDeviceDto> monitorDataQualityReport(Integer type, List<Long>  sceneIds, Integer year, Integer month , Integer day) {
+    public List<MonitorDataChartReportDeviceDto> monitorDataQualityReport(Integer type, List<Long>  sceneIds, Integer year, Integer month , Integer day, String startTime, String endTime) {
         LoginUser loginUser = UserUtil.getCurrentUser();
-
         List<MonitorDataChartReportDeviceDto> monitorDataChartReportDeviceDtos = null;
-        if(type != null && type == 3){
+        if (type == null) {
+            return monitorDataChartReportDeviceDtos;
+        }
+        if(type == 3){
             monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataQualityReportByDay(sceneIds,year,month,day,
                     loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
-        } else if(type != null && type == 2){
+        } else if(type == 2){
             monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataQualityReportByMonth(sceneIds,year,month,
                     loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
-        } else if(type != null && type == 1){
+        } else if(type == 1){
             monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataQualityReportByYear(sceneIds,year,
                     loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
+        } else if (type == 4) {
+            startTime += " 00:00:00";
+            endTime   += " 23:59:59";
+            monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataQualityReport(sceneIds,startTime,endTime,
+                    loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
         }
-        if(monitorDataChartReportDeviceDtos != null){
+        if (monitorDataChartReportDeviceDtos != null && type == 4){
+            FillLoseData(startTime, endTime, monitorDataChartReportDeviceDtos);
+        } else  if (monitorDataChartReportDeviceDtos != null){
             FillLoseData(monitorDataChartReportDeviceDtos,type,year,month,day);
         }
-
         return monitorDataChartReportDeviceDtos;
     }
 
     @Override
-    public List<MonitorDataChartReportDeviceDto> monitorDataEnergyReport(Integer type, List<Long> sceneIds, Integer year, Integer month , Integer day, Integer sceneType) {
+    public List<MonitorDataChartReportDeviceDto> monitorDataEnergyReport(Integer type, List<Long> sceneIds, Integer year, Integer month , Integer day, Integer sceneType,String startTime, String endTime) {
         LoginUser loginUser = UserUtil.getCurrentUser();
         List<MonitorDataChartReportDeviceDto> monitorDataChartReportDeviceDtos = null;
-        if(type != null && type == 3){
+        if (type == null) {
+            return monitorDataChartReportDeviceDtos;
+        }
+        if(type == 3){
             monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataEnergyReportByDay(sceneType,sceneIds,year,month,day,
                    loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
-       } else if(type != null && type == 2){
+       } else if(type == 2){
             monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataEnergyReportByMonth(sceneType,sceneIds,year,month,
                    loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
-       } else if(type != null && type == 1){
+       } else if(type == 1){
            monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataEnergyReportByYear(sceneType,sceneIds,year,
                    loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
-       }
-        if(monitorDataChartReportDeviceDtos != null){
+       } else if (type == 4) {
+            startTime += " 00:00:00";
+            endTime   += " 23:59:59";
+            monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataEnergyReport(sceneType,sceneIds,startTime,endTime,
+                    loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
+        }
+        if (monitorDataChartReportDeviceDtos != null && type == 4) {
+            FillLoseData(startTime, endTime, monitorDataChartReportDeviceDtos);
+        }else if (monitorDataChartReportDeviceDtos != null){
             FillLoseData(monitorDataChartReportDeviceDtos,type,year,month,day);
         }
         //单位转换为“万”
@@ -168,20 +221,30 @@ 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) {
+    public List<MonitorDataChartReportDeviceDto> monitorWaterPowerConsumptionReport(Integer type, List<Long> sceneIds, Integer year, Integer month , Integer day, Integer sceneType, String startTime, String endTime) {
         LoginUser loginUser = UserUtil.getCurrentUser();
         List<MonitorDataChartReportDeviceDto> monitorDataChartReportDeviceDtos = null;
-        if (type != null && type == 3){
+        if (type == null) {
+            return monitorDataChartReportDeviceDtos;
+        }
+        if ( type == 3){
             monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataEnergyReportByDay(sceneType,sceneIds,year,month,day,
                     loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
-        } else if(type != null && type == 2){
+        } else if(type == 2){
             monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataEnergyReportByMonth(sceneType,sceneIds,year,month,
                     loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
-        } else if(type != null && type == 1){
+        } else if(type == 1){
             monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataEnergyReportByYear(sceneType,sceneIds,year,
                     loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
+        } else if (type == 4) {
+            startTime += " 00:00:00";
+            endTime   += " 23:59:59";
+            monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataEnergyReport(sceneType,sceneIds,startTime,endTime,
+                    loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
         }
-        if (monitorDataChartReportDeviceDtos != null) {
+        if (monitorDataChartReportDeviceDtos != null && type == 4){
+            FillLoseData(startTime, endTime, monitorDataChartReportDeviceDtos);
+        } else if (monitorDataChartReportDeviceDtos != null) {
             FillLoseData(monitorDataChartReportDeviceDtos,type,year,month,day);
         }
         for (MonitorDataChartReportDeviceDto water: monitorDataChartReportDeviceDtos) {
@@ -190,16 +253,21 @@ public class MonitorDataReportServiceImpl implements MonitorDataReportService {
             List<MonitorDataChartReportAttributeDto> attributeDtos =  water.getAttributeData();
             newAttrData.setAttributeName("水电耗");
             newAttrData.setUnit("kwh/㎡");
+            newAttrData.setAttributeType("99");
+            // 计算水电耗=每日电量/每日用水量*100
+            // 缺失每日电量或者每日水量将不进行计算
             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));
-                // 耗电量
+                // attributeType ==  5 --> 每日电量
+                // attributeType ==  4 --> 每日用水量
                 if ("5".equals(attributeDto1.getAttributeType())) {
+                    Map<Integer,MonitorDataChartReportValueDto> map2 = attributeDto2.getMonitorDataChartReportValue().stream().collect(Collectors.toMap(MonitorDataChartReportValueDto::getDateLabel, a -> a,(k1, k2)->k1));
                     calculation(attributeDto1, map2);
                     newAttrData.setMonitorDataChartReportValue(attributeDto1.getMonitorDataChartReportValue());
                 } else {
+                    Map<Integer,MonitorDataChartReportValueDto> map1 = attributeDto1.getMonitorDataChartReportValue().stream().collect(Collectors.toMap(MonitorDataChartReportValueDto::getDateLabel, a -> a,(k1, k2)->k1));
                     calculation(attributeDto2, map1);
                     newAttrData.setMonitorDataChartReportValue(attributeDto2.getMonitorDataChartReportValue());
                 }
@@ -210,6 +278,7 @@ public class MonitorDataReportServiceImpl implements MonitorDataReportService {
         return monitorDataChartReportDeviceDtos;
     }
 
+    // 计算水电耗=每日电量/每日用水量*100
     private void calculation(MonitorDataChartReportAttributeDto attributeDto, Map<Integer,MonitorDataChartReportValueDto> map){
         for (MonitorDataChartReportValueDto valueDto : attributeDto.getMonitorDataChartReportValue()) {
             BigDecimal b1 = new BigDecimal(valueDto.getData());
@@ -217,8 +286,10 @@ public class MonitorDataReportServiceImpl implements MonitorDataReportService {
             valueDto.setMonitorData("");
             if (b1.compareTo(new BigDecimal(0)) == 0 || b2.compareTo(new BigDecimal(0)) == 0) {
                 valueDto.setData(0d);
+                valueDto.setMonitorData("0 kwh/㎡");
             } else {
                 valueDto.setData(b1.divide(b2, 5, RoundingMode.HALF_UP).multiply(new BigDecimal(100)).doubleValue());
+                valueDto.setMonitorData(valueDto.getData() + " kwh/㎡");
             }
         }
     }
@@ -228,24 +299,33 @@ public class MonitorDataReportServiceImpl implements MonitorDataReportService {
         return monitorDataReportMapper.getDeviceBySceneTypeName(sceneTypeName,loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
     }
     @Override
-    public List<MonitorDataChartReportDeviceDto> monitorDataDeviceReport(Integer type, List<Long>  deviceIds, Integer searchType, Integer year, Integer month , Integer day){
+    public List<MonitorDataChartReportDeviceDto> monitorDataDeviceReport(Integer type, List<Long>  deviceIds, Integer searchType, Integer year, Integer month , Integer day, String startTime, String endTime){
 
         LoginUser loginUser = UserUtil.getCurrentUser();
         List<MonitorDataChartReportDeviceDto> monitorDataChartReportDeviceDtos = null;
-        if(type != null && type == 3){
+        if (type == null) {
+            return monitorDataChartReportDeviceDtos;
+        }
+        if (type == 3){
             monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataDeviceReportByDay(deviceIds,searchType,year,month,day,
                     loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
-        } else if(type != null && type == 2){
+        } else if(type == 2){
             monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataDeviceReportByMonth(deviceIds,searchType,year,month,
                     loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
-        } else if(type != null && type == 1){
+        } else if(type == 1){
             monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataDeviceReportByYear(deviceIds,searchType,year,
                     loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
+        } else if (type == 4){
+            startTime += " 00:00:00";
+            endTime   += " 23:59:59";
+            monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataDeviceReport(deviceIds,searchType,startTime,endTime,
+                    loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
         }
-        if(monitorDataChartReportDeviceDtos != null){
+        if (monitorDataChartReportDeviceDtos != null && type == 4){
+            FillLoseData(startTime,endTime, monitorDataChartReportDeviceDtos);
+        } else if (monitorDataChartReportDeviceDtos != null){
             FillLoseData(monitorDataChartReportDeviceDtos,type,year,month,day);
         }
-
         return monitorDataChartReportDeviceDtos;
     }
 
@@ -1320,4 +1400,25 @@ public class MonitorDataReportServiceImpl implements MonitorDataReportService {
             amountMonth = BigDecimal.ZERO;
         return amountMonth;
     }
+
+
+    private void FillLoseData(String startTime, String endTime,List<MonitorDataChartReportDeviceDto> monitorDataChartReportDeviceDtos){
+        LocalDateTime  startDate =  LocalDateTime.parse(startTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+        LocalDateTime  endDate   =  LocalDateTime.parse(endTime,   DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+        if (startDate.getYear() == endDate.getYear()){
+            for (int i = startDate.getMonth().getValue();i <= endDate.getMonth().getValue(); i++){
+                FillLoseData(monitorDataChartReportDeviceDtos,2, startDate.getYear(), i, 1);
+            }
+        } else {
+            int start = 0;
+            int end = 0;
+            for (int i = startDate.getYear(); i <= endDate.getYear(); i++){
+                start = i == startDate.getYear() ? startDate.getMonth().getValue() : 1;
+                end   = i == endDate.getYear()   ? endDate.getMonthValue() : 12;
+                for (int m = start;m <= end; m++){
+                    FillLoseData(monitorDataChartReportDeviceDtos,2, i , m,1);
+                }
+            }
+        }
+    }
 }

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

@@ -100,6 +100,7 @@
         a.month as "month" ,
         a.day as "day" ,
         a.hour as "hour" ,
+        a.DEVICE_NAME as "deviceName",
         b.parent_scene_id as "parentSceneId",
         c.SCENE_NAME as "parentSceneName"
         FROM sms_day_report a
@@ -135,6 +136,52 @@
         </where>
         order by b.parent_scene_id,a.year,a.month,a.day,a.hour
     </select>
+    <!--  根据获取实体 page   -->
+    <select id="findPageReprot" resultType="com.huaxu.dto.ReportDto">
+        SELECT
+        distinct
+        a.tenant_id as "tenantId" ,
+        a.year as "year" ,
+        a.month as "month" ,
+        a.day as "day" ,
+        a.hour as "hour" ,
+        a.DEVICE_NAME as "deviceName",
+        b.parent_scene_id as "parentSceneId",
+        c.SCENE_NAME as "parentSceneName",
+        a.COLLECT_DATE as "collectDate"
+        FROM sms_day_report a
+        inner join sms_device_parm b on a.DEVICE_ID = b.DEVICE_ID and a.ATTRIBUTE_ID=b.ATTRIBUTE_ID
+        <if test="dayReport.typeIds != null">
+            and b.PARM_TYPE in
+            <foreach collection="dayReport.typeIds" item="typeId" open="(" close=")" separator=",">
+                #{typeId}
+            </foreach>
+        </if>
+        and b.`STATUS`=1
+        inner join sms_scene c on b.PARENT_SCENE_ID=c.id
+        <where>
+            b.IS_REPORT=1
+            <if test="dayReport.tenantId != null  and dayReport.tenantId != ''">and a.tenant_id =
+                #{dayReport.tenantId}
+            </if>
+            <if test="dayReport.deviceIds != null and dayReport.deviceIds.size() > 0">
+                and b.DEVICE_ID in
+                <foreach collection="dayReport.deviceIds" item="dramaId" open="(" close=")" separator=",">
+                    #{dramaId.id}
+                </foreach>
+            </if>
+            <if test="dayReport.year != null ">and a.year = #{dayReport.year}</if>
+            <if test="dayReport.month != null ">and a.month = #{dayReport.month}</if>
+            <if test="dayReport.day != null ">and a.day = #{dayReport.day}</if>
+            <if test="dayReport.parentSceneIds != null and dayReport.parentSceneIds.length > 0">
+                and b.parent_scene_id in
+                <foreach collection="dayReport.parentSceneIds" item="dramaId" open="(" close=")" separator=",">
+                    #{dramaId}
+                </foreach>
+            </if>
+        </where>
+        order by b.parent_scene_id,a.year,a.month,a.day,a.hour
+    </select>
     <select id="findAttributeList" resultType="com.huaxu.dto.ReportAttributeDto">
         SELECT tab.attributeName,tab.ATTRIBUTE_TYPE,min(tab.minValue) as "minValue",
         max(tab.maxValue) as "maxValue",AVG(tab.avgValue)as "avgValue",

+ 253 - 0
sms_water/src/main/resources/mapper/MonitorDataReportMapper.xml

@@ -1523,4 +1523,257 @@
         </if>
         </where>
     </select>
+    <select id="monthMonitorData" resultMap="MonitorDataChartReportMap">
+        SELECT
+        r.`day` AS "dateLabel",
+        CONCAT( s.SCENE_NAME, r.DEVICE_NAME ) AS "deviceName",
+        r.DEVICE_CODE AS "devoceCode",
+        r.ATTRIBUTE_NAME AS "attributeName",
+        da.unit AS "unit",
+
+        ROUND( sum(r.AVG_VALUE), 2 ) AS "data",
+        max(r.COLLECT_DATE) AS "date"
+        FROM sms_device_parm p
+        LEFT JOIN sms_month_report r ON p.DEVICE_ID = r.DEVICE_ID AND p.ATTRIBUTE_ID = r.ATTRIBUTE_ID
+        LEFT JOIN sms_device_attribute da ON da.id = r.ATTRIBUTE_ID
+        LEFT JOIN sms_device d ON d.id = r.DEVICE_ID
+        left join sms_scene s on s.id=p.PARENT_SCENE_ID
+        where p.IS_CHART = 1 and p.`STATUS`= 1 and d.ENABLE_STATE = 1  and d.`STATUS`= 1
+        and p.PARENT_SCENE_ID=#{sceneId}
+        <if test="startTime != null and endTime != null ">
+            and r.COLLECT_DATE BETWEEN #{startTime} AND #{endTime}
+        </if>
+        <if test="tenantId != null and tenantId != '' ">
+            and d.tenant_id = #{tenantId}
+        </if>
+        <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 ( d.DEPT_ORG_ID in
+                <foreach collection="programItems" item="item" open="(" close=")" separator=",">
+                    #{item.orgId}
+                </foreach>
+                or
+                d.COMPANY_ORG_ID in
+                <foreach collection="programItems" item="item" open="(" close=")" separator=",">
+                    #{item.orgId}
+                </foreach>
+                )
+            </if>
+            <if test="permissonType == 4 or permissonType == 3">
+                and d.DEPT_ORG_ID in
+                <foreach collection="programItems" item="item" open="(" close=")" separator=",">
+                    #{item.orgId}
+                </foreach>
+            </if>
+            <if test="permissonType == 1">
+                and d.COMPANY_ORG_ID in
+                <foreach collection="programItems" item="item" open="(" close=")" separator=",">
+                    #{item.orgId}
+                </foreach>
+                and (d.DEPT_ORG_ID is null or d.DEPT_ORG_ID =0)
+            </if>
+        </if>
+        group by r.day ,s.SCENE_NAME,r.DEVICE_NAME,r.DEVICE_CODE,r.ATTRIBUTE_NAME,da.unit
+        ORDER BY r.`day` ASC
+    </select>
+    <select id="MonitorDataDeviceReport" resultMap="MonitorDataChartReportMap">
+        SELECT
+        d.DEVICE_NAME AS "deviceName",
+        p.parm_type AS "attributeType",
+        IF( p.parm_type = 13, '压力',
+        IF( p.parm_type = 14, '瞬时流量',
+        IF( p.parm_type = 16, '流速',
+        IF( p.parm_type = 7, 'PH',
+        IF( p.parm_type = 15, 'COD',
+        IF( p.parm_type = 9, '浊度',
+        IF( p.parm_type = 11, '余氯', '' )))))))
+        AS "attributeName",
+        da.unit AS "unit",
+        r.`day` AS "dateLabel",
+        ifnull( ROUND( sum( r.AVG_VALUE ), 2 ), 0 ) AS "data",
+        max( r.COLLECT_DATE ) AS "date"
+        FROM sms_device_parm p
+        LEFT JOIN sms_month_report r ON p.DEVICE_ID = r.DEVICE_ID AND p.ATTRIBUTE_ID = r.ATTRIBUTE_ID
+        left join sms_device_attribute  da ON da.id = p.ATTRIBUTE_ID
+        LEFT JOIN sms_device d ON d.id = p.DEVICE_ID
+        WHERE p.`STATUS`= 1   and d.ENABLE_STATE = 1
+        <if test="startTime != null and endTime != null ">
+            and r.COLLECT_DATE BETWEEN #{startTime} AND #{endTime}
+        </if>
+        <if test="searchType != null and searchType == 1">
+            and p.parm_type = 13
+        </if>
+        <if test="searchType != null and searchType == 2">
+            and p.parm_type in (14,16)
+        </if>
+        <if test="searchType != null and searchType == 3">
+            and p.parm_type in (7,9,11,15)
+        </if>
+        <if test="deviceIds != null and deviceIds.size()>0">
+            and d.id in
+            <foreach collection="deviceIds" item="item" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        <if test="tenantId != null and tenantId != '' ">
+            and d.tenant_id = #{tenantId}
+        </if>
+        <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 ( d.DEPT_ORG_ID in
+                <foreach collection="programItems" item="item" open="(" close=")" separator=",">
+                    #{item.orgId}
+                </foreach>
+                or
+                d.COMPANY_ORG_ID in
+                <foreach collection="programItems" item="item" open="(" close=")" separator=",">
+                    #{item.orgId}
+                </foreach>
+                )
+            </if>
+            <if test="permissonType == 4 or permissonType == 3">
+                and d.DEPT_ORG_ID in
+                <foreach collection="programItems" item="item" open="(" close=")" separator=",">
+                    #{item.orgId}
+                </foreach>
+            </if>
+            <if test="permissonType == 1">
+                and d.COMPANY_ORG_ID in
+                <foreach collection="programItems" item="item" open="(" close=")" separator=",">
+                    #{item.orgId}
+                </foreach>
+                and (d.DEPT_ORG_ID is null or d.DEPT_ORG_ID =0)
+            </if>
+        </if>
+        GROUP BY d.DEVICE_NAME, p.parm_type,da.unit,r.day
+        order by r.day asc
+    </select>
+    <select id="MonitorDataEnergyReport" resultMap="MonitorDataChartReportMap">
+        SELECT
+        r.`day` AS "dateLabel",
+        <if test="sceneType != null and sceneType == 1">
+            IF( p.parm_type = 5, '耗电量','取水量'  ) AS "attributeName",
+        </if>
+        <if test="sceneType == null or sceneType == 0">
+            IF( p.parm_type = 5, '耗电量','用水量'  ) AS "attributeName",
+        </if>
+        s.SCENE_NAME AS "deviceName",
+        p.parm_type AS "attributeType",
+        da.unit AS "unit",
+
+        ifnull( ROUND( sum( r.SUM_VALUE ), 2 ), 0 ) AS "data",
+        max( r.COLLECT_DATE ) AS "date"
+        FROM sms_device_parm p
+        LEFT JOIN sms_month_report r ON p.DEVICE_ID = r.DEVICE_ID AND p.ATTRIBUTE_ID = r.ATTRIBUTE_ID
+        left join sms_scene s on s.id=p.parent_scene_id
+        left join sms_device_attribute  da ON da.id = p.ATTRIBUTE_ID
+        LEFT JOIN sms_device d ON d.id = r.DEVICE_ID
+        WHERE p.`STATUS`= 1
+        <if test="sceneType != null and sceneType == 1">
+            and p.parm_type in (4,5)
+        </if>
+        <if test="sceneType == null or  sceneType == 0">
+            and p.parm_type in (3,5)
+        </if>
+        and d.ENABLE_STATE = 1  and d.`STATUS`= 1
+        <if test="startTime != null and endTime != null ">
+            and r.COLLECT_DATE BETWEEN #{startTime} AND #{endTime}
+        </if>
+        <if test="sceneIds != null and sceneIds.size()>0">
+            and p.PARENT_SCENE_ID in
+            <foreach collection="sceneIds" item="item" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        <if test="tenantId != null and tenantId != '' ">
+            and d.tenant_id = #{tenantId}
+        </if>
+        <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 ( d.DEPT_ORG_ID in
+                <foreach collection="programItems" item="item" open="(" close=")" separator=",">
+                    #{item.orgId}
+                </foreach>
+                or
+                d.COMPANY_ORG_ID in
+                <foreach collection="programItems" item="item" open="(" close=")" separator=",">
+                    #{item.orgId}
+                </foreach>
+                )
+            </if>
+            <if test="permissonType == 4 or permissonType == 3">
+                and d.DEPT_ORG_ID in
+                <foreach collection="programItems" item="item" open="(" close=")" separator=",">
+                    #{item.orgId}
+                </foreach>
+            </if>
+            <if test="permissonType == 1">
+                and d.COMPANY_ORG_ID in
+                <foreach collection="programItems" item="item" open="(" close=")" separator=",">
+                    #{item.orgId}
+                </foreach>
+                and (d.DEPT_ORG_ID is null or d.DEPT_ORG_ID =0)
+            </if>
+        </if>
+        GROUP BY s.SCENE_NAME,p.parm_type,da.unit,r.day
+        order by r.`day` asc
+    </select>
+    <select id="MonitorDataQualityReport" resultMap="MonitorDataChartReportMap">
+        SELECT
+        r.`day` AS "dateLabel",
+        if(p.parm_type=7,'PH',if(p.parm_type=11,'余氯','浊度')) as  "attributeName",
+        s.SCENE_NAME AS "deviceName",
+        p.parm_type AS "attributeType",
+        da.unit AS "unit",
+
+        ifnull( ROUND( sum( r.SUM_VALUE ), 2 ), 0 ) AS "data",
+        max( r.COLLECT_DATE ) AS "date"
+        FROM sms_device_parm p
+        LEFT JOIN sms_month_report r ON p.DEVICE_ID = r.DEVICE_ID AND p.ATTRIBUTE_ID = r.ATTRIBUTE_ID
+        left join sms_scene s on s.id=p.parent_scene_id
+        left join sms_device_attribute  da ON da.id = p.ATTRIBUTE_ID
+        LEFT JOIN sms_device d ON d.id = r.DEVICE_ID
+        WHERE p.`STATUS`= 1 and p.parm_type in (7,11,9) and d.ENABLE_STATE = 1  and d.`STATUS`= 1
+        <if test="startTime != null and endTime != null ">
+            and r.COLLECT_DATE BETWEEN #{startTime} AND #{endTime}
+        </if>
+        <if test="sceneIds != null and sceneIds.size()>0">
+            and p.PARENT_SCENE_ID in
+            <foreach collection="sceneIds" item="item" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        <if test="tenantId != null and tenantId != '' ">
+            and d.tenant_id = #{tenantId}
+        </if>
+        <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 ( d.DEPT_ORG_ID in
+                <foreach collection="programItems" item="item" open="(" close=")" separator=",">
+                    #{item.orgId}
+                </foreach>
+                or
+                d.COMPANY_ORG_ID in
+                <foreach collection="programItems" item="item" open="(" close=")" separator=",">
+                    #{item.orgId}
+                </foreach>
+                )
+            </if>
+            <if test="permissonType == 4 or permissonType == 3">
+                and d.DEPT_ORG_ID in
+                <foreach collection="programItems" item="item" open="(" close=")" separator=",">
+                    #{item.orgId}
+                </foreach>
+            </if>
+            <if test="permissonType == 1">
+                and d.COMPANY_ORG_ID in
+                <foreach collection="programItems" item="item" open="(" close=")" separator=",">
+                    #{item.orgId}
+                </foreach>
+                and (d.DEPT_ORG_ID is null or d.DEPT_ORG_ID =0)
+            </if>
+        </if>
+        GROUP BY s.SCENE_NAME,p.parm_type,da.unit,r.day
+        order by r.`day` asc
+    </select>
 </mapper>

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

@@ -99,6 +99,7 @@
         a.year as "year" ,
         a.month as "month" ,
         a.day as "day" ,
+        a.DEVICE_NAME as "deviceName",
         b.parent_scene_id as "parentSceneId",
         c.SCENE_NAME as "parentSceneName"
         FROM sms_month_report a
@@ -133,6 +134,53 @@
         </where>
         order by  b.parent_scene_id,a.year,a.month,a.day
     </select>
+    <!--  根据获取实体 page   -->
+    <select id="findPageReprot" resultType="com.huaxu.dto.ReportDto">
+        SELECT
+        distinct
+        a.tenant_id as "tenantId" ,
+        a.year as "year" ,
+        a.month as "month" ,
+        a.day as "day" ,
+        a.DEVICE_NAME as "deviceName",
+        b.parent_scene_id as "parentSceneId",
+        c.SCENE_NAME as "parentSceneName",
+        a.COLLECT_DATE as "collectDate"
+        FROM sms_month_report a
+        inner join sms_device_parm b on a.DEVICE_ID = b.DEVICE_ID and a.ATTRIBUTE_ID=b.ATTRIBUTE_ID
+        <if test="monthReport.typeIds != null">
+            and b.PARM_TYPE in
+            <foreach collection="monthReport.typeIds" item="typeId" open="(" close=")" separator=",">
+                #{typeId}
+            </foreach>
+        </if>
+        and b.`STATUS`=1
+        inner join sms_scene c on b.PARENT_SCENE_ID=c.id
+        <where>
+            b.IS_REPORT=1
+            <if test="monthReport.tenantId != null  and monthReport.tenantId != ''">and a.tenant_id =
+                #{monthReport.tenantId}
+            </if>
+            <if test="monthReport.deviceIds != null and monthReport.deviceIds.size() > 0">
+                and b.DEVICE_ID in
+                <foreach collection="monthReport.deviceIds" item="dramaId" open="(" close=")" separator=",">
+                    #{dramaId.id}
+                </foreach>
+            </if>
+            <if test="monthReport.startTime != null and monthReport.endTime != null ">
+                and a.COLLECT_DATE BETWEEN #{monthReport.startTime} AND #{monthReport.endTime}
+            </if>
+            <if test="monthReport.year != null ">and a.year = #{monthReport.year}</if>
+            <if test="monthReport.month != null ">and a.month = #{monthReport.month}</if>
+            <if test="monthReport.parentSceneIds != null and monthReport.parentSceneIds.length > 0">
+                and b.parent_scene_id in
+                <foreach collection = "monthReport.parentSceneIds" item = "dramaId" open = "(" close = ")" separator = "," >
+                    #{dramaId}
+                </foreach>
+            </if>
+        </where>
+        order by  b.parent_scene_id,a.year,a.month,a.day
+    </select>
     <select id="findAttributeList" resultType="com.huaxu.dto.ReportAttributeDto">
         SELECT tab.attributeName,tab.ATTRIBUTE_TYPE,min(tab.minValue) as "minValue",
         max(tab.maxValue) as "maxValue",AVG(tab.avgValue)as "avgValue",
@@ -153,6 +201,9 @@
                 #{dramaId.id}
             </foreach>
         </if>
+        <if test="report.startTime != null and report.endTime != null ">
+            and c.COLLECT_DATE BETWEEN #{report.startTime} AND #{report.endTime}
+        </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>
@@ -196,6 +247,9 @@
                 #{dramaId}
             </foreach>
         </if>
+        <if test="report.startTime != null and report.endTime != null ">
+            and c.COLLECT_DATE BETWEEN #{report.startTime} AND #{report.endTime}
+        </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>

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

@@ -99,6 +99,7 @@
         a.year as "year" ,
         a.month as "month" ,
         b.parent_scene_id as "parentSceneId",
+        a.DEVICE_NAME as "deviceName",
         c.SCENE_NAME as "parentSceneName"
         FROM sms_year_report a
         inner join sms_device_parm b on a.DEVICE_ID = b.DEVICE_ID and a.ATTRIBUTE_ID=b.ATTRIBUTE_ID
@@ -133,6 +134,50 @@
         </where>
         order by  b.parent_scene_id,a.year,a.month
     </select>
+    <!--  根据获取实体 page   -->
+    <select id="findPageReprot" resultType="com.huaxu.dto.ReportDto">
+        SELECT
+        distinct
+        a.tenant_id as "tenantId" ,
+        a.year as "year" ,
+        a.month as "month" ,
+        b.parent_scene_id as "parentSceneId",
+        a.DEVICE_NAME as "deviceName",
+        c.SCENE_NAME as "parentSceneName",
+        a.COLLECT_DATE as "collectDate"
+        FROM sms_year_report a
+        inner join sms_device_parm b on a.DEVICE_ID = b.DEVICE_ID and a.ATTRIBUTE_ID=b.ATTRIBUTE_ID
+        <if test="yearReport.typeIds != null">
+            and b.PARM_TYPE in
+            <foreach collection="yearReport.typeIds" item="typeId" open="(" close=")" separator=",">
+                #{typeId}
+            </foreach>
+        </if>
+        and b.`STATUS`=1
+        inner join sms_scene c on b.PARENT_SCENE_ID=c.id
+        <where>
+            b.IS_REPORT=1
+            <if test="yearReport.tenantId != null  and yearReport.tenantId != ''">and a.tenant_id =
+                #{yearReport.tenantId}
+            </if>
+            <if test="yearReport.deviceIds != null and yearReport.deviceIds.size() > 0">
+                and b.DEVICE_ID in
+                <foreach collection="yearReport.deviceIds" item="dramaId" open="(" close=")" separator=",">
+                    #{dramaId.id}
+                </foreach>
+            </if>
+            <if test="yearReport.year != null ">
+                and a.year = #{yearReport.year}
+            </if>
+            <if test="yearReport.parentSceneIds != null and yearReport.parentSceneIds.length > 0">
+                and b.parent_scene_id in
+                <foreach collection = "yearReport.parentSceneIds" item = "dramaId" open = "(" close = ")" separator = "," >
+                    #{dramaId}
+                </foreach>
+            </if>
+        </where>
+        order by  b.parent_scene_id,a.year,a.month
+    </select>
     <select id="findAttributeList" resultType="com.huaxu.dto.ReportAttributeDto">
         SELECT tab.attributeName,tab.ATTRIBUTE_TYPE,min(tab.minValue) as "minValue",
         max(tab.maxValue) as "maxValue",AVG(tab.avgValue)as "avgValue",

+ 1 - 1
user_auth/src/main/java/com/huaxu/controller/ThirdPartyLoginController.java

@@ -18,7 +18,7 @@ import org.springframework.web.bind.annotation.RestController;
 
 /**
  * @ClassName ThirdPartyLoginController
- * @Description: 第三方登录登录业务处理
+ * @Description: 第三方登录业务处理
  * @Author lihui
  * @Date 2021/4/7
  * @Version V1.0