ソースを参照

部分接口权限过滤

lin 4 年 前
コミット
b82b65ac8d
35 ファイル変更264 行追加118 行削除
  1. 18 0
      smart-city-platform/src/main/java/com/bz/smart_city/commom/util/UserUtil.java
  2. 1 1
      smart-city-platform/src/main/java/com/bz/smart_city/controller/CommunityManagerController.java
  3. 11 4
      smart-city-platform/src/main/java/com/bz/smart_city/controller/DeviceController.java
  4. 1 0
      smart-city-platform/src/main/java/com/bz/smart_city/controller/clearing/WaterClearingController.java
  5. 3 3
      smart-city-platform/src/main/java/com/bz/smart_city/controller/water/WaterMeterReadController.java
  6. 5 3
      smart-city-platform/src/main/java/com/bz/smart_city/dao/BuildingMapper.java
  7. 6 4
      smart-city-platform/src/main/java/com/bz/smart_city/dao/ClearingPlanMapper.java
  8. 15 12
      smart-city-platform/src/main/java/com/bz/smart_city/dao/ClearingRecordMapper.java
  9. 4 3
      smart-city-platform/src/main/java/com/bz/smart_city/dao/CollectorMapper.java
  10. 4 1
      smart-city-platform/src/main/java/com/bz/smart_city/dao/CommunityMapper.java
  11. 4 2
      smart-city-platform/src/main/java/com/bz/smart_city/dao/ConcentratorMapper.java
  12. 1 1
      smart-city-platform/src/main/java/com/bz/smart_city/dao/DeviceMapper.java
  13. 14 14
      smart-city-platform/src/main/java/com/bz/smart_city/dao/StatMeterReadRateByBuildingMapper.java
  14. 1 1
      smart-city-platform/src/main/java/com/bz/smart_city/service/BuildingService.java
  15. 2 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/CommunityService.java
  16. 2 2
      smart-city-platform/src/main/java/com/bz/smart_city/service/DeviceService.java
  17. 1 1
      smart-city-platform/src/main/java/com/bz/smart_city/service/clearing/ClearingPlanService.java
  18. 1 2
      smart-city-platform/src/main/java/com/bz/smart_city/service/clearing/impl/ClearingPlanServiceImpl.java
  19. 2 1
      smart-city-platform/src/main/java/com/bz/smart_city/service/clearing/impl/ClearingRecordServiceImpl.java
  20. 7 7
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/BuildingServiceImpl.java
  21. 4 13
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/CollectorServiceImpl.java
  22. 7 2
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/CommunityServiceImpl.java
  23. 2 2
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/ConcentratorServiceImpl.java
  24. 4 5
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/DeviceServiceImpl.java
  25. 1 1
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/DimensionServiceImpl.java
  26. 9 12
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/StatMeterReadRateByBuildingServiceImpl.java
  27. 38 9
      smart-city-platform/src/main/resources/mapper/BuildingMapper.xml
  28. 8 0
      smart-city-platform/src/main/resources/mapper/ClearingPlanMapper.xml
  29. 4 0
      smart-city-platform/src/main/resources/mapper/ClearingRecordMapper.xml
  30. 6 0
      smart-city-platform/src/main/resources/mapper/CollectorMapper.xml
  31. 33 0
      smart-city-platform/src/main/resources/mapper/CommunityMapper.xml
  32. 6 0
      smart-city-platform/src/main/resources/mapper/ConcentratorMapper.xml
  33. 5 1
      smart-city-platform/src/main/resources/mapper/DeviceMapper.xml
  34. 31 8
      smart-city-platform/src/main/resources/mapper/StatMeterReadRateByBuildingMapper.xml
  35. 3 3
      smart-city-platform/src/test/java/com/bz/smart_city/ForCreateDataTest.java

+ 18 - 0
smart-city-platform/src/main/java/com/bz/smart_city/commom/util/UserUtil.java

@@ -9,6 +9,7 @@ import org.springframework.security.authentication.UsernamePasswordAuthenticatio
 import org.springframework.security.core.Authentication;
 import org.springframework.security.core.context.SecurityContextHolder;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import static com.google.common.collect.Lists.newArrayList;
@@ -110,5 +111,22 @@ public class UserUtil {
         }
     }
 
+    public static List<Integer> getCustomerIds(){
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        List<ProgramItem> programItems = UserUtil.getCurrentSiteProgramItems(loginUser);
+        if (programItems != null && programItems.size() > 0) {
+            List<Integer> customerIds = new ArrayList<Integer>();
+            for(ProgramItem  item :  programItems) {
+                if(item.getDimensionCode().equals("CUSTOMER")) {
+                    customerIds.add(Integer.parseInt(item.getDimensionValue()));
+                }
+            }
+            return customerIds;
+        }
+
+
+        return null;
+    }
+
 
 }

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

@@ -59,7 +59,7 @@ public class CommunityManagerController {
         if(StringUtils.isNotBlank(name)) {
         	param.setName("%"+name+"%");
         }
-        List<CommunityDto> list = communityService.queryList(param);
+        List<CommunityDto> list = communityService.queryCommunity(param);
         
         return new AjaxMessage<>(ResultStatus.OK, list);
 	}

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

@@ -67,6 +67,8 @@ public class DeviceController {
             @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,
             @ApiParam(value = "页数,非必传,默认第一页", required = false, defaultValue = "1") @RequestParam(required = false, defaultValue = "1") int pageNum,
@@ -74,7 +76,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,registerStatus,issueStatus,syncStatus,sortColumn, sortOrder, pageNum, pageSize);
+                deviceTypeId,valveStatus,registerStatus,issueStatus,syncStatus, startReading, endReading, sortColumn, sortOrder, pageNum, pageSize);
         return new AjaxMessage<>(ResultStatus.OK, pageInfo);
     }
 
@@ -121,13 +123,15 @@ public class DeviceController {
             @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.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,registerStatus,issueStatus,syncStatus,sortColumn, sortOrder, httpServletResponse);
+                deviceTypeId,valveStatus,registerStatus,issueStatus,syncStatus, startReading, endReading, sortColumn, sortOrder, httpServletResponse);
 
     }
 
@@ -195,10 +199,13 @@ public class DeviceController {
             @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 = "同步状态 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
     ) {
         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,registerStatus,issueStatus,syncStatus);
+                floor, locDesc, province, city, region, community, concentratorNo, collectorNo, errorType, customerId, days, startDays,endDays,deviceTypeId,
+                valveStatus,registerStatus,issueStatus,syncStatus, startReading, endReading);
         return new AjaxMessage<>(ResultStatus.OK, list);
     }
 

+ 1 - 0
smart-city-platform/src/main/java/com/bz/smart_city/controller/clearing/WaterClearingController.java

