浏览代码

Merge remote-tracking branch 'origin/20200908' into 20200908

hym 4 年之前
父节点
当前提交
6dea892a8a

+ 1 - 1
smart-city-intf/src/main/java/com/zcxk/smartcity/data/access/rabbitmq/WaterMeterDataSender.java

@@ -26,7 +26,7 @@ public class WaterMeterDataSender {
     @Autowired
     private RabbitTemplate rabbitTemplate;
 
-    @Value("${com.zcxk.rabbitmq.meterdata.exchange}")
+    @Value("${com.zcxk.rabbitmq.meter.data.exchange}")
     String exchange ;
 
     RabbitTemplate.ConfirmCallback confirmCallback = new RabbitTemplate.ConfirmCallback() {

+ 1 - 1
smart-city-intf/src/main/resources/application-sit-node0.properties

@@ -75,4 +75,4 @@ spring.rabbitmq.listener.direct.acknowledge-mode=manual
 spring.rabbitmq.listener.simple.acknowledge-mode=manual
 com.zcxk.rabbitmq.water.meter.queue=water_meter_queue
 com.zcxk.rabbitmq.command.status.queue=command_status_queue
-com.zcxk.rabbitmq.meterdata.exchange=hr-employee-exchange
+com.zcxk.rabbitmq.meter.data.exchange=meter-data-exchange

+ 1 - 1
smart-city-intf/src/main/resources/application-sit-node1.properties

@@ -75,4 +75,4 @@ spring.rabbitmq.listener.direct.acknowledge-mode=manual
 spring.rabbitmq.listener.simple.acknowledge-mode=manual
 com.zcxk.rabbitmq.water.meter.queue=water_meter_queue
 com.zcxk.rabbitmq.command.status.queue=command_status_queue
-com.zcxk.rabbitmq.meterdata.exchange=hr-employee-exchange
+com.zcxk.rabbitmq.meterdata.exchange=meter-data-exchange

+ 5 - 0
smart-city-platform/src/main/java/com/bz/smart_city/commom/model/Pagination.java

@@ -36,4 +36,9 @@ public class Pagination<T> implements Serializable {
         this.list = page;
         this.total = page.getTotal();
     }
+
+    public Pagination(List<T> list ,long total){
+        this.list = list ;
+        this.total =total ;
+    }
 }

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

@@ -590,8 +590,10 @@ public class WaterMeterReadController {
 		List<ProgramItem> programItems = loginUser.getDataPermissionMap().get(loginUser.getSiteId());
 		// 1,设置数据权限
 		CommonQueryCondition condition = new CommonQueryCondition();
-		condition.setProgramItems(programItems);
+		// 修改为只按照客户数据权限控制
+		// condition.setProgramItems(programItems);
 		condition.setSiteId(loginUser.getSiteId());
+		condition.setCustomerIds(UserUtil.getCustomerIds());
 		// 2,设置其他查询条件
 		condition.setDeviceTypeId(deviceTypeId);
 		condition.setPeriod(period);
@@ -622,8 +624,10 @@ public class WaterMeterReadController {
 		List<ProgramItem> programItems = loginUser.getDataPermissionMap().get(loginUser.getSiteId());
 		// 1,设置数据权限
 		CommonQueryCondition condition = new CommonQueryCondition();
-		condition.setProgramItems(programItems);
-		condition.setSiteId(loginUser.getSiteId());
+        // 修改为只按照客户数据权限控制
+        // condition.setProgramItems(programItems);
+        condition.setSiteId(loginUser.getSiteId());
+        condition.setCustomerIds(UserUtil.getCustomerIds());
 		// 2,设置其他查询条件
         condition.setDeviceTypeId(deviceTypeId);
 		condition.setPeriod(period);
@@ -653,8 +657,10 @@ public class WaterMeterReadController {
         List<ProgramItem> programItems = loginUser.getDataPermissionMap().get(loginUser.getSiteId());
         // 1,设置数据权限
         CommonQueryCondition condition = new CommonQueryCondition();
-        condition.setProgramItems(programItems);
+        // 修改为只按照客户数据权限控制
+        // condition.setProgramItems(programItems);
         condition.setSiteId(loginUser.getSiteId());
+        condition.setCustomerIds(UserUtil.getCustomerIds());
         // 2,设置其他查询条件
         condition.setDeviceTypeId(deviceTypeId);
         condition.setPeriod(period);

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

@@ -53,9 +53,13 @@ public interface MeterReadRecordMapper {
 
     List<DeviceDto> queryUnReadDeviceList(@Param("param") CommonQueryCondition condition);
 
-    List<DeviceDto> queryUnReadDeviceListForToday(@Param("param") CommonQueryCondition condition);
+    List<Long> queryUnReadDeviceListForToday(@Param("param") CommonQueryCondition condition);
+    //List<DeviceDto> queryUnReadDeviceListForToday(@Param("param") CommonQueryCondition condition);
+    List<DeviceDto> queryUnReadDeviceListByIds(@Param("param") List<Long> deviceIds);
 
-    List<DeviceDto> queryUnReadDeviceListV2(@Param("tableName") String tableName, @Param("param") CommonQueryCondition condition);
+    List<Long> queryUnReadDeviceListV2(@Param("tableName") String tableName, @Param("param") CommonQueryCondition condition);
+
+    // List<DeviceDto> queryUnReadDeviceListV2(@Param("tableName") String tableName, @Param("param") CommonQueryCondition condition);
 
     List<DeviceDto> queryUnReadDeviceListFor7Day(@Param("param") CommonQueryCondition condition);
 

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

@@ -12,6 +12,7 @@ import com.bz.smart_city.commom.util.UserUtil;
 import com.bz.smart_city.dto.*;
 import com.bz.smart_city.service.BuildingService;
 import com.bz.smart_city.service.CustomerService;
+import com.github.pagehelper.Page;
 import com.github.pagehelper.PageHelper;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -52,28 +53,32 @@ public class StatMeterReadRateByBuildingServiceImpl implements StatMeterReadRate
         PageHelper.startPage(pageNum, pageSize);
         int period = condition.getPeriod();
         List<DeviceDto> rtnList = null;
+        List<Long> deviceIdList = null; ;
         if(period == MeterReadPeriod.TODAY){
-            rtnList = meterReadRecordMapper.queryUnReadDeviceListForToday(condition);
+            deviceIdList = 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);
+            deviceIdList = meterReadRecordMapper.queryUnReadDeviceListV2("sc_stat_meter_unread_device_by_building",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);
+            deviceIdList = meterReadRecordMapper.queryUnReadDeviceListV2("sc_stat_meter_unread_device_by_building_7day",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);
+            deviceIdList = meterReadRecordMapper.queryUnReadDeviceListV2("sc_stat_meter_unread_device_by_building_15day",condition);
         }
         else if (period == MeterReadPeriod.LAST_MONTH) {
             DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMM");
             condition.setStatDay(Integer.parseInt(LocalDateTime.now().plusMonths(-1).format(df)));
-            rtnList = meterReadRecordMapper.queryUnReadDeviceListV2("sc_stat_meter_unread_device_by_building_month",condition);
+            deviceIdList = meterReadRecordMapper.queryUnReadDeviceListV2("sc_stat_meter_unread_device_by_building_month",condition);
+        }
+        if(deviceIdList != null && deviceIdList.size() != 0 ){
+            rtnList = meterReadRecordMapper.queryUnReadDeviceListByIds(deviceIdList) ;
         }
         log.info("end StatMeterReadRateByBuildingService queryUnReadDeviceList , condition = " + JSON.toJSONString(condition));
-        return new Pagination<>(rtnList);
+        return new Pagination<>(rtnList,((Page)deviceIdList).getTotal());
     }
 
     @Override

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

@@ -1033,7 +1033,26 @@
 				) tmp 
 		)
     </select>
-
+    <select id="queryUnReadDeviceListV2" resultType="Long">
+        select
+            device_id
+        from
+            ${tableName}
+        where 1=1
+        <if test="param.custormerId != null and param.custormerId != 0">
+            and customer_id = #{param.custormerId}
+        </if>
+        <if test = "param.channelId != null and param.channelId != 0">
+            and channel_id = #{param.channelId}
+        </if>
+        <if test = "param.statDay != null and param.statDay != 0">
+            and stat_day = #{param.statDay}
+        </if>
+        <if test = "param.buildingId != null and param.buildingId != 0">
+            AND building_id = #{param.buildingId}
+        </if>
+    </select>
+    <!--
     <select id="queryUnReadDeviceListV2" resultType="com.bz.smart_city.dto.DeviceDto">
         SELECT
         d.site_id as siteId,
@@ -1085,6 +1104,7 @@
             AND t1.building_id = #{param.buildingId}
         </if>
     </select>
+    -->
     <select id="queryUnReadDeviceListForToday_COUNT" resultType="Long">
         SELECT
             count(device_id)
@@ -1101,6 +1121,51 @@
         </if>
         AND read_date = DATE_FORMAT( now( ), '%Y%m%d' )
     </select>
+    <select id="queryUnReadDeviceListForToday" resultType="Long">
+        SELECT
+            device_id
+        FROM sc_meter_read_record
+        WHERE read_status = 1
+        <if test = "param.buildingId != null">
+            and building_id = #{param.buildingId}
+        </if>
+        <if test="param.channelId != null">
+            and sys_id = #{param.channelId}
+        </if>
+        <if test="param.custormerId != null ">
+            and customer_id = #{param.custormerId}
+        </if>
+        AND read_date = DATE_FORMAT( now( ), '%Y%m%d' )
+    </select>
+    <select id="queryUnReadDeviceListByIds" 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
+            sc_device d
+            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
+        <if test="param != null">
+            and d.id in <foreach collection="param" item="deviceId" open="(" separator="," close=")"> #{deviceId}</foreach>
+        </if>
+    </select>
+
+    <!--
     <select id="queryUnReadDeviceListForToday" resultType="com.bz.smart_city.dto.DeviceDto">
         SELECT
             d.site_id as siteId,
@@ -1140,6 +1205,7 @@
         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
 		  	d.site_id as siteId,

+ 30 - 0
smart-city-platform/src/main/resources/mapper/StatMeterReadRateByConcentratorMapper.xml

@@ -400,6 +400,10 @@
 					</if> 
 					<!-- 数据权限 -->
 					<if test="param.siteId != null and param.siteId != 0 "> and site_id = #{param.siteId} </if>
+					<if test="param.customerIds != null and param.customerIds.size() != 0">
+						and customer_id in <foreach collection="param.customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
+					</if>
+					<!--
 					<if test='param.programItems != null and param.programItems.size() != 0' >
 						and concentrator_id IN (
 								SELECT DISTINCT
@@ -422,6 +426,7 @@
 									) 
 								)
 					</if>
