Browse Source

Merge branch '0617' into 0727

lin 4 years ago
parent
commit
a4e2a3ffe8
20 changed files with 830 additions and 143 deletions
  1. 7 78
      gydatasync/log.log
  2. 1 1
      gydatasync/src/main/resources/application-prd.properties
  3. 1 1
      gydatasync/src/main/resources/application.properties
  4. 2 2
      smart-city-platform/src/main/java/com/bz/smart_city/async/AsyncInstallPlanDownloadTask.java
  5. 2 0
      smart-city-platform/src/main/java/com/bz/smart_city/dao/CustomerMapper.java
  6. 2 1
      smart-city-platform/src/main/java/com/bz/smart_city/entity/Building.java
  7. 2 1
      smart-city-platform/src/main/java/com/bz/smart_city/entity/Community.java
  8. 2 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/BuildingService.java
  9. 2 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/CommunityService.java
  10. 7 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/BuildingServiceImpl.java
  11. 7 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/CommunityServiceImpl.java
  12. 2 1
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/DeviceServiceImpl.java
  13. 1 1
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/DeviceTypeServiceImpl.java
  14. 59 57
      smart-city-platform/src/main/java/com/bz/smart_city/service/importfile/AsyncTaskImportService.java
  15. 579 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/udip/ConvertUtils.java
  16. 85 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/udip/Lora188Parser.java
  17. BIN
      smart-city-platform/src/main/resources/excel/installPlanTemplate20200731.xlsx
  18. 4 0
      smart-city-platform/src/main/resources/mapper/CustomerMapper.xml
  19. 22 0
      smart-city-platform/src/test/java/com/bz/smart_city/ProtocolParser.java
  20. 43 0
      smart-city-platform/src/test/java/com/bz/smart_city/ScTest.java

+ 7 - 78
gydatasync/log.log