@@ -124,6 +124,7 @@ public class WaterClearingController {
 	@PreAuthorize("hasAuthority('clearing:record:list')")
 	@ApiOperation(value = "查询结算记录",notes = "权限:clearing:record:list")
 	public AjaxMessage<Pagination<ClearingRecordDTO>> listClearingRecord(
+			@ApiParam(value = "客户id", required = false) @RequestParam(required = false) Integer customerId,
 			@ApiParam(value = "结算计划", required = false) @RequestParam(required = false) Integer clearingPlanId,
 			@ApiParam(value = "查询名称", required = false) @RequestParam(required = false) String queryName,
 			@ApiParam(value = "小区", required = false) @RequestParam(required = false) Integer communityId,

+ 3 - 3
smart-city-platform/src/main/java/com/bz/smart_city/controller/water/WaterMeterReadController.java

@@ -386,7 +386,7 @@ public class WaterMeterReadController {
 	@GetMapping("/v2/getRateListByBuilding")
 	@ApiOperation(value = "场景下抄表率-按照建筑统计抄表率-适用于所有场景(新统计口径)")
 	public AjaxMessage<Pagination<StatMeterReadRateDto>> getRateListByBuilding(
-			@ApiParam(value = "场景", required = true) @RequestParam(required = true) int channelId,
+			@ApiParam(value = "场景", required = false) @RequestParam(required = false) int channelId,
 			@ApiParam(value = "小区", required = false) @RequestParam(required = false) Integer communityId,
 			@ApiParam(value = "客户Id", required = false) @RequestParam(required = false) Integer customerId,
 			@ApiParam(value = "建筑", required = false) @RequestParam(required = false) Integer buildingId,
@@ -423,7 +423,7 @@ public class WaterMeterReadController {
 	@GetMapping("/rateAreaList")
 	@ApiOperation(value = "获取抄表率区域列表")
 	public AjaxMessage<List<BuildingSelectDto>> rateAreaList(
-			@ApiParam(value = "场景", required = true) @RequestParam(required = true) int channelId,
+			@ApiParam(value = "场景", required = false) @RequestParam(required = false) int channelId,
 			@ApiParam(value = "小区", required = false) @RequestParam(required = false) Integer communityId,
 			@ApiParam(value = "客户Id", required = false) @RequestParam(required = false) Integer customerId,
 			@ApiParam(value = "建筑", required = false) @RequestParam(required = false) Integer buildingId,
@@ -568,7 +568,7 @@ public class WaterMeterReadController {
 	@GetMapping("/v2/summaryRateListByBuilding")
 	@ApiOperation(value = "场景下抄表率-按照建筑汇总-适用于所有场景(新统计口径)")
 	public AjaxMessage<StatMeterReadRateDto> summaryRateListByBuilding(
-			@ApiParam(value = "场景", required = true) @RequestParam(required = true) int channelId,
+			@ApiParam(value = "场景", required = false) @RequestParam(required = false) int channelId,
 			@ApiParam(value = "小区", required = false) @RequestParam(required = false) Integer communityId,
 			@ApiParam(value = "建筑", required = false) @RequestParam(required = false) Integer buildingId,
 			@ApiParam(value = "客户", required = false) @RequestParam(required = false) Integer customerId,

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

@@ -22,7 +22,9 @@ public interface BuildingMapper {
 
     List<Building> findBySiteId(@Param("siteId") Integer siteId, @Param("sysId") Integer sysId);
 
-    List<Building> findBySiteIdAndProgramItem(@Param("siteId") Integer siteId, @Param("sysId") Integer sysId, @Param("buildingIds") List<Integer> buildingIds, @Param("buildingName") String buildingName);
+    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<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);
 
@@ -32,7 +34,7 @@ public interface BuildingMapper {
 
     List<BuildingInfoDto> findBySiteIdAndName(@Param("siteId") Integer siteId, @Param("sysId") Integer sysId, @Param("buildingId") Integer buildingId, @Param("buildingName") String buildingName);
 
-    List<BuildingInfoListDto> getBuildingList(@Param("siteId") Integer siteId, @Param("programItems") List<ProgramItem> programItems, @Param("sysId") Integer sysId, @Param("buildingName") String buildingName, @Param("province") Integer province, @Param("city") Integer city, @Param("region") Integer region, @Param("community") Integer community);
+    List<BuildingInfoListDto> getBuildingList(@Param("siteId") Integer siteId, @Param("programItems") List<ProgramItem> programItems, @Param("sysId") Integer sysId, @Param("buildingName") String buildingName, @Param("province") Integer province, @Param("city") Integer city, @Param("region") Integer region, @Param("community") Integer community, @Param("customerIds") List<Integer> customerIds);
 
     List<FloorDto> queryFloor(@Param("sysId") Integer sysId, @Param("buildingId") Integer buildingId);
 
@@ -67,7 +69,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, @Param("registerStatus") Integer registerStatus, @Param("issueStatus") Integer issueStatus, @Param("syncStatus") Integer syncStatus);
+    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, @Param("issueStatus") Integer issueStatus, @Param("syncStatus") Integer syncStatus, @Param("startReading") Double startReading, @Param("endReading") Double endReading);
 
     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);
 

+ 6 - 4
smart-city-platform/src/main/java/com/bz/smart_city/dao/ClearingPlanMapper.java

@@ -2,7 +2,9 @@ package com.bz.smart_city.dao;
 
 import com.bz.smart_city.dto.ClearingPlanDTO;
 import com.bz.smart_city.entity.ClearingPlan;
+
 import java.util.List;
+
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -13,10 +15,10 @@ public interface ClearingPlanMapper {
     int updateByPrimaryKeySelective(ClearingPlan record);
 
     int batchInsert(@Param("list") List<ClearingPlan> list);
-    
-    ClearingPlan findClearingPlanById(@Param("id")Integer id);
-    
-    List<ClearingPlanDTO> quereyClearingPlanList(@Param("queryName") String queryName,@Param("siteId") Integer siteId);
+
+    ClearingPlan findClearingPlanById(@Param("id") Integer id);
+
+    List<ClearingPlanDTO> quereyClearingPlanList(@Param("queryName") String queryName, @Param("siteId") Integer siteId, @Param("customerIds") List<Integer> customerIds);
 
     Integer countDeviceByPlan(@Param("planId") Integer planId);
 

+ 15 - 12
smart-city-platform/src/main/java/com/bz/smart_city/dao/ClearingRecordMapper.java

@@ -2,7 +2,9 @@ package com.bz.smart_city.dao;
 
 import com.bz.smart_city.dto.ClearingRecordDTO;
 import com.bz.smart_city.entity.ClearingRecord;
+
 import java.util.List;
+
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -13,17 +15,18 @@ public interface ClearingRecordMapper {
     int updateByPrimaryKeySelective(ClearingRecord record);
 
     int batchInsert(@Param("list") List<ClearingRecord> list);
-    
-    ClearingRecord findClearingRecord(@Param("clearingPlanId") Integer clearingPlanId , @Param("clearingDay")Integer clearingDay );
-    
-    List<ClearingRecordDTO> queryClearingRecordList(@Param("clearingPlanId")Integer clearingPlanId,@Param("buildingId")Integer buildingId ,
-    		@Param("communityId") Integer communityId);
-    
-    ClearingRecord findClearingRecordById(@Param("id")Integer id);
-    
-    ClearingRecord findClearingRecordByAccoutPeriod(@Param("clearingPlanId")Integer clearingPlanId,@Param("accountPeriod")String accountPeriod);
+
+    ClearingRecord findClearingRecord(@Param("clearingPlanId") Integer clearingPlanId, @Param("clearingDay") Integer clearingDay);
+
+    List<ClearingRecordDTO> queryClearingRecordList(@Param("clearingPlanId") Integer clearingPlanId, @Param("buildingId") Integer buildingId,
+                                                    @Param("communityId") Integer communityId, @Param("customerIds") List<Integer> customerIds);
+
+    ClearingRecord findClearingRecordById(@Param("id") Integer id);
+
+    ClearingRecord findClearingRecordByAccoutPeriod(@Param("clearingPlanId") Integer clearingPlanId, @Param("accountPeriod") String accountPeriod);
+
     ClearingRecord findClearingRecordByAccoutPeriodAndCust(
-    			@Param("accountPeriod")String accountPeriod,
-    			@Param("custId")Integer custId);
-    
+            @Param("accountPeriod") String accountPeriod,
+            @Param("custId") Integer custId);
+
 }

+ 4 - 3
smart-city-platform/src/main/java/com/bz/smart_city/dao/CollectorMapper.java

@@ -6,7 +6,6 @@ import com.bz.smart_city.entity.Collector;
 
 import java.util.List;
 
-import io.swagger.models.auth.In;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -27,7 +26,8 @@ public interface CollectorMapper {
             @Param("cityId") Integer cityId,
             @Param("regionId") Integer regionId,
             @Param("communityId") Integer communityId,
-            @Param("buildingId") Integer buildingId);
+            @Param("buildingId") Integer buildingId,
+            @Param("customerIds") List<Integer> customerIds);
 
     List<Collector> findList(@Param("concentratorId") Integer concentratorId);
 
@@ -35,7 +35,8 @@ public interface CollectorMapper {
             @Param("siteId") Integer siteId,
             @Param("collectorNo") String collectorNo,
             @Param("serialNumber") String serialNumber,
-            @Param("address") String address);
+            @Param("address") String address,
+            @Param("customerIds") List<Integer> customerIds);
 
     Integer countByConcentratorId(@Param("concentratorId") Integer concentratorId);
 

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

@@ -20,7 +20,7 @@ public interface CommunityMapper {
 
     int updateByPrimaryKeySelective(@Param("community") Community community);
 
-    List<CommunityDto> findBySiteId(@Param("siteId") Integer siteId);
+    List<CommunityDto> findBySiteId(@Param("siteId") Integer siteId, @Param("customerIds") List<Integer> customerIds);
 
     List<CommunityDto> findByCustomerId(@Param("customerId") Integer customerId);
 
@@ -28,6 +28,8 @@ public interface CommunityMapper {
 
     List<CommunityDto> queryList(@Param("param") Community param);
 
+    List<CommunityDto> queryCommunity(@Param("param") Community param, @Param("customerIds") List<Integer> customerIds);
+
     int findByNameUnique(@Param("siteId") Integer siteId, @Param("id") Integer id, @Param("province") Integer province, @Param("city") Integer city, @Param("region") Integer region, @Param("name") String name);
 
     List<CommunityDto> getList(@Param("siteId") Integer siteId, @Param("customerId") Integer customerId, @Param("communityName") String communityName, @Param("province") Integer province, @Param("city") Integer city, @Param("region") Integer region);
@@ -45,5 +47,6 @@ public interface CommunityMapper {
     List<Community> getMaxCodeBySiteId(@Param("siteId") Integer siteId);
 
     List<CommunityDto> getListByCustomerIds(@Param("siteId") Integer siteId, @Param("customerIds") List<Integer> customerIds, @Param("communityName") String communityName, @Param("province") Integer province, @Param("city") Integer city, @Param("region") Integer region);
+
     AreaResponseData findCommunityByArea(AreaRequstData areaRequstData);
 }

+ 4 - 2
smart-city-platform/src/main/java/com/bz/smart_city/dao/ConcentratorMapper.java

@@ -27,7 +27,8 @@ public interface ConcentratorMapper {
             @Param("cityId") Integer cityId,
             @Param("regionId") Integer regionId,
             @Param("communityId") Integer communityId,
-            @Param("buildingId") Integer buildingId);
+            @Param("buildingId") Integer buildingId,
+            @Param("customerIds") List<Integer> customerIds);
 
     List<ConcentratorDto> findList(@Param("siteId") Integer siteId, @Param("serialNumber") String serialNumber);
 
@@ -36,7 +37,8 @@ public interface ConcentratorMapper {
             @Param("serialNumber") String serialNumber,
             @Param("deviceStatus") Integer deviceStatus,
             @Param("customerId") Integer customerId,
-            @Param("address") String address);
+            @Param("address") String address,
+            @Param("customerIds") List<Integer> customerIds);
 
     int findBySerialNumberUnique(@Param("id") Integer id, @Param("serialNumber") String serialNumber);
 

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

@@ -33,7 +33,7 @@ public interface DeviceMapper {
                             @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, @Param("issueStatus") Integer issueStatus, @Param("syncStatus") Integer syncStatus, @Param("sortColumn") String sortColumn, @Param("sortOrder") String sortOrder);
+                            @Param("registerStatus") Integer registerStatus, @Param("issueStatus") Integer issueStatus, @Param("syncStatus") Integer syncStatus, @Param("startReading") Double startReading, @Param("endReading") Double endReading, @Param("sortColumn") String sortColumn, @Param("sortOrder") String sortOrder);
 
     //按设备编号查询
     List<DeviceDto> getWaterMeterListByDeviceNo(@Param("deviceNo") String deviceNo, @Param("waterMeterNo") String waterMeterNo);

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

@@ -57,20 +57,20 @@ public interface StatMeterReadRateByBuildingMapper {
     WaterReadRateCountDto getRateCountByTime(
             @Param("siteId") Integer siteId,
             @Param("startDate") Integer startDate,
-            @Param("buildingIds") List<Integer> buildingIds
-    );
+            @Param("buildingIds") List<Integer> buildingIds,
+            @Param("customerIds") List<Integer> customerIds);
 
     WaterReadRateCountDto getRateCount7DayByTime(
             @Param("siteId") Integer siteId,
             @Param("startDate") Integer startDate,
-            @Param("buildingIds") List<Integer> buildingIds
-    );
+            @Param("buildingIds") List<Integer> buildingIds,
+            @Param("customerIds") List<Integer> customerIds);
 
     WaterReadRateCountDto getRateCount15DayByTime(
             @Param("siteId") Integer siteId,
             @Param("startDate") Integer startDate,
-            @Param("buildingIds") List<Integer> buildingIds
-    );
+            @Param("buildingIds") List<Integer> buildingIds,
+            @Param("customerIds") List<Integer> customerIds);
 
 
     List<WaterReadRateListDto> getRateListByType(
@@ -78,16 +78,16 @@ public interface StatMeterReadRateByBuildingMapper {
             @Param("sortColumn") String sortColumn,
             @Param("sortOrder") String sortOrder,
             @Param("startDate") Integer startDate,
-            @Param("buildingIds") List<Integer> buildingIds
-    );
+            @Param("buildingIds") List<Integer> buildingIds,
+            @Param("customerIds") List<Integer> customerIds);
 
     List<WaterReadRateListDto> getRateList7DayByType(
             @Param("siteId") Integer siteId,
             @Param("sortColumn") String sortColumn,
             @Param("sortOrder") String sortOrder,
             @Param("startDate") Integer startDate,
-            @Param("buildingIds") List<Integer> buildingIds
-    );
+            @Param("buildingIds") List<Integer> buildingIds,
+            @Param("customerIds") List<Integer> customerIds);
 
 
     List<WaterReadRateListDto> getRateList15DayByType(
@@ -95,8 +95,8 @@ public interface StatMeterReadRateByBuildingMapper {
             @Param("sortColumn") String sortColumn,
             @Param("sortOrder") String sortOrder,
             @Param("startDate") Integer startDate,
-            @Param("buildingIds") List<Integer> buildingIds
-    );
+            @Param("buildingIds") List<Integer> buildingIds,
+            @Param("customerIds") List<Integer> customerIds);
 
     @Deprecated
     Double getLast7DaysReadRate(
@@ -123,7 +123,7 @@ public interface StatMeterReadRateByBuildingMapper {
             @Param("buildingIds") List<Integer> buildingIds,
             @Param("channelId") Integer channelId,
             @Param("customerIds") List<Integer> customerIds
-            );
+    );
 
     List<WaterReadRateListDto> getRateListByCustomerV2AndDeviceType(
             @Param("tableName") String tableName,
@@ -162,7 +162,7 @@ public interface StatMeterReadRateByBuildingMapper {
             @Param("buildingIds") List<Integer> buildingIds,
             @Param("channelId") Integer channelId,
             @Param("customerIds") List<Integer> customerIds
-            );
+    );
 
     WaterReadRateCountDto getCount7DayByCustomer(
             @Param("siteId") Integer siteId,

+ 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, Integer registerStatus, Integer issueStatus, Integer syncStatus);
+    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, Integer issueStatus, Integer syncStatus, Double startReading, Double endReading);
 
     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);
 

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

