Ver código fonte

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

hym 4 anos atrás
pai
commit
99d5ae1183
28 arquivos alterados com 639 adições e 78 exclusões
  1. 8 1
      meter-reading-batch/pom.xml
  2. 14 1
      meter-reading-common/pom.xml
  3. 51 0
      meter-reading-common/src/main/java/com/huaxu/zoniot/config/MongoDBConfig.java
  4. 41 1
      meter-reading-common/src/main/java/com/huaxu/zoniot/entity/MeterReadRecord.java
  5. 26 0
      meter-reading-common/src/main/java/com/huaxu/zoniot/entity/WaterMeter.java
  6. 14 0
      meter-reading-common/src/main/java/com/huaxu/zoniot/repository/MeterReadRecordRepository.java
  7. 83 21
      meter-reading-common/src/main/java/com/huaxu/zoniot/service/impl/MeterReadRecordServiceImpl.java
  8. 8 0
      meter-reading-common/src/main/resources/application-common-dev.properties
  9. 8 0
      meter-reading-common/src/main/resources/application-common-sit.properties
  10. 4 3
      meter-reading-common/src/main/resources/mapper/MeterReadRecordMapper.xml
  11. 37 1
      meter-reading-common/src/main/resources/mapper/WaterMeterMapper.xml
  12. 4 1
      meter-reading-job/pom.xml
  13. 5 4
      meter-reading-service/pom.xml
  14. 2 2
      meter-reading-service/src/main/resources/application-service-dev.properties
  15. 0 13
      meter-reading-service/src/test/java/com/huaxu/zoniot/MeterReadRateServiceTests.java
  16. 35 6
      meter-reading-service/src/test/java/com/huaxu/zoniot/MeterReadingServiceTests.java
  17. 6 2
      smart-city-intf/pom.xml
  18. 51 0
      smart-city-intf/src/main/java/com/zcxk/smartcity/data/access/config/MongoDBConfig.java
  19. 107 0
      smart-city-intf/src/main/java/com/zcxk/smartcity/data/access/dto/DeviceData.java
  20. 14 0
      smart-city-intf/src/main/java/com/zcxk/smartcity/data/access/repository/DeviceDataRepository.java
  21. 47 5
      smart-city-intf/src/main/java/com/zcxk/smartcity/data/access/service/impl/DeviceDataServiceImpl.java
  22. 49 2
      smart-city-intf/src/main/java/com/zcxk/smartcity/data/access/service/impl/DeviceDataServiceV2Impl.java
  23. 4 1
      smart-city-intf/src/main/resources/application-188sit.properties
  24. 5 6
      smart-city-intf/src/main/resources/application-dev.properties
  25. 3 1
      smart-city-intf/src/main/resources/application-sit-node0.properties
  26. 4 2
      smart-city-intf/src/main/resources/application-sit-node1.properties
  27. 4 3
      smart-city-intf/src/main/resources/application-test.properties
  28. 5 2
      smart-city-intf/src/main/resources/application-uat.properties

+ 8 - 1
meter-reading-batch/pom.xml

@@ -6,13 +6,17 @@
     <parent>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-parent</artifactId>
-        <version>2.3.1.RELEASE</version>
+        <version>2.2.6.RELEASE</version>
         <relativePath/> <!-- lookup parent from repository -->
     </parent>
     <groupId>com.huaxu.zoniot</groupId>
     <artifactId>meter-reading-batch</artifactId>
     <version>1.0</version>
     <description>抄表批处理模块</description>
+    <properties>
+        <maven.build.timestamp.format>yyyyMMdd</maven.build.timestamp.format>
+    </properties>
+
     <dependencies>
         <dependency>
             <groupId>com.huaxu.zoniot</groupId>
@@ -40,6 +44,9 @@
         </dependency>
     </dependencies>
     <build>
+        <finalName>
+            ${project.artifactId}-${project.version}-${maven.build.timestamp}
+        </finalName>
         <plugins>
             <plugin>
                 <groupId>org.springframework.boot</groupId>

+ 14 - 1
meter-reading-common/pom.xml

@@ -6,13 +6,16 @@
     <parent>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-parent</artifactId>
-        <version>2.3.1.RELEASE</version>
+        <version>2.2.6.RELEASE</version>
         <relativePath/> <!-- lookup parent from repository -->
     </parent>
     <groupId>com.huaxu.zoniot</groupId>
     <artifactId>meter-reading-common</artifactId>
     <version>1.0</version>
     <description>抄表通用功能模块</description>
+    <properties>
+        <maven.build.timestamp.format>yyyyMMdd</maven.build.timestamp.format>
+    </properties>
     <dependencies>
         <!-- Redis -->
         <dependency>
@@ -35,6 +38,10 @@
             <groupId>org.apache.commons</groupId>
             <artifactId>commons-lang3</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-pool2</artifactId>
+        </dependency>
         <!-- 糊涂工具包 -->
         <dependency>
             <groupId>cn.hutool</groupId>
@@ -51,10 +58,16 @@
             <groupId>mysql</groupId>
             <artifactId>mysql-connector-java</artifactId>
         </dependency>
+        <!-- mybatis -->
         <dependency>
             <groupId>org.mybatis.spring.boot</groupId>
             <artifactId>mybatis-spring-boot-starter</artifactId>
             <version>2.1.3</version>
         </dependency>
+        <!-- mongodb -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-mongodb</artifactId>
+        </dependency>
     </dependencies>
 </project>

+ 51 - 0
meter-reading-common/src/main/java/com/huaxu/zoniot/config/MongoDBConfig.java

@@ -0,0 +1,51 @@
+package com.huaxu.zoniot.config;
+
+import com.mongodb.MongoClientOptions;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.convert.CustomConversions;
+import org.springframework.data.mongodb.MongoDbFactory;
+import org.springframework.data.mongodb.core.convert.DbRefResolver;
+import org.springframework.data.mongodb.core.convert.DefaultDbRefResolver;
+import org.springframework.data.mongodb.core.convert.DefaultMongoTypeMapper;
+import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
+import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
+
+/**
+ * @author pengdi
+ */
+@Configuration
+public class MongoDBConfig {
+    /**
+     * <p>解决 MongoSocketReadTimeoutException异常</p>
+     * @return
+     */
+    @Bean
+    public MongoClientOptions mongoOptions() {
+        return MongoClientOptions
+            .builder()
+            .maxConnectionIdleTime(60000)
+            .build();
+    }
+
+    /**
+     * <p>去除文档中的_class字段</p>
+     * @param factory
+     * @param context
+     * @param beanFactory
+     * @return
+     */
+    @Bean
+    public MappingMongoConverter mappingMongoConverter(MongoDbFactory factory, MongoMappingContext context, BeanFactory beanFactory) {
+        DbRefResolver dbRefResolver = new DefaultDbRefResolver(factory);
+        MappingMongoConverter mappingConverter = new MappingMongoConverter(dbRefResolver, context);
+        try {
+            mappingConverter.setCustomConversions(beanFactory.getBean(CustomConversions.class));
+        } catch (NoSuchBeanDefinitionException ignore) {
+        }
+        mappingConverter.setTypeMapper(new DefaultMongoTypeMapper(null));
+        return mappingConverter;
+    }
+}

