浏览代码

客户抄表率

lin 4 年之前
父节点
当前提交
a80abde568
共有 22 个文件被更改,包括 256 次插入80 次删除
  1. 8 4
      smart-city-platform/src/main/java/com/bz/smart_city/controller/DeviceController.java
  2. 24 9
      smart-city-platform/src/main/java/com/bz/smart_city/controller/water/WaterReadController.java
  3. 1 1
      smart-city-platform/src/main/java/com/bz/smart_city/dao/BuildingMapper.java
  4. 3 1
      smart-city-platform/src/main/java/com/bz/smart_city/dao/CustomerMapper.java
  5. 1 1
      smart-city-platform/src/main/java/com/bz/smart_city/dao/DeviceMapper.java
  6. 28 5
      smart-city-platform/src/main/java/com/bz/smart_city/dao/StatMeterReadRateByBuildingMapper.java
  7. 14 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/CustomerRateDto.java
  8. 3 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/WaterReadRateListDto.java
  9. 1 1
      smart-city-platform/src/main/java/com/bz/smart_city/service/BuildingService.java
  10. 4 3
      smart-city-platform/src/main/java/com/bz/smart_city/service/CustomerService.java
  11. 2 2
      smart-city-platform/src/main/java/com/bz/smart_city/service/DeviceService.java
  12. 5 3
      smart-city-platform/src/main/java/com/bz/smart_city/service/StatMeterReadRateByBuildingService.java
  13. 2 2
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/BuildingServiceImpl.java
  14. 6 6
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/CustomerServiceImpl.java
  15. 9 4
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/DeviceServiceImpl.java
  16. 63 26
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/StatMeterReadRateByBuildingServiceImpl.java
  17. 二进制
      smart-city-platform/src/main/resources/excel/installPlanTemplate20200709.xlsx
  18. 4 3
      smart-city-platform/src/main/resources/mapper/BuildingMapper.xml
  19. 8 0
      smart-city-platform/src/main/resources/mapper/CustomerMapper.xml
  20. 11 6
      smart-city-platform/src/main/resources/mapper/DeviceMapper.xml
  21. 56 0
      smart-city-platform/src/main/resources/mapper/StatMeterReadRateByBuildingMapper.xml
  22. 3 3
      smart-city-platform/src/test/java/com/bz/smart_city/ForCreateDataTest.java

+ 8 - 4
smart-city-platform/src/main/java/com/bz/smart_city/controller/DeviceController.java

@@ -60,6 +60,7 @@ public class DeviceController {
             @ApiParam(value = "连续故障结束天数", required = false) @RequestParam(required = false) Integer endDays,
             @ApiParam(value = "设备类型ID", required = false) @RequestParam(required = false) Integer deviceTypeId,
             @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 = "排序参数,对应列表字段", required = false) @RequestParam(required = false,defaultValue = "sd.date_create") String sortColumn,
             @ApiParam(value = "排序方式,顺序:ASC  倒序:DESC", required = false) @RequestParam(required = false, defaultValue = "DESC") String sortOrder,
             @ApiParam(value = "页数,非必传,默认第一页", required = false, defaultValue = "1") @RequestParam(required = false, defaultValue = "1") int pageNum,
@@ -67,7 +68,7 @@ public class DeviceController {
     ) {
         Pagination<DeviceDto> pageInfo = deviceService.getList(sysId, buildingId, StringUtils.trim(deviceNo), status, manufacturerId, StringUtils.trim(equipmentType), StringUtils.trim(model), isTag,
                 floor, StringUtils.trim(locDesc), province, city, region, community, concentratorNo, collectorNo, errorType, customerId, days, startDays,endDays,
-                deviceTypeId,valveStatus,sortColumn, sortOrder, pageNum, pageSize);
+                deviceTypeId,valveStatus,registerStatus,sortColumn, sortOrder, pageNum, pageSize);
         return new AjaxMessage<>(ResultStatus.OK, pageInfo);
     }
 
@@ -111,13 +112,14 @@ public class DeviceController {
             @ApiParam(value = "连续故障结束天数", required = false) @RequestParam(required = false) Integer endDays,
             @ApiParam(value = "设备类型ID", required = false) @RequestParam(required = false) Integer deviceTypeId,
             @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 = "排序参数,对应列表字段", 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.getDeviceListExcel(sysId, buildingId, StringUtils.trim(deviceNo), status, manufacturerId, StringUtils.trim(equipmentType), StringUtils.trim(model), isTag,
                 floor, StringUtils.trim(locDesc), province, city, region, community, concentratorNo, collectorNo, errorType, customerId, days, startDays, endDays,
-                deviceTypeId,valveStatus,sortColumn, sortOrder, httpServletResponse);
+                deviceTypeId,valveStatus,registerStatus,sortColumn, sortOrder, httpServletResponse);
 
     }
 
