Browse Source

客户抄表率

lin 4 years ago
parent
commit
6b13cd9756

+ 2 - 2
smart-city-platform/src/main/java/com/bz/smart_city/async/AsyncInstallPlanDownloadTask.java

@@ -185,7 +185,7 @@ public class AsyncInstallPlanDownloadTask {
                 }
             }
 
-            InputStream in = this.getClass().getClassLoader().getResourceAsStream("excel/installPlanTemplate20200709.xlsx");   //得到文档的路径
+            InputStream in = this.getClass().getClassLoader().getResourceAsStream("excel/installPlanTemplate20200716.xlsx");   //得到文档的路径
 
             //列表数据将存储到指定的excel文件路径
             FileOutputStream out = new FileOutputStream(filePath);
@@ -243,7 +243,7 @@ public class AsyncInstallPlanDownloadTask {
             //5、获取安装计划清单数据
 
 
-            InputStream in = this.getClass().getClassLoader().getResourceAsStream("excel/installPlanTemplate20200709.xlsx");   //得到文档的路径
+            InputStream in = this.getClass().getClassLoader().getResourceAsStream("excel/installPlanTemplate20200716.xlsx");   //得到文档的路径
 
             //列表数据将存储到指定的excel文件路径
             FileOutputStream out = new FileOutputStream(filePath);

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

@@ -49,4 +49,6 @@ public interface CustomerMapper {
     Integer countChildrenNum(@Param("customerId") Integer customerId);
 
     List<Integer> findSubIds(@Param("customerId") Integer customerId);
+
+    List<Integer> findAllSubIds(@Param("customerId") Integer customerId);
 }

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

@@ -161,7 +161,7 @@ public interface StatMeterReadRateByBuildingMapper {
             @Param("startDate") Integer startDate,
             @Param("buildingIds") List<Integer> buildingIds,
             @Param("channelId") Integer channelId,
-            @Param("customerId") Integer customerId
+            @Param("customerIds") List<Integer> customerIds
             );
 
     WaterReadRateCountDto getCount7DayByCustomer(

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

@@ -49,4 +49,7 @@ public interface CustomerService {
 
     /*获取子类ID*/
     List<Integer> findSubIds(Integer customerId);
+
+    /*获取所有子类ID*/
+    List<Integer> findAllSubIds(Integer customerId);
 }

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

@@ -240,4 +240,9 @@ public class CustomerServiceImpl implements CustomerService {
     public List<Integer> findSubIds(Integer customerId) {
         return customerMapper.findSubIds(customerId);
     }
+
+    @Override
+    public List<Integer> findAllSubIds(Integer customerId) {
+        return customerMapper.findAllSubIds(customerId);
+    }
 }

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

@@ -333,7 +333,7 @@ public class StatMeterReadRateByBuildingServiceImpl implements StatMeterReadRate
 
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
         //Integer startDate = Integer.valueOf(LocalDate.now().plusDays(-1).format(formatter));
-        Integer startDate = 20200619;
+        Integer startDate = 20200317;
 
 
         List<CustomerRateDto> customerRateDtoList = newArrayList();
@@ -349,6 +349,8 @@ public class StatMeterReadRateByBuildingServiceImpl implements StatMeterReadRate
             PageHelper.startPage(pageNum, pageSize);
             customerRateDtoList = statMeterReadRateByBuildingMapper.getRateListByCustomerV2("sc_stat_meter_read_rate_by_building_15day",loginUser.getSiteId(), startDate, buildingIds,channelId,customerIds);
         }else if (period == 99) {// 上个月,查询15天表
+            DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMM");
+            startDate = Integer.parseInt(LocalDateTime.now().plusMonths(-1).format(df));
             PageHelper.startPage(pageNum, pageSize);
             customerRateDtoList = statMeterReadRateByBuildingMapper.getRateListByCustomerV2("sc_stat_meter_read_rate_by_building_month",loginUser.getSiteId(), startDate, buildingIds,channelId,customerIds);
         }
@@ -373,7 +375,7 @@ public class StatMeterReadRateByBuildingServiceImpl implements StatMeterReadRate
 
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
         //Integer startDate = Integer.valueOf(LocalDate.now().plusDays(-1).format(formatter));
-        Integer startDate = 20200619;
+        Integer startDate = 20200317;
 
 
         List<CustomerRateDto> customerRateDtoList = newArrayList();
@@ -384,6 +386,8 @@ public class StatMeterReadRateByBuildingServiceImpl implements StatMeterReadRate
         } 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天表