+					-->
 					<if test = "param.statDay != null and param.statDay != 0"> and stat_day = #{param.statDay}</if>
 				GROUP BY
 					customer_id,
@@ -486,6 +491,10 @@
 					</if> 
 					<!-- 数据权限 -->
 					<if test="param.siteId != null and param.siteId != 0 "> and site_id = #{param.siteId} </if>
+					<if test="param.customerIds != null and param.customerIds.size() != 0">
+						and customer_id in <foreach collection="param.customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
+					</if>
+					<!--
 					<if test='param.programItems != null and param.programItems.size() != 0' >
 						and concentrator_id IN (
 								SELECT DISTINCT
@@ -508,6 +517,7 @@
 									) 
 								)
 					</if>
+					-->
 					<if test = "param.statDay != null and param.statDay != 0"> and stat_day = #{param.statDay}</if>
 				GROUP BY
 					customer_id,
@@ -572,6 +582,10 @@
 					</if> 
 					<!-- 数据权限 -->
 					<if test="param.siteId != null and param.siteId != 0 "> and site_id = #{param.siteId} </if>
+					<if test="param.customerIds != null and param.customerIds.size() != 0">
+						and customer_id in <foreach collection="param.customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
+					</if>
+					<!--
 					<if test='param.programItems != null and param.programItems.size() != 0' >
 						and concentrator_id IN (
 								SELECT DISTINCT
@@ -594,6 +608,7 @@
 									) 
 								)
 					</if>
