Browse Source

同步设备

lin 4 years ago
parent
commit
ed0e1cdaa2
20 changed files with 230 additions and 58 deletions
  1. 7 1
      meter-reading-common/src/main/java/com/huaxu/zoniot/dao/BuildingMapper.java
  2. 11 5
      meter-reading-common/src/main/java/com/huaxu/zoniot/dao/CommunityMapper.java
  3. 6 4
      meter-reading-common/src/main/java/com/huaxu/zoniot/model/BuildingData.java
  4. 3 2
      meter-reading-common/src/main/java/com/huaxu/zoniot/model/CommunityData.java
  5. 1 0
      meter-reading-common/src/main/java/com/huaxu/zoniot/model/DeviceData.java
  6. 28 0
      meter-reading-common/src/main/resources/mapper/BuildingMapper.xml
  7. 30 0
      meter-reading-common/src/main/resources/mapper/CommunityMapper.xml
  8. 43 13
      meter-reading-job/src/main/java/com/huaxu/zoniot/config/RabbitConfig.java
  9. 1 1
      meter-reading-job/src/main/java/com/huaxu/zoniot/dao/PushLogMapper.java
  10. 1 1
      meter-reading-job/src/main/java/com/huaxu/zoniot/entity/PushLog.java
  11. 2 2
      meter-reading-job/src/main/java/com/huaxu/zoniot/job/BuildingSyncJob.java
  12. 2 2
      meter-reading-job/src/main/java/com/huaxu/zoniot/job/CommunitySyncJob.java
  13. 20 9
      meter-reading-job/src/main/java/com/huaxu/zoniot/service/impl/BuildingSyncServiceImpl.java
  14. 20 9
      meter-reading-job/src/main/java/com/huaxu/zoniot/service/impl/CommunitySyncServiceImpl.java
  15. 11 3
      meter-reading-job/src/main/java/com/huaxu/zoniot/service/impl/MeterFileSyncServiceImpl.java
  16. 31 0
      meter-reading-job/src/main/java/com/huaxu/zoniot/web/TestController.java
  17. 1 1
      meter-reading-job/src/main/resources/application-job-dev.properties
  18. 8 1
      meter-reading-job/src/main/resources/mapper/PushLogMapper.xml
  19. 2 2
      meter-reading-wugang/src/main/java/com/zoniot/wg/controller/ExternalApiController.java
  20. 2 2
      smart-city-platform/src/main/java/com/bz/smart_city/excel/AbstractResolverExcelTemplate.java

+ 7 - 1
meter-reading-common/src/main/java/com/huaxu/zoniot/dao/BuildingMapper.java

@@ -1,13 +1,17 @@
 package com.huaxu.zoniot.dao;
 
 import com.huaxu.zoniot.entity.Building;
+
+import java.util.Date;
 import java.util.List;
 