@@ -1,78 +1,7 @@
-2020-07-22 14:34:40.455  INFO 7804 --- [main] c.h.gydatasync.GydatasyncApplication     : Starting GydatasyncApplication on ZJY-PC with PID 7804 (E:\Work\对外接口\桂阳\code\gydatasync\target\classes started by ZJY in E:\Work\对外接口\桂阳\code\gydatasync)
-2020-07-22 14:34:40.490  INFO 7804 --- [main] c.h.gydatasync.GydatasyncApplication     : The following profiles are active: dev
-2020-07-22 14:34:42.879  INFO 7804 --- [main] o.s.s.c.ThreadPoolTaskScheduler          : Initializing ExecutorService 'taskScheduler'
-2020-07-22 14:35:06.987  INFO 7804 --- [main] c.h.gydatasync.GydatasyncApplication     : Started GydatasyncApplication in 27.194 seconds (JVM running for 28.189)
-2020-07-22 14:35:07.048  INFO 7804 --- [scheduling-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
-2020-07-22 14:35:15.065  INFO 7804 --- [scheduling-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
-2020-07-22 14:35:15.122 DEBUG 7804 --- [scheduling-1] c.h.g.d.mssql.SaveMeterDataDao.IsExist   : ==>  Preparing: select COUNT(*) from WaterData where CONVERT(varchar(10),UpLoadDateTime,120) = CONVERT(varchar(10),GETDATE(),120)
-2020-07-22 14:35:15.887 DEBUG 7804 --- [scheduling-1] c.h.g.d.mssql.SaveMeterDataDao.IsExist   : ==> Parameters: 
-2020-07-22 14:35:16.376 DEBUG 7804 --- [scheduling-1] c.h.g.d.mssql.SaveMeterDataDao.IsExist   : <==      Total: 1
-2020-07-22 14:40:09.330  WARN 7804 --- [HikariPool-1 housekeeper] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=4m54s159ms653µs980ns).
-2020-07-22 14:40:09.333  INFO 7804 --- [scheduling-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-2 - Starting...
-2020-07-22 14:40:09.899  INFO 7804 --- [scheduling-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-2 - Start completed.
-2020-07-22 14:40:09.901 DEBUG 7804 --- [scheduling-1] c.h.g.dao.mysql.ReadMeterDao.getAllList  : ==>  Preparing: SELECT sd.water_meter_file_no as customerID, a.device_id as deviceID, a.read_data as cbz, a.read_time as cbsj, now() as upLoadDateTime, CONCAT(sd.water_meter_file_no,'1') as customerMeterID FROM sc_meter_read_record a left JOIN sc_device sd on a.device_id = sd.id WHERE a.read_date = DATE_FORMAT( DATE_SUB( now(), INTERVAL 1 DAY ), '%Y%m%d' ) AND a.device_id IN ( SELECT id FROM sc_device WHERE building_id IN ( 6675, 6676, 6677, 6678, 6679, 6680 ) AND STATUS = 1 )
-2020-07-22 14:40:09.938 DEBUG 7804 --- [scheduling-1] c.h.g.dao.mysql.ReadMeterDao.getAllList  : ==> Parameters: 
-2020-07-22 14:40:10.479 DEBUG 7804 --- [scheduling-1] c.h.g.dao.mysql.ReadMeterDao.getAllList  : <==      Total: 476
-2020-07-22 14:40:56.786  WARN 7804 --- [HikariPool-1 housekeeper] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=47s455ms360µs350ns).
-2020-07-22 14:40:56.788  WARN 7804 --- [HikariPool-2 housekeeper] com.zaxxer.hikari.pool.HikariPool        : HikariPool-2 - Thread starvation or clock leap detected (housekeeper delta=46s787ms862µs479ns).
-2020-07-22 14:40:56.856  INFO 7804 --- [SpringContextShutdownHook] o.s.s.c.ThreadPoolTaskScheduler          : Shutting down ExecutorService 'taskScheduler'
-2020-07-22 14:40:56.857  INFO 7804 --- [SpringContextShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
-2020-07-22 14:40:56.862  INFO 7804 --- [SpringContextShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.
-2020-07-22 14:40:56.864  INFO 7804 --- [SpringContextShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-2 - Shutdown initiated...
-2020-07-22 14:40:56.872  INFO 7804 --- [SpringContextShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-2 - Shutdown completed.
-2020-07-22 14:45:16.734  INFO 10816 --- [main] c.h.gydatasync.GydatasyncApplication     : Starting GydatasyncApplication on ZJY-PC with PID 10816 (E:\Work\对外接口\桂阳\code\gydatasync\target\classes started by ZJY in E:\Work\对外接口\桂阳\code\gydatasync)
-2020-07-22 14:45:16.739  INFO 10816 --- [main] c.h.gydatasync.GydatasyncApplication     : The following profiles are active: dev
-2020-07-22 14:45:17.751  INFO 10816 --- [main] o.s.s.c.ThreadPoolTaskScheduler          : Initializing ExecutorService 'taskScheduler'
-2020-07-22 14:45:22.081  INFO 10816 --- [main] c.h.gydatasync.GydatasyncApplication     : Started GydatasyncApplication in 5.737 seconds (JVM running for 6.374)
-2020-07-22 14:45:22.132  INFO 10816 --- [scheduling-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
-2020-07-22 14:45:29.890  INFO 10816 --- [scheduling-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
-2020-07-22 14:45:29.946 DEBUG 10816 --- [scheduling-1] c.h.g.d.mssql.SaveMeterDataDao.IsExist   : ==>  Preparing: select COUNT(*) from WaterData where CONVERT(varchar(10),UpLoadDateTime,120) = CONVERT(varchar(10),GETDATE(),120)
-2020-07-22 14:45:30.688 DEBUG 10816 --- [scheduling-1] c.h.g.d.mssql.SaveMeterDataDao.IsExist   : ==> Parameters: 
-2020-07-22 14:45:31.089 DEBUG 10816 --- [scheduling-1] c.h.g.d.mssql.SaveMeterDataDao.IsExist   : <==      Total: 1
-2020-07-22 14:46:41.936  WARN 10816 --- [HikariPool-1 housekeeper] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=1m11s944ms422µs457ns).
-2020-07-22 14:46:41.937  INFO 10816 --- [scheduling-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-2 - Starting...
-2020-07-22 14:46:41.997  INFO 10816 --- [SpringContextShutdownHook] o.s.s.c.ThreadPoolTaskScheduler          : Shutting down ExecutorService 'taskScheduler'
-2020-07-22 14:46:41.999  INFO 10816 --- [SpringContextShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
-2020-07-22 14:46:42.005  INFO 10816 --- [SpringContextShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.
-2020-07-22 14:52:03.682  INFO 11176 --- [main] c.h.gydatasync.GydatasyncApplication     : Starting GydatasyncApplication on ZJY-PC with PID 11176 (E:\Work\对外接口\桂阳\code\gydatasync\target\classes started by ZJY in E:\Work\对外接口\桂阳\code\gydatasync)
-2020-07-22 14:52:03.684  INFO 11176 --- [main] c.h.gydatasync.GydatasyncApplication     : The following profiles are active: dev
-2020-07-22 14:52:04.720  INFO 11176 --- [main] o.s.s.c.ThreadPoolTaskScheduler          : Initializing ExecutorService 'taskScheduler'
-2020-07-22 14:52:08.049  INFO 11176 --- [main] c.h.gydatasync.GydatasyncApplication     : Started GydatasyncApplication in 4.734 seconds (JVM running for 5.359)
-2020-07-22 14:52:08.100  INFO 11176 --- [scheduling-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
-2020-07-22 14:52:16.759  INFO 11176 --- [scheduling-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
-2020-07-22 14:52:16.817 DEBUG 11176 --- [scheduling-1] c.h.g.d.mssql.SaveMeterDataDao.IsExist   : ==>  Preparing: select COUNT(*) from WaterData where CONVERT(varchar(10),UpLoadDateTime,120) = CONVERT(varchar(10),GETDATE(),120)
-2020-07-22 14:52:17.627 DEBUG 11176 --- [scheduling-1] c.h.g.d.mssql.SaveMeterDataDao.IsExist   : ==> Parameters: 
-2020-07-22 14:52:18.056 DEBUG 11176 --- [scheduling-1] c.h.g.d.mssql.SaveMeterDataDao.IsExist   : <==      Total: 1
-2020-07-22 14:53:08.573  WARN 11176 --- [HikariPool-1 housekeeper] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=51s711ms984µs857ns).
-2020-07-22 14:53:08.575  INFO 11176 --- [scheduling-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-2 - Starting...
-2020-07-22 14:53:08.624  INFO 11176 --- [SpringContextShutdownHook] o.s.s.c.ThreadPoolTaskScheduler          : Shutting down ExecutorService 'taskScheduler'
-2020-07-22 14:53:08.625  INFO 11176 --- [SpringContextShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
-2020-07-22 14:53:08.631  INFO 11176 --- [SpringContextShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.
-2020-07-22 14:56:00.743  INFO 9644 --- [main] c.h.gydatasync.GydatasyncApplication     : Starting GydatasyncApplication on ZJY-PC with PID 9644 (E:\Work\对外接口\桂阳\code\gydatasync\target\classes started by ZJY in E:\Work\对外接口\桂阳\code\gydatasync)
-2020-07-22 14:56:00.746  INFO 9644 --- [main] c.h.gydatasync.GydatasyncApplication     : The following profiles are active: dev
-2020-07-22 14:56:01.851  INFO 9644 --- [main] o.s.s.c.ThreadPoolTaskScheduler          : Initializing ExecutorService 'taskScheduler'
-2020-07-22 14:56:01.886  INFO 9644 --- [main] c.h.gydatasync.GydatasyncApplication     : Started GydatasyncApplication in 1.492 seconds (JVM running for 2.129)
-2020-07-22 14:56:01.898  INFO 9644 --- [scheduling-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
-2020-07-22 14:56:02.104  INFO 9644 --- [scheduling-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
-2020-07-22 14:56:02.111 DEBUG 9644 --- [scheduling-1] c.h.g.d.mssql.SaveMeterDataDao.IsExist   : ==>  Preparing: select COUNT(*) from WaterData where CONVERT(varchar(10),UpLoadDateTime,120) = CONVERT(varchar(10),GETDATE(),120)
-2020-07-22 14:56:02.141 DEBUG 9644 --- [scheduling-1] c.h.g.d.mssql.SaveMeterDataDao.IsExist   : ==> Parameters: 
-2020-07-22 14:56:02.169 DEBUG 9644 --- [scheduling-1] c.h.g.d.mssql.SaveMeterDataDao.IsExist   : <==      Total: 1
-2020-07-22 15:01:41.411  INFO 9644 --- [scheduling-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-2 - Starting...
-2020-07-22 15:01:41.413  WARN 9644 --- [HikariPool-1 housekeeper] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=6m9s302ms961µs737ns).
-2020-07-22 15:01:41.469  INFO 9644 --- [SpringContextShutdownHook] o.s.s.c.ThreadPoolTaskScheduler          : Shutting down ExecutorService 'taskScheduler'
-2020-07-22 15:01:41.470  INFO 9644 --- [SpringContextShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
-2020-07-22 15:01:41.482  INFO 9644 --- [SpringContextShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.
-2020-07-22 15:01:54.872  INFO 4348 --- [main] c.h.gydatasync.GydatasyncApplication     : Starting GydatasyncApplication on ZJY-PC with PID 4348 (E:\Work\对外接口\桂阳\code\gydatasync\target\classes started by ZJY in E:\Work\对外接口\桂阳\code\gydatasync)
-2020-07-22 15:01:54.875  INFO 4348 --- [main] c.h.gydatasync.GydatasyncApplication     : The following profiles are active: dev
-2020-07-22 15:01:55.927  INFO 4348 --- [main] o.s.s.c.ThreadPoolTaskScheduler          : Initializing ExecutorService 'taskScheduler'
-2020-07-22 15:01:55.964  INFO 4348 --- [main] c.h.gydatasync.GydatasyncApplication     : Started GydatasyncApplication in 1.484 seconds (JVM running for 2.102)
-2020-07-22 15:01:55.976  INFO 4348 --- [scheduling-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
-2020-07-22 15:01:56.176  INFO 4348 --- [scheduling-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
-2020-07-22 15:01:56.184 DEBUG 4348 --- [scheduling-1] c.h.g.d.mssql.SaveMeterDataDao.IsExist   : ==>  Preparing: select COUNT(*) from WaterData where CONVERT(varchar(10),UpLoadDateTime,120) = CONVERT(varchar(10),GETDATE(),120)
-2020-07-22 15:01:56.205 DEBUG 4348 --- [scheduling-1] c.h.g.d.mssql.SaveMeterDataDao.IsExist   : ==> Parameters: 
-2020-07-22 15:01:56.233 DEBUG 4348 --- [scheduling-1] c.h.g.d.mssql.SaveMeterDataDao.IsExist   : <==      Total: 1
-2020-07-22 15:02:24.323  WARN 4348 --- [HikariPool-1 housekeeper] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=58s146ms293µs997ns).
-2020-07-22 15:02:24.325  INFO 4348 --- [scheduling-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-2 - Starting...
-2020-07-22 15:02:24.401  INFO 4348 --- [SpringContextShutdownHook] o.s.s.c.ThreadPoolTaskScheduler          : Shutting down ExecutorService 'taskScheduler'
-2020-07-22 15:02:24.403  INFO 4348 --- [SpringContextShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
-2020-07-22 15:02:24.410  INFO 4348 --- [SpringContextShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.
+2020-07-28 09:18:15.703  INFO 59676 --- [main] c.h.g.GydatasyncApplicationTests         : Starting GydatasyncApplicationTests on pengdi with PID 59676 (started by pengdi in C:\Users\86159\git_repos\water-iot\gydatasync)
+2020-07-28 09:18:15.711  INFO 59676 --- [main] c.h.g.GydatasyncApplicationTests         : The following profiles are active: prd
+2020-07-28 09:18:18.513  INFO 59676 --- [main] o.s.s.c.ThreadPoolTaskScheduler          : Initializing ExecutorService 'taskScheduler'
+2020-07-28 09:18:18.647  INFO 59676 --- [main] c.h.g.GydatasyncApplicationTests         : Started GydatasyncApplicationTests in 3.552 seconds (JVM running for 5.549)
+2020-07-28 09:18:19.283  INFO 59676 --- [SpringContextShutdownHook] o.s.s.c.ThreadPoolTaskScheduler          : Shutting down ExecutorService 'taskScheduler'
+2020-07-28 09:18:19.286  INFO 59676 --- [SpringContextShutdownHook] com.alibaba.druid.pool.DruidDataSource   : {dataSource-0} closing ...
+2020-07-28 09:18:19.288  INFO 59676 --- [SpringContextShutdownHook] com.alibaba.druid.pool.DruidDataSource   : {dataSource-0} closing ...

+ 1 - 1
gydatasync/src/main/resources/application-prd.properties

@@ -17,7 +17,7 @@ spring.datasource.second.type=com.alibaba.druid.pool.DruidDataSource
 #日志
 logging.level.root=info
 logging.file.name=log.log
-logging.level.com.huaxu.gydatasync.dao.*=debug
+logging.level.com.huaxu.gydatasync.dao.*=info
 mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
 
 

+ 1 - 1
gydatasync/src/main/resources/application.properties

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

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

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

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

@@ -53,4 +53,6 @@ public interface CustomerMapper {
     List<Integer> findAllSubIds(@Param("customerId") Integer customerId);
 
     List<Integer> findAllIds(@Param("customerId") Integer customerId);
+
+    Customer findByName(@Param("siteId") Integer siteId, @Param("name") String name);
 }

+ 2 - 1
smart-city-platform/src/main/java/com/bz/smart_city/entity/Building.java

@@ -9,13 +9,14 @@ import lombok.Data;
 import lombok.ToString;
 import org.springframework.format.annotation.DateTimeFormat;
 
+import java.io.Serializable;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 
 @Data
 @ToString
 @ApiModel("建筑")
-public class Building {
+public class Building implements Serializable {
     @ApiModelProperty(value = "id", position = 1)
     private Integer id;
 

+ 2 - 1
smart-city-platform/src/main/java/com/bz/smart_city/entity/Community.java

@@ -3,13 +3,14 @@ package com.bz.smart_city.entity;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
+import java.io.Serializable;
 import java.time.LocalDateTime;
 import java.util.Date;
 import lombok.Data;
 
 @ApiModel(value="小区")
 @Data
-public class Community {
+public class Community implements Serializable {
     @ApiModelProperty(value="主键", hidden = true)
     private Integer id;
 

+ 2 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/BuildingService.java

@@ -86,4 +86,6 @@ public interface BuildingService{
     List<BuildingSelectDto> abnormalAreaBuildingList(Integer sysId, Integer buildingId, Integer floor, Integer measuringId, Long deviceId, String deviceNo, String location, Integer alarmCategory, Integer handleStatus, Integer alarmTypeId, Integer equipmentId, Integer manufacturerId, Integer customerId, Integer province, Integer city, Integer region, Integer communityId, LocalDateTime startDate, LocalDateTime endDate);
 
     List<BuildingSelectDto> installAreaList(String deviceNo, Integer status, String errorType, Integer customerId, Integer province, Integer city, Integer region, Integer community, Integer buildingId, String locDesc, Integer deviceTypeId, Integer registerStatus, LocalDateTime startDate, LocalDateTime endDate);
+
+    Building findCacheByName(Integer siteId, String name);
 }

+ 2 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/CommunityService.java

@@ -49,4 +49,6 @@ public interface CommunityService {
     List<Community> getMaxCodeBySiteId(Integer siteId);
 
     Community findByNameV2(Integer siteId, Integer province, Integer city, Integer region, String communityName);
+
+    Community findCacheByName(Integer siteId, String communityName);
 }

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

@@ -19,6 +19,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.cache.annotation.Cacheable;
 import org.springframework.cache.annotation.Caching;
 import org.springframework.stereotype.Service;
 
@@ -1324,6 +1325,12 @@ public class BuildingServiceImpl implements BuildingService {
         return 0;
     }
 
+    @Override
+    @Cacheable(value = "CacheBuilding", key = "#siteId + #name",unless = "#result == null")
+    public Building findCacheByName(Integer siteId, String name) {
+        return buildingMapper.findByName(siteId,name);
+    }
+
     private String getFilePath() {
         String name = Util.createUUIDId();
         String fullPath = filesPath + "/" + name + ".xlsm";

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

@@ -13,6 +13,7 @@ import com.bz.smart_city.entity.Area;
 import com.bz.smart_city.entity.ProgramItem;
 import com.github.pagehelper.PageHelper;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
 import java.time.LocalDateTime;
@@ -288,4 +289,10 @@ public class CommunityServiceImpl implements CommunityService{
     public Community findByNameV2(Integer siteId, Integer province, Integer city, Integer region, String communityName) {
         return communityMapper.findByNameV2(siteId,province,city,region,communityName);
     }
+
+    @Override
+    @Cacheable(value = "CacheCommunity", key = "#siteId + #communityName",unless = "#result == null")
+    public Community findCacheByName(Integer siteId, String communityName) {
+        return communityMapper.findByName(siteId,communityName);
+    }
 }

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

@@ -1320,6 +1320,7 @@ public  class DeviceServiceImpl implements DeviceService {
 
     @Override
     public void setValve(Long deviceId) {
+        Device device = deviceMapper.findByDeviceId(deviceId);
         WaterMeterErrorDays waterMeterErrorDays = waterMeterErrorDaysMapper.findByDeviceId(deviceId);
         String sendValveStatus = "0";
 
@@ -1330,7 +1331,7 @@ public  class DeviceServiceImpl implements DeviceService {
                 }
             }
         }
-        Device device = deviceMapper.findByDeviceId(deviceId);
+
         if (device.getUdipId() != null && !"".equals(device.getUdipId())) {
             //1、下发开关阀门
             Map<String,Object> map = new HashMap<>();

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

@@ -233,7 +233,7 @@ public class DeviceTypeServiceImpl implements DeviceTypeService {
     }
 
     @Override
-    @Cacheable(value = "deviceTypeName", key = "#deviceTypeName + #deviceTypeModel")
+    @Cacheable(value = "CacheDeviceType", key = "#deviceTypeName + #deviceTypeModel",unless = "#result == null")
     public DeviceTypeDto getByName(String deviceTypeName,String deviceTypeModel) {
         return deviceTypeMapper.getByName(deviceTypeName,deviceTypeModel);
     }

+ 59 - 57
smart-city-platform/src/main/java/com/bz/smart_city/service/importfile/AsyncTaskImportService.java

@@ -60,6 +60,8 @@ public class AsyncTaskImportService {
     @Resource
     private BuildingMapper buildingMapper;
     @Autowired
+    private BuildingService buildingService;
+    @Autowired
     private InstallManagerService installManagerService;
     @Autowired
     private DeviceTypeService deviceTypeService;
@@ -140,20 +142,27 @@ public class AsyncTaskImportService {
                     }
                     invalidTemplate = true;
                     // 1,处理表头,解析客户、户数
-                    Row customerIdRow = hssfSheet.getRow(2); // 客户Id行
-                    Cell customerIdCell =  customerIdRow.getCell(7);
-                    if(customerIdCell == null ) {
+                    Row customerRow = hssfSheet.getRow(1); // 客户Id行
+                    Cell customerNameCell =  customerRow.getCell(5);
+                    customerNameCell.setCellType(CellType.STRING);
+                    if(StringUtils.equals("", customerNameCell.getStringCellValue().trim())) {
+                        messageContent.append("导入失败,");
+                        messageContent.append(ResultStatus.CUSTOMER_IS_NOT_EXISTED.getMessage());
+                        continue;
+                    }
+                    Customer customer = customerMapper.findByName(record.getSiteId(),customerNameCell.getStringCellValue().trim());
+                    if(customer!=null){
+                        dto.setCustomerId(customer.getId());
+
+                    }else {
                         messageContent.append("导入失败,");
                         messageContent.append(ResultStatus.CUSTOMER_IS_NOT_EXISTED.getMessage());
                         continue;
                     }
-                    CellValue customerIdCellValue = evaluator.evaluate(customerIdCell);
-                    Integer customerId =   (int) customerIdCellValue.getNumberValue();
-                    dto.setCustomerId(customerId);
 
 
-                    Row numberRow = hssfSheet.getRow(3); // 安装数字,只处理指定安装户数的数据
-                    Cell numberCell = numberRow.getCell(7);
+                    Row numberRow = hssfSheet.getRow(2); // 安装数字,只处理指定安装户数的数据
+                    Cell numberCell = numberRow.getCell(5);
 
                     numberCell.setCellType(CellType.NUMERIC);
                     int number = ((Double)numberCell.getNumericCellValue()).intValue();
@@ -164,27 +173,24 @@ public class AsyncTaskImportService {
                     }
 
                     // 2,处理明细行数据
-                    for (int rowNum = 9; rowNum < 9+number ; rowNum++) {
+                    for (int rowNum = 8; rowNum < 8+number ; rowNum++) {
                         Row row = hssfSheet.getRow(rowNum);
                         if (row != null) {
 
                             Cell idCell = row.getCell(1) ; // 编号
                             Cell communityCell = row.getCell(2);
-                            Cell communityIdCell = row.getCell(3);
-                            Cell buildingCell = row.getCell(4);
-                            Cell buildingIdCell = row.getCell(5);
-                            Cell doorNoCell = row.getCell(6);
-                            Cell deviceTypeCell = row.getCell(7);
-                            Cell deviceTypeIdCell = row.getCell(8);
-                            Cell electronicNoCell = row.getCell(9);
-                            Cell deviceNoCell = row.getCell(10);
-                            Cell fileNoCell = row.getCell(11);
-                            Cell newMeterStartCell = row.getCell(12);
-                            Cell oldMeterEndCell = row.getCell(13);
-                            Cell userNameCell = row.getCell(14);
-                            Cell userPhoneCell = row.getCell(15);
-                            Cell idCardCell = row.getCell(16);
-                            Cell remarkCell = row.getCell(17);
+                            Cell buildingCell = row.getCell(3);
+                            Cell doorNoCell = row.getCell(4);
+                            Cell deviceTypeCell = row.getCell(5);
+                            Cell electronicNoCell = row.getCell(6);
+                            Cell deviceNoCell = row.getCell(7);
+                            Cell fileNoCell = row.getCell(8);
+                            Cell newMeterStartCell = row.getCell(9);
+                            Cell oldMeterEndCell = row.getCell(10);
+                            Cell userNameCell = row.getCell(11);
+                            Cell userPhoneCell = row.getCell(12);
+                            Cell idCardCell = row.getCell(13);
+                            Cell remarkCell = row.getCell(14);
 
 
                             if(idCell !=null){
@@ -193,31 +199,33 @@ public class AsyncTaskImportService {
                             }
 
                             communityCell.setCellType(CellType.STRING);
-                            if (StringUtils.equals("", communityCell.getStringCellValue())) {
+                            if (StringUtils.equals("", communityCell.getStringCellValue().trim())) {
                                 continue;
                             }
-                            if (communityIdCell != null) {
-                                CellValue communityIdCellValue = evaluator.evaluate(communityIdCell);
-                                Integer communityId =   ((Double) communityIdCellValue.getNumberValue()).intValue();
-                                if(communityId==0){
-                                    continue;
-                                }
-                                dto.setCommunityId(communityId);
+                            Community community = communityService.findCacheByName(record.getSiteId(),communityCell.getStringCellValue().trim());
+                            if (community != null) {
+                                dto.setCommunityId(community.getId());
+                            }else {
+                                failTime++ ;
+                                remarkCell.setCellValue(ResultStatus.COMMUNITY_IS_NOT_EXISTED.getMessage());
+                                continue;
                             }
 
+
                             buildingCell.setCellType(CellType.STRING);
-                            if (StringUtils.equals("", buildingCell.getStringCellValue())) {
+                            if (StringUtils.equals("", buildingCell.getStringCellValue().trim())) {
                                 continue;
                             }
-                            if (buildingIdCell != null) {
-                                CellValue buildingIdCellValue = evaluator.evaluate(buildingIdCell);
-                                Integer buildingId =   ((Double) buildingIdCellValue.getNumberValue()).intValue();
-                                if(buildingId==0){
-                                    continue;
-                                }
-                                dto.setBuildingId(buildingId);
+                            Building building = buildingService.findCacheByName(record.getSiteId(),buildingCell.getStringCellValue().trim());
+                            if (building != null) {
+                                dto.setBuildingId(building.getId());
+                            }else {
+                                failTime++ ;
+                                remarkCell.setCellValue(ResultStatus.BUILDING_IS_NOT_EXISTED.getMessage());
+                                continue;
                             }
 
+
                             doorNoCell.setCellType(CellType.STRING);
                             if (!StringUtils.equals("", doorNoCell.getStringCellValue())) {
                                 String doorNo = doorNoCell.getStringCellValue().trim();
@@ -229,24 +237,18 @@ public class AsyncTaskImportService {
 
 
                             deviceTypeCell.setCellType(CellType.STRING);
-                            if (StringUtils.equals("", deviceTypeCell.getStringCellValue())) {
+                            if (StringUtils.equals("", deviceTypeCell.getStringCellValue().trim())) {
                                 continue;
                             }
-                            if (deviceTypeIdCell != null) {
-                                CellValue deviceTypeIdCellValue = evaluator.evaluate(deviceTypeIdCell);
-                                Integer deviceTypeId =   ((Double) deviceTypeIdCellValue.getNumberValue()).intValue();
-                                if(deviceTypeId==0){
-                                    continue;
-                                }
-                                DeviceTypeDto dt = deviceTypeService.findById(deviceTypeId);
-                                if(dt == null) {
-                                    failTime++ ;
-                                    remarkCell.setCellValue(ResultStatus.DEVICE_TYPE_NOT_EXISTED.getMessage());
-                                    continue;
-                                }else {
-                                    dto.setDeviceTypeId(dt.getId());
-                                    dto.setFactoryId(dt.getManufacturerId());
-                                }
+                            String[] deviceType  = StringUtils.split(deviceTypeCell.getStringCellValue().trim(),"/");
+                            DeviceTypeDto dt = deviceTypeService.getByName(deviceType[1],deviceType[2]);
+                            if(dt != null) {
+                                dto.setDeviceTypeId(dt.getId());
+                                dto.setFactoryId(dt.getManufacturerId());
+                            }else {
+                                failTime++ ;
+                                remarkCell.setCellValue(ResultStatus.DEVICE_TYPE_NOT_EXISTED.getMessage());
+                                continue;
                             }
 
 
@@ -328,7 +330,7 @@ public class AsyncTaskImportService {
 
                     //循环为空的行上移
                     if(failTime > 0){
-                        for (int rowNum = 9+number-1; rowNum >= 9 ; rowNum--) {
+                        for (int rowNum = 8+number-1; rowNum >= 8 ; rowNum--) {
                             Row row = hssfSheet.getRow(rowNum);
                             if (row == null) {
                                 hssfSheet.shiftRows(rowNum+1, 5000, -1);

+ 579 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/udip/ConvertUtils.java

@@ -0,0 +1,579 @@
+package com.bz.smart_city.service.udip;
+
+import org.springframework.stereotype.Component;
+
+import java.math.BigInteger;
+import java.text.DecimalFormat;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+import static com.google.common.collect.Lists.newArrayList;
+
+public class ConvertUtils {
+    /**ConvertQuantity1
+     * 16进制转10进制
+     * @param hex
+     * @return
+     */
+    public BigInteger hexToDecimal(String hex) {
+        return new BigInteger(hex, 16);
+    }
+
+    /**
+     * 10进制转16进制
+     *
+     * @param i
+     * @return
+     */
+    public String demicalToHex(int i) {
+        return  Integer.toHexString(i);
+    }
+
+
+    /**
+     * 16进制转2进制字符
+     *
+     * @param hex
+     * @return
+     */
+    public String hexToByte(String hex) {
+        int i = Integer.parseInt(hex, 16);
+        String str2 = Integer.toBinaryString(i);
+        return str2;
+    }
+
+
+    /**
+     * 2进制字符转16进制
+     *
+     * @param bString
+     * @return
+     */
+    public String byteToHex(String bString) {
+        if (bString == null || bString.equals("") || bString.length() % 8 != 0)
+            return null;
+        StringBuffer tmp = new StringBuffer();
+        int iTmp = 0;
+        for (int i = 0; i < bString.length(); i += 4) {
+            iTmp = 0;
+            for (int j = 0; j < 4; j++) {
+                iTmp += Integer.parseInt(bString.substring(i + j, i + j + 1)) << (4 - j - 1);
+            }
+            tmp.append(Integer.toHexString(iTmp));
+        }
+        return tmp.toString();
+    }
+
+    /**
+     * 16进制转2进制字符串
+     *
+     * @param hexString
+     * @return
+     */
+    public String hexString2binaryString(String hexString) {
+        if (hexString == null || hexString.length() % 2 != 0)
+            return null;
+        String bString = "", tmp;
+        for (int i = 0; i < hexString.length(); i++) {
+            tmp = "0000" + Integer.toBinaryString(Integer.parseInt(hexString.substring(i, i + 1), 16));
+            bString += tmp.substring(tmp.length() - 4);
+        }
+        return bString;
+    }
+
+    /**
+     * 2进制字符转16进制
+     *
+     * @param bString
+     * @return
+     */
+    public String binaryString2hexString(String bString) {
+        if (bString == null || bString.equals("") || bString.length() % 8 != 0)
+            return null;
+        StringBuffer tmp = new StringBuffer();
+        int iTmp = 0;
+        for (int i = 0; i < bString.length(); i += 4) {
+            iTmp = 0;
+            for (int j = 0; j < 4; j++) {
+                iTmp += Integer.parseInt(bString.substring(i + j, i + j + 1)) << (4 - j - 1);
+            }
+            tmp.append(Integer.toHexString(iTmp));
+        }
+        return tmp.toString();
+    }
+
+    /**
+     * 2进制字符转10进制
+     * @param str
+     * @return
+     */
+    public int byteToDecimal(String str) {
+        int len = str.length();
+        char ch;
+        int num = 0;
+        for (int i = len - 1; i >= 0; i--) {
+            ch = str.charAt(i);
+            if (ch != '0' && ch != '1') {
+                System.out.println("input wrong!!");
+                break;
+            }
+            if (ch == '1') {
+                num = (int) (num + Math.pow(2, (len - 1) - i));
+            }
+        }
+        return num;
+    }
+
+    /**
+     * 十进制转二进制
+     *
+     * @param decNum
+     * @param digit
+     * @return
+     */
+    public  String decimalToByte(int decNum, int digit) {
+        String binStr = "";
+        for (int i = digit - 1; i >= 0; i--) {
+            binStr += (decNum >> i) & 1;
+        }
+        return binStr;
+    }
+
+    /**
+     * 16进制高低位转换
+     *
+     * @param src
+     * @return
+     */
+    public  String hexTransfer(String src) {
+        if (src.length() % 2 != 0) {
+            System.out.println("16进制数字长度错误!");
+            return "";
+        }
+        // 按照2个字节进行截取
+        List<String> tmp = new ArrayList<String>();
+        for (int i = 0; i < src.length() / 2; i++) {
+            tmp.add(src.substring(i * 2, (i + 1) * 2));
+        }
+        Collections.reverse(tmp);
+        StringBuffer sb = new StringBuffer();
+        for (String str : tmp) {
+            sb.append(str);
+        }
+        return sb.toString();
+    }
+
+    /**
+     * string转换为BYTE数组
+     *
+     * @param hexString
+     * @return
+     */
+    public static byte[] hexStringToByte(String hexString) {
+        if (hexString == null || hexString.equals("")) {
+            return null;
+        }
+        hexString = hexString.toUpperCase();
+        int length = hexString.length() / 2;
+        char[] hexChars = hexString.toCharArray();
+        byte[] d = new byte[length];
+        for (int i = 0; i < length; i++) {
+            int pos = i * 2;
+            d[i] = (byte) (charToByte(hexChars[pos]) << 4 | charToByte(hexChars[pos + 1]));
+        }
+        return d;
+    }
+    private static byte charToByte(char c) {
+        return (byte) "0123456789ABCDEF".indexOf(c);
+    }
+
+    /**
+     * 将字节数组转换为16进制格式的字符串
+     *
+     * @param b
+     * @return
+     */
+    public static String ByteToHexString(byte[] b) {
+        String r = "";
+
+        for (int i = 0; i < b.length; i++) {
+            String hex = Integer.toHexString(b[i] & 0xFF);
+            if (hex.length() == 1) {
+                hex = '0' + hex;
+            }
+            r += hex.toUpperCase();
+        }
+
+        return r;
+    }
+
+
+    /**
+     * 16进制加法
+     *
+     * @param hex1
+     * @param hex2
+     * @return
+     */
+    public  String hexAddHex(String hex1, String hex2) {
+        BigInteger hi1 = hexToDecimal(hex1);
+        BigInteger hi2 = hexToDecimal(hex2);
+        return demicalToHex(hi1.add(hi2).intValue());
+    }
+
+    /**
+     * 16进制减法
+     *
+     * @param hex1
+     * @param hex2
+     * @return
+     */
+    public String hexSubHex(String hex1, String hex2) {
+        BigInteger hi1 = hexToDecimal(hex1);
+        BigInteger hi2 = hexToDecimal(hex2);
+        return demicalToHex(hi1.subtract(hi2).intValue());
+    }
+
+    /**
+     * hex1 和 hex2 按位与的补码表示
+     * @param hex1
+     * @param hex2
+     * @return
+     */
+    public String bitwiseAnd(String hex1, String hex2){
+        return demicalToHex(hexToDecimal(hex1).intValue() & hexToDecimal(hex2).intValue());
+    }
+
+    /**
+     * hex1 和 hex2 按位或的补码表示
+     * @param hex1
+     * @param hex2
+     * @return
+     */
+    public String bitwiseOr(String hex1, String hex2){
+        return demicalToHex(hexToDecimal(hex1).intValue() | hexToDecimal(hex2).intValue());
+    }
+
+    /**
+     * 十六进制补位(不足补0)
+     * @param s
+     * @param length
+     * @return
+     */
+    public String padLeft(String s, int length)
+    {
+        byte[] bs = new byte[length];
+        byte[] ss = s.getBytes();
+        Arrays.fill(bs, (byte) (48 & 0xff));
+        System.arraycopy(ss, 0, bs,length - ss.length, ss.length);
+        return new String(bs);
+    }
+
+    /**
+     * "7dd",4,'0'==>"07dd"
+     * @param input 需要补位的字符串
+     * @param size 补位后的最终长度
+     * @param symbol 按symol补充 如'0'
+     * @return
+     * N_TimeCheck中用到了
+     */
+    public String fill(String input, int size, char symbol) {
+        while (input.length() < size) {
+            input = symbol + input;
+        }
+        return input;
+    }
+
+    public String fill(String input, int size) {
+        char symbol = '0';
+        while (input.length() < size) {
+            input = symbol + input;
+        }
+        return input;
+    }
+
+    /**
+     * 保留小数
+     * @param num
+     * @param length
+     * @return
+     */
+    public  String reserveDecimal(Double num, int length) {
+        String format = "%." + length + "f";
+        return String.format(format, num);
+    }
+
+
+    // 电磁水表换算 华旭提供
+    public static int dchs(String hexString) {
+        int temp = 0;
+        for (int i = 0; i < 8; i++) {
+            temp += (Integer.parseInt(hexString.substring(i, i + 1), 16) * Math.pow(16, 7 - i));
+        }
+        return temp;
+    }
+
+    /**
+     * 按长度分离字符
+     * @param str
+     * @param length
+     * @return
+     */
+    public static List<String> split(String str, int length){
+        List<String> list = newArrayList();
+        int z = 0;
+        for(int i=0;i<str.length()/length;i++){
+            String a = str.substring(z,z+length);
+
+            list.add(a);
+            z = z+length;
+        }
+        return list;
+    }
+
+
+    /**
+     * 16进制数转换成10进制数
+     *
+     * @param hexStr
+     * @return
+     */
+    public String ConvertQuantity(String hex) {
+        if(hex.equals("EEEEEEEE"))
+            return "";
+        //DecimalFormat df = new DecimalFormat("0.00");
+        //return df.format((Utilty.bytesToInt(Utilty.hexStringToBytes(hex), 0))/ (double) 100);
+        return hexToDecimal(hex).toString();
+    }
+    /**
+     * 16进制数转换成10进制数(有符号数)
+     * @param hex
+     * @return
+     */
+    public String ConvertQuantity4(String hex) {
+        if((hex.length()==4 &&hex.equals("EEEE"))||(hex.length()==8 &&hex.equals("EEEEEEEE")))
+            return "";
+        return String.valueOf(Integer.valueOf(hex,16).shortValue());
+    }
+    /**
+     * 16进制数转换成10进制数(100)
+     *
+     * @param hexStr
+     * @return
+     */
+    public String ConvertQuantity3(String hex) {
+        if((hex.length()==4 &&hex.equals("EEEE"))||(hex.length()==8 &&hex.equals("EEEEEEEE")))
+            return "";
+        DecimalFormat df = new DecimalFormat("0.000");
+        return df.format(Integer.parseInt(hex,16)/(double)1000);
+    }
+    /**
+     * 16进制数转换成10进制数(1000)
+     *
+     * @param hexStr
+     * @return
+     */
+    public String ConvertQuantity2(String hex) {
+        if((hex.length()==4 &&hex.equals("EEEE"))||(hex.length()==8 &&hex.equals("EEEEEEEE")))
+            return "";
+        DecimalFormat df = new DecimalFormat("0.000");
+        return df.format(Integer.parseInt(hex,16)/(double)100);
+    }
+    /**
+     * 16进制数转换成10进制数(1000)
+     *
+     * @param hexStr
+     * @return
+     */
+    public String ConvertQuantity5(String hex) {
+        if((hex.length()==4 &&hex.equals("EEEE"))||(hex.length()==8 &&hex.equals("EEEEEEEE")))
+            return "";
+        DecimalFormat df = new DecimalFormat("0.00");
+        return df.format(Integer.parseInt(hex,16)/(double)100);
+    }
+    /**
+     * 16进制数转换成10进制数(1000)
+     *
+     * @param hexStr
+     * @return
+     */
+    public String ConvertQuantity1(String hex) {
+        if((hex.length()==4 &&hex.equals("EEEE"))||(hex.length()==8 &&hex.equals("EEEEEEEE")))
+            return "";
+        DecimalFormat df = new DecimalFormat("0.000");
+        return df.format(Integer.parseInt(hex,16)/(double)1000);
+    }
+
+    public String dateFormat(Date date, String format) {
+        SimpleDateFormat sdf = new SimpleDateFormat(format);
+        return sdf.format(date);
+    }
+
+    /**
+     * 返回水表编码
+     * @param
+     * @return
+     */
+    public  String AnalyzeAddress(String HexString) {
+        String Address = "";
+        Address += HexString.substring(12, 14) + HexString.substring(10, 12);
+        Address += HexString.substring(8, 10) + HexString.substring(6, 8);
+        Address += HexString.substring(4, 6) + HexString.substring(2, 4);
+        Address += HexString.substring(0, 2);
+        return Address;
+    }
+
+    public String calculateChecksum(String HexString) {
+        byte[] frameBody = hexStringToByte(HexString);
+        byte sum = 0x00;
+        byte[] reByte= new byte[1];
+        int a = frameBody.length;
+        for (int i = 0; i < frameBody.length; i++)
+            sum += frameBody[i];
+        reByte[0]=sum;
+        return ByteToHexString(reByte);
+    }
+    //16进制转换为ASCII
+    public static String convertHexToString(String hex){
+        StringBuilder sb = new StringBuilder();
+        StringBuilder temp = new StringBuilder();
+        //49204c6f7665204a617661 split into two cha racters 49, 20, 4c...
+        for( int i=0; i<hex.length()-1; i+=2 ){
+            //grab the hex in pairs
+            String output = hex.substring(i, (i + 2));
+            if(output.equals("00"))
+                continue;
+
+            //convert hex to decimal
+            int decimal = Integer.parseInt(output, 16);
+            //convert the decimal to character
+            sb.append((char)decimal);
+            temp.append(decimal);
+        }
+        return sb.toString();
+    }
+
+    public static String ChangeSort(String hex) {
+        String tempString="";
+        for(int i=0;i<hex.length()/2;i++)
+        {
+            tempString =(hex.substring(i*2,i*2+2)+tempString);
+        }
+        return tempString;
+    }
+
+    /**
+     * byte数组中转换为int数值,本方法适用于(低位在前,高位在后)的顺序。
+     *
+     * @param hexStr
+     * @return
+     */
+    public static int bytesToInt(byte[] src, int offset) {
+        int value;
+        value = (int) ((src[offset] & 0xFF) | ((src[offset + 1] & 0xFF) << 8)
+                | ((src[offset + 2] & 0xFF) << 16) | ((src[offset + 3] & 0xFF) << 24));
+        return value;
+    }
+
+    /**
+     * 16进制直接转换成为byte数组(无需Unicode解码)
+     *
+     * @param hexStr
+     * @return
+     */
+    public static byte[] hexStringToBytes(String hexString) {
+        if (hexString == null || hexString.equals("")) {
+            return null;
+        }
+        hexString = hexString.toUpperCase();
+        int length = hexString.length() / 2;
+        char[] hexChars = hexString.toCharArray();
+        byte[] d = new byte[length];
+        for (int i = 0; i < length; i++) {
+            int pos = i * 2;
+            d[i] = (byte) (charToByte(hexChars[pos]) << 4 | charToByte(hexChars[pos + 1]));
+        }
+        return d;
+    }
+    /**
+     * 16进制数转换成10进制数
+     *
+     * @param hexStr
+     * @return
+     */
+    private String ConvertQuantity6(String hex) {
+        if(hex.equals("EEEEEEEE"))
+            return "";
+        DecimalFormat df = new DecimalFormat("0.00");
+        return df.format((bytesToInt(hexStringToBytes(hex), 0))/ (double) 100);
+    }
+
+    public String bytes2HexString(byte[] b) {
+        String r = "";
+
+        for (int i = 0; i < b.length; i++) {
+            String hex = Integer.toHexString(b[i] & 0xFF);
+            if (hex.length() == 1) {
+                hex = '0' + hex;
+            }
+            r += hex.toUpperCase();
+        }
+
+        return r;
+    }
+
+    private static String[] binaryArray = { "0000", "0001", "0010", "0011",
+            "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011",
+            "1100", "1101", "1110", "1111" };
+    private static String hexStr = "0123456789ABCDEF";
+
+    /**
+     *
+     * @param str
+     * @return 二进制数组转换为二进制字符串 2-2
+     */
+    public static String bytes2BinStr(byte[] bArray) {
+
+        String outStr = "";
+        int pos = 0;
+        for (byte b : bArray) {
+            // 高四位
+            pos = (b & 0xF0) >> 4;
+            outStr += binaryArray[pos];
+            // 低四位
+            pos = b & 0x0F;
+            outStr += binaryArray[pos];
+        }
+        return outStr;
+    }
+
+    /**
+     *
+     * @param hexString
+     * @return 将十六进制转换为二进制字节数组 16-2
+     */
+    public static byte[] hexStr2BinArr(String hexString) {
+        // hexString的长度对2取整,作为bytes的长度
+        int len = hexString.length() / 2;
+        byte[] bytes = new byte[len];
+        byte high = 0;// 字节高四位
+        byte low = 0;// 字节低四位
+        for (int i = 0; i < len; i++) {
+            // 右移四位得到高位
+            high = (byte) ((hexStr.indexOf(hexString.charAt(2 * i))) << 4);
+            low = (byte) hexStr.indexOf(hexString.charAt(2 * i + 1));
+            bytes[i] = (byte) (high | low);// 高地位做或运算
+        }
+        return bytes;
+    }
+
+    /**
+     *
+     * @param hexString
+     * @return 将十六进制转换为二进制字符串 16-2
+     */
+    public static String hexStr2BinStr(String hexString) {
+        return bytes2BinStr(hexStr2BinArr(hexString));
+    }
+
+}

+ 85 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/udip/Lora188Parser.java

@@ -0,0 +1,85 @@
+package com.bz.smart_city.service.udip;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class Lora188Parser {
+    ConvertUtils convertUtils = new ConvertUtils();
+
+    public Map<String,Object> protocolToRawData(Map<String,Object> jsonObj) {
+        String precursor = "FEFEFEFE"; //前导
+
+        String StartChar = "68";//起始符
+
+        String meterType = "10";//表类型 冷水表
+
+        String P_AddressField;//地址域
+
+        String P_ControlField = "04";//控制域
+
+        String P_DataLength = "04"; //帧数据域长度
+
+
+        String P_DataSymbol ="A017";//数据单元标识
+
+        String P_SER ="00";//序号SER
+
+        String P_Content="";//帧数据单元域
+
+        String P_Checksum="";//校验码
+
+        String EndChar = "16";//结束符
+
+
+
+        Map<String,Object> resultObj = new HashMap<>();
+        try {
+            if("WriteValve".equals(jsonObj.get("method"))){
+                Map<String,Object> params = (Map<String, Object>) jsonObj.get("params");
+                String meterEleno = String.valueOf(params.get("electronicNo"));//电子表号
+                String valve = String.valueOf(params.get("valveStatus"));
+
+                //转换电子表号
+                P_AddressField = convertUtils.hexTransfer(convertUtils.padLeft(meterEleno,14));
+                if (valve.equals("1"))
+                    P_Content = "55";//开阀
+                else if (valve.equals("0"))
+                    P_Content = "99";//关阀
+
+
+                String sHead = StartChar + meterType + P_AddressField;
+                String sBody = P_ControlField + P_DataLength + P_DataSymbol + P_SER  + P_Content;
+
+                P_Checksum =  convertUtils.calculateChecksum(sHead + sBody);
+
+                String data =  precursor + sHead + sBody + P_Checksum + EndChar;
+                resultObj.put("status",1);
+                resultObj.put("message","successful");
+                resultObj.put("data",data);
+                return resultObj;
+            }else {
+                resultObj.put("status",0);
+                resultObj.put("message","method mismatching");
+                return resultObj;
+            }
+        }catch(Exception e) {
+            e.fillInStackTrace();
+            resultObj.put("status",0);
+            resultObj.put("message",e.getMessage());
+            return resultObj;
+        }
+    }
+
+    public static void main(String[] args) {
+        System.out.println(1);
+        /*Lora188Parser parser = new Lora188Parser();
+        Map<String,Object> map = new HashMap<>();
+        Map<String,Object> paras = new HashMap<>();
+        //paras.put("electronicNo","00202004170001")
+        paras.put("electronicNo","00000190439135");
+        paras.put("valveStatus", "1");//阀门状态  0:关阀 1:开阀
+        map.put("params", paras);
+        map.put("method", "WriteValve");
+        System.out.println(parser.protocolToRawData(map));*/
+    }
+}

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


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

@@ -351,6 +351,10 @@
         ) T1
     </select>
 
+    <select id="findByName" resultMap="BaseResultMap">
+        select id,customer_name from sc_customer where status = 1 and site_id = #{siteId} and customer_name = #{name} limit 1
+    </select>
+
 
 </mapper>
 

+ 22 - 0
smart-city-platform/src/test/java/com/bz/smart_city/ProtocolParser.java

@@ -0,0 +1,22 @@
+package com.bz.smart_city;
+
+import com.bz.smart_city.service.udip.Lora188Parser;
+import org.junit.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class ProtocolParser {
+    @Test
+    public void test(){
+        Lora188Parser parser = new Lora188Parser();
+        Map<String,Object> map = new HashMap<>();
+        Map<String,Object> paras = new HashMap<>();
+        //paras.put("electronicNo","00202004170001")
+        paras.put("electronicNo","00000190439127");
+        paras.put("valveStatus", "1");//阀门状态  0:关阀 1:开阀
+        map.put("params", paras);
+        map.put("method", "WriteValve");
+        System.out.println(parser.protocolToRawData(map));
+    }
+}

+ 43 - 0
smart-city-platform/src/test/java/com/bz/smart_city/ScTest.java

@@ -1,6 +1,9 @@
 package com.bz.smart_city;
 
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.bz.smart_city.commom.util.HttpRequest;
 import com.bz.smart_city.commom.util.Jdk8DateUtils;
 import com.bz.smart_city.commom.util.Util;
 import com.bz.smart_city.dto.DeviceTypeDto;
@@ -13,9 +16,11 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.http.message.BasicNameValuePair;
 import org.junit.Test;
 
 import javax.validation.constraints.Null;
+import java.io.IOException;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.LocalTime;
@@ -310,6 +315,44 @@ public class ScTest {
         log.info("udipUnit json:"+ json);
     }
 
+    @Test
+    public void downlink(){
+        String url = "http://api.easylinkin.com/api/v1/application/downlink?";
+        Map<String,Object> map = new HashMap<>();
+        map.put("mac","004a77012403af45");
+        map.put("token","huaxu180820");
+        map.put("appeui","2C26C501241E0000");
+        map.put("payload","FEFEFEFE6810279143900100000404A01700551816");
+        map.put("ttl","2h");
+        map.put("payloadType","1");
+        map.put("confirmed",true);
+        String temp = "";
+        for (String key : map.keySet()) {
+            temp += "&" + key + "=" +map.get(key);
+        }
+        url += temp.substring(1);
+        System.out.println(url);
+        try {
+            String result = HttpRequest.doGet(url);
+            System.out.println(result);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+
+    }
+
+    @Test
+    public void jsonPerTest(){
+        String param = "{\n" +
+                "            \"code\": [\"YFFJK\",\"GDZD\",\"WXYC\",\"YXYC\",\"LORAWM\",\"NBWM\",\"LORAM\",\"QBTGDZD\"]\n" +
+                "        }";
+        JSONObject obj = JSONObject.parseObject(param);
+        //JSONArray list = obj.getJSONArray("code");
+        List<String> list =  JSON.parseArray(obj.getString("code"),String.class);
+        System.out.println(list);
+    }
+
+
 
 
 }