Browse Source

压力水量报表

wangyangyang 4 years ago
parent
commit
36127dc21e

+ 1 - 1
sms_water/src/main/java/com/huaxu/config/ResourceServerConfig.java

@@ -17,7 +17,7 @@ public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
                 .and()
                 .authorizeRequests()
                 .antMatchers("/swagger-ui.html","/webjars/**", "/webjars/**", "/swagger-resources/**",
-                       "/v2/**","/devicetype/**")
+                       "/v2/**","/devicetype/**","/report/**")
                 .permitAll() //配置不需要身份认证的请求路径
                 .anyRequest().authenticated() //其他所有访问路径都需要身份认证
                 .and()

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

@@ -2,6 +2,8 @@ package com.huaxu.controller;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.huaxu.dto.DevicePressReportAttributeDto;
+import com.huaxu.dto.DeviceReportDto;
 import com.huaxu.dto.ReportDto;
 import com.huaxu.entity.MonitorInfoEntity;
 import com.huaxu.entity.SceneEntity;
@@ -49,4 +51,23 @@ public class DayMonthYearReportController {
         Pagination<ReportDto> pages = new Pagination<>(iPage);
         return new AjaxMessage<>(ResultStatus.OK,pages);
     }
+
+    @ApiOperation(value = "按设备统计压力及流量年月日统计报表")
+    @RequestMapping(value = "/getDevicePressReportByDeviceIds", method = RequestMethod.POST)
+    @ResponseBody
+    public AjaxMessage<Pagination<DevicePressReportAttributeDto>> getDevicePressReportByDeviceIds(
+            @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<DevicePressReportAttributeDto> iPage = new Page<>(pageNum, pageSize);
+        iPage = reportService.getDevicePressReportByDeviceIds(iPage,ids,year,month,day,reportType,type);
+        Pagination<DevicePressReportAttributeDto> pages = new Pagination<>(iPage);
+        return new AjaxMessage<>(ResultStatus.OK,pages);
+    }
 }

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

@@ -1,8 +1,11 @@
 package com.huaxu.dao;
 
+import com.huaxu.dto.DevicePressReportAttributeDto;
+import com.huaxu.dto.DeviceReportDto;
 import com.huaxu.dto.ReportAttributeDto;
 import com.huaxu.dto.ReportDto;
 import com.huaxu.entity.DayReportEntity;
+
 import java.io.Serializable;
 import java.util.List;
 import java.util.Map;
@@ -12,32 +15,36 @@ import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+
 /**
- *
  * sms_day_reportDAO接口
+ *
  * @author: WYY
  * @date 2020-12-03 16:20
  */
 @Mapper
 public interface DayReportMapper extends BaseMapper<DayReportEntity> {
 
-	/**
+    /**
      * 自定义分页查询
-     * @param  page 
-     * @param  dayReportEntity 实体类
+     *
+     * @param page
+     * @param dayReportEntity 实体类
      */
-     Page<ReportDto> findPage(IPage<ReportDto> page,
-                              @Param("dayReport") DayReportEntity dayReportEntity);
+    Page<ReportDto> findPage(IPage<ReportDto> page,
+                             @Param("dayReport") DayReportEntity dayReportEntity);
 
-     DayReportEntity findDayReportById(Serializable id);
+    DayReportEntity findDayReportById(Serializable id);
 
 
-     List<DayReportEntity> findList(DayReportEntity dayReportEntity);
+    List<DayReportEntity> findList(DayReportEntity dayReportEntity);
 
-     List<ReportAttributeDto> findAttributeList(@Param("report") ReportDto reportDto);
+    List<ReportAttributeDto> findAttributeList(@Param("report") ReportDto reportDto);
 
     List<ReportDto> findReport(@Param("report") ReportDto item);
 
+    Page<DevicePressReportAttributeDto> findDevicePressPage(IPage<DevicePressReportAttributeDto> page, @Param("dayReport") DayReportEntity dayReportEntity);
+
 
     /**删除相关方法  使用mybatis-plus集成的 **/
 }

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

@@ -3,6 +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.ReportAttributeDto;
 import com.huaxu.dto.ReportDto;
 import com.huaxu.entity.DayReportEntity;
@@ -39,5 +40,7 @@ public interface MonthReportMapper extends BaseMapper<MonthReportEntity> {
 
     List<ReportDto> findReport(@Param("report") ReportDto item);
 
-     /**删除相关方法  使用mybatis-plus集成的 **/
+    Page<DevicePressReportAttributeDto> findDevicePressPage(IPage<DevicePressReportAttributeDto> page, @Param("monthReport")  MonthReportEntity monthReportEntity);
+
+    /**删除相关方法  使用mybatis-plus集成的 **/
 }

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