+import com.huaxu.zoniot.model.BuildingData;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
 /**
  * <p></p>
+ *
  * @Author wilian.peng
  * @Date 2021/1/9 19:03
  * @Version 1.0
@@ -28,5 +32,7 @@ public interface BuildingMapper {
 
     int batchInsert(@Param("list") List<Building> list);
 
-    Building findBuildingByName(@Param("name")String name ,@Param("communityId") Integer communityId );
+    Building findBuildingByName(@Param("name") String name, @Param("communityId") Integer communityId);
+
+    List<BuildingData> getPushBuildingList(@Param("customers") String customers, @Param("status") Integer status, @Param("beginDate") Date beginDate, @Param("endDate") Date endDate);
 }

+ 11 - 5
meter-reading-common/src/main/java/com/huaxu/zoniot/dao/CommunityMapper.java

@@ -1,13 +1,17 @@
 package com.huaxu.zoniot.dao;
 
 import com.huaxu.zoniot.entity.Community;
+
+import java.util.Date;
 import java.util.List;
 
+import com.huaxu.zoniot.model.CommunityData;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
 /**
  * <p></p>
+ *
  * @Author wilian.peng
  * @Date 2021/1/9 19:04
  * @Version 1.0
@@ -23,15 +27,17 @@ public interface CommunityMapper {
     Community selectByPrimaryKey(Integer id);
 
     Community findCommunityWithName(@Param("name") String name,
-                            @Param("siteId") Integer siteId ,
-                            //@Param("customerId") Integer customerId ,
-                            @Param("province")Integer province,
-                            @Param("city") Integer city ,
-                            @Param("region") Integer region);
+                                    @Param("siteId") Integer siteId,
+                                    //@Param("customerId") Integer customerId ,
+                                    @Param("province") Integer province,
+                                    @Param("city") Integer city,
+                                    @Param("region") Integer region);
 
     int updateByPrimaryKeySelective(Community record);
 
     int updateByPrimaryKey(Community record);
 
     int batchInsert(@Param("list") List<Community> list);
+
+    List<CommunityData> getPushCommunityList(@Param("customers") String customers, @Param("status") Integer status, @Param("beginDate") Date beginDate, @Param("endDate") Date endDate);
 }

+ 6 - 4
meter-reading-common/src/main/java/com/huaxu/zoniot/model/BuildingData.java

@@ -1,8 +1,10 @@
 package com.huaxu.zoniot.model;
 
+import com.alibaba.fastjson.annotation.JSONField;
 import lombok.Data;
 
 import java.time.LocalDateTime;
+import java.util.Date;
 
 @Data
 public class BuildingData {
@@ -28,10 +30,10 @@ public class BuildingData {
     private Double latitude;
 
     private Integer status;
-
-    private LocalDateTime createDate;
-
-    private LocalDateTime updateDate;
+    @JSONField(format="yyyy-MM-dd HH:mm:ss")
+    private Date createDate;
+    @JSONField(format="yyyy-MM-dd HH:mm:ss")
+    private Date updateDate;
 
 
 }

+ 3 - 2
meter-reading-common/src/main/java/com/huaxu/zoniot/model/CommunityData.java

@@ -1,5 +1,6 @@
 package com.huaxu.zoniot.model;
 
+import com.alibaba.fastjson.annotation.JSONField;
 import lombok.Data;
 
 import java.time.LocalDateTime;
@@ -32,9 +33,9 @@ public class CommunityData {
     private String remark;
 
     private Integer status;
-
+    @JSONField(format="yyyy-MM-dd HH:mm:ss")
     private Date dateCreate;
-
+    @JSONField(format="yyyy-MM-dd HH:mm:ss")
     private Date dateUpdate;
 
 }

+ 1 - 0
meter-reading-common/src/main/java/com/huaxu/zoniot/model/DeviceData.java

@@ -21,6 +21,7 @@ public class DeviceData {
     private String locDesc;
     private Double meterReading;
     private Integer valveStatus;
+    private Integer status;
     @JSONField(format="yyyy-MM-dd HH:mm:ss")
     private Date lastReceiveTime;
     @JSONField(format="yyyy-MM-dd HH:mm:ss")

+ 28 - 0
meter-reading-common/src/main/resources/mapper/BuildingMapper.xml

@@ -732,4 +732,32 @@
       and community = #{communityId,jdbcType=INTEGER}
     limit 1
   </select>
+
+  <select id="getPushBuildingList" resultType="com.huaxu.zoniot.model.BuildingData">
+    select
+    sb.id,
+    sb.community as community_id,
+    sc.customer_id,
+    sb.name,
+    sb.address,
+    sb.province,
+    sb.city,
+    sb.region,
+    sb.longitude,
+    sb.latitude,
+    sb.status,
+    sb.create_date,
+    sb.update_date
+    from sc_building sb
+    LEFT JOIN sc_community sc on (sc.id =sb.community)
+    where 1 = 1
+    <if test="customers != null and customers != '' ">
+      AND FIND_IN_SET( sc.customer_id, #{customers} )
+    </if>
+    <if test="status != null">
+      AND sb.status = #{status}
+    </if>
+    and sb.update_date > #{beginDate ,jdbcType=TIMESTAMP }
+    and sb.update_date <![CDATA[ <= ]]> #{endDate ,jdbcType=TIMESTAMP }
+  </select>
 </mapper>

+ 30 - 0
meter-reading-common/src/main/resources/mapper/CommunityMapper.xml

@@ -276,4 +276,34 @@
       and region = #{region,jdbcType=INTEGER}
     limit 1
   </select>
+
+  <select id="getPushCommunityList" resultType="com.huaxu.zoniot.model.CommunityData">
+    select
+    sc.id,
+    sc.name,
+    sc.code,
+    sc.customer_id,
+    sc.province,
+    sc.city,
+    sc.region,
+    sc.longitude,
+    sc.latitude,
+    sc.district_id,
+    sc.address,
+    sc.remark,
+    sc.status,
+    sc.date_create,
+    sc.date_update
+    from sc_community sc
+
+    where 1 = 1
+    <if test="customers != null and customers != '' ">
+      AND FIND_IN_SET( sc.customer_id, #{customers} )
+    </if>
+    <if test="status != null">
+      AND sc.status = #{status}
+    </if>
+    and sc.date_update > #{beginDate ,jdbcType=TIMESTAMP }
+    and sc.date_update <![CDATA[ <= ]]> #{endDate ,jdbcType=TIMESTAMP }
+  </select>
 </mapper>

+ 43 - 13
meter-reading-job/src/main/java/com/huaxu/zoniot/config/RabbitConfig.java

@@ -1,10 +1,7 @@
 package com.huaxu.zoniot.config;
 
 
-import org.springframework.amqp.core.Binding;
-import org.springframework.amqp.core.BindingBuilder;
-import org.springframework.amqp.core.FanoutExchange;
-import org.springframework.amqp.core.Queue;
+import org.springframework.amqp.core.*;
 import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
 import org.springframework.amqp.rabbit.connection.ConnectionFactory;
 import org.springframework.beans.factory.annotation.Value;
@@ -26,25 +23,58 @@ public class RabbitConfig {
     @Value("${spring.rabbitmq.exchange}")
     private String exchange;
     @Value("${spring.rabbitmq.device.queue}")
-    private String queue;
+    private String deviceQueue;
 
+    @Value("${spring.rabbitmq.community.queue}")
+    private String communityQueue;
+
+    @Value("${spring.rabbitmq.building.queue}")
+    private String buildingQueue;
+
+
+    //创建队列
+    @Bean
+    public Queue createDeviceQueue() {
+        return new Queue(deviceQueue);
+    }
+
+    //创建队列
+    @Bean
+    public Queue createCommunityQueue() {
+        return new Queue(communityQueue);
+    }
 
     //创建队列
     @Bean
-    public Queue createFanoutQueue() {
-        return new Queue(queue);
+    public Queue createBuildingQueue() {
+        return new Queue(buildingQueue);
     }
+
+
     //创建交换机
     @Bean
-    public FanoutExchange defFanoutExchange() {
-        return new FanoutExchange(exchange);
+    public TopicExchange exchange() {
+        return new TopicExchange(exchange);
+    }
+
+
+
+    //对列绑定并关联到ROUTINGKEY
+    @Bean
+    Binding bindingDeviceExchangeMessage(Queue createDeviceQueue, TopicExchange exchange) {
+        return BindingBuilder.bind(createDeviceQueue).to(exchange).with(deviceQueue);
+    }
+
+    //对列绑定并关联到ROUTINGKEY
+    @Bean
+    Binding bindingCommunityExchangeMessage(Queue createCommunityQueue, TopicExchange exchange) {
+        return BindingBuilder.bind(createCommunityQueue).to(exchange).with(communityQueue);
     }
 
-    //队列与交换机进行绑定
+    //对列绑定并关联到ROUTINGKEY
     @Bean
-    Binding bindingFanout() {
-        return BindingBuilder.bind(createFanoutQueue()).
-                to(defFanoutExchange());
+    Binding bindingBuildingExchangeMessage(Queue createBuildingQueue, TopicExchange exchange) {
+        return BindingBuilder.bind(createBuildingQueue).to(exchange).with(buildingQueue);
     }
 
 

+ 1 - 1
meter-reading-job/src/main/java/com/huaxu/zoniot/dao/PushLogMapper.java

@@ -34,5 +34,5 @@ public interface PushLogMapper {
      */
     PushLog findLastRecord(@Param("configId") Integer configId, @Param("pushContent") Integer pushContent);
 
