Browse Source

水务版优化迭代23

lin 3 years ago
parent
commit
6ecac7be24
26 changed files with 496 additions and 68 deletions
  1. 6 3
      smart-city-platform/src/main/java/com/bz/smart_city/commom/util/ExcelUtil.java
  2. 2 1
      smart-city-platform/src/main/java/com/bz/smart_city/controller/CommunityManagerController.java
  3. 40 0
      smart-city-platform/src/main/java/com/bz/smart_city/controller/DeviceController.java
  4. 2 2
      smart-city-platform/src/main/java/com/bz/smart_city/controller/system/BuildingController.java
  5. 29 1
      smart-city-platform/src/main/java/com/bz/smart_city/controller/water/WaterConsumptionController.java
  6. 1 1
      smart-city-platform/src/main/java/com/bz/smart_city/dao/BuildingMapper.java
  7. 2 0
      smart-city-platform/src/main/java/com/bz/smart_city/dao/MeterReadRecordMapper.java
  8. 3 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/CommunityDto.java
  9. 11 2
      smart-city-platform/src/main/java/com/bz/smart_city/dto/WaterConsumptionDto.java
  10. 46 0
      smart-city-platform/src/main/java/com/bz/smart_city/rabbitmq/listener/GeneralReceiver.java
  11. 9 0
      smart-city-platform/src/main/java/com/bz/smart_city/rabbitmq/model/RabbitParamData.java
  12. 24 0
      smart-city-platform/src/main/java/com/bz/smart_city/rabbitmq/model/RabbitWaterConsumptionData.java
  13. 1 1
      smart-city-platform/src/main/java/com/bz/smart_city/service/BuildingService.java
  14. 1 1
      smart-city-platform/src/main/java/com/bz/smart_city/service/CommunityService.java
  15. 3 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/DeviceService.java
  16. 6 4
      smart-city-platform/src/main/java/com/bz/smart_city/service/MeterReadRecordService.java
  17. 5 5
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/BuildingServiceImpl.java
  18. 3 3
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/CommunityServiceImpl.java
  19. 41 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/DeviceServiceImpl.java
  20. 189 20
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/MeterReadRecordServiceImpl.java
  21. 1 0
      smart-city-platform/src/main/resources/application-dev.properties
  22. 2 1
      smart-city-platform/src/main/resources/application-prd.properties
  23. 2 1
      smart-city-platform/src/main/resources/application-sit.properties
  24. 2 1
      smart-city-platform/src/main/resources/mapper/BuildingMapper.xml
  25. 8 4
      smart-city-platform/src/main/resources/mapper/CommunityMapper.xml
  26. 57 17
      smart-city-platform/src/main/resources/mapper/MeterReadRecordMapper.xml

+ 6 - 3
smart-city-platform/src/main/java/com/bz/smart_city/commom/util/ExcelUtil.java

@@ -322,17 +322,20 @@ public class ExcelUtil {
                 //剔除
                 dataList.subList(0, pointsDataLimit).clear();
             }