@@ -3,6 +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.ReportAttributeDto;
 import com.huaxu.dto.ReportDto;
 import com.huaxu.entity.DayReportEntity;
@@ -39,5 +40,7 @@ public interface YearReportMapper extends BaseMapper<YearReportEntity> {
 
     List<ReportDto> findReport(@Param("report") ReportDto item);
 
-     /**删除相关方法  使用mybatis-plus集成的 **/
+    Page<DevicePressReportAttributeDto> findDevicePressPage(IPage<DevicePressReportAttributeDto> page, @Param("yearReport") YearReportEntity yearReportEntity);
+
+    /**删除相关方法  使用mybatis-plus集成的 **/
 }

+ 33 - 0
sms_water/src/main/java/com/huaxu/dto/DeviceAmountReportAttributeDto.java

@@ -0,0 +1,33 @@
+package com.huaxu.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+@Data
+@ApiModel("压力报表参数列表")
+public class DeviceAmountReportAttributeDto implements Serializable {
+    private static final long serialVersionUID = 4074399088580570408L;
+    @ApiModelProperty(value = "设备名称")
+    private String deviceName;
+    @ApiModelProperty(value = "设备编号")
+    private String deviceCode;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8")
+    @ApiModelProperty(value = "采集时间")
+    private Date collectDate;
+
+    @ApiModelProperty(value = "最小值")
+    private Double minValue;
+    @ApiModelProperty(value = "最大值")
+    private Double maxValue;
+    @ApiModelProperty(value = "平均值")
+    private Double avgValue;
+    @ApiModelProperty(value = "合计值")
+    private Double sumValue;
+    @ApiModelProperty(value = "最新值")
+    private Double latestValue;
+}

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

@@ -0,0 +1,36 @@
+package com.huaxu.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+@Data
+@ApiModel("压力报表参数列表")
+public class DevicePressReportAttributeDto implements Serializable {
+    private static final long serialVersionUID = 4074399088580570408L;
+    @ApiModelProperty(value = "设备名称")
+    private String deviceName;
+    @ApiModelProperty(value = "设备编号")
+    private String deviceCode;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8")
+    @ApiModelProperty(value = "采集时间")
+    private Date collectDate;
+
+    @ApiModelProperty(value = "最小值")
+    private Double minValue;
+    @ApiModelProperty(value = "最大值")
+    private Double maxValue;
+    @ApiModelProperty(value = "平均值")
+    private Double avgValue;
+    @ApiModelProperty(value = "合计值")
+    private Double sumValue;
+    @ApiModelProperty(value = "最新值")
+    private Double latestValue;
+}

+ 32 - 0
sms_water/src/main/java/com/huaxu/dto/DeviceReportDto.java

@@ -0,0 +1,32 @@
+package com.huaxu.dto;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+
+@Data
+@ApiModel("统计报表日报月报年报")
+public class DeviceReportDto implements Serializable {
+    private static final long serialVersionUID = 4074399088580570408L;
+    @ApiModelProperty("年")
+    private Integer year;
+    @ApiModelProperty("月")
+    private Integer month;
+    @ApiModelProperty("日")
+    private Integer day;
+    @ApiModelProperty("时")
+    private Integer hour;
+    @ApiModelProperty(value = "设备名称")
+    private String deviceName;
+    @ApiModelProperty(value = "设备编号")
+    private String deviceCode;
+    @ApiModelProperty("设备数据")
+    List<ReportAttributeDto> dataValues;
+    @ApiModelProperty(value = "统计时间")
+    private String collectDate;
+}

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