+					-->
 					<if test = "param.statDay != null and param.statDay != 0"> and stat_day = #{param.statDay}</if>
 				GROUP BY
 					customer_id,
@@ -659,6 +674,10 @@
 		</if>
 		<!-- 数据权限 -->
 		<if test="param.siteId != null and param.siteId != 0 "> and site_id = #{param.siteId} </if>
+		<if test="param.customerIds != null and param.customerIds.size() != 0">
+			and customer_id in <foreach collection="param.customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
+		</if>
+		<!--
 		<if test='param.programItems != null and param.programItems.size() != 0' >
 			and concentrator_id IN (
 			SELECT DISTINCT
@@ -681,6 +700,7 @@
 				)
 			)
 		</if>
+		-->
 		<if test = "param.statDay != null and param.statDay != 0"> and read_date = #{param.statDay}</if>
 		GROUP BY
 		customer_id,
@@ -716,6 +736,10 @@
 			</if>
 			<!-- 数据权限 -->
 			<if test="param.siteId != null and param.siteId != 0 "> and site_id = #{param.siteId} </if>
+			<if test="param.customerIds != null and param.customerIds.size() != 0">
+				and customer_id in <foreach collection="param.customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
+			</if>
+			<!--
 			<if test='param.programItems != null and param.programItems.size() != 0' >
 				and concentrator_id IN (
 				SELECT DISTINCT
@@ -738,6 +762,7 @@
 				)
 				)
 			</if>
+			-->
 			<if test = "param.statDay != null and param.statDay != 0"> and read_date = #{param.statDay}</if>
 		GROUP BY
 			customer_id,
@@ -805,6 +830,10 @@
 			</if>
 			<!-- 数据权限 -->
 			<if test="param.siteId != null and param.siteId != 0 "> and site_id = #{param.siteId} </if>
+			<if test="param.customerIds != null and param.customerIds.size() != 0">
+				and customer_id in <foreach collection="param.customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
+			</if>
+			<!--
 			<if test='param.programItems != null and param.programItems.size() != 0' >
 				and concentrator_id IN (
 					SELECT DISTINCT
@@ -827,6 +856,7 @@
 					)
 				)
 			</if>
+			-->
 			<if test = "param.statDay != null and param.statDay != 0"> and stat_month = #{param.statDay}</if>
 			GROUP BY
 			customer_id,