Browse Source

今日抄表率及按集中器抄表率需求提交By PengDi@2020/12/31

pengdi@zoniot.com 4 years ago
parent
commit
41c87a7cff
16 changed files with 784 additions and 763 deletions
  1. 32 0
      smart-city-platform/src/main/java/com/bz/smart_city/commom/constant/MeterReadPeriod.java
  2. 3 1
      smart-city-platform/src/main/java/com/bz/smart_city/commom/model/CommonQueryCondition.java
  3. 216 683
      smart-city-platform/src/main/java/com/bz/smart_city/controller/water/WaterMeterReadController.java
  4. 2 0
      smart-city-platform/src/main/java/com/bz/smart_city/dao/MeterReadRecordMapper.java
  5. 4 0
      smart-city-platform/src/main/java/com/bz/smart_city/dao/StatMeterReadRateByBuildingMapper.java
  6. 63 2
      smart-city-platform/src/main/java/com/bz/smart_city/dao/StatMeterReadRateByConcentratorMapper.java
  7. 4 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/StatMeterReadRateDto.java
  8. 3 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/UdipUnitDTO.java
  9. 1 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/DeviceDataPushServiceImpl.java
  10. 61 35
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/StatMeterReadRateByBuildingServiceImpl.java
  11. 52 29
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/StatMeterReadRateByConcentratorServiceImpl.java
  12. 1 1
      smart-city-platform/src/main/resources/application.properties
  13. 34 1
      smart-city-platform/src/main/resources/mapper/MeterReadRecordMapper.xml
  14. 108 1
      smart-city-platform/src/main/resources/mapper/StatMeterReadRateByBuildingMapper.xml
  15. 198 8
      smart-city-platform/src/main/resources/mapper/StatMeterReadRateByConcentratorMapper.xml
  16. 2 2
      smart-city-platform/src/test/java/com/bz/smart_city/DeviceDataPushServiceTest.java

+ 32 - 0
smart-city-platform/src/main/java/com/bz/smart_city/commom/constant/MeterReadPeriod.java

@@ -0,0 +1,32 @@
+package com.bz.smart_city.commom.constant;
+
+/**
+ * <p>抄表率查询周期</p>
+ *
+ * @Author wilian.peng
+ * @Date 2020/12/29 20:28
+ * @Version 1.0
+ */
+public class MeterReadPeriod {
+    /**
+     * 今天
+     */
+    public final static Integer TODAY= 1 ;
+    /**
+     * 昨日
+     */
+    public final static Integer LAST_DAY = 2 ;
+    /**
+     * 近7日
+     */
+    public final static Integer LAST_7_DAY = 7 ;
+
+    /**
+     * 近15天
+     */
+    public final static Integer LAST_15_DAY = 15 ;
+    /**
+     * 上月
+     */
+    public final static Integer LAST_MONTH = 99 ;
+}

+ 3 - 1
smart-city-platform/src/main/java/com/bz/smart_city/commom/model/CommonQueryCondition.java