@@ -138,6 +138,11 @@ public class DayReportEntity{
     @JsonIgnore
     private String updateBy;
 
+    @ApiModelProperty(value = "报表类型")
+    @TableField(exist = false)
+    @JsonIgnore
+    private Integer type;
+
     public String getMapkey(){
         StringBuilder stringBuilder=new StringBuilder();
         stringBuilder.append(this.deviceId);

+ 6 - 0
sms_water/src/main/java/com/huaxu/entity/MonthReportEntity.java

@@ -1,6 +1,7 @@
 package com.huaxu.entity;
 
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.annotation.JsonFormat;
@@ -135,6 +136,11 @@ public class MonthReportEntity {
     @JsonIgnore
     private Date dateUpdate;
 
+    @ApiModelProperty(value = "报表类型")
+    @TableField(exist = false)
+    @JsonIgnore
+    private Integer type;
+
     @ApiModelProperty(value = "更新人")
     @JsonIgnore
     private String updateBy;

+ 6 - 0
sms_water/src/main/java/com/huaxu/entity/YearReportEntity.java

@@ -1,6 +1,7 @@
 package com.huaxu.entity;
 
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.annotation.JsonFormat;
@@ -131,6 +132,11 @@ public class YearReportEntity {
     @JsonIgnore
     private Date dateUpdate;
 
+    @ApiModelProperty(value = "报表类型")
+    @TableField(exist = false)
+    @JsonIgnore
+    private Integer type;
+
     @ApiModelProperty(value = "更新人")
     @JsonIgnore
     private String updateBy;

+ 24 - 3
sms_water/src/main/java/com/huaxu/service/DayReportService.java

@@ -3,9 +3,7 @@ package com.huaxu.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.huaxu.dao.DayReportMapper;
-import com.huaxu.dto.DeviceDto;
-import com.huaxu.dto.ReportAttributeDto;
-import com.huaxu.dto.ReportDto;
+import com.huaxu.dto.*;
 import com.huaxu.entity.DayReportEntity;
 import com.huaxu.model.LoginUser;
 import com.huaxu.util.UserUtil;
@@ -160,4 +158,27 @@ public class DayReportService extends ServiceImpl<DayReportMapper, DayReportEnti
             }
         }
     }
+
+    public Page<DevicePressReportAttributeDto> findDevicePressPage(IPage<DevicePressReportAttributeDto> page, Long[] ids, Integer year, Integer month, Integer day,Integer type) {
+        LoginUser currentUser = UserUtil.getCurrentUser();
+        Page<DevicePressReportAttributeDto> reportPage = new Page<>();
+        //查询场景下的所有设备信息
+        List<DeviceDto> devices = new ArrayList<>();
+        for (Long id : ids) {
+            DeviceDto deviceDto = new DeviceDto();
+            deviceDto.setId(id);
+            devices.add(deviceDto);
+        }
+        //根据设备ID查询报表测点信息
+        DayReportEntity dayReportEntity = new DayReportEntity();
+        dayReportEntity.setYear(year);
+        dayReportEntity.setMonth(month);
+        dayReportEntity.setDay(day);
+        dayReportEntity.setTenantId(currentUser.getTenantId());
+        dayReportEntity.setType(type);
+        dayReportEntity.setDeviceIds(devices);
+        //查询到分页的行数
+        reportPage = dayReportMapper.findDevicePressPage(page, dayReportEntity);
+        return reportPage;
+    }
 }

+ 23 - 3
sms_water/src/main/java/com/huaxu/service/MonthReportService.java

@@ -6,9 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.huaxu.dao.DayReportMapper;
 import com.huaxu.dao.MonthReportMapper;
-import com.huaxu.dto.DeviceDto;
-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 com.huaxu.model.LoginUser;
@@ -153,4 +151,26 @@ public class MonthReportService extends ServiceImpl<MonthReportMapper, MonthRepo
             }
         }
     }
+
+    public Page<DevicePressReportAttributeDto> findDevicePressPage(IPage<DevicePressReportAttributeDto> page, Long[] ids, Integer year, Integer month, Integer day,Integer type) {
+        LoginUser currentUser = UserUtil.getCurrentUser();
+        Page<DevicePressReportAttributeDto> reportPage = new Page<>();
+        //查询场景下的所有设备信息
+        List<DeviceDto> devices = new ArrayList<>();
+        for (Long id : ids) {
+            DeviceDto deviceDto = new DeviceDto();
+            deviceDto.setId(id);
+            devices.add(deviceDto);
+        }
+        //根据设备ID查询报表测点信息
+        MonthReportEntity monthReportEntity = new MonthReportEntity();
+        monthReportEntity.setYear(year);
+        monthReportEntity.setMonth(month);
+        monthReportEntity.setTenantId(currentUser.getTenantId());
+        monthReportEntity.setType(type);
+        monthReportEntity.setDeviceIds(devices);
+        //查询到分页的行数
+        reportPage = monthReportMapper.findDevicePressPage(page, monthReportEntity);
+        return reportPage;
+    }
 }

+ 19 - 0
sms_water/src/main/java/com/huaxu/service/ReportService.java

@@ -2,6 +2,8 @@ package com.huaxu.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.huaxu.dto.DevicePressReportAttributeDto;
+import com.huaxu.dto.DeviceReportDto;
 import com.huaxu.dto.ReportDto;
 import com.huaxu.entity.SceneEntity;
 import com.huaxu.model.LoginUser;