+            DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMM");
+            startDate = Integer.parseInt(LocalDateTime.now().plusMonths(-1).format(df));
             customerRateDtoList = statMeterReadRateByBuildingMapper.getRateListByCustomerV2("sc_stat_meter_read_rate_by_building_month",loginUser.getSiteId(), startDate, buildingIds,channelId,subIds);
         }
         if (customerRateDtoList != null && customerRateDtoList.size()>0) {
@@ -444,21 +448,26 @@ public class StatMeterReadRateByBuildingServiceImpl implements StatMeterReadRate
         //1、查询数据权限的建筑ids
         List<Integer> buildingIds = buildingService.getIdsByDataPermission();
 
+        List<Integer> customerIds = newArrayList();
+        if (channelId != null) {
+            customerIds = customerService.findAllSubIds(customerId);
+        }
+
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
         //Integer startDate = Integer.valueOf(LocalDate.now().plusDays(-1).format(formatter));
-        Integer startDate = 20200619;
+        Integer startDate = 20200317;
 
-        //2、根据数据项查询客户
-        //List<Customer> customerList = customerService.getCustomerListByItem(loginUser.getSiteId(), buildingIds, null);
 
         if (period == 2) {
-            return statMeterReadRateByBuildingMapper.getCountByCustomerV2("sc_stat_meter_read_rate_by_building",loginUser.getSiteId(), startDate, buildingIds, channelId, customerId);
+            return statMeterReadRateByBuildingMapper.getCountByCustomerV2("sc_stat_meter_read_rate_by_building",loginUser.getSiteId(), startDate, buildingIds, channelId, customerIds);
         } else if (period == 7) {
-            return statMeterReadRateByBuildingMapper.getCountByCustomerV2("sc_stat_meter_read_rate_by_building_7day",loginUser.getSiteId(), startDate, buildingIds, channelId, customerId);
+            return statMeterReadRateByBuildingMapper.getCountByCustomerV2("sc_stat_meter_read_rate_by_building_7day",loginUser.getSiteId(), startDate, buildingIds, channelId, customerIds);
         } else if (period == 15) {
-            return statMeterReadRateByBuildingMapper.getCountByCustomerV2("sc_stat_meter_read_rate_by_building_15day",loginUser.getSiteId(), startDate, buildingIds, channelId, customerId);
+            return statMeterReadRateByBuildingMapper.getCountByCustomerV2("sc_stat_meter_read_rate_by_building_15day",loginUser.getSiteId(), startDate, buildingIds, channelId, customerIds);
         } else if (period == 99) {
-            return statMeterReadRateByBuildingMapper.getCountByCustomerV2("sc_stat_meter_read_rate_by_building_month",loginUser.getSiteId(), startDate, buildingIds, channelId, customerId);
+            DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMM");
+            startDate = Integer.parseInt(LocalDateTime.now().plusMonths(-1).format(df));
+            return statMeterReadRateByBuildingMapper.getCountByCustomerV2("sc_stat_meter_read_rate_by_building_month",loginUser.getSiteId(), startDate, buildingIds, channelId, customerIds);
         }
         return null;
     }

BIN
smart-city-platform/src/main/resources/excel/installPlanTemplate20200716.xlsx


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

@@ -301,6 +301,23 @@
         select id from sc_customer where status = 1 and parent_id = #{customerId}
     </select>
 
+    <select id="findAllSubIds" resultType="java.lang.Integer">
+        SELECT  DATA.id FROM(
+            SELECT
+                @ids as _ids,
+                (   SELECT @ids := GROUP_CONCAT(id)
+                    FROM sc_customer
+                    WHERE FIND_IN_SET(parent_id, @ids)
+                ) as cids,
+                @l := @l+1 as level
+            FROM sc_customer,
+                (SELECT @ids :=#{customerId}, @l := 0 ) b
+            WHERE @ids IS NOT NULL
+        ) id, sc_customer DATA
+        WHERE FIND_IN_SET(DATA.id, ID._ids)
+        ORDER BY level, id;
+    </select>
+
 
 </mapper>
 

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

@@ -630,8 +630,8 @@
         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>
+        <if test="customerIds != null and customerIds.size() != 0"> and customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach> </if>
     </select>
 
     <!--按客户查询时间范围内的抄表率数据统计-->