-    PushLog findLastRecordBycustomerId(@Param("customerId") Integer customerId);
+    PushLog findLastRecordBycustomerId(@Param("customerId") Integer customerId, @Param("pushContent") Integer pushContent);
 }

+ 1 - 1
meter-reading-job/src/main/java/com/huaxu/zoniot/entity/PushLog.java

@@ -17,7 +17,7 @@ public class PushLog {
     private Integer id;
 
     /**
-    * 推送内容 1,档案 2,数据
+    * 推送内容 1,档案 2,数据 3,设备 4,小区 5,建筑
     */
     private Integer pushContent;
 

+ 2 - 2
meter-reading-job/src/main/java/com/huaxu/zoniot/job/BuildingSyncJob.java

@@ -18,8 +18,8 @@ public class BuildingSyncJob {
     @Autowired
     private BuildingSyncService buildingSyncService;
 
-    @XxlJob("deviceSyncJobHandler")
-    public ReturnT<String> deviceSyncJobHandler(String param) throws Exception {
+    @XxlJob("buildingSyncJobHandler")
+    public ReturnT<String> buildingSyncJobHandler(String param) throws Exception {
         XxlJobLogger.log("XXL-JOB, device Sync Job.Param = {}",param);
         Map<String,Object> paramMap = JSON.parseObject(param , Map.class);
         int total = buildingSyncService.rabbitSync();

+ 2 - 2
meter-reading-job/src/main/java/com/huaxu/zoniot/job/CommunitySyncJob.java

@@ -19,8 +19,8 @@ public class CommunitySyncJob {
     @Autowired
     private CommunitySyncService communitySyncService;
 
-    @XxlJob("deviceSyncJobHandler")
-    public ReturnT<String> deviceSyncJobHandler(String param) throws Exception {
+    @XxlJob("communitySyncJobHandler")
+    public ReturnT<String> communitySyncJobHandler(String param) throws Exception {
         XxlJobLogger.log("XXL-JOB, device Sync Job.Param = {}",param);
         Map<String,Object> paramMap = JSON.parseObject(param , Map.class);
         int total = communitySyncService.rabbitSync();

+ 20 - 9
meter-reading-job/src/main/java/com/huaxu/zoniot/service/impl/BuildingSyncServiceImpl.java

@@ -2,9 +2,11 @@ package com.huaxu.zoniot.service.impl;
 
 import cn.hutool.core.date.DateUtil;
 import com.alibaba.fastjson.JSON;
+import com.huaxu.zoniot.dao.BuildingMapper;
 import com.huaxu.zoniot.dao.CustomerMapper;
 import com.huaxu.zoniot.dao.PushLogMapper;
 import com.huaxu.zoniot.entity.PushLog;
+import com.huaxu.zoniot.model.BuildingData;
 import com.huaxu.zoniot.model.DeviceData;
 import com.huaxu.zoniot.service.BuildingSyncService;
 import lombok.extern.slf4j.Slf4j;
@@ -15,6 +17,7 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.nio.charset.Charset;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -26,6 +29,8 @@ public class BuildingSyncServiceImpl implements BuildingSyncService {
     PushLogMapper pushLogMapper;
     @Autowired
     CustomerMapper customerMapper;
+    @Autowired
+    BuildingMapper buildingMapper;
 
     @Resource
     private RabbitTemplate rabbitTemplate;
@@ -37,12 +42,12 @@ public class BuildingSyncServiceImpl implements BuildingSyncService {
     @Override
     public int rabbitSync() {
         List<Integer> customerIds = new ArrayList<>();
-        customerIds.add(54);
+        customerIds.add(127);
 
         if (customerIds != null && customerIds.size() > 0) {
             for (Integer customerId : customerIds) {
                 // 1,查询推送记录,1档案;2数据
-                PushLog lastLog = pushLogMapper.findLastRecordBycustomerId(customerId);
+                PushLog lastLog = pushLogMapper.findLastRecordBycustomerId(customerId,5);
                 // 2,计算推送数据时间;如果为首次推送,则判断是否需要将历史数据推送给对方;
                 Date beginDate = null ;
                 Date endDate = new Date();
@@ -58,11 +63,9 @@ public class BuildingSyncServiceImpl implements BuildingSyncService {
                 // 3,根据推送数据时间进行数据查询
                 List<Integer> cIds = customerMapper.getSubId(customerId);
                 String pushCustomers = StringUtils.join(cIds, ",");
-                String pushChannels = "40,55";
                 log.info("begin query push device list , beginDate={}, endDate={}",
                         beginDate, endDate);
-                /*List<DeviceData> dataList = waterMeterMapper.getPushMeterListV2(pushCustomers,
-                        pushChannels,
+                List<BuildingData> dataList = buildingMapper.getPushBuildingList(pushCustomers,
                         status,
                         beginDate,
                         endDate);
@@ -70,17 +73,25 @@ public class BuildingSyncServiceImpl implements BuildingSyncService {
                 log.info("end query push device list , size = {}",dataList.size());
                 if(dataList.size() != 0) {
                     sendRabbitData(dataList);
-                }*/
+                }
+                // 4,定义push日志
+                PushLog pushLog = new PushLog();
+                pushLog.setDataSize(dataList.size());
+                pushLog.setCustomerId(customerId);
+                pushLog.setDateCreate(new Date());
+                pushLog.setPushTime(endDate);
+                pushLog.setPushContent(5);
+                pushLogMapper.insertSelective(pushLog);
             }
         }
         return 0;
     }
 
-    private void sendRabbitData(List<DeviceData> dataList) {
-        for (DeviceData data : dataList) {
+    private void sendRabbitData(List<BuildingData> dataList) {
+        for (BuildingData data : dataList) {
             String msg = JSON.toJSONString(data);
             log.info("transfer mq msg:{}",msg);
-            //rabbitTemplate.convertAndSend(exchange, queue,msg.getBytes(Charset.forName("UTF-8")));
+            rabbitTemplate.convertAndSend(exchange, queue,msg.getBytes(Charset.forName("UTF-8")));
         }
     }
 }

+ 20 - 9
meter-reading-job/src/main/java/com/huaxu/zoniot/service/impl/CommunitySyncServiceImpl.java

@@ -2,9 +2,11 @@ package com.huaxu.zoniot.service.impl;
 
 import cn.hutool.core.date.DateUtil;
 import com.alibaba.fastjson.JSON;
+import com.huaxu.zoniot.dao.CommunityMapper;
 import com.huaxu.zoniot.dao.CustomerMapper;
 import com.huaxu.zoniot.dao.PushLogMapper;
 import com.huaxu.zoniot.entity.PushLog;
+import com.huaxu.zoniot.model.CommunityData;
 import com.huaxu.zoniot.model.DeviceData;
 import com.huaxu.zoniot.service.CommunitySyncService;
 import lombok.extern.slf4j.Slf4j;
@@ -15,6 +17,7 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.nio.charset.Charset;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -27,6 +30,8 @@ public class CommunitySyncServiceImpl implements CommunitySyncService {
     PushLogMapper pushLogMapper;
     @Autowired
     CustomerMapper customerMapper;
+    @Autowired
+    CommunityMapper communityMapper;
     @Resource
     private RabbitTemplate rabbitTemplate;
     @Value("${spring.rabbitmq.exchange}")
@@ -37,12 +42,12 @@ public class CommunitySyncServiceImpl implements CommunitySyncService {
     @Override
     public int rabbitSync() {
         List<Integer> customerIds = new ArrayList<>();
-        customerIds.add(54);
+        customerIds.add(127);
 
         if (customerIds != null && customerIds.size() > 0) {
             for (Integer customerId : customerIds) {
                 // 1,查询推送记录,1档案;2数据
-                PushLog lastLog = pushLogMapper.findLastRecordBycustomerId(customerId);
+                PushLog lastLog = pushLogMapper.findLastRecordBycustomerId(customerId,4);
                 // 2,计算推送数据时间;如果为首次推送,则判断是否需要将历史数据推送给对方;
                 Date beginDate = null ;
                 Date endDate = new Date();
@@ -58,11 +63,9 @@ public class CommunitySyncServiceImpl implements CommunitySyncService {
                 // 3,根据推送数据时间进行数据查询
                 List<Integer> cIds = customerMapper.getSubId(customerId);
                 String pushCustomers = StringUtils.join(cIds, ",");
-                String pushChannels = "40,55";
                 log.info("begin query push device list , beginDate={}, endDate={}",
                         beginDate, endDate);
-                /*List<DeviceData> dataList = waterMeterMapper.getPushMeterListV2(pushCustomers,
-                        pushChannels,
+                List<CommunityData> dataList = communityMapper.getPushCommunityList(pushCustomers,
                         status,
                         beginDate,
                         endDate);
@@ -70,17 +73,25 @@ public class CommunitySyncServiceImpl implements CommunitySyncService {
                 log.info("end query push device list , size = {}",dataList.size());
                 if(dataList.size() != 0) {
                     sendRabbitData(dataList);
-                }*/
+                }
+                // 4,定义push日志
+                PushLog pushLog = new PushLog();
+                pushLog.setDataSize(dataList.size());
+                pushLog.setCustomerId(customerId);
+                pushLog.setDateCreate(new Date());
+                pushLog.setPushTime(endDate);
+                pushLog.setPushContent(4);
+                pushLogMapper.insertSelective(pushLog);
             }
         }
         return 0;
     }
 
-    private void sendRabbitData(List<DeviceData> dataList) {
-        for (DeviceData data : dataList) {
+    private void sendRabbitData(List<CommunityData> dataList) {
+        for (CommunityData data : dataList) {
             String msg = JSON.toJSONString(data);
             log.info("transfer mq msg:{}",msg);
-            //rabbitTemplate.convertAndSend(exchange, queue,msg.getBytes(Charset.forName("UTF-8")));
+            rabbitTemplate.convertAndSend(exchange, queue,msg.getBytes(Charset.forName("UTF-8")));
         }
     }
 }

+ 11 - 3
meter-reading-job/src/main/java/com/huaxu/zoniot/service/impl/MeterFileSyncServiceImpl.java

@@ -274,12 +274,12 @@ public class MeterFileSyncServiceImpl  implements MeterFileSyncService {
     public int rabbitSync() {
 
         List<Integer> customerIds = new ArrayList<>();
-        customerIds.add(54);
+        customerIds.add(127);
 
         if (customerIds != null && customerIds.size() > 0) {
             for (Integer customerId : customerIds) {
                 // 1,查询推送记录,1档案;2数据
-                PushLog lastLog = pushLogMapper.findLastRecordBycustomerId(customerId);
+                PushLog lastLog = pushLogMapper.findLastRecordBycustomerId(customerId,3);
                 // 2,计算推送数据时间;如果为首次推送,则判断是否需要将历史数据推送给对方;
                 Date beginDate = null ;
                 Date endDate = new Date();
@@ -308,6 +308,14 @@ public class MeterFileSyncServiceImpl  implements MeterFileSyncService {
                 if(dataList.size() != 0) {
                     sendRabbitData(dataList);
                 }
+                // 1,定义push日志
+                PushLog pushLog = new PushLog();
+                pushLog.setDataSize(dataList.size());
+                pushLog.setCustomerId(customerId);
+                pushLog.setDateCreate(new Date());
+                pushLog.setPushTime(endDate);
+                pushLog.setPushContent(3);
+                pushLogMapper.insertSelective(pushLog);
             }
         }
 
@@ -318,7 +326,7 @@ public class MeterFileSyncServiceImpl  implements MeterFileSyncService {
         for (DeviceData data : dataList) {
             String msg = JSON.toJSONString(data);
             log.info("transfer mq msg:{}",msg);
-            //rabbitTemplate.convertAndSend(exchange, queue,msg.getBytes(Charset.forName("UTF-8")));
+            rabbitTemplate.convertAndSend(exchange, queue,msg.getBytes(Charset.forName("UTF-8")));
         }
     }
 }

+ 31 - 0
meter-reading-job/src/main/java/com/huaxu/zoniot/web/TestController.java

@@ -1,5 +1,8 @@
 package com.huaxu.zoniot.web;
 
+import com.huaxu.zoniot.entity.Community;
+import com.huaxu.zoniot.job.BuildingSyncJob;
+import com.huaxu.zoniot.job.CommunitySyncJob;
 import com.huaxu.zoniot.job.MeterFileSyncJob;
 import io.swagger.annotations.Api;
 import lombok.extern.slf4j.Slf4j;
@@ -16,6 +19,10 @@ public class TestController {
 
     @Autowired
     private MeterFileSyncJob meterFileSyncJob;
+    @Autowired
+    private BuildingSyncJob buildingSyncJob;
+    @Autowired
+    private CommunitySyncJob communitySyncJob;
 
     @GetMapping(value = "pushDevice")
     public String pushDevice(
@@ -28,4 +35,28 @@ public class TestController {
         }
         return "ok";
     }
+
+    @GetMapping(value = "pushBuilding")
+    public String pushBuilding(
+
+    ) {
+        try {
+            buildingSyncJob.buildingSyncJobHandler(null);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return "ok";
+    }
+
+    @GetMapping(value = "pushCommunity")
+    public String pushCommunity(
+
+    ) {
+        try {
+            communitySyncJob.communitySyncJobHandler(null);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return "ok";
+    }
 }

+ 1 - 1
meter-reading-job/src/main/resources/application-job-dev.properties

@@ -28,7 +28,7 @@ spring.rabbitmq.listener.direct.acknowledge-mode=manual
 spring.rabbitmq.listener.simple.acknowledge-mode=manual
 # �������
 job.task.rabbit.exchange=job-task-exchange
-spring.rabbitmq.exchange=batch-handler-exchange
+spring.rabbitmq.exchange=sync-handler-exchange
 spring.rabbitmq.device.queue=sync-device-handler-queue
 spring.rabbitmq.community.queue=sync-community-handler-queue
 spring.rabbitmq.building.queue=sync-building-handler-queue

+ 8 - 1
meter-reading-job/src/main/resources/mapper/PushLogMapper.xml

@@ -53,6 +53,9 @@
       <if test="pushConfigId != null">
         push_config_id,
       </if>
+      <if test="customerId != null">
+        customer_id,
+      </if>
       <if test="pushTime != null">
         push_time,
       </if>
@@ -82,6 +85,9 @@
       <if test="pushConfigId != null">
         #{pushConfigId,jdbcType=INTEGER},
       </if>
+      <if test="customerId != null">
+        #{customerId,jdbcType=INTEGER},
+      </if>
       <if test="pushTime != null">
         #{pushTime,jdbcType=TIMESTAMP},
       </if>
@@ -170,7 +176,8 @@
     from
     sc_push_log
     where
-    customer_id = #{customerId}
+    push_content = #{pushContent}
+    and customer_id = #{customerId}
     order by push_time desc limit 1
     </select>
 </mapper>

+ 2 - 2
meter-reading-wugang/src/main/java/com/zoniot/wg/controller/ExternalApiController.java

@@ -51,7 +51,7 @@ public class ExternalApiController {
     public RequestDto updateUserCode(
             @ApiParam(value = "结果", required = true) @RequestBody(required = true) RequestDto result
     ) {
-        log.info("updateUserCode result = " + result);
+        log.info("updateUserCode result = " + JSON.toJSONString(result));
         RequestDto requestDto = new RequestDto();
         requestDto.setHead(result.getHead());
         requestDto.getHead().setTime(LocalDateTime.now().format(df));
@@ -105,7 +105,7 @@ public class ExternalApiController {
     public RequestDto getMeterReadList(
             @ApiParam(value = "结果", required = true) @RequestBody(required = true) RequestDto result
     ) {
-        log.info("getMeterReadList result = " + result);
+        log.info("getMeterReadList result = {}" + JSON.toJSONString(result));
         RequestDto requestDto = new RequestDto();
         requestDto.setHead(result.getHead());
         requestDto.getHead().setTime(LocalDateTime.now().format(df));

+ 2 - 2
smart-city-platform/src/main/java/com/bz/smart_city/excel/AbstractResolverExcelTemplate.java

@@ -1,5 +1,6 @@
 package com.bz.smart_city.excel;
 
+import com.alibaba.fastjson.JSON;
 import com.bz.smart_city.commom.util.FileUtil;
 import com.bz.smart_city.commom.util.Util;
 import com.bz.smart_city.entity.Import;
@@ -75,7 +76,6 @@ public abstract class AbstractResolverExcelTemplate {
             failFile();
             recordMessage();
         } catch (Exception e) {
-            e.printStackTrace();
             messageContent.append("导入失败,读取文件错误。");
             Message message = new Message();
             message.setSiteId(record.getUserId());
@@ -86,7 +86,7 @@ public abstract class AbstractResolverExcelTemplate {
             message.setObjId(record.getId());
             message.setRead(0);
             messageService.insertSelective(message);
-            log.error("read excel error = " + e.getMessage());
+            log.error("read excel error = {} {}" , e.getMessage(), JSON.toJSON(e));
         }finally {
             FileUtil.deleteFile(record.getImportFilePath());
             try {