@@ -47,4 +49,21 @@ public class ReportService {
         }
         return reportPage;
     }
+
+    public IPage<DevicePressReportAttributeDto> getDevicePressReportByDeviceIds(IPage<DevicePressReportAttributeDto> page, Long[] ids, Integer year, Integer month, Integer day, Integer reportType, Integer type) {
+        Page<DevicePressReportAttributeDto> reportPage = new Page<>();
+        if (reportType.equals(0))//日报
+        {
+            reportPage = dayReportService.findDevicePressPage(page, ids, year, month, day,type);
+        }
+        if (reportType.equals(1))//月报
+        {
+            reportPage = monthReportService.findDevicePressPage(page, ids, year, month, day,type);
+        }
+        if (reportType.equals(2))//年报
+        {
+            reportPage = yearReportService.findDevicePressPage(page, ids, year, month, day,type);
+        }
+        return reportPage;
+    }
 }

+ 22 - 3
sms_water/src/main/java/com/huaxu/service/YearReportService.java

@@ -7,9 +7,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.huaxu.dao.DayReportMapper;
 import com.huaxu.dao.MonthReportMapper;
 import com.huaxu.dao.YearReportMapper;
-import com.huaxu.dto.DeviceDto;
-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 com.huaxu.entity.YearReportEntity;
@@ -153,4 +151,25 @@ public class YearReportService extends ServiceImpl<YearReportMapper, YearReportE
             }
         }
     }
+
+    public Page<DevicePressReportAttributeDto> findDevicePressPage(IPage<DevicePressReportAttributeDto> page, Long[] ids, Integer year, Integer month, Integer day,Integer type) {
+        LoginUser currentUser = UserUtil.getCurrentUser();
+        Page<DevicePressReportAttributeDto> reportPage = new Page<>();
+        //查询场景下的所有设备信息
+        List<DeviceDto> devices = new ArrayList<>();
+        for (Long id : ids) {
+            DeviceDto deviceDto = new DeviceDto();
+            deviceDto.setId(id);
+            devices.add(deviceDto);
+        }
+        //根据设备ID查询报表测点信息
+        YearReportEntity yearReportEntity = new YearReportEntity();
+        yearReportEntity.setYear(year);
+        yearReportEntity.setTenantId(currentUser.getTenantId());
+        yearReportEntity.setType(type);
+        yearReportEntity.setDeviceIds(devices);
+        //查询到分页的行数
+        reportPage = yearReportMapper.findDevicePressPage(page, yearReportEntity);
+        return reportPage;
+    }
 }

+ 32 - 1
sms_water/src/main/resources/mapper/DayReportMapper.xml

@@ -103,7 +103,7 @@
         a.parent_scene_id as "parentSceneId",
         a.parent_scene_name as "parentSceneName"
         FROM sms_day_report a
-        inner join sms_device_parm b on a.DEVICE_ID = b.DEVICE_ID
+        inner join sms_device_parm b on a.DEVICE_ID = b.DEVICE_ID and a.ATTRIBUTE_ID=b.ATTRIBUTE_ID
         <where>
             b.IS_REPORT=1
             <if test="dayReport.tenantId != null  and dayReport.tenantId != ''">and a.tenant_id =
@@ -184,4 +184,35 @@
         group by tab.year,tab.month,tab.day,tab.HOUR
         order by tab.year desc,tab.month desc,tab.day desc,tab.hour desc
     </select>
+    <!--  根据获取实体 page   -->
+    <select id="findDevicePressPage" resultType="com.huaxu.dto.DevicePressReportAttributeDto">
+        SELECT
+        a.DEVICE_CODE as  "deviceCode",
+        a.DEVICE_NAME as "deviceName",
+        a.min_value as "minValue" ,a.max_value as "maxValue" ,a.avg_value as "avgValue" ,
+        a.sum_value as "sumValue" ,a.latest_value as "latestValue",
+        a.COLLECT_DATE as "collectDate"
+        FROM sms_day_report a
+        inner join sms_device d on d.id = a.DEVICE_ID
+        inner join sms_device_parm b on a.DEVICE_ID = b.DEVICE_ID and a.ATTRIBUTE_ID=b.ATTRIBUTE_ID
+        <if test="dayReport.type == 1">
+               and b.PARM_TYPE = 13
+           </if>
+        <if test="dayReport.type == 2">
+            and b.PARM_TYPE = 14
+        </if>
+        <where>
+            <if test="dayReport.tenantId != null  and dayReport.tenantId != ''">and a.tenant_id =
+                #{dayReport.tenantId}
+            </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>
+            and a.DEVICE_ID in
+            <foreach collection="dayReport.deviceIds" item="dramaId" open="(" close=")" separator=",">
+                #{dramaId.id}
+            </foreach>
+        </where>
+        order by a.DEVICE_ID,a.year,a.month,a.day,a.hour
+    </select>
 </mapper>

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