@@ -20,6 +20,8 @@ public interface CommunityService {
 
     List<CommunityDto> queryList(Community community);
 
+    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);
 
     void addCommunity(@Param("communityDto") CommunityDto communityDto);

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

@@ -39,13 +39,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, Integer registerStatus, Integer issueStatus, Integer syncStatus, String sortColumn, String sortOrder, int pageNum, int pageSize);
+                                  Integer customerId, Integer days, Integer startDays, Integer endDays, Integer deviceTypeId, Integer valveStatus, Integer registerStatus, Integer issueStatus, Integer syncStatus, Double startReading, Double endReading, 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, Integer registerStatus, Integer issueStatus, Integer syncStatus, String sortColumn, String sortOrder, HttpServletResponse httpServletResponse);
+                            Integer customerId, Integer days, Integer startDays, Integer endDays, Integer deviceTypeId, Integer valveStatus, Integer registerStatus, Integer issueStatus, Integer syncStatus, Double startReading, Double endReading, String sortColumn, String sortOrder, HttpServletResponse httpServletResponse);
 
 
     void exportDeviceListAsXML(Integer sysId,

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

@@ -10,7 +10,7 @@ import com.bz.smart_city.dto.ClearingPlanDTO;
  * @date 2019年8月6日 下午9:00:41
  */
 public interface ClearingPlanService {
-	Pagination<ClearingPlanDTO> listClearingPlan(String queryName,int pageNum,int pageSize);
+	Pagination<ClearingPlanDTO> listClearingPlan(String queryName, int pageNum, int pageSize);
 	ClearingPlanDTO saveClearingPlan(ClearingPlanDTO dto);
 	ClearingPlanDTO editClearingPlan(ClearingPlanDTO dto);
 	int deleteClearingPlan(Integer planId);

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

@@ -11,7 +11,6 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
-import org.thymeleaf.util.LoggingUtils;
 
 import com.bz.smart_city.commom.exception.ServiceException;
 import com.bz.smart_city.commom.model.Pagination;
@@ -48,7 +47,7 @@ public class ClearingPlanServiceImpl implements ClearingPlanService {
 	public Pagination<ClearingPlanDTO> listClearingPlan(String queryName, int pageNum, int pageSize) {
 		LoginUser loginUser = UserUtil.getCurrentUser();
 		PageHelper.startPage(pageNum, pageSize);
-		List<ClearingPlanDTO> rtnList = clearingPlanMapper.quereyClearingPlanList(queryName,loginUser.getCurrentSiteId());
+		List<ClearingPlanDTO> rtnList = clearingPlanMapper.quereyClearingPlanList(queryName,loginUser.getCurrentSiteId(),UserUtil.getCustomerIds());
 		// 查询每个结算计划的表数量
 		for(ClearingPlanDTO clearingPlan : rtnList){
 			Integer deviceCount = clearingPlanDeviceService.countDeviceByClearingPlan(clearingPlan.getId());

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

@@ -1,5 +1,6 @@
 package com.bz.smart_city.service.clearing.impl;
 
+import com.bz.smart_city.commom.util.UserUtil;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
@@ -264,7 +265,7 @@ public class ClearingRecordServiceImpl implements ClearingRecordService{
 	public Pagination<ClearingRecordDTO> queryClearingRecordList(Integer clearingPlanId, Integer buildingId,
 			Integer communityId, int pageNum, int pageSize) {
     	PageHelper.startPage(pageNum, pageSize);
-    	List<ClearingRecordDTO> rtnList = clearingRecordMapper.queryClearingRecordList(clearingPlanId, buildingId, communityId);
+    	List<ClearingRecordDTO> rtnList = clearingRecordMapper.queryClearingRecordList(clearingPlanId, buildingId, communityId, UserUtil.getCustomerIds());
 		return new Pagination<ClearingRecordDTO>(rtnList);
 	}
     

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

@@ -112,7 +112,7 @@ public class BuildingServiceImpl implements BuildingService {
         //查询数据权限的建筑ids
         List<Integer> buildingIds = this.getIdsByDataPermission();
         //查询用户数据项下的建筑列表
-        List<Building> buildingList = buildingMapper.findBySiteIdAndProgramItem(loginUser.getSiteId(), channelId, buildingIds, null);
+        List<Building> buildingList = buildingMapper.findBySiteIdAndProgramItem(loginUser.getSiteId(), channelId, buildingIds, null,UserUtil.getCustomerIds());
 
         if (buildingList != null && buildingList.size() > 0) {
             buildingList.forEach(building -> {
@@ -212,7 +212,7 @@ public class BuildingServiceImpl implements BuildingService {
         List<Integer> buildingIds = this.getIdsByDataPermission();
         //查询用户数据项下的建筑列表
         PageHelper.startPage(1,10);
-        List<Building> buildingList = buildingMapper.findBySiteIdAndProgramItem(loginUser.getSiteId(), channelId, buildingIds, buildingName);
+        List<Building> buildingList = buildingMapper.findBySiteIdAndProgramItem(loginUser.getSiteId(), channelId, buildingIds, buildingName, UserUtil.getCustomerIds());
         if (buildingList != null && buildingList.size() > 0) {
             buildingList.forEach(building -> {
                 //设备关联上级父类,按小区、区、市、省关联,为空的往上一层关联
@@ -766,7 +766,7 @@ public class BuildingServiceImpl implements BuildingService {
         List<Integer> ids = newArrayList();
         List<Integer> communityIds = newArrayList();
         List<BuildingSelectDto> buildingSelectDtoArrayList = newArrayList();
-        List<Building> buildingList = buildingMapper.findBySiteId(loginUser.getSiteId(), sysId);
+        List<Building> buildingList = buildingMapper.findBySiteIdAndCustomerIds(loginUser.getSiteId(), sysId, UserUtil.getCustomerIds());
 
         if (buildingList != null && buildingList.size() > 0) {
             buildingList.forEach(building -> {
@@ -926,10 +926,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, Integer registerStatus, Integer issueStatus, Integer syncStatus) {
+    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, Integer issueStatus, Integer syncStatus, Double startReading, Double endReading) {
         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,registerStatus,issueStatus,syncStatus);
+        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,issueStatus,syncStatus,startReading,endReading);
 
         return this.areaList(buildingList);
     }
@@ -962,7 +962,7 @@ public class BuildingServiceImpl implements BuildingService {
         LoginUser loginUser = UserUtil.getCurrentUser();
 
         PageHelper.startPage(pageNum, pageSize);
-        List<BuildingInfoListDto> list = buildingMapper.getBuildingList(loginUser.getSiteId(), UserUtil.getCurrentSiteProgramItems(loginUser), sysId, buildingName, province, city, region, community);
+        List<BuildingInfoListDto> list = buildingMapper.getBuildingList(loginUser.getSiteId(), UserUtil.getCurrentSiteProgramItems(loginUser), sysId, buildingName, province, city, region, community, UserUtil.getCustomerIds());
         return new Pagination<>(list);
         //return null;
     }
@@ -997,7 +997,7 @@ public class BuildingServiceImpl implements BuildingService {
     @Override
     public List<BuildingInfoListDto> getAllList(Integer sysId) {
         LoginUser loginUser = UserUtil.getCurrentUser();
-        return buildingMapper.getBuildingList(loginUser.getSiteId(), null, sysId, null, null, null, null, null);
+        return buildingMapper.getBuildingList(loginUser.getSiteId(), null, sysId, null, null, null, null, null,UserUtil.getCustomerIds());
     }
 
     @Override

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

@@ -4,28 +4,19 @@ import com.alibaba.fastjson.JSON;
 import com.bz.smart_city.commom.exception.ServiceException;
 import com.bz.smart_city.commom.model.Pagination;
 import com.bz.smart_city.commom.model.ResultStatus;
-import com.bz.smart_city.commom.util.FileUtil;
 import com.bz.smart_city.commom.util.UserUtil;
 import com.bz.smart_city.dao.ConcentratorMapper;
 import com.bz.smart_city.dao.WaterRelatedDeviceMapper;
 import com.bz.smart_city.dto.*;
-import com.bz.smart_city.entity.Building;
 import com.bz.smart_city.entity.Concentrator;
-import com.bz.smart_city.entity.Customer;
 import com.bz.smart_city.excel.download.CollectorDownloadExcelTemplate;
 import com.bz.smart_city.service.BuildingService;
 import com.github.pagehelper.PageHelper;
 import lombok.extern.slf4j.Slf4j;
-import org.jxls.util.JxlsHelper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
-import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletResponse;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.net.URLEncoder;
 import java.time.LocalDateTime;
 import java.util.List;
 import com.bz.smart_city.dao.CollectorMapper;
@@ -68,7 +59,7 @@ public class CollectorServiceImpl implements CollectorService{
         PageHelper.startPage(pageNum,pageSize);
         List<CollectorDto> list = collectorMapper.getList(
                 loginUser.getSiteId(),collectorNo,serialNumber,address,
-                provinceId,cityId,regionId,communityId,buildingId
+                provinceId,cityId,regionId,communityId,buildingId,UserUtil.getCustomerIds()
         );
         return new Pagination<>(list);
     }
@@ -76,14 +67,14 @@ public class CollectorServiceImpl implements CollectorService{
     @Override
     public List<CollectorDto> getList(String collectorNo, String serialNumber) {
         LoginUser loginUser = UserUtil.getCurrentUser();
-        return collectorMapper.getList(loginUser.getSiteId(),collectorNo,serialNumber,null,null,null,null,null,null);
+        return collectorMapper.getList(loginUser.getSiteId(),collectorNo,serialNumber,null,null,null,null,null,null, UserUtil.getCustomerIds());
     }
 
     @Override
     public List<BuildingSelectDto> getAreaList(String collectorNo, String serialNumber, String address) {
         LoginUser loginUser = UserUtil.getCurrentUser();
         List<BuildingSelectInfoDto> buildingList = collectorMapper.getAreaList(
-                loginUser.getSiteId(),collectorNo,serialNumber,address);
+                loginUser.getSiteId(),collectorNo,serialNumber,address,UserUtil.getCustomerIds());
         return buildingService.areaList(buildingList);
     }
 
@@ -151,7 +142,7 @@ public class CollectorServiceImpl implements CollectorService{
 
     @Override
     public void test() {
-        List<CollectorDto> list = collectorMapper.getList(1,null,null,null,null,null,null,null,null);
+        List<CollectorDto> list = collectorMapper.getList(1,null,null,null,null,null,null,null,null, UserUtil.getCustomerIds());
         for (CollectorDto collectorDto : list) {
             Concentrator concentrator = concentratorMapper.findById(collectorDto.getConcentratorId());
             if (concentrator != null) {

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

@@ -42,7 +42,7 @@ public class CommunityServiceImpl implements CommunityService{
 	public List<BuildingSelectDto> regionSearch(Integer siteId , String name) {
         List<Integer> ids = newArrayList();
         List<BuildingSelectDto> buildingSelectDtoArrayList = newArrayList();
-        List<CommunityDto> communityList = communityMapper.findBySiteId(siteId);
+        List<CommunityDto> communityList = communityMapper.findBySiteId(siteId, null);
 
         if (communityList != null && communityList.size() > 0) {
             communityList.forEach(community -> {
@@ -109,6 +109,11 @@ public class CommunityServiceImpl implements CommunityService{
 		return communityMapper.queryList(community);
 	}
 
+    @Override
+    public List<CommunityDto> queryCommunity(Community community) {
+        return communityMapper.queryCommunity(community,UserUtil.getCustomerIds());
+    }
+
     @Override
     public Pagination<CommunityDto> getCommunityPage(String communityName, Integer province, Integer city, Integer region, int pageNum, int pageSize) {
         LoginUser loginUser = UserUtil.getCurrentUser();
@@ -230,7 +235,7 @@ public class CommunityServiceImpl implements CommunityService{
 
         List<CommunityDto> communityList =newArrayList();
         if (loginUser.getSiteType() != 2) {
-            communityList = communityMapper.findBySiteId(loginUser.getSiteId());
+            communityList = communityMapper.findBySiteId(loginUser.getSiteId(),UserUtil.getCustomerIds());
         }else {
             communityList = communityMapper.findByCustomerId(loginUser.getCustomerId());
         }

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

@@ -64,7 +64,7 @@ public class ConcentratorServiceImpl implements ConcentratorService{
         PageHelper.startPage(pageNum,pageSize);
         List<ConcentratorDto> list = concentratorMapper.getList(
                 loginUser.getSiteId(),serialNumber,deviceStatus,customerId,address,
-                provinceId,cityId,regionId,communityId,buildingId);
+                provinceId,cityId,regionId,communityId,buildingId,UserUtil.getCustomerIds());
         return new Pagination<>(list);
     }
 
@@ -80,7 +80,7 @@ public class ConcentratorServiceImpl implements ConcentratorService{
     public List<BuildingSelectDto> getAreaList(String serialNumber, Integer deviceStatus, Integer customerId, String address) {
         LoginUser loginUser = UserUtil.getCurrentUser();
         List<BuildingSelectInfoDto> buildingList = concentratorMapper.getAreaList(
-                loginUser.getSiteId(),serialNumber,deviceStatus,customerId,address);
+                loginUser.getSiteId(),serialNumber,deviceStatus,customerId,address,UserUtil.getCustomerIds());
         return buildingService.areaList(buildingList);
     }
 

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

@@ -13,7 +13,6 @@ import com.bz.smart_city.dto.assistant.InstallListDTO;
 import com.bz.smart_city.dto.assistant.PlanBuildingDTO;
 import com.bz.smart_city.dto.assistant.PlanCommunityDTO;
 import com.bz.smart_city.dto.udip.CommandRspNotifyResult;
-import com.bz.smart_city.dto.udip.DataCommandRequestDTO;
 import com.bz.smart_city.entity.*;
 import com.bz.smart_city.excel.download.GdDeviceDownloadExcelTemplate;
 import com.bz.smart_city.excel.download.GeneralDownloadExcelTemplate;
@@ -170,13 +169,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, Integer registerStatus, Integer issueStatus, Integer syncStatus, 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, Integer issueStatus, Integer syncStatus, Double startReading, Double endReading, 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, registerStatus, issueStatus, syncStatus, sortColumn, sortOrder);
+                days, startDays, endDays,deviceTypeId, valveStatus, registerStatus, issueStatus, syncStatus,startReading,endReading, sortColumn, sortOrder);
         return new Pagination<>(list);
     }
 
@@ -187,12 +186,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, Integer registerStatus, Integer issueStatus, Integer syncStatus, 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, 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, manufacturerId,
                 equipmentType, model, isTag, floor, locDesc, province, city, region, community, concentratorNo, collectorNo, errorType, customerId,
-                days, startDays, endDays, deviceTypeId, valveStatus, registerStatus, issueStatus, syncStatus, sortColumn, sortOrder);
+                days, startDays, endDays, deviceTypeId, valveStatus, registerStatus, issueStatus, syncStatus, startReading, endReading, sortColumn, sortOrder);
         String title = "设备列表";
         //判断是否是水表场景
         WMeterType wMeterType = wMeterTypeMapper.getChannelIdAndLevel(sysId, 2);

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

@@ -174,7 +174,7 @@ public class DimensionServiceImpl implements DimensionService{
         }
 
         //小区
-        List<CommunityDto> communityAreaList = communityMapper.findBySiteId(loginUser.getSiteId());
+        List<CommunityDto> communityAreaList = communityMapper.findBySiteId(loginUser.getSiteId(), null);
         if (communityAreaList != null && communityAreaList.size() > 0) {
             communityAreaList.forEach(community -> {
                 DimensionDataItemDto build = new DimensionDataItemDto();

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

@@ -9,8 +9,6 @@ import com.bz.smart_city.commom.util.ExcelUtil;
 import com.bz.smart_city.commom.util.TreeUtil;
 import com.bz.smart_city.commom.util.UserUtil;
 import com.bz.smart_city.dto.*;
-import com.bz.smart_city.dto.assistant.InstallPlanDataDTO;
-import com.bz.smart_city.entity.Customer;
 import com.bz.smart_city.service.BuildingService;
 import com.bz.smart_city.service.CustomerService;
 import com.github.pagehelper.PageHelper;
@@ -25,7 +23,6 @@ import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.Comparator;
 import java.util.List;
-import java.util.Objects;
 import java.util.stream.Collectors;
 
 import com.bz.smart_city.entity.StatMeterReadRateByBuilding;
@@ -252,11 +249,11 @@ public class StatMeterReadRateByBuildingServiceImpl implements StatMeterReadRate
         Integer startDate = Integer.valueOf(LocalDate.now().plusDays(-1).format(formatter));
 
         if (period == 2) {
-            return statMeterReadRateByBuildingMapper.getRateCountByTime(loginUser.getSiteId(), startDate, buildingIds);
+            return statMeterReadRateByBuildingMapper.getRateCountByTime(loginUser.getSiteId(), startDate, buildingIds, UserUtil.getCustomerIds());
         } else if (period == 7) {
-            return statMeterReadRateByBuildingMapper.getRateCount7DayByTime(loginUser.getSiteId(), startDate, buildingIds);
+            return statMeterReadRateByBuildingMapper.getRateCount7DayByTime(loginUser.getSiteId(), startDate, buildingIds, UserUtil.getCustomerIds());
         } else if (period == 15) {
-            return statMeterReadRateByBuildingMapper.getRateCount15DayByTime(loginUser.getSiteId(), startDate, buildingIds);
+            return statMeterReadRateByBuildingMapper.getRateCount15DayByTime(loginUser.getSiteId(), startDate, buildingIds, UserUtil.getCustomerIds());
         }
         return null;
 
@@ -276,11 +273,11 @@ public class StatMeterReadRateByBuildingServiceImpl implements StatMeterReadRate
 
         List<WaterReadRateListDto> waterReadRateListDtoList = newArrayList();
         if (period == 2) {
-            waterReadRateListDtoList = statMeterReadRateByBuildingMapper.getRateListByType(loginUser.getSiteId(), sortColumn, sortOrder, startDate, buildingIds);
+            waterReadRateListDtoList = statMeterReadRateByBuildingMapper.getRateListByType(loginUser.getSiteId(), sortColumn, sortOrder, startDate, buildingIds, UserUtil.getCustomerIds());
         } else if (period == 7) {
-            waterReadRateListDtoList = statMeterReadRateByBuildingMapper.getRateList7DayByType(loginUser.getSiteId(), sortColumn, sortOrder, startDate, buildingIds);
+            waterReadRateListDtoList = statMeterReadRateByBuildingMapper.getRateList7DayByType(loginUser.getSiteId(), sortColumn, sortOrder, startDate, buildingIds, UserUtil.getCustomerIds());
         } else if (period == 15) {
-            waterReadRateListDtoList = statMeterReadRateByBuildingMapper.getRateList15DayByType(loginUser.getSiteId(), sortColumn, sortOrder, startDate, buildingIds);
+            waterReadRateListDtoList = statMeterReadRateByBuildingMapper.getRateList15DayByType(loginUser.getSiteId(), sortColumn, sortOrder, startDate, buildingIds, UserUtil.getCustomerIds());
         }
         return waterReadRateListDtoList;
     }
@@ -299,11 +296,11 @@ public class StatMeterReadRateByBuildingServiceImpl implements StatMeterReadRate
 
         List<WaterReadRateListDto> waterReadRateListDtoList = newArrayList();
         if (period == 2) {
-            waterReadRateListDtoList = statMeterReadRateByBuildingMapper.getRateListByType(loginUser.getSiteId(), null, null, startDate, buildingIds);
+            waterReadRateListDtoList = statMeterReadRateByBuildingMapper.getRateListByType(loginUser.getSiteId(), null, null, startDate, buildingIds, UserUtil.getCustomerIds());
         } else if (period == 7) {
-            waterReadRateListDtoList = statMeterReadRateByBuildingMapper.getRateList7DayByType(loginUser.getSiteId(), null, null, startDate, buildingIds);
+            waterReadRateListDtoList = statMeterReadRateByBuildingMapper.getRateList7DayByType(loginUser.getSiteId(), null, null, startDate, buildingIds, UserUtil.getCustomerIds());
         } else if (period == 15) {
-            waterReadRateListDtoList = statMeterReadRateByBuildingMapper.getRateList15DayByType(loginUser.getSiteId(), null, null, startDate, buildingIds);
+            waterReadRateListDtoList = statMeterReadRateByBuildingMapper.getRateList15DayByType(loginUser.getSiteId(), null, null, startDate, buildingIds, UserUtil.getCustomerIds());
         }
 
 

+ 38 - 9
smart-city-platform/src/main/resources/mapper/BuildingMapper.xml

@@ -551,16 +551,40 @@
         </if>
     </select>
 
+    <select id="findBySiteIdAndCustomerIds" resultMap="BaseResultMap">
+        select
+        b.id,
+        b.name,
+        b.province,
+        b.city,
+        b.region,
+        b.community
+        from sc_building b
+        left join sc_community c on(c.id = b.community)
+        where b.status = 1
+        <if test="siteId != null"> and b.site_id=#{siteId} </if>
+        <if test="sysId != null">
+            and b.id in( SELECT sc_device.building_id FROM sc_device  WHERE sc_device.status = 1 <if test="siteId != null"> and sc_device.site_id=#{siteId} </if> and sc_device.sys_id = #{sysId}  GROUP BY sc_device.building_id)
+        </if>
+        <if test="customerIds != null and customerIds.size() != 0">
+            and c.customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
+        </if>
+    </select>
+
     <select id="findBySiteIdAndProgramItem" resultMap="BaseResultMap">
         select
-        id,name,province,city,region,community,longitude,latitude
-        from sc_building
-        where status = 1
-        <if test="siteId != null"> and site_id=#{siteId} </if>
-        <if test="buildingIds != null and buildingIds.size() != 0"> and id in <foreach collection="buildingIds" item="item" open="(" separator="," close=")">#{item}</foreach> </if>
-        <if test="sysId != null"> and id in (select sd.building_id from sc_device sd where sd.status = 1 and 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 name LIKE concat('%',#{buildingName},'%')</if>
-        order by name asc
+        sb.id,sb.name,sb.province,sb.city,sb.region,sb.community,sb.longitude,sb.latitude
+        from sc_building sb
+        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="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>
+        <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.name asc
     </select>
 
     <select id="findBuildingCountDeviceNum" resultType="com.bz.smart_city.dto.BuildingSelectInfoDto">
@@ -733,6 +757,9 @@
         <if test="city != null"> AND sb.city = #{city}</if>
         <if test="region != null"> AND sb.region = #{region}</if>
         <if test="community != null"> AND sb.community = #{community}</if>
+        <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
     </select>
 
@@ -996,7 +1023,7 @@
             <if test="(concentratorNo != null and concentratorNo != '') or (collectorNo != null and collectorNo != '') or issueStatus != null">left join sc_water_related_device swrd on ( swrd.device_id = sd.id and swrd.status = 1)</if>
             <if test="concentratorNo != null and concentratorNo != ''">left join sc_concentrator scon on ( scon.id = swrd.concentrator_id and scon.status = 1)</if>
             <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="(errorType != null and errorType != '') or days != null or startDays != null or endDays != null or (valveStatus != null) or startReading != null or endReading != 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 <![CDATA[ <> ]]> -99
             <!--and sd.site_id = 1-->
@@ -1023,6 +1050,8 @@
             <if test="days != null"> and swmed.days = #{days} </if>
             <if test="startDays != null"> and swmed.days >= #{startDays} </if>
             <if test="endDays != null"> and swmed.days <![CDATA[ <= ]]> #{endDays} </if>
+            <if test="startReading != null"> and swmed.meter_reading >= #{startReading} </if>
+            <if test="endReading != null"> and swmed.meter_reading <![CDATA[ <= ]]> #{endReading} </if>
             <if test="valveStatus != null and valveStatus == 0"> and swmed.valve_status = #{valveStatus} and sdt.is_valve = 1</if>
             <if test="valveStatus != null and valveStatus == 1"> and (swmed.valve_status = #{valveStatus} or swmed.valve_status is null ) and sdt.is_valve = 1</if>
             <if test="valveStatus != null and valveStatus == 2"> and sdt.is_valve = 0</if>

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

@@ -199,6 +199,10 @@
 			<if test="siteId != null">
 				AND site_id = #{siteId}
 			</if>
+          <if test="customerIds != null and customerIds.size() != 0">
+              and  clearing_customer in
+              <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item} </foreach>
+          </if>
 		) tmp 
 	WHERE
 		1 = 1 
@@ -240,6 +244,10 @@
 			<if test="siteId != null">
 				AND site_id = #{siteId}
 			</if>
+              <if test="customerIds != null and customerIds.size() != 0">
+                  and  clearing_customer in
+                  <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item} </foreach>
+              </if>
 		) tmp 
 	WHERE
 		1 = 1 

+ 4 - 0
smart-city-platform/src/main/resources/mapper/ClearingRecordMapper.xml

@@ -186,6 +186,10 @@
 	<if test="communityId != null and communityId != 0">
 		and FIND_IN_SET(#{communityId},cp.clearing_community)
 	</if>
+      <if test="customerIds != null and customerIds.size() != 0">
+          and  cp.clearing_customer in
+          <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item} </foreach>
+      </if>
   </select>
   <select id="findClearingRecordById" resultMap="BaseResultMap">
   	select

+ 6 - 0
smart-city-platform/src/main/resources/mapper/CollectorMapper.xml

@@ -193,6 +193,9 @@
     <if test="regionId != null"> and sb.region = #{regionId}</if>
     <if test="communityId != null"> and sb.community = #{communityId}</if>
     <if test="buildingId != null"> and sb.id = #{buildingId}</if>
+    <if test="customerIds != null and customerIds.size() != 0">
+      and soll.customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
+    </if>
     order by soll.date_create desc
   </select>
   <select id="findList" resultType="com.bz.smart_city.entity.Collector">
@@ -220,6 +223,9 @@
     <if test="collectorNo != null and collectorNo != ''"> and soll.collector_no LIKE concat('%',#{collectorNo},'%')</if>
     <if test="serialNumber != null and serialNumber != ''"> and scon.serial_number LIKE concat('%',#{serialNumber},'%')</if>
     <if test="address != null and address != ''"> and soll.address LIKE concat('%',#{address},'%')</if>
+    <if test="customerIds != null and customerIds.size() != 0">
+      and soll.customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
+    </if>
     GROUP BY soll.building_id
     ) t1 on (t1.building_id = b.id)
     where b.status = 1

+ 33 - 0
smart-city-platform/src/main/resources/mapper/CommunityMapper.xml

@@ -253,6 +253,9 @@
         left join sc_area sa3 on   sc.region=sa3.id
         where sc.status = 1
         <if test="siteId != null"> and sc.site_id = #{siteId} </if>
+        <if test="customerIds != null and customerIds.size() != 0">
+            and customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
+        </if>
     </select>
 
     <select id="findByCustomerId" resultType="com.bz.smart_city.dto.CommunityDto">
@@ -301,6 +304,36 @@
         <if test="param.id != null"> and sc.id = #{param.id}</if>
         <if test="param.name != null and param.name != '' "> and sc.name like #{param.name}</if>
     </select>
+
+    <select id="queryCommunity" resultType="com.bz.smart_city.dto.CommunityDto">
+        select
+        sc.id as id,
+        sc.name as name ,
+        sc.code as code,
+        sc.province as province,
+        sc.city as city,
+        sc.region as region,
+        sc.longitude as longitude,
+        sc.latitude as latitude,
+        sc.address as address,
+        sa1.name as province_name,
+        sa2.name as city_name,
+        sa3.name as region_name
+        from sc_community sc
+        left join sc_area sa1 on   sc.province =sa1.id
+        left join sc_area sa2 on   sc.city=sa2.id
+        left join sc_area sa3 on   sc.region=sa3.id
+        where sc.status = 1
+        <if test="param.customerId != null and param.customerId != 0 "> and sc.customer_id = #{param.customerId} </if>
+        <if test="param.province != null"> and sc.province = #{param.province} </if>
+        <if test="param.city != null"> and sc.city = #{param.city} </if>
+        <if test="param.region != null"> and sc.region = #{param.region} </if>
+        <if test="param.id != null"> and sc.id = #{param.id}</if>
+        <if test="param.name != null and param.name != '' "> and sc.name like #{param.name}</if>
+        <if test="customerIds != null and customerIds.size() != 0">
+            and sc.customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
+        </if>
+    </select>
     <select id="getList" resultType="com.bz.smart_city.dto.CommunityDto">
         select <include refid="General_Column_List"></include>,
         sa1.name as province_name,

+ 6 - 0
smart-city-platform/src/main/resources/mapper/ConcentratorMapper.xml

@@ -281,6 +281,9 @@
         <if test="regionId != null"> and sb.region = #{regionId}</if>
         <if test="communityId != null"> and sb.community = #{communityId}</if>
         <if test="buildingId != null"> and sb.id = #{buildingId}</if>
+        <if test="customerIds != null and customerIds.size() != 0">
+          and customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
+        </if>
         order by scon.date_create desc
   </select>
 
@@ -314,6 +317,9 @@
     <if test="deviceStatus != null"> and scon.device_status = #{deviceStatus}</if>
     <if test="customerId != null"> and scon.customer_id = #{customerId}</if>
     <if test="address != null and address != ''"> and scon.address LIKE concat('%',#{address},'%')</if>
+    <if test="customerIds != null and customerIds.size() != 0">
+      and scon.customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
+    </if>
     GROUP BY scon.building_id
     ) t1 on (t1.building_id = b.id)
     where b.status = 1

+ 5 - 1
smart-city-platform/src/main/resources/mapper/DeviceMapper.xml

@@ -406,6 +406,8 @@
         <if test="registerStatus != null"> and sd.register_status = #{registerStatus}</if>
         <if test="issueStatus != null"> and swrd.issue_status = #{issueStatus}</if>
         <if test="syncStatus != null"> and sd.sync_status = #{syncStatus}</if>
+        <if test="startReading != null"> and swmed.meter_reading >= #{startReading} </if>
+        <if test="endReading != null"> and swmed.meter_reading <![CDATA[ <= ]]> #{endReading} </if>
         <if test="days != null">
             <choose>
                 <when test="days == 0">
@@ -439,7 +441,7 @@
         <if test="(concentratorNo != null and concentratorNo != '') or (collectorNo != null and collectorNo != '') or issueStatus != null">left join sc_water_related_device swrd on ( swrd.device_id = sd.id and swrd.status = 1)</if>
         <if test="concentratorNo != null and concentratorNo != ''">left join sc_concentrator scon on ( scon.id = swrd.concentrator_id and scon.status = 1)</if>
         <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="(errorType != null and errorType != '') or days != null or startDays != null or endDays != null or (valveStatus != null) or startReading != null or endReading != 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
         <if test="sysId != null"> AND sd.sys_id = #{sysId}</if>
@@ -468,6 +470,8 @@
         <if test="registerStatus != null"> and sd.register_status = #{registerStatus}</if>
         <if test="issueStatus != null"> and swrd.issue_status = #{issueStatus}</if>
         <if test="syncStatus != null"> and sd.sync_status = #{syncStatus}</if>
+        <if test="startReading != null"> and swmed.meter_reading >= #{startReading} </if>
+        <if test="endReading != null"> and swmed.meter_reading <![CDATA[ <= ]]> #{endReading} </if>
         <if test="days != null">
             <choose>
                 <when test="days == 0">

+ 31 - 8
smart-city-platform/src/main/resources/mapper/StatMeterReadRateByBuildingMapper.xml

@@ -292,6 +292,7 @@
         SELECT
         (select SUM(device_count) from sc_stat_meter_read_rate_by_building where 1 = 1 <if test="siteId != null"> and site_id = #{siteId} </if>
         <if test="buildingIds != null and buildingIds.size() != 0"> and building_id in <foreach collection="buildingIds" item="item" open="(" separator="," close=")">#{item}</foreach> </if>
+        <if test="customerIds != null and customerIds.size() != 0"> and customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach> </if>
         GROUP BY stat_day desc limit 1) as device_count,
         SUM(read_times) as read_times,
         SUM(real_read_times) as real_read_times,
@@ -303,6 +304,7 @@
         AND b.`status` = 1
         <if test="siteId != null"> and a.site_id = #{siteId} </if>
         <if test="buildingIds != null and buildingIds.size() != 0"> and a.building_id in <foreach collection="buildingIds" item="item" open="(" separator="," close=")">#{item}</foreach> </if>
+        <if test="customerIds != null and customerIds.size() != 0"> and a.customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach> </if>
     </select>
 
     <!--按表类型查询7天内的抄表率数据统计-->
@@ -310,6 +312,7 @@
         SELECT
         (select SUM(device_count) from sc_stat_meter_read_rate_by_building_7day where 1 = 1 <if test="siteId != null"> and site_id = #{siteId} </if>
         <if test="buildingIds != null and buildingIds.size() != 0"> and building_id in <foreach collection="buildingIds" item="item" open="(" separator="," close=")">#{item}</foreach> </if>
+        <if test="customerIds != null and customerIds.size() != 0"> and customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach> </if>
         GROUP BY stat_day desc limit 1) as device_count,
         SUM(read_times) as read_times,
         SUM(real_read_times) as real_read_times,
@@ -321,6 +324,7 @@
         AND b.`status` = 1
         <if test="siteId != null"> and a.site_id = #{siteId} </if>
         <if test="buildingIds != null and buildingIds.size() != 0"> and a.building_id in <foreach collection="buildingIds" item="item" open="(" separator="," close=")">#{item}</foreach> </if>
+        <if test="customerIds != null and customerIds.size() != 0"> and a.customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach> </if>
     </select>
 
 
@@ -329,6 +333,7 @@
         SELECT
         (select SUM(device_count) from sc_stat_meter_read_rate_by_building_15day where 1 = 1 <if test="siteId != null"> and site_id = #{siteId} </if>
         <if test="buildingIds != null and buildingIds.size() != 0"> and building_id in <foreach collection="buildingIds" item="item" open="(" separator="," close=")">#{item}</foreach> </if>
+        <if test="customerIds != null and customerIds.size() != 0"> and customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach> </if>
         GROUP BY stat_day desc limit 1) as device_count,
         SUM(read_times) as read_times,
         SUM(real_read_times) as real_read_times,
@@ -340,15 +345,18 @@
         AND b.`status` = 1
         <if test="siteId != null"> and a.site_id = #{siteId} </if>
         <if test="buildingIds != null and buildingIds.size() != 0"> and a.building_id in <foreach collection="buildingIds" item="item" open="(" separator="," close=")">#{item}</foreach> </if>
+        <if test="customerIds != null and customerIds.size() != 0"> and a.customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach> </if>
     </select>
 
     <!--查询时间范围内根据表类型的抄表率数据统计-->
     <select id="getRateListByType" resultType="com.bz.smart_city.dto.WaterReadRateListDto">
+        select * from (
         SELECT
             swmt.channel_id,
             sdt.equipment_type as device_type_name,
             (select SUM(device_count) from sc_stat_meter_read_rate_by_building where channel_id = swmt.channel_id <if test="siteId != null"> and site_id = #{siteId} </if>
             <if test="buildingIds != null and buildingIds.size() != 0"> and building_id in <foreach collection="buildingIds" item="item" open="(" separator="," close=")">#{item}</foreach> </if>
+            <if test="customerIds != null and customerIds.size() != 0"> and customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach> </if>
             GROUP BY stat_day desc limit 1) as device_count,
             SUM(ssmrrbb.read_times) as read_times,
             SUM(ssmrrbb.real_read_times) as real_read_times,
@@ -359,6 +367,7 @@
             ssmrrbb.channel_id = swmt.channel_id  <if test="siteId != null"> and ssmrrbb.site_id = #{siteId} </if>
             and ssmrrbb.stat_day =  #{startDate}
             <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>
             )
         left join sc_device_type sdt on (sdt.id = swmt.device_type_id)
         WHERE swmt.`level` = 2
@@ -368,15 +377,21 @@
                 order by ${sortColumn} ${sortOrder}
             </if>
         </if>
+        ) t1
+        where t1.device_count is not null
     </select>
 
     <!--查询7天内根据表类型的抄表率数据统计-->
     <select id="getRateList7DayByType" resultType="com.bz.smart_city.dto.WaterReadRateListDto">
-        SELECT
-        swmt.channel_id,
-        sdt.equipment_type as device_type_name,
-        (select SUM(device_count) from sc_stat_meter_read_rate_by_building_7day where channel_id = swmt.channel_id <if test="siteId != null"> and site_id = #{siteId} </if>
+        <if test="siteId != null">select * from (
+            SELECT
+            swmt.channel_id,
+            sdt.equipment_type as device_type_name,
+            (select SUM(device_count) from sc_stat_meter_read_rate_by_building_7day where channel_id =
+            swmt.channel_idand site_id = #{siteId}
+        </if>
         <if test="buildingIds != null and buildingIds.size() != 0"> and building_id in <foreach collection="buildingIds" item="item" open="(" separator="," close=")">#{item}</foreach> </if>
+        <if test="customerIds != null and customerIds.size() != 0"> and customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach> </if>
         GROUP BY stat_day desc limit 1) as device_count,
         SUM(ssmrrbb.read_times) as read_times,
         SUM(ssmrrbb.real_read_times) as real_read_times,
@@ -387,6 +402,7 @@
         ssmrrbb.channel_id = swmt.channel_id  <if test="siteId != null"> and ssmrrbb.site_id = #{siteId} </if>
         and ssmrrbb.stat_day =  #{startDate}
         <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>
         )
         left join sc_device_type sdt on (sdt.id = swmt.device_type_id)
         WHERE swmt.`level` = 2
@@ -396,16 +412,21 @@
                 order by ${sortColumn} ${sortOrder}
             </if>
         </if>
+        ) t1 where t1.device_count is not null
     </select>
 
 
     <!--查询15天内根据表类型的抄表率数据统计-->
     <select id="getRateList15DayByType" resultType="com.bz.smart_city.dto.WaterReadRateListDto">
-        SELECT
-        swmt.channel_id,
-        sdt.equipment_type as device_type_name,
-        (select SUM(device_count) from sc_stat_meter_read_rate_by_building_15day where channel_id = swmt.channel_id <if test="siteId != null"> and site_id = #{siteId} </if>
+        <if test="siteId != null">select * from (
+            SELECT
+            swmt.channel_id,
+            sdt.equipment_type as device_type_name,
+            (select SUM(device_count) from sc_stat_meter_read_rate_by_building_15day where channel_id =
+            swmt.channel_idand site_id = #{siteId}
+        </if>
         <if test="buildingIds != null and buildingIds.size() != 0"> and building_id in <foreach collection="buildingIds" item="item" open="(" separator="," close=")">#{item}</foreach> </if>
+        <if test="customerIds != null and customerIds.size() != 0"> and customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach> </if>
         GROUP BY stat_day desc limit 1) as device_count,
         SUM(ssmrrbb.read_times) as read_times,
         SUM(ssmrrbb.real_read_times) as real_read_times,
@@ -416,6 +437,7 @@
         ssmrrbb.channel_id = swmt.channel_id  <if test="siteId != null"> and ssmrrbb.site_id = #{siteId} </if>
         and ssmrrbb.stat_day =  #{startDate}
         <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>
         )
         left join sc_device_type sdt on (sdt.id = swmt.device_type_id)
         WHERE swmt.`level` = 2
@@ -425,6 +447,7 @@
                 order by ${sortColumn} ${sortOrder}
             </if>
         </if>
+        ) t1 where t1.device_count is not null
     </select>
 
     <!--查询最近7天抄表率-->

+ 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, 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, 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, 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, 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, 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, null, null, null,null);
 
         for (int i = 0; i < 105; i++) {
             DeviceDto d = devices.get(getRandom(devices.size()));