@@ -21,7 +21,8 @@ public class CommonQueryCondition {
 	private Integer buildingId = 0; // 建筑
 	private Integer floor = 0; // 楼层
 	private String alarmCategory = "0"; // 告警分类
-	private Integer period = 1; // 统计周期  0 表示自定义,1表示今天,2表示昨天,7表示近7天,30表示近30天,99表示上个月
+	// 统计周期  0 表示自定义,1表示今天,2表示昨天,7表示近7天,30表示近30天,99表示上个月
+	private Integer period = 1;
 	private Integer startDate ; // 开始时间
 	private Integer endDate ; // 结束时间
 	private Integer statDay ; // 统计日期
@@ -59,4 +60,5 @@ public class CommonQueryCondition {
 	private List<Integer> regions;
 	private List<Integer> communities;
 	private List<Integer> customerIds;
+	private Integer concentratorId ; // 集中器ID
 }

File diff suppressed because it is too large
+ 216 - 683
smart-city-platform/src/main/java/com/bz/smart_city/controller/water/WaterMeterReadController.java


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

@@ -56,6 +56,8 @@ public interface MeterReadRecordMapper {
 
     List<DeviceDto> queryUnReadDeviceList(@Param("param") CommonQueryCondition condition);
 
+    List<DeviceDto> queryUnReadDeviceListForToday(@Param("param") CommonQueryCondition condition);
+
     List<DeviceDto> queryUnReadDeviceListV2(@Param("tableName") String tableName, @Param("param") CommonQueryCondition condition);
 
     List<DeviceDto> queryUnReadDeviceListFor7Day(@Param("param") CommonQueryCondition condition);

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

@@ -27,11 +27,15 @@ public interface StatMeterReadRateByBuildingMapper {
 
     List<StatMeterReadRateDto> analysisMeterReadRate(@Param("param") CommonQueryCondition condition);
 
+    List<StatMeterReadRateDto> getRateListByBuildingForToday(@Param("param") CommonQueryCondition condition);
 
     List<StatMeterReadRateDto> getRateListByBuildingForDay(@Param("param") CommonQueryCondition condition);
 
+    List<BuildingSelectInfoDto> getRateAreaListByBuildingForToday(@Param("param") CommonQueryCondition condition);
+
     List<BuildingSelectInfoDto> getRateAreaListByBuildingForDay(@Param("param") CommonQueryCondition condition);
 
+    StatMeterReadRateDto summaryRateListByBuildingForToday(@Param("param") CommonQueryCondition condition);
     StatMeterReadRateDto summaryRateListByBuildingForDay(@Param("param") CommonQueryCondition condition);
 
     List<StatMeterReadRateDto> getRateListByBuildingFor7Day(@Param("param") CommonQueryCondition condition);

+ 63 - 2
smart-city-platform/src/main/java/com/bz/smart_city/dao/StatMeterReadRateByConcentratorMapper.java

@@ -49,12 +49,73 @@ public interface StatMeterReadRateByConcentratorMapper {
     
     StatMeterReadRateDto summaryList(@Param("param")CommonQueryCondition condition);
 
-    
+    /**
+     * 查询集中器今日抄表率
+     * @param condition
+     * @return
+     */
+    List<StatMeterReadRateDto> getListByToday(@Param("param")CommonQueryCondition condition);
+
+    /**
+     * 查询集中器昨日抄表率
+     * @param condition
+     * @return
+     */
     List<StatMeterReadRateDto> getListByDay(@Param("param")CommonQueryCondition condition);
+
+    /**
+     * 查询集中器近7日抄表率
+     * @param condition
+     * @return
+     */
     List<StatMeterReadRateDto> getListBy7Day(@Param("param")CommonQueryCondition condition);
+
+    /**
+     * 查询集中器近15日抄表率
+     * @param condition
+     * @return
+     */
     List<StatMeterReadRateDto> getListBy15Day(@Param("param")CommonQueryCondition condition);
-    
+
+    /**
+     * 查询集中器上月抄表率
+     * @param condition
+     * @return
+     */
+    List<StatMeterReadRateDto> getListByMonth(@Param("param")CommonQueryCondition condition);
+
+    /**
+     * 汇总今日抄表率
+     * @param condition
+     * @return
+     */
+    StatMeterReadRateDto summaryListByToday(@Param("param")CommonQueryCondition condition);
+
+    /**
+     * 汇总昨日抄表率
+     * @param condition
+     * @return
+     */
     StatMeterReadRateDto summaryListByDay(@Param("param")CommonQueryCondition condition);
+
+    /**
+     * 汇总近7日抄表率
+     * @param condition
+     * @return
+     */
     StatMeterReadRateDto summaryListBy7Day(@Param("param")CommonQueryCondition condition);
+
+    /**
+     *汇总近15日抄表率
+     * @param condition
+     * @return
+     */
     StatMeterReadRateDto summaryListBy15Day(@Param("param")CommonQueryCondition condition);
+
+    /**
+     * 汇总上上月抄表率
+     * @param condition
+     * @return
+     */
+    StatMeterReadRateDto summaryListByMonth(@Param("param")CommonQueryCondition condition);
 }

+ 4 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dto/StatMeterReadRateDto.java

@@ -42,4 +42,8 @@ public class StatMeterReadRateDto extends StatMeterReadRateByCollector {
     
     @ApiModelProperty(value="安装设备总数")
     private Integer installedDeviceCount;
+
+    @ApiModelProperty(value="设备型号")
+    private Integer deviceTypeName ;
+
 }

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

@@ -53,4 +53,7 @@ public class UdipUnitDTO implements Serializable {
 
     @ApiModelProperty(value="备注")
     private String comment;
+
+    @ApiModelProperty(value="是否关联到第三方平台,1:是,其他:否")
+    private String isThirdSystem ;
 }

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

@@ -320,6 +320,7 @@ public class DeviceDataPushServiceImpl implements DeviceDataPushService , Initia
 		jsonMap.put("dataList",dataMapList);
 		
 		String jsonString = JSON.toJSONString(jsonMap);
+		log.info("Push Content = {}",jsonString);
 		return jsonString;
 	}
 	

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

@@ -1,6 +1,7 @@
 package com.bz.smart_city.service.impl;
 
 import com.alibaba.fastjson.JSON;
+import com.bz.smart_city.commom.constant.MeterReadPeriod;
 import com.bz.smart_city.commom.exception.ServiceException;
 import com.bz.smart_city.commom.model.CommonQueryCondition;
 import com.bz.smart_city.commom.model.Pagination;
@@ -49,25 +50,26 @@ public class StatMeterReadRateByBuildingServiceImpl implements StatMeterReadRate
     public Pagination<DeviceDto> queryUnReadDeviceList(CommonQueryCondition condition, int pageNum, int pageSize) {
         log.info("begin StatMeterReadRateByBuildingService queryUnReadDeviceList , condition = " + JSON.toJSONString(condition));
         PageHelper.startPage(pageNum, pageSize);
-        int period = condition.getPeriod(); // 统计周期,2,昨天,7,近7天 15,近15天
+        int period = condition.getPeriod();
         List<DeviceDto> rtnList = null;
-        condition.setStatDay(Integer.parseInt(DateTimeUtil.formatDate(DateTimeUtil.beforeNow(1), "yyyyMMdd")));
-        if (period == 2) {
-            //rtnList = meterReadRecordMapper.queryUnReadDeviceList(condition);
+        if(period == MeterReadPeriod.TODAY){
+            rtnList = meterReadRecordMapper.queryUnReadDeviceListForToday(condition);
+        }
+        else if (period == MeterReadPeriod.LAST_DAY) {
+            condition.setStatDay(Integer.parseInt(DateTimeUtil.formatDate(DateTimeUtil.beforeNow(1), "yyyyMMdd")));
             rtnList = meterReadRecordMapper.queryUnReadDeviceListV2("sc_stat_meter_unread_device_by_building",condition);
         }
-        else if(period == 7) { // 近7天,查询近7天表
-        	//rtnList = meterReadRecordMapper.queryUnReadDeviceListFor7Day(condition);
+        else if(period == MeterReadPeriod.LAST_7_DAY) {
+            condition.setStatDay(Integer.parseInt(DateTimeUtil.formatDate(DateTimeUtil.beforeNow(1), "yyyyMMdd")));
             rtnList = meterReadRecordMapper.queryUnReadDeviceListV2("sc_stat_meter_unread_device_by_building_7day",condition);
         }
-        else if (period == 15) { // 近15天,查询近15天表
-        	//rtnList = meterReadRecordMapper.queryUnReadDeviceListFor15Day(condition);
+        else if (period == MeterReadPeriod.LAST_15_DAY) {
+            condition.setStatDay(Integer.parseInt(DateTimeUtil.formatDate(DateTimeUtil.beforeNow(1), "yyyyMMdd")));
             rtnList = meterReadRecordMapper.queryUnReadDeviceListV2("sc_stat_meter_unread_device_by_building_15day",condition);
         }
-        else if (period == 99) { // 上月,查询月表
+        else if (period == MeterReadPeriod.LAST_MONTH) {
             DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMM");
             condition.setStatDay(Integer.parseInt(LocalDateTime.now().plusMonths(-1).format(df)));
-            //rtnList = meterReadRecordMapper.queryUnReadDeviceListForMonth(condition);
             rtnList = meterReadRecordMapper.queryUnReadDeviceListV2("sc_stat_meter_unread_device_by_building_month",condition);
         }
         log.info("end StatMeterReadRateByBuildingService queryUnReadDeviceList , condition = " + JSON.toJSONString(condition));
@@ -78,16 +80,23 @@ public class StatMeterReadRateByBuildingServiceImpl implements StatMeterReadRate
     public Pagination<StatMeterReadRateDto> getRateListByBuildingV2(CommonQueryCondition condition, int pageNum, int pageSize) {
         log.info("begin StatMeterReadRateByBuildingService getRateListByBuildingV2 , condition = " + JSON.toJSONString(condition));
         PageHelper.startPage(pageNum, pageSize);
-        int period = condition.getPeriod(); // 统计周期,2,昨天,7,近7天 15,近15天 99,上个月
+        // 统计周期,1,今天,2,昨天,7,近7天 15,近15天 99,上个月
+        int period = condition.getPeriod();
         List<StatMeterReadRateDto> rtnList = null;
-        condition.setStatDay(Integer.parseInt(DateTimeUtil.formatDate(DateTimeUtil.beforeNow(1), "yyyyMMdd")));
-        if (period == 2) { // 昨天,查询天表
+        if(period == MeterReadPeriod.TODAY ){
+            condition.setStatDay(Integer.parseInt(DateTimeUtil.formatNow("yyyyMMdd")));
+            rtnList = statMeterReadRateByBuildingMapper.getRateListByBuildingForToday(condition);
+        }
+        else if (period == MeterReadPeriod.LAST_DAY) {
+            condition.setStatDay(Integer.parseInt(DateTimeUtil.formatDate(DateTimeUtil.beforeNow(1), "yyyyMMdd")));
             rtnList = statMeterReadRateByBuildingMapper.getRateListByBuildingForDay(condition);
-        } else if (period == 7) { // 近7天,查询7天表
+        } else if (period == MeterReadPeriod.LAST_7_DAY) {
+            condition.setStatDay(Integer.parseInt(DateTimeUtil.formatDate(DateTimeUtil.beforeNow(1), "yyyyMMdd")));
             rtnList = statMeterReadRateByBuildingMapper.getRateListByBuildingFor7Day(condition);
-        } else if (period == 15) {// 近15天,查询15天表
+        } else if (period == MeterReadPeriod.LAST_15_DAY) {
+            condition.setStatDay(Integer.parseInt(DateTimeUtil.formatDate(DateTimeUtil.beforeNow(1), "yyyyMMdd")));
             rtnList = statMeterReadRateByBuildingMapper.getRateListByBuildingFor15Day(condition);
-        }else if (period == 99) {// 上个月,查询月表
+        }else if (period == MeterReadPeriod.LAST_MONTH) {
             DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMM");
             condition.setStatDay(Integer.parseInt(LocalDateTime.now().plusMonths(-1).format(df)));
             rtnList = statMeterReadRateByBuildingMapper.getRateListByBuildingForMonth(condition);
@@ -100,15 +109,21 @@ public class StatMeterReadRateByBuildingServiceImpl implements StatMeterReadRate
     public StatMeterReadRateDto summaryRateListByBuildingV2(CommonQueryCondition condition) {
         log.info("begin StatMeterReadRateByBuildingService summaryRateListByBuildingV2 , condition = " + JSON.toJSONString(condition));
         StatMeterReadRateDto resp = null;
-        int period = condition.getPeriod(); // 统计周期,2,昨天,7,近7天 15,近15天 99,上个月
-        condition.setStatDay(Integer.parseInt(DateTimeUtil.formatDate(DateTimeUtil.beforeNow(1), "yyyyMMdd")));
-        if (period == 2) { // 昨天,查询天表
+        int period = condition.getPeriod();
+        if(period == MeterReadPeriod.TODAY ){
+            condition.setStatDay(Integer.parseInt(DateTimeUtil.formatNow("yyyyMMdd")));
+            resp = statMeterReadRateByBuildingMapper.summaryRateListByBuildingForToday(condition);
+        }
+        else if (period == MeterReadPeriod.LAST_DAY) {
+            condition.setStatDay(Integer.parseInt(DateTimeUtil.formatDate(DateTimeUtil.beforeNow(1), "yyyyMMdd")));
             resp = statMeterReadRateByBuildingMapper.summaryRateListByBuildingForDay(condition);
-        } else if (period == 7) { // 近7天,查询7天表
+        } else if (period == MeterReadPeriod.LAST_7_DAY) {
+            condition.setStatDay(Integer.parseInt(DateTimeUtil.formatDate(DateTimeUtil.beforeNow(1), "yyyyMMdd")));
             resp = statMeterReadRateByBuildingMapper.summaryRateListByBuildingFor7Day(condition);
-        } else if (period == 15) { // 近7天,查询7天表
+        } else if (period == MeterReadPeriod.LAST_15_DAY) {
+            condition.setStatDay(Integer.parseInt(DateTimeUtil.formatDate(DateTimeUtil.beforeNow(1), "yyyyMMdd")));
             resp = statMeterReadRateByBuildingMapper.summaryRateListByBuildingFor15Day(condition);
-        }else if (period == 99) { // 上个月,查询月表
+        }else if (period == MeterReadPeriod.LAST_MONTH) {
             DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMM");
             condition.setStatDay(Integer.parseInt(LocalDateTime.now().plusMonths(-1).format(df)));
             resp = statMeterReadRateByBuildingMapper.summaryRateListByBuildingForMonth(condition);
@@ -120,17 +135,23 @@ public class StatMeterReadRateByBuildingServiceImpl implements StatMeterReadRate
     @Override
     public void exportRateListByBuildingV2(CommonQueryCondition condition, HttpServletResponse httpServletResponse) {
         log.info("begin StatMeterReadRateByBuildingService exportRateListByBuildingV2 , condition = " + JSON.toJSONString(condition));
-        int period = condition.getPeriod(); // 统计周期,2,昨天,7,近7天 15,近15天 99,上个月
-        condition.setStatDay(Integer.parseInt(DateTimeUtil.formatDate(DateTimeUtil.beforeNow(1), "yyyyMMdd")));
+        int period = condition.getPeriod();
         // 1,查询数据
         List<StatMeterReadRateDto> rtnList = null;
-        if (period == 2) { // 昨天,查询天表
+        if(period == MeterReadPeriod.TODAY){
+            condition.setStatDay(Integer.parseInt(DateTimeUtil.formatNow("yyyyMMdd")));
+            rtnList = statMeterReadRateByBuildingMapper.getRateListByBuildingForToday(condition);
+        }
+        else if (period == MeterReadPeriod.LAST_DAY) {
+            condition.setStatDay(Integer.parseInt(DateTimeUtil.formatDate(DateTimeUtil.beforeNow(1), "yyyyMMdd")));
             rtnList = statMeterReadRateByBuildingMapper.getRateListByBuildingForDay(condition);
-        } else if (period == 7) { // 近7天,查询7天表
+        } else if (period == MeterReadPeriod.LAST_7_DAY) {
+            condition.setStatDay(Integer.parseInt(DateTimeUtil.formatDate(DateTimeUtil.beforeNow(1), "yyyyMMdd")));
             rtnList = statMeterReadRateByBuildingMapper.getRateListByBuildingFor7Day(condition);
-        } else if (period == 15) {// 近15天,查询15天表
+        } else if (period == MeterReadPeriod.LAST_15_DAY) {
+            condition.setStatDay(Integer.parseInt(DateTimeUtil.formatDate(DateTimeUtil.beforeNow(1), "yyyyMMdd")));
             rtnList = statMeterReadRateByBuildingMapper.getRateListByBuildingFor15Day(condition);
-        }else if (period == 99) {// 上个月,查询月表
+        }else if (period == MeterReadPeriod.LAST_MONTH) {
             DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMM");
             condition.setStatDay(Integer.parseInt(LocalDateTime.now().plusMonths(-1).format(df)));
             rtnList = statMeterReadRateByBuildingMapper.getRateListByBuildingForMonth(condition);
@@ -571,22 +592,27 @@ public class StatMeterReadRateByBuildingServiceImpl implements StatMeterReadRate
 
     @Override
     public List<BuildingSelectDto> rateAreaList(CommonQueryCondition condition) {
-
-        int period = condition.getPeriod(); // 统计周期,2,昨天,7,近7天 15,近15天 99,近15天
+        int period = condition.getPeriod();
         List<BuildingSelectInfoDto> buildingList  = null;
         condition.setStatDay(Integer.parseInt(DateTimeUtil.formatDate(DateTimeUtil.beforeNow(1), "yyyyMMdd")));
-        if (period == 2) { // 昨天,查询天表
+        if(period == MeterReadPeriod.TODAY){
+            condition.setStatDay(Integer.parseInt(DateTimeUtil.formatNow("yyyyMMdd")));
+            buildingList = statMeterReadRateByBuildingMapper.getRateAreaListByBuildingForToday(condition);
+        }
+        else if (period == MeterReadPeriod.LAST_DAY) {
+            condition.setStatDay(Integer.parseInt(DateTimeUtil.formatDate(DateTimeUtil.beforeNow(1), "yyyyMMdd")));
             buildingList = statMeterReadRateByBuildingMapper.getRateAreaListByBuildingForDay(condition);
-        } else if (period == 7) { // 近7天,查询7天表
+        } else if (period == MeterReadPeriod.LAST_7_DAY) {
+            condition.setStatDay(Integer.parseInt(DateTimeUtil.formatDate(DateTimeUtil.beforeNow(1), "yyyyMMdd")));
             buildingList = statMeterReadRateByBuildingMapper.getRateAreaListByBuildingFor7Day(condition);
-        } else if (period == 15) {// 近15天,查询15天表
+        } else if (period == MeterReadPeriod.LAST_15_DAY) {
+            condition.setStatDay(Integer.parseInt(DateTimeUtil.formatDate(DateTimeUtil.beforeNow(1), "yyyyMMdd")));
             buildingList = statMeterReadRateByBuildingMapper.getRateAreaListByBuildingFor15Day(condition);
-        }else if (period == 99) {// 上个月,查询月表
+        }else if (period == MeterReadPeriod.LAST_MONTH) {
             DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMM");
             condition.setStatDay(Integer.parseInt(LocalDateTime.now().plusMonths(-1).format(df)));
             buildingList = statMeterReadRateByBuildingMapper.getRateAreaListByBuildingForMonth(condition);
         }
-
         return buildingService.areaList(buildingList);
     }
 }

+ 52 - 29
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/StatMeterReadRateByConcentratorServiceImpl.java

@@ -1,6 +1,7 @@
 package com.bz.smart_city.service.impl;
 
 import com.alibaba.fastjson.JSON;
+import com.bz.smart_city.commom.constant.MeterReadPeriod;
 import com.bz.smart_city.commom.exception.ServiceException;
 import com.bz.smart_city.commom.model.CommonQueryCondition;
 import com.bz.smart_city.commom.model.Pagination;
@@ -13,6 +14,7 @@ import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
 import java.time.LocalDate;
+import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
 import java.util.List;
@@ -38,8 +40,18 @@ public class StatMeterReadRateByConcentratorServiceImpl implements StatMeterRead
 	public Pagination<StatMeterReadRateDto> getRateListByConcentrator(CommonQueryCondition condition, int pageNum,
 			int pageSize) {
     	log.info("begin StatMeterReadRateByConcentratorService getRateListByConcentrator,condition = "+ JSON.toJSONString(condition));
-    	List<StatMeterReadRateDto> list = null;
-    	condition.setStatDay(Integer.parseInt(DateTimeUtil.formatDate(DateTimeUtil.beforeNow(1), "yyyyMMdd")));
+    	List<StatMeterReadRateDto> list;
+    	// 若查询周期为今日,则进行实时计算,若查询周期不为今日,则查询离线统计数据
+        if(condition.getPeriod().equals(MeterReadPeriod.TODAY)){
+            condition.setStatDay(Integer.parseInt(DateTimeUtil.formatNow("yyyyMMdd")));
+        }
+        else if(condition.getPeriod().equals(MeterReadPeriod.LAST_MONTH)){
+            DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMM");
+            condition.setStatDay(Integer.parseInt(LocalDateTime.now().plusMonths(-1).format(df)));
+        }
+        else{
+            condition.setStatDay(Integer.parseInt(DateTimeUtil.formatDate(DateTimeUtil.beforeNow(1), "yyyyMMdd")));
+        }
     	PageHelper.startPage(pageNum, pageSize);
     	list = baseQuery(condition);
     	log.info("end StatMeterReadRateByConcentratorService getRateListByConcentrator ! ");
@@ -48,61 +60,72 @@ public class StatMeterReadRateByConcentratorServiceImpl implements StatMeterRead
 	
 	protected List<StatMeterReadRateDto> baseQuery(CommonQueryCondition condition){
 		List<StatMeterReadRateDto> list = null;
-		int period = condition.getPeriod(); // 统计周期,2,昨天,7,近7天 15,近15天
-    	if (period == 2) { // 昨天,查询天表
+		int period = condition.getPeriod();
+		if(period == MeterReadPeriod.TODAY){
+            list = statMeterReadRateByConcentratorMapper.getListByDay(condition);
+        }
+    	else if(period == MeterReadPeriod.LAST_DAY) {
     		list = statMeterReadRateByConcentratorMapper.getListByDay(condition);
-    	}else if (period == 7) { // 近7天,查询7天表
+    	}else if (period == MeterReadPeriod.LAST_7_DAY) {
     		list = statMeterReadRateByConcentratorMapper.getListBy7Day(condition);
-    	}else if (period == 15) {// 近15天,查询15天表
+    	}else if (period == MeterReadPeriod.LAST_15_DAY) {
     		list = statMeterReadRateByConcentratorMapper.getListBy15Day(condition);
-    	}
-//		if(condition.getStartDate() == condition.getEndDate()) {
-//            list = statMeterReadRateByConcentratorMapper.getListWith7Day(condition);
-//    	}
-//    	else {
-//            list = statMeterReadRateByConcentratorMapper.getListWithOut7Day(condition);
-//    	}
+    	}else if(period == MeterReadPeriod.LAST_MONTH){
+            list = statMeterReadRateByConcentratorMapper.getListByMonth(condition);
+        }
 		return list;
 	}
 	@Override
 	public StatMeterReadRateDto summaryRateListByConcentrator(CommonQueryCondition condition) {
     	log.info("begin StatMeterReadRateByConcentratorService summaryRateListByConcentrator,condition = "+ JSON.toJSONString(condition));
-    	StatMeterReadRateDto resp = null ;
-    	int period = condition.getPeriod(); // 统计周期,2,昨天,7,近7天 15,近15天
-        condition.setStatDay(Integer.parseInt(DateTimeUtil.formatDate(DateTimeUtil.beforeNow(1), "yyyyMMdd")));
-    	if (period == 2) { // 昨天,查询天表
+    	StatMeterReadRateDto resp = null;
+    	int period = condition.getPeriod();
+        if(condition.getPeriod().equals(MeterReadPeriod.TODAY)){
+            condition.setStatDay(Integer.parseInt(DateTimeUtil.formatNow("yyyyMMdd")));
+        }
+        else if(condition.getPeriod().equals(MeterReadPeriod.LAST_MONTH)){
+            DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMM");
+            condition.setStatDay(Integer.parseInt(LocalDateTime.now().plusMonths(-1).format(df)));
+        }
+        else{
+            condition.setStatDay(Integer.parseInt(DateTimeUtil.formatDate(DateTimeUtil.beforeNow(1), "yyyyMMdd")));
+        }
+        if(period == MeterReadPeriod.TODAY){
+            resp = statMeterReadRateByConcentratorMapper.summaryListByToday(condition);
+        }
+        else if (period == MeterReadPeriod.LAST_DAY) {
             resp = statMeterReadRateByConcentratorMapper.summaryListByDay(condition);
-        } else if (period == 7) { // 近7天,查询7天表
+        } else if (period == MeterReadPeriod.LAST_7_DAY) {
             resp = statMeterReadRateByConcentratorMapper.summaryListBy7Day(condition);
-        } else if (period == 15) { // 近7天,查询7天表
+        } else if (period == MeterReadPeriod.LAST_15_DAY) {
             resp = statMeterReadRateByConcentratorMapper.summaryListBy15Day(condition);
+        }else if(period == MeterReadPeriod.LAST_MONTH){
+            resp = statMeterReadRateByConcentratorMapper.summaryListByMonth(condition);
         }
-    	resp = statMeterReadRateByConcentratorMapper.summaryList(condition);
     	log.info("end StatMeterReadRateByConcentratorService summaryRateListByConcentrator !");
 		return resp;
 	}
 	
 	@Override
 	public void exportRateListByConcentrator(CommonQueryCondition condition, HttpServletResponse httpServletResponse) {
-		log.info("begin StatMeterReadRateByConcentratorService exportRateListByConcentrator,condition = "+ JSON.toJSONString(condition));
+		log.info("begin StatMeterReadRateByConcentratorService exportRateListByConcentrator,condition ={} ", JSON.toJSONString(condition));
 		// 1,查询数据
 		List<StatMeterReadRateDto> list = baseQuery(condition);
     	// 2,定义excel格式&内容
 		String title = "按集中器统计抄表率";
-		String[] rowsName = new String[]{"序号", "所属客户","集中器编号","水表数量", "应抄数量", "实抄数量", "未抄数量", "抄表率(%)"};
+		String[] rowsName = new String[]{"序号","集中器编号", "所属客户","设备型号","应抄水表总数", "抄收成功总数", "抄收成功率(%)"};
 		List<Object[]> dataList = newArrayList();
-		Object[] objs = null;
+		Object[] objs  ;
 		for (int i = 0; i < list.size(); i++) {
 			StatMeterReadRateDto dto = list.get(i);
 			objs = new Object[rowsName.length];
 			objs[0] = i;
-			objs[1] = dto.getCustomerName();
-			objs[2] = dto.getCollectorNo();
-			objs[3] = dto.getDeviceCount();
-			objs[4] = dto.getReadTimes();
+			objs[1] = dto.getCollectorNo() ;
+			objs[2] = dto.getCustomerName();
+			objs[3] = dto.getDeviceTypeName();
+			objs[4] = dto.getDeviceCount();
 			objs[5] = dto.getRealReadTimes();
-			objs[6] = dto.getUnReadTimes();
-			objs[7] = dto.getReadRate();
+			objs[6] = dto.getReadRate();
 			dataList.add(objs);
 		}
 		ExcelUtil excelUtil = new ExcelUtil(title, rowsName, dataList);

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

@@ -1,2 +1,2 @@
 #开发环境:dev  测试环境:sit  线上环境:prd  演示环境:uat
-spring.profiles.active=dev
+spring.profiles.active=sit

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

@@ -994,6 +994,7 @@
 				) tmp 
 		)
     </select>
+
     <select id="queryUnReadDeviceListV2" resultType="com.bz.smart_city.dto.DeviceDto">
         SELECT
         d.site_id as siteId,
@@ -1044,7 +1045,39 @@
         <if test = "param.buildingId != null and param.buildingId != 0">
             AND t1.building_id = #{param.buildingId}
         </if>
-
+    </select>
+    <select id="queryUnReadDeviceListForToday" resultType="com.bz.smart_city.dto.DeviceDto">
+        SELECT
+            d.site_id as siteId,
+            d.customer_id as customerId,
+            d.sys_id as sysId,
+            d.id as id,
+            d.device_type as deviceType,
+            d.building_id as buildingId,
+            col.collector_no as collectorName,
+            con.serial_number as concentratorName,
+            d.water_meter_no as waterMeterNo,
+            d.water_meter_file_no as waterMeterFileNo,
+            d.device_no as deviceNo,
+            d.device_status as deviceStatus,
+            d.floor as floor,
+            d.loc_desc as locDesc,
+            d.last_receive_time as lastReceiveTime
+        FROM  (
+            SELECT
+            device_id
+            FROM sc_meter_read_record
+            WHERE read_status = 1
+            and building_id = #{param.buildingId}
+            and customer_id =  #{param.custormerId}
+            and sys_id = #{param.channelId}
+            AND read_date = DATE_FORMAT( now( ), '%Y%m%d' )
+        ) t1
+        LEFT JOIN sc_device d on (t1.device_id = d.id)
+        LEFT JOIN sc_water_related_device rd ON ( rd.device_id = d.id AND rd.`status` = 1 )
+        LEFT JOIN sc_collector col ON ( col.id = rd.collector_id AND col.`status` = 1 )
+        LEFT JOIN sc_concentrator con ON ( con.id = rd.concentrator_id AND con.`status` = 1 )
+        where d.status = 1
     </select>
     <select id="queryUnReadDeviceListFor7Day" resultType="com.bz.smart_city.dto.DeviceDto">
     	SELECT

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

@@ -740,7 +740,56 @@
             <foreach collection="customerList" item="item" open="(" separator="," close=")">#{item.id}</foreach>
         </if>
     </select>
-
+    <!-- 按建筑统计今日抄表率-->
+    <sql id="base_GetRateListByBuildingForToday">
+        SELECT
+	        rb.stat_day as stat_day,
+			rb.building_id as building_id,
+			b.`name` AS building_name,
+			rb.device_count AS device_count,
+			rb.read_times AS read_times,
+			rb.real_read_times AS real_read_times,
+			rb.un_read_times AS un_read_times,
+			rb.read_rate AS read_rate,
+			rb.customer_id as customer_id,
+			c.customer_name as customer_name
+        FROM
+        (
+            SELECT
+                DATE_FORMAT( now( ), '%Y%m%d' ) AS stat_day,
+                mrr.site_id,
+                mrr.sys_id as channel_id,
+                mrr.building_id AS building_id,
+                count( DISTINCT device_id ) AS device_count,
+                count( 1 ) AS read_times,
+                SUM( IF ( read_status = 2, 1, 0 ) ) AS real_read_times,
+                SUM( IF ( read_status = 1, 1, 0 ) ) AS un_read_times,
+                FORMAT( SUM( IF ( read_status = 2, 1, 0 ) ) / COUNT( 1 ) * 100, 2 ) AS read_rate,
+                mrr.customer_id AS customer_id
+            FROM
+                sc_meter_read_record mrr
+            WHERE
+                mrr.`status` = 1
+                AND mrr.sys_id = #{param.channelId}
+                AND mrr.read_date = DATE_FORMAT( now( ), '%Y%m%d' )
+            GROUP BY
+                mrr.site_id,
+                mrr.sys_id,
+                mrr.customer_id,
+                mrr.building_id
+        ) rb
+        LEFT JOIN sc_building b ON ( rb.building_id = b.id )
+        LEFT JOIN sc_customer c ON ( rb.customer_id = c.id )
+    </sql>
+    <select id="getRateListByBuildingForToday"  resultType="com.bz.smart_city.dto.StatMeterReadRateDto">
+        <include refid="base_GetRateListByBuildingForToday"></include>
+        <include refid="where_clause"></include>
+        <if test="param.sortColumn != null and param.sortColumn != ''">
+            <if test="param.sortOrder != null and param.sortOrder != ''">
+                order by ${param.sortColumn} ${param.sortOrder},device_count desc
+            </if>
+        </if>
+    </select>
     <!-- 按建筑统计天表 -->
     <sql id="base_GetRateListByBuildingForDay">
     	select 
@@ -768,6 +817,47 @@
             </if>
         </if>
     </select>
+
+    <select id="getRateAreaListByBuildingForToday" resultType="com.bz.smart_city.dto.BuildingSelectInfoDto">
+        SELECT
+        b.id,
+        b.name,
+        b.province,
+        b.city,
+        b.region,
+        b.community,
+        b.longitude,
+        b.latitude,
+        0
+        FROM
+        (
+            SELECT
+                DATE_FORMAT( now( ), '%Y%m%d' ) AS stat_day,
+                mrr.site_id,
+                mrr.sys_id as channel_id,
+                mrr.building_id AS building_id,
+                count( DISTINCT device_id ) AS device_count,
+                count( 1 ) AS read_times,
+                SUM( IF ( read_status = 2, 1, 0 ) ) AS real_read_times,
+                SUM( IF ( read_status = 1, 1, 0 ) ) AS un_read_times,
+                FORMAT( SUM( IF ( read_status = 2, 1, 0 ) ) / COUNT( 1 ) * 100, 2 ) AS read_rate,
+                mrr.customer_id AS customer_id
+            FROM
+                sc_meter_read_record mrr
+            WHERE
+            mrr.`status` = 1
+            AND mrr.sys_id = #{param.channelId}
+            AND mrr.read_date = DATE_FORMAT( now( ), '%Y%m%d' )
+            GROUP BY
+            mrr.site_id,
+            mrr.sys_id,
+            mrr.customer_id,
+            mrr.building_id
+        ) rb
+        LEFT JOIN sc_building b ON ( rb.building_id = b.id )
+        LEFT JOIN sc_customer c ON ( rb.customer_id = c.id )
+        <include refid="where_clause"></include>
+    </select>
     <select id="getRateAreaListByBuildingForDay"  resultType="com.bz.smart_city.dto.BuildingSelectInfoDto">
         select
         b.id,
@@ -785,6 +875,23 @@
         LEFT JOIN  sc_customer c on (rb.customer_id = c.id)
         <include refid="where_clause"></include>
     </select>
+    <select id="summaryRateListByBuildingForToday" resultType="com.bz.smart_city.dto.StatMeterReadRateDto">
+        select
+        ifnull(SUM(tmp.device_count),0) as device_count,
+        ifnull(SUM(tmp.read_times),0) as read_times,
+        ifnull(SUM(tmp.real_read_times),0) as real_read_times,
+        ifnull(SUM(tmp.un_read_times),0) as un_read_times,
+        ifnull(ROUND(SUM(tmp.real_read_times)/SUM(tmp.read_times)*100,2),0) as read_rate
+        from (
+        <include refid="base_GetRateListByBuildingForToday"></include>
+        <include refid="where_clause"></include>
+        ) tmp
+        <if test="param.sortColumn != null and param.sortColumn != ''">
+            <if test="param.sortOrder != null and param.sortOrder != ''">
+                order by read_rate ${param.sortOrder}
+            </if>
+        </if>
+    </select>
     <select id="summaryRateListByBuildingForDay" resultType="com.bz.smart_city.dto.StatMeterReadRateDto">
     	select
 			ifnull(SUM(tmp.device_count),0) as device_count,

+ 198 - 8
smart-city-platform/src/main/resources/mapper/StatMeterReadRateByConcentratorMapper.xml

@@ -346,6 +346,8 @@
 			<if test = "param.beginRate != null "> and tmp.read_rate >= #{param.beginRate}</if>
     		<if test = "param.endRate != null "> and tmp.read_rate <![CDATA[ <= ]]>  #{param.endRate}</if>
     		<if test = "param.custormerId != null"> and tmp.customer_id = #{param.custormerId}</if>
+			<if test = "param.concentratorId != null">and tmp.concentrator_id = #{param.concentratorId}</if>
+			<if test = "param.deviceTypeId != null" >and tmp.device_type_id = #{param.deviceTypeId}</if>
     		<if test = "param.concentratorCode != null and param.concentratorCode != '' "> and con.serial_number like #{param.concentratorCode}</if>
     </sql>
     <!-- 查询抄表率,不含近7天统计 -->
@@ -372,6 +374,7 @@
     	SELECT
 			cust.customer_name as customer_name,
 			con.serial_number as serial_number,
+		    concat_ws('/',m.name,dt.equipment_type,dt.model) as device_type_name,
 			tmp.device_count as device_count,
 			tmp.read_times as read_times,
 			tmp.real_read_times as real_read_times,
@@ -382,6 +385,7 @@
 				SELECT
 					customer_id,
 					concentrator_id,
+					meter_type_id as device_type_id,
 					sum( device_count) AS device_count,
 					sum( read_times ) AS read_times,
 					sum( real_read_times ) AS real_read_times,
@@ -421,10 +425,13 @@
 					<if test = "param.statDay != null and param.statDay != 0"> and stat_day = #{param.statDay}</if>
 				GROUP BY
 					customer_id,
-					concentrator_id
+					concentrator_id,
+					device_type_id
 			) tmp
 			LEFT JOIN sc_customer cust ON ( tmp.customer_id = cust.id )
 			LEFT JOIN sc_concentrator con ON ( tmp.concentrator_id = con.id )
+		    left join sc_device_type dt on (tmp.device_type_id = dt.id)
+		    left join sc_device_manufacturer m on (dt.manufacturer_id = m.id)
     </sql>
     <select id="getListByDay" resultType="com.bz.smart_city.dto.StatMeterReadRateDto">
     	<include refid="base_query_getListByDay" />
@@ -453,7 +460,8 @@
     	SELECT
 			cust.customer_name as customer_name,
 			con.serial_number as serial_number,
-			tmp.device_count as device_count,
+		    concat_ws('/',m.name,dt.equipment_type,dt.model) as device_type_name,
+		    tmp.device_count as device_count,
 			tmp.read_times as read_times,
 			tmp.real_read_times as real_read_times,
 			tmp.un_read_times as un_read_times,
@@ -463,7 +471,8 @@
 				SELECT
 					customer_id,
 					concentrator_id,
-					sum( device_count) AS device_count,
+		            meter_type_id as device_type_id,
+		            sum( device_count) AS device_count,
 					sum( read_times ) AS read_times,
 					sum( real_read_times ) AS real_read_times,
 					sum( un_read_times ) AS un_read_times ,
@@ -502,10 +511,13 @@
 					<if test = "param.statDay != null and param.statDay != 0"> and stat_day = #{param.statDay}</if>
 				GROUP BY
 					customer_id,
-					concentrator_id
+					concentrator_id,
+		            device_type_id
 			) tmp
 			LEFT JOIN sc_customer cust ON ( tmp.customer_id = cust.id )
 			LEFT JOIN sc_concentrator con ON ( tmp.concentrator_id = con.id )
+		    left join sc_device_type dt on (tmp.device_type_id = dt.id)
+		    left join sc_device_manufacturer m on (dt.manufacturer_id = m.id)
     </sql>
     <select id="getListBy7Day" resultType="com.bz.smart_city.dto.StatMeterReadRateDto">
     	<include refid="base_query_getListBy7Day" />
@@ -534,7 +546,8 @@
     	SELECT
 			cust.customer_name as customer_name,
 			con.serial_number as serial_number,
-			tmp.device_count as device_count,
+		    concat_ws('/',m.name,dt.equipment_type,dt.model) as device_type_name,
+		    tmp.device_count as device_count,
 			tmp.read_times as read_times,
 			tmp.real_read_times as real_read_times,
 			tmp.un_read_times as un_read_times,
@@ -544,6 +557,7 @@
 				SELECT
 					customer_id,
 					concentrator_id,
+					meter_type_id as device_type_id,
 					sum( device_count) AS device_count,
 					sum( read_times ) AS read_times,
 					sum( real_read_times ) AS real_read_times,
@@ -583,10 +597,13 @@
 					<if test = "param.statDay != null and param.statDay != 0"> and stat_day = #{param.statDay}</if>
 				GROUP BY
 					customer_id,
-					concentrator_id
+					concentrator_id,
+					device_type_id
 			) tmp
 			LEFT JOIN sc_customer cust ON ( tmp.customer_id = cust.id )
 			LEFT JOIN sc_concentrator con ON ( tmp.concentrator_id = con.id )
+		    left join sc_device_type dt on (tmp.device_type_id = dt.id)
+		    left join sc_device_manufacturer m on (dt.manufacturer_id = m.id)
     </sql>
     <select id="getListBy15Day" resultType="com.bz.smart_city.dto.StatMeterReadRateDto">
     	<include refid="base_query_getListBy15Day" />
@@ -610,7 +627,180 @@
     	) tmp
     	ORDER BY read_rate DESC 
     </select>
-    
-    
+	<!-- 今日抄表率 -->
+    <sql id="base_query_getListByToday">
+		SELECT
+		cust.customer_name as customer_name,
+		con.serial_number as serial_number,
+		concat_ws('/',m.name,dt.equipment_type,dt.model) as device_type_name,
+		tmp.device_count as device_count,
+		tmp.read_times as read_times,
+		tmp.real_read_times as real_read_times,
+		tmp.un_read_times as un_read_times,
+		tmp.read_rate as read_rate
+		FROM
+		(
+		SELECT
+			customer_id,
+			concentrator_id,
+			device_type_id,
+		    count(1) as device_count,
+		    count(1) AS read_times,
+		    SUM(IF(read_status = 2, 1, 0)) as real_read_times,
+		    SUM(IF(read_status = 1, 1, 0)) as un_read_times ,
+			FORMAT( SUM(IF(read_status = 2, 1, 0)) / count(1) * 100, 2 ) AS read_rate
+		FROM
+			sc_meter_read_record
+		WHERE 1 = 1
+		and device_type_id IN ( SELECT device_type_id FROM sc_w_meter_type WHERE parent_id = 1 )
+		<!-- 表类型 -->
+		<if test="param.deviceTypeId != null ">
+			and device_type_id = #{param.deviceTypeId}
+		</if>
+		<!-- 数据权限 -->
+		<if test="param.siteId != null and param.siteId != 0 "> and site_id = #{param.siteId} </if>
+		<if test='param.programItems != null and param.programItems.size() != 0' >
+			and concentrator_id IN (
+			SELECT DISTINCT
+				rd.concentrator_id
+			FROM
+				sc_water_related_device rd
+			WHERE
+			rd.device_id IN (
+			SELECT
+			ud.device_id
+			FROM
+			(
+			SELECT
+				DISTINCT df.device_id
+			FROM sc_device_dim_info df
+			WHERE 1 = 1
+				and <foreach collection="param.programItems" item="item" open="(" separator=" or " close=")">
+				(df.dimension_code = #{item.dimensionCode} and df.dimension_value = #{item.dimensionValue})
+					</foreach> ) ud
+				)
+			)
+		</if>
+		<if test = "param.statDay != null and param.statDay != 0"> and read_date = #{param.statDay}</if>
+		GROUP BY
+		customer_id,
+		concentrator_id,
+		device_type_id
+		) tmp
+		LEFT JOIN sc_customer cust ON ( tmp.customer_id = cust.id )
+		LEFT JOIN sc_concentrator con ON ( tmp.concentrator_id = con.id )
+		left join sc_device_type dt on (tmp.device_type_id = dt.id)
+		left join sc_device_manufacturer m on (dt.manufacturer_id = m.id)
+	</sql>
+    <select id="getListByToday" resultType="com.bz.smart_city.dto.StatMeterReadRateDto">
+		<include refid="base_query_getListByToday" />
+		<include refid="where_clause" />
+		<if test="param.sortColumn != null and param.sortColumn != ''">
+			<if test="param.sortOrder != null and param.sortOrder != ''">
+				order by ${param.sortColumn} ${param.sortOrder}
+			</if>
+		</if>
+	</select>
+	<select id="summaryListByToday" resultType="com.bz.smart_city.dto.StatMeterReadRateDto">
+		select
+		ifnull(SUM(tmp.device_count),0) as device_count,
+		ifnull(SUM(tmp.read_times),0) as read_times,
+		ifnull(SUM(tmp.real_read_times),0) as real_read_times,
+		ifnull(SUM(tmp.un_read_times),0) as un_read_times,
+		ifnull(FORMAT(SUM(tmp.real_read_times)/SUM(tmp.read_times)*100,2),0) as read_rate
+		from (
+		<include refid="base_query_getListByToday" />
+		<include refid="where_clause"/>
+		) tmp
+		ORDER BY read_rate DESC
+	</select>
+
+	<!-- 按月查询抄表率 -->
+	<sql id="base_query_getListByMonth">
+		SELECT
+			cust.customer_name as customer_name,
+			con.serial_number as serial_number,
+			concat_ws('/',m.name,dt.equipment_type,dt.model) as device_type_name,
+			tmp.device_count as device_count,
+			tmp.read_times as read_times,
+			tmp.real_read_times as real_read_times,
+			tmp.un_read_times as un_read_times,
+			tmp.read_rate as read_rate
+		FROM
+		(
+			SELECT
+				customer_id,
+				concentrator_id,
+				meter_type_id as device_type_id,
+				sum( device_count) AS device_count,
+				sum( read_times ) AS read_times,
+				sum( real_read_times ) AS real_read_times,
+				sum( un_read_times ) AS un_read_times ,
+				FORMAT( sum( real_read_times ) / sum( read_times ) * 100, 2 ) AS read_rate
+			FROM
+				sc_stat_meter_read_rate_by_concentrator_month
+			WHERE 1 = 1
+			<!-- 表类型 -->
+			<if test="param.deviceTypeId != null ">
+				and meter_type_id = #{param.deviceTypeId}
+			</if>
+			<!-- 数据权限 -->
+			<if test="param.siteId != null and param.siteId != 0 "> and site_id = #{param.siteId} </if>
+			<if test='param.programItems != null and param.programItems.size() != 0' >
+				and concentrator_id IN (
+					SELECT DISTINCT
+						rd.concentrator_id
+					FROM
+						sc_water_related_device rd
+					WHERE
+						rd.device_id IN (
+					SELECT
+					ud.device_id
+					FROM
+					(
+					SELECT
+						DISTINCT df.device_id
+					FROM sc_device_dim_info df
+					WHERE 1 = 1
+					and <foreach collection="param.programItems" item="item" open="(" separator=" or " close=")">
+						(df.dimension_code = #{item.dimensionCode} and df.dimension_value = #{item.dimensionValue})
+						</foreach> ) ud
+					)
+				)
+			</if>
+			<if test = "param.statDay != null and param.statDay != 0"> and stat_month = #{param.statDay}</if>
+			GROUP BY
+			customer_id,
+			concentrator_id,
+			device_type_id
+		) tmp
+		LEFT JOIN sc_customer cust ON ( tmp.customer_id = cust.id )
+		LEFT JOIN sc_concentrator con ON ( tmp.concentrator_id = con.id )
+		left join sc_device_type dt on (tmp.device_type_id = dt.id)
+		left join sc_device_manufacturer m on (dt.manufacturer_id = m.id)
+	</sql>
+	<select id="getListByMonth" resultType="com.bz.smart_city.dto.StatMeterReadRateDto">
+		<include refid="base_query_getListByMonth" />
+		<include refid="where_clause" />
+		<if test="param.sortColumn != null and param.sortColumn != ''">
+			<if test="param.sortOrder != null and param.sortOrder != ''">
+				order by ${param.sortColumn} ${param.sortOrder}
+			</if>
+		</if>
+	</select>
+	<select id="summaryListByMonth" resultType="com.bz.smart_city.dto.StatMeterReadRateDto">
+		select
+		ifnull(SUM(tmp.device_count),0) as device_count,
+		ifnull(SUM(tmp.read_times),0) as read_times,
+		ifnull(SUM(tmp.real_read_times),0) as real_read_times,
+		ifnull(SUM(tmp.un_read_times),0) as un_read_times,
+		ifnull(FORMAT(SUM(tmp.real_read_times)/SUM(tmp.read_times)*100,2),0) as read_rate
+		from (
+		<include refid="base_query_getListByMonth" />
+		<include refid="where_clause"/>
+		) tmp
+		ORDER BY read_rate DESC
+	</select>
+
 </mapper>
 

+ 2 - 2
smart-city-platform/src/test/java/com/bz/smart_city/DeviceDataPushServiceTest.java

@@ -55,7 +55,7 @@ public class DeviceDataPushServiceTest {
 
 	@Test
 	public void devicePushInfoTest(){
-		DeviceInfoPushConfig config = deviceInfoPushConfigMapper.findConfigById(3);
+		DeviceInfoPushConfig config = deviceInfoPushConfigMapper.findConfigById(2);
 		deviceInfoPushService.generalPushMethod(config);
 	}
 
@@ -69,7 +69,7 @@ public class DeviceDataPushServiceTest {
 
 	@Test
 	public void deviceDataPushJobTest2(){
-		int configId = 7;
+		int configId = 6;
 		DeviceDataPushConfig config = deviceDataPushConfigMapper.findConfigById(configId);
 		deviceDataPushService.generalPushMethod(config);
 	}

Some files were not shown because too many files changed in this diff