@@ -138,6 +140,7 @@ public class DeviceController {
             @ApiParam(value = "连续故障天数", required = false) @RequestParam(required = false) Integer days,
             @ApiParam(value = "设备类型ID", required = false) @RequestParam(required = false) Integer deviceTypeId,
             @ApiParam(value = "阀门状态 0:关阀 1:开阀  2:无阀", required = false) @RequestParam(required = false) Integer valveStatus,
+            @ApiParam(value = "注册状态 0:未注册 1:已注册", required = false) @RequestParam(required = false) Integer registerStatus,
             HttpServletResponse httpServletResponse
     ){
         deviceService.exportDeviceListAsXML(sysId,
@@ -181,10 +184,11 @@ public class DeviceController {
             @ApiParam(value = "连续故障开始天数", required = false) @RequestParam(required = false) Integer startDays,
             @ApiParam(value = "连续故障结束天数", required = false) @RequestParam(required = false) Integer endDays,
             @ApiParam(value = "设备类型ID", required = false) @RequestParam(required = false) Integer deviceTypeId,
-            @ApiParam(value = "阀门状态 0:关阀 1:开阀  2:无阀", required = false) @RequestParam(required = false) Integer valveStatus
+            @ApiParam(value = "阀门状态 0:关阀 1:开阀  2:无阀", required = false) @RequestParam(required = false) Integer valveStatus,
+            @ApiParam(value = "注册状态 0:未注册 1:已注册", required = false) @RequestParam(required = false) Integer registerStatus
     ) {
         List<BuildingSelectDto> list = buildingService.deviceAreaList(sysId, buildingId, deviceNo, status, manufacturerId, equipmentType, model, isTag,
-                floor, locDesc, province, city, region, community, concentratorNo, collectorNo, errorType, customerId, days, startDays,endDays,deviceTypeId,valveStatus);
+                floor, locDesc, province, city, region, community, concentratorNo, collectorNo, errorType, customerId, days, startDays,endDays,deviceTypeId,valveStatus,registerStatus);
         return new AjaxMessage<>(ResultStatus.OK, list);
     }
 

+ 24 - 9
smart-city-platform/src/main/java/com/bz/smart_city/controller/water/WaterReadController.java

@@ -118,9 +118,11 @@ public class WaterReadController {
     @GetMapping("/getCountByCustomer")
     @ApiOperation(value = "根据客户获取抄表率统计数据")
     public AjaxMessage<WaterReadRateCountDto> getCountByCustomer(
-            @ApiParam(value = "查询范围,2:昨天,7:近7日,15:近15日", required = false) @RequestParam(required = false) Integer period
+            @ApiParam(value = "查询范围,2:昨天,7:近7日,15:近15日,99:上月", required = false) @RequestParam(required = false) Integer period,
+            @ApiParam(value = "场景id", required = false) @RequestParam(required = false) Integer channelId,
+            @ApiParam(value = "客户id", required = false) @RequestParam(required = false) Integer customerId
     ) {
-        return new AjaxMessage<>(ResultStatus.OK, statMeterReadRateByBuildingService.getCountByCustomer(period));
+        return new AjaxMessage<>(ResultStatus.OK, statMeterReadRateByBuildingService.getCountByCustomer(period,channelId,customerId));
     }
 
 
@@ -130,24 +132,37 @@ public class WaterReadController {
     @ResponseBody
     @GetMapping("getListByCustomer")
     @ApiOperation(value = "根据客户获取抄表率列表数据")
-    public AjaxMessage<Pagination<WaterReadRateListDto>> getListByCustomer(
-            @ApiParam(value = "查询范围,2:昨天,7:近7日,15:近15日", required = false) @RequestParam(required = false) Integer period,
-            @ApiParam(value = "排序参数,对应列表字段", required = false) @RequestParam(required = false) String sortColumn,
-            @ApiParam(value = "排序方式,顺序:ASC  倒序:DESC", required = false) @RequestParam(required = false) String sortOrder,
+    public AjaxMessage<Pagination<CustomerRateDto>> getListByCustomer(
+            @ApiParam(value = "查询范围,2:昨天,7:近7日,15:近15日,99:上月", required = false) @RequestParam(required = false) Integer period,
+            @ApiParam(value = "场景id", required = false) @RequestParam(required = false) Integer channelId,
+            @ApiParam(value = "客户id", required = false) @RequestParam(required = false) Integer customerId,
             @ApiParam(value = "页数,默认第一页", required = true, defaultValue = "1") @RequestParam(required = true, defaultValue = "1") int pageNum,
             @ApiParam(value = "条数,默认15条", required = true, defaultValue = "15") @RequestParam(required = true, defaultValue = "15") int pageSize
     ) {
-        return new AjaxMessage<>(ResultStatus.OK, statMeterReadRateByBuildingService.getListByCustomer(period, sortColumn, sortOrder, pageNum, pageSize));
+        return new AjaxMessage<>(ResultStatus.OK, statMeterReadRateByBuildingService.getListByCustomer(period, channelId, customerId, null, null, pageNum, pageSize));
+    }
+
+    @ResponseBody
+    @GetMapping("getSubListByCustomer")
+    @ApiOperation(value = "根据客户获取子类抄表率列表数据")
+    public AjaxMessage<List<CustomerRateDto>> getSubListByCustomer(
+            @ApiParam(value = "查询范围,2:昨天,7:近7日,15:近15日,99:上月", required = false) @RequestParam(required = false) Integer period,
+            @ApiParam(value = "场景id", required = false) @RequestParam(required = false) Integer channelId,
+            @ApiParam(value = "客户id", required = false) @RequestParam(required = false) Integer customerId
+    ) {
+        return new AjaxMessage<>(ResultStatus.OK, statMeterReadRateByBuildingService.getSubListByCustomer(period, channelId, customerId));
     }
 
     @GetMapping("getExcelByCustomer")
     @ApiOperation(value = "根据客户获取抄表率Excel")
     public void getExcelByCustomer(
-            @ApiParam(value = "查询范围,2:昨天,7:近7日,15:近15日", required = false) @RequestParam(required = false) Integer period,
+            @ApiParam(value = "查询范围,2:昨天,7:近7日,15:近15日,99:上月", required = false) @RequestParam(required = false) Integer period,
+            @ApiParam(value = "场景id", required = false) @RequestParam(required = false) Integer channelId,
+            @ApiParam(value = "客户id", required = false) @RequestParam(required = false) Integer customerId,
             @ApiParam(value = "token", required = true) @RequestParam(required = true) String token,
             HttpServletResponse httpServletResponse
     ) {
-        statMeterReadRateByBuildingService.getRateExcelByCustomer(period, httpServletResponse);
+        statMeterReadRateByBuildingService.getRateExcelByCustomer(period,channelId,customerId, httpServletResponse);
     }
    
     /*

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

@@ -67,7 +67,7 @@ public interface BuildingMapper {
 
     List<Building> findByIds(@Param("ids") List<Integer> ids);
 
-    List<BuildingSelectInfoDto> deviceCountAreaList(@Param("siteId") Integer siteId, @Param("programItems") List<ProgramItem> programItems, @Param("sysId") Integer sysId, @Param("buildingId") Integer buildingId, @Param("deviceNo") String deviceNo, @Param("status") Integer status, @Param("manufacturerId") Integer manufacturerId, @Param("equipmentType") String equipmentType, @Param("model") String model, @Param("isTag") Integer isTag, @Param("floor") Integer floor, @Param("locDesc") String locDesc, @Param("province") Integer province, @Param("city") Integer city, @Param("region") Integer region, @Param("community") Integer community, @Param("concentratorNo") String concentratorNo, @Param("collectorNo") String collectorNo, @Param("errorType") String errorType, @Param("customerId") Integer customerId, @Param("days") Integer days, @Param("startDays") Integer startDays, @Param("endDays") Integer endDays, @Param("deviceTypeId") Integer deviceTypeId, @Param("valveStatus") Integer valveStatus);
+    List<BuildingSelectInfoDto> deviceCountAreaList(@Param("siteId") Integer siteId, @Param("programItems") List<ProgramItem> programItems, @Param("sysId") Integer sysId, @Param("buildingId") Integer buildingId, @Param("deviceNo") String deviceNo, @Param("status") Integer status, @Param("manufacturerId") Integer manufacturerId, @Param("equipmentType") String equipmentType, @Param("model") String model, @Param("isTag") Integer isTag, @Param("floor") Integer floor, @Param("locDesc") String locDesc, @Param("province") Integer province, @Param("city") Integer city, @Param("region") Integer region, @Param("community") Integer community, @Param("concentratorNo") String concentratorNo, @Param("collectorNo") String collectorNo, @Param("errorType") String errorType, @Param("customerId") Integer customerId, @Param("days") Integer days, @Param("startDays") Integer startDays, @Param("endDays") Integer endDays, @Param("deviceTypeId") Integer deviceTypeId, @Param("valveStatus") Integer valveStatus, @Param("registerStatus") Integer registerStatus);
 
     List<BuildingSelectInfoDto> abnormalAreaBuildingList(@Param("siteId") Integer siteId, @Param("programItems") List<ProgramItem> programItems, @Param("sysId") Integer sysId, @Param("buildingId") Integer buildingId, @Param("floor") Integer floor, @Param("measuringId") Integer measuringId, @Param("deviceId") Long deviceId, @Param("deviceNo") String deviceNo, @Param("location") String location, @Param("alarmCategory") Integer alarmCategory, @Param("handleStatus") Integer handleStatus, @Param("alarmTypeId") Integer alarmTypeId, @Param("equipmentId") Integer equipmentId, @Param("manufacturerId") Integer manufacturerId, @Param("customerId") Integer customerId, @Param("province") Integer province, @Param("city") Integer city, @Param("region") Integer region, @Param("communityId") Integer communityId, @Param("startDate") LocalDateTime startDate, @Param("endDate") LocalDateTime endDate);
 

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

@@ -20,7 +20,7 @@ public interface CustomerMapper {
 
     List<Customer> getList(@Param("siteId") Integer siteId);
 
-    List<Customer> getCustomerListByItem(@Param("siteId") Integer siteId, @Param("buildingIds") List<Integer> buildingIds);
+    List<Customer> getCustomerListByItem(@Param("siteId") Integer siteId, @Param("buildingIds") List<Integer> buildingIds, @Param("customerId") Integer customerId);
 
     Customer findCustWithCode(@Param("code") String code);
 
@@ -47,4 +47,6 @@ public interface CustomerMapper {
     List<CustomerDto> getCustomerTree(@Param("siteId") Integer siteId, @Param("customerName") String customerName);
 
     Integer countChildrenNum(@Param("customerId") Integer customerId);
+
+    List<Integer> findSubIds(@Param("customerId") Integer customerId);
 }

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

@@ -31,7 +31,7 @@ public interface DeviceMapper {
                             @Param("model") String model, @Param("isTag") Integer isTag, @Param("floor") Integer floor, @Param("locDesc") String locDesc, @Param("province") Integer province,
                             @Param("city") Integer city, @Param("region") Integer region, @Param("community") Integer community, @Param("concentratorNo") String concentratorNo,
                             @Param("collectorNo") String collectorNo, @Param("errorType") String errorType, @Param("customerId") Integer customerId, @Param("days") Integer days,
-                            @Param("startDays") Integer startDays, @Param("endDays") Integer endDays, @Param("deviceTypeId") Integer deviceTypeId, @Param("valveStatus") Integer valveStatus, @Param("sortColumn") String sortColumn, @Param("sortOrder") String sortOrder);
+                            @Param("startDays") Integer startDays, @Param("endDays") Integer endDays, @Param("deviceTypeId") Integer deviceTypeId, @Param("valveStatus") Integer valveStatus, @Param("registerStatus") Integer registerStatus, @Param("sortColumn") String sortColumn, @Param("sortOrder") String sortOrder);
 
     //按设备编号查询
     List<DeviceDto> getWaterMeterListByDeviceNo(@Param("deviceNo") String deviceNo, @Param("waterMeterNo") String waterMeterNo);

+ 28 - 5
smart-city-platform/src/main/java/com/bz/smart_city/dao/StatMeterReadRateByBuildingMapper.java

@@ -1,10 +1,7 @@
 package com.bz.smart_city.dao;
 
 import com.bz.smart_city.commom.model.CommonQueryCondition;
-import com.bz.smart_city.dto.BuildingSelectInfoDto;
-import com.bz.smart_city.dto.StatMeterReadRateDto;
-import com.bz.smart_city.dto.WaterReadRateCountDto;
-import com.bz.smart_city.dto.WaterReadRateListDto;
+import com.bz.smart_city.dto.*;
 import com.bz.smart_city.entity.Customer;
 import com.bz.smart_city.entity.ProgramItem;
 import org.apache.ibatis.annotations.Mapper;
@@ -119,6 +116,23 @@ public interface StatMeterReadRateByBuildingMapper {
             @Param("sortColumn") String sortColumn,
             @Param("sortOrder") String sortOrder);
 
+    List<CustomerRateDto> getRateListByCustomerV2(
+            @Param("tableName") String tableName,
+            @Param("siteId") Integer siteId,
+            @Param("startDate") Integer startDate,
+            @Param("buildingIds") List<Integer> buildingIds,
+            @Param("channelId") Integer channelId,
+            @Param("customerIds") List<Integer> customerIds
+            );
+
+    List<WaterReadRateListDto> getRateListByCustomerV2AndDeviceType(
+            @Param("tableName") String tableName,
+            @Param("siteId") Integer siteId,
+            @Param("startDate") Integer startDate,
+            @Param("buildingIds") List<Integer> buildingIds,
+            @Param("channelId") Integer channelId,
+            @Param("customerId") Integer customerId);
+
     List<WaterReadRateListDto> getRateList7DayByCustomer(
             @Param("siteId") Integer siteId,
             @Param("startDate") Integer startDate,
@@ -141,6 +155,15 @@ public interface StatMeterReadRateByBuildingMapper {
             @Param("buildingIds") List<Integer> buildingIds,
             @Param("customerList") List<Customer> customerList);
 
+    WaterReadRateCountDto getCountByCustomerV2(
+            @Param("tableName") String tableName,
+            @Param("siteId") Integer siteId,
+            @Param("startDate") Integer startDate,
+            @Param("buildingIds") List<Integer> buildingIds,
+            @Param("channelId") Integer channelId,
+            @Param("customerId") Integer customerId
+            );
+
     WaterReadRateCountDto getCount7DayByCustomer(
             @Param("siteId") Integer siteId,
             @Param("startDate") Integer startDate,
@@ -152,7 +175,7 @@ public interface StatMeterReadRateByBuildingMapper {
             @Param("startDate") Integer startDate,
             @Param("buildingIds") List<Integer> buildingIds,
             @Param("customerList") List<Customer> customerList);
-    
+
     /**********************************************以下方法为新表安装场景专用**************************************************/
     List<StatMeterReadRateDto> getRateListByBuildingForDayWithNew(@Param("param") CommonQueryCondition condition);
 

+ 14 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dto/CustomerRateDto.java

@@ -0,0 +1,14 @@
+package com.bz.smart_city.dto;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class CustomerRateDto {
+
+    private Integer customerId;
+    private String customerName;
+    private Integer childrenNum;
+    private List<WaterReadRateListDto> list;
+}

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

@@ -15,6 +15,9 @@ public class WaterReadRateListDto extends WaterReadRateCountDto {
     @ApiModelProperty(value="场景ID")
     private Integer channelId;
 
+    @ApiModelProperty(value="场景名称")
+    private String channelName;
+
     @ApiModelProperty(value="客户ID")
     private Integer customerId;
 

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

@@ -81,7 +81,7 @@ public interface BuildingService{
 
     public List<BuildingSelectDto> areaList(List<BuildingSelectInfoDto> buildingList);
 
-    List<BuildingSelectDto> deviceAreaList(Integer sysId, Integer buildingId, String deviceNo, Integer status, Integer manufacturerId, String equipmentType, String model, Integer isTag, Integer floor, String locDesc, Integer province, Integer city, Integer region, Integer community, String concentratorNo, String collectorNo, String errorType, Integer customerId, Integer days, Integer startDays, Integer endDays, Integer deviceTypeId, Integer valveStatus);
+    List<BuildingSelectDto> deviceAreaList(Integer sysId, Integer buildingId, String deviceNo, Integer status, Integer manufacturerId, String equipmentType, String model, Integer isTag, Integer floor, String locDesc, Integer province, Integer city, Integer region, Integer community, String concentratorNo, String collectorNo, String errorType, Integer customerId, Integer days, Integer startDays, Integer endDays, Integer deviceTypeId, Integer valveStatus, Integer registerStatus);
 
     List<BuildingSelectDto> abnormalAreaBuildingList(Integer sysId, Integer buildingId, Integer floor, Integer measuringId, Long deviceId, String deviceNo, String location, Integer alarmCategory, Integer handleStatus, Integer alarmTypeId, Integer equipmentId, Integer manufacturerId, Integer customerId, Integer province, Integer city, Integer region, Integer communityId, LocalDateTime startDate, LocalDateTime endDate);
 

+ 4 - 3
smart-city-platform/src/main/java/com/bz/smart_city/service/CustomerService.java

@@ -5,8 +5,6 @@ import java.util.List;
 import com.bz.smart_city.commom.model.Pagination;
 import com.bz.smart_city.dto.CustomerDto;
 import com.bz.smart_city.entity.Customer;
-import com.bz.smart_city.entity.Permission;
-import com.bz.smart_city.entity.ProgramItem;
 import org.apache.ibatis.annotations.Param;
 
 public interface CustomerService {
@@ -21,7 +19,7 @@ public interface CustomerService {
 
     List<Customer> getCustomerList(Integer siteId);
 
-    List<Customer> getCustomerListByItem(Integer siteId, List<Integer> buildingIds);
+    List<Customer> getCustomerListByItem(Integer siteId, List<Integer> buildingIds, Integer customerId);
 
     Pagination<CustomerDto> getCustomerPage(String customerName, int pageNum, int pageSize);
 
@@ -48,4 +46,7 @@ public interface CustomerService {
     List<CustomerDto> findSiteCustomer();
 
     Pagination<CustomerDto> getCustomerTree(String customerName);
+
+    /*获取子类ID*/
+    List<Integer> findSubIds(Integer customerId);
 }

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

@@ -38,13 +38,13 @@ public interface DeviceService{
 
     Pagination<DeviceDto> getList(Integer sysId, Integer buildingId, String deviceNo, Integer status, Integer manufacturerId, String equipmentType, String model, Integer isTag, Integer floor,
                                   String locDesc, Integer province, Integer city, Integer region, Integer community, String concentratorNo, String collectorNo, String errorType,
-                                  Integer customerId, Integer days, Integer startDays, Integer endDays, Integer deviceTypeId, Integer valveStatus, String sortColumn, String sortOrder, int pageNum, int pageSize);
+                                  Integer customerId, Integer days, Integer startDays, Integer endDays, Integer deviceTypeId, Integer valveStatus, Integer registerStatus, String sortColumn, String sortOrder, int pageNum, int pageSize);
 
     List<DeviceDto> getWaterMeterListByDeviceNo(String deviceNo,String waterMeterNo);
 
     void getDeviceListExcel(Integer sysId, Integer buildingId, String deviceNo, Integer status, Integer manufacturerId, String equipmentType, String model, Integer isTag, Integer floor,
                             String locDesc, Integer province, Integer city, Integer region, Integer community, String concentratorNo, String collectorNo, String errorType,
-                            Integer customerId, Integer days, Integer startDays, Integer endDays, Integer deviceTypeId, Integer valveStatus, String sortColumn, String sortOrder, HttpServletResponse httpServletResponse);
+                            Integer customerId, Integer days, Integer startDays, Integer endDays, Integer deviceTypeId, Integer valveStatus, Integer registerStatus, String sortColumn, String sortOrder, HttpServletResponse httpServletResponse);
 
 
     void exportDeviceListAsXML(Integer sysId,

+ 5 - 3
smart-city-platform/src/main/java/com/bz/smart_city/service/StatMeterReadRateByBuildingService.java

@@ -25,11 +25,13 @@ public interface StatMeterReadRateByBuildingService{
 
     void getRateExcelByDeviceType(Integer period, HttpServletResponse httpServletResponse);
 
-    Pagination<WaterReadRateListDto> getListByCustomer(Integer period, String sortColumn, String sortOrder, int pageNum, int pageSize);
+    Pagination<CustomerRateDto> getListByCustomer(Integer period, Integer channelId, Integer customerId, String sortColumn, String sortOrder, int pageNum, int pageSize);
 
-    void getRateExcelByCustomer(Integer period, HttpServletResponse httpServletResponse);
+    List<CustomerRateDto> getSubListByCustomer(Integer period, Integer channelId, Integer customerId);
 
-    WaterReadRateCountDto getCountByCustomer(Integer period);
+    void getRateExcelByCustomer(Integer period, Integer channelId, Integer customerId, HttpServletResponse httpServletResponse);
+
+    WaterReadRateCountDto getCountByCustomer(Integer period, Integer channelId, Integer customerId);
     /**
      * 获取建筑统计明细表
      * @param condition

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

@@ -925,10 +925,10 @@ public class BuildingServiceImpl implements BuildingService {
     }
 
     @Override
-    public List<BuildingSelectDto> deviceAreaList(Integer sysId, Integer buildingId, String deviceNo, Integer status, Integer manufacturerId, String equipmentType, String model, Integer isTag, Integer floor, String locDesc, Integer province, Integer city, Integer region, Integer communityId, String concentratorNo, String collectorNo, String errorType, Integer customerId, Integer days, Integer startDays, Integer endDays, Integer deviceTypeId, Integer valveStatus) {
+    public List<BuildingSelectDto> deviceAreaList(Integer sysId, Integer buildingId, String deviceNo, Integer status, Integer manufacturerId, String equipmentType, String model, Integer isTag, Integer floor, String locDesc, Integer province, Integer city, Integer region, Integer communityId, String concentratorNo, String collectorNo, String errorType, Integer customerId, Integer days, Integer startDays, Integer endDays, Integer deviceTypeId, Integer valveStatus, Integer registerStatus) {
         LoginUser loginUser = UserUtil.getCurrentUser();
         //查询用户数据项下的建筑列表
-        List<BuildingSelectInfoDto> buildingList = buildingMapper.deviceCountAreaList(loginUser.getSiteId(), UserUtil.getCurrentSiteProgramItems(loginUser), sysId, buildingId, deviceNo, status, manufacturerId, equipmentType, model, isTag, floor, locDesc, province, city, region, communityId, concentratorNo, collectorNo, errorType, customerId, days, startDays, endDays,deviceTypeId,valveStatus);
+        List<BuildingSelectInfoDto> buildingList = buildingMapper.deviceCountAreaList(loginUser.getSiteId(), UserUtil.getCurrentSiteProgramItems(loginUser), sysId, buildingId, deviceNo, status, manufacturerId, equipmentType, model, isTag, floor, locDesc, province, city, region, communityId, concentratorNo, collectorNo, errorType, customerId, days, startDays, endDays,deviceTypeId,valveStatus,registerStatus);
 
         return this.areaList(buildingList);
     }

+ 6 - 6
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/CustomerServiceImpl.java

@@ -5,20 +5,16 @@ import com.bz.smart_city.commom.model.Pagination;
 import com.bz.smart_city.commom.model.ResultStatus;
 import com.bz.smart_city.commom.util.TreeUtil;
 import com.bz.smart_city.commom.util.UserUtil;
-import com.bz.smart_city.commom.util.Util;
 import com.bz.smart_city.dto.CustomerDto;
 import com.bz.smart_city.dto.LoginUser;
-import com.bz.smart_city.entity.Permission;
 import com.bz.smart_city.entity.ProgramItem;
 import com.github.pagehelper.PageHelper;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.time.LocalDateTime;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
 
 import com.bz.smart_city.entity.Customer;
@@ -104,8 +100,8 @@ public class CustomerServiceImpl implements CustomerService {
     }
 
     @Override
-    public List<Customer> getCustomerListByItem(Integer siteId, List<Integer> buildingIds) {
-        return customerMapper.getCustomerListByItem(siteId, buildingIds);
+    public List<Customer> getCustomerListByItem(Integer siteId, List<Integer> buildingIds, Integer customerId) {
+        return customerMapper.getCustomerListByItem(siteId, buildingIds,customerId);
     }
 
     @Override
@@ -240,4 +236,8 @@ public class CustomerServiceImpl implements CustomerService {
         }
     }
 
+    @Override
+    public List<Integer> findSubIds(Integer customerId) {
+        return customerMapper.findSubIds(customerId);
+    }
 }

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

@@ -150,13 +150,13 @@ public  class DeviceServiceImpl implements DeviceService {
     }
 
     @Override
-    public Pagination<DeviceDto> getList(Integer sysId, Integer buildingId, String deviceNo, Integer status, Integer manufacturerId, String equipmentType, String model, Integer isTag, Integer floor, String locDesc, Integer province, Integer city, Integer region, Integer community, String concentratorNo, String collectorNo, String errorType, Integer customerId, Integer days, Integer startDays, Integer endDays, Integer deviceTypeId, Integer valveStatus, String sortColumn, String sortOrder, int pageNum, int pageSize) {
+    public Pagination<DeviceDto> getList(Integer sysId, Integer buildingId, String deviceNo, Integer status, Integer manufacturerId, String equipmentType, String model, Integer isTag, Integer floor, String locDesc, Integer province, Integer city, Integer region, Integer community, String concentratorNo, String collectorNo, String errorType, Integer customerId, Integer days, Integer startDays, Integer endDays, Integer deviceTypeId, Integer valveStatus, Integer registerStatus, String sortColumn, String sortOrder, int pageNum, int pageSize) {
         LoginUser loginUser = UserUtil.getCurrentUser();
 
         PageHelper.startPage(pageNum, pageSize);
         List<DeviceDto> list = deviceMapper.getList(sysId, buildingId, loginUser.getSiteId(), UserUtil.getCurrentSiteProgramItems(loginUser), deviceNo, status, manufacturerId,
                 equipmentType, model, isTag, floor, locDesc, province, city, region, community, concentratorNo, collectorNo, errorType, customerId,
-                days, startDays, endDays,deviceTypeId, valveStatus, sortColumn, sortOrder);
+                days, startDays, endDays,deviceTypeId, valveStatus, registerStatus, sortColumn, sortOrder);
         return new Pagination<>(list);
     }
 
@@ -167,12 +167,12 @@ public  class DeviceServiceImpl implements DeviceService {
     }
 
     @Override
-    public void getDeviceListExcel(Integer sysId, Integer buildingId, String deviceNo, Integer status, Integer manufacturerId, String equipmentType, String model, Integer isTag, Integer floor, String locDesc, Integer province, Integer city, Integer region, Integer community, String concentratorNo, String collectorNo, String errorType, Integer customerId, Integer days, Integer startDays, Integer endDays, Integer deviceTypeId, Integer valveStatus, String sortColumn, String sortOrder, HttpServletResponse httpServletResponse) {
+    public void getDeviceListExcel(Integer sysId, Integer buildingId, String deviceNo, Integer status, Integer manufacturerId, String equipmentType, String model, Integer isTag, Integer floor, String locDesc, Integer province, Integer city, Integer region, Integer community, String concentratorNo, String collectorNo, String errorType, Integer customerId, Integer days, Integer startDays, Integer endDays, Integer deviceTypeId, Integer valveStatus, Integer registerStatus, String sortColumn, String sortOrder, HttpServletResponse httpServletResponse) {
         LoginUser loginUser = UserUtil.getCurrentUser();
 
         List<DeviceDto> list = deviceMapper.getList(sysId, buildingId, loginUser.getSiteId(), UserUtil.getCurrentSiteProgramItems(loginUser), deviceNo, status, manufacturerId,
                 equipmentType, model, isTag, floor, locDesc, province, city, region, community, concentratorNo, collectorNo, errorType, customerId,
-                days, startDays, endDays, deviceTypeId, valveStatus, sortColumn, sortOrder);
+                days, startDays, endDays, deviceTypeId, valveStatus, registerStatus, sortColumn, sortOrder);
         String title = "设备列表";
         //判断是否是水表场景
         WMeterType wMeterType = wMeterTypeMapper.getChannelIdAndLevel(sysId, 2);
@@ -457,6 +457,11 @@ public  class DeviceServiceImpl implements DeviceService {
             device.setCustomerId(deviceDataDto.getCustomerId());
             device.setWaterMeterNo(deviceDataDto.getWaterMeterNo());
             device.setUdipId(udipId);
+            if (udipId != null) {
+                device.setRegisterStatus(1);
+            }else {
+                device.setRegisterStatus(0);
+            }
             int result = this.insertSynArchives(device);
 
 

+ 63 - 26
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/StatMeterReadRateByBuildingServiceImpl.java

@@ -322,52 +322,86 @@ public class StatMeterReadRateByBuildingServiceImpl implements StatMeterReadRate
     }
 
     @Override
-    public Pagination<WaterReadRateListDto> getListByCustomer(Integer period, String sortColumn, String sortOrder, int pageNum, int pageSize) {
+    public Pagination<CustomerRateDto> getListByCustomer(Integer period, Integer channelId, Integer customerId, String sortColumn, String sortOrder, int pageNum, int pageSize) {
         LoginUser loginUser = UserUtil.getCurrentUser();
         ///查询数据权限的建筑ids
         List<Integer> buildingIds = buildingService.getIdsByDataPermission();
         //2、根据数据项查询客户
-        List<Customer> customerList = customerService.getCustomerListByItem(loginUser.getSiteId(), buildingIds);
+        //List<Customer> customerList = customerService.getCustomerListByItem(loginUser.getSiteId(), buildingIds, customerId);
+
+
 
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
-        Integer startDate = Integer.valueOf(LocalDate.now().plusDays(-1).format(formatter));
+        //Integer startDate = Integer.valueOf(LocalDate.now().plusDays(-1).format(formatter));
+        Integer startDate = 20200619;
+
 
+        List<CustomerRateDto> customerRateDtoList = newArrayList();
         List<WaterReadRateListDto> waterReadRateListDtoList = newArrayList();
+
         if (period == 2) { // 昨天,查询天表
             PageHelper.startPage(pageNum, pageSize);
-            waterReadRateListDtoList = statMeterReadRateByBuildingMapper.getRateListByCustomer(loginUser.getSiteId(), startDate, buildingIds, customerList, sortColumn, sortOrder);
+            customerRateDtoList = statMeterReadRateByBuildingMapper.getRateListByCustomerV2("sc_stat_meter_read_rate_by_building",loginUser.getSiteId(), startDate, buildingIds,channelId,newArrayList(customerId));
         } else if (period == 7) { // 近7天,查询7天表
             PageHelper.startPage(pageNum, pageSize);
-            waterReadRateListDtoList = statMeterReadRateByBuildingMapper.getRateList7DayByCustomer(loginUser.getSiteId(), startDate, buildingIds, customerList, sortColumn, sortOrder);
+            customerRateDtoList = statMeterReadRateByBuildingMapper.getRateListByCustomerV2("sc_stat_meter_read_rate_by_building_7day",loginUser.getSiteId(), startDate, buildingIds,channelId,newArrayList(customerId));
         } else if (period == 15) {// 近15天,查询15天表
             PageHelper.startPage(pageNum, pageSize);
-            waterReadRateListDtoList = statMeterReadRateByBuildingMapper.getRateList15DayByCustomer(loginUser.getSiteId(), startDate, buildingIds, customerList, sortColumn, sortOrder);
+            customerRateDtoList = statMeterReadRateByBuildingMapper.getRateListByCustomerV2("sc_stat_meter_read_rate_by_building_15day",loginUser.getSiteId(), startDate, buildingIds,channelId,newArrayList(customerId));
+        }else if (period == 99) {// 上个月,查询15天表
+            PageHelper.startPage(pageNum, pageSize);
+            customerRateDtoList = statMeterReadRateByBuildingMapper.getRateListByCustomerV2("sc_stat_meter_read_rate_by_building_month",loginUser.getSiteId(), startDate, buildingIds,channelId,newArrayList(customerId));
+        }
+        if (customerRateDtoList != null && customerRateDtoList.size()>0) {
+            for (CustomerRateDto customerRateDto : customerRateDtoList) {
+                customerRateDto.setList(statMeterReadRateByBuildingMapper.getRateListByCustomerV2AndDeviceType("sc_stat_meter_read_rate_by_building_month",loginUser.getSiteId(), startDate, buildingIds,channelId,customerRateDto.getCustomerId()));
+            }
         }
 
+        return new Pagination<>(customerRateDtoList);
+    }
 
-        /*long days = endTime - beginTime;
-        if (0 == days) {
-            DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMMdd");
-            LocalDate endDate = LocalDate.parse(beginTime.toString(), df);
-            // 根据日期的间隔来判断是否查询最近7天的抄表率
-            for (int i = 0; i < waterReadRateListDtoList.size(); i++) {
-                WaterReadRateListDto waterReadRateListDto = waterReadRateListDtoList.get(i);
-                LocalDate start = endDate.minusDays(6);
-                Double last7dayReadRate = statMeterReadRateByBuildingMapper.getLast7DaysReadRate(loginUser.getSiteId(),null, waterReadRateListDto.getCustomerId(), Integer.valueOf(start.format(df)), endTime, programItems);
-                waterReadRateListDto.setLast7dayReadRate(last7dayReadRate);
+    @Override
+    public List<CustomerRateDto> getSubListByCustomer(Integer period, Integer channelId, Integer customerId) {
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        ///查询数据权限的建筑ids
+        List<Integer> buildingIds = buildingService.getIdsByDataPermission();
+        //2、根据数据项查询客户
+        //List<Customer> customerList = customerService.getCustomerListByItem(loginUser.getSiteId(), buildingIds, customerId);
+        List<Integer> subIds = customerService.findSubIds(customerId);
+
+
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
+        //Integer startDate = Integer.valueOf(LocalDate.now().plusDays(-1).format(formatter));
+        Integer startDate = 20200619;
+
+
+        List<CustomerRateDto> customerRateDtoList = newArrayList();
+        if (period == 2) { // 昨天,查询天表
+            customerRateDtoList = statMeterReadRateByBuildingMapper.getRateListByCustomerV2("sc_stat_meter_read_rate_by_building",loginUser.getSiteId(), startDate, buildingIds,channelId,subIds);
+        } else if (period == 7) { // 近7天,查询7天表
+            customerRateDtoList = statMeterReadRateByBuildingMapper.getRateListByCustomerV2("sc_stat_meter_read_rate_by_building_7day",loginUser.getSiteId(), startDate, buildingIds,channelId,subIds);
+        } else if (period == 15) {// 近15天,查询15天表
+            customerRateDtoList = statMeterReadRateByBuildingMapper.getRateListByCustomerV2("sc_stat_meter_read_rate_by_building_15day",loginUser.getSiteId(), startDate, buildingIds,channelId,subIds);
+        }else if (period == 99) {// 上个月,查询15天表
+            customerRateDtoList = statMeterReadRateByBuildingMapper.getRateListByCustomerV2("sc_stat_meter_read_rate_by_building_month",loginUser.getSiteId(), startDate, buildingIds,channelId,subIds);
+        }
+        if (customerRateDtoList != null && customerRateDtoList.size()>0) {
+            for (CustomerRateDto customerRateDto : customerRateDtoList) {
+                customerRateDto.setList(statMeterReadRateByBuildingMapper.getRateListByCustomerV2AndDeviceType("sc_stat_meter_read_rate_by_building_month",loginUser.getSiteId(), startDate, buildingIds,channelId,customerRateDto.getCustomerId()));
             }
-        }*/
-        return new Pagination<>(waterReadRateListDtoList);
+        }
+        return customerRateDtoList;
     }
 
     @Override
-    public void getRateExcelByCustomer(Integer period, HttpServletResponse httpServletResponse) {
+    public void getRateExcelByCustomer(Integer period, Integer channelId, Integer customerId, HttpServletResponse httpServletResponse) {
         LoginUser loginUser = UserUtil.getCurrentUser();
         //1、查询数据权限的建筑ids
         List<Integer> buildingIds = buildingService.getIdsByDataPermission();
 
         //2、根据数据项查询客户
-        List<Customer> customerList = customerService.getCustomerListByItem(loginUser.getSiteId(), buildingIds);
+        List<Customer> customerList = customerService.getCustomerListByItem(loginUser.getSiteId(), buildingIds, null);
 
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
         Integer startDate = Integer.valueOf(LocalDate.now().plusDays(-1).format(formatter));
@@ -405,23 +439,26 @@ public class StatMeterReadRateByBuildingServiceImpl implements StatMeterReadRate
     }
 
     @Override
-    public WaterReadRateCountDto getCountByCustomer(Integer period) {
+    public WaterReadRateCountDto getCountByCustomer(Integer period, Integer channelId, Integer customerId) {
         LoginUser loginUser = UserUtil.getCurrentUser();
         //1、查询数据权限的建筑ids
         List<Integer> buildingIds = buildingService.getIdsByDataPermission();
 
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
-        Integer startDate = Integer.valueOf(LocalDate.now().plusDays(-1).format(formatter));
+        //Integer startDate = Integer.valueOf(LocalDate.now().plusDays(-1).format(formatter));
+        Integer startDate = 20200619;
 
         //2、根据数据项查询客户
-        List<Customer> customerList = customerService.getCustomerListByItem(loginUser.getSiteId(), buildingIds);
+        //List<Customer> customerList = customerService.getCustomerListByItem(loginUser.getSiteId(), buildingIds, null);
 
         if (period == 2) {
-            return statMeterReadRateByBuildingMapper.getCountByCustomer(loginUser.getSiteId(), startDate, buildingIds, customerList);
+            return statMeterReadRateByBuildingMapper.getCountByCustomerV2("sc_stat_meter_read_rate_by_building",loginUser.getSiteId(), startDate, buildingIds, channelId, customerId);
         } else if (period == 7) {
-            return statMeterReadRateByBuildingMapper.getCount7DayByCustomer(loginUser.getSiteId(), startDate, buildingIds, customerList);
+            return statMeterReadRateByBuildingMapper.getCountByCustomerV2("sc_stat_meter_read_rate_by_building_7day",loginUser.getSiteId(), startDate, buildingIds, channelId, customerId);
         } else if (period == 15) {
-            return statMeterReadRateByBuildingMapper.getCount15DayByCustomer(loginUser.getSiteId(), startDate, buildingIds, customerList);
+            return statMeterReadRateByBuildingMapper.getCountByCustomerV2("sc_stat_meter_read_rate_by_building_15day",loginUser.getSiteId(), startDate, buildingIds, channelId, customerId);
+        } else if (period == 99) {
+            return statMeterReadRateByBuildingMapper.getCountByCustomerV2("sc_stat_meter_read_rate_by_building_month",loginUser.getSiteId(), startDate, buildingIds, channelId, customerId);
         }
         return null;
     }

二进制
smart-city-platform/src/main/resources/excel/installPlanTemplate20200709.xlsx


+ 4 - 3
smart-city-platform/src/main/resources/mapper/BuildingMapper.xml

@@ -998,7 +998,7 @@
             <if test="collectorNo != null and collectorNo != ''">left join sc_collector scol on ( scol.id = swrd.collector_id)</if>
             <if test="(errorType != null and errorType != '') or days != null or startDays != null or endDays != null or (valveStatus != null)">left join sc_water_meter_error_days swmed on ( swmed.device_id = sd.id)</if>
             <if test="programItems != null and programItems.size() != 0">left join sc_device_dimension sdd on (sdd.device_id = sd.id and sdd.status = 1)</if>
-            where sd.status = 1 and sys_id != -99
+            where sd.status = 1 and sys_id <![CDATA[ <> ]]> -99
             <!--and sd.site_id = 1-->
             <if test="sysId != null"> AND sd.sys_id = #{sysId}</if>
             <if test="buildingId != null"> AND sd.building_id = #{buildingId}</if>
@@ -1025,6 +1025,7 @@
             <if test="endDays != null"> and swmed.days <![CDATA[ <= ]]> #{endDays} </if>
             <if test="valveStatus != null and valveStatus != 2"> and swmed.valve_status = #{valveStatus} </if>
             <if test="valveStatus != null and valveStatus == 2"> and sdt.is_valve = 0 </if>
+            <if test="registerStatus != null"> and sd.register_status = #{registerStatus} </if>
             <if test="programItems != null and programItems.size() != 0"> and
                 <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
                     sdd.${item.dimensionCode} = #{item.dimensionValue}
@@ -1136,8 +1137,8 @@
         <if test="province != null or city != null or region != null or community != null">left join sc_building sb on (sb.id = sd.building_id and sb.status = 1)</if>
         <if test="errorType != null and errorType != ''">left join sc_water_meter_error_days swmed on ( swmed.device_id = sd.id)</if>
         <if test="programItems != null and programItems.size() != 0">left join sc_device_dimension sdd on (sdd.device_id = sd.id and sdd.status = 1)</if>
-        <if test="startDate != null or endDate != null">left join sc_install_list sil on (sil.device_id = sd.id)</if>
-        where sd.status = 1 and sys_id = -99
+        left join sc_install_list sil on (sil.device_id = sd.id)
+        where sd.status = 1 and sys_id = -99 and sil.status = 1
         <if test="buildingId != null"> AND sd.building_id = #{buildingId}</if>
         <if test="siteId != null"> AND sd.site_id = #{siteId}</if>
         <if test="deviceNo != null and deviceNo != ''"> AND (sd.device_no LIKE concat('%',#{deviceNo},'%') or sd.water_meter_no LIKE concat('%',#{deviceNo},'%') or sd.water_meter_file_no LIKE concat('%',#{deviceNo},'%'))</if>

+ 8 - 0
smart-city-platform/src/main/resources/mapper/CustomerMapper.xml

@@ -233,6 +233,8 @@
                 <if test="buildingIds != null and buildingIds.size() != 0"> and building_id in <foreach collection="buildingIds" item="item" open="(" separator="," close=")">#{item}</foreach> </if>
                 GROUP BY customer_id
                 )
+        <if test="customerId != null"> and id = #{customerId}</if>
+
     </select>
     <select id="getCustomerList" resultType="com.bz.smart_city.dto.CustomerDto">
         select <include refid="Base_Column_List"></include> from sc_customer
@@ -294,5 +296,11 @@
     <select id="countChildrenNum" resultType="java.lang.Integer">
         select count(1) from sc_customer where status = 1 and parent_id = #{customerId}
     </select>
+
+    <select id="findSubIds" resultType="java.lang.Integer">
+        select id from sc_customer where status = 1 and parent_id = #{customerId}
+    </select>
+
+
 </mapper>
 

+ 11 - 6
smart-city-platform/src/main/resources/mapper/DeviceMapper.xml

@@ -167,7 +167,8 @@
             customer_id,
             metercode,
             account_id,
-            udip_id
+            udip_id,
+            register_status
         ) VALUES (
             #{device.id,jdbcType=BIGINT},
             #{device.deviceNo,jdbcType=VARCHAR},
@@ -194,7 +195,8 @@
             #{device.customerId,jdbcType=INTEGER},
             #{device.metercode,jdbcType=VARCHAR},
             #{device.accountId,jdbcType=BIGINT},
-            #{device.udipId,jdbcType=VARCHAR}
+            #{device.udipId,jdbcType=VARCHAR},
+            #{device.registerStatus,jdbcType=INTEGER}
         )
 </insert>
 
@@ -225,7 +227,8 @@
             <if test="device.waterMeterNo!=null"> water_meter_no,</if>
             <if test="device.waterMeterFileNo!=null"> water_meter_file_no,</if>
             <if test="device.customerId!=null"> customer_id,</if>
-            <if test="device.udipId!=null"> udip_id</if>
+            <if test="device.udipId!=null"> udip_id,</if>
+            <if test="device.registerStatus!=null"> register_status</if>
         </trim>
         VALUES
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -252,7 +255,8 @@
             <if test="device.waterMeterNo!=null"> #{device.waterMeterNo,jdbcType=VARCHAR},</if>
             <if test="device.waterMeterFileNo!=null"> #{device.waterMeterFileNo,jdbcType=VARCHAR},</if>
             <if test="device.customerId!=null"> #{device.customerId,jdbcType=INTEGER},</if>
-            <if test="device.udipId!=null"> #{device.udipId,jdbcType=VARCHAR}</if>
+            <if test="device.udipId!=null"> #{device.udipId,jdbcType=VARCHAR},</if>
+            <if test="device.registerStatus!=null"> #{device.registerStatus,jdbcType=INTEGER}</if>
         </trim>
 </insert>
 
@@ -369,7 +373,7 @@
         <if test="programItems != null and programItems.size() != 0">left join sc_device_dimension sdd on (sdd.device_id = sd.id and sdd.status = 1)</if>
         where sd.status = 1
         <if test="sysId != null"> AND sd.sys_id = #{sysId}</if>
-        <if test="sysId == null"> AND sd.sys_id != -99</if>
+        <if test="sysId == null"> AND sd.sys_id <![CDATA[ <> ]]> -99</if>
         <if test="buildingId != null"> AND sd.building_id = #{buildingId}</if>
         <if test="siteId != null"> AND sd.site_id = #{siteId}</if>
         <if test="deviceNo != null and deviceNo != ''"> AND (sd.device_no LIKE concat('%',#{deviceNo},'%') or sd.water_meter_no LIKE concat('%',#{deviceNo},'%') or sd.water_meter_file_no LIKE concat('%',#{deviceNo},'%'))</if>
@@ -391,6 +395,7 @@
         <if test="customerId != null"> and sd.customer_id = #{customerId}</if>
         <if test="valveStatus != null and valveStatus != 2"> and swmed.valve_status = #{valveStatus}</if>
         <if test="valveStatus != null and valveStatus == 2"> and sdt.is_valve = 0</if>
+        <if test="registerStatus != null"> and sd.register_status = #{registerStatus}</if>
         <if test="days != null">
             <choose>
                 <when test="days == 0">
@@ -739,7 +744,7 @@
         left join sc_customer scus on ( scus.id = sd.customer_id)
         left join sc_install_list sil on (sil.device_id = sd.id)
         <if test="programItems != null and programItems.size() != 0">left join sc_device_dimension sdd on (sdd.device_id = sd.id and sdd.status = 1)</if>
-        where sd.status = 1
+        where sd.status = 1 and sil.status = 1
         <if test="sysId != null"> AND sd.sys_id = #{sysId}</if>
         <if test="siteId != null"> AND sd.site_id = #{siteId}</if>
         <if test="deviceNo != null and deviceNo != ''"> AND (sd.device_no LIKE concat('%',#{deviceNo},'%') or sd.water_meter_no LIKE concat('%',#{deviceNo},'%') or sd.water_meter_file_no LIKE concat('%',#{deviceNo},'%'))</if>

+ 56 - 0
smart-city-platform/src/main/resources/mapper/StatMeterReadRateByBuildingMapper.xml

@@ -492,6 +492,46 @@
         </if>
     </select>
 
+    <select id="getRateListByCustomerV2" resultType="com.bz.smart_city.dto.CustomerRateDto">
+		SELECT
+            ssmrrbb.customer_id,
+            sc.customer_name,
+            sc.children_num
+        FROM
+            ${tableName} ssmrrbb
+        left join sc_customer sc on(sc.id = ssmrrbb.customer_id)
+        WHERE
+            ssmrrbb.site_id = #{siteId}
+            <if test="channelId != null"> and ssmrrbb.channel_id = #{channelId} </if>
+            AND ssmrrbb.stat_day = #{startDate}
+            AND ssmrrbb.channel_id <![CDATA[ <> ]]> - 99
+            <if test="buildingIds != null and buildingIds.size() != 0"> and ssmrrbb.building_id in <foreach collection="buildingIds" item="item" open="(" separator="," close=")">#{item}</foreach> </if>
+            <if test="customerIds != null and customerIds.size() != 0"> and ssmrrbb.customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach> </if>
+            <if test="customerIds == null "> and sc.parent_id = 0 </if>
+        GROUP BY
+            ssmrrbb.customer_id,sc.customer_name,sc.children_num
+    </select>
+    <select id="getRateListByCustomerV2AndDeviceType" resultType="com.bz.smart_city.dto.WaterReadRateListDto">
+        SELECT
+        ssmrrbb.channel_id,
+        sc.channel_name,
+        SUM(device_count) as device_count,
+        SUM(ssmrrbb.read_times) as read_times,
+        SUM(ssmrrbb.real_read_times) as real_read_times,
+        SUM(ssmrrbb.un_read_times) as un_read_times,
+        ifnull(ROUND(sum(real_read_times)/sum(device_count)*100,2),0) as read_rate
+        FROM sc_stat_meter_read_rate_by_building ssmrrbb
+        left join sc_channel sc on(sc.id = ssmrrbb.channel_id)
+        WHERE
+        ssmrrbb.customer_id = #{customerId}
+        and ssmrrbb.site_id = #{siteId}
+        and ssmrrbb.stat_day = #{startDate}
+        AND ssmrrbb.channel_id <![CDATA[ <> ]]> - 99
+        <if test="channelId != null"> and ssmrrbb.channel_id = #{channelId} </if>
+        GROUP BY ssmrrbb.channel_id,sc.channel_name
+        order by read_rate desc
+    </select>
+
     <!--按客户查询7天内的抄表率数数据统计-->
     <select id="getRateList7DayByCustomer" resultType="com.bz.smart_city.dto.WaterReadRateListDto">
         SELECT
@@ -578,6 +618,22 @@
         </if>
     </select>
 
+    <select id="getCountByCustomerV2" resultType="com.bz.smart_city.dto.WaterReadRateCountDto">
+        SELECT
+        SUM(device_count) as device_count,
+        SUM(read_times) as read_times,
+        SUM(real_read_times) as real_read_times,
+        SUM(un_read_times) as un_read_times,
+        ifnull(ROUND(sum(real_read_times)/sum(device_count)*100,2),0) as read_rate
+        FROM ${tableName} scmrrbb
+        WHERE stat_day = #{startDate}
+        and channel_id <![CDATA[ <> ]]> - 99
+        <if test="siteId != null"> and site_id = #{siteId} </if>
+        <if test="channelId != null"> and channel_id = #{channelId} </if>
+        <if test="customerId != null"> and customer_id = #{customerId} </if>
+        <if test="buildingIds != null and buildingIds.size() != 0"> and building_id in <foreach collection="buildingIds" item="item" open="(" separator="," close=")">#{item}</foreach> </if>
+    </select>
+
     <!--按客户查询时间范围内的抄表率数据统计-->
     <select id="getCount7DayByCustomer" resultType="com.bz.smart_city.dto.WaterReadRateCountDto">
         SELECT

+ 3 - 3
smart-city-platform/src/test/java/com/bz/smart_city/ForCreateDataTest.java

@@ -99,7 +99,7 @@ public class ForCreateDataTest {
         Integer systemId = 18;
         Integer siteId = 37;
         String prefix = "30393731";
-        List<DeviceDto> devices = deviceMapper.getList(systemId, null, siteId, null, prefix, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,null, null, null, null, null, null,null);
+        List<DeviceDto> devices = deviceMapper.getList(systemId, null, siteId, null, prefix, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,null, null, null, null, null, null, null,null);
         int i = 0;
         for (DeviceDto d : devices) {
             if (i % 100 == 0) {
@@ -195,7 +195,7 @@ public class ForCreateDataTest {
         Integer systemId = 4;
         Integer siteId = 37;
         String prefix = "004a70124";
-        List<DeviceDto> devices = deviceMapper.getList(systemId, null, siteId, null, prefix, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,null);
+        List<DeviceDto> devices = deviceMapper.getList(systemId, null, siteId, null, prefix, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,null);
         int i = 0;
         for (DeviceDto d : devices) {
             if (i % 100 == 0) {
@@ -218,7 +218,7 @@ public class ForCreateDataTest {
         Integer systemId = 4;
         Integer siteId = 37;
         String prefix = "004a70124";
-        List<DeviceDto> devices = deviceMapper.getList(systemId, null, siteId, null, prefix, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,null);
+        List<DeviceDto> devices = deviceMapper.getList(systemId, null, siteId, null, prefix, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,null);
 
         for (int i = 0; i < 105; i++) {
             DeviceDto d = devices.get(getRandom(devices.size()));