-
+            FileOutputStream output = null;
             try {
                 //输出Excel文件
-                FileOutputStream output = new FileOutputStream(path);
+                output = new FileOutputStream(path);
                 workbook.write(output);
                 output.flush();
-                workbook.close();
+
             } catch (IOException e) {
                 e.printStackTrace();
             }finally {
                 workbook.close();
+                if(output!=null){
+                    output.close();
+                }
             }
 
         } catch (Exception e) {

+ 2 - 1
smart-city-platform/src/main/java/com/bz/smart_city/controller/CommunityManagerController.java

@@ -68,6 +68,7 @@ public class CommunityManagerController {
 	@ApiOperation(value = "获取小区列表分页", notes = "权限:sys:community:query")
 	@PreAuthorize("hasAuthority('sys:community:query')")
 	public AjaxMessage<Pagination<CommunityDto>> getCommunityPage(
+			@ApiParam(value = "客户id", required = false) @RequestParam(required = false) Integer customerId,
 			@ApiParam(value = "小区名称", required = false) @RequestParam(required = false) String communityName,
 			@ApiParam(value = "省", required = false) @RequestParam(required = false) Integer province,
 			@ApiParam(value = "市", required = false) @RequestParam(required = false) Integer city,
@@ -75,7 +76,7 @@ public class CommunityManagerController {
 			@ApiParam(value = "页数,非必传,默认第一页", required = false, defaultValue = "1") @RequestParam(required = false, defaultValue = "1") int pageNum,
 			@ApiParam(value = "条数,非必传,默认15条", required = false, defaultValue = "15") @RequestParam(required = false, defaultValue = "15") int pageSize
 	) {
-		Pagination<CommunityDto> pageInfo = communityService.getCommunityPage(StringUtils.trim(communityName), province, city, region, pageNum, pageSize);
+		Pagination<CommunityDto> pageInfo = communityService.getCommunityPage(StringUtils.trim(communityName), province, city, region,customerId, pageNum, pageSize);
 		return new AjaxMessage<>(ResultStatus.OK, pageInfo);
 	}
 

+ 40 - 0
smart-city-platform/src/main/java/com/bz/smart_city/controller/DeviceController.java

@@ -169,6 +169,46 @@ public class DeviceController {
                 httpServletResponse);
     }
 
+    @ResponseBody
+    @GetMapping("/getDeviceListTxt")
+    @ApiOperation(value = "导出设备列表txt")
+    public AjaxMessage getDeviceListTxt(
+            @ApiParam(value = "别名", required = false) @RequestParam(required = false) String alias,
+            @ApiParam(value = "系统id", required = false) @RequestParam(required = false) Integer sysId,
+            @ApiParam(value = "客户id", required = false) @RequestParam(required = false) Integer customerId,
+            @ApiParam(value = "设备类型id", required = false) @RequestParam(required = false) Integer deviceTypeId,
+            @ApiParam(value = "省", required = false) @RequestParam(required = false) Integer province,
+            @ApiParam(value = "市", required = false) @RequestParam(required = false) Integer city,
+            @ApiParam(value = "区", required = false) @RequestParam(required = false) Integer region,
+            @ApiParam(value = "小区id", required = false) @RequestParam(required = false) Integer community,
+            @ApiParam(value = "建筑id", required = false) @RequestParam(required = false) Integer buildingId,
+            @ApiParam(value = "设备编号", required = false) @RequestParam(required = false) String deviceNo,
+            @ApiParam(value = "楼层", required = false) @RequestParam(required = false) Integer floor,
+            @ApiParam(value = "位置描述", required = false) @RequestParam(required = false) String locDesc,
+            @ApiParam(value = "集中器id", required = false) @RequestParam(required = false) Integer concentratorId,
+            @ApiParam(value = "集中器编号", required = false) @RequestParam(required = false) String concentratorNo,
+            @ApiParam(value = "采集器id", required = false) @RequestParam(required = false) Integer collectorId,
+            @ApiParam(value = "采集器编号", required = false) @RequestParam(required = false) String collectorNo,
+            @ApiParam(value = "通道号id", required = false) @RequestParam(required = false) Integer channelNumberId,
+            @ApiParam(value = "故障类型", required = false) @RequestParam(required = false) String errorType,
+            @ApiParam(value = "连续故障天数", required = false) @RequestParam(required = false) Integer days,
+            @ApiParam(value = "设备状态  1:正常 2:故障 3:无 4: 预警 5:未启用", required = false) @RequestParam(required = false) Integer status,
+            @ApiParam(value = "阀门状态 0:关阀 1:开阀  2:无阀", required = false) @RequestParam(required = false) Integer valveStatus,
+            @ApiParam(value = "注册状态 0:未注册 1:已注册", required = false) @RequestParam(required = false) Integer registerStatus,
+            @ApiParam(value = "下发状态 0:未下发 1:已下发", required = false) @RequestParam(required = false) Integer issueStatus,
+            @ApiParam(value = "同步状态 0:未同步 1:已同步", required = false) @RequestParam(required = false) Integer syncStatus,
+            @ApiParam(value = "开始当前读数", required = false) @RequestParam(required = false) Double startReading,
+            @ApiParam(value = "结束当前读数", required = false) @RequestParam(required = false) Double endReading,
+            @ApiParam(value = "排序参数,对应列表字段", required = false) @RequestParam(required = false,defaultValue = "sd.date_create") String sortColumn,
+            @ApiParam(value = "排序方式,顺序:ASC  倒序:DESC", required = false) @RequestParam(required = false,defaultValue = "DESC") String sortOrder,
+            HttpServletResponse httpServletResponse
+    ) {
+        deviceService.getDeviceListTxt(alias,sysId, buildingId, StringUtils.trim(deviceNo), status, floor, StringUtils.trim(locDesc),
+                province, city, region, community,concentratorId, concentratorNo, collectorId,collectorNo,channelNumberId, errorType, customerId, days,
+                deviceTypeId,valveStatus,registerStatus,issueStatus,syncStatus, startReading, endReading, sortColumn, sortOrder, httpServletResponse);
+        return new AjaxMessage<>(ResultStatus.OK,"导出执行成功,请稍后在消息查看导出文件并下载。");
+    }
+
     @ResponseBody
     @GetMapping("/deviceAreaList")
     @ApiOperation(value = "获取设备数量区域列表")

+ 2 - 2
smart-city-platform/src/main/java/com/bz/smart_city/controller/system/BuildingController.java

@@ -44,10 +44,10 @@ public class BuildingController {
     @ApiOperation(value = "获取建筑树形列表(用户权限)")
     public AjaxMessage<List<BuildingSelectDto>> select(
             @ApiParam(value = "场景id", required = false) @RequestParam(required = false) Integer sysId,
-            @ApiParam(value = "名称", required = false) @RequestParam(required = false) Integer name
+            @ApiParam(value = "客户id", required = false) @RequestParam(required = false) Integer customerId
     ) {
         LoginUser loginUser = UserUtil.getCurrentUser();
-        List<BuildingSelectDto> list = buildingService.select(loginUser, sysId);
+        List<BuildingSelectDto> list = buildingService.select(loginUser, sysId,customerId);
         return new AjaxMessage<>(ResultStatus.OK, list);
     }
 

+ 29 - 1
smart-city-platform/src/main/java/com/bz/smart_city/controller/water/WaterConsumptionController.java

@@ -5,6 +5,7 @@ import com.bz.smart_city.commom.model.CommonQueryCondition;
 import com.bz.smart_city.commom.model.Pagination;
 import com.bz.smart_city.commom.model.ResultStatus;
 import com.bz.smart_city.commom.util.UserUtil;
+import com.bz.smart_city.dto.BuildingSelectDto;
 import com.bz.smart_city.dto.LoginUser;
 import com.bz.smart_city.dto.WaterConsumptionDto;
 import com.bz.smart_city.dto.WaterConsumptionSummaryDto;
@@ -13,10 +14,12 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 
 @Api(tags ="用水量统计")
@@ -64,7 +67,7 @@ public class WaterConsumptionController {
             @ApiParam(value = "开始时间 格式:yyyyMMdd", required = false) @RequestParam(required = false) Integer endDate,
             @ApiParam(value = "最低用水量", required = false) @RequestParam(required = false) Double minConsumption,
             @ApiParam(value = "最高用水量", required = false) @RequestParam(required = false) Double maxConsumption,
-            @ApiParam(value = "排序方式,顺序:ASC  倒序:DESC", required = false, defaultValue = "ASC") @RequestParam(required = false, defaultValue = "ASC") String sortOrder,
+            @ApiParam(value = "排序方式,顺序:ASC  倒序:DESC", required = false, defaultValue = "DESC") @RequestParam(required = false, defaultValue = "DESC") String sortOrder,
             @ApiParam(value = "页数,非必传,默认第一页", required = false, defaultValue = "1") @RequestParam(required = false, defaultValue = "1") int pageNum,
             @ApiParam(value = "条数,非必传,默认15条", required = false, defaultValue = "15") @RequestParam(required = false, defaultValue = "15") int pageSize
     ) {
@@ -106,4 +109,29 @@ public class WaterConsumptionController {
         log.info("结束执行用用水量恢复");
         return new AjaxMessage(ResultStatus.OK);
     }
+
+    @ResponseBody
+    @GetMapping("/getConsumptionExcel")
+    @ApiOperation(value = "导出列表excel")
+    public AjaxMessage getConsumptionExcel(
+            @ApiParam(value = "客户", required = false) @RequestParam(required = false) Integer customerId,
+            @ApiParam(value = "省 数字用','隔开", required = false) @RequestParam(required = false) List<Integer> provinces,
+            @ApiParam(value = "市 数字用','隔开", required = false) @RequestParam(required = false) List<Integer> cities,
+            @ApiParam(value = "区 数字用','隔开", required = false) @RequestParam(required = false) List<Integer> regions,
+            @ApiParam(value = "小区 数字用','隔开", required = false) @RequestParam(required = false) List<Integer> communities,
+            @ApiParam(value = "建筑id 数字用','隔开", required = false) @RequestParam(required = false) List<Integer> buildingIds,
+            @ApiParam(value = "开始时间 格式:yyyyMMdd", required = false) @RequestParam(required = false) Integer startDate,
+            @ApiParam(value = "开始时间 格式:yyyyMMdd", required = false) @RequestParam(required = false) Integer endDate,
+            @ApiParam(value = "最低用水量", required = false) @RequestParam(required = false) Double minConsumption,
+            @ApiParam(value = "最高用水量", required = false) @RequestParam(required = false) Double maxConsumption,
+            @ApiParam(value = "排序方式,顺序:ASC  倒序:DESC", required = false, defaultValue = "DESC") @RequestParam(required = false, defaultValue = "DESC") String sortOrder,
+            HttpServletResponse httpServletResponse
+    ) {
+        CommonQueryCondition condition = setConditionForQuery(customerId, provinces, cities, regions, communities, buildingIds, startDate, endDate, minConsumption, maxConsumption);
+        condition.setSortOrder(sortOrder);
+        condition.setCustomerIds(UserUtil.getCustomerIds());
+        meterReadRecordService.getConsumptionExcel(condition, httpServletResponse);
+        return new AjaxMessage<>(ResultStatus.OK,"导出执行成功,请稍后在消息查看导出文件并下载。");
+    }
+
 }

+ 1 - 1
smart-city-platform/src/main/java/com/bz/smart_city/dao/BuildingMapper.java

@@ -24,7 +24,7 @@ public interface BuildingMapper {
 
     List<Building> findBySiteIdAndCustomerIds(@Param("siteId") Integer siteId, @Param("sysId") Integer sysId, @Param("customerIds") List<Integer> customerIds);
 
-    List<Building> findBySiteIdAndProgramItem(@Param("siteId") Integer siteId, @Param("sysId") Integer sysId, @Param("buildingIds") List<Integer> buildingIds, @Param("buildingName") String buildingName, @Param("customerIds") List<Integer> customerIds);
+    List<Building> findBySiteIdAndProgramItem(@Param("siteId") Integer siteId, @Param("sysId") Integer sysId, @Param("buildingIds") List<Integer> buildingIds, @Param("buildingName") String buildingName,@Param("customerId") Integer customerId, @Param("customerIds") List<Integer> customerIds);
 
     List<BuildingSelectInfoDto> findBuildingCountDeviceNum(@Param("siteId") Integer siteId, @Param("sysId") Integer sysId, @Param("programItems") List<ProgramItem> programItems, @Param("deviceNo") String deviceNo, @Param("locDesc") String locDesc, @Param("deviceTypeId") Integer deviceTypeId, @Param("deviceStatus") Integer deviceStatus, @Param("region") Integer region, @Param("communityId") Integer communityId);
 

+ 2 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dao/MeterReadRecordMapper.java

@@ -77,6 +77,8 @@ public interface MeterReadRecordMapper {
     WaterConsumptionSummaryDto getSummary(@Param("param") CommonQueryCondition condition);
 
     List<WaterConsumptionDto> getList(@Param("param") CommonQueryCondition condition);
+
+    List<WaterConsumptionDto> getListDay(@Param("param") CommonQueryCondition condition);
     //
 
     // 每日跑p计算每日用水量

+ 3 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dto/CommunityDto.java

@@ -22,4 +22,7 @@ public class CommunityDto extends Community {
     @ApiModelProperty(value = "片区区", position = 4)
     private String districtName;
 
+    @ApiModelProperty(value = "客户名称", position = 4)
+    private String customerName;
+
 }

+ 11 - 2
smart-city-platform/src/main/java/com/bz/smart_city/dto/WaterConsumptionDto.java

@@ -9,8 +9,17 @@ public class WaterConsumptionDto {
     @ApiModelProperty(value = "水表电子号")
     private String meterNo;
 
-    @ApiModelProperty(value = "水表类型")
-    private String deviceType;
+    @ApiModelProperty(value = "档案号")
+    private String fileNo;
+
+    @ApiModelProperty(value = "系列", position = 100)
+    private String equipmentType;
+
+    @ApiModelProperty(value = "型号", position = 101)
+    private String model;
+
+    @ApiModelProperty(value = "厂商名称", position = 102)
+    private String manufacturerName;
 
     @ApiModelProperty(value = "所属客户")
     private String customer;

+ 46 - 0
smart-city-platform/src/main/java/com/bz/smart_city/rabbitmq/listener/GeneralReceiver.java

@@ -0,0 +1,46 @@
+package com.bz.smart_city.rabbitmq.listener;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.TypeReference;
+import com.bz.smart_city.rabbitmq.model.RabbitCommandParamData;
+import com.bz.smart_city.rabbitmq.model.RabbitParamData;
+import com.bz.smart_city.rabbitmq.model.RabbitWaterConsumptionData;
+import com.bz.smart_city.service.DeviceCommandService;
+import com.bz.smart_city.service.MeterReadRecordService;
+import com.rabbitmq.client.Channel;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.amqp.core.Message;
+import org.springframework.amqp.rabbit.annotation.RabbitListener;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.io.IOException;
+
+
+@Component
+@Slf4j
+public class GeneralReceiver {
+
+    @Autowired
+    private MeterReadRecordService meterReadRecordService;
+
+    @RabbitListener(queues = {"${spring.rabbitmq.general-task-queue}"},containerFactory = "platformListenerContainerFactory")
+    public void receiver(Channel channel, Message message) throws IOException {
+        //String str = new String(body);
+        try {
+            String msg = new String(message.getBody());
+            log.info("-----GeneralReceiver msg-----,"  +msg);
+
+            RabbitParamData paramData = JSON.parseObject(msg, RabbitParamData.class);
+            if(StringUtils.equals("waterConsumptionExcel",paramData.getService())){
+                // 1,处理消息
+                RabbitParamData<RabbitWaterConsumptionData> data = JSON.parseObject(msg, new TypeReference<RabbitParamData<RabbitWaterConsumptionData>>(){});
+                meterReadRecordService.executeWaterConsumptionExcel(data.getData());
+            }
+
+        } catch (Exception e) {
+            log.error("consumer message error !",e);
+        }
+    }
+}

+ 9 - 0
smart-city-platform/src/main/java/com/bz/smart_city/rabbitmq/model/RabbitParamData.java

@@ -0,0 +1,9 @@
+package com.bz.smart_city.rabbitmq.model;
+
+import lombok.Data;
+
+@Data
+public class RabbitParamData<T> {
+    private String service;
+    private T data;
+}

+ 24 - 0
smart-city-platform/src/main/java/com/bz/smart_city/rabbitmq/model/RabbitWaterConsumptionData.java

@@ -0,0 +1,24 @@
+package com.bz.smart_city.rabbitmq.model;
+
+import lombok.Data;
+import java.util.List;
+
+@Data
+public class RabbitWaterConsumptionData {
+    private Integer taskId;
+    private Integer userId;
+    private Integer siteId;
+    private Integer customerId;
+    private List<Integer> provinces;
+    private List<Integer> cities;
+    private List<Integer> regions;
+    private List<Integer> communities;
+    private List<Integer> buildingIds;
+    private Integer startDate;
+    private Integer endDate;
+    private Double minConsumption;
+    private Double maxConsumption;
+    private String sortOrder;
+    private List<Integer> customerIds;
+    private String title;
+}

+ 1 - 1
smart-city-platform/src/main/java/com/bz/smart_city/service/BuildingService.java

@@ -22,7 +22,7 @@ public interface BuildingService{
 
     List<BuildingInfoDto> queryBuildingInfo(Integer sysId, Integer buildingId, String buildingName);
 
-    List<BuildingSelectDto> select(LoginUser loginUser, Integer channelId);
+    List<BuildingSelectDto> select(LoginUser loginUser, Integer channelId, Integer customerId);
 
     List<BuildingSelectDto> buildingSearch(LoginUser loginUser, Integer channelId, String buildingName);
 

+ 1 - 1
smart-city-platform/src/main/java/com/bz/smart_city/service/CommunityService.java

@@ -22,7 +22,7 @@ public interface CommunityService {
 
     List<CommunityDto> queryCommunity(Community community);
 
-    Pagination<CommunityDto> getCommunityPage(@Param("communityName") String communityName, @Param("province") Integer province, @Param("city") Integer city, @Param("region") Integer region, @Param("pageNum") int pageNum, @Param("pageSize") int pageSize);
+    Pagination<CommunityDto> getCommunityPage(String communityName, Integer province, Integer city, Integer region, Integer customerId, int pageNum, int pageSize);
 
     void addCommunity(@Param("communityDto") CommunityDto communityDto);
 

+ 3 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/DeviceService.java

@@ -52,6 +52,9 @@ public interface DeviceService{
     void getDeviceListExcel(String alias, Integer sysId, Integer buildingId, String deviceNo, Integer status, Integer floor,
                             String locDesc, Integer province, Integer city, Integer region, Integer community, Integer concentratorId, String concentratorNo, Integer collectorId, String collectorNo,Integer channelNumberId, String errorType,
                             Integer customerId, Integer days,  Integer deviceTypeId, Integer valveStatus, Integer registerStatus, Integer issueStatus, Integer syncStatus, Double startReading, Double endReading, String sortColumn, String sortOrder, HttpServletResponse httpServletResponse);
+    void getDeviceListTxt(String alias, Integer sysId, Integer buildingId, String deviceNo, Integer status, Integer floor,
+                            String locDesc, Integer province, Integer city, Integer region, Integer community, Integer concentratorId, String concentratorNo, Integer collectorId, String collectorNo,Integer channelNumberId, String errorType,
+                            Integer customerId, Integer days,  Integer deviceTypeId, Integer valveStatus, Integer registerStatus, Integer issueStatus, Integer syncStatus, Double startReading, Double endReading, String sortColumn, String sortOrder, HttpServletResponse httpServletResponse);
 
     void executeDeviceListExcel(RabbitDeviceParamData paramData);
 

+ 6 - 4
smart-city-platform/src/main/java/com/bz/smart_city/service/MeterReadRecordService.java

@@ -6,13 +6,11 @@ import java.util.List;
 import com.bz.smart_city.commom.model.CommonQueryCondition;
 import com.bz.smart_city.commom.model.ListObjectWrapper;
 import com.bz.smart_city.commom.model.Pagination;
-import com.bz.smart_city.dto.ClearingDataDTO;
-import com.bz.smart_city.dto.MeterReadDataDTO;
-import com.bz.smart_city.dto.WaterConsumptionDto;
-import com.bz.smart_city.dto.WaterConsumptionSummaryDto;
+import com.bz.smart_city.dto.*;
 import com.bz.smart_city.entity.MeterReadRate;
 import com.bz.smart_city.entity.MeterReadRecord;
 import com.bz.smart_city.entity.MeterRecordStat;
+import com.bz.smart_city.rabbitmq.model.RabbitWaterConsumptionData;
 
 import javax.servlet.http.HttpServletResponse;
 
@@ -80,4 +78,8 @@ public interface MeterReadRecordService{
      * @return
      */
     int waterMeterReadDataByType(Date date ,String waterMeterCode ,String wsvCode);
+
+    void getConsumptionExcel(CommonQueryCondition condition, HttpServletResponse httpServletResponse);
+
+    void executeWaterConsumptionExcel(RabbitWaterConsumptionData data);
 }

+ 5 - 5
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/BuildingServiceImpl.java

@@ -106,14 +106,14 @@ public class BuildingServiceImpl implements BuildingService {
 
     @Override
     //@Cacheable(value = "buildingSelectDtoCache", key = "#loginUser.id.toString() + #loginUser.siteId + #channelId")
-    public List<BuildingSelectDto> select(LoginUser loginUser, Integer channelId) {
+    public List<BuildingSelectDto> select(LoginUser loginUser, Integer channelId, Integer customerId) {
         List<Integer> ids = newArrayList();
         List<Integer> communityIds = newArrayList();
         List<BuildingSelectDto> buildingSelectDtoArrayList = newArrayList();
         //查询数据权限的建筑ids
-        List<Integer> buildingIds = this.getIdsByDataPermission();
+        //List<Integer> buildingIds = this.getIdsByDataPermission();
         //查询用户数据项下的建筑列表
-        List<Building> buildingList = buildingMapper.findBySiteIdAndProgramItem(loginUser.getSiteId(), channelId, buildingIds, null,UserUtil.getCustomerIds());
+        List<Building> buildingList = buildingMapper.findBySiteIdAndProgramItem(loginUser.getSiteId(), channelId, null, null,customerId,UserUtil.getCustomerIds());
 
         if (buildingList != null && buildingList.size() > 0) {
             buildingList.forEach(building -> {
@@ -210,10 +210,10 @@ public class BuildingServiceImpl implements BuildingService {
     public List<BuildingSelectDto> buildingSearch(LoginUser loginUser, Integer channelId, String buildingName) {
         List<BuildingSelectDto> buildingSelectDtoArrayList = newArrayList();
         //查询数据权限的建筑ids
-        List<Integer> buildingIds = this.getIdsByDataPermission();
+        //List<Integer> buildingIds = this.getIdsByDataPermission();
         //查询用户数据项下的建筑列表
         PageHelper.startPage(1,10);
-        List<Building> buildingList = buildingMapper.findBySiteIdAndProgramItem(loginUser.getSiteId(), channelId, buildingIds, buildingName, UserUtil.getCustomerIds());
+        List<Building> buildingList = buildingMapper.findBySiteIdAndProgramItem(loginUser.getSiteId(), channelId, null, buildingName,null, UserUtil.getCustomerIds());
         if (buildingList != null && buildingList.size() > 0) {
             buildingList.forEach(building -> {
                 //设备关联上级父类,按小区、区、市、省关联,为空的往上一层关联

+ 3 - 3
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/CommunityServiceImpl.java

@@ -115,14 +115,14 @@ public class CommunityServiceImpl implements CommunityService{
     }
 
     @Override
-    public Pagination<CommunityDto> getCommunityPage(String communityName, Integer province, Integer city, Integer region, int pageNum, int pageSize) {
+    public Pagination<CommunityDto> getCommunityPage(String communityName, Integer province, Integer city, Integer region,Integer customerId, int pageNum, int pageSize) {
         LoginUser loginUser = UserUtil.getCurrentUser();
 
         if (loginUser.getSiteType() == 1) {
             List<ProgramItem> programItems = UserUtil.getCurrentSiteProgramItems(loginUser);
             if(programItems == null || programItems.size() == 0) {
                 PageHelper.startPage(pageNum, pageSize);
-                List<CommunityDto> list = communityMapper.getList(loginUser.getSiteId(), null, communityName, province, city, region);
+                List<CommunityDto> list = communityMapper.getList(loginUser.getSiteId(), customerId, communityName, province, city, region);
                 return new Pagination<>(list);
             }
             else {
@@ -134,7 +134,7 @@ public class CommunityServiceImpl implements CommunityService{
                 }
                 if(customerIds.size() == 0) {
                     PageHelper.startPage(pageNum, pageSize);
-                    List<CommunityDto> list = communityMapper.getList(loginUser.getSiteId(), null, communityName, province, city, region);
+                    List<CommunityDto> list = communityMapper.getList(loginUser.getSiteId(), customerId, communityName, province, city, region);
                     return new Pagination<>(list);
                 }
                 else {

+ 41 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/DeviceServiceImpl.java

@@ -37,6 +37,7 @@ import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletResponse;
 import java.io.*;
 import java.io.File;
@@ -280,6 +281,46 @@ public  class DeviceServiceImpl implements DeviceService {
 
 
 
+    }
+
+    @Override
+    public void getDeviceListTxt(String alias, Integer sysId, Integer buildingId, String deviceNo, Integer status, Integer floor, String locDesc, Integer province, Integer city, Integer region, Integer community, Integer concentratorId, String concentratorNo, Integer collectorId, String collectorNo,Integer channelNumberId, String errorType, Integer customerId, Integer days, Integer deviceTypeId, Integer valveStatus, Integer registerStatus, Integer issueStatus, Integer syncStatus, Double startReading, Double endReading, String sortColumn, String sortOrder, HttpServletResponse httpServletResponse) {
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        List<DeviceDto> list = deviceMapper.getList(sysId, buildingId, loginUser.getSiteId(), UserUtil.getCurrentSiteProgramItems(loginUser), deviceNo, status,
+                floor, locDesc, province, city, region, community, concentratorId, concentratorNo, collectorId, collectorNo, null, errorType, customerId,
+                days, deviceTypeId, valveStatus, registerStatus, issueStatus, syncStatus, startReading, endReading, sortColumn, sortOrder);
+        StringBuffer buff = new StringBuffer();
+        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        for (int i = 0; i < list.size(); i++) {
+            DeviceDto dto = list.get(i);
+            String fileNo = dto.getWaterMeterFileNo()!=null?dto.getWaterMeterFileNo():"";
+            String lastReceiveTime = dto.getLastReceiveTime()!=null?dto.getLastReceiveTime().format(df):"";
+            String meterReading = dto.getMeterReading()!=null?dto.getMeterReading():"";
+            String deviceStatus = dto.getDeviceStatus()==1?"1":"14";
+            buff.append(fileNo+"|"+lastReceiveTime+"|"+meterReading+"|"+deviceStatus);
+            buff.append("\r\n");
+        }
+
+        try {
+
+            DateTimeFormatter f = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
+            LocalDateTime date = LocalDateTime.now();
+            String fileName = "设备列表" + "-" + date.format(f) + ".txt";
+            fileName = URLEncoder.encode(fileName, "UTF-8");
+            httpServletResponse.setContentType("application/octet-stream");
+            httpServletResponse.setHeader("Content-disposition", "attachment;filename=" + fileName);
+
+            ServletOutputStream outputStream = httpServletResponse.getOutputStream();
+
+            //将文件写入浏览器
+            outputStream.write(buff.toString().getBytes());
+            outputStream.flush();
+            outputStream.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+
+
     }
 
     public void executeDeviceListExcel(RabbitDeviceParamData paramData){

+ 189 - 20
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/MeterReadRecordServiceImpl.java

@@ -3,9 +3,18 @@ package com.bz.smart_city.service.impl;
 import com.bz.smart_city.commom.constant.MeterReadEnum;
 import com.bz.smart_city.commom.exception.ServiceException;
 import com.bz.smart_city.commom.util.*;
+import com.bz.smart_city.dao.*;
 import com.bz.smart_city.dto.*;
 
+import com.bz.smart_city.entity.*;
+import com.bz.smart_city.rabbitmq.model.RabbitDeviceParamData;
+import com.bz.smart_city.rabbitmq.model.RabbitParamData;
+import com.bz.smart_city.rabbitmq.model.RabbitWaterConsumptionData;
+import com.bz.smart_city.service.MessageService;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.amqp.rabbit.connection.SimpleResourceHolder;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.jdbc.datasource.DataSourceUtils;
 import org.springframework.scheduling.annotation.Async;
@@ -15,6 +24,7 @@ import javax.servlet.http.HttpServletResponse;
 
 import java.math.BigDecimal;
 import java.time.LocalDate;
+import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
 import java.util.Date;
@@ -22,30 +32,12 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import com.bz.smart_city.entity.ClearingRecord;
-import com.bz.smart_city.entity.Customer;
-import com.bz.smart_city.entity.Device;
-import com.bz.smart_city.entity.DeviceDataDim;
-import com.bz.smart_city.entity.JobCard;
-import com.bz.smart_city.entity.MeterReadRate;
-import com.bz.smart_city.entity.MeterReadRecord;
-import com.bz.smart_city.entity.MeterRecordStat;
-import com.bz.smart_city.entity.Site;
-import com.bz.smart_city.entity.WMeterType;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.bz.smart_city.commom.model.CommonQueryCondition;
 import com.bz.smart_city.commom.model.ListObjectWrapper;
 import com.bz.smart_city.commom.model.Pagination;
 import com.bz.smart_city.commom.model.ResultStatus;
-import com.bz.smart_city.dao.BuildingMapper;
-import com.bz.smart_city.dao.DeviceDataDimMapper;
-import com.bz.smart_city.dao.DeviceMapper;
-import com.bz.smart_city.dao.MeterReadRateMapper;
-import com.bz.smart_city.dao.MeterReadRecordMapper;
-import com.bz.smart_city.dao.StatMeterReadRateByBuildingMapper;
-import com.bz.smart_city.dao.UserMapper;
-import com.bz.smart_city.dao.WMeterTypeMapper;
 import com.bz.smart_city.service.CustomerService;
 import com.bz.smart_city.service.MeterReadRecordService;
 import com.bz.smart_city.service.UserService;
@@ -97,8 +89,22 @@ public class MeterReadRecordServiceImpl implements MeterReadRecordService{
 	@Resource
 	private StatMeterReadRateByBuildingMapper statMeterReadRateByBuildingMapper;
 
+	@Value("${service.domain}")
+	private String domain;
+
+	@Resource
+	private TaskMapper taskMapper;
+	@Autowired
+	private MessageService messageService;
+
 	@Resource
 	CustomerService customerService;
+	@Value("${spring.rabbitmq.exchange}")
+	private String exchange;
+	@Value("${spring.rabbitmq.general-task-queue}")
+	private String queue;
+	@Autowired
+	private RabbitTemplate rabbitTemplate;
 
 	@Override
 	public Pagination<MeterReadRecord> queryMeterReadRecord(MeterReadRecord param, int pageNum, int pageSize) {
@@ -696,8 +702,15 @@ public class MeterReadRecordServiceImpl implements MeterReadRecordService{
 	@Override
 	public Pagination<WaterConsumptionDto> getWaterConsumptionList(CommonQueryCondition condition, Integer pageNum, Integer pageSize) {
 		log.info("begin MeterReadRecordService getWaterConsumptionList, params = " + JSON.toJSONString(condition) + ", pageNum = " + pageNum + ", pageSize = " + pageSize);
-		PageHelper.startPage(pageNum, pageSize);
-		List<WaterConsumptionDto> result = meterReadRecordMapper.getList(condition);
+		List<WaterConsumptionDto> result = null;
+		if(condition.getEndDate()-condition.getStartDate() > 0){
+			PageHelper.startPage(pageNum, pageSize);
+			result = meterReadRecordMapper.getList(condition);
+		}else {
+			PageHelper.startPage(pageNum, pageSize);
+			result = meterReadRecordMapper.getListDay(condition);
+		}
+
 		log.info("end MeterReadRecordService getWaterConsumptionList, result.size = "+result.size());
 		return new Pagination<>(result);
 	}
@@ -1079,4 +1092,160 @@ public class MeterReadRecordServiceImpl implements MeterReadRecordService{
 		}
 		return readRecord ;
 	}
+
+	@Override
+	public void getConsumptionExcel(CommonQueryCondition condition, HttpServletResponse httpServletResponse) {
+		LoginUser loginUser = UserUtil.getCurrentUser();
+		String title = "用水量统计";
+
+		RabbitWaterConsumptionData data = new RabbitWaterConsumptionData();
+		data.setUserId(loginUser.getId());
+		data.setSiteId(loginUser.getSiteId());
+		data.setCustomerId(condition.getCustormerId());
+		data.setProvinces(condition.getProvinces());
+		data.setCities(condition.getCities());
+		data.setRegions(condition.getRegions());
+		data.setCommunities(condition.getCommunities());
+		data.setBuildingIds(condition.getBuildingIds());
+		data.setStartDate(condition.getStartDate());
+		data.setEndDate(condition.getEndDate());
+		data.setMinConsumption(condition.getBeginRate());
+		data.setMaxConsumption(condition.getEndRate());
+		data.setSortOrder(condition.getSortOrder());
+		data.setCustomerIds(condition.getCustomerIds());
+		data.setTitle(title);
+
+
+
+
+
+
+		DateTimeFormatter f = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
+		LocalDateTime date = LocalDateTime.now();
+		String fileName = title + "-" + date.format(f) + ".xls";
+
+		Task task = new Task();
+		task.setName(fileName);
+		task.setType(1);
+		task.setStatus(1);
+		task.setCreateDate(LocalDateTime.now());
+		task.setUpdateDate(LocalDateTime.now());
+		taskMapper.insertSelective(task);
+		data.setTaskId(task.getId());
+
+		RabbitParamData<RabbitWaterConsumptionData> rabbitParamData = new RabbitParamData<>();
+		rabbitParamData.setService("waterConsumptionExcel");
+		rabbitParamData.setData(data);
+
+
+		String message = JSON.toJSONString(rabbitParamData);
+
+		//设置当前线程lookupKey,内部由ThreadLocal实现
+		SimpleResourceHolder.bind(rabbitTemplate.getConnectionFactory(), "platform");
+		//业务操作会根据线程中的lookupKey从routeConnectionFactory的targetConnectionFactories中选择对应的connectionFactory
+		rabbitTemplate.convertAndSend(exchange,queue, message);
+		//操作完以后记得解绑。不影响线程的后序其他工厂操作
+		SimpleResourceHolder.unbind(rabbitTemplate.getConnectionFactory());
+	}
+
+	@Override
+	public void executeWaterConsumptionExcel(RabbitWaterConsumptionData data) {
+
+		CommonQueryCondition condition = setConditionForQuery(data);
+		List<WaterConsumptionDto> list = null;
+		if(condition.getEndDate()-condition.getStartDate() > 0){
+			list = meterReadRecordMapper.getList(condition);
+		}else {
+			list = meterReadRecordMapper.getListDay(condition);
+		}
+
+
+		String title = "用水量统计";
+		String[] rowsName = new String[]{"序号", "水表电子号", "水表档案号", "设备型号", "客户", "小区", "建筑", "安装地址","用水量"};
+		List<Object[]> dataList = newArrayList();
+		Object[] objs = null;
+		for (int i = 0; i < list.size(); i++) {
+			WaterConsumptionDto dto = list.get(i);
+			objs = new Object[rowsName.length];
+			objs[0] = i;
+			objs[1] = dto.getMeterNo();
+			objs[2] = dto.getFileNo();
+			objs[3] = dto.getManufacturerName()+"/"+dto.getEquipmentType()+"/"+dto.getModel();
+			objs[4] = dto.getCustomer();
+			objs[5] = dto.getCommunity();
+			objs[6] = dto.getBuilding();
+			objs[7] = dto.getLocation();
+			objs[8] = dto.getWaterConsumption();
+			dataList.add(objs);
+		}
+		ExcelUtil excelUtil = new ExcelUtil(title, rowsName, dataList);
+		String filePath = getFilePath();
+		try {
+			excelUtil.download(filePath);
+		} catch (Exception e) {
+			throw new ServiceException(-900, "导出异常");
+		}
+
+		Task taskTemp = taskMapper.findById(data.getTaskId());
+		try {
+
+
+			//生成下载文件
+			Task task = new Task();
+			task.setId(data.getTaskId());
+			task.setPath(filePath);
+			task.setUpdateDate(LocalDateTime.now());
+			taskMapper.updateByPrimaryKeySelective(task);
+
+			//生成消息
+			Message message = new Message();
+			message.setSiteId(data.getSiteId());
+			message.setUserId(data.getUserId());
+			message.setMessageType(2);
+			message.setMessageTitle(data.getTitle()+"-导出");
+			message.setMessageContent(taskTemp.getName()+"导出完成");
+			message.setMessageUrl(domain+"/api/file/task/download?objId="+data.getTaskId());
+			message.setObjId(data.getTaskId());
+			message.setRead(0);
+			messageService.insertSelective(message);
+		}catch (Exception e){
+			log.info("Exception {},{}",e.getMessage(),e);
+			Message message = new Message();
+			message.setSiteId(data.getSiteId());
+			message.setUserId(data.getUserId());
+			message.setMessageType(2);
+			message.setMessageTitle(data.getTitle()+"-导出");
+			message.setMessageContent(taskTemp.getName()+"导出失败");
+			message.setObjId(data.getTaskId());
+			message.setRead(0);
+			messageService.insertSelective(message);
+		}
+	}
+
+	private CommonQueryCondition setConditionForQuery(RabbitWaterConsumptionData data) {
+		CommonQueryCondition condition = new CommonQueryCondition();
+		condition.setSiteId(data.getSiteId());
+		condition.setCustormerId(data.getCustomerId());
+		condition.setProvinces(data.getProvinces());
+		condition.setCities(data.getCities());
+		condition.setRegions(data.getRegions());
+		condition.setCommunities(data.getCommunities());
+		condition.setBuildingIds(data.getBuildingIds());
+		condition.setStartDate(data.getStartDate());
+		condition.setEndDate(data.getEndDate());
+		condition.setBeginRate(data.getMinConsumption());
+		condition.setEndRate(data.getMaxConsumption());
+		condition.setCustomerIds(data.getCustomerIds());
+		condition.setSortOrder(data.getSortOrder());
+		return condition;
+	}
+
+	@Value("${files.path}")
+	private String filesPath;
+
+	protected String getFilePath() {
+		String name = Util.createUUIDId();
+		String fullPath = filesPath + "/file/" + name + ".xls";
+		return fullPath;
+	}
 }

+ 1 - 0
smart-city-platform/src/main/resources/application-dev.properties

@@ -192,6 +192,7 @@ spring.rabbitmq.exchange=task-handler-exchange
 spring.rabbitmq.download-device-queue=download-device-queue
 spring.rabbitmq.download-install-queue=download-install-queue
 spring.rabbitmq.command-task-queue=command-task-queue
+spring.rabbitmq.general-task-queue=general-task-queue
 
 #sentry.dsn=http://2384bbf9e2134af9b765dc8c10a2c08a@192.168.174.133:8080/1
 #sentry.exception-resolver-order=2147483647

+ 2 - 1
smart-city-platform/src/main/resources/application-prd.properties

@@ -194,4 +194,5 @@ platform_url=http://114.135.61.187:38087/user-auth/user/getUniqId?appId={appId}&
 spring.rabbitmq.exchange=task-handler-exchange
 spring.rabbitmq.download-device-queue=download-device-queue
 spring.rabbitmq.download-install-queue=download-install-queue
-spring.rabbitmq.command-task-queue=command-task-queue
+spring.rabbitmq.command-task-queue=command-task-queue
+spring.rabbitmq.general-task-queue=general-task-queue

+ 2 - 1
smart-city-platform/src/main/resources/application-sit.properties

@@ -191,4 +191,5 @@ platform_url=http://114.135.61.187:38081/user-auth/user/getUniqId?appId={appId}&
 spring.rabbitmq.exchange=task-handler-exchange
 spring.rabbitmq.download-device-queue=download-device-queue
 spring.rabbitmq.download-install-queue=download-install-queue
-spring.rabbitmq.command-task-queue=command-task-queue
+spring.rabbitmq.command-task-queue=command-task-queue
+spring.rabbitmq.general-task-queue=general-task-queue

+ 2 - 1
smart-city-platform/src/main/resources/mapper/BuildingMapper.xml

@@ -582,6 +582,7 @@
         left join sc_community sc on(sc.id = sb.community)
         where sb.status = 1
         <if test="siteId != null"> and sb.site_id=#{siteId} </if>
+        <if test="customerId != null"> and sc.customer_id=#{customerId} </if>
         <if test="buildingIds != null and buildingIds.size() != 0"> and sb.id in <foreach collection="buildingIds" item="item" open="(" separator="," close=")">#{item}</foreach> </if>
         <if test="sysId != null"> and sb.id in (select sd.building_id from sc_device sd where sd.status = 1 and sd.sys_id = #{sysId}  <if test="siteId != null"> and sd.site_id=#{siteId} </if> group by sd.building_id) </if>
         <if test="buildingName != null and buildingName != ''"> AND sb.name LIKE concat('%',#{buildingName},'%')</if>
@@ -833,7 +834,7 @@
         <if test="customerIds != null and customerIds.size() != 0">
             and sc.customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
         </if>
-        order by sb.create_date desc
+        order by sb.create_date desc,sb.id desc
     </select>
 
     <select id="queryFloor" resultType="com.bz.smart_city.dto.FloorDto">

+ 8 - 4
smart-city-platform/src/main/resources/mapper/CommunityMapper.xml

@@ -340,13 +340,15 @@
         select <include refid="General_Column_List"></include>,
         sa1.name as province_name,
         sa2.name as city_name,
-        sa3.name as region_name
+        sa3.name as region_name,
+        scu.customer_name
         from sc_community sc
         left join sc_area sa1 on sa1.id = sc.province
         left join sc_area sa2 on sa2.id = sc.city
         left join sc_area sa3 on sa3.id = sc.region
+        left join sc_customer scu on scu.id = sc.customer_id
         where sc.status = 1
-        <if test="siteId != null"> and site_id = #{siteId} </if>
+        <if test="siteId != null"> and sc.site_id = #{siteId} </if>
         <if test="customerId != null"> and customer_id = #{customerId} </if>
         <if test="communityName != null and communityName != ''"> and sc.name like concat('%',#{communityName} ,'%')</if>
         <if test="province != null"> and sc.province = #{province}</if>
@@ -399,13 +401,15 @@
         select <include refid="General_Column_List"></include>,
         sa1.name as province_name,
         sa2.name as city_name,
-        sa3.name as region_name
+        sa3.name as region_name,
+        scu.customer_name
         from sc_community sc
         left join sc_area sa1 on sa1.id = sc.province
         left join sc_area sa2 on sa2.id = sc.city
         left join sc_area sa3 on sa3.id = sc.region
+        left join sc_customer scu on scu.id = sc.customer_id
         where sc.status = 1
-        <if test="siteId != null"> and site_id = #{siteId} </if>
+        <if test="siteId != null"> and sc.site_id = #{siteId} </if>
         <if test="customerIds != null">
             and customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
         </if>

+ 57 - 17
smart-city-platform/src/main/resources/mapper/MeterReadRecordMapper.xml

@@ -837,7 +837,7 @@
 			<if test = "param.channelNumberId != null"> and wrd.channel_number_id = #{param.channelNumberId}</if>
 			<if test = "param.collectorCode != null and param.collectorCode != '' "> and col.collector_no like #{param.collectorCode}</if>
 			<if test = "param.deviceNo != null and param.deviceNo != '' "> 
-				and m.meter_no like #{param.deviceElectricNo}
+				and (m.meter_no like #{param.deviceElectricNo} or m.meter_file_no like #{param.deviceElectricNo})
 			</if>
 			<if test = "param.custormerId !=null and param.custormerId != 0"> and m.customer_id = #{param.custormerId}</if>
 			<if test = "param.communityId != null and param.communityId != 0"> and m.community = #{param.communityId}</if>
@@ -880,7 +880,7 @@
         <if test = "param.channelNumberId != null"> and wrd.channel_number_id = #{param.channelNumberId}</if>
         <if test = "param.collectorCode != null and param.collectorCode != '' "> and col.collector_no like #{param.collectorCode}</if>
         <if test = "param.deviceNo != null and param.deviceNo != '' ">
-            and  m.meter_no like #{param.deviceElectricNo}
+            and  (m.meter_no like #{param.deviceElectricNo} or m.meter_file_no like #{param.deviceElectricNo})
         </if>
         <if test = "param.custormerId !=null and param.custormerId != 0"> and m.customer_id = #{param.custormerId}</if>
         <if test = "param.communityId != null and param.communityId != 0"> and m.community = #{param.communityId}</if>
@@ -1625,7 +1625,10 @@
     <select id="getList" resultType="com.bz.smart_city.dto.WaterConsumptionDto">
         select
             list.meter_no as meter_no,
-            list.device_type as device_type,
+            list.file_no as file_no,
+            list.equipment_type,
+            list.model,
+            list.manufacturer_name,
             list.customer as customer,
             list.district as district,
             list.community as community,
@@ -1635,7 +1638,8 @@
         from (
                 select
                 smrr.meter_no as meter_no,
-                sdt.equipment_type as device_type,
+                smrr.meter_file_no as file_no,
+                sdt.equipment_type,sdt.model,sdm.name as manufacturer_name,
                 scu.customer_name as customer,
                 replace(replace(sa.manger_name, "中国", ""), ",", "") as district,
                 sco.name as community,
@@ -1645,19 +1649,14 @@
                 from
                 sc_meter_read_record smrr
                 left join sc_device_type sdt on (smrr.device_type_id = sdt.id and sdt.status = 1)
+                left join sc_device_manufacturer sdm on (sdm.id = sdt.manufacturer_id and sdm.status = 1)
                 left join sc_customer scu on (smrr.customer_id = scu.id and scu.status = 1)
                 left join sc_building sb on (smrr.building_id = sb.id and sb.status = 1)
                 left join sc_area sa on (sa.id = sb.region)
                 left join sc_community sco on (sb.community = sco.id and sco.id)
-                <if test="param.programItems != null and param.programItems.size() != 0"> left join sc_device_dimension sdd on (sdd.device_id = smrr.device_id and sdd.status = 1) </if>
                 where
                 smrr.status = 1
                 <if test="param.siteId != null"> and smrr.site_id = #{param.siteId} </if>
-                <if test="param.programItems != null and param.programItems.size() != 0"> and
-                    <foreach collection="param.programItems" item="item" open="(" separator=" or " close=")">
-                        sdd.${item.dimensionCode} = #{item.dimensionValue}
-                    </foreach>
-                </if>
                 <if test="param.custormerId != null"> and smrr.customer_id = #{param.custormerId} </if>
                 <if test="param.provinces != null and param.provinces.size() != 0">
                     and sb.province in <foreach collection="param.provinces" item="item" open="(" separator="," close=")"> #{item} </foreach>
@@ -1678,7 +1677,7 @@
                 <if test="param.endDate != null"> and smrr.read_date <![CDATA[ <= ]]> #{param.endDate} </if>
                 <if test="param.customerIds != null and param.customerIds.size() != 0"> and smrr.customer_id in <foreach collection="param.customerIds" item="item" open="(" separator="," close=")">#{item}</foreach> </if>
                 group by
-                smrr.meter_no, sdt.equipment_type, scu.customer_name, district, sco.name, sb.name, smrr.location
+                smrr.device_id,smrr.meter_no,smrr.meter_file_no,sdt.equipment_type,sdt.model,sdm.name, scu.customer_name, district, sco.name, sb.name, smrr.location
             ) list
         where 1 = 1
         <if test="param.beginRate != null"> and list.water_consumption <![CDATA[ >= ]]> #{param.beginRate} </if>
@@ -1708,13 +1707,7 @@
                 smrr.device_id, smrr.building_id
             ) result
         left join sc_building sb on (result.building_id = sb.id and sb.status = 1)
-        <if test="param.programItems != null and param.programItems.size() != 0"> left join sc_device_dimension sdd on (sdd.device_id = result.device_id and sdd.status = 1) </if>
         where 1 = 1
-        <if test="param.programItems != null and param.programItems.size() != 0"> and
-            <foreach collection="param.programItems" item="item" open="(" separator=" or " close=")">
-                sdd.${item.dimensionCode} = #{item.dimensionValue}
-            </foreach>
-        </if>
         <if test="param.provinces != null and param.provinces.size() != 0">
             and sb.province in <foreach collection="param.provinces" item="item" open="(" separator="," close=")"> #{item} </foreach>
         </if>
@@ -1731,6 +1724,53 @@
         <if test="param.endRate != null"> and result.water_consumption <![CDATA[ <= ]]> #{param.endRate} </if>
     </select>
 
+    <select id="getListDay" resultType="com.bz.smart_city.dto.WaterConsumptionDto">
+        select
+        smrr.meter_no as meter_no,
+        smrr.meter_file_no as file_no,
+        sdt.equipment_type,sdt.model,sdm.name as manufacturer_name,
+        scu.customer_name as customer,
+        replace(replace(sa.manger_name, "中国", ""), ",", "") as district,
+        sco.name as community,
+        sb.name as building,
+        smrr.location as location,
+        smrr.last_cost as water_consumption
+        from
+        sc_meter_read_record smrr
+        left join sc_device_type sdt on (smrr.device_type_id = sdt.id and sdt.status = 1)
+        left join sc_device_manufacturer sdm on (sdm.id = sdt.manufacturer_id and sdm.status = 1)
+        left join sc_customer scu on (smrr.customer_id = scu.id and scu.status = 1)
+        left join sc_building sb on (smrr.building_id = sb.id and sb.status = 1)
+        left join sc_area sa on (sa.id = sb.region)
+        left join sc_community sco on (sb.community = sco.id and sco.id)
+        where
+        smrr.status = 1
+        <if test="param.siteId != null"> and smrr.site_id = #{param.siteId} </if>
+        <if test="param.custormerId != null"> and smrr.customer_id = #{param.custormerId} </if>
+        <if test="param.provinces != null and param.provinces.size() != 0">
+            and sb.province in <foreach collection="param.provinces" item="item" open="(" separator="," close=")"> #{item} </foreach>
+        </if>
+        <if test="param.cities != null and param.cities.size() != 0">
+            and sb.city in <foreach collection="param.cities" item="item" open="(" separator="," close=")"> #{item} </foreach>
+        </if>
+        <if test="param.regions != null and param.regions.size() != 0">
+            and sb.region in <foreach collection="param.regions" item="item" open="(" separator="," close=")"> #{item} </foreach>
+        </if>
+        <if test="param.communities != null and param.communities.size() != 0">
+            and sb.community in <foreach collection="param.communities" item="item" open="(" separator="," close=")"> #{item} </foreach>
+        </if>
+        <if test="param.buildingIds != null and param.buildingIds.size() != 0">
+            and smrr.building_id in <foreach collection="param.buildingIds" item="item" open="(" separator="," close=")"> #{item}</foreach>
+        </if>
+        <if test="param.startDate != null"> and smrr.read_date =  #{param.startDate} </if>
+        <if test="param.customerIds != null and param.customerIds.size() != 0"> and smrr.customer_id in <foreach collection="param.customerIds" item="item" open="(" separator="," close=")">#{item}</foreach> </if>
+
+        <if test="param.beginRate != null"> and smrr.last_cost <![CDATA[ >= ]]> #{param.beginRate} </if>
+        <if test="param.endRate != null"> and smrr.last_cost <![CDATA[ <= ]]> #{param.endRate} </if>
+        <if test="param.sortOrder != null"> order by smrr.last_cost ${param.sortOrder} </if>
+    </select>
+
+
     <select id="getLastDayData" resultMap="BaseResultMap">
         select
         <include refid="Base_Column_List" />