@@ -102,7 +102,9 @@
         a.parent_scene_id as "parentSceneId",
         a.parent_scene_name as "parentSceneName"
         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
         <where>
+            b.IS_REPORT=1
             <if test="monthReport.tenantId != null  and monthReport.tenantId != ''">and a.tenant_id =
                 #{monthReport.tenantId}
             </if>
@@ -178,4 +180,34 @@
         group by tab.year,tab.month,tab.day
         order by tab.year desc,tab.month desc,tab.day desc
     </select>
+    <!--  根据获取实体 page   -->
+    <select id="findDevicePressPage" resultType="com.huaxu.dto.DevicePressReportAttributeDto">
+        SELECT
+        a.DEVICE_CODE as  "deviceCode",
+        a.DEVICE_NAME as "deviceName",
+        a.min_value as "minValue" ,a.max_value as "maxValue" ,a.avg_value as "avgValue" ,
+        a.sum_value as "sumValue" ,a.latest_value as "latestValue",
+        a.COLLECT_DATE as "collectDate"
+        FROM sms_month_report a
+        inner join sms_device d on d.id = a.DEVICE_ID
+        inner join sms_device_parm b on a.DEVICE_ID = b.DEVICE_ID and a.ATTRIBUTE_ID=b.ATTRIBUTE_ID
+        <if test="monthReport.type == 1">
+            and b.PARM_TYPE = 13
+        </if>
+        <if test="monthReport.type == 2">
+            and b.PARM_TYPE = 14
+        </if>
+        <where>
+            <if test="monthReport.tenantId != null  and monthReport.tenantId != ''">and a.tenant_id =
+                #{dayReport.tenantId}
+            </if>
+            <if test="monthReport.year != null ">and a.year = #{monthReport.year}</if>
+            <if test="monthReport.month != null ">and a.month = #{monthReport.month}</if>
+            and a.DEVICE_ID in
+            <foreach collection="monthReport.deviceIds" item="dramaId" open="(" close=")" separator=",">
+                #{dramaId.id}
+            </foreach>
+        </where>
+        order by a.DEVICE_ID,a.year,a.month,a.day
+    </select>
 </mapper>

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

@@ -101,7 +101,9 @@
         a.parent_scene_id as "parentSceneId",
         a.parent_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
         <where>
+            b.IS_REPORT=1
             <if test="yearReport.tenantId != null  and yearReport.tenantId != ''">and a.tenant_id =
                 #{yearReport.tenantId}
             </if>
@@ -175,4 +177,34 @@
         group by tab.year,tab.month
         order by tab.year desc,tab.month desc
     </select>
+
+    <!--  根据获取实体 page   -->
+    <select id="findDevicePressPage" resultType="com.huaxu.dto.DevicePressReportAttributeDto">
+        SELECT
+        a.DEVICE_CODE as  "deviceCode",
+        a.DEVICE_NAME as "deviceName",
+        a.min_value as "minValue" ,a.max_value as "maxValue" ,a.avg_value as "avgValue" ,
+        a.sum_value as "sumValue" ,a.latest_value as "latestValue",
+        a.COLLECT_DATE as "collectDate"
+        FROM sms_year_report a
+        inner join sms_device d on d.id = a.DEVICE_ID
+        inner join sms_device_parm b on a.DEVICE_ID = b.DEVICE_ID and a.ATTRIBUTE_ID=b.ATTRIBUTE_ID
+        <if test="yearReport.type == 1">
+            and b.PARM_TYPE = 13
+        </if>
+        <if test="yearReport.type == 2">
+            and b.PARM_TYPE = 14
+        </if>
+        <where>
+            <if test="yearReport.tenantId != null  and yearReport.tenantId != ''">and a.tenant_id =
+                #{yearReport.tenantId}
+            </if>
+            <if test="yearReport.year != null ">and a.year = #{yearReport.year}</if>
+            and a.DEVICE_ID in
+            <foreach collection="yearReport.deviceIds" item="dramaId" open="(" close=")" separator=",">
+                #{dramaId.id}
+            </foreach>
+        </where>
+        order by a.DEVICE_ID,a.year,a.month
+    </select>
 </mapper>