+ 41 - 1
meter-reading-common/src/main/java/com/huaxu/zoniot/entity/MeterReadRecord.java

@@ -1,18 +1,25 @@
 package com.huaxu.zoniot.entity;
 
 import lombok.Data;
+import org.springframework.data.mongodb.core.mapping.Document;
 
+import java.io.Serializable;
 import java.math.BigDecimal;
 import java.util.Date;
+import java.util.Map;
 
 /**
  * <p>抄表记录</p>
+ * sh.enableSharding("meter-reading-database");
+ * sh.shardCollection("meter-reading-database.sc_meter_read_record",{"readDate":1,"deviceId":1});
+ * db.sc_meter_read_record.createIndex({readDate:1,customerId:1,buildingId:1,siteId:1,sysId:1,readStatus:1,concentratorId:1},{background: true,name:'idx_1'})
  * @Author wilian.peng
  * @Date 2020/12/22 16:59
  * @Version 1.0
  */
 @Data
-public class MeterReadRecord {
+@Document(collection = "sc_meter_read_record")
+public class MeterReadRecord implements Serializable {
     /**
     * 主键
     */
@@ -152,4 +159,37 @@ public class MeterReadRecord {
     * 更新人
     */
     private String updateBy;
+
+    /***********************************以下字段将存入MongoDB中**************************************/
+    private String communityName;
+
+    private String buildingName ;
+
+    private String customerName ;
+
+    private String provinceName ;
+
+    private String cityName ;
+
+    private String regionName ;
+
+    private String deviceTypeName ;
+
+    private String concentratorNo ;
+
+    private String collectorNo ;
+
+    private Integer manufacturerId ;
+
+    private String manufacturerName ;
+
+    private Integer channelNumberId;
+
+    private String channelName ;
+
+    /**
+     * 最后上送数据,格式如下:
+     * {"数据ID":11111,data:{"WSV":"1","VOL":"2.5"}}
+     */
+    private Map<String, String> lastSendData ;
 }

+ 26 - 0
meter-reading-common/src/main/java/com/huaxu/zoniot/entity/WaterMeter.java

@@ -136,4 +136,30 @@ public class WaterMeter {
      */
     private String updateBy;
 
+    /***********************************以下字段将存入MongoDB中**************************************/
+    private String communityName;
+
+    private String buildingName ;
+
+    private String customerName ;
+
+    private String provinceName ;
+
+    private String cityName ;
+
+    private String regionName ;
+
+    private String deviceTypeName ;
+
+    private String concentratorNo ;
+
+    private String collectorNo ;
+
+    private Integer manufacturerId ;
+
+    private String manufacturerName ;
+
+    private Integer channelNumberId;
+
+    private String channelName ;
 }

+ 14 - 0
meter-reading-common/src/main/java/com/huaxu/zoniot/repository/MeterReadRecordRepository.java

@@ -0,0 +1,14 @@
+package com.huaxu.zoniot.repository;
+
+import com.huaxu.zoniot.entity.MeterReadRecord;
+import org.springframework.data.mongodb.repository.MongoRepository;
+
+/**
+ * <p></p>
+ *
+ * @Author wilian.peng
+ * @Date 2021/1/6 18:14
+ * @Version 1.0
+ */
+public interface MeterReadRecordRepository extends MongoRepository<MeterReadRecord,Long> {
+}

+ 83 - 21
meter-reading-common/src/main/java/com/huaxu/zoniot/service/impl/MeterReadRecordServiceImpl.java

@@ -16,12 +16,15 @@ import com.huaxu.zoniot.entity.JobTask;
 import com.huaxu.zoniot.entity.MeasuringData;
 import com.huaxu.zoniot.entity.MeterReadRecord;
 import com.huaxu.zoniot.entity.WaterMeter;
+import com.huaxu.zoniot.repository.MeterReadRecordRepository;
 import com.huaxu.zoniot.service.MeterReadRecordService;
 import com.huaxu.zoniot.utils.RedisUtil;
 import com.huaxu.zoniot.utils.SnowflakeIdWorker;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.time.StopWatch;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.mongodb.core.MongoTemplate;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Isolation;
 import org.springframework.transaction.annotation.Propagation;
@@ -29,10 +32,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * <p>抄表记录服务实现类</p>
@@ -55,6 +55,8 @@ public class MeterReadRecordServiceImpl implements MeterReadRecordService {
     @Resource
     RedisUtil redisUtil ;
 
+    @Autowired
+    MeterReadRecordRepository meterReadRecordRepository ;
     /**
      * 根据任务生成未抄记录
      * @param jobTask
@@ -97,11 +99,12 @@ public class MeterReadRecordServiceImpl implements MeterReadRecordService {
         }
         else{
             List<MeterReadRecord> meterReadRecordList = new ArrayList<>();
+            List<MeterReadRecord> meterReadRecordListForMongo = new ArrayList<>();
             for (WaterMeter waterMeter : waterMeterList){
                 MeterReadRecord meterReadRecord = buildUnReadRecord(waterMeter, readDay);
                 if(meterReadRecord != null){
-
                     meterReadRecordList.add(meterReadRecord);
+                    meterReadRecordListForMongo.add(meterReadRecord);
                 }
                 if (meterReadRecordList.size() == Constants.BATCH_SIZE){
                     // 按批次提交
@@ -115,6 +118,14 @@ public class MeterReadRecordServiceImpl implements MeterReadRecordService {
                 i = i+insert ;
                 meterReadRecordList.clear();
             }
+            if(meterReadRecordListForMongo.size() != 0){
+                try {
+                    meterReadRecordRepository.saveAll(meterReadRecordListForMongo);
+                }catch (Exception e){
+                    e.printStackTrace();
+                    log.error("Batch insert meter read record to mongo failed !",e);
+                }
+            }
         }
         log.info("end batch create meter record , readDay={} ,result size = {}",readDay,i);
         return i;
@@ -139,17 +150,17 @@ public class MeterReadRecordServiceImpl implements MeterReadRecordService {
      * @return
      */
     protected MeterReadRecord buildUnReadRecord(WaterMeter waterMeter , Integer readDay){
-        if(compareMeterReadDay(readDay) == 0){
-            // 生成今日的未抄,从缓存中获取最新的数据,若最新的数据不为今日数据才生成今日未抄
-            Map<String, MeasuringData> cacheMeasuringData = getMeterLastDataFromCache(waterMeter.getDeviceId());
-            if(cacheMeasuringData != null){
-                Date lastSendTime = getDateFromMeterData(cacheMeasuringData);
-                if(lastSendTime.after(DateUtil.parse(String.valueOf(readDay),Constants.DEFAULT_METER_READ_DATE_FORMAT))){
-                    log.warn("Don't Need Create UnRead Record , Device = {},Last Send Time = {}",waterMeter.getDeviceId(),lastSendTime);
-                    return  null ;
-                }
-            }
-        }
+//        if(compareMeterReadDay(readDay) == 0){
+//            // 生成今日的未抄,从缓存中获取最新的数据,若最新的数据不为今日数据才生成今日未抄
+//            Map<String, MeasuringData> cacheMeasuringData = getMeterLastDataFromCache(waterMeter.getDeviceId());
+//            if(cacheMeasuringData != null){
+//                Date lastSendTime = getDateFromMeterData(cacheMeasuringData);
+//                if(lastSendTime.after(DateUtil.parse(String.valueOf(readDay),Constants.DEFAULT_METER_READ_DATE_FORMAT))){
+//                    log.warn("Don't Need Create UnRead Record , Device = {},Last Send Time = {}",waterMeter.getDeviceId(),lastSendTime);
+//                    return  null ;
+//                }
+//            }
+//        }
         MeterReadRecord meterReadRecord = new MeterReadRecord() ;
         meterReadRecord.setBuildingId(waterMeter.getBuildingId());
         meterReadRecord.setCity(waterMeter.getCity());
@@ -176,6 +187,21 @@ public class MeterReadRecordServiceImpl implements MeterReadRecordService {
         meterReadRecord.setSysId(waterMeter.getSysId());
         meterReadRecord.setProvince(waterMeter.getProvince());
         meterReadRecord.setLastValid(getMeterLastValid(waterMeter,readDay));
+        /*********************如下字段为了MongoDB的需要**************************/
+        meterReadRecord.setProvinceName(waterMeter.getProvinceName());
+        meterReadRecord.setCityName(waterMeter.getCityName());
+        meterReadRecord.setRegionName(waterMeter.getRegionName());
+        meterReadRecord.setCustomerName(waterMeter.getCustomerName());
+        meterReadRecord.setDeviceTypeName(waterMeter.getDeviceTypeName());
+        meterReadRecord.setManufacturerId(waterMeter.getManufacturerId());
+        meterReadRecord.setManufacturerName(waterMeter.getManufacturerName());
+        meterReadRecord.setConcentratorNo(waterMeter.getConcentratorNo());
+        meterReadRecord.setCollectorNo(waterMeter.getCollectorNo());
+        meterReadRecord.setBuildingName(waterMeter.getBuildingName());
+        meterReadRecord.setCommunityName(waterMeter.getCommunityName());
+        meterReadRecord.setChannelNumberId(waterMeter.getChannelNumberId());
+        meterReadRecord.setChannelName(waterMeter.getChannelName());
+
         return meterReadRecord ;
     }
 
@@ -299,8 +325,10 @@ public class MeterReadRecordServiceImpl implements MeterReadRecordService {
             // 判断数据上报时间与抄表日期是否匹配
             Date sendTime = getDateFromMeterData(measuringData);
             DateTime readDate = DateUtil.parse(String.valueOf(readDay), Constants.DEFAULT_METER_READ_DATE_FORMAT);
+            // 允许一个小时日切延时
             int hour = 24 ;
-            if(sendTime.before(readDate) || sendTime.after(DateUtil.offsetHour(readDate,hour))){
+            if(sendTime.before(DateUtil.offsetHour(readDate,-1)) ||
+                    sendTime.after(DateUtil.offsetHour(readDate,hour))){
                 log.error("表{}数据异常,抄表时间与上报时间不匹配,上报时间{} != 本次抄表时间{}",
                         waterMeter.getDeviceId(),sendTime,readDate);
                 throw new ServiceException(ResultStatus.READING_ERROR_2);
@@ -310,7 +338,15 @@ public class MeterReadRecordServiceImpl implements MeterReadRecordService {
             if(record == null){
                 // 抄表记录不存在,则生成今日未抄表记录
                 record = buildUnReadRecord(waterMeter,readDay);
-                meterReadRecordMapper.insert(record);
+                if(record != null){
+                    meterReadRecordMapper.insert(record);
+                    // 同时也插入一份到mongo中
+                    meterReadRecordRepository.insert(record);
+                }
+                else{
+                    throw new ServiceException(ResultStatus.READING_ERROR_3);
+                }
+
             }
             // 根据上报数据更新抄表数据
             if(record.getReadStatus().equals(Constants.READ)){
@@ -329,7 +365,9 @@ public class MeterReadRecordServiceImpl implements MeterReadRecordService {
                 throw new ServiceException(ResultStatus.READING_ERROR_4);
             }
             // 计算今日用水量
-            BigDecimal todayCost = calculateTodayCost(currentReading, record);
+            BigDecimal todayCost = calculateTodayCost(currentReading,
+                    new BigDecimal(getMeterLastValid(waterMeter,readDay)),
+                    record);
             MeterReadRecord update = new MeterReadRecord();
             update.setId(record.getId());
             update.setLastCost(todayCost);
@@ -340,6 +378,21 @@ public class MeterReadRecordServiceImpl implements MeterReadRecordService {
             update.setReadTime(sendTime);
             update.setUpdateBy(Constants.SYS_FLAG);
             meterReadRecordMapper.updateByPrimaryKeySelective(update) ;
+            // 同时也将mongo抄表记录更新
+            try {
+                record.setLastSendData(getMeasuringValueMap(measuringData));
+                update.setLastCost(todayCost);
+                record.setReadData(currentReading);
+                record.setLastValid(currentReading);
+                record.setReadStatus(Constants.READ);
+                record.setDateUpdate(new Date());
+                record.setReadTime(sendTime);
+                record.setUpdateBy(Constants.SYS_FLAG);
+                meterReadRecordRepository.save(record);
+            }catch (Exception e){
+                e.printStackTrace();
+                log.error("Update meter record to mongo failed!",e);
+            }
             // 更新缓存
             setMeterLastDataToCache(waterMeter.getDeviceId(),measuringData);
         }catch (Exception e){
@@ -355,6 +408,15 @@ public class MeterReadRecordServiceImpl implements MeterReadRecordService {
         log.debug("-----end meter reading , meter = {},readDay = {},Cost = {}ms",waterMeter.getDeviceId(),readDay,clock.getTime());
     }
 
+    protected Map<String,String> getMeasuringValueMap(Map<String, MeasuringData> measuringData){
+        Map<String,String> measuringValueMap = new HashMap<>(measuringData.size());
+        Iterator<Map.Entry<String, MeasuringData>> iterator = measuringData.entrySet().iterator();
+        while(iterator.hasNext()){
+            Map.Entry<String, MeasuringData> next = iterator.next();
+            measuringValueMap.put(next.getValue().getMeasuringCode(),next.getValue().getMeasuringVaule());
+        }
+        return measuringValueMap ;
+    }
     @Override
     public void meterReading(Long meterId, Map<String, MeasuringData> measuringData) {
         WaterMeter meter = waterMeterMapper.findWaterMeterById(meterId);
@@ -374,9 +436,9 @@ public class MeterReadRecordServiceImpl implements MeterReadRecordService {
         String readingValue = readingData.getMeasuringVaule();
         return readingValue ;
     }
-    protected  BigDecimal calculateTodayCost(String currentReading,MeterReadRecord record){
+    protected  BigDecimal calculateTodayCost(String currentReading,BigDecimal lastValid,MeterReadRecord record){
         BigDecimal lastCost = record.getLastCost();
-        BigDecimal lastValid = new BigDecimal(record.getLastValid());
+//        BigDecimal lastValid = new BigDecimal(record.getLastValid());
         BigDecimal currentValid = new BigDecimal(currentReading);
         BigDecimal  cost = currentValid.subtract(lastValid).add(lastCost) ;
         return cost ;

+ 8 - 0
meter-reading-common/src/main/resources/application-common-dev.properties

@@ -32,6 +32,14 @@ spring.redis.host=114.135.61.188
 spring.redis.port=26379
 spring.redis.password=zoniot
 spring.redis.database=1
+spring.redis.lettuce.pool.max-active=8
+spring.redis.lettuce.pool.max-wait=100
+spring.redis.lettuce.pool.max-idle=8
+spring.redis.lettuce.pool.min-idle=0
+spring.redis.lettuce.shutdown-timeout=100
+######################################################MongoDB配置#####################################################
+spring.data.mongodb.uri=mongodb://114.135.61.188:17017/meter-reading-database
+logging.level.org.springframework.data.mongodb.core=DEBUG
 #########################################业务配置############################################
 #定义每个任务的数据集大小
 task.chunk.size=2000

+ 8 - 0
meter-reading-common/src/main/resources/application-common-sit.properties

@@ -32,6 +32,14 @@ spring.redis.host=114.135.61.188
 spring.redis.port=26379
 spring.redis.password=zoniot
 spring.redis.database=1
+spring.redis.lettuce.pool.max-active=8
+spring.redis.lettuce.pool.max-wait=100
+spring.redis.lettuce.pool.max-idle=8
+spring.redis.lettuce.pool.min-idle=0
+spring.redis.lettuce.shutdown-timeout=100
+######################################################MongoDB配置#####################################################
+spring.data.mongodb.uri=mongodb://114.135.61.188:17017/meter-reading-database
+logging.level.org.springframework.data.mongodb.core=DEBUG
 #########################################业务配置############################################
 #定义每个任务的数据集大小
 task.chunk.size=2000

+ 4 - 3
meter-reading-common/src/main/resources/mapper/MeterReadRecordMapper.xml

@@ -399,12 +399,13 @@
       sc_meter_read_record
     where
         status = 1
-    and device_id = #{deviceId,jdbcType=BIGINT}
     and read_date = #{readDate,jdbcType=INTEGER}
+    and device_id = #{deviceId,jdbcType=BIGINT}
   </select>
   <update id="deleteRecordByReadDayAndDeviceId">
     update sc_meter_read_record set status = 0
-    where device_id = #{deviceId,jdbcType=BIGINT}
-      and read_date = #{readDate,jdbcType=INTEGER}
+    where
+     read_date = #{readDate,jdbcType=INTEGER}
+    and device_id = #{deviceId,jdbcType=BIGINT}
   </update>
 </mapper>

+ 37 - 1
meter-reading-common/src/main/resources/mapper/WaterMeterMapper.xml

@@ -27,6 +27,19 @@
     <result column="date_update" jdbcType="TIMESTAMP" property="dateUpdate" />
     <result column="create_by" jdbcType="VARCHAR" property="createBy" />
     <result column="update_by" jdbcType="VARCHAR" property="updateBy" />
+      <result column="community_name" jdbcType="VARCHAR" property="communityName" />
+      <result column="building_name" jdbcType="VARCHAR" property="buildingName" />
+      <result column="customer_name" jdbcType="VARCHAR" property="customerName" />
+      <result column="province_name" jdbcType="VARCHAR" property="provinceName" />
+      <result column="city_name" jdbcType="VARCHAR" property="cityName"/>
+      <result column="region_name" jdbcType="VARCHAR" property="regionName" />
+      <result column="concentrator_no" jdbcType="VARCHAR" property="concentratorNo" />
+      <result column="collector_no" jdbcType="VARCHAR" property="collectorNo" />
+      <result column="device_type_name" jdbcType="VARCHAR" property="deviceTypeName"/>
+      <result column="manufacturer_id" jdbcType="INTEGER" property="manufacturerId" />
+      <result column="manufacturer_name" jdbcType="VARCHAR" property="manufacturerName" />
+
+
   </resultMap>
   <sql id="Base_Column_List">
     <!--@mbg.generated-->
@@ -55,7 +68,20 @@
       d.loc_desc as location,
       wmt.valve_measuring_code as valve_measuring_code ,
 	  wmt.reading_measuring_code as reading_measuring_code,
-	  d.date_create as date_create
+	  d.date_create as date_create,
+	  b.`name` as building_name,
+	  c.`name` as community_name ,
+	  p.name as province_name,
+	  cc.name as city_name,
+	  r.`name` as region_name,
+	  con.serial_number as concentrator_no,
+      col.collector_no as collector_no,
+	  concat_ws('/',m.name,dt.equipment_type,dt.model) as device_type_name,
+	  d.manufacturer_id as manufacturer_id ,
+	  m.`name` as manufacturer_name,
+      cu.customer_name as customer_name,
+      cn.channel_name as channel_name ,
+      wrd.channel_number_id as channel_number_id
   </sql>
   <sql id="Base_Meter_Query_Where">
       d.`status` = 1
@@ -77,6 +103,16 @@
       left join sc_device d on (d.`status` = 1 and wmt.device_type_id = d.device_type)
       left join sc_water_related_device  wrd on (wrd.device_id =d.id)
       left join sc_building b on (d.building_id = b.id)
+      LEFT JOIN sc_community c on (b.community = c.id )
+	  LEFT JOIN sc_area p on (c.province = p.id)
+	  LEFT JOIN sc_area cc on (c.city = cc.id)
+	  LEFT JOIN sc_area r on (c.region =r.id)
+	  LEFT JOIN sc_concentrator con on (con.id = wrd.concentrator_id)
+	  LEFT JOIN sc_collector col on (col.id = wrd.collector_id)
+	  left join sc_device_type dt on (d.device_type = dt.id)
+	  left join sc_device_manufacturer m on (d.manufacturer_id = m.id)
+	  left join sc_customer cu on (cu.id = d.customer_id)
+	  left join sc_channel_number cn on(cn.id = wrd.channel_number_id)
   </sql>
   <select id="findAllWaterMeterList" resultMap="BaseResultMap">
     <include refid="Base_Meter_Query" />

+ 4 - 1
meter-reading-job/pom.xml

@@ -6,7 +6,7 @@
     <parent>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-parent</artifactId>
-        <version>2.3.1.RELEASE</version>
+        <version>2.2.6.RELEASE</version>
         <relativePath/> <!-- lookup parent from repository -->
     </parent>
     <groupId>com.huaxu.zoniot</groupId>
@@ -46,6 +46,9 @@
         </dependency>
     </dependencies>
     <build>
+        <finalName>
+            ${project.artifactId}-${project.version}-${maven.build.timestamp}
+        </finalName>
         <plugins>
             <plugin>
                 <groupId>org.springframework.boot</groupId>

+ 5 - 4
meter-reading-service/pom.xml

@@ -6,19 +6,17 @@
     <parent>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-parent</artifactId>
-        <version>2.3.1.RELEASE</version>
+        <version>2.2.6.RELEASE</version>
         <relativePath/> <!-- lookup parent from repository -->
     </parent>
     <groupId>com.huaxu.zoniot</groupId>
     <artifactId>meter-reading-service</artifactId>
     <version>1.0</version>
     <description>抄表服务</description>
-
     <properties>
         <java.version>1.8</java.version>
-        <netty-all.version>4.1.54.Final</netty-all.version>
-        <gson.version>2.8.6</gson.version>
         <skipTests>true</skipTests>
+        <maven.build.timestamp.format>yyyyMMdd</maven.build.timestamp.format>
     </properties>
     <dependencies>
         <dependency>
@@ -59,6 +57,9 @@
         -->
     </dependencies>
     <build>
+        <finalName>
+            ${project.artifactId}-${project.version}-${maven.build.timestamp}
+        </finalName>
         <plugins>
             <plugin>
                 <groupId>org.springframework.boot</groupId>

+ 2 - 2
meter-reading-service/src/main/resources/application-service-dev.properties

@@ -21,5 +21,5 @@ spring.rabbitmq.listener.simple.concurrency=2
 spring.rabbitmq.listener.simple.max-concurrency=4
 spring.rabbitmq.listener.simple.prefetch=250
 # Ë®±íÊý¾Ý¶ÓÁÐ
-com.huaxu.zoniot.meter.data.exchange=meter-data-exchange
-com.huaxu.zoniot.meter.data.queue=meter-data-queue
+com.huaxu.zoniot.meter.data.exchange=dev-meter-data-exchange
+com.huaxu.zoniot.meter.data.queue=dev-meter-data-queue

+ 0 - 13
meter-reading-service/src/test/java/com/huaxu/zoniot/MeterReadRateServiceTests.java

@@ -1,12 +1,8 @@
 package com.huaxu.zoniot;
 
-import com.huaxu.zoniot.service.MeterReadRateService;
 import org.junit.jupiter.api.Test;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 
-import java.util.Date;
-
 /**
  * <p></p>
  *
@@ -16,16 +12,7 @@ import java.util.Date;
  */
 @SpringBootTest
 public class MeterReadRateServiceTests {
-
-    @Autowired
-    MeterReadRateService meterReadRateService;
     @Test
     void contextLoads() {
     }
-
-    @Test
-    void statLastDayReadRateByBuildingTest(){
-//        int i = meterReadRateService.statLastDayReadRateByBuilding(new Date());
-//        System.out.println(i);
-    }
 }

+ 35 - 6
meter-reading-service/src/test/java/com/huaxu/zoniot/MeterReadingServiceTests.java

@@ -10,7 +10,9 @@ import org.springframework.boot.test.context.SpringBootTest;
 
 import javax.annotation.Resource;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * <p></p>
@@ -106,8 +108,8 @@ public class MeterReadingServiceTests {
         System.out.println(result.size());
     }
     @Test
-    void meterReadingTest(){
-        //WaterMeter meter = waterMeterMapper.findWaterMeterById(580141137533075456L);
+    void meterReadingTest1(){
+        WaterMeter meter = waterMeterMapper.findWaterMeterById(580141137533075456L);
         // 模拟数据
         MeasuringData md1 = new MeasuringData();
         md1.setMeasuringCode("TIME");
@@ -124,10 +126,37 @@ public class MeterReadingServiceTests {
         list.add(md1);
         list.add(md2);
         System.out.println(JSON.toJSONString(list));
-//        Map<String ,MeasuringData > mdm = new HashMap<>();
-//        mdm.put("TIME",md1);
-//        mdm.put("currentQuantity",md2);
-//        meterReadRecordService.meterReading(meter,mdm,20201225);
+        Map<String ,MeasuringData > mdm = new HashMap<>();
+        mdm.put("TIME",md1);
+        mdm.put("currentQuantity",md2);
+        meterReadRecordService.meterReading(meter,mdm,20201225);
+    }
+
+
+    @Test
+    void meterReadingTest2(){
+        //WaterMeter meter = waterMeterMapper.findWaterMeterById(775700946759057408L);
+        // 模拟数据
+        MeasuringData md1 = new MeasuringData();
+        md1.setMeasuringCode("TIME");
+        md1.setMeasuringName("最后上报时间");
+        md1.setMeasuringVaule("20210106132520");
+
+        MeasuringData md2 = new MeasuringData();
+        md2.setMeasuringCode("currentQuantity");
+        md2.setMeasuringName("当前止度");
+        md2.setMeasuringVaule("72.8");
+        md2.setMeasuringUnit("m³");
+
+        List<MeasuringData> list = new ArrayList<>();
+        list.add(md1);
+        list.add(md2);
+        System.out.println(JSON.toJSONString(list));
+        Map<String ,MeasuringData > mdm = new HashMap<>();
+        mdm.put("TIME",md1);
+        mdm.put("currentQuantity",md2);
+        meterReadRecordService.meterReading(775700946759057408L,mdm);
     }
 
+
 }

+ 6 - 2
smart-city-intf/pom.xml

@@ -110,7 +110,11 @@
 			<groupId>org.springframework.boot</groupId>
 			<artifactId>spring-boot-starter-amqp</artifactId>
 		</dependency>
-
+		<!-- SpringBoot MongoDB-->
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-data-mongodb</artifactId>
+		</dependency>
 		<dependency>
 			<groupId>com.aliyun.mq</groupId>
 			<artifactId>mq-http-sdk</artifactId>
@@ -140,7 +144,7 @@
 
 	<build>
 		<finalName>
-		  ${project.artifactId}-${project.version}_${maven.build.timestamp}
+		  ${project.artifactId}-${project.version}-${maven.build.timestamp}
 		</finalName>
 		<plugins>
 			<plugin>

+ 51 - 0
smart-city-intf/src/main/java/com/zcxk/smartcity/data/access/config/MongoDBConfig.java

@@ -0,0 +1,51 @@
+package com.zcxk.smartcity.data.access.config;
+
+import com.mongodb.MongoClientOptions;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.convert.CustomConversions;
+import org.springframework.data.mongodb.MongoDbFactory;
+import org.springframework.data.mongodb.core.convert.DbRefResolver;
+import org.springframework.data.mongodb.core.convert.DefaultDbRefResolver;
+import org.springframework.data.mongodb.core.convert.DefaultMongoTypeMapper;
+import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
+import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
+
+/**
+ * @author pengdi
+ */
+@Configuration
+public class MongoDBConfig {
+    /**
+     * <p>解决 MongoSocketReadTimeoutException异常</p>
+     * @return
+     */
+    @Bean
+    public MongoClientOptions mongoOptions() {
+        return MongoClientOptions
+            .builder()
+            .maxConnectionIdleTime(60000)
+            .build();
+    }
+
+    /**
+     * <p>去除文档中的_class字段</p>
+     * @param factory
+     * @param context
+     * @param beanFactory
+     * @return
+     */
+    @Bean
+    public MappingMongoConverter mappingMongoConverter(MongoDbFactory factory, MongoMappingContext context, BeanFactory beanFactory) {
+        DbRefResolver dbRefResolver = new DefaultDbRefResolver(factory);
+        MappingMongoConverter mappingConverter = new MappingMongoConverter(dbRefResolver, context);
+        try {
+            mappingConverter.setCustomConversions(beanFactory.getBean(CustomConversions.class));
+        } catch (NoSuchBeanDefinitionException ignore) {
+        }
+        mappingConverter.setTypeMapper(new DefaultMongoTypeMapper(null));
+        return mappingConverter;
+    }
+}

+ 107 - 0
smart-city-intf/src/main/java/com/zcxk/smartcity/data/access/dto/DeviceData.java

@@ -0,0 +1,107 @@
+package com.zcxk.smartcity.data.access.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springframework.data.annotation.Id;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+import java.util.Date;
+import java.util.Map;
+
+/**
+ * 
+ * @Description  
+ * <p>设备数据表,按照设备ID进行分片</p>
+ * sh.enableSharding("iot-water-database")
+ * sh.shardCollection("iot-water-database.sc_device_data",{"receiveDate":1,"deviceId":1});
+ * @author wilian.peng
+ * @date 2019年11月12日 下午10:05:10
+ */
+@Data
+@ApiModel("设备数据表")
+@Document(collection = "sc_device_data")
+public class DeviceData implements Serializable{
+	private static final long serialVersionUID = 4357722209160768792L;
+	@Id
+	@ApiModelProperty("id")
+	private Long id;
+
+	@ApiModelProperty("设备ID")
+	private Long deviceId ;
+
+	@ApiModelProperty("设备编号")
+	private String deviceNo;
+
+	@ApiModelProperty("站点ID")
+	private Integer siteId ;
+
+	@ApiModelProperty(value = "厂商", position = 9)
+	private Integer manufacturerId;
+
+//	@ApiModelProperty(value = "厂商名称", position = 9)
+//	private String manufacturerName ;
+
+	@ApiModelProperty("场景ID")
+	private Integer channelId;
+
+	@ApiModelProperty("设备类型ID")
+	private Integer deviceTypeId ;
+
+//	@ApiModelProperty("设备类型名称")
+//	private String deviceTypeName;
+
+	@ApiModelProperty("建筑Id")
+	private Integer buildingId;
+
+//	private String buildingName ;
+
+	@ApiModelProperty("小区Id")
+	private Integer communityId;
+
+//	private String  communityName ;
+
+//	@ApiModelProperty("省Id")
+//	private Integer provinceId;
+//
+//	private String provinceName ;
+
+//	@ApiModelProperty("市Id")
+//	private Integer cityId;
+//
+//	private String cityName ;
+
+//	@ApiModelProperty("区Id")
+//	private Integer regionId;
+//
+//	private String regionName ;
+
+	@ApiModelProperty("设备地址")
+	private String location ;
+
+	@ApiModelProperty("上报日期")
+	private Integer receiveDate ;
+
+	@ApiModelProperty("上报详细时间")
+	private Date receiveTime;
+
+	@ApiModelProperty("状态")
+	private Integer status;
+
+	@ApiModelProperty("上报详细数据")
+	private Map<String,String> data;
+
+	@ApiModelProperty("创建时间")
+	private LocalDateTime dateCreate;
+
+	@ApiModelProperty("更新时间")
+	private LocalDateTime dateUpdate ;
+
+	@ApiModelProperty("客户Id")
+	private Integer customerId;
+
+//	@ApiModelProperty("客户名称")
+//	private String customerName ;
+}

+ 14 - 0
smart-city-intf/src/main/java/com/zcxk/smartcity/data/access/repository/DeviceDataRepository.java

@@ -0,0 +1,14 @@
+package com.zcxk.smartcity.data.access.repository;
+
+import com.zcxk.smartcity.data.access.dto.DeviceData;
+import org.springframework.data.mongodb.repository.MongoRepository;
+
+/**
+ * <p>设备数据MongoDB仓库类</p>
+ *
+ * @Author wilian.peng
+ * @Date 2021/1/7 11:41
+ * @Version 1.0
+ */
+public interface DeviceDataRepository extends MongoRepository<DeviceData,Long> {
+}

+ 47 - 5
smart-city-intf/src/main/java/com/zcxk/smartcity/data/access/service/impl/DeviceDataServiceImpl.java

@@ -2,14 +2,13 @@ package com.zcxk.smartcity.data.access.service.impl;
 
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.time.LocalDateTime;
+import java.util.*;
 
 import com.zcxk.smartcity.data.access.common.CommonConstant;
+import com.zcxk.smartcity.data.access.dto.DeviceData;
 import com.zcxk.smartcity.data.access.rabbitmq.WaterMeterDataSender;
+import com.zcxk.smartcity.data.access.repository.DeviceDataRepository;
 import org.apache.commons.collections.MapUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.logging.Log;
@@ -112,6 +111,9 @@ public class DeviceDataServiceImpl implements DeviceDataService {
 	@Resource
 	WaterMeterDataSender waterMeterDataSender ;
 
+	@Autowired
+	DeviceDataRepository  deviceDataRepository ;
+
 	@Override
 	public int savaDeviceData(Device device, DeviceDataBase srcData, ProtocolData data) {
 		log.info(
@@ -557,6 +559,15 @@ public class DeviceDataServiceImpl implements DeviceDataService {
 				i++;
 			}
 		}
+		// 将数据保存到MongoDB中
+		try{
+			// 构建DeviceData对象
+			DeviceData deviceData = buildDeviceData(device, dataMap, receiveTime);
+			deviceDataRepository.save(deviceData);
+		}catch (Exception e){
+			e.printStackTrace();
+			log.error("Device data save mongo failed !",e);
+		}
 		// 2,判断设备是否水表,如果是水表则保存读数
 		if(device.getIsWater() == 1) {
 			// 如果是水表数据则继续将数据发送到抄表队列供抄表服务进行抄表 2020/12/25
@@ -589,6 +600,37 @@ public class DeviceDataServiceImpl implements DeviceDataService {
 		return i;
 	}
 
+	protected DeviceData buildDeviceData(Device device, Map<String, MeasuringData> dataMap, String receiveTime){
+		DeviceData deviceData = new DeviceData();
+		deviceData.setChannelId(device.getSysId());
+		deviceData.setCommunityId(device.getCommunityId());
+		deviceData.setCustomerId(device.getCustomerId());
+		deviceData.setDateCreate(LocalDateTime.now());
+		deviceData.setDeviceId(device.getId());
+		deviceData.setDeviceNo(device.getDeviceNo());
+		deviceData.setDeviceTypeId(device.getDeviceType());
+		deviceData.setId(idWorker.nextId());
+		deviceData.setLocation(device.getLocDesc());
+		deviceData.setManufacturerId(device.getManufacturerId());
+		deviceData.setReceiveDate(Integer.parseInt(receiveTime.substring(0, 8)));
+		deviceData.setReceiveTime(parserDate(receiveTime));
+		deviceData.setSiteId(device.getSiteId());
+		deviceData.setStatus(1);
+		deviceData.setData(getDeviceMeasuringValueMap(dataMap));
+		deviceData.setBuildingId(device.getBuildingId());
+		return deviceData ;
+	}
+
+	protected  Map<String,String> getDeviceMeasuringValueMap(Map<String, MeasuringData> dataMap){
+		Map<String,String> measuringValueMap = new HashMap<>(dataMap.size());
+		Iterator<Map.Entry<String, MeasuringData>> iterator = dataMap.entrySet().iterator();
+		while(iterator.hasNext()){
+			Map.Entry<String, MeasuringData> next = iterator.next();
+			measuringValueMap.put(next.getValue().getMeasuringCode(),next.getValue().getMeasuringVaule());
+		}
+		return measuringValueMap ;
+	}
+
 	protected Map<String, MeasuringData> measuringDataListToMap(List<MeasuringData> measuringDataList) {
 		Map<String, MeasuringData> map = new HashMap<String, MeasuringData>(measuringDataList.size());
 		for (MeasuringData data : measuringDataList) {

+ 49 - 2
smart-city-intf/src/main/java/com/zcxk/smartcity/data/access/service/impl/DeviceDataServiceV2Impl.java

@@ -6,11 +6,13 @@ import com.zcxk.smartcity.data.access.common.CommonConstant;
 import com.zcxk.smartcity.data.access.common.RedisUtil;
 import com.zcxk.smartcity.data.access.dao.*;
 import com.zcxk.smartcity.data.access.dto.ConfigDataDto;
+import com.zcxk.smartcity.data.access.dto.DeviceData;
 import com.zcxk.smartcity.data.access.dto.UdipUnitDataDTO;
 import com.zcxk.smartcity.data.access.dto.ValveControlDataDto;
 import com.zcxk.smartcity.data.access.entity.*;
 import com.zcxk.smartcity.data.access.protocol.model.MeasuringData;
 import com.zcxk.smartcity.data.access.rabbitmq.WaterMeterDataSender;
+import com.zcxk.smartcity.data.access.repository.DeviceDataRepository;
 import com.zcxk.smartcity.data.access.service.ConfigService;
 import com.zcxk.smartcity.data.access.service.DeviceDataServiceV2;
 import com.zcxk.smartcity.data.access.util.JacksonUtil;
@@ -31,6 +33,7 @@ import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.time.LocalDateTime;
 import java.util.*;
 
 import static com.google.common.collect.Lists.newArrayList;
@@ -85,6 +88,9 @@ public class DeviceDataServiceV2Impl implements DeviceDataServiceV2 {
     @Resource
     WaterMeterDataSender waterMeterDataSender;
 
+    @Autowired
+    DeviceDataRepository deviceDataRepository ;
+
     @Override
     public int saveDeviceData(Device device, UdipUnitDataDTO unitData) {
         log.info("begin saveDeviceData,device = {} ,data = {}" , JSON.toJSONString(device) ,JSON.toJSONString(unitData));
@@ -144,7 +150,7 @@ public class DeviceDataServiceV2Impl implements DeviceDataServiceV2 {
         return j;
     }
 
-    public int saveDeviceMeasuringDatas(Device device, Map<String, MeasuringData> dataMap, String lastUpateTime, Date receiveTime) {
+    public int saveDeviceMeasuringDatas(Device device, Map<String, MeasuringData> dataMap, String lastUpdateTime, Date receiveTime) {
         log.info("begin saveDeviceMeasuringData  ,device = {} ,data = {} " ,JSON.toJSONString(device) , JSON.toJSONString(dataMap));
         List<DeviceMeasuringPoint> dmps = deviceMeasuringPointMapper.findByDeviceTypeId(device.getDeviceType());
         int i = 0;
@@ -168,13 +174,22 @@ public class DeviceDataServiceV2Impl implements DeviceDataServiceV2 {
                 dd.setMeasuringData(measuringValue);
                 dd.setSiteId(device.getSiteId());
                 dd.setSysId(device.getSysId());
-                dd.setSendDate(Integer.parseInt(lastUpateTime.substring(0, 8)));
+                dd.setSendDate(Integer.parseInt(lastUpdateTime.substring(0, 8)));
                 dd.setSendTime(receiveTime);
                 dd.setMeasuringUnit(dmp.getDataUnit());
                 deviceDataDimMapper.save(dd);
                 i++;
             }
         }
+        // 将数据保存到MongoDB中
+        try{
+            // 构建DeviceData对象
+            DeviceData deviceData = buildDeviceData(device, dataMap, lastUpdateTime);
+            deviceDataRepository.save(deviceData);
+        }catch (Exception e){
+            e.printStackTrace();
+            log.error("Device data save mongo failed !",e);
+        }
         // 2,判断设备是否水表,如果是水表则保存读数
         if(device.getIsWater() == 1) {
             try
@@ -247,6 +262,38 @@ public class DeviceDataServiceV2Impl implements DeviceDataServiceV2 {
         return i;
     }
 
+
+    protected DeviceData buildDeviceData(Device device, Map<String, MeasuringData> dataMap, String receiveTime){
+        DeviceData deviceData = new DeviceData();
+        deviceData.setChannelId(device.getSysId());
+        deviceData.setCommunityId(device.getCommunityId());
+        deviceData.setCustomerId(device.getCustomerId());
+        deviceData.setDateCreate(LocalDateTime.now());
+        deviceData.setDeviceId(device.getId());
+        deviceData.setDeviceNo(device.getDeviceNo());
+        deviceData.setDeviceTypeId(device.getDeviceType());
+        deviceData.setId(idWorker.nextId());
+        deviceData.setLocation(device.getLocDesc());
+        deviceData.setManufacturerId(device.getManufacturerId());
+        deviceData.setReceiveDate(Integer.parseInt(receiveTime.substring(0, 8)));
+        deviceData.setReceiveTime(parserDate(receiveTime));
+        deviceData.setSiteId(device.getSiteId());
+        deviceData.setStatus(1);
+        deviceData.setData(getDeviceMeasuringValueMap(dataMap));
+        deviceData.setBuildingId(device.getBuildingId());
+        return deviceData ;
+    }
+
+    protected  Map<String,String> getDeviceMeasuringValueMap(Map<String, MeasuringData> dataMap){
+        Map<String,String> measuringValueMap = new HashMap<>(dataMap.size());
+        Iterator<Map.Entry<String, MeasuringData>> iterator = dataMap.entrySet().iterator();
+        while(iterator.hasNext()){
+            Map.Entry<String, MeasuringData> next = iterator.next();
+            measuringValueMap.put(next.getValue().getMeasuringCode(),next.getValue().getMeasuringVaule());
+        }
+        return measuringValueMap ;
+    }
+
     private boolean matches(Integer customerId) {
         List<ConfigDataDto> configDataList = configService.getConfigData("push_valve_config");
         if (configDataList != null && configDataList.size() > 0) {

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

@@ -32,7 +32,7 @@ mybatis.configuration.use-column-label=true
 
 spring.jackson.time-zone=GMT+8
 spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
-spring.jackson.joda-date-time-format: yyyy-MM-dd HH:mm:ss
+spring.jackson.joda-date-time-format=yyyy-MM-dd HH:mm:ss
 
 #redis
 spring.redis.host=114.135.61.188
@@ -55,3 +55,6 @@ com.zcxk.kafka.alarm.topic=sc_alarm_topic_sit
 com.zcxk.kafka.card.topic=sc_card_topic_sit
 com.zcxk.kafka.single.data.topic=sc_single_data_topic
 com.zcxk.kafka.multi.data.topic=sc_multi_data_topic
+######################################################MongoDBÅäÖÃ#####################################################
+spring.data.mongodb.uri=mongodb://114.135.61.188:17017/iot-water-database
+logging.level.org.springframework.data.mongodb.core=DEBUG

+ 5 - 6
smart-city-intf/src/main/resources/application-dev.properties

@@ -31,7 +31,7 @@ mybatis.configuration.use-column-label=true
 
 spring.jackson.time-zone=GMT+8
 spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
-spring.jackson.joda-date-time-format: yyyy-MM-dd HH:mm:ss
+spring.jackson.joda-date-time-format=yyyy-MM-dd HH:mm:ss
 #redis config
 spring.redis.host=114.135.61.188
 spring.redis.port=26379
@@ -60,14 +60,11 @@ aliyun.nms.access.key=LTAI9bq4vr6ClPGW
 aliyun.nms.secret.key=hKYWEneQH2hQOs2DnG4PsAUqk4Thps
 aliyun.nms.server.name=http://MQ_INST_1159852013518008_Ba5mtzmw.mq-internet-access.mq-internet.aliyuncs.com:80
 aliyun.nms.group.id=GID_ZONIOT_NMS_DEV
-
-
 ##############################RabbitMQ#########################################
 spring.rabbitmq.host=114.135.61.188
 spring.rabbitmq.port=55672
 spring.rabbitmq.username=zoniot
 spring.rabbitmq.password=zcxk100
-
 # 开启发送确认
 spring.rabbitmq.publisher-confirms=true
 # 开启发送失败退回
@@ -75,6 +72,8 @@ spring.rabbitmq.publisher-returns=true
 # 开启ACK
 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.command.status.queue=command_status_queue
+######################################################MongoDB配置#####################################################
+spring.data.mongodb.uri=mongodb://114.135.61.188:17017/iot-water-database
+logging.level.org.springframework.data.mongodb.core=DEBUG

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

@@ -6,7 +6,6 @@ server.workId=0
 spring.jackson.time-zone=GMT+8
 spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
 spring.jackson.joda-date-time-format=yyyy-MM-dd HH:mm:ss
-spring.data.mongodb.uri=mongodb://39.108.172.131:27017/smart-city
 ###################################################数据库配置######################################################
 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
 spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
@@ -76,3 +75,6 @@ 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.meter.data.exchange=meter-data-exchange
+######################################################MongoDB配置#####################################################
+spring.data.mongodb.uri=mongodb://114.135.61.188:17017/iot-water-database
+logging.level.org.springframework.data.mongodb.core=DEBUG

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

@@ -6,7 +6,6 @@ server.workId=1
 spring.jackson.time-zone=GMT+8
 spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
 spring.jackson.joda-date-time-format=yyyy-MM-dd HH:mm:ss
-spring.data.mongodb.uri=mongodb://39.108.172.131:27017/smart-city
 ###################################################数据库配置######################################################
 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
 spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
@@ -75,4 +74,7 @@ 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=meter-data-exchange
+com.zcxk.rabbitmq.meter.data.exchange=meter-data-exchange
+######################################################MongoDB配置#####################################################
+spring.data.mongodb.uri=mongodb://114.135.61.188:17017/iot-water-database
+logging.level.org.springframework.data.mongodb.core=DEBUG

+ 4 - 3
smart-city-intf/src/main/resources/application-test.properties

@@ -32,9 +32,7 @@ mybatis.configuration.use-column-label=true
 
 spring.jackson.time-zone=GMT+8
 spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
-spring.jackson.joda-date-time-format: yyyy-MM-dd HH:mm:ss
-
-spring.data.mongodb.uri= mongodb://39.108.172.131:27017/smart-city
+spring.jackson.joda-date-time-format=yyyy-MM-dd HH:mm:ss
 
 #redis
 spring.redis.host=114.135.61.188
@@ -62,3 +60,6 @@ aliyun.nms.access.key=LTAI9bq4vr6ClPGW
 aliyun.nms.secret.key=hKYWEneQH2hQOs2DnG4PsAUqk4Thps
 aliyun.nms.server.name=http://MQ_INST_1159852013518008_Ba5mtzmw.mq-internet-access.mq-internet.aliyuncs.com:80
 aliyun.nms.group.id=GID_ZONIOT_NMS_TEST
+######################################################MongoDBÅäÖÃ#####################################################
+spring.data.mongodb.uri=mongodb://114.135.61.188:17017/iot-water-database
+logging.level.org.springframework.data.mongodb.core=DEBUG

+ 5 - 2
smart-city-intf/src/main/resources/application-uat.properties

@@ -31,7 +31,7 @@ mybatis.configuration.use-column-label=true
 
 spring.jackson.time-zone=GMT+8
 spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
-spring.jackson.joda-date-time-format: yyyy-MM-dd HH:mm:ss
+spring.jackson.joda-date-time-format=yyyy-MM-dd HH:mm:ss
 
 #redis
 spring.redis.host=114.135.61.188
@@ -76,4 +76,7 @@ spring.rabbitmq.listener.direct.acknowledge-mode=manual
 spring.rabbitmq.listener.simple.acknowledge-mode=manual
 
 com.zcxk.rabbitmq.water.meter.queue=water_meter_queue_uat
-com.zcxk.rabbitmq.command.status.queue=command_status_queue_uat
+com.zcxk.rabbitmq.command.status.queue=command_status_queue_uat
+######################################################MongoDB配置#####################################################
+spring.data.mongodb.uri=mongodb://114.135.61.188:17017/iot-water-database
+logging.level.org.springframework.data.mongodb.core=DEBUG