523096025 hace 2 años
commit
836cd0a2a2
Se han modificado 85 ficheros con 6350 adiciones y 0 borrados
  1. 92 0
      huimv-env-common/pom.xml
  2. 80 0
      huimv-env-common/src/main/java/com/huimv/env/common/utils/Const.java
  3. 425 0
      huimv-env-common/src/main/java/com/huimv/env/common/utils/DateUtil.java
  4. 123 0
      huimv-env-common/src/main/java/com/huimv/env/common/utils/MathUtil.java
  5. 30 0
      huimv-env-common/src/main/java/com/huimv/env/common/utils/MathUtil2.java
  6. 31 0
      huimv-env-common/src/main/java/com/huimv/env/common/utils/RegexUtil.java
  7. 12 0
      huimv-env-common/src/main/java/com/huimv/env/common/utils/SMSManager.java
  8. 126 0
      huimv-env-common/src/test/java/com/huimv/env/common/CodeGenerator.java
  9. 128 0
      huimv-env-device/pom.xml
  10. 30 0
      huimv-env-device/src/main/java/com/huimv/env/device/HuimvDeviceApplication.java
  11. 45 0
      huimv-env-device/src/main/java/com/huimv/env/device/config/ConfigBean.java
  12. 161 0
      huimv-env-device/src/main/java/com/huimv/env/device/config/TopicRabbitMQConfig.java
  13. 12 0
      huimv-env-device/src/main/java/com/huimv/env/device/config/WeChatMessage.java
  14. 87 0
      huimv-env-device/src/main/java/com/huimv/env/device/config/WeChatMessageHelperTest.java
  15. 175 0
      huimv-env-device/src/main/java/com/huimv/env/device/config/WebSocket.java
  16. 19 0
      huimv-env-device/src/main/java/com/huimv/env/device/config/WebSocketConfig.java
  17. 338 0
      huimv-env-device/src/main/java/com/huimv/env/device/listener/DeviceListener.java
  18. 52 0
      huimv-env-device/src/main/java/com/huimv/env/device/listener/SensorListener.java
  19. 45 0
      huimv-env-device/src/main/java/com/huimv/env/device/producer/Producer.java
  20. 8 0
      huimv-env-device/src/main/java/com/huimv/env/device/service/ICommandParserService.java
  21. 46 0
      huimv-env-device/src/main/java/com/huimv/env/device/service/IDeviceService.java
  22. 29 0
      huimv-env-device/src/main/java/com/huimv/env/device/service/impl/CommandParserServiceImpl.java
  23. 477 0
      huimv-env-device/src/main/java/com/huimv/env/device/service/impl/DeviceServiceImpl.java
  24. 104 0
      huimv-env-device/src/main/resources/application-dev.yml
  25. 110 0
      huimv-env-device/src/main/resources/application-prod.yml
  26. 34 0
      huimv-env-device/src/main/resources/application.properties
  27. 3 0
      huimv-env-device/src/main/resources/conf/config.properties
  28. 61 0
      huimv-env-device/src/test/java/com/huimv/env/device/service/DeviceTest.java
  29. 150 0
      huimv-env-input-water/pom.xml
  30. 25 0
      huimv-env-input-water/src/main/java/com/huimv/env/input/HuimvEnvInputApplication.java
  31. 48 0
      huimv-env-input-water/src/main/java/com/huimv/env/input/controller/ChengzhongController.java
  32. 43 0
      huimv-env-input-water/src/main/java/com/huimv/env/input/entity/Chengzhong.java
  33. 16 0
      huimv-env-input-water/src/main/java/com/huimv/env/input/mapper/ChengzhongMapper.java
  34. 139 0
      huimv-env-input-water/src/main/java/com/huimv/env/input/producer/Producer.java
  35. 49 0
      huimv-env-input-water/src/main/java/com/huimv/env/input/server/DtuServer.java
  36. 115 0
      huimv-env-input-water/src/main/java/com/huimv/env/input/server/DtuServiceHandler.java
  37. 67 0
      huimv-env-input-water/src/main/java/com/huimv/env/input/server/EnvInputServer.java
  38. 264 0
      huimv-env-input-water/src/main/java/com/huimv/env/input/server/EnvInputServerHandler.java
  39. 16 0
      huimv-env-input-water/src/main/java/com/huimv/env/input/service/IChengzhongService.java
  40. 8 0
      huimv-env-input-water/src/main/java/com/huimv/env/input/service/ICommandProcessorService.java
  41. 20 0
      huimv-env-input-water/src/main/java/com/huimv/env/input/service/impl/ChengzhongServiceImpl.java
  42. 19 0
      huimv-env-input-water/src/main/java/com/huimv/env/input/service/impl/CommandProcessorServiceImpl.java
  43. 187 0
      huimv-env-input-water/src/main/java/com/huimv/env/input/utils/DateUtil2.java
  44. 55 0
      huimv-env-input-water/src/main/java/com/huimv/env/input/utils/ModBusUtils.java
  45. 79 0
      huimv-env-input-water/src/main/java/com/huimv/env/input/utils/Result.java
  46. 41 0
      huimv-env-input-water/src/main/java/com/huimv/env/input/utils/ResultCode.java
  47. 105 0
      huimv-env-input-water/src/main/resources/application-dev.yml
  48. 89 0
      huimv-env-input-water/src/main/resources/application-prod.yml
  49. 33 0
      huimv-env-input-water/src/main/resources/application.properties
  50. 24 0
      huimv-env-input-water/src/main/resources/assembly.xml
  51. 12 0
      huimv-env-input-water/src/main/resources/com/huimv/env/input/ChengzhongMapper.xml
  52. 105 0
      huimv-env-input-water/target/classes/application-dev.yml
  53. 89 0
      huimv-env-input-water/target/classes/application-prod.yml
  54. 33 0
      huimv-env-input-water/target/classes/application.properties
  55. 24 0
      huimv-env-input-water/target/classes/assembly.xml
  56. 12 0
      huimv-env-input-water/target/classes/com/huimv/env/input/ChengzhongMapper.xml
  57. BIN
      huimv-env-input-water/target/classes/com/huimv/env/input/HuimvEnvInputApplication.class
  58. BIN
      huimv-env-input-water/target/classes/com/huimv/env/input/controller/ChengzhongController.class
  59. BIN
      huimv-env-input-water/target/classes/com/huimv/env/input/entity/Chengzhong.class
  60. BIN
      huimv-env-input-water/target/classes/com/huimv/env/input/mapper/ChengzhongMapper.class
  61. BIN
      huimv-env-input-water/target/classes/com/huimv/env/input/server/EnvInputServer.class
  62. BIN
      huimv-env-input-water/target/classes/com/huimv/env/input/server/EnvInputServerHandler.class
  63. BIN
      huimv-env-input-water/target/classes/com/huimv/env/input/service/IChengzhongService.class
  64. BIN
      huimv-env-input-water/target/classes/com/huimv/env/input/service/impl/ChengzhongServiceImpl.class
  65. BIN
      huimv-env-input-water/target/classes/com/huimv/env/input/utils/ModBusUtils.class
  66. BIN
      huimv-env-input-water/target/classes/com/huimv/env/input/utils/Result.class
  67. BIN
      huimv-env-input-water/target/classes/com/huimv/env/input/utils/ResultCode.class
  68. BIN
      huimv-env-input-water/target/huimv-env-input-0.0.1-SNAPSHOT.jar
  69. BIN
      huimv-env-input-water/target/huimv-env-input-0.0.1-SNAPSHOT.jar.original
  70. 3 0
      huimv-env-input-water/target/maven-archiver/pom.properties
  71. 2 0
      huimv-env-input-water/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
  72. 16 0
      huimv-env-input-water/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
  73. 112 0
      huimv-env-input/pom.xml
  74. 33 0
      huimv-env-input/src/main/java/com/huimv/env/input/HuimvEnvInputApplication.java
  75. 160 0
      huimv-env-input/src/main/java/com/huimv/env/input/config/TopicRabbitMQConfig.java
  76. 139 0
      huimv-env-input/src/main/java/com/huimv/env/input/producer/Producer.java
  77. 74 0
      huimv-env-input/src/main/java/com/huimv/env/input/server/EnvInputServer.java
  78. 584 0
      huimv-env-input/src/main/java/com/huimv/env/input/server/EnvInputServerHandler.java
  79. 8 0
      huimv-env-input/src/main/java/com/huimv/env/input/service/ICommandProcessorService.java
  80. 32 0
      huimv-env-input/src/main/java/com/huimv/env/input/service/impl/CommandProcessorServiceImpl.java
  81. 187 0
      huimv-env-input/src/main/java/com/huimv/env/input/utils/DateUtil2.java
  82. 105 0
      huimv-env-input/src/main/resources/application-dev.yml
  83. 89 0
      huimv-env-input/src/main/resources/application-prod.yml
  84. 32 0
      huimv-env-input/src/main/resources/application.properties
  85. 24 0
      huimv-env-input/src/main/resources/assembly.xml

+ 92 - 0
huimv-env-common/pom.xml

@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>huimv-env-platform</artifactId>
+        <groupId>com.huimv</groupId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <packaging>jar</packaging>
+    <groupId>com.huimv</groupId>
+    <artifactId>huimv-env-common</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+
+    <distributionManagement>
+        <repository>
+            <id>rdc-releases</id>
+            <url>https://repo.rdc.aliyun.com/repository/136471-release-drEU5y/</url>
+        </repository>
+        <snapshotRepository>
+            <id>rdc-snapshots</id>
+            <url>https://repo.rdc.aliyun.com/repository/136471-snapshot-WhviYl/</url>
+        </snapshotRepository>
+    </distributionManagement>
+
+    <dependencies>
+        <!--Mybatis-Plus生成器依赖-->
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-generator</artifactId>
+        </dependency>
+        <!--freemarker 模板引擎(没有用原生的模板引擎)-->
+        <dependency>
+            <groupId>org.freemarker</groupId>
+            <artifactId>freemarker</artifactId>
+        </dependency>
+        <!--mybits-plus-->
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-boot-starter</artifactId>
+        </dependency>
+        <!-- mybatis-plus-extension -->
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-extension</artifactId>
+        </dependency>
+        <!-- 连接池 -->
+        <dependency>
+            <!--自动配置-->
+            <groupId>com.alibaba</groupId>
+            <artifactId>druid-spring-boot-starter</artifactId>
+        </dependency>
+        <!-- velocity -->
+        <dependency>
+            <groupId>org.apache.velocity</groupId>
+            <artifactId>velocity-engine-core</artifactId>
+        </dependency>
+        <!-- junit -->
+        <dependency>
+            <groupId>org.junit.platform</groupId>
+            <artifactId>junit-platform-commons</artifactId>
+        </dependency>
+        <!-- JPA -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-jpa</artifactId>
+        </dependency>
+        <!-- mysql -->
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+        </dependency>
+        <!-- lombok -->
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+        </dependency>
+        <!-- 二方包统一版本管理 -->
+        <dependency>
+            <groupId>com.huimv</groupId>
+            <artifactId>huimv-common</artifactId>
+        </dependency>
+    </dependencies>
+
+</project>

+ 80 - 0
huimv-env-common/src/main/java/com/huimv/env/common/utils/Const.java

@@ -0,0 +1,80 @@
+package com.huimv.env.common.utils;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+public class Const {
+    // 温度
+    public final static String ROUTING_KEY_TEMP = "topic.temp.key1";
+//    public final static String QUEUE_TEMP = "topic.temp.queue";
+    public final static String QUEUE_TEMP = "topic.temp.queue1";
+    public final static String EXCHANGE_TEMP = "topic.temp.exchange1";
+
+    // 湿度
+    public final static String ROUTING_KEY_HUMI = "topic.humi.key1";
+//    public final static String QUEUE_HUMI = "topic.humi.queue";
+    public final static String QUEUE_HUMI = "topic.humi.queue1";
+    public final static String EXCHANGE_HUMI = "topic.humi.exchange1";
+
+    // 氨气
+    public final static String ROUTING_KEY_AMMONIA = "topic.ammonia.key1";
+//    public final static String QUEUE_AMMONIA = "topic.ammonia.queue";
+    public final static String QUEUE_AMMONIA = "topic.ammonia.queue";
+    public final static String EXCHANGE_AMMONIA = "topic.ammonia.exchange1";
+
+    // 传感器
+    public final static String ROUTING_KEY_SENSOR = "topic.sensor.key1";
+//    public final static String QUEUE_SENSOR = "topic.sensor.queue";
+    public final static String QUEUE_SENSOR = "topic.sensor.queue1";
+    public final static String EXCHANGE_SENSOR = "topic.sensor.exchange1";
+
+    //设备状态
+    public final static String ROUTING_KEY_DEVICE_STATUS = "topic.deviceStatus.key1";
+//    public final static String QUEUE_DEVICE_STATUS = "topic.deviceStatus.queue";
+    public final static String QUEUE_DEVICE_STATUS = "topic.deviceStatus.queue1";
+    public final static String EXCHANGE_DEVICE_STATUS = "topic.deviceStatus.exchange1";
+
+    //平台推送短信
+    public final static String ROUTING_KEY_PUSH_MESSAGE = "topic.pushMessage.key1";
+//    public final static String QUEUE_PUSH_MESSAGE = "topic.pushMessage.queue";
+    public final static String QUEUE_PUSH_MESSAGE = "topic.pushMessage.queue1";
+    public final static String EXCHANGE_PUSH_MESSAGE = "topic.pushMessage.exchange1";
+
+    // 水压
+    public final static String ROUTING_KEY_WATER_GEGE = "topic.waterGege.key1";
+//    public final static String QUEUE_WATER_GEGE = "topic.waterGege.queue";
+    public final static String QUEUE_WATER_GEGE = "topic.waterGege.queue1";
+    public final static String EXCHANGE_WATER_GEGE = "topic.waterGege.exchange1";
+
+    // PH
+    public final static String ROUTING_KEY_PH = "topic.ph.key1";
+//    public final static String QUEUE_PH = "topic.ph.queue";
+    public final static String QUEUE_PH = "topic.ph.queue1";
+    public final static String EXCHANGE_PH = "topic.ph.exchange1";
+
+    // 水表
+    public final static String ROUTING_KEY_WATER_METER = "topic.waterMeter.key1";
+//    public final static String QUEUE_WATER_METER = "topic.waterMeter.queue";
+    public final static String QUEUE_WATER_METER = "topic.waterMeter.queue1";
+    public final static String EXCHANGE_WATER_METER = "topic.waterMeter.exchange1";
+
+    // 电表
+    public final static String ROUTING_KEY_ELECTRICITY_METER = "topic.electricityMeter.key1";
+//    public final static String QUEUE_ELECTRICITY_METER = "topic.electricityMeter.queue";
+    public final static String QUEUE_ELECTRICITY_METER = "topic.electricityMeter.queue1";
+    public final static String EXCHANGE_ELECTRICITY_METER = "topic.electricityMeter.exchange1";
+
+    public final static Integer ERR_TODAY_WATER_CODE = 10050;
+    public final static String ERR_TODAY_WATER_INFO = "今天水量数据不存在";
+
+    public final static Integer ERR_TODAY_ELECTRICITY_CODE = 10051;
+    public final static String ERR_TODAY_ELECTRICITY_INFO = "今天电量数据不存在";
+
+    public final static Integer ERR_EMPTY_CODE = 10052;
+    public final static String ERR_EMPTY_INFO = "数据为空";
+}

+ 425 - 0
huimv-env-common/src/main/java/com/huimv/env/common/utils/DateUtil.java

@@ -0,0 +1,425 @@
+package com.huimv.env.common.utils;
+
+import cn.hutool.core.date.DateTime;
+import org.springframework.stereotype.Component;
+
+import java.sql.Timestamp;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@Component
+//@Slf4j
+public class DateUtil {
+
+    //格式化本月
+    public String getLastMonthAndYear(Date date){
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(date);
+        cal.add(Calendar.MONTH, -1);
+        int month = cal.get(Calendar.MONTH) + 1;
+        int year = cal.get(Calendar.YEAR);
+        return year+"-"+month;
+    }
+
+    //格式化上月
+    public String getBeforeMonthAndYear(int beforeMonths){
+        Calendar cal = Calendar.getInstance();
+        cal.add(Calendar.MONTH, -beforeMonths);
+        int month = cal.get(Calendar.MONTH) + 1;
+        int year = cal.get(Calendar.YEAR);
+        return year+"-"+month;
+    }
+
+    //格式化上月
+    public String getLastMonthAndYear(){
+        Calendar cal = Calendar.getInstance();
+        cal.add(Calendar.MONTH, -1);
+        int month = cal.get(Calendar.MONTH) + 1;
+        int year = cal.get(Calendar.YEAR);
+        return year+"-"+month;
+    }
+
+    public String getThisMonthAndYear(){
+        Calendar cal = Calendar.getInstance();
+//        cal.add(Calendar.MONTH, -1);
+        int month = cal.get(Calendar.MONTH) + 1;
+        int year = cal.get(Calendar.YEAR);
+        return year+"-"+month;
+    }
+
+
+    //读取之前hours小时的时间
+    public String getBeforeHoursDatetime(String newTime,int hours) throws ParseException {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Date newDate = sdf.parse(newTime);
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(newDate);
+        cal.add(Calendar.HOUR_OF_DAY, -hours+1);
+        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd");
+        String dateText = sdf2.format(cal.getTime());
+        int hour = cal.get(Calendar.HOUR_OF_DAY);
+        String hourText = String.valueOf(hour);
+        if(hour<10){
+            hourText = "0"+String.valueOf(hour);
+        }
+        return dateText + " "+hourText + ":00:00";
+    }
+
+    //读取之后hours小时的时间
+    public String getAfterHoursDatetime(String newTime,int hours) throws ParseException {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Date newDate = sdf.parse(newTime);
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(newDate);
+        cal.add(Calendar.HOUR_OF_DAY, +hours);
+        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd");
+        String dateText = sdf2.format(cal.getTime());
+        int hour = cal.get(Calendar.HOUR_OF_DAY);
+        String hourText = String.valueOf(hour);
+        if(hour<10){
+            hourText = "0"+String.valueOf(hour);
+        }
+        return dateText + " "+hourText + ":00:00";
+    }
+
+    public int setCalendarNewTime(String newTime) throws ParseException {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(sdf.parse(newTime));
+        return cal.get(Calendar.HOUR_OF_DAY);
+    }
+    //
+    public String handleAskTime(String askTime) {
+        String newAskTime = askTime.substring(0, 4) + "-" + askTime.substring(4, 6) + "-" + askTime.substring(6, 8) + " " + askTime.substring(8, 10) + ":" + askTime.substring(10, 12) + ":" + askTime.substring(12, 14);
+        return newAskTime;
+    }
+
+    public int getNowHour(){
+        Calendar cal = Calendar.getInstance();
+        return cal.get(Calendar.HOUR_OF_DAY);
+    }
+
+    //格式化日期(Long --> Date)
+    public String formatLongToDate(Long longDate){
+        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Date date= new Date(longDate);
+        return df.format(date);
+    }
+
+    //格式化本年
+    public String getThisYear(){
+        Calendar cal = Calendar.getInstance();
+        int year = cal.get(Calendar.YEAR);
+        return String.valueOf(year);
+    }
+
+    //格式化本月
+    public String getThisMonth(){
+        Calendar cal = Calendar.getInstance();
+        int month = cal.get(Calendar.MONTH) + 1;
+        if(String.valueOf(month).length()==1)
+        {
+            return "0"+String.valueOf(month);
+        }else{
+            return String.valueOf(month);
+        }
+    }
+
+    //格式化日期时间
+    public String formatDateTime(String dateText) throws ParseException {
+        if(dateText.indexOf("T") != -1){
+            dateText = dateText.replace("T"," ");
+        }
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Date date = sdf.parse(dateText);
+        return sdf.format(date);
+    }
+
+    //格式化日期时间
+    public String formatDateText(String dateText) throws ParseException {
+        if(dateText.indexOf("T") != -1){
+            dateText = dateText.replace("T"," ");
+        }
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        Date date = sdf.parse(dateText);
+        return sdf.format(date);
+    }
+//    public String formatDateText(Date date) throws ParseException {
+//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+//        return sdf.format(date);
+//    }
+
+    public Date parseDateTime(String dateText) throws ParseException {
+        if(dateText.indexOf("T") != -1){
+            dateText = dateText.replace("T"," ");
+        }
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        return sdf.parse(dateText);
+    }
+
+    public Date parseDate(String dateText) throws ParseException {
+        if(dateText.indexOf("T") != -1){
+            dateText = dateText.replace("T"," ");
+        }
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        return sdf.parse(dateText);
+    }
+
+    public Long parseDateTimeTextToLong(String dateText) throws ParseException {
+        if(dateText.indexOf("T") != -1){
+            dateText = dateText.replace("T"," ");
+        }
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Date date = sdf.parse(dateText);
+        return date.getTime();
+    }
+
+    public Long parseDateTextToLong(String dateText) throws ParseException {
+        if(dateText.indexOf("T") != -1){
+            dateText = dateText.replace("T"," ");
+        }
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        Date date = sdf.parse(dateText);
+        return date.getTime();
+    }
+
+    //
+    public Date getTodayDate() throws ParseException {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        return sdf.parse(sdf.format(new Date()));
+    }
+
+    public Date getTodayDatetime() throws ParseException {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        return sdf.parse(sdf.format(new Date()));
+    }
+
+    public String getTodayDateText() throws ParseException {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        return sdf.format(new Date());
+    }
+
+    public java.sql.Date getTodayMySQLDate(){
+        java.sql.Date todayDate = new java.sql.Date(new Date().getTime());
+        return todayDate;
+    }
+
+    public Timestamp getTimestamp(){
+        Timestamp nowTimestamp = new Timestamp(new Date().getTime());
+        return nowTimestamp;
+    }
+
+    public String getTodayText() throws ParseException {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        return sdf.format(new Date());
+    }
+
+    public String formatDateText(Date date) throws ParseException {
+        if(date == null){
+            return "";
+        }
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        return sdf.format(date);
+    }
+
+    public String formatDatetimeText(Date date) throws ParseException {
+        if(date == null || date.toString().length()==0){
+            return "";
+        }
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        return sdf.format(date);
+    }
+
+    public String getNowText() throws ParseException {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
+        return sdf.format(new Date());
+    }
+
+    public String getTodayMissionText() throws ParseException {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
+        return sdf.format(new Date());
+    }
+
+    public String getStartDateInThisMonth(){
+        DateTime date = cn.hutool.core.date.DateUtil.date();
+        return (cn.hutool.core.date.DateUtil.beginOfMonth(date) + "").substring(0, 10);
+    }
+
+    public String getEndDateInThisMonth(){
+        DateTime date = cn.hutool.core.date.DateUtil.date();
+        return (date + "").substring(0, 10);
+    }
+
+    /**
+     * 获取过去或者未来 任意天内的日期数组
+     * @param intervals      intervals天内
+     * @return              日期数组
+     */
+    public ArrayList<String> test(int intervals ) {
+        ArrayList<String> pastDaysList = new ArrayList<>();
+        ArrayList<String> fetureDaysList = new ArrayList<>();
+        for (int i = 0; i <intervals; i++) {
+            pastDaysList.add(getPastDate(i));
+            fetureDaysList.add(getFetureDate(i));
+        }
+        return pastDaysList;
+    }
+
+    /**
+     * @Method      : getPastIntervals
+     * @Description : 返回过去N天日期(倒排序)
+     * @Params      : [intervals]
+     * @Return      : java.util.ArrayList<java.lang.String>
+     * 
+     * @Author      : ZhuoNing
+     * @Date        : 2022/3/7       
+     * @Time        : 15:27
+     */
+    public ArrayList<String> getPastIntervals(int intervals ) {
+        ArrayList<String> pastDaysList = new ArrayList<>();
+        for (int i = 0; i <intervals; i++) {
+            pastDaysList.add(getPastDate(i));
+        }
+        return pastDaysList;
+    }
+
+    /**
+     * @Method      : getPastIntervalsASC
+     * @Description : 正排序
+     * @Params      : [intervals]
+     * @Return      : java.util.ArrayList<java.lang.String>
+     * 
+     * @Author      : ZhuoNing
+     * @Date        : 2022/3/7       
+     * @Time        : 16:33
+     */
+    public ArrayList<String> getPastIntervalsASC(int intervals ) {
+        ArrayList<String> pastDaysList = new ArrayList<>();
+        for (int i = intervals-1; i >=0; i--) {
+            pastDaysList.add(getPastDate(i));
+        }
+        return pastDaysList;
+    }
+
+    /**
+     * @Method      : getFetureIntervals
+     * @Description : 获取未来N天日期
+     * @Params      : [intervals]
+     * @Return      : java.util.ArrayList<java.lang.String>
+     * 
+     * @Author      : ZhuoNing
+     * @Date        : 2022/3/7       
+     * @Time        : 15:28
+     */
+    public ArrayList<String> getFetureIntervals(int intervals ) {
+        ArrayList<String> fetureDaysList = new ArrayList<>();
+        for (int i = 0; i <intervals; i++) {
+            fetureDaysList.add(getFetureDate(i));
+        }
+        return fetureDaysList;
+    }
+
+
+    /**
+     * 获取过去第几天的日期
+     *
+     * @param past
+     * @return
+     */
+    public String getPastDate(int past) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - past);
+        Date today = calendar.getTime();
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+        String result = format.format(today);
+        return result;
+    }
+
+    /**
+     * 获取未来 第 past 天的日期
+     * @param past
+     * @return
+     */
+    public String getFetureDate(int past) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) + past);
+        Date today = calendar.getTime();
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+        String result = format.format(today);
+        return result;
+    }
+
+    //重新构建日期
+    public String rebuildDateTime(String text){
+        return text.substring(0,4)+"-"+text.substring(4,6)+"-"+text.substring(6,8)+" "+text.substring(8,10)+":"+text.substring(10,12)+":"+text.substring(12,14);
+    }
+
+    public static void main(String[] args){
+        DateUtil du = new DateUtil();
+        //
+//        du.test1();
+        List<String> pastList = du.getPastIntervalsASC(5);
+        for(String pastDate:pastList){
+            System.out.println("pastDate>>"+pastDate);
+        }
+
+        List<String> fetureList = du.getFetureIntervals(5);
+        for(String fetureDate:fetureList){
+            System.out.println("fetureDate>>"+fetureDate);
+        }
+
+    }
+
+    private void test1() {
+        String text = "20211201104300";
+//        String text = "1234567890abcd";
+        String date = text.substring(0,4)+"-"+text.substring(4,6)+"-"+text.substring(6,8)+" "+text.substring(8,10)+":"+text.substring(10,12)+":"+text.substring(12,14);
+        System.out.println("date="+date);
+    }
+
+    //获取long时间
+    public Long getNowLong(){
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(calendar.get(Calendar.YEAR),calendar.get(Calendar.MONTH),calendar.get(Calendar.DAY_OF_MONTH)-1,0,0,0);
+        return calendar.getTime().getTime();
+    }
+
+    public String formatTime1(Date datetime) {
+        SimpleDateFormat format = new SimpleDateFormat("MM-dd:HH");
+        String newDatetimeText = format.format(datetime);
+        return newDatetimeText;
+    }
+
+    public Date getFirstDayInThisMonth() {
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+        //获取当前月第一天:
+        Calendar c = Calendar.getInstance();
+        c.add(Calendar.MONTH, 0);
+        c.set(Calendar.DAY_OF_MONTH,1);//设置为1号,当前日期既为本月第一天
+        String first = format.format(c.getTime());
+        System.out.println("===============first:"+first);
+        return c.getTime();
+    }
+
+    public Date getEndDayInThisMonth() {
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+        //获取当前月最后一天
+        Calendar ca = Calendar.getInstance();
+        ca.set(Calendar.DAY_OF_MONTH, ca.getActualMaximum(Calendar.DAY_OF_MONTH));
+        String last = format.format(ca.getTime());
+        System.out.println("===============last:"+last);
+        return ca.getTime();
+    }
+}

+ 123 - 0
huimv-env-common/src/main/java/com/huimv/env/common/utils/MathUtil.java

@@ -0,0 +1,123 @@
+package com.huimv.env.common.utils;
+
+import org.springframework.stereotype.Component;
+
+import java.math.BigDecimal;
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@Component
+public class MathUtil {
+
+    public static double A = 0.00335396319311466;
+    public static double B = 0.000256376549039663;
+    public static double C = 0.00000248933580817244;
+    public static double D = 0.0000000753805242068686;
+    public static double E = -0.0000000204758173596178;
+
+    public static BigDecimal formatScale(String val1,String val2,Integer scale){
+        if(scale == null){
+            scale = 2;
+        }
+        BigDecimal deviceRateBd= new BigDecimal(val1).divide(new BigDecimal(val2),scale,BigDecimal.ROUND_HALF_UP);
+        return deviceRateBd;
+    }
+
+    public static BigDecimal countEnvtemp(String val1,Integer scale){
+        if(scale == null){
+            scale = 2;
+        }
+        BigDecimal deviceRateBd= new BigDecimal(val1).divide(new BigDecimal(100),scale,BigDecimal.ROUND_HALF_UP);
+        return deviceRateBd;
+    }
+
+    public static BigDecimal countEnvtemp2(String val1,Integer scale){
+        if(scale == null){
+            scale = 2;
+        }
+        BigDecimal deviceRateBd= new BigDecimal(val1).divide(new BigDecimal(10),scale,BigDecimal.ROUND_HALF_UP);
+        return deviceRateBd;
+    }
+
+    public static BigDecimal countRate(String val1,Integer scale){
+        if(scale == null){
+            scale = 2;
+        }
+        BigDecimal deviceRateBd= new BigDecimal(val1).divide(new BigDecimal(100),scale,BigDecimal.ROUND_HALF_UP);
+        return deviceRateBd;
+    }
+
+    //保留一位小数
+    public static  double changeDouble(Double dou) {
+        NumberFormat nf = new DecimalFormat("0.0 ");
+        dou = Double.parseDouble(nf.format(dou));
+        return dou;
+    }
+
+    public static double ln(int rv) {
+        int R_REF = 10000;
+        double ln = Math.log((double) rv / R_REF);
+//        System.out.println("$$$$$$$$$ ln>>"+ln);
+        //保留一位小数
+        return changeDouble(1 / (A + B * ln + C * Math.pow(ln, 2) + D * Math.pow(ln, 3) + E * Math.pow(ln, 4)) - 273.15) + 0.001;
+    }
+
+    public String formatBit(float num, int bit) {
+        // 创建一个数值格式化对象
+        NumberFormat numberFormat = NumberFormat.getInstance();
+        // 设置精确到小数点后2位
+        numberFormat.setMaximumFractionDigits(bit);
+        return numberFormat.format(num);
+    }
+
+    public String formatBit(float num) {
+        return String.valueOf(num);
+    }
+
+    //计算比率
+    public String countRate(float num, int bit) {
+        // 创建一个数值格式化对象
+        NumberFormat numberFormat = NumberFormat.getInstance();
+        // 设置精确到小数点后2位
+        numberFormat.setMaximumFractionDigits(bit);
+        return numberFormat.format(num * 100);//所占百分比
+    }
+
+    //计算占比
+    public String countRate(float num, float total,int bit) {
+        // 创建一个数值格式化对象
+        NumberFormat numberFormat = NumberFormat.getInstance();
+        // 设置精确到小数点后2位
+        numberFormat.setMaximumFractionDigits(bit);
+        //所占百分比
+        return numberFormat.format((float)  num/ (float)total* 100);
+    }
+
+    //格式化
+    public String format(float num, int bit) {
+        // 创建一个数值格式化对象
+        NumberFormat numberFormat = NumberFormat.getInstance();
+        // 设置精确到小数点后2位
+        numberFormat.setMaximumFractionDigits(bit);
+        return numberFormat.format(num * 100);//所占百分比
+    }
+
+    //格式化
+    public String format(float num, float total,int bit) {
+        // 创建一个数值格式化对象
+        NumberFormat numberFormat = NumberFormat.getInstance();
+        // 设置精确到小数点后2位
+        numberFormat.setMaximumFractionDigits(bit);
+        //所占百分比
+        return numberFormat.format((float)  num/ (float)total* 100);
+    }
+
+}

+ 30 - 0
huimv-env-common/src/main/java/com/huimv/env/common/utils/MathUtil2.java

@@ -0,0 +1,30 @@
+package com.huimv.env.common.utils;
+
+import org.springframework.stereotype.Component;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@Component
+public class MathUtil2 {
+    //计算温度
+    public double countTemp(int temp){
+        return temp * 0.1;
+    }
+
+    //计算湿度
+    public double countHumi(int temp){
+        return temp * 0.1;
+    }
+
+    //计算温度
+    public double countMeter(int temp){
+        return temp * 0.01;
+    }
+
+}

+ 31 - 0
huimv-env-common/src/main/java/com/huimv/env/common/utils/RegexUtil.java

@@ -0,0 +1,31 @@
+package com.huimv.env.common.utils;
+
+import org.springframework.stereotype.Component;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@Component
+public class RegexUtil {
+
+    //计算+出现的次数
+    public int countPlus(String str) {//创建countSpace方法用于统计文本的空格个数
+        int count = 0;//创建一个返回值count
+//        Pattern p = Pattern.compile("\\s");//将给定的正则表达式编译并赋予给Pattern类
+        Pattern p = Pattern.compile("\\+");//将给定的正则表达式编译并赋予给Pattern类
+        Matcher m = p.matcher(str);//生成一个给定命名的Matcher对象
+        while(m.find()){//查找类似于Matcher对象的字符
+            count++;//count自加作为标记
+        }
+        return count;//返回count值
+    }
+
+}

+ 12 - 0
huimv-env-common/src/main/java/com/huimv/env/common/utils/SMSManager.java

@@ -0,0 +1,12 @@
+package com.huimv.env.common.utils;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+public class SMSManager {
+}

+ 126 - 0
huimv-env-common/src/test/java/com/huimv/env/common/CodeGenerator.java

@@ -0,0 +1,126 @@
+package com.huimv.env.common;
+
+/**
+ * @Project :
+ * @Package :
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create :
+ **/
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.core.exceptions.MybatisPlusException;
+import com.baomidou.mybatisplus.generator.AutoGenerator;
+import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
+import com.baomidou.mybatisplus.generator.config.GlobalConfig;
+import com.baomidou.mybatisplus.generator.config.PackageConfig;
+import com.baomidou.mybatisplus.generator.config.StrategyConfig;
+import com.baomidou.mybatisplus.generator.config.rules.DateType;
+import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
+import org.junit.platform.commons.util.StringUtils;
+
+import java.util.Scanner;
+
+public class CodeGenerator {
+    // user defined
+    private static String childProjectPath = "/huimv-env-common";
+    private static String rootPackage = "com.huimv.env.common";
+    private static String dbIp = "192.168.1.7";
+    private static String dbPort = "3306";
+    private static String dbName = "huimv-env-platform";
+    private static String driverName = "com.mysql.cj.jdbc.Driver";
+    private static String username = "root";
+    private static String password = "hm123456";
+
+    public static String scanner(String tip) {
+        Scanner scanner = new Scanner(System.in);
+        StringBuilder help = new StringBuilder();
+        help.append("请输入" + tip + ":");
+        System.out.println(help.toString());
+        if (scanner.hasNext()) {
+            String ipt = scanner.next();
+            if (StringUtils.isNotBlank(ipt)) {
+                return ipt;
+            }
+        }
+        throw new MybatisPlusException("请输入正确的" + tip + "!");
+    }
+
+    public static void main(String[] args) {
+        // 代码生成器
+        AutoGenerator mpg = new AutoGenerator();
+
+        // 全局配置
+        GlobalConfig gc = new GlobalConfig();
+        String rootPath = System.getProperty("user.dir");
+        System.out.println("rootPath + childProjectPath="+rootPath + childProjectPath);
+        gc.setOutputDir(rootPath + childProjectPath + "/src/main/java");//设置代码生成路径
+        gc.setFileOverride(true);//是否覆盖以前文件
+        gc.setOpen(false);//是否打开生成目录
+        gc.setAuthor("zn");//设置项目作者名称
+        gc.setIdType(IdType.AUTO);//设置主键策略
+        gc.setBaseResultMap(true);//生成基本ResultMap
+        gc.setBaseColumnList(true);//生成基本ColumnList
+        gc.setServiceName("%sService");//去掉服务默认前缀
+        gc.setDateType(DateType.ONLY_DATE);//设置时间类型
+        mpg.setGlobalConfig(gc);
+
+        // 数据源配置
+        DataSourceConfig dsc = new DataSourceConfig();
+        //dsc.setUrl("jdbc:mysql://122.112.224.199:3306/huimv_registration_center?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai");
+        String url = "jdbc:mysql://"+dbIp+":"+dbPort+"/"+dbName+"?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai";
+        System.out.println("url="+url);
+        System.out.println("driverName="+driverName);
+        System.out.println("username="+username);
+        System.out.println("password="+password);
+        dsc.setUrl(url);
+        dsc.setDriverName(driverName);
+        dsc.setUsername(username);
+        dsc.setPassword(password);
+        mpg.setDataSource(dsc);
+
+        // 包配置
+        PackageConfig pc = new PackageConfig();
+        pc.setParent(rootPackage);
+        pc.setMapper("mapper");
+        pc.setXml("mapper.xml");
+//        pc.setEntity("pojo");
+        pc.setEntity("entity");
+        pc.setService("service");
+        pc.setServiceImpl("service.impl");
+        pc.setController("controller");
+        mpg.setPackageInfo(pc);
+
+        // 策略配置
+        StrategyConfig sc = new StrategyConfig();
+        sc.setNaming(NamingStrategy.underline_to_camel);
+        sc.setColumnNaming(NamingStrategy.underline_to_camel);
+        sc.setEntityLombokModel(true);//自动lombok
+        sc.setRestControllerStyle(true);
+        sc.setControllerMappingHyphenStyle(true);
+
+        sc.setLogicDeleteFieldName("deleted");//设置逻辑删除
+
+        //设置自动填充配置
+//        TableFill gmt_create = new TableFill("create_time", FieldFill.INSERT);
+//        TableFill gmt_modified = new TableFill("update_time", FieldFill.INSERT_UPDATE);
+//        ArrayList<TableFill> tableFills=new ArrayList<>();
+//        tableFills.add(gmt_create);
+//        tableFills.add(gmt_modified);
+//        sc.setTableFillList(tableFills);
+
+        //乐观锁
+        sc.setVersionFieldName("version");
+        sc.setRestControllerStyle(true);//驼峰命名
+
+
+
+        //  sc.setTablePrefix("tbl_"); 设置表名前缀
+        sc.setInclude(scanner("表名,多个英文逗号分割").split(","));
+        mpg.setStrategy(sc);
+
+        // 生成代码
+        mpg.execute();
+    }
+
+}

+ 128 - 0
huimv-env-device/pom.xml

@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>huimv-env-platform</artifactId>
+        <groupId>com.huimv</groupId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+<!--    <groupId>com.huimv</groupId>-->
+    <artifactId>huimv-env-device</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+
+    <dependencies>
+        <!-- 排除Tomcat容器 -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+            <!-- 移除掉默认支持的 Tomcat -->
+            <exclusions>
+                <exclusion>
+                    <groupId>org.springframework.boot</groupId>
+                    <artifactId>spring-boot-starter-tomcat</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <!-- 添加 Undertow 容器 -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-undertow</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-websocket</artifactId>
+            <version>2.6.2</version>
+        </dependency>
+<!--        微信推送-->
+        <dependency>
+            <groupId>com.github.binarywang</groupId>
+            <artifactId>weixin-java-miniapp</artifactId>
+            <version>4.1.0</version>
+        </dependency>
+        <!-- JPA -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-jpa</artifactId>
+        </dependency>
+        <!-- mysql -->
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+        </dependency>
+        <!--rabbitmq-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-amqp</artifactId>
+        </dependency>
+        <!-- redis -->
+<!--        <dependency>-->
+<!--            <groupId>org.springframework.boot</groupId>-->
+<!--            <artifactId>spring-boot-starter-data-redis</artifactId>-->
+<!--        </dependency>-->
+        <!-- actuator -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-actuator</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <!-- fastjson -->
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+        </dependency>
+        <!--hutool-->
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+        </dependency>
+        <!-- 一方包统一版本管理 -->
+        <dependency>
+            <groupId>com.huimv</groupId>
+            <artifactId>huimv-env-common</artifactId>
+        </dependency>
+        <!-- 二方包统一版本管理 -->
+        <dependency>
+            <groupId>com.huimv</groupId>
+            <artifactId>huimv-common</artifactId>
+        </dependency>
+<!--        <dependency>-->
+<!--            <groupId>com.huimv</groupId>-->
+<!--            <artifactId>huimv-env-manage</artifactId>-->
+<!--            <version>0.0.1-SNAPSHOT</version>-->
+<!--            <scope>compile</scope>-->
+<!--        </dependency>-->
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-resources-plugin</artifactId>
+                <version>2.6</version>
+            </plugin>
+        </plugins>
+    </build>
+</project>

+ 30 - 0
huimv-env-device/src/main/java/com/huimv/env/device/HuimvDeviceApplication.java

@@ -0,0 +1,30 @@
+package com.huimv.env.device;
+
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.domain.EntityScan;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.ComponentScans;
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@ComponentScans({@ComponentScan("com.huimv.env.common.utils"), @ComponentScan("com.huimv.env.common.service")})
+@EntityScan(value = "com.huimv.env.common.dao.entity")
+@EnableJpaRepositories(basePackages = "com.huimv.env.common.dao.repo")
+@EnableConfigurationProperties
+@SpringBootApplication
+@MapperScan("com.huimv.env.common.mapper")
+public class HuimvDeviceApplication {
+    public static void main(String[] args) {
+        SpringApplication.run(HuimvDeviceApplication.class, args);
+    }
+}

+ 45 - 0
huimv-env-device/src/main/java/com/huimv/env/device/config/ConfigBean.java

@@ -0,0 +1,45 @@
+package com.huimv.env.device.config;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.stereotype.Component;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@ConfigurationProperties(prefix = "config")
+@PropertySource("classpath:conf/config.properties")
+@Component
+public class ConfigBean {
+    private String fault;
+    private String act;
+
+    public String getFault() {
+        return fault;
+    }
+
+    public void setFault(String fault) {
+        this.fault = fault;
+    }
+
+    public String getAct() {
+        return act;
+    }
+
+    public void setAct(String act) {
+        this.act = act;
+    }
+
+    @Override
+    public String toString() {
+        return "ConfigBean{" +
+                "fault='" + fault + '\'' +
+                ", act='" + act + '\'' +
+                '}';
+    }
+}

+ 161 - 0
huimv-env-device/src/main/java/com/huimv/env/device/config/TopicRabbitMQConfig.java

@@ -0,0 +1,161 @@
+package com.huimv.env.device.config;
+
+import com.huimv.env.common.utils.Const;
+import org.springframework.amqp.core.Binding;
+import org.springframework.amqp.core.BindingBuilder;
+import org.springframework.amqp.core.Queue;
+import org.springframework.amqp.core.TopicExchange;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@Configuration
+public class TopicRabbitMQConfig {
+    //温度
+    @Bean
+    public Queue tempQueue() {
+        return new Queue(Const.QUEUE_TEMP);
+    }
+    @Bean
+    TopicExchange tempExchange() {
+        return new TopicExchange(Const.EXCHANGE_TEMP);
+    }
+    @Bean
+    Binding bindingTempExchangeMessage() {
+        return BindingBuilder.bind(tempQueue()).to(tempExchange()).with(Const.ROUTING_KEY_TEMP);
+    }
+
+    //湿度
+    @Bean
+    public Queue humiQueue() {
+        return new Queue(Const.QUEUE_HUMI);
+    }
+    @Bean
+    TopicExchange humiExchange() {
+        return new TopicExchange(Const.EXCHANGE_HUMI);
+    }
+    @Bean
+    Binding bindingHumiExchangeMessage() {
+        return BindingBuilder.bind(humiQueue()).to(humiExchange()).with(Const.ROUTING_KEY_HUMI);
+    }
+
+    //氨气
+    @Bean
+    public Queue ammoniaQueue() {
+        return new Queue(Const.QUEUE_AMMONIA);
+    }
+    @Bean
+    TopicExchange ammoniaExchange() {
+        return new TopicExchange(Const.EXCHANGE_AMMONIA);
+    }
+    @Bean
+    Binding bindingAmmoniaExchangeMessage() {
+        return BindingBuilder.bind(ammoniaQueue()).to(ammoniaExchange()).with(Const.ROUTING_KEY_AMMONIA);
+    }
+
+    //传感器
+    @Bean
+    public Queue sensorQueue() {
+        return new Queue(Const.QUEUE_SENSOR);
+    }
+    @Bean
+    TopicExchange sensorExchange() {
+        return new TopicExchange(Const.EXCHANGE_SENSOR);
+    }
+    @Bean
+    Binding bindingSensorExchangeMessage() {
+        return BindingBuilder.bind(sensorQueue()).to(sensorExchange()).with(Const.ROUTING_KEY_SENSOR);
+    }
+
+    //设备状态
+    @Bean
+    public Queue deviceStatusQueue() {
+        return new Queue(Const.QUEUE_DEVICE_STATUS);
+    }
+    @Bean
+    TopicExchange deviceStatusExchange() {
+        return new TopicExchange(Const.EXCHANGE_DEVICE_STATUS);
+    }
+    @Bean
+    Binding bindingDeviceStatusExchangeMessage() {
+        return BindingBuilder.bind(deviceStatusQueue()).to(deviceStatusExchange()).with(Const.ROUTING_KEY_DEVICE_STATUS);
+    }
+
+    //推送短信
+    @Bean
+    public Queue pushMessageQueue() {
+        return new Queue(Const.QUEUE_PUSH_MESSAGE);
+    }
+    @Bean
+    TopicExchange pushMessageExchange() {
+        return new TopicExchange(Const.EXCHANGE_PUSH_MESSAGE);
+    }
+    @Bean
+    Binding bindingPushMessageMessage() {
+        return BindingBuilder.bind(pushMessageQueue()).to(pushMessageExchange()).with(Const.ROUTING_KEY_PUSH_MESSAGE);
+    }
+
+
+    //推送水压
+    @Bean
+    public Queue waterGegeQueue() {
+        return new Queue(Const.QUEUE_WATER_GEGE);
+    }
+    @Bean
+    TopicExchange waterGegeExchange() {
+        return new TopicExchange(Const.EXCHANGE_WATER_GEGE);
+    }
+    @Bean
+    Binding bindingWaterGegeExchangeMessage() {
+        return BindingBuilder.bind(waterGegeQueue()).to(waterGegeExchange()).with(Const.ROUTING_KEY_WATER_GEGE);
+    }
+    //推送PH
+    @Bean
+    public Queue phGegeQueue() {
+        return new Queue(Const.QUEUE_PH);
+    }
+    @Bean
+    TopicExchange phGegeExchange() {
+        return new TopicExchange(Const.EXCHANGE_PH);
+    }
+    @Bean
+    Binding bindingPhExchangeMessage() {
+        return BindingBuilder.bind(phGegeQueue()).to(phGegeExchange()).with(Const.ROUTING_KEY_PH);
+    }
+
+    //推送水表
+    @Bean
+    public Queue waterMeterQueue() {
+        return new Queue(Const.QUEUE_WATER_METER);
+    }
+    @Bean
+    TopicExchange waterMeterExchange() {
+        return new TopicExchange(Const.EXCHANGE_WATER_METER);
+    }
+    @Bean
+    Binding bindingwaterMeterExchangeMessage() {
+        return BindingBuilder.bind(waterMeterQueue()).to(waterMeterExchange()).with(Const.ROUTING_KEY_WATER_METER);
+    }
+
+
+    //推送电表
+    @Bean
+    public Queue electricityMeterQueue() {
+        return new Queue(Const.QUEUE_ELECTRICITY_METER);
+    }
+    @Bean
+    TopicExchange electricityMeterExchange() {
+        return new TopicExchange(Const.EXCHANGE_ELECTRICITY_METER);
+    }
+    @Bean
+    Binding bindingelectricityMeterExchangeMessage() {
+        return BindingBuilder.bind(electricityMeterQueue()).to(electricityMeterExchange()).with(Const.ROUTING_KEY_ELECTRICITY_METER);
+    }
+}

+ 12 - 0
huimv-env-device/src/main/java/com/huimv/env/device/config/WeChatMessage.java

@@ -0,0 +1,12 @@
+package com.huimv.env.device.config;
+
+
+import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
+import me.chanjar.weixin.common.service.WxService;
+import org.springframework.stereotype.Component;
+
+@Component
+public class WeChatMessage {
+    private static WxService wxService  =  new WxMaServiceImpl();
+
+}

+ 87 - 0
huimv-env-device/src/main/java/com/huimv/env/device/config/WeChatMessageHelperTest.java

@@ -0,0 +1,87 @@
+package com.huimv.env.device.config;
+
+import cn.binarywang.wx.miniapp.api.WxMaService;
+import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
+import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage;
+import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
+import org.springframework.stereotype.Component;
+ 
+import java.util.ArrayList;
+import java.util.logging.Logger;
+
+@Component
+public class WeChatMessageHelperTest {
+ 
+    private static WxMaService wxMaService = new WxMaServiceImpl();
+ 
+    /**
+     * 发送小程序订阅消息
+     * @param appletsSubType 小程序类型(developer为开发版、trial为体验版、formal为正式版)
+     * @param appSubTempId 订阅消息模板id
+     * @param appSubPagePath 跳转小程序地址
+     * @param appletsAppid 小程序appId
+     * @param appletsSecret 小程序secret
+     * @param appletsSubToken 小程序token
+     * @param appletsSubAesKey 小程序EncodingAESKey
+     * @param appletsSubDataFormat 数据格式
+     * @param wxMaSubMsgList 消息列表
+     * @param userIds 接收用户id
+     * @return void
+     * @version V1.0
+     * modify history
+     */
+    public static void sendWechatAppSubMessage(String appletsSubType, String appSubTempId, String appSubPagePath, String appletsAppid, String appletsSecret, String appletsSubToken, String appletsSubAesKey, String appletsSubDataFormat, ArrayList<WxMaSubscribeMessage.MsgData> wxMaSubMsgList, String... userIds) throws Exception {
+ 
+        /*
+        // wxMaSubMsgList组装示例,在业务里组装好,再调用系统消息发送工具,系统消息判断是否需要发送小程序订阅消息进行分发,此处不做展示
+        ArrayList<WxMaSubscribeMessage.MsgData> wxMaSubscribeData = new ArrayList<>();
+        WxMaSubscribeMessage.MsgData characterString1 = new WxMaSubscribeMessage.MsgData();
+        characterString1.setName("character_string1");
+        characterString1.setValue("DR15325419846198615651");
+        wxMaSubscribeData.add(characterString1);
+        WxMaSubscribeMessage.MsgData thing3 = new WxMaSubscribeMessage.MsgData();
+        thing3.setName("thing3");
+        thing3.setValue("请XXXXXXXX");
+        wxMaSubscribeData.add(thing3);
+        WxMaSubscribeMessage.MsgData time5 = new WxMaSubscribeMessage.MsgData();
+        time5.setName("time5");
+        time5.setValue(DateUtil.format(new Date(),DateUtil.DATE_TIME_FORMAT));
+        wxMaSubscribeData.add(time5);
+        */
+ 
+        WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
+        // 小程序appId
+        config.setAppid(appletsAppid);
+        // 小程序secret
+        config.setSecret(appletsSecret);
+        // 小程序token
+        config.setToken(appletsSubToken);
+        // 小程序EncodingAESKey
+        config.setAesKey(appletsSubAesKey);
+        // 数据格式
+        config.setMsgDataFormat(appletsSubDataFormat);
+        wxMaService.setWxMaConfig(config);
+ 
+        for (String userId : userIds) {
+            // TODO:根据用户id获取OpenId,测试时写死
+            WxMaSubscribeMessage subscribeMessage = new WxMaSubscribeMessage();
+            // 要推送的用户openid
+            subscribeMessage.setToUser("openId");
+            // 小程序类型(developer为开发版、trial为体验版、formal为正式版),默认为formal(正式版)
+            subscribeMessage.setMiniprogramState(appletsSubType);
+            // 订阅消息模板id
+            subscribeMessage.setTemplateId(appSubTempId);
+            // 跳转小程序地址
+            subscribeMessage.setPage(appSubPagePath);
+            // 消息列表(组装示例请看方法开始注释部分)
+            subscribeMessage.setData(wxMaSubMsgList);
+ 
+            try {
+                // 发送订阅消息
+                wxMaService.getMsgService().sendSubscribeMsg(subscribeMessage);
+            } catch (Exception e) {
+                System.out.println("微信小程序订阅消息推送失败,接收userId: " + userId+"      "+ e);
+            }
+        }
+    }
+}

+ 175 - 0
huimv-env-device/src/main/java/com/huimv/env/device/config/WebSocket.java

@@ -0,0 +1,175 @@
+package com.huimv.env.device.config;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+import javax.websocket.*;
+import javax.websocket.server.PathParam;
+import javax.websocket.server.ServerEndpoint;
+import java.io.IOException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.concurrent.ConcurrentHashMap;
+
+//注册成组件
+@Component
+//定义websocket服务器端,它的功能主要是将目前的类定义成一个websocket服务器端。注解的值将被用于监听用户连接的终端访问URL地址
+@Slf4j
+@ServerEndpoint("/websocket/{farmCode}")
+public class WebSocket {
+    //静态变量,用来记录当前在线连接数。应该把它设计成线程安全的。
+    private static int onlineCount = 0;
+    //concurrent包的线程安全Set,用来存放每个客户端对应的MyWebSocket对象。若要实现服务端与单一客户端通信的话,可以使用Map来存放,其中Key可以为用户标识
+    private static ConcurrentHashMap<String, WebSocket> webSocketSet = new ConcurrentHashMap<String, WebSocket>();
+    //与某个客户端的连接会话,需要通过它来给客户端发送数据
+    private Session WebSocketsession;
+    //当前发消息的人员编号
+    private String farmCode = "";
+
+
+
+    @OnOpen
+    public void onOpen(@PathParam(value = "farmCode") String param, Session WebSocketsession, EndpointConfig config) {
+        System.out.println(param);
+        farmCode = param;//接收到发送消息的人员编号
+        this.WebSocketsession = WebSocketsession;
+        webSocketSet.put(param, this);//加入map中
+        addOnlineCount();           //在线数加1
+        System.out.println("有新连接加入!当前在线人数为" + getOnlineCount());
+    }
+
+
+    /**
+     * 连接关闭调用的方法
+     */
+    @OnClose
+    public void onClose() {
+        if (!farmCode.equals("")) {
+            webSocketSet.remove(farmCode);  //从set中删除
+            subOnlineCount();           //在线数减1
+            System.out.println("有一连接关闭!当前在线人数为" + getOnlineCount());
+        }
+    }
+
+
+    /**
+     * 收到客户端消息后调用的方法
+     *
+     * @param message 客户端发送过来的消息
+     * @param session 可选的参数
+     */
+    @SuppressWarnings("unused")
+//	@OnMessage
+    public void onMessage(String message, Session session) {
+        System.out.println("来自客户端的消息:" + message);
+//        session.get
+        //群发消息
+        if (1 < 2) {
+            sendAll(message);
+        } else {
+            //给指定的人发消息
+            sendToUser(message);
+        }
+    }
+
+
+    /**
+     * 给指定的人发送消息
+     * @param message
+     */
+    @OnMessage
+    public void sendToUser(String message) {
+        String sendfarmCode = message.split(",")[1];
+        String sendMessage = message.split(",")[0];
+        String now = getNowTime();
+        try {
+            if (webSocketSet.get(sendfarmCode) != null) {
+                webSocketSet.get(sendfarmCode).sendMessage(now + "用户" + farmCode + "发来消息:" + " <br/> " + sendMessage);
+            } else {
+                System.out.println("当前用户不在线");
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+
+    /**
+     * 给所有人发消息
+     * @param message
+     */
+    private void sendAll(String message) {
+        String now = getNowTime();
+        String sendMessage = message.split("[|]")[0];
+        //遍历HashMap
+        for (String key : webSocketSet.keySet()) {
+            try {
+                //判断接收用户是否是当前发消息的用户
+                if (!farmCode.equals(key)) {
+                    webSocketSet.get(key).sendMessage(now + "用户" + farmCode + "发来消息:" + " <br/> " + sendMessage);
+                    System.out.println("key = " + key);
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+
+
+
+    /**
+     * 获取当前时间
+     *
+     * @return
+     */
+    private String getNowTime() {
+        Date date = new Date();
+        DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String time = format.format(date);
+        return time;
+    }
+    /**
+     * 发生错误时调用
+     *
+     * @param session
+     * @param error
+     */
+    @OnError
+    public void onError(Session session, Throwable error) {
+        System.out.println("发生错误");
+        error.printStackTrace();
+    }
+
+
+    /**
+     * 这个方法与上面几个方法不一样。没有用注解,是根据自己需要添加的方法。
+     *
+     * @param message
+     * @throws IOException
+     */
+    public void sendMessage(String message) throws IOException {
+        this.WebSocketsession.getBasicRemote().sendText(message);
+        //this.session.getAsyncRemote().sendText(message);
+    }
+
+
+    public static synchronized int getOnlineCount() {
+        return onlineCount;
+    }
+
+
+    public static synchronized void addOnlineCount() {
+        WebSocket.onlineCount++;
+    }
+
+
+    public static synchronized void subOnlineCount() {
+        WebSocket.onlineCount--;
+    }
+
+
+
+
+}

+ 19 - 0
huimv-env-device/src/main/java/com/huimv/env/device/config/WebSocketConfig.java

@@ -0,0 +1,19 @@
+package com.huimv.env.device.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.socket.server.standard.ServerEndpointExporter;
+
+/**
+ * websocket
+ * 的配置信息
+ */
+@Configuration
+public class WebSocketConfig {
+
+    @Bean
+    public ServerEndpointExporter serverEndpointExporter() {
+
+        return new ServerEndpointExporter();
+    }
+}

+ 338 - 0
huimv-env-device/src/main/java/com/huimv/env/device/listener/DeviceListener.java

@@ -0,0 +1,338 @@
+package com.huimv.env.device.listener;
+
+import com.alibaba.fastjson.JSONObject;
+import com.huimv.env.common.dao.entity.EnvAmmoniaEntity;
+import com.huimv.env.common.dao.entity.EnvDeviceRegisterEntity;
+import com.huimv.env.common.dao.entity.EnvHumiEntity;
+import com.huimv.env.common.dao.entity.EnvTempEntity;
+import com.huimv.env.common.dao.repo.EnvAmmoniaEntityRepo;
+import com.huimv.env.common.dao.repo.EnvHumiEntityRepo;
+import com.huimv.env.common.dao.repo.EnvTempEntityRepo;
+import com.huimv.env.common.entity.BaseThreshold;
+import com.huimv.env.common.service.*;
+import com.huimv.env.common.utils.Const;
+import com.huimv.env.common.utils.DateUtil;
+import com.huimv.env.common.utils.MathUtil;
+import com.huimv.env.common.utils.MathUtil2;
+import com.huimv.env.device.config.WeChatMessageHelperTest;
+import com.huimv.env.device.config.WebSocket;
+import com.huimv.env.device.producer.Producer;
+import com.huimv.env.device.service.ICommandParserService;
+import com.huimv.env.device.service.IDeviceService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.amqp.rabbit.annotation.RabbitHandler;
+import org.springframework.amqp.rabbit.annotation.RabbitListener;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.sql.Date;
+import java.sql.Timestamp;
+import java.text.ParseException;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@Component
+@Slf4j
+public class DeviceListener {
+    @Autowired
+    private IDeviceRegisterService deviceRegisterService;
+    @Autowired
+    private IDeviceService deviceService;
+    @Autowired
+    private MathUtil2 mathUtil;
+    @Autowired
+    private ICommandParserService cmdParserService;
+    @Autowired
+    private IPushMessageService pushMessageService;
+    @Autowired
+    private ISprayStatusService sprayStatusService;
+    @Autowired
+    private IEnvPushMessageService envPushMessageService;
+
+
+    @Autowired
+    private WebSocket webSocket;
+
+    @RabbitListener(queues = Const.QUEUE_ELECTRICITY_METER)
+    @RabbitHandler
+    public void processElectricityMeter(Map RawMap)   {
+        System.out.println(">>>>>>>>>>>>>> 222222222222222222 接收电表数据 RawMap>>" + RawMap.toString());
+        String askText = RawMap.get("askText").toString();
+        JSONObject dataJo = deviceService.handleAskText(askText);
+        dataJo.put("dataUnit", "");
+        System.out.println("电表数据=" + dataJo);
+        java.sql.Date todayDate = new java.sql.Date(new java.util.Date().getTime());
+        Timestamp nowTimestamp = new Timestamp(new java.util.Date().getTime());
+        String deviceCode = dataJo.getString("deviceCode");
+        //根据设备编码获取设备注册信息
+        EnvDeviceRegisterEntity envDeviceRegisterEntity = deviceRegisterService.getDeviceRegisterByDeviceCode(deviceCode);
+        if (envDeviceRegisterEntity == null) {
+            log.error("该设备[" + dataJo.getString("deviceCode") + "]未注册.");
+            return;
+        }
+        String farmCode = envDeviceRegisterEntity.getFarmCode();
+        String electricityMeter =  new BigDecimal(mathUtil.countMeter(dataJo.getIntValue("value"))).setScale(1, RoundingMode.UP)+dataJo.getString("dataUnit");;
+        int sensorSort = 1;
+        //更新传感器数据
+//        deviceService.updateSensorRegister(deviceCode, dataJo.getInteger("sensorSn"), nowTimestamp, todayDate, temp, farmCode,sensorSort);
+        deviceService.sendSensorToMQ(deviceCode, dataJo.getInteger("sensorSn"), nowTimestamp, todayDate, electricityMeter, farmCode,sensorSort);
+
+        //保存实时电表流水数据
+        deviceService.saveElectricityMeter(dataJo, envDeviceRegisterEntity, nowTimestamp, todayDate, farmCode);
+
+        //保存每天用电量数据
+        deviceService.saveDayElectricityConsumption(dataJo,envDeviceRegisterEntity, nowTimestamp, todayDate, farmCode);
+
+        //保存每月用电量数据
+        deviceService.saveMonthElectricityConsumption(dataJo,envDeviceRegisterEntity, nowTimestamp, todayDate, farmCode);
+    }
+
+
+    @RabbitListener(queues = Const.QUEUE_WATER_METER)
+    @RabbitHandler
+    public void processWaterMeterGege(Map RawMap) throws ParseException {
+        System.out.println(" 接收水表数据 RawMap>>" + RawMap.toString());
+        String askText = RawMap.get("askText").toString();
+        JSONObject dataJo = deviceService.handleAskText(askText);
+        dataJo.put("dataUnit", "");
+        System.out.println("水表数据=" + dataJo);
+        java.sql.Date todayDate = new java.sql.Date(new java.util.Date().getTime());
+        Timestamp nowTimestamp = new Timestamp(new java.util.Date().getTime());
+        String deviceCode = dataJo.getString("deviceCode");
+        //根据设备编码获取设备注册信息
+        EnvDeviceRegisterEntity envDeviceRegisterEntity = deviceRegisterService.getDeviceRegisterByDeviceCode(deviceCode);
+        if (envDeviceRegisterEntity == null) {
+            log.error("该设备[" + dataJo.getString("deviceCode") + "]未注册.");
+            return;
+        }
+        DateUtil dateUtil = new DateUtil();
+        String farmCode = envDeviceRegisterEntity.getFarmCode();
+        String waterMeter =  new BigDecimal(mathUtil.countMeter(dataJo.getIntValue("value"))).setScale(1, RoundingMode.UP)+dataJo.getString("dataUnit");;
+        int sensorSort = 1;
+         //
+        //保存水表流水数据
+        deviceService.saveWaterMeter(dataJo, envDeviceRegisterEntity, nowTimestamp, todayDate, farmCode);
+
+        //保存每天用水量数据
+        deviceService.saveDayWaterConsumption(dataJo,envDeviceRegisterEntity, nowTimestamp, todayDate, farmCode);
+
+        //保存每月用水量数据
+        deviceService.saveMonthWaterConsumption(dataJo,envDeviceRegisterEntity, nowTimestamp, todayDate, farmCode);
+
+        //更新传感器数据
+//        deviceService.updateSensorRegister(deviceCode, dataJo.getInteger("sensorSn"), nowTimestamp, todayDate, temp, farmCode,sensorSort);
+        deviceService.sendSensorToMQ(deviceCode, dataJo.getInteger("sensorSn"), nowTimestamp, todayDate, waterMeter, farmCode,sensorSort);
+
+    }
+    
+    @RabbitListener(queues = Const.QUEUE_PH)
+    @RabbitHandler
+    public void processPhGege(Map RawMap)   {
+        System.out.println(">>>>>>>>>>>>>>接收PH数据 RawMap>>" + RawMap.toString());
+        String askText = RawMap.get("askText").toString();
+        JSONObject dataJo = deviceService.handleAskText(askText);
+        dataJo.put("dataUnit", "");
+        System.out.println("PH数据=" + dataJo);
+        java.sql.Date todayDate = new java.sql.Date(new java.util.Date().getTime());
+        Timestamp nowTimestamp = new Timestamp(new java.util.Date().getTime());
+        String deviceCode = dataJo.getString("deviceCode");
+        //根据设备编码获取设备注册信息
+        EnvDeviceRegisterEntity envDeviceRegisterEntity = deviceRegisterService.getDeviceRegisterByDeviceCode(deviceCode);
+        if (envDeviceRegisterEntity == null) {
+            log.error("该设备[" + dataJo.getString("deviceCode") + "]未注册.");
+            return;
+        }
+        String farmCode = envDeviceRegisterEntity.getFarmCode();
+        String PH = new BigDecimal(mathUtil.countMeter(dataJo.getIntValue("value"))).setScale(1, RoundingMode.UP)+dataJo.getString("dataUnit");
+
+        int sensorSort = 1;
+        //更新传感器数据
+//        deviceService.updateSensorRegister(deviceCode, dataJo.getInteger("sensorSn"), nowTimestamp, todayDate, temp, farmCode,sensorSort);
+        deviceService.sendSensorToMQ(deviceCode, dataJo.getInteger("sensorSn"), nowTimestamp, todayDate, PH, farmCode,sensorSort);
+
+        //保存PH流水数据
+        deviceService.savePH(dataJo, envDeviceRegisterEntity, nowTimestamp, todayDate, farmCode);
+    }
+
+
+    @RabbitListener(queues = Const.QUEUE_WATER_GEGE)
+    @RabbitHandler
+    public void processWaterGege(Map RawMap)   {
+        System.out.println(">>>>>>>>>>>>>>接收水压数据 RawMap>>" + RawMap.toString());
+        String askText = RawMap.get("askText").toString();
+        JSONObject dataJo = deviceService.handleAskText(askText);
+        dataJo.put("dataUnit", "Kpa");
+        System.out.println("水压数据=" + dataJo);
+        java.sql.Date todayDate = new java.sql.Date(new java.util.Date().getTime());
+        Timestamp nowTimestamp = new Timestamp(new java.util.Date().getTime());
+        String deviceCode = dataJo.getString("deviceCode");
+        //根据设备编码获取设备注册信息
+        EnvDeviceRegisterEntity envDeviceRegisterEntity = deviceRegisterService.getDeviceRegisterByDeviceCode(deviceCode);
+        if (envDeviceRegisterEntity == null) {
+            log.error("该设备[" + dataJo.getString("deviceCode") + "]未注册.");
+            return;
+        }
+        String farmCode = envDeviceRegisterEntity.getFarmCode();
+       String watreGege = dataJo.getString("value");
+        int sensorSort = 1;
+        //更新传感器数据
+//        deviceService.updateSensorRegister(deviceCode, dataJo.getInteger("sensorSn"), nowTimestamp, todayDate, temp, farmCode,sensorSort);
+        deviceService.sendSensorToMQ(deviceCode, dataJo.getInteger("sensorSn"), nowTimestamp, todayDate, watreGege, farmCode,sensorSort);
+
+        //保存水压流水数据
+        deviceService.saveWaterGege(dataJo, envDeviceRegisterEntity, nowTimestamp, todayDate, farmCode);
+    }
+
+
+    @RabbitListener(queues = Const.QUEUE_TEMP)
+    @RabbitHandler
+    public void processTemp(Map RawMap) throws ParseException {
+        System.out.println(">>>>>>>>>>>>>>接收温度数据 RawMap>>" + RawMap.toString());
+        String askText = RawMap.get("askText").toString();
+        JSONObject dataJo = deviceService.handleAskText(askText);
+        dataJo.put("dataUnit", "°");
+        System.out.println("温度数据=" + dataJo);
+        java.sql.Date todayDate = new java.sql.Date(new java.util.Date().getTime());
+        Timestamp nowTimestamp = new Timestamp(new java.util.Date().getTime());
+        String deviceCode = dataJo.getString("deviceCode");
+        //根据设备编码获取设备注册信息
+        EnvDeviceRegisterEntity envDeviceRegisterEntity = deviceRegisterService.getDeviceRegisterByDeviceCode(deviceCode);
+        if (envDeviceRegisterEntity == null) {
+            log.error("该设备[" + dataJo.getString("deviceCode") + "]未注册.");
+            return;
+        }
+        String farmCode = envDeviceRegisterEntity.getFarmCode();
+        String temp = new BigDecimal(mathUtil.countTemp(dataJo.getIntValue("value"))).setScale(1, RoundingMode.UP) + dataJo.getString("dataUnit");
+        int sensorSort = 1;
+        //更新传感器数据
+//        deviceService.updateSensorRegister(deviceCode, dataJo.getInteger("sensorSn"), nowTimestamp, todayDate, temp, farmCode,sensorSort);
+        deviceService.sendSensorToMQ(deviceCode, dataJo.getInteger("sensorSn"), nowTimestamp, todayDate, temp, farmCode,sensorSort);
+        //报警 TODO
+//        envPushMessageService.saveTemp();
+        //保存温度流水数据
+        deviceService.saveTempFlow(dataJo, envDeviceRegisterEntity, nowTimestamp, todayDate, farmCode);
+    }
+
+    @RabbitListener(queues = Const.QUEUE_HUMI)
+    @RabbitHandler
+    public void processHumi(Map RawMap) throws ParseException {
+        System.out.println(">>>>>>>>>>>>>>接收湿度数据 RawMap>>" + RawMap.toString());
+        String askText = RawMap.get("askText").toString();
+        JSONObject dataJo = deviceService.handleAskText(askText);
+        dataJo.put("dataUnit", "%");
+        System.out.println("湿度数据=" + dataJo);
+        String todayDateText = new DateUtil().getTodayDateText();
+        java.sql.Date todayDate = new java.sql.Date(new java.util.Date().getTime());
+        Timestamp nowTimestamp = new Timestamp(new java.util.Date().getTime());
+        String deviceCode = dataJo.getString("deviceCode");
+        //根据设备编码获取设备注册信息
+        EnvDeviceRegisterEntity envDeviceRegisterEntity = deviceRegisterService.getDeviceRegisterByDeviceCode(deviceCode);
+        if (envDeviceRegisterEntity == null) {
+            log.error("该设备[" + dataJo.getString("deviceCode") + "]未注册.");
+            return;
+        }
+        String farmCode = envDeviceRegisterEntity.getFarmCode();
+        String humi = new BigDecimal(mathUtil.countTemp(dataJo.getIntValue("value"))).setScale(1, RoundingMode.UP) + dataJo.getString("dataUnit");
+        int sensorSort = 2;
+        //更新传感器数据
+//        deviceService.updateSensorRegister(deviceCode, dataJo.getInteger("sensorSn"), nowTimestamp, todayDate, humi, farmCode, sensorSort);
+        deviceService.sendSensorToMQ(deviceCode, dataJo.getInteger("sensorSn"), nowTimestamp, todayDate, humi, farmCode, sensorSort);
+        //保存湿度流水数据
+        deviceService.saveHumiFlow(dataJo, envDeviceRegisterEntity, nowTimestamp, todayDate, farmCode);
+        envPushMessageService.saveHumi(deviceCode,nowTimestamp,dataJo,farmCode);
+    }
+
+    @RabbitListener(queues = Const.QUEUE_AMMONIA)
+    @RabbitHandler
+    public void processAmmonia(Map RawMap) throws ParseException {
+        System.out.println(">>>>>>>>>>>>>>接收氨气数据 RawMap>>" + RawMap.toString());
+        String askText = RawMap.get("askText").toString();
+        JSONObject dataJo = deviceService.handleAskText(askText);
+        dataJo.put("dataUnit", "ppm");
+        System.out.println("氨气数据=" + dataJo);
+        String todayDateText = new DateUtil().getTodayDateText();
+        java.sql.Date todayDate = new java.sql.Date(new java.util.Date().getTime());
+        Timestamp nowTimestamp = new Timestamp(new java.util.Date().getTime());
+        String deviceCode = dataJo.getString("deviceCode");
+        //读取设备注册信息
+        EnvDeviceRegisterEntity envDeviceRegisterEntity = deviceRegisterService.getDeviceRegisterByDeviceCode(deviceCode);
+        if(envDeviceRegisterEntity == null){
+            log.error("该设备[" + deviceCode + "]未注册.");
+            return;
+        }
+        String farmCode = envDeviceRegisterEntity.getFarmCode();
+        String anmonia = dataJo.getString("value") + dataJo.getString("dataUnit");
+        int sensorSort = 3;
+        //更新传感器数据
+//        deviceService.updateSensorRegister(deviceCode, dataJo.getInteger("sensorSn"), nowTimestamp, todayDate, anmonia, farmCode, sensorSort);
+        deviceService.sendSensorToMQ(deviceCode, dataJo.getInteger("sensorSn"), nowTimestamp, todayDate, anmonia, farmCode, sensorSort);
+        //保存氨气流水数据
+        deviceService.saveAmmoniaFlow(dataJo, envDeviceRegisterEntity, nowTimestamp, todayDate, farmCode);
+    }
+
+    @RabbitListener(queues = Const.QUEUE_DEVICE_STATUS)
+    @RabbitHandler
+    public void processSprayStatus(Map RawMap) throws ParseException {
+        System.out.println(">>>>>>>>>>>>>>接收设备状态数据 RawMap>>" + RawMap.toString());
+        String askText = RawMap.get("askText").toString();
+        JSONObject dataJo = deviceService.handleSprayStatusAskCmd(askText);
+        String deviceCode = dataJo.getString("deviceCode");
+        //读取设备注册信息
+        EnvDeviceRegisterEntity envDeviceRegisterEntity = deviceRegisterService.getDeviceRegisterByDeviceCode(deviceCode);
+        if(envDeviceRegisterEntity == null){
+            log.error("该设备[" + deviceCode + "]未注册.");
+            return;
+        }
+        java.sql.Date todayDate = new java.sql.Date(new java.util.Date().getTime());
+        Timestamp nowTimestamp = new Timestamp(new java.util.Date().getTime());
+        String farmCode = envDeviceRegisterEntity.getFarmCode();
+        //{保存喷雾状态流水}
+        sprayStatusService.saveSprayStatusFlow(dataJo,envDeviceRegisterEntity,nowTimestamp,todayDate,farmCode);
+
+    }
+
+
+    @RabbitListener(queues = Const.QUEUE_PUSH_MESSAGE)
+    @RabbitHandler
+    public void processPushMessage(Map RawMap) throws ParseException {
+        System.out.println(">>>>>>>>>>>>>>接收平台推送消息 RawMap>>" + RawMap.toString());
+        String askText = RawMap.get("askText").toString();
+        JSONObject dataJo = cmdParserService.handlePushMessageCmd(askText);
+        String deviceCode = dataJo.getString("deviceCode");
+        //读取设备注册信息
+        EnvDeviceRegisterEntity envDeviceRegisterEntity = deviceRegisterService.getDeviceRegisterByDeviceCode(deviceCode);
+        if(envDeviceRegisterEntity == null){
+            log.error("该设备[" + deviceCode + "]未注册.");
+            return;
+        }
+        java.sql.Date todayDate = new java.sql.Date(new java.util.Date().getTime());
+        Timestamp nowTimestamp = new Timestamp(new java.util.Date().getTime());
+        String farmCode = envDeviceRegisterEntity.getFarmCode();
+        //webSocket 推送
+        webSocket.sendToUser("true,"+farmCode);
+        //微信推送
+//        WeChatMessageHelperTest.sendWechatAppSubMessage();
+
+
+        //{}
+        String messageContent = deviceService.getMessageContent(dataJo,envDeviceRegisterEntity);
+        //{保存消息推送流水}
+        pushMessageService.savePushMessageFlow(dataJo,messageContent,nowTimestamp,todayDate,farmCode);
+    }
+
+
+
+
+}

+ 52 - 0
huimv-env-device/src/main/java/com/huimv/env/device/listener/SensorListener.java

@@ -0,0 +1,52 @@
+package com.huimv.env.device.listener;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.huimv.env.common.service.ISensorRegisterService;
+import com.huimv.env.common.utils.Const;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.amqp.rabbit.annotation.RabbitHandler;
+import org.springframework.amqp.rabbit.annotation.RabbitListener;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.sql.Timestamp;
+import java.text.ParseException;
+import java.util.Date;
+import java.util.Map;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@Component
+@Slf4j
+public class SensorListener {
+    @Autowired
+    private ISensorRegisterService sensorRegisterService;
+
+    @RabbitListener(queues = Const.QUEUE_SENSOR)
+    @RabbitHandler
+    public void processTemp(Map RawMap) throws ParseException {
+        System.out.println(">>>>>>接收传感器数据 RawMap>>" + RawMap.toString());
+        JSONObject sensorJo = JSON.parseObject(RawMap.get("sensor").toString());
+        String deviceCode = sensorJo.getString("deviceCode");
+        int sensorSn = sensorJo.getInteger("sensorSn");
+        int sensorSort = sensorJo.getInteger("sensorSort");
+        String farmCode = sensorJo.getString("farmCode");
+        Timestamp nowTimestamp = sensorJo.getTimestamp("timestamp");
+        java.sql.Date todayDate = new java.sql.Date(sensorJo.getDate("todayDate").getTime());
+        String value = sensorJo.getString("value");
+        if (sensorRegisterService.isExistSensorRegister(deviceCode, sensorSn, farmCode,sensorSort)) {
+            //{更新传感器注册信息}
+            sensorRegisterService.updateSensorRegister(deviceCode, sensorSn, nowTimestamp, todayDate, value, farmCode,sensorSort);
+        } else {
+            //{保存传感器注册信息}
+            sensorRegisterService.saveSensorRegister(deviceCode, sensorSn, nowTimestamp, todayDate, value, farmCode,sensorSort);
+        }
+    }
+}

+ 45 - 0
huimv-env-device/src/main/java/com/huimv/env/device/producer/Producer.java

@@ -0,0 +1,45 @@
+package com.huimv.env.device.producer;
+
+import com.alibaba.fastjson.JSONObject;
+import com.huimv.env.common.utils.Const;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@Component
+@Slf4j
+public class Producer {
+    @Autowired
+    RabbitTemplate rabbitTemplate;  //使用RabbitTemplate,这提供了接收/发送等等方法
+
+    /**
+     * @Method      : sendTempAskToMQ
+     * @Description : 
+     * @Params      : [askText]
+     * @Return      : java.lang.String
+     * 
+     * @Author      : ZhuoNing
+     * @Date        : 2022/8/17       
+     * @Time        : 19:29
+     */
+    public String sendSensorAskToMQ(JSONObject sensorJo){
+        Map map = new HashMap();
+        map.put("sensor",sensorJo);
+        rabbitTemplate.convertAndSend(Const.EXCHANGE_SENSOR, Const.ROUTING_KEY_SENSOR, map);
+        return "ok";
+    }
+
+
+}

+ 8 - 0
huimv-env-device/src/main/java/com/huimv/env/device/service/ICommandParserService.java

@@ -0,0 +1,8 @@
+package com.huimv.env.device.service;
+
+import com.alibaba.fastjson.JSONObject;
+
+public interface ICommandParserService {
+    //
+    JSONObject handlePushMessageCmd(String askText);
+}

+ 46 - 0
huimv-env-device/src/main/java/com/huimv/env/device/service/IDeviceService.java

@@ -0,0 +1,46 @@
+package com.huimv.env.device.service;
+
+import com.alibaba.fastjson.JSONObject;
+import com.huimv.env.common.dao.entity.EnvDeviceRegisterEntity;
+
+import java.sql.Date;
+import java.sql.Timestamp;
+import java.text.ParseException;
+
+public interface IDeviceService {
+    void sendSensorToMQ(String deviceCode, Integer sensorSn, Timestamp nowTimestamp, Date todayDate, String value, String farmCode, int sensorSort);
+
+    //保存温度流水数据
+    void saveTempFlow(JSONObject dataJo, EnvDeviceRegisterEntity envDeviceRegisterEntity, Timestamp nowTimestamp, Date todayDate, String farmCode);
+
+    //保存湿度流水数据
+    void saveHumiFlow(JSONObject dataJo, EnvDeviceRegisterEntity envDeviceRegisterEntity, Timestamp nowTimestamp, Date todayDate, String farmCode);
+
+    //保存氨气流水数据
+    void saveAmmoniaFlow(JSONObject dataJo, EnvDeviceRegisterEntity envDeviceRegisterEntity, Timestamp nowTimestamp, Date todayDate, String farmCode);
+
+    //
+    JSONObject handleAskText(String askText);
+
+    //
+    String getMessageContent(JSONObject dataJo, EnvDeviceRegisterEntity envDeviceRegisterEntity);
+
+    //
+    JSONObject handleSprayStatusAskCmd(String askText);
+
+    void saveWaterGege(JSONObject dataJo, EnvDeviceRegisterEntity envDeviceRegisterEntity, Timestamp nowTimestamp, Date todayDate, String farmCode);
+
+    void savePH(JSONObject dataJo, EnvDeviceRegisterEntity envDeviceRegisterEntity, Timestamp nowTimestamp, Date todayDate, String farmCode);
+
+    void saveWaterMeter(JSONObject dataJo, EnvDeviceRegisterEntity envDeviceRegisterEntity, Timestamp nowTimestamp, Date todayDate, String farmCode);
+
+    void saveElectricityMeter(JSONObject dataJo, EnvDeviceRegisterEntity envDeviceRegisterEntity, Timestamp nowTimestamp, Date todayDate, String farmCode);
+
+    void saveDayElectricityConsumption(JSONObject dataJo, EnvDeviceRegisterEntity envDeviceRegisterEntity, Timestamp nowTimestamp, Date todayDate, String farmCode);
+//
+    void saveMonthElectricityConsumption(JSONObject dataJo, EnvDeviceRegisterEntity envDeviceRegisterEntity, Timestamp nowTimestamp, Date todayDate, String farmCode);
+
+    void saveDayWaterConsumption(JSONObject dataJo, EnvDeviceRegisterEntity envDeviceRegisterEntity, Timestamp nowTimestamp, Date todayDate, String farmCode) throws ParseException;
+
+    void saveMonthWaterConsumption(JSONObject dataJo, EnvDeviceRegisterEntity envDeviceRegisterEntity, Timestamp nowTimestamp, Date todayDate, String farmCode);
+}

+ 29 - 0
huimv-env-device/src/main/java/com/huimv/env/device/service/impl/CommandParserServiceImpl.java

@@ -0,0 +1,29 @@
+package com.huimv.env.device.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.huimv.env.device.service.ICommandParserService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@Service
+public class CommandParserServiceImpl implements ICommandParserService {
+
+    @Override
+    public JSONObject handlePushMessageCmd(String askText) {
+        String[] dataArray = askText.split("\\+");
+        JSONObject dataJo = new JSONObject();
+        dataJo.put("deviceCode", dataArray[1]);
+        dataJo.put("cmd", dataArray[2]);
+        dataJo.put("faultSn", dataArray[3]);
+        dataJo.put("actType", dataArray[4]);
+        dataJo.put("askTime", dataArray[5]);
+        return dataJo;
+    }
+}

+ 477 - 0
huimv-env-device/src/main/java/com/huimv/env/device/service/impl/DeviceServiceImpl.java

@@ -0,0 +1,477 @@
+package com.huimv.env.device.service.impl;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.alibaba.fastjson.JSONObject;
+import com.huimv.env.common.dao.entity.*;
+import com.huimv.env.common.dao.repo.*;
+import com.huimv.env.common.entity.EnvElectricityDay;
+import com.huimv.env.common.entity.EnvElectricityMonth;
+import com.huimv.env.common.entity.EnvWaterDay;
+import com.huimv.env.common.entity.EnvWaterMonth;
+import com.huimv.env.common.service.*;
+import com.huimv.env.common.utils.DateUtil;
+import com.huimv.env.common.utils.MathUtil;
+import com.huimv.env.common.utils.MathUtil2;
+import com.huimv.env.device.config.ConfigBean;
+import com.huimv.env.device.producer.Producer;
+import com.huimv.env.device.service.IDeviceService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.web.client.RestTemplate;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.sql.Date;
+import java.sql.Timestamp;
+import java.text.ParseException;
+import java.util.List;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@Service
+@Slf4j
+public class DeviceServiceImpl implements IDeviceService {
+    @Autowired
+    private EnvTempEntityRepo envTempEntityRepo;
+    @Autowired
+    private EnvHumiEntityRepo envHumiEntityRepo;
+    @Autowired
+    private EnvAmmoniaEntityRepo envAmmoniaEntityRepo;
+    @Autowired
+    private MathUtil2 mathUtil;
+    @Autowired
+    private DateUtil dateUtil;
+    @Autowired
+    private Producer producer;
+    @Autowired
+    private ISensorRegisterService sensorRegisterService;
+    @Autowired
+    private ConfigBean configBean;
+    @Autowired
+    private IPigpenService pigpenService;
+    @Autowired
+    private EnvWaterGegeEntityRepo envWaterGegeEntityRepo;
+    @Autowired
+    private EnvPhEntityRepo envPhEntityRepo;
+    @Autowired
+    private EnvWaterMeterRepo envWaterMeterRepo;
+    @Autowired
+    private EnvElectricityMeterRepo envElectricityMeterRepo;
+    @Resource
+    private EnvWaterDayService envWaterDayService;
+    @Resource
+    private EnvWaterMonthService envWaterMonthService;
+    @Resource
+    private EnvElectricityDayService envElectricityDayService;
+    @Resource
+    private EnvElectricityMonthService envElectricityMonthService;
+    //保存每天的用水量
+    @Override
+    public void saveDayWaterConsumption(JSONObject dataJo, EnvDeviceRegisterEntity envDeviceRegisterEntity, Timestamp nowTimestamp, Date todayDate, String farmCode) throws ParseException {
+        System.out.println("保存每天用电数据 dataJo>>>>>>>>>>>>>>>>>>"+dataJo);
+        DateUtil dateUtil = new DateUtil();
+        String deviceCode = dataJo.getString("deviceCode");
+        String sensorSn = dataJo.getString("sensorSn");
+        //查询每天的用水量数据
+        EnvWaterDay envWaterDay = envWaterDayService.getDayWaterConsumption(farmCode,deviceCode,sensorSn,todayDate);
+        System.out.println("envWaterDay="+envWaterDay);
+        if(envWaterDay == null){
+            envWaterDayService.saveDayWater(dataJo,envDeviceRegisterEntity,nowTimestamp,todayDate,farmCode);
+        }else{
+            //读取当天的累加次数
+            float sumWaterMeter = getSumTodayWaterMeter(farmCode,deviceCode,todayDate);
+            System.out.println(dateUtil.getTodayMissionText()+" sumWaterMeter 每天的用水量累加 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> "+sumWaterMeter);
+            if(sumWaterMeter != 0.0){
+                envWaterDayService.updateDayWater(sumWaterMeter,envWaterDay,dataJo,envDeviceRegisterEntity,nowTimestamp,todayDate,farmCode);
+            }else{
+                System.out.println("sumWaterMeter==0,不用更新");
+            }
+        }
+    }
+
+    //获取累加结果
+    private float getSumTodayWaterMeter(String farmCode,String deviceCode, Date todayDate) {
+        List<Object[]> sumList =  envWaterMeterRepo.getSumWaterMeter(farmCode,deviceCode,todayDate);
+        Object[] sumObj = (Object[]) sumList.get(0);
+        return Float.parseFloat(sumObj[0].toString());
+    }
+
+    //保存每月的用水量
+    @Override
+    public void saveMonthWaterConsumption(JSONObject dataJo, EnvDeviceRegisterEntity envDeviceRegisterEntity, Timestamp nowTimestamp, Date todayDate, String farmCode) {
+        System.out.println("保存每天用电数据 dataJo>>>>>>>>>>>>>>>>>>"+dataJo);
+        String deviceCode = dataJo.getString("deviceCode");
+        String sensorSn = dataJo.getString("sensorSn");
+        DateUtil dateUtil = new DateUtil();
+        String year = dateUtil.getThisYear();
+        String month = dateUtil.getThisMonth();
+        //查询每天的用电量数据
+        EnvWaterMonth envWaterMonth = envWaterMonthService.getMonthWaterConsumption(farmCode,deviceCode,sensorSn,year,month);
+        if(envWaterMonth == null){
+            envWaterMonthService.saveMonthWater(dataJo,envDeviceRegisterEntity,nowTimestamp,year,month,farmCode);
+        }else{
+            //计算本月的每天用水量累加
+            float sumDayWaterMeter = sumDayWaterMeterForMonth(farmCode,deviceCode,todayDate);
+            envWaterMonthService.updateMonthWater(sumDayWaterMeter,envWaterMonth,dataJo,nowTimestamp,year,month,farmCode);
+        }
+    }
+
+    //累加计算本月水量
+    private float sumDayWaterMeterForMonth(String farmCode,String deviceCode, Date todayDate) {
+        DateUtil dateUtil = new DateUtil();
+        java.util.Date startDate = dateUtil.getFirstDayInThisMonth();
+        java.util.Date endDate = dateUtil.getEndDayInThisMonth();
+        return envWaterDayService.getSumWaterMeter(farmCode,deviceCode,new java.sql.Date(startDate.getTime()),new java.sql.Date(endDate.getTime()));
+    }
+
+    //保存每天的用电量
+    @Override
+    public void saveDayElectricityConsumption(JSONObject dataJo, EnvDeviceRegisterEntity envDeviceRegisterEntity, Timestamp nowTimestamp, Date todayDate, String farmCode) {
+        System.out.println("保存每天用电数据 dataJo>>>>>>>>>>>>>>>>>>"+dataJo);
+        String deviceCode = dataJo.getString("deviceCode");
+        String sensorSn = dataJo.getString("sensorSn");
+        //查询每天的用电量数据
+        EnvElectricityDay envElectricityDay = envElectricityDayService.getDayElectricityConsumption(farmCode,deviceCode,sensorSn,todayDate);
+        System.out.println("envElectricityDay="+envElectricityDay);
+        if(envElectricityDay == null){
+            envElectricityDayService.saveDayElectricity(dataJo,envDeviceRegisterEntity,nowTimestamp,todayDate,farmCode);
+        }else{
+            //读取当天的累加次数
+            float sumElectricityMeter = getSumTodayElectricityMeter(farmCode,deviceCode,todayDate);
+            envElectricityDayService.updateDayElectricity(sumElectricityMeter,envElectricityDay,dataJo,envDeviceRegisterEntity,nowTimestamp,todayDate,farmCode);
+        }
+    }
+
+    //累计当天所有电量
+    private float getSumTodayElectricityMeter(String farmCode, String deviceCode, Date todayDate) {
+        List<Object[]> sumList =  envElectricityMeterRepo.getSumElectricityMeter(farmCode,deviceCode,todayDate);
+        System.out.println("00000000000000000000 sumList.size="+sumList.size());
+        Object[] sumObj = (Object[]) sumList.get(0);
+        return Float.parseFloat(sumObj[0].toString());
+    }
+
+    @Override
+    public void saveMonthElectricityConsumption(JSONObject dataJo, EnvDeviceRegisterEntity envDeviceRegisterEntity, Timestamp nowTimestamp, Date todayDate, String farmCode) {
+        System.out.println("保存每月用水数据 dataJo>>>>>>>>>>>>>>>>>>"+dataJo);
+        String deviceCode = dataJo.getString("deviceCode");
+        String sensorSn = dataJo.getString("sensorSn");
+        DateUtil dateUtil = new DateUtil();
+        String year = dateUtil.getThisYear();
+        String month = dateUtil.getThisMonth();
+        //查询每天的用电量数据
+        EnvElectricityMonth envElectricityMonth = envElectricityMonthService.getMonthElectricityConsumption(farmCode,deviceCode,sensorSn,year,month);
+        if(envElectricityMonth == null){
+            envElectricityMonthService.saveMonthElectricity(dataJo,envDeviceRegisterEntity,nowTimestamp,year,month,farmCode);
+        }else{
+            //计算本月的每天用电量量累加
+            float sumDayElectricityMeter = sumDayElectricityMeterForMonth(farmCode,deviceCode,todayDate);
+            envElectricityMonthService.updateMonthElectricity(sumDayElectricityMeter,envElectricityMonth,dataJo,nowTimestamp);
+        }
+    }
+
+    //计算本月的每天用电量量累加
+    private float sumDayElectricityMeterForMonth(String farmCode, String deviceCode, Date todayDate) {
+        DateUtil dateUtil = new DateUtil();
+        java.util.Date startDate = dateUtil.getFirstDayInThisMonth();
+        java.util.Date endDate = dateUtil.getEndDayInThisMonth();
+        return envElectricityDayService.getSumElectricityMeter(farmCode,deviceCode,new java.sql.Date(startDate.getTime()),new java.sql.Date(endDate.getTime()));
+    }
+
+    @Override
+    public void sendSensorToMQ(String deviceCode, Integer sensorSn, Timestamp nowTimestamp, Date todayDate, String value, String farmCode, int sensorSort) {
+        JSONObject sensorJo = new JSONObject();
+        sensorJo.put("deviceCode", deviceCode);
+        sensorJo.put("sensorSn", sensorSn);
+        sensorJo.put("timestamp", nowTimestamp);
+        sensorJo.put("todayDate", todayDate);
+        sensorJo.put("value", value);
+        sensorJo.put("farmCode", farmCode);
+        sensorJo.put("sensorSort", sensorSort);
+        producer.sendSensorAskToMQ(sensorJo);
+    }
+
+    //更新传感器数据
+    private void updateSensorRegister(String deviceCode, int sensorSn, Timestamp nowTimestamp, Date todayDate, String value, String farmCode, int sensorSort) {
+        if (sensorRegisterService.isExistSensorRegister(deviceCode, sensorSn, farmCode, sensorSort)) {
+            System.out.println("更新...");
+            //{更新传感器注册信息}
+            sensorRegisterService.updateSensorRegister(deviceCode, sensorSn, nowTimestamp, todayDate, value, farmCode, sensorSort);
+        } else {
+            System.out.println("新建...");
+            //{保存传感器注册信息}
+            sensorRegisterService.saveSensorRegister(deviceCode, sensorSn, nowTimestamp, todayDate, value, farmCode, sensorSort);
+        }
+    }
+
+    //保存温度流水数据
+    @Override
+    public void saveTempFlow(JSONObject dataJo, EnvDeviceRegisterEntity envDeviceRegisterEntity, Timestamp nowTimestamp, Date todayDate, String farmCode) {
+        EnvTempEntity envTempEntity = new EnvTempEntity();
+        String deviceCode = dataJo.getString("deviceCode");
+        BigDecimal bigDecimal = new BigDecimal(mathUtil.countTemp(dataJo.getIntValue("value")));
+        envTempEntity.setDeviceCode(deviceCode);
+        envTempEntity.setSensorSn(dataJo.getInteger("sensorSn"));
+        envTempEntity.setTemp(bigDecimal);
+        envTempEntity.setAskTime(dateUtil.handleAskTime(dataJo.getString("askTime")));
+        envTempEntity.setAddTime(nowTimestamp);
+        envTempEntity.setAddDate(todayDate);
+        envTempEntity.setFarmCode(farmCode);
+        envTempEntity.setPigpenId(envDeviceRegisterEntity.getPigpenId());
+        envTempEntity.setUnitId(envDeviceRegisterEntity.getUnitId());
+        envTempEntity.setDataUnit(dataJo.getString("dataUnit"));
+        envTempEntityRepo.saveAndFlush(envTempEntity);
+        if ("121".equals(deviceCode)){
+            RestTemplate restTemplate = new RestTemplate();
+            restTemplate.getForObject("http://139.9.167.178:9050/info/saveData/save?type=1&value="+bigDecimal,String.class);
+        }
+    }
+
+    //保存湿度流水数据
+    @Override
+    public void saveHumiFlow(JSONObject dataJo, EnvDeviceRegisterEntity envDeviceRegisterEntity, Timestamp nowTimestamp, Date todayDate, String farmCode) {
+        EnvHumiEntity envHumiEntity = new EnvHumiEntity();
+        String deviceCode = dataJo.getString("deviceCode");
+        BigDecimal bigDecimal = new BigDecimal(mathUtil.countHumi(dataJo.getIntValue("value")));
+
+        envHumiEntity.setDeviceCode(deviceCode);
+        envHumiEntity.setSensorSn(dataJo.getInteger("sensorSn"));
+        envHumiEntity.setHumi(bigDecimal);
+        envHumiEntity.setAskTime(dateUtil.handleAskTime(dataJo.getString("askTime")));
+        envHumiEntity.setAddTime(nowTimestamp);
+        envHumiEntity.setAddDate(todayDate);
+        envHumiEntity.setFarmCode(farmCode);
+        envHumiEntity.setPigpenId(envDeviceRegisterEntity.getPigpenId());
+        envHumiEntity.setUnitId(envDeviceRegisterEntity.getUnitId());
+        envHumiEntity.setDataUnit(dataJo.getString("dataUnit"));
+        envHumiEntityRepo.saveAndFlush(envHumiEntity);
+        if ("121".equals(deviceCode)){
+            RestTemplate restTemplate = new RestTemplate();
+            restTemplate.getForObject("http://139.9.167.178:9050/info/saveData/save?type=2&value="+bigDecimal,String.class);
+        }
+    }
+
+    //保存氨气流水数据
+    @Override
+    public void saveAmmoniaFlow(JSONObject dataJo, EnvDeviceRegisterEntity envDeviceRegisterEntity, Timestamp nowTimestamp, Date todayDate, String farmCode) {
+        EnvAmmoniaEntity envAmmoniaEntity = new EnvAmmoniaEntity();
+        String deviceCode = dataJo.getString("deviceCode");
+        BigDecimal bigDecimal = new BigDecimal(mathUtil.countMeter(dataJo.getIntValue("value")));
+        envAmmoniaEntity.setDeviceCode(deviceCode);
+        envAmmoniaEntity.setSensorSn(dataJo.getInteger("sensorSn"));
+        envAmmoniaEntity.setAmmonia(bigDecimal);
+        envAmmoniaEntity.setAskTime(dateUtil.handleAskTime(dataJo.getString("askTime")));
+        envAmmoniaEntity.setAddTime(nowTimestamp);
+        envAmmoniaEntity.setAddDate(todayDate);
+        envAmmoniaEntity.setFarmCode(farmCode);
+        envAmmoniaEntity.setPigpenId(envDeviceRegisterEntity.getPigpenId());
+        envAmmoniaEntity.setUnitId(envDeviceRegisterEntity.getUnitId());
+        envAmmoniaEntity.setDataUnit(dataJo.getString("dataUnit"));
+        envAmmoniaEntityRepo.saveAndFlush(envAmmoniaEntity);
+        System.out.println("111111111"+deviceCode + "   "  +bigDecimal);
+        if ("121".equals(deviceCode)){
+            RestTemplate restTemplate = new RestTemplate();
+            String forObject = restTemplate.getForObject("http://139.9.167.178:9050/info/saveData/save?type=3&value=" + bigDecimal, String.class);
+            System.out.println("2222222"+forObject);
+        }
+    }
+    //保存水压流水数据
+    @Override
+    public void saveWaterGege(JSONObject dataJo, EnvDeviceRegisterEntity envDeviceRegisterEntity, Timestamp nowTimestamp, Date todayDate, String farmCode) {
+        EnvWaterGege envAmmoniaEntity = new EnvWaterGege();
+        envAmmoniaEntity.setDeviceCode(dataJo.getString("deviceCode"));
+        envAmmoniaEntity.setSensorSn(dataJo.getInteger("sensorSn"));
+        envAmmoniaEntity.setWaterGege(new BigDecimal(dataJo.getIntValue("value")));
+        envAmmoniaEntity.setAskTime(dateUtil.handleAskTime(dataJo.getString("askTime")));
+        envAmmoniaEntity.setAddTime(nowTimestamp);
+        envAmmoniaEntity.setAddDate(todayDate);
+        envAmmoniaEntity.setFarmCode(farmCode);
+        envAmmoniaEntity.setPigpenId(envDeviceRegisterEntity.getPigpenId());
+        envAmmoniaEntity.setUnitId(envDeviceRegisterEntity.getUnitId());
+        envAmmoniaEntity.setDataUnit(dataJo.getString("dataUnit"));
+        envWaterGegeEntityRepo.saveAndFlush(envAmmoniaEntity);
+    }
+    //保存PH
+    @Override
+    public void savePH(JSONObject dataJo, EnvDeviceRegisterEntity envDeviceRegisterEntity, Timestamp nowTimestamp, Date todayDate, String farmCode) {
+        EnvPh envPh = new EnvPh();
+        envPh.setDeviceCode(dataJo.getString("deviceCode"));
+        envPh.setSensorSn(dataJo.getInteger("sensorSn"));
+        envPh.setPh(new BigDecimal(mathUtil.countMeter(dataJo.getIntValue("value"))));
+        envPh.setAskTime(dateUtil.handleAskTime(dataJo.getString("askTime")));
+        envPh.setAddTime(nowTimestamp);
+        envPh.setAddDate(todayDate);
+        envPh.setFarmCode(farmCode);
+        envPh.setPigpenId(envDeviceRegisterEntity.getPigpenId());
+        envPh.setUnitId(envDeviceRegisterEntity.getUnitId());
+        envPh.setDataUnit(dataJo.getString("dataUnit"));
+        envPhEntityRepo.saveAndFlush(envPh);
+    }
+    //保存水表
+    @Override
+    public void saveWaterMeter(JSONObject dataJo, EnvDeviceRegisterEntity envDeviceRegisterEntity, Timestamp nowTimestamp, Date todayDate, String farmCode) {
+        int newValueData = dataJo.getIntValue("value");
+        String deviceCode = dataJo.getString("deviceCode");
+        EnvWaterMeter envWaterMeterData = envWaterMeterRepo.getOneByMaxId(deviceCode);
+        Integer lastWaterMeterData ;
+        Integer value = 0;
+        if (envWaterMeterData ==null || envWaterMeterData.getWaterMeterData() ==null){
+            lastWaterMeterData = 0;
+        }else {
+            lastWaterMeterData = envWaterMeterData.getWaterMeterData();
+        }
+        if (newValueData >= lastWaterMeterData){
+            value = newValueData - lastWaterMeterData;
+        }else {
+            value = newValueData;
+        }
+        EnvWaterMeter envWaterMeter = new EnvWaterMeter();
+        envWaterMeter.setDeviceCode(deviceCode);
+        envWaterMeter.setSensorSn(dataJo.getInteger("sensorSn"));
+        envWaterMeter.setWaterMeter(new BigDecimal(mathUtil.countMeter(value)));
+        envWaterMeter.setWaterMeterData(newValueData);
+        envWaterMeter.setAskTime(dateUtil.handleAskTime(dataJo.getString("askTime")));
+        envWaterMeter.setAddTime(nowTimestamp);
+        envWaterMeter.setAddDate(todayDate);
+        envWaterMeter.setFarmCode(farmCode);
+        envWaterMeter.setPigpenId(envDeviceRegisterEntity.getPigpenId());
+        envWaterMeter.setUnitId(envDeviceRegisterEntity.getUnitId());
+        envWaterMeter.setDataUnit(dataJo.getString("dataUnit"));
+        System.out.println("已经保存水量流水数据 >>");
+        System.out.println("envWaterMeter >> "+envWaterMeter.toString());
+        envWaterMeterRepo.saveAndFlush(envWaterMeter);
+    }
+
+    //保存电表
+    @Override
+    public void saveElectricityMeter(JSONObject dataJo, EnvDeviceRegisterEntity envDeviceRegisterEntity, Timestamp nowTimestamp, Date todayDate, String farmCode) {
+        int valueData = dataJo.getIntValue("value");
+        String deviceCode = dataJo.getString("deviceCode");
+        EnvElectricityMeter envElectricityMeterData = envElectricityMeterRepo.getOneByMaxId(deviceCode);
+        Integer electricityMeterData ;
+        Integer value = 0;
+        if (ObjectUtil.isEmpty(envElectricityMeterData)|| envElectricityMeterData.getElectricityMeterData() ==null){
+            electricityMeterData = 0;
+        }else {
+            electricityMeterData =  envElectricityMeterData.getElectricityMeterData();
+        }
+        if (valueData >= electricityMeterData){
+            value = valueData-electricityMeterData;
+        }else {
+            value = 0;
+        }
+        EnvElectricityMeter envElectricityMeter = new EnvElectricityMeter();
+        envElectricityMeter.setDeviceCode(dataJo.getString("deviceCode"));
+        envElectricityMeter.setSensorSn(dataJo.getInteger("sensorSn"));
+        envElectricityMeter.setElectricityMeter(new BigDecimal(value));
+        envElectricityMeter.setElectricityMeterData(valueData);
+        envElectricityMeter.setAskTime(dateUtil.handleAskTime(dataJo.getString("askTime")));
+        envElectricityMeter.setAddTime(nowTimestamp);
+        envElectricityMeter.setAddDate(todayDate);
+        envElectricityMeter.setFarmCode(farmCode);
+        envElectricityMeter.setPigpenId(envDeviceRegisterEntity.getPigpenId());
+        envElectricityMeter.setUnitId(envDeviceRegisterEntity.getUnitId());
+        envElectricityMeter.setDataUnit(dataJo.getString("dataUnit"));
+        envElectricityMeterRepo.saveAndFlush(envElectricityMeter);
+    }
+
+    //
+    @Override
+    public JSONObject handleAskText(String askText) {
+        String[] dataArray = askText.split("\\+");
+        return buildDataObj(dataArray);
+    }
+
+    @Override
+    public String getMessageContent(JSONObject dataJo, EnvDeviceRegisterEntity envDeviceRegisterEntity) {
+        String act = configBean.getAct();
+        String fault = configBean.getFault();
+        log.info("所有故障类型="+fault);
+        log.info("所有动作类型="+act);
+        int faultSn = dataJo.getInteger("faultSn");
+        int actType = dataJo.getInteger("actType");
+        //
+        String faultText = getFaultText(faultSn, fault);
+        log.info("当前故障="+faultText);
+        //1:报警 2:恢复
+        String actText = getActText(actType, act);
+        log.info("当前操作="+actText);
+        String messageConent = "";
+        if (actType == 1) {
+            if (faultText.indexOf("报警") == -1) {
+                messageConent = faultText + actText;
+            } else {
+                messageConent = faultText;
+            }
+        } else {
+            messageConent = faultText+"已"+actText;
+        }
+        //获取栋舍
+        String pigpenName = pigpenService.getPigpenByDevice(dataJo.getString("deviceCode"));
+        //芯片ID
+        String chipId = envDeviceRegisterEntity.getChipId();
+        //2栋的芯片ID[86178908]高温报警
+        return "["+pigpenName+"]芯片ID为["+chipId+"]的设备提示:"+messageConent;
+    }
+
+    @Override
+    public JSONObject handleSprayStatusAskCmd(String askText) {
+        String[] dataArray = askText.split("\\+");
+        JSONObject dataJo = new JSONObject();
+        dataJo.put("deviceCode",dataArray[1]);
+        dataJo.put("sprayStatus",dataArray[3]);
+        dataJo.put("askTime",dataArray[4]);
+        return dataJo;
+    }
+
+
+    private String getActText(int actType, String act) {
+        String[] actGroupArray = act.split(",");
+        String actText = "";
+        for (int a = 0; a < actGroupArray.length; a++) {
+            String actGroup = actGroupArray[a];
+            String[] actArray = actGroup.split(":");
+            JSONObject newJo = new JSONObject();
+            newJo.put("id", actArray[0]);
+            newJo.put("fault", actArray[1]);
+            if (Integer.parseInt(actArray[0]) == actType) {
+                actText = actArray[1];
+                break;
+            }
+        }
+        return actText;
+    }
+
+    //
+    private String getFaultText(int faultSn, String fault) {
+        String[] faultGroupArray = fault.split(",");
+        String faultText = "";
+        for (int a = 0; a < faultGroupArray.length; a++) {
+            String falutGroup = faultGroupArray[a];
+            String[] faultArray = falutGroup.split(":");
+            if (Integer.parseInt(faultArray[0]) == faultSn) {
+                faultText = faultArray[1];
+                break;
+            }
+        }
+        return faultText;
+    }
+
+    //
+    public JSONObject buildDataObj(String[] dataArray) {
+        JSONObject dataJo = new JSONObject();
+        dataJo.put("deviceCode", dataArray[1]);
+        dataJo.put("cmd", dataArray[2]);
+        dataJo.put("sensorSn", dataArray[3]);
+        dataJo.put("value", dataArray[4]);
+        dataJo.put("askTime", dataArray[5]);
+        return dataJo;
+    }
+
+}

+ 104 - 0
huimv-env-device/src/main/resources/application-dev.yml

@@ -0,0 +1,104 @@
+server:
+  port: 8092
+
+spring:
+  application:
+    name: huimv-env-device
+
+  datasource:
+    url: jdbc:mysql://122.112.224.199:3306/huimv-env-platform?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+    username: root
+    password: hm123456
+    driver-class-name: com.mysql.cj.jdbc.Driver
+  jpa:
+    show-sql: true
+    database: mysql
+    hibernate:
+      ddl-auto: update
+    database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
+    open-in-view: true
+
+  #配置rabbitMq 服务器
+#  rabbitmq:
+#    host: 10.0.0.4
+#    port: 5672
+#    username: huimv
+#    password: hm123456
+#    #虚拟host 可以不设置,使用server默认host
+#    virtual-host: /
+  rabbitmq:
+    host: 121.36.134.218
+    port: 5672
+    username: admin
+    password: admin
+    #虚拟host 可以不设置,使用server默认host
+    virtual-host: /env
+
+    #确认消息已发送到交换机(Exchange)
+#    publisher-confirms: true #(过时、弃用)
+    publisher-confirm-type: correlated
+    #确认消息已发送到队列(Queue)
+    publisher-returns: true
+
+  #redis
+  redis:
+    database: 0
+    host: 192.168.1.68
+    port: 6379
+    password: hm123456
+    timeout: 5000ms
+    jedis:
+      pool:
+        max-active: 20
+        max-wait: -1
+        max-idle: 10
+        min-idle: 0
+    lettuce:
+      pool:
+        max-active: 3
+        min-idle: 2
+        max-idle: 3
+        max-wait: 1
+      shutdown-timeout: 100
+
+  data:
+    redis:
+      repositories:
+        enabled: false
+
+  #是否缓存空值
+  cache:
+    redis:
+      cache-null-values: false
+
+
+
+    #server:
+#  port: 9110
+#spring:
+#  application:
+#    name: huimv-hy-autoGetData
+#
+#  datasource:
+##    url: jdbc:mysql://47.98.175.112:3306/huimv_ql_farm_haiyan?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+#    #    url: jdbc:mysql://36.22.189.214:3306/huimv_ql_farm?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+#        url: jdbc:mysql://192.168.1.7:3306/huimv_ql_farm?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+#    username: root
+#    password: hm123456
+#    driver-class-name: com.mysql.cj.jdbc.Driver
+#  jpa:
+#    properties:
+#      hibernate:
+#        enable_lazy_load_no_trans: true
+#    show-sql: true
+#    database: mysql
+#    hibernate:
+#      ddl-auto: update
+#    database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
+#    open-in-view: true
+management:
+  endpoints:
+    web:
+      exposure:
+        include: "*"   # * 在yaml 文件属于关键字,所以需要加引号
+

+ 110 - 0
huimv-env-device/src/main/resources/application-prod.yml

@@ -0,0 +1,110 @@
+server:
+  port: 8092
+
+spring:
+  application:
+    name: huimv-env-device
+
+  datasource:
+    url: jdbc:mysql://122.112.224.199:3306/huimv-env-platform-qingshan?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+    username: qingshan
+    password: qingshan@2022
+    driver-class-name: com.mysql.cj.jdbc.Driver
+  jpa:
+    show-sql: true
+    database: mysql
+    hibernate:
+      ddl-auto: update
+    database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
+    open-in-view: true
+
+  #配置rabbitMq 服务器
+#  rabbitmq:
+#    host: 10.0.0.4
+#    port: 5672
+#    username: huimv
+#    password: hm123456
+#    #虚拟host 可以不设置,使用server默认host
+#    virtual-host: /
+  rabbitmq:
+    host: 121.36.134.218
+    port: 5672
+    username: admin
+    password: admin
+    #虚拟host 可以不设置,使用server默认host
+    virtual-host: /env
+    listener:
+      simple:
+        acknowledge-mode: none  #消费端不需要确认
+    #确认消息已发送到交换机(Exchange)
+    publisher-confirm-type: correlated
+    #确认消息已发送到队列(Queue)
+    publisher-returns: true
+
+  #redis
+#  redis:
+#    database: 0
+#    host: 192.168.1.68
+#    port: 6379
+#    password: hm123456
+#    timeout: 5000ms
+#    jedis:
+#      pool:
+#        max-active: 20
+#        max-wait: -1
+#        max-idle: 10
+#        min-idle: 0
+#    lettuce:
+#      pool:
+#        max-active: 3
+#        min-idle: 2
+#        max-idle: 3
+#        max-wait: 1
+#      shutdown-timeout: 100
+
+#  data:
+#    redis:
+#      repositories:
+#        enabled: false
+
+  #是否缓存空值
+#  cache:
+#    redis:
+#      cache-null-values: false
+
+
+
+    #server:
+#  port: 9110
+#spring:
+#  application:
+#    name: huimv-hy-autoGetData
+#
+#  datasource:
+##    url: jdbc:mysql://47.98.175.112:3306/huimv_ql_farm_haiyan?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+#    #    url: jdbc:mysql://36.22.189.214:3306/huimv_ql_farm?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+#        url: jdbc:mysql://192.168.1.7:3306/huimv_ql_farm?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+#    username: root
+#    password: hm123456
+#    driver-class-name: com.mysql.cj.jdbc.Driver
+#  jpa:
+#    properties:
+#      hibernate:
+#        enable_lazy_load_no_trans: true
+#    show-sql: true
+#    database: mysql
+#    hibernate:
+#      ddl-auto: update
+#    database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
+#    open-in-view: true
+management:
+  endpoints:
+    web:
+      exposure:
+        include: "*"   # * 在yaml 文件属于关键字,所以需要加引号
+
+mybatis-plus:
+  configuration:
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+  # mapper.xml文件所存放的位置
+  mapper-locations: classpath*:com/huimv/env/common/mapper/xml/*.xml  # 不加这一行出错:“org.apache.ibatis.binding.BindingException:  Invalid bound statement (not found)”

+ 34 - 0
huimv-env-device/src/main/resources/application.properties

@@ -0,0 +1,34 @@
+spring.profiles.active=prod
+#spring.profiles.active=dev
+
+#\u5F00\u542F\u5065\u5EB7\u76D1\u63A7
+management.endpoints.web.exposure.include=*
+
+#########################################################
+###             \u914D\u7F6Eundertow\u53D6\u4EE3tomcat                ###
+#########################################################
+# \u662F\u5426\u6253\u5F00 undertow \u65E5\u5FD7\uFF0C\u9ED8\u8BA4\u4E3A false
+server.undertow.accesslog.enabled=false
+# \u8BBE\u7F6E\u8BBF\u95EE\u65E5\u5FD7\u6240\u5728\u76EE\u5F55
+server.undertow.accesslog.dir=logs
+# \u6307\u5B9A\u5DE5\u4F5C\u8005\u7EBF\u7A0B\u7684 I/0 \u7EBF\u7A0B\u6570\uFF0C\u9ED8\u8BA4\u4E3A 2 \u6216\u8005 CPU \u7684\u4E2A\u6570
+server.undertow.io-threads=
+# \u6307\u5B9A\u5DE5\u4F5C\u8005\u7EBF\u7A0B\u4E2A\u6570\uFF0C\u9ED8\u8BA4\u4E3A I/O \u7EBF\u7A0B\u4E2A\u6570\u7684 8 \u500D
+server.undertow.worker-threads=
+# \u8BBE\u7F6E HTTP POST \u5185\u5BB9\u7684\u6700\u5927\u957F\u5EA6\uFF0C\u9ED8\u8BA4\u4E0D\u505A\u9650\u5236
+server.undertow.max-http-post-size=0
+
+#########################################################
+###   Actuator Monitor  --   Actuator configuration   ###
+#########################################################
+management.security.enabled=false
+
+# \u6570\u636E\u5904\u7406\u6D41\u7A0B
+data.input.flow=2
+
+# \u662F\u5426\u5199\u5165\u6D4B\u8BD5\u6570\u636E(1:\u5199\u5165 0:\u4E0D\u5199\u5165)
+data.test.input=0
+
+# PinYin
+#push.message.fault.list=0:\u521D\u59CB\u5316,1:\u65AD\u7535,2:\u9AD8\u6E29,3:\u4F4E\u6E29,4:\u4F20\u611F\u5668\u6545\u969C
+#push.message.act.list=1:\u62A5\u8B66,2:\u6062\u590D

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 3 - 0
huimv-env-device/src/main/resources/conf/config.properties


+ 61 - 0
huimv-env-device/src/test/java/com/huimv/env/device/service/DeviceTest.java

@@ -0,0 +1,61 @@
+package com.huimv.env.device.service;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.huimv.env.device.config.ConfigBean;
+import com.huimv.env.device.listener.DeviceListener;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import javax.annotation.security.RunAs;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@SpringBootTest
+@RunWith(SpringRunner.class)
+public class DeviceTest {
+//    @Autowired
+//    private Show show;
+    @Autowired
+    private ConfigBean configBean;
+
+//    @Test
+//    public void test1(){
+//        show.show1();
+//
+//        JSONArray testJa = new JSONArray();
+//        JSONObject testJo = new JSONObject();
+//        testJa.add(testJo);
+//        testJo.put("id",0);
+//        testJo.put("fault","初始化");
+//        JSONObject testJo2 = new JSONObject();
+//        testJa.add(testJo2);
+//        testJo2.put("id",0);
+//        testJo2.put("fault","初始化");
+//        System.out.println("testJa="+testJa.toJSONString());
+//    }
+
+//    @Test
+//    public void test2() {
+//        show.show2();
+//    }
+
+    @Test
+    public void test3(){
+        String act = configBean.getAct();
+        String fault = configBean.getFault();
+        System.out.println("act="+act);
+        System.out.println("fault="+fault);
+    }
+}

+ 150 - 0
huimv-env-input-water/pom.xml

@@ -0,0 +1,150 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.4.3</version>
+        <relativePath/> <!-- lookup parent from repository -->
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>com.huimv</groupId>
+    <artifactId>huimv-env-input</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+
+    <dependencies>
+        <!-- 排除Tomcat容器 -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+            <!-- 移除掉默认支持的 Tomcat -->
+            <exclusions>
+                <exclusion>
+                    <groupId>org.springframework.boot</groupId>
+                    <artifactId>spring-boot-starter-tomcat</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <!-- 添加 Undertow 容器 -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-undertow</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>1.2.28</version>
+        </dependency>
+        <!-- JPA -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-jpa</artifactId>
+        </dependency>
+        <!-- mysql -->
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+        </dependency>
+        <!--rabbitmq-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-amqp</artifactId>
+        </dependency>
+        <!-- redis -->
+        <dependency>
+            <groupId>cn.dustlight.captcha</groupId>
+            <artifactId>redis-store</artifactId>
+            <version>0.0.6</version>
+        </dependency>
+        <!-- actuator -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-actuator</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <!-- fastjson -->
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+            <version> 5.8.1</version>
+        </dependency>
+        <dependency>
+            <groupId>io.netty</groupId>
+            <artifactId>netty-all</artifactId>
+        </dependency>
+        <!-- 一方包统一版本管理 -->
+<!--        <dependency>-->
+<!--            <groupId>com.huimv</groupId>-->
+<!--            <artifactId>huimv-env-common</artifactId>-->
+<!--        </dependency>-->
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>1.2.73</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-boot-starter</artifactId>
+            <version>3.4.2</version>
+        </dependency>
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-extension</artifactId>
+            <version>3.4.2</version>
+        </dependency>
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-generator</artifactId>
+            <version>3.2.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.mybatis</groupId>
+            <artifactId>mybatis-spring</artifactId>
+            <version>2.0.6</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.java-websocket</groupId>
+            <artifactId>Java-WebSocket</artifactId>
+            <version>1.3.7</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-websocket</artifactId>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-resources-plugin</artifactId>
+                <version>2.6</version>
+            </plugin>
+        </plugins>
+    </build>
+</project>

+ 25 - 0
huimv-env-input-water/src/main/java/com/huimv/env/input/HuimvEnvInputApplication.java

@@ -0,0 +1,25 @@
+package com.huimv.env.input;
+
+import com.huimv.env.input.server.EnvInputServer;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.ApplicationContext;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@MapperScan(basePackages = "com.huimv.env.input.mapper")
+@SpringBootApplication
+public class HuimvEnvInputApplication {
+    public static void main(String[] args) throws InterruptedException {
+        ApplicationContext applicationContext = SpringApplication.run(HuimvEnvInputApplication.class, args);
+        // EnvInputServer
+        applicationContext.getBean(EnvInputServer.class).run();
+    }
+}

+ 48 - 0
huimv-env-input-water/src/main/java/com/huimv/env/input/controller/ChengzhongController.java

@@ -0,0 +1,48 @@
+package com.huimv.env.input.controller;
+
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.huimv.env.input.entity.Chengzhong;
+import com.huimv.env.input.service.IChengzhongService;
+import com.huimv.env.input.utils.Result;
+import com.huimv.env.input.utils.ResultCode;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author author
+ * @since 2023-03-11
+ */
+@RestController
+@RequestMapping("/chengzhong")
+@CrossOrigin
+public class ChengzhongController {
+
+    @Autowired
+    private IChengzhongService chengzhongService;
+
+
+    @GetMapping("/get")
+    public Result get(){
+        return new Result(ResultCode.SUCCESS,chengzhongService.list(new QueryWrapper<Chengzhong>().orderByDesc("id").last("limit 10 "))) ;
+    }
+
+    @GetMapping("/get1")
+    public void get1(){
+//        while (true){
+//            List<Chengzhong> id = chengzhongService.list(new QueryWrapper<Chengzhong>().orderByDesc("id").last("limit 10 "));
+//            WebSocket.sendMessage(id.toString());
+//        }
+    }
+
+}

+ 43 - 0
huimv-env-input-water/src/main/java/com/huimv/env/input/entity/Chengzhong.java

@@ -0,0 +1,43 @@
+package com.huimv.env.input.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import java.time.LocalDateTime;
+import java.io.Serializable;
+import java.util.Date;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author author
+ * @since 2023-03-11
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@TableName("chengzhong")
+public class Chengzhong implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    private Integer weight;
+
+    @JsonFormat(pattern = "MM-dd HH:mm:ss",timezone = "GMT+8")
+    private Date creatTime;
+
+    private String macAddr;
+    private Integer num;
+
+
+}

+ 16 - 0
huimv-env-input-water/src/main/java/com/huimv/env/input/mapper/ChengzhongMapper.java

@@ -0,0 +1,16 @@
+package com.huimv.env.input.mapper;
+
+import com.huimv.env.input.entity.Chengzhong;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author author
+ * @since 2023-03-11
+ */
+public interface ChengzhongMapper extends BaseMapper<Chengzhong> {
+
+}

+ 139 - 0
huimv-env-input-water/src/main/java/com/huimv/env/input/producer/Producer.java

@@ -0,0 +1,139 @@
+//package com.huimv.env.input.producer;
+//
+//import com.huimv.env.common.utils.Const;
+//import lombok.extern.slf4j.Slf4j;
+//import org.springframework.amqp.rabbit.core.RabbitTemplate;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.stereotype.Component;
+//
+//import java.util.HashMap;
+//import java.util.Map;
+//
+///**
+// * @Project : huimv.shiwan
+// * @Package : com.huimv.biosafety.uface.controller
+// * @Description : TODO
+// * @Version : 1.0
+// * @Author : ZhuoNing
+// * @Create : 2020-12-25
+// **/
+//@Component
+//@Slf4j
+//public class Producer {
+//    @Autowired
+//    RabbitTemplate rabbitTemplate;  //使用RabbitTemplate,这提供了接收/发送等等方法
+//
+//    /**
+//     * @Method      : sendTempAskToMQ
+//     * @Description :
+//     * @Params      : [askText]
+//     * @Return      : java.lang.String
+//     *
+//     * @Author      : ZhuoNing
+//     * @Date        : 2022/8/17
+//     * @Time        : 19:29
+//     */
+//    public String sendTempAskToMQ(String askText){
+//        Map map = new HashMap();
+//        map.put("askText",askText);
+//        rabbitTemplate.convertAndSend(Const.EXCHANGE_TEMP, Const.ROUTING_KEY_TEMP, map);
+//        return "ok";
+//    }
+//
+//    /**
+//     * @Method      : sendHumiAskToMQ
+//     * @Description :
+//     * @Params      : [askText]
+//     * @Return      : java.lang.String
+//     *
+//     * @Author      : ZhuoNing
+//     * @Date        : 2022/8/17
+//     * @Time        : 19:13
+//     */
+//    public String sendHumiAskToMQ(String askText){
+//        Map map = new HashMap();
+//        map.put("askText",askText);
+//        rabbitTemplate.convertAndSend(Const.EXCHANGE_HUMI, Const.ROUTING_KEY_HUMI, map);
+//        return "ok";
+//    }
+//
+//    /**
+//     * @Method      : sendAmmoniaAskToMQ
+//     * @Description :
+//     * @Params      : [askText]
+//     * @Return      : java.lang.String
+//     *
+//     * @Author      : ZhuoNing
+//     * @Date        : 2022/8/17
+//     * @Time        : 19:13
+//     */
+//    public String sendAmmoniaAskToMQ(String askText){
+//        Map map = new HashMap();
+//        map.put("askText",askText);
+//        rabbitTemplate.convertAndSend(Const.EXCHANGE_AMMONIA, Const.ROUTING_KEY_AMMONIA, map);
+//        return "ok";
+//    }
+//
+//    /**
+//     * @Method      : sendSprayEquipStatusToMQ
+//     * @Description :
+//     * @Params      : [askText]
+//     * @Return      : java.lang.String
+//     *
+//     * @Author      : ZhuoNing
+//     * @Date        : 2022/8/18
+//     * @Time        : 20:51
+//     */
+//    public String sendSprayEquipStatusToMQ(String askText) {
+//        Map map = new HashMap();
+//        map.put("askText",askText);
+//        rabbitTemplate.convertAndSend(Const.EXCHANGE_DEVICE_STATUS, Const.ROUTING_KEY_DEVICE_STATUS, map);
+//        return "ok";
+//    }
+//
+//    /**
+//     * @Method      : sendPushMessageToMQ
+//     * @Description :
+//     * @Params      : [askText]
+//     * @Return      : java.lang.String
+//     *
+//     * @Author      : ZhuoNing
+//     * @Date        : 2022/8/18
+//     * @Time        : 20:52
+//     */
+//    public String sendPushMessageToMQ(String askText) {
+//        Map map = new HashMap();
+//        map.put("askText",askText);
+//        rabbitTemplate.convertAndSend(Const.EXCHANGE_PUSH_MESSAGE, Const.ROUTING_KEY_PUSH_MESSAGE, map);
+//        return "ok";
+//    }
+//
+//    public String sendWaterGege(String askText) {
+//
+//        Map map = new HashMap();
+//        map.put("askText",askText);
+//        rabbitTemplate.convertAndSend(Const.EXCHANGE_WATER_GEGE, Const.ROUTING_KEY_WATER_GEGE, map);
+//        return "ok";
+//    }
+//
+//    public String sendPHGege(String askText) {
+//        Map map = new HashMap();
+//        map.put("askText",askText);
+//        rabbitTemplate.convertAndSend(Const.EXCHANGE_PH, Const.ROUTING_KEY_PH, map);
+//        return "ok";
+//    }
+//
+//    public String sendWaterMeter(String askText) {
+//        Map map = new HashMap();
+//        map.put("askText",askText);
+//        rabbitTemplate.convertAndSend(Const.EXCHANGE_WATER_METER, Const.ROUTING_KEY_WATER_METER, map);
+//        return "ok";
+//    }
+//
+//    public String sendElectricityMeter(String askText) {
+//        Map map = new HashMap();
+//        map.put("askText",askText);
+//        rabbitTemplate.convertAndSend(Const.EXCHANGE_ELECTRICITY_METER, Const.ROUTING_KEY_ELECTRICITY_METER, map);
+//        return "ok";
+//    }
+//}

+ 49 - 0
huimv-env-input-water/src/main/java/com/huimv/env/input/server/DtuServer.java

@@ -0,0 +1,49 @@
+//package com.huimv.env.input.server;
+//
+//import io.netty.bootstrap.ServerBootstrap;
+//import io.netty.channel.ChannelFuture;
+//import io.netty.channel.ChannelInitializer;
+//import io.netty.channel.EventLoopGroup;
+//import io.netty.channel.nio.NioEventLoopGroup;
+//import io.netty.channel.socket.SocketChannel;
+//import io.netty.channel.socket.nio.NioServerSocketChannel;
+//import io.netty.handler.timeout.IdleStateHandler;
+//
+//import java.util.concurrent.TimeUnit;
+//
+///**
+// * TODO
+// *
+// * @author linfeng
+// * @date 2022/12/26 15:57
+// */
+//public class DtuServer implements Runnable {
+//
+//    public static void main(String[] args) {
+//        new Thread(new DtuServer()).start();
+//    }
+//
+//    @Override
+//    public void run() {
+//        EventLoopGroup bossGroup = new NioEventLoopGroup(2);
+//        EventLoopGroup workGroup = new NioEventLoopGroup(10);
+//        ServerBootstrap serverBootstrap = new ServerBootstrap();
+//        serverBootstrap.group(bossGroup,workGroup).channel(NioServerSocketChannel.class)
+//                .childHandler(new ChannelInitializer<SocketChannel>() {
+//
+//                    @Override
+//                    protected void initChannel(SocketChannel ch) throws Exception {
+//                        ch.pipeline().addLast(new IdleStateHandler(15, 0, 0, TimeUnit.MINUTES));
+//                        ch.pipeline().addLast(new DtuServiceHandler());
+//                    }
+//
+//                });
+//        try {
+//            ChannelFuture channelFuture = serverBootstrap.bind(9005).sync();
+//            channelFuture.channel().closeFuture().sync();
+//        } catch (InterruptedException e) {
+//            e.printStackTrace();
+//        }
+//    }
+//}
+//

+ 115 - 0
huimv-env-input-water/src/main/java/com/huimv/env/input/server/DtuServiceHandler.java

@@ -0,0 +1,115 @@
+//package com.huimv.env.input.server;
+//
+//import com.huimv.env.input.utils.ModBusUtils;
+//import io.netty.buffer.ByteBuf;
+//import io.netty.buffer.Unpooled;
+//import io.netty.channel.Channel;
+//import io.netty.channel.ChannelHandlerContext;
+//import io.netty.channel.ChannelId;
+//import io.netty.channel.ChannelInboundHandlerAdapter;
+//import io.netty.channel.group.ChannelGroup;
+//import io.netty.channel.group.DefaultChannelGroup;
+//import io.netty.util.concurrent.GlobalEventExecutor;
+//
+//import java.net.SocketAddress;
+//import java.util.Map;
+//import java.util.concurrent.ConcurrentHashMap;
+//
+///**
+// * TODO
+// *
+// * @author linfeng
+// * @date 2022/12/26 15:58
+// */
+//public class DtuServiceHandler extends ChannelInboundHandlerAdapter {
+//
+//	// 保存
+//    private static ChannelGroup channelGroup = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);
+//
+//	// 保存客户端channelId与注册包信息
+//    private static Map<String,String> channelIdMap = new ConcurrentHashMap<>();
+//
+//    @Override
+//    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
+//        Channel channel = ctx.channel();
+//        ChannelId channelId = channel.id();
+//        ByteBuf byteBuf = (ByteBuf) msg;
+//        byte[] bytes = new byte[byteBuf.readableBytes()];
+//        byteBuf.readBytes(bytes);
+//        String str = ModBusUtils.bytes2HexString(bytes);
+//        for (String s : str.split(" ")) {
+//            System.out.println(s);
+//        }
+//        System.out.println(bytes.length);
+//        if(bytes.length == 16){
+//        	// 注册包长度为16(我这边用到4G DTU(ZHC4013)注册包长度为16,如果有变化需要修改)
+//        	// 注册包为设备编号,设备编号是唯一的。
+//            String registerPackage = "";
+//            for(int i=0;i<bytes.length;i++) {
+//                registerPackage=registerPackage+ModBusUtils.byteToASCLL(bytes[i]);
+//            }
+//            // channelId.asLongText()获取的是客户端全局唯一ID,根据channelId获取注册包信息,可以判断出数据是哪个节点上传的
+//            channelIdMap.put(channelId.asLongText(),registerPackage);
+//            System.out.println("注册包:"+registerPackage);
+//        }else {
+//        	// 从channelIdMap获取注册包(设备编号)
+//        	String registerPackage = channelIdMap.get(channelId.asLongText());
+//        	// 获取到客户端注册包,可以根据注册包(设备编号)查询数据库唯一的设备信息。
+//        	// 数据就不做解析了,数据解析相关代码在上面分享的博客地址中。
+//        	// 后面就是业务逻辑和数据解析了。
+//        	/** 如果要服务端向客户端发送信息,可以利用客户端心跳机制发送数据(也可以写发送数据的线程),其中具体业务逻辑就需要利用数据库了。
+//        		具体思想:首先数据库保存发送状态和发送数据,利用channelIdMap查询注册包,可以通过注册包在数据库中查询相关数据,
+//        		根据发送状态判断是否需要发送数据。
+//        		Netty发送数据需要转ByteBuf,具体代码:channel.writeAndFlush(Unpooled.copiedBuffer(new byte[]{1, 2, 3})),
+//			*/
+//
+//		}
+//
+//        System.out.println("收到的数据:"+str);
+//        System.out.println("链接数:"+channelGroup.size());
+//        System.out.println("注册包数:"+channelIdMap.size());
+////        channel.writeAndFlush("1F 03 00 2A 00 01 A6 7C");
+////        channel.writeAndFlush(Unpooled.copiedBuffer(hexStr2Bytes("1F 03 00 2A 00 01 A6 7C")));
+//        Thread.sleep(5*1000);
+//        super.channelRead(ctx, msg);
+//    }
+//
+//
+//    @Override
+//    public void channelActive(ChannelHandlerContext ctx) throws Exception {
+//        SocketAddress socketAddress = ctx.channel().remoteAddress();
+//        System.out.println(socketAddress);
+//        super.channelActive(ctx);
+//    }
+//
+//    @Override
+//    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
+//        Channel channel = ctx.channel();
+//        ChannelId channelId = channel.id();
+//        channelIdMap.remove(channelId.asLongText());
+//        System.out.println(channelId.asLongText()+" channelInactive客户端关闭连接");
+//        super.channelInactive(ctx);
+//    }
+//
+//    @Override
+//    public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
+//        super.userEventTriggered(ctx, evt);
+//    }
+//
+//    @Override
+//    public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
+//        // 连接建立
+//        Channel channel = ctx.channel();
+//        channelGroup.add(channel);
+//        super.handlerAdded(ctx);
+//    }
+//
+//    @Override
+//    public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
+//        Channel channel = ctx.channel();
+//        ChannelId channelId = channel.id();
+//        channelIdMap.remove(channelId.asLongText());
+//        System.out.println(channelId.asLongText()+" ChannelHandlerContext客户端关闭连接");
+//        super.handlerRemoved(ctx);
+//    }
+//}

+ 67 - 0
huimv-env-input-water/src/main/java/com/huimv/env/input/server/EnvInputServer.java

@@ -0,0 +1,67 @@
+package com.huimv.env.input.server;
+
+import io.netty.bootstrap.ServerBootstrap;
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.SocketChannel;
+import io.netty.channel.socket.nio.NioServerSocketChannel;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class EnvInputServer {
+    @Autowired
+    private EnvInputServerHandler serverHandler;
+    //监听端口
+    private int port = 3726;
+    //创建构造方法
+    public EnvInputServer(){
+    }
+
+    public static void main(String[] args) throws InterruptedException {
+        new EnvInputServer().run();
+    }
+/**
+ *
+ * 功能描述: 启动方法前台多个服务  处理多个线程
+ *
+ * @param:
+ * @return:
+ * @auther: LiGang
+ * @date: 2019/3/26 11:31
+ */
+    /**
+     * 启动流程
+     */
+    public void run() throws InterruptedException {
+        //配置服务端线程组
+        EventLoopGroup bossGroup=new NioEventLoopGroup();
+        EventLoopGroup workGroup=new NioEventLoopGroup();
+
+        try{
+            //引导整个server的启动
+            ServerBootstrap serverBootstrap = new ServerBootstrap();
+            serverBootstrap.group(bossGroup,workGroup)
+                    .channel(NioServerSocketChannel.class)    //指定处理的连接类型
+                    .childHandler(new ChannelInitializer<SocketChannel>() {
+                        @Override
+                        protected void initChannel(SocketChannel socketChannel) throws Exception {
+                            System.out.println("连接建立");
+                            socketChannel.pipeline().addLast(serverHandler);
+                        }
+                    });
+            System.out.println("# 耳标及采集器设备数据接收服务器已经启动,监听端口(Port):"+port);
+            System.out.println("# 准备接收数据:");
+            //绑定端口,同步等待成功
+            ChannelFuture cf = serverBootstrap.bind(port).sync();
+            // 等待服务端监听端口关闭
+            cf.channel().closeFuture().sync();
+        }finally {
+            //优雅的退出
+            bossGroup.shutdownGracefully();
+            workGroup.shutdownGracefully();
+        }
+    }
+}

+ 264 - 0
huimv-env-input-water/src/main/java/com/huimv/env/input/server/EnvInputServerHandler.java

@@ -0,0 +1,264 @@
+package com.huimv.env.input.server;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.alibaba.fastjson.JSONArray;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.huimv.env.input.entity.Chengzhong;
+import com.huimv.env.input.service.IChengzhongService;
+import com.huimv.env.input.utils.ModBusUtils;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+
+import io.netty.channel.*;
+import io.netty.util.CharsetUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.tomcat.util.codec.binary.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.text.ParseException;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import static com.huimv.env.input.utils.ModBusUtils.hexStr2Bytes;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@ChannelHandler.Sharable
+@Component
+@Slf4j
+public class EnvInputServerHandler extends ChannelInboundHandlerAdapter {
+    private StringBuilder askTextSb = null;
+
+    @Autowired
+    private IChengzhongService chengzhongService;
+
+    //
+    public void appendClientAsk(String text) {
+        if (this.askTextSb == null) {
+            askTextSb = new StringBuilder();
+        }
+        askTextSb.append(text);
+    }
+
+    @Override
+    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
+        Channel channel = ctx.channel();
+        ByteBuf byteBuf = (ByteBuf) msg;
+
+        byte[] bytes = new byte[byteBuf.readableBytes()];
+        byteBuf.readBytes(bytes);
+        String str = ModBusUtils.bytes2HexString(bytes);
+        saveWeight(str);
+        System.out.println("收到的数据:"+str);
+        Thread.sleep(10*1000);
+//        channel.writeAndFlush(Unpooled.copiedBuffer(hexStr2Bytes("1F 03 00 2A 00 01 A6 7C")));
+        channel.writeAndFlush(Unpooled.copiedBuffer(hexStr2Bytes("01 42 3F 02 0D")));
+        super.channelRead(ctx, msg);
+    }
+    private void saveWeight(String str) {
+        try {
+            if (null != str && str.split(" ").length > 7){
+                String[] s = str.split(" ");
+
+                String macAddr = s[0]+s[1]+ s[2]+s[3]+ s[4]+s[5];
+                Integer i = countWeight(s);
+                Chengzhong chengzhong = new Chengzhong();
+                chengzhong.setCreatTime(new Date());
+                chengzhong.setMacAddr(macAddr);
+//                int i = Integer.parseInt(weight, 16);
+             /*   if (i>60000){
+                    i=0;
+                }*/
+                chengzhong.setWeight(i);
+                Chengzhong one = chengzhongService.getOne(new QueryWrapper<Chengzhong>().orderByDesc("id").eq("mac_addr", macAddr).last("limit 1"));
+                int num = i;
+                if (ObjectUtil.isNotEmpty(one)){
+                    num = i -one.getWeight();
+                }
+                System.out.println(i);
+                chengzhong.setNum(num);
+                chengzhongService.save(chengzhong);
+            }
+        }catch (Exception e){
+            System.out.println(e);
+        }
+
+    }
+
+    private Integer countWeight(String[] s) {
+        int count = 48;
+        return (Integer.parseInt(s[8], 16) -count)
+                 +((Integer.parseInt(s[9], 16) -count) * 16)
+                 +((Integer.parseInt(s[10], 16) -count) * 256)
+                 +((Integer.parseInt(s[11], 16) -count) * 4096)
+                 +((Integer.parseInt(s[12], 16) -count) * 6556);
+    }
+
+    @Override
+    public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
+
+//        if (true){
+//            ctx.writeAndFlush(Unpooled.copiedBuffer(new byte[]{1, 2, 3}));
+//        }
+
+//        if (askTextSb.toString().indexOf("end") != -1) {
+//            // {处理客户端消息}
+
+
+//            handleClientAskCmd(askTextSb.toString(), ctx);
+//            //清空重置;
+//            askTextSb.delete(0, askTextSb.length());
+//        }
+    }
+
+    @Override
+    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
+        if (cause.getMessage().indexOf("Connection reset") != -1) {
+            log.info("相关采集器设备正在重启:" + cause.toString());
+        }
+//        cause.printStackTrace();
+        ctx.close();
+    }
+
+    /**
+     * @Method : handleClientAskCmd
+     * @Description : 处理请求小心
+     * @Params : [clientAskText, ctx]
+     * @Return : void
+     * @Author : ZhuoNing
+     * @Date : 2022/3/28
+     * @Time : 17:36
+     */
+    private void handleClientAskCmd(String clientAskText, ChannelHandlerContext ctx) throws ParseException, IOException {
+        clientAskText = clientAskText.replaceAll("\r", "").replaceAll("\n", "");
+        //{处理非正常命令}
+//        int countPlus = regexUtil.countPlus(clientAskText);
+//        if (countPlus < 4) {
+//            System.out.println("当前数据为不完整数据,故丢弃.>>" + clientAskText);
+//        } else {
+        //--处理客户端请求数据
+        //{拆分粘包数据}
+        JSONArray askJa = parseAskCmdPackage(clientAskText);
+        for (int a = 0; a < askJa.size(); a++) {
+            String askText = askJa.getString(a);
+            //{处理请求命令}
+            askCmdActuator(askText, ctx);
+        }
+//        }
+    }
+
+    /**
+     * @Method : askCmdActuator
+     * @Description :
+     * @Params : [askText, ctx]
+     * @Return : void
+     * @Author : ZhuoNing
+     * @Date : 2022/3/23
+     * @Time : 18:08
+     */
+    private void askCmdActuator(String askText, ChannelHandlerContext ctx) throws ParseException, IOException {
+        System.out.println("======>接收设备请求:" + askText);
+        String[] dataArray = askText.split("\\+");
+        String cmdHeader = dataArray[0];
+        if (!cmdHeader.trim().equalsIgnoreCase("hm")) {
+            log.info("当前命令是非hm命令[" + askText + "]");
+            return;
+        }
+        //芯片id/设备编码
+        String idCode = dataArray[1];
+        String cmd = dataArray[2];
+        Map map = new HashMap();
+        map.put("askText", askText);
+        switch (cmd) {
+            case "1":
+                //获取远程设备编码
+                getDeviceCode(askText, idCode, ctx);
+                break;
+            case "2":
+                //同步时间
+                getServerTime(askText, idCode, ctx);
+                break;
+            default:
+                System.out.println("==>未知命令");
+                log.error(">>当前数据为非法数据-未知命令>>" + askText);
+        }
+    }
+
+
+
+    //时间同步请求
+    private void getServerTime(String askText, String deviceCode, ChannelHandlerContext ctx) throws ParseException {
+        System.out.println("==>时间同步请求:" + askText);
+//        if (!cmdProService.isEffectiveDevice(deviceCode)) {
+//            System.out.println("##时间同步请求-未注册设备 idCode=" + deviceCode);
+//            return;
+//        }
+        String answerText = "hm+2+"  + "+0+4+end";
+//        log.info(">>时间同步请求-应答数据>>" + answerText);
+        answerCmd(answerText, ctx);
+    }
+
+    //获取远程设备编码
+    private void getDeviceCode(String askText, String idCode, ChannelHandlerContext ctx) {
+        System.out.println("==>获取远程设备编码请求:" + askText.trim());
+        //{读取设备编码}
+//        String deviceCode = cmdProService.getDeviceCodeByChipId(idCode);
+//        log.info("获取远程设备编码请求,芯片id>>" + idCode + " ,deviceCode>>" + deviceCode);
+//        if (deviceCode == null) {
+//            log.error("该设备未注册,已舍弃请求.");
+//            return;
+//        }
+//        String answerText = "hm+1+0+" + deviceCode + "+123+8+end";
+//        log.info("<<获取远程设备编码请求-应答数据:" + answerText);
+        //{应答指令}
+//        answerCmd(answerText, ctx);
+    }
+
+    //应答
+    public void answerCmd(String answerText, ChannelHandlerContext ctx) {
+        ctx.writeAndFlush(Unpooled.copiedBuffer(answerText.getBytes()));
+    }
+
+    //检查无效耳标
+    public boolean checkValidEarmark(String earmark) {
+        if (earmark.trim().equalsIgnoreCase("ffffffffffffffff") || earmark.trim().equalsIgnoreCase("0000000000000000")) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    //拆分粘包数据
+    public JSONArray parseAskCmdPackage(String text) {
+        String key = "end";
+        Pattern pattern = Pattern.compile(key);
+        Matcher matcher = pattern.matcher(text);
+        int count = 0;
+        while (matcher.find()) {
+            count++;
+        }
+        JSONArray dataJa = new JSONArray();
+        if (count == 1) {
+            dataJa.add(text);
+        } else {
+            for (int a = 0; a < count; a++) {
+                int p1 = text.indexOf("end");
+                dataJa.add(text.substring(0, p1 + 3));
+                text = text.substring(p1 + 3, text.length());
+            }
+        }
+        return dataJa;
+    }
+}

+ 16 - 0
huimv-env-input-water/src/main/java/com/huimv/env/input/service/IChengzhongService.java

@@ -0,0 +1,16 @@
+package com.huimv.env.input.service;
+
+import com.huimv.env.input.entity.Chengzhong;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author author
+ * @since 2023-03-11
+ */
+public interface IChengzhongService extends IService<Chengzhong> {
+
+}

+ 8 - 0
huimv-env-input-water/src/main/java/com/huimv/env/input/service/ICommandProcessorService.java

@@ -0,0 +1,8 @@
+//package com.huimv.env.input.service;
+//
+//public interface ICommandProcessorService {
+//
+//    String getDeviceCodeByChipId(String idCode);
+//
+//    boolean isEffectiveDevice(String idCode);
+//}

+ 20 - 0
huimv-env-input-water/src/main/java/com/huimv/env/input/service/impl/ChengzhongServiceImpl.java

@@ -0,0 +1,20 @@
+package com.huimv.env.input.service.impl;
+
+import com.huimv.env.input.entity.Chengzhong;
+import com.huimv.env.input.mapper.ChengzhongMapper;
+import com.huimv.env.input.service.IChengzhongService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author author
+ * @since 2023-03-11
+ */
+@Service
+public class ChengzhongServiceImpl extends ServiceImpl<ChengzhongMapper, Chengzhong> implements IChengzhongService {
+
+}

+ 19 - 0
huimv-env-input-water/src/main/java/com/huimv/env/input/service/impl/CommandProcessorServiceImpl.java

@@ -0,0 +1,19 @@
+//package com.huimv.env.input.service.impl;
+//
+//import com.huimv.env.input.service.ICommandProcessorService;
+//import com.huimv.env.common.service.IDeviceRegisterService;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.stereotype.Service;
+//
+///**
+// * @Project : huimv.shiwan
+// * @Package : com.huimv.biosafety.uface.controller
+// * @Description : TODO
+// * @Version : 1.0
+// * @Author : ZhuoNing
+// * @Create : 2020-12-25
+// **/
+//@Service
+//public class CommandProcessorServiceImpl implements ICommandProcessorService {
+//
+//}

+ 187 - 0
huimv-env-input-water/src/main/java/com/huimv/env/input/utils/DateUtil2.java

@@ -0,0 +1,187 @@
+//package com.huimv.env.input.utils;
+//
+//import cn.hutool.core.date.DateTime;
+//import lombok.extern.slf4j.Slf4j;
+//import org.springframework.stereotype.Component;
+//
+//import java.text.ParseException;
+//import java.text.SimpleDateFormat;
+//import java.util.ArrayList;
+//import java.util.Calendar;
+//import java.util.Date;
+//
+///**
+// * @Project : huimv.shiwan
+// * @Package : com.huimv.biosafety.uface.controller
+// * @Description : TODO
+// * @Version : 1.0
+// * @Author : ZhuoNing
+// * @Create : 2020-12-25
+// **/
+//@Component
+//@Slf4j
+//public class DateUtil2 {
+//
+//    //格式化日期(Long --> Date)
+//    public String formatLongToDate(Long longDate){
+//        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+//        Date date= new Date(longDate);
+//        return df.format(date);
+//    }
+//
+//    //格式化本年
+//    public String getThisYear(){
+//        Calendar cal = Calendar.getInstance();
+//        int year = cal.get(Calendar.YEAR);
+//        return String.valueOf(year);
+//    }
+//
+//    //格式化本月
+//    public String getThisMonth(){
+//        Calendar cal = Calendar.getInstance();
+//        int month = cal.get(Calendar.MONTH) + 1;
+//        if(String.valueOf(month).length()==1)
+//        {
+//            return "0"+String.valueOf(month);
+//        }else{
+//            return String.valueOf(month);
+//        }
+//    }
+//
+//    //格式化日期时间
+//    public String formatDateTime(String dateText) throws ParseException {
+//        if(dateText.indexOf("T") != -1){
+//            dateText = dateText.replace("T"," ");
+//        }
+//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+//        Date date = sdf.parse(dateText);
+//        return sdf.format(date);
+//    }
+//
+//    public Date parseDateTime(String dateText) throws ParseException {
+//        if(dateText.indexOf("T") != -1){
+//            dateText = dateText.replace("T"," ");
+//        }
+//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+//        return sdf.parse(dateText);
+//    }
+//
+//    public Long parseDateTimeLong(String dateText) throws ParseException {
+//        if(dateText.indexOf("T") != -1){
+//            dateText = dateText.replace("T"," ");
+//        }
+//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+//        Date date = sdf.parse(dateText);
+//        return date.getTime();
+//    }
+//
+//    //
+//    public Date getTodayDate() throws ParseException {
+//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+//        return sdf.parse(sdf.format(new Date()));
+//    }
+//
+//    public Date getTodayDatetime() throws ParseException {
+//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+//        return sdf.parse(sdf.format(new Date()));
+//    }
+//
+//    public String getTodayDateText() throws ParseException {
+//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+//        return sdf.format(new Date());
+//    }
+//
+//    public String getTodayText() throws ParseException {
+//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+//        return sdf.format(new Date());
+//    }
+//
+//    public String getNowText() throws ParseException {
+//        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
+//        return sdf.format(new Date());
+//    }
+//
+//    public String getTodayMissionText() throws ParseException {
+//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
+//        return sdf.format(new Date());
+//    }
+//
+//    public String getStartDateInThisMonth(){
+//        DateTime date = cn.hutool.core.date.DateUtil.date();
+//        return (cn.hutool.core.date.DateUtil.beginOfMonth(date) + "").substring(0, 10);
+//    }
+//
+//    public String getEndDateInThisMonth(){
+//        DateTime date = cn.hutool.core.date.DateUtil.date();
+//        return (date + "").substring(0, 10);
+//    }
+//
+//    /**
+//     * 获取过去或者未来 任意天内的日期数组
+//     * @param intervals      intervals天内
+//     * @return              日期数组
+//     */
+//    public ArrayList<String> test(int intervals ) {
+//        ArrayList<String> pastDaysList = new ArrayList<>();
+//        ArrayList<String> fetureDaysList = new ArrayList<>();
+//        for (int i = 0; i <intervals; i++) {
+//            pastDaysList.add(getPastDate(i));
+//            fetureDaysList.add(getFetureDate(i));
+//        }
+//        return pastDaysList;
+//    }
+//
+//    /**
+//     * 获取过去第几天的日期
+//     *
+//     * @param past
+//     * @return
+//     */
+//    public String getPastDate(int past) {
+//        Calendar calendar = Calendar.getInstance();
+//        calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - past);
+//        Date today = calendar.getTime();
+//        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+//        String result = format.format(today);
+//        return result;
+//    }
+//
+//    /**
+//     * 获取未来 第 past 天的日期
+//     * @param past
+//     * @return
+//     */
+//    public String getFetureDate(int past) {
+//        Calendar calendar = Calendar.getInstance();
+//        calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) + past);
+//        Date today = calendar.getTime();
+//        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+//        String result = format.format(today);
+//        return result;
+//    }
+//
+//    //重新构建日期
+//    public String rebuildDateTime(String text){
+//        return text.substring(0,4)+"-"+text.substring(4,6)+"-"+text.substring(6,8)+" "+text.substring(8,10)+":"+text.substring(10,12)+":"+text.substring(12,14);
+//    }
+//
+//    public static void main(String[] args){
+//        DateUtil2 du = new DateUtil2();
+//        //
+//        du.test1();
+//    }
+//
+//    private void test1() {
+//        String text = "20211201104300";
+////        String text = "1234567890abcd";
+//        String date = text.substring(0,4)+"-"+text.substring(4,6)+"-"+text.substring(6,8)+" "+text.substring(8,10)+":"+text.substring(10,12)+":"+text.substring(12,14);
+//        System.out.println("date="+date);
+//    }
+//
+//    //获取long时间
+//    public Long getNowLong(){
+//        Calendar calendar = Calendar.getInstance();
+//        calendar.set(calendar.get(Calendar.YEAR),calendar.get(Calendar.MONTH),calendar.get(Calendar.DAY_OF_MONTH)-1,0,0,0);
+//        return calendar.getTime().getTime();
+//    }
+//}

+ 55 - 0
huimv-env-input-water/src/main/java/com/huimv/env/input/utils/ModBusUtils.java

@@ -0,0 +1,55 @@
+package com.huimv.env.input.utils;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * TODO
+ *
+ * @author linfeng
+ * @date 2022/12/8 16:04
+ */
+public class ModBusUtils {
+
+    public static char byteToASCLL(byte b) {
+        return (char) b;
+    }
+
+
+    /*
+     * 字节数组转16进制字符串
+     */
+    public static 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;
+    }
+    public static byte[] hexStr2Bytes(String src) {
+        src = src.replaceAll(" ", "");
+        System.out.println(src);
+        int m = 0, n = 0;
+        int l = src.length() / 2;
+        byte[] ret = new byte[l];
+        for (int i = 0; i < l; i++) {
+            m = i * 2 + 1;
+            n = m + 1;
+            String sss = "0x" + src.substring(i * 2, m) + src.substring(m, n);
+            try {
+                ret[i] = Byte.decode(sss);
+            } catch (Exception e) {
+                // TODO: handle exception
+                int s = Integer.decode(sss);
+                ret[i] = (byte)s;
+            }
+        }
+        return ret;
+    }
+}
+

+ 79 - 0
huimv-env-input-water/src/main/java/com/huimv/env/input/utils/Result.java

@@ -0,0 +1,79 @@
+package com.huimv.env.input.utils;
+
+import java.io.Serializable;
+
+public class Result implements Serializable {
+
+    private boolean success;
+    private Integer code;
+    private String message;
+
+    public boolean isSuccess() {
+        return success;
+    }
+
+    public void setSuccess(boolean success) {
+        this.success = success;
+    }
+
+    public Integer getCode() {
+        return code;
+    }
+
+    public void setCode(Integer code) {
+        this.code = code;
+    }
+
+    public String getMessage() {
+        return message;
+    }
+
+    public void setMessage(String message) {
+        this.message = message;
+    }
+
+    public Object getData() {
+        return data;
+    }
+
+    public void setData(Object data) {
+        this.data = data;
+    }
+
+    private Object data;
+
+    //不需要返回数据时使用
+    public Result(ResultCode code) {
+        this.success = code.success;
+        this.code = code.code;
+        this.message = code.message;
+    }
+
+    public Result(ResultCode code, Object data) {
+        this.success = code.success;
+        this.code = code.code;
+        this.message = code.message;
+        this.data = data;
+    }
+
+    public Result(Integer code, String message, boolean success) {
+        this.code = code;
+        this.message = message;
+        this.success = success;
+    }
+
+    /*
+     * 调用ResultCode类封装常用的返回数据
+     */
+    public static Result SUCCESS(){
+        return new Result(ResultCode.SUCCESS);
+    }
+
+    public static Result ERROR(){
+        return new Result(ResultCode.SERVER_ERROR);
+    }
+
+    public static Result FAIL(){
+        return new Result(ResultCode.FAIL);
+    }
+}

+ 41 - 0
huimv-env-input-water/src/main/java/com/huimv/env/input/utils/ResultCode.java

@@ -0,0 +1,41 @@
+package com.huimv.env.input.utils;
+
+public enum ResultCode {
+    SUCCESS(true,10000,"操作成功!"),
+    //---系统错误返回码-----
+    FAIL(false,10001,"操作失败"),
+    UNAUTHENTICATED(false,10002,"您还未登录"),
+    UNAUTHORISE(false,10003,"权限不足"),
+    SERVER_ERROR(false,99999,"抱歉,系统繁忙,请稍后重试!"),
+    DATA_NULL(false,10004,"数据为空"),
+    //---用户操作返回码  2xxxx----
+    MOBILEORPASSWORDERROR(false,20001,"用户名或密码错误");
+    //---企业操作返回码  3xxxx----
+    //---权限操作返回码----
+    //---其他操作返回码----
+
+    //操作是否成功
+    boolean success;
+    //操作代码
+    int code;
+    //提示信息
+    String message;
+
+    ResultCode(boolean success,int code, String message){
+        this.success = success;
+        this.code = code;
+        this.message = message;
+    }
+
+    public boolean success() {
+        return success;
+    }
+
+    public int code() {
+        return code;
+    }
+
+    public String message() {
+        return message;
+    }
+}

+ 105 - 0
huimv-env-input-water/src/main/resources/application-dev.yml

@@ -0,0 +1,105 @@
+server:
+  port: 8091
+
+spring:
+  application:
+    name: huimv-env-input
+
+  datasource:
+    url: jdbc:mysql://115.238.57.190:3306/huimv?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+    username: root
+    password: hm123456
+    driver-class-name: com.mysql.cj.jdbc.Driver
+  jpa:
+    show-sql: true
+    database: mysql
+    hibernate:
+      ddl-auto: update
+    database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
+    open-in-view: true
+
+  #配置rabbitMq 服务器
+#  rabbitmq:
+#    host: 10.0.0.4
+#    port: 5672
+#    username: huimv
+#    password: hm123456
+#    #虚拟host 可以不设置,使用server默认host
+#    virtual-host: /
+  rabbitmq:
+#    host: 192.168.1.82
+    host: 121.36.134.218
+    port: 5672
+    username: admin
+    password: admin
+    #虚拟host 可以不设置,使用server默认host
+    virtual-host: /env
+
+    #确认消息已发送到交换机(Exchange)
+#    publisher-confirms: true #(过时、弃用)
+    publisher-confirm-type: correlated
+    #确认消息已发送到队列(Queue)
+    publisher-returns: true
+
+  #redis
+#  redis:
+#    database: 0
+#    host: 192.168.1.68
+#    port: 6379
+#    password: hm123456
+#    timeout: 5000ms
+#    jedis:
+#      pool:
+#        max-active: 20
+#        max-wait: -1
+#        max-idle: 10
+#        min-idle: 0
+#    lettuce:
+#      pool:
+#        max-active: 3
+#        min-idle: 2
+#        max-idle: 3
+#        max-wait: 1
+#      shutdown-timeout: 100
+
+#  data:
+#    redis:
+#      repositories:
+#        enabled: false
+
+  #是否缓存空值
+#  cache:
+#    redis:
+#      cache-null-values: false
+
+
+
+    #server:
+#  port: 9110
+#spring:
+#  application:
+#    name: huimv-hy-autoGetData
+#
+#  datasource:
+##    url: jdbc:mysql://47.98.175.112:3306/huimv_ql_farm_haiyan?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+#    #    url: jdbc:mysql://36.22.189.214:3306/huimv_ql_farm?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+#        url: jdbc:mysql://192.168.1.7:3306/huimv_ql_farm?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+#    username: root
+#    password: hm123456
+#    driver-class-name: com.mysql.cj.jdbc.Driver
+#  jpa:
+#    properties:
+#      hibernate:
+#        enable_lazy_load_no_trans: true
+#    show-sql: true
+#    database: mysql
+#    hibernate:
+#      ddl-auto: update
+#    database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
+#    open-in-view: true
+management:
+  endpoints:
+    web:
+      exposure:
+        include: "*"   # * 在yaml 文件属于关键字,所以需要加引号
+

+ 89 - 0
huimv-env-input-water/src/main/resources/application-prod.yml

@@ -0,0 +1,89 @@
+server:
+  port: 8091
+
+spring:
+  application:
+    name: huimv-env-input
+
+  datasource:
+    url: jdbc:mysql://122.112.224.199:3306/huimv?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+    username: root
+    password: hm123456
+    driver-class-name: com.mysql.cj.jdbc.Driver
+  jpa:
+    show-sql: true
+    database: mysql
+    hibernate:
+      ddl-auto: update
+    database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
+    open-in-view: true
+
+  #配置rabbitMq 服务器
+#  rabbitmq:
+#    host: 10.0.0.4
+#    port: 5672
+#    username: huimv
+#    password: hm123456
+#    #虚拟host 可以不设置,使用server默认host
+#    virtual-host: /
+  rabbitmq:
+    host: 121.36.134.218
+    port: 5672
+    username: admin
+    password: admin
+    #虚拟host 可以不设置,使用server默认host
+    virtual-host: /env
+
+    #确认消息已发送到交换机(Exchange)
+#    publisher-confirms: true #(过时、弃用)
+    publisher-confirm-type: correlated
+    #确认消息已发送到队列(Queue)
+    publisher-returns: true
+
+  #redis
+  redis:
+    host: 122.112.224.199
+    port: 6379
+    password: hm123456
+
+  data:
+    redis:
+      repositories:
+        enabled: false
+
+  #是否缓存空值
+  cache:
+    redis:
+      cache-null-values: false
+
+
+
+    #server:
+#  port: 9110
+#spring:
+#  application:
+#    name: huimv-hy-autoGetData
+#
+#  datasource:
+##    url: jdbc:mysql://47.98.175.112:3306/huimv_ql_farm_haiyan?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+#    #    url: jdbc:mysql://36.22.189.214:3306/huimv_ql_farm?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+#        url: jdbc:mysql://192.168.1.7:3306/huimv_ql_farm?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+#    username: root
+#    password: hm123456
+#    driver-class-name: com.mysql.cj.jdbc.Driver
+#  jpa:
+#    properties:
+#      hibernate:
+#        enable_lazy_load_no_trans: true
+#    show-sql: true
+#    database: mysql
+#    hibernate:
+#      ddl-auto: update
+#    database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
+#    open-in-view: true
+management:
+  endpoints:
+    web:
+      exposure:
+        include: "*"   # * 在yaml 文件属于关键字,所以需要加引号
+

+ 33 - 0
huimv-env-input-water/src/main/resources/application.properties

@@ -0,0 +1,33 @@
+spring.profiles.active=prod
+#spring.profiles.active=dev
+netty.server.port=9021
+
+#\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD
+management.endpoints.web.exposure.include=*
+
+#########################################################
+###             \uFFFD\uFFFD\uFFFD\uFFFDundertow\u0221\uFFFD\uFFFDtomcat                ###
+#########################################################
+# \uFFFD\u01F7\uFFFD\uFFFD undertow \uFFFD\uFFFD\u05BE\uFFFD\uFFFD\u012C\uFFFD\uFFFD\u03AA false
+server.undertow.accesslog.enabled=false
+# \uFFFD\uFFFD\uFFFD\u00F7\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u05BE\uFFFD\uFFFD\uFFFD\uFFFD\u013F\u00BC
+server.undertow.accesslog.dir=logs
+# \u05B8\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u07F3\u0335\uFFFD I/0 \uFFFD\u07F3\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u012C\uFFFD\uFFFD\u03AA 2 \uFFFD\uFFFD\uFFFD\uFFFD CPU \uFFFD\u0138\uFFFD\uFFFD\uFFFD
+server.undertow.io-threads=
+# \u05B8\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u07F3\u0338\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u012C\uFFFD\uFFFD\u03AA I/O \uFFFD\u07F3\u0338\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD 8 \uFFFD\uFFFD
+server.undertow.worker-threads=
+# \uFFFD\uFFFD\uFFFD\uFFFD HTTP POST \uFFFD\uFFFD\uFFFD\u0775\uFFFD\uFFFD\uFFFD\uDB8E\uDD36\u0223\uFFFD\u012C\uFFFD\u03F2\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD
+server.undertow.max-http-post-size=0
+
+#########################################################
+###   Actuator Monitor  --   Actuator configuration   ###
+#########################################################
+management.security.enabled=false
+
+# \uFFFD\uFFFD\uFFFD\u0774\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD
+data.input.flow=2
+
+# \uFFFD\u01F7\uFFFD\u0434\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD(1:\u0434\uFFFD\uFFFD 0:\uFFFD\uFFFD\u0434\uFFFD\uFFFD)
+data.test.input=0
+
+

+ 24 - 0
huimv-env-input-water/src/main/resources/assembly.xml

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<assembly>
+    <id>jar-with-dependencies</id>
+    <formats>
+        <format>jar</format>
+    </formats>
+    <includeBaseDirectory>false</includeBaseDirectory>
+    <dependencySets>
+        <!-- 默认的配置 -->
+        <dependencySet>
+            <outputDirectory>/</outputDirectory>
+            <useProjectArtifact>true</useProjectArtifact>
+            <unpack>true</unpack>
+            <scope>runtime</scope>
+        </dependencySet>
+        <!-- 增加scope类型为system的配置 -->
+        <dependencySet>
+            <outputDirectory>/</outputDirectory>
+            <useProjectArtifact>true</useProjectArtifact>
+            <unpack>true</unpack>
+            <scope>system</scope>
+        </dependencySet>
+    </dependencySets>
+</assembly>

+ 12 - 0
huimv-env-input-water/src/main/resources/com/huimv/env/input/ChengzhongMapper.xml

@@ -0,0 +1,12 @@
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.huimv.env.input.mapper.ChengzhongMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.huimv.env.input.entity.Chengzhong">
+        <id column="id" property="id" />
+        <result column="weight" property="weight" />
+        <result column="creat_time" property="creatTime" />
+        <result column="mac_addr" property="macAddr" />
+    </resultMap>
+
+</mapper>

+ 105 - 0
huimv-env-input-water/target/classes/application-dev.yml

@@ -0,0 +1,105 @@
+server:
+  port: 8091
+
+spring:
+  application:
+    name: huimv-env-input
+
+  datasource:
+    url: jdbc:mysql://115.238.57.190:3306/huimv?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+    username: root
+    password: hm123456
+    driver-class-name: com.mysql.cj.jdbc.Driver
+  jpa:
+    show-sql: true
+    database: mysql
+    hibernate:
+      ddl-auto: update
+    database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
+    open-in-view: true
+
+  #配置rabbitMq 服务器
+#  rabbitmq:
+#    host: 10.0.0.4
+#    port: 5672
+#    username: huimv
+#    password: hm123456
+#    #虚拟host 可以不设置,使用server默认host
+#    virtual-host: /
+  rabbitmq:
+#    host: 192.168.1.82
+    host: 121.36.134.218
+    port: 5672
+    username: admin
+    password: admin
+    #虚拟host 可以不设置,使用server默认host
+    virtual-host: /env
+
+    #确认消息已发送到交换机(Exchange)
+#    publisher-confirms: true #(过时、弃用)
+    publisher-confirm-type: correlated
+    #确认消息已发送到队列(Queue)
+    publisher-returns: true
+
+  #redis
+#  redis:
+#    database: 0
+#    host: 192.168.1.68
+#    port: 6379
+#    password: hm123456
+#    timeout: 5000ms
+#    jedis:
+#      pool:
+#        max-active: 20
+#        max-wait: -1
+#        max-idle: 10
+#        min-idle: 0
+#    lettuce:
+#      pool:
+#        max-active: 3
+#        min-idle: 2
+#        max-idle: 3
+#        max-wait: 1
+#      shutdown-timeout: 100
+
+#  data:
+#    redis:
+#      repositories:
+#        enabled: false
+
+  #是否缓存空值
+#  cache:
+#    redis:
+#      cache-null-values: false
+
+
+
+    #server:
+#  port: 9110
+#spring:
+#  application:
+#    name: huimv-hy-autoGetData
+#
+#  datasource:
+##    url: jdbc:mysql://47.98.175.112:3306/huimv_ql_farm_haiyan?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+#    #    url: jdbc:mysql://36.22.189.214:3306/huimv_ql_farm?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+#        url: jdbc:mysql://192.168.1.7:3306/huimv_ql_farm?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+#    username: root
+#    password: hm123456
+#    driver-class-name: com.mysql.cj.jdbc.Driver
+#  jpa:
+#    properties:
+#      hibernate:
+#        enable_lazy_load_no_trans: true
+#    show-sql: true
+#    database: mysql
+#    hibernate:
+#      ddl-auto: update
+#    database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
+#    open-in-view: true
+management:
+  endpoints:
+    web:
+      exposure:
+        include: "*"   # * 在yaml 文件属于关键字,所以需要加引号
+

+ 89 - 0
huimv-env-input-water/target/classes/application-prod.yml

@@ -0,0 +1,89 @@
+server:
+  port: 8091
+
+spring:
+  application:
+    name: huimv-env-input
+
+  datasource:
+    url: jdbc:mysql://122.112.224.199:3306/huimv?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+    username: root
+    password: hm123456
+    driver-class-name: com.mysql.cj.jdbc.Driver
+  jpa:
+    show-sql: true
+    database: mysql
+    hibernate:
+      ddl-auto: update
+    database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
+    open-in-view: true
+
+  #配置rabbitMq 服务器
+#  rabbitmq:
+#    host: 10.0.0.4
+#    port: 5672
+#    username: huimv
+#    password: hm123456
+#    #虚拟host 可以不设置,使用server默认host
+#    virtual-host: /
+  rabbitmq:
+    host: 121.36.134.218
+    port: 5672
+    username: admin
+    password: admin
+    #虚拟host 可以不设置,使用server默认host
+    virtual-host: /env
+
+    #确认消息已发送到交换机(Exchange)
+#    publisher-confirms: true #(过时、弃用)
+    publisher-confirm-type: correlated
+    #确认消息已发送到队列(Queue)
+    publisher-returns: true
+
+  #redis
+  redis:
+    host: 122.112.224.199
+    port: 6379
+    password: hm123456
+
+  data:
+    redis:
+      repositories:
+        enabled: false
+
+  #是否缓存空值
+  cache:
+    redis:
+      cache-null-values: false
+
+
+
+    #server:
+#  port: 9110
+#spring:
+#  application:
+#    name: huimv-hy-autoGetData
+#
+#  datasource:
+##    url: jdbc:mysql://47.98.175.112:3306/huimv_ql_farm_haiyan?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+#    #    url: jdbc:mysql://36.22.189.214:3306/huimv_ql_farm?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+#        url: jdbc:mysql://192.168.1.7:3306/huimv_ql_farm?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+#    username: root
+#    password: hm123456
+#    driver-class-name: com.mysql.cj.jdbc.Driver
+#  jpa:
+#    properties:
+#      hibernate:
+#        enable_lazy_load_no_trans: true
+#    show-sql: true
+#    database: mysql
+#    hibernate:
+#      ddl-auto: update
+#    database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
+#    open-in-view: true
+management:
+  endpoints:
+    web:
+      exposure:
+        include: "*"   # * 在yaml 文件属于关键字,所以需要加引号
+

+ 33 - 0
huimv-env-input-water/target/classes/application.properties

@@ -0,0 +1,33 @@
+spring.profiles.active=prod
+#spring.profiles.active=dev
+netty.server.port=9021
+
+#\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD
+management.endpoints.web.exposure.include=*
+
+#########################################################
+###             \uFFFD\uFFFD\uFFFD\uFFFDundertow\u0221\uFFFD\uFFFDtomcat                ###
+#########################################################
+# \uFFFD\u01F7\uFFFD\uFFFD undertow \uFFFD\uFFFD\u05BE\uFFFD\uFFFD\u012C\uFFFD\uFFFD\u03AA false
+server.undertow.accesslog.enabled=false
+# \uFFFD\uFFFD\uFFFD\u00F7\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u05BE\uFFFD\uFFFD\uFFFD\uFFFD\u013F\u00BC
+server.undertow.accesslog.dir=logs
+# \u05B8\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u07F3\u0335\uFFFD I/0 \uFFFD\u07F3\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u012C\uFFFD\uFFFD\u03AA 2 \uFFFD\uFFFD\uFFFD\uFFFD CPU \uFFFD\u0138\uFFFD\uFFFD\uFFFD
+server.undertow.io-threads=
+# \u05B8\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u07F3\u0338\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u012C\uFFFD\uFFFD\u03AA I/O \uFFFD\u07F3\u0338\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD 8 \uFFFD\uFFFD
+server.undertow.worker-threads=
+# \uFFFD\uFFFD\uFFFD\uFFFD HTTP POST \uFFFD\uFFFD\uFFFD\u0775\uFFFD\uFFFD\uFFFD\uDB8E\uDD36\u0223\uFFFD\u012C\uFFFD\u03F2\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD
+server.undertow.max-http-post-size=0
+
+#########################################################
+###   Actuator Monitor  --   Actuator configuration   ###
+#########################################################
+management.security.enabled=false
+
+# \uFFFD\uFFFD\uFFFD\u0774\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD
+data.input.flow=2
+
+# \uFFFD\u01F7\uFFFD\u0434\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD(1:\u0434\uFFFD\uFFFD 0:\uFFFD\uFFFD\u0434\uFFFD\uFFFD)
+data.test.input=0
+
+

+ 24 - 0
huimv-env-input-water/target/classes/assembly.xml

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<assembly>
+    <id>jar-with-dependencies</id>
+    <formats>
+        <format>jar</format>
+    </formats>
+    <includeBaseDirectory>false</includeBaseDirectory>
+    <dependencySets>
+        <!-- 默认的配置 -->
+        <dependencySet>
+            <outputDirectory>/</outputDirectory>
+            <useProjectArtifact>true</useProjectArtifact>
+            <unpack>true</unpack>
+            <scope>runtime</scope>
+        </dependencySet>
+        <!-- 增加scope类型为system的配置 -->
+        <dependencySet>
+            <outputDirectory>/</outputDirectory>
+            <useProjectArtifact>true</useProjectArtifact>
+            <unpack>true</unpack>
+            <scope>system</scope>
+        </dependencySet>
+    </dependencySets>
+</assembly>

+ 12 - 0
huimv-env-input-water/target/classes/com/huimv/env/input/ChengzhongMapper.xml

@@ -0,0 +1,12 @@
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.huimv.env.input.mapper.ChengzhongMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.huimv.env.input.entity.Chengzhong">
+        <id column="id" property="id" />
+        <result column="weight" property="weight" />
+        <result column="creat_time" property="creatTime" />
+        <result column="mac_addr" property="macAddr" />
+    </resultMap>
+
+</mapper>

BIN
huimv-env-input-water/target/classes/com/huimv/env/input/HuimvEnvInputApplication.class


BIN
huimv-env-input-water/target/classes/com/huimv/env/input/controller/ChengzhongController.class


BIN
huimv-env-input-water/target/classes/com/huimv/env/input/entity/Chengzhong.class


BIN
huimv-env-input-water/target/classes/com/huimv/env/input/mapper/ChengzhongMapper.class


BIN
huimv-env-input-water/target/classes/com/huimv/env/input/server/EnvInputServer.class


BIN
huimv-env-input-water/target/classes/com/huimv/env/input/server/EnvInputServerHandler.class


BIN
huimv-env-input-water/target/classes/com/huimv/env/input/service/IChengzhongService.class


BIN
huimv-env-input-water/target/classes/com/huimv/env/input/service/impl/ChengzhongServiceImpl.class


BIN
huimv-env-input-water/target/classes/com/huimv/env/input/utils/ModBusUtils.class


BIN
huimv-env-input-water/target/classes/com/huimv/env/input/utils/Result.class


BIN
huimv-env-input-water/target/classes/com/huimv/env/input/utils/ResultCode.class


BIN
huimv-env-input-water/target/huimv-env-input-0.0.1-SNAPSHOT.jar


BIN
huimv-env-input-water/target/huimv-env-input-0.0.1-SNAPSHOT.jar.original


+ 3 - 0
huimv-env-input-water/target/maven-archiver/pom.properties

@@ -0,0 +1,3 @@
+artifactId=huimv-env-input
+groupId=com.huimv
+version=0.0.1-SNAPSHOT

+ 2 - 0
huimv-env-input-water/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst

@@ -0,0 +1,2 @@
+com\huimv\env\input\utils\Result.class
+com\huimv\env\input\utils\ResultCode.class

+ 16 - 0
huimv-env-input-water/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst

@@ -0,0 +1,16 @@
+G:\idea\yxx\huimv-env-input\src\main\java\com\huimv\env\input\server\DtuServer.java
+G:\idea\yxx\huimv-env-input\src\main\java\com\huimv\env\input\service\impl\ChengzhongServiceImpl.java
+G:\idea\yxx\huimv-env-input\src\main\java\com\huimv\env\input\utils\DateUtil2.java
+G:\idea\yxx\huimv-env-input\src\main\java\com\huimv\env\input\producer\Producer.java
+G:\idea\yxx\huimv-env-input\src\main\java\com\huimv\env\input\controller\ChengzhongController.java
+G:\idea\yxx\huimv-env-input\src\main\java\com\huimv\env\input\server\EnvInputServer.java
+G:\idea\yxx\huimv-env-input\src\main\java\com\huimv\env\input\server\DtuServiceHandler.java
+G:\idea\yxx\huimv-env-input\src\main\java\com\huimv\env\input\utils\ModBusUtils.java
+G:\idea\yxx\huimv-env-input\src\main\java\com\huimv\env\input\service\impl\CommandProcessorServiceImpl.java
+G:\idea\yxx\huimv-env-input\src\main\java\com\huimv\env\input\HuimvEnvInputApplication.java
+G:\idea\yxx\huimv-env-input\src\main\java\com\huimv\env\input\service\IChengzhongService.java
+G:\idea\yxx\huimv-env-input\src\main\java\com\huimv\env\input\entity\Chengzhong.java
+G:\idea\yxx\huimv-env-input\src\main\java\com\huimv\env\input\mapper\ChengzhongMapper.java
+G:\idea\yxx\huimv-env-input\src\main\java\com\huimv\env\input\service\ICommandProcessorService.java
+G:\idea\yxx\huimv-env-input\src\main\java\com\huimv\env\input\config\TopicRabbitMQConfig.java
+G:\idea\yxx\huimv-env-input\src\main\java\com\huimv\env\input\server\EnvInputServerHandler.java

+ 112 - 0
huimv-env-input/pom.xml

@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>huimv-env-platform</artifactId>
+        <groupId>com.huimv</groupId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>com.huimv</groupId>
+    <artifactId>huimv-env-input</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+
+    <dependencies>
+        <!-- 排除Tomcat容器 -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+            <!-- 移除掉默认支持的 Tomcat -->
+            <exclusions>
+                <exclusion>
+                    <groupId>org.springframework.boot</groupId>
+                    <artifactId>spring-boot-starter-tomcat</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <!-- 添加 Undertow 容器 -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-undertow</artifactId>
+        </dependency>
+        <!-- JPA -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-jpa</artifactId>
+        </dependency>
+        <!-- mysql -->
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+        </dependency>
+        <!--rabbitmq-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-amqp</artifactId>
+        </dependency>
+        <!-- redis -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-redis</artifactId>
+        </dependency>
+        <!-- actuator -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-actuator</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <!-- fastjson -->
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.huimv</groupId>
+            <artifactId>huimv-env-common</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>io.netty</groupId>
+            <artifactId>netty-all</artifactId>
+        </dependency>
+        <!-- 一方包统一版本管理 -->
+        <dependency>
+            <groupId>com.huimv</groupId>
+            <artifactId>huimv-env-common</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-resources-plugin</artifactId>
+                <version>2.6</version>
+            </plugin>
+        </plugins>
+    </build>
+</project>

+ 33 - 0
huimv-env-input/src/main/java/com/huimv/env/input/HuimvEnvInputApplication.java

@@ -0,0 +1,33 @@
+package com.huimv.env.input;
+
+import com.huimv.env.input.server.EnvInputServer;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.domain.EntityScan;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.ComponentScans;
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@ComponentScans({@ComponentScan("com.huimv.env.common.utils"),
+        @ComponentScan("com.huimv.env.common.service")})
+@EntityScan(value = "com.huimv.env.common.dao.entity")
+@EnableJpaRepositories(basePackages = "com.huimv.env.common.dao.repo")
+@MapperScan(basePackages = "com.huimv.env.common.mapper")
+@SpringBootApplication
+public class HuimvEnvInputApplication {
+    public static void main(String[] args) throws InterruptedException {
+        ApplicationContext applicationContext = SpringApplication.run(HuimvEnvInputApplication.class, args);
+        // EnvInputServer
+        applicationContext.getBean(EnvInputServer.class).run();
+    }
+}

+ 160 - 0
huimv-env-input/src/main/java/com/huimv/env/input/config/TopicRabbitMQConfig.java

@@ -0,0 +1,160 @@
+package com.huimv.env.input.config;
+
+import com.huimv.env.common.utils.Const;
+import org.springframework.amqp.core.Binding;
+import org.springframework.amqp.core.BindingBuilder;
+import org.springframework.amqp.core.Queue;
+import org.springframework.amqp.core.TopicExchange;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@Configuration
+public class TopicRabbitMQConfig {
+    //温度
+    @Bean
+    public Queue tempQueue() {
+        return new Queue(Const.QUEUE_TEMP);
+    }
+    @Bean
+    TopicExchange tempExchange() {
+        return new TopicExchange(Const.EXCHANGE_TEMP);
+    }
+    @Bean
+    Binding bindingTempExchangeMessage() {
+        return BindingBuilder.bind(tempQueue()).to(tempExchange()).with(Const.ROUTING_KEY_TEMP);
+    }
+
+    //湿度
+    @Bean
+    public Queue humiQueue() {
+        return new Queue(Const.QUEUE_HUMI);
+    }
+    @Bean
+    TopicExchange humiExchange() {
+        return new TopicExchange(Const.EXCHANGE_HUMI);
+    }
+    @Bean
+    Binding bindingHumiExchangeMessage() {
+        return BindingBuilder.bind(humiQueue()).to(humiExchange()).with(Const.ROUTING_KEY_HUMI);
+    }
+
+    //氨气
+    @Bean
+    public Queue ammoniaQueue() {
+        return new Queue(Const.QUEUE_AMMONIA);
+    }
+    @Bean
+    TopicExchange ammoniaExchange() {
+        return new TopicExchange(Const.EXCHANGE_AMMONIA);
+    }
+    @Bean
+    Binding bindingAmmoniaExchangeMessage() {
+        return BindingBuilder.bind(ammoniaQueue()).to(ammoniaExchange()).with(Const.ROUTING_KEY_AMMONIA);
+    }
+
+    //传感器
+    @Bean
+    public Queue sensorQueue() {
+        return new Queue(Const.QUEUE_SENSOR);
+    }
+    @Bean
+    TopicExchange sensorExchange() {
+        return new TopicExchange(Const.EXCHANGE_SENSOR);
+    }
+    @Bean
+    Binding bindingSensorExchangeMessage() {
+        return BindingBuilder.bind(sensorQueue()).to(sensorExchange()).with(Const.ROUTING_KEY_SENSOR);
+    }
+
+    //设备状态
+    @Bean
+    public Queue deviceStatusQueue() {
+        return new Queue(Const.QUEUE_DEVICE_STATUS);
+    }
+    @Bean
+    TopicExchange deviceStatusExchange() {
+        return new TopicExchange(Const.EXCHANGE_DEVICE_STATUS);
+    }
+    @Bean
+    Binding bindingDeviceStatusExchangeMessage() {
+        return BindingBuilder.bind(deviceStatusQueue()).to(deviceStatusExchange()).with(Const.ROUTING_KEY_DEVICE_STATUS);
+    }
+
+    //推送短信
+    @Bean
+    public Queue pushMessageQueue() {
+        return new Queue(Const.QUEUE_PUSH_MESSAGE);
+    }
+    @Bean
+    TopicExchange pushMessageExchange() {
+        return new TopicExchange(Const.EXCHANGE_PUSH_MESSAGE);
+    }
+    @Bean
+    Binding bindingPushMessageMessage() {
+        return BindingBuilder.bind(pushMessageQueue()).to(pushMessageExchange()).with(Const.ROUTING_KEY_PUSH_MESSAGE);
+    }
+    //推送水压
+    @Bean
+    public Queue waterGegeQueue() {
+        return new Queue(Const.QUEUE_WATER_GEGE);
+    }
+    @Bean
+    TopicExchange waterGegeExchange() {
+        return new TopicExchange(Const.EXCHANGE_WATER_GEGE);
+    }
+    @Bean
+    Binding bindingWaterGegeExchangeMessage() {
+        return BindingBuilder.bind(waterGegeQueue()).to(waterGegeExchange()).with(Const.ROUTING_KEY_WATER_GEGE);
+    }
+
+    //推送PH
+    @Bean
+    public Queue phGegeQueue() {
+        return new Queue(Const.QUEUE_PH);
+    }
+    @Bean
+    TopicExchange phGegeExchange() {
+        return new TopicExchange(Const.EXCHANGE_PH);
+    }
+    @Bean
+    Binding bindingPhExchangeMessage() {
+        return BindingBuilder.bind(phGegeQueue()).to(phGegeExchange()).with(Const.ROUTING_KEY_PH);
+    }
+
+    //推送水表
+    @Bean
+    public Queue waterMeterQueue() {
+        return new Queue(Const.QUEUE_WATER_METER);
+    }
+    @Bean
+    TopicExchange waterMeterExchange() {
+        return new TopicExchange(Const.EXCHANGE_WATER_METER);
+    }
+    @Bean
+    Binding bindingwaterMeterExchangeMessage() {
+        return BindingBuilder.bind(waterMeterQueue()).to(waterMeterExchange()).with(Const.ROUTING_KEY_WATER_METER);
+    }
+
+
+    //推送电表
+    @Bean
+    public Queue electricityMeterQueue() {
+        return new Queue(Const.QUEUE_ELECTRICITY_METER);
+    }
+    @Bean
+    TopicExchange electricityMeterExchange() {
+        return new TopicExchange(Const.EXCHANGE_ELECTRICITY_METER);
+    }
+    @Bean
+    Binding bindingelectricityMeterExchangeMessage() {
+        return BindingBuilder.bind(electricityMeterQueue()).to(electricityMeterExchange()).with(Const.ROUTING_KEY_ELECTRICITY_METER);
+    }
+}

+ 139 - 0
huimv-env-input/src/main/java/com/huimv/env/input/producer/Producer.java

@@ -0,0 +1,139 @@
+package com.huimv.env.input.producer;
+
+import com.huimv.env.common.utils.Const;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@Component
+@Slf4j
+public class Producer {
+    @Autowired
+    RabbitTemplate rabbitTemplate;  //使用RabbitTemplate,这提供了接收/发送等等方法
+
+    /**
+     * @Method      : sendTempAskToMQ
+     * @Description : 
+     * @Params      : [askText]
+     * @Return      : java.lang.String
+     * 
+     * @Author      : ZhuoNing
+     * @Date        : 2022/8/17       
+     * @Time        : 19:29
+     */
+    public String sendTempAskToMQ(String askText){
+        Map map = new HashMap();
+        map.put("askText",askText);
+        rabbitTemplate.convertAndSend(Const.EXCHANGE_TEMP, Const.ROUTING_KEY_TEMP, map);
+        return "ok";
+    }
+
+    /**
+     * @Method      : sendHumiAskToMQ
+     * @Description : 
+     * @Params      : [askText]
+     * @Return      : java.lang.String
+     * 
+     * @Author      : ZhuoNing
+     * @Date        : 2022/8/17       
+     * @Time        : 19:13
+     */
+    public String sendHumiAskToMQ(String askText){
+        Map map = new HashMap();
+        map.put("askText",askText);
+        rabbitTemplate.convertAndSend(Const.EXCHANGE_HUMI, Const.ROUTING_KEY_HUMI, map);
+        return "ok";
+    }
+
+    /**
+     * @Method      : sendAmmoniaAskToMQ
+     * @Description : 
+     * @Params      : [askText]
+     * @Return      : java.lang.String
+     * 
+     * @Author      : ZhuoNing
+     * @Date        : 2022/8/17       
+     * @Time        : 19:13
+     */
+    public String sendAmmoniaAskToMQ(String askText){
+        Map map = new HashMap();
+        map.put("askText",askText);
+        rabbitTemplate.convertAndSend(Const.EXCHANGE_AMMONIA, Const.ROUTING_KEY_AMMONIA, map);
+        return "ok";
+    }
+
+    /**
+     * @Method      : sendSprayEquipStatusToMQ
+     * @Description : 
+     * @Params      : [askText]
+     * @Return      : java.lang.String
+     * 
+     * @Author      : ZhuoNing
+     * @Date        : 2022/8/18       
+     * @Time        : 20:51
+     */
+    public String sendSprayEquipStatusToMQ(String askText) {
+        Map map = new HashMap();
+        map.put("askText",askText);
+        rabbitTemplate.convertAndSend(Const.EXCHANGE_DEVICE_STATUS, Const.ROUTING_KEY_DEVICE_STATUS, map);
+        return "ok";
+    }
+
+    /**
+     * @Method      : sendPushMessageToMQ
+     * @Description : 
+     * @Params      : [askText]
+     * @Return      : java.lang.String
+     * 
+     * @Author      : ZhuoNing
+     * @Date        : 2022/8/18       
+     * @Time        : 20:52
+     */
+    public String sendPushMessageToMQ(String askText) {
+        Map map = new HashMap();
+        map.put("askText",askText);
+        rabbitTemplate.convertAndSend(Const.EXCHANGE_PUSH_MESSAGE, Const.ROUTING_KEY_PUSH_MESSAGE, map);
+        return "ok";
+    }
+
+    public String sendWaterGege(String askText) {
+
+        Map map = new HashMap();
+        map.put("askText",askText);
+        rabbitTemplate.convertAndSend(Const.EXCHANGE_WATER_GEGE, Const.ROUTING_KEY_WATER_GEGE, map);
+        return "ok";
+    }
+
+    public String sendPHGege(String askText) {
+        Map map = new HashMap();
+        map.put("askText",askText);
+        rabbitTemplate.convertAndSend(Const.EXCHANGE_PH, Const.ROUTING_KEY_PH, map);
+        return "ok";
+    }
+
+    public String sendWaterMeter(String askText) {
+        Map map = new HashMap();
+        map.put("askText",askText);
+        rabbitTemplate.convertAndSend(Const.EXCHANGE_WATER_METER, Const.ROUTING_KEY_WATER_METER, map);
+        return "ok";
+    }
+
+    public String sendElectricityMeter(String askText) {
+        Map map = new HashMap();
+        map.put("askText",askText);
+        rabbitTemplate.convertAndSend(Const.EXCHANGE_ELECTRICITY_METER, Const.ROUTING_KEY_ELECTRICITY_METER, map);
+        return "ok";
+    }
+}

+ 74 - 0
huimv-env-input/src/main/java/com/huimv/env/input/server/EnvInputServer.java

@@ -0,0 +1,74 @@
+package com.huimv.env.input.server;
+
+import io.netty.bootstrap.ServerBootstrap;
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.SocketChannel;
+import io.netty.channel.socket.nio.NioServerSocketChannel;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@Component
+public class EnvInputServer {
+    @Autowired
+    private EnvInputServerHandler serverHandler;
+    //监听端口
+    private int port = 3726;
+    //创建构造方法
+    public EnvInputServer(){
+    }
+
+    public static void main(String[] args) throws InterruptedException {
+        new EnvInputServer().run();
+    }
+/**
+ *
+ * 功能描述: 启动方法前台多个服务  处理多个线程
+ *
+ * @param:
+ * @return:
+ * @auther: LiGang
+ * @date: 2019/3/26 11:31
+ */
+    /**
+     * 启动流程
+     */
+    public void run() throws InterruptedException {
+        //配置服务端线程组
+        EventLoopGroup bossGroup=new NioEventLoopGroup();
+        EventLoopGroup workGroup=new NioEventLoopGroup();
+
+        try{
+            //引导整个server的启动
+            ServerBootstrap serverBootstrap = new ServerBootstrap();
+            serverBootstrap.group(bossGroup,workGroup)
+                    .channel(NioServerSocketChannel.class)    //指定处理的连接类型
+                    .childHandler(new ChannelInitializer<SocketChannel>() {
+                        @Override
+                        protected void initChannel(SocketChannel socketChannel) throws Exception {
+                            socketChannel.pipeline().addLast(serverHandler);
+                        }
+                    });
+            System.out.println("# 耳标及采集器设备数据接收服务器已经启动,监听端口(Port):"+port);
+            System.out.println("# 准备接收数据:");
+            //绑定端口,同步等待成功
+            ChannelFuture cf = serverBootstrap.bind(port).sync();
+            // 等待服务端监听端口关闭
+            cf.channel().closeFuture().sync();
+        }finally {
+            //优雅的退出
+            bossGroup.shutdownGracefully();
+            workGroup.shutdownGracefully();
+        }
+    }
+}

+ 584 - 0
huimv-env-input/src/main/java/com/huimv/env/input/server/EnvInputServerHandler.java

@@ -0,0 +1,584 @@
+package com.huimv.env.input.server;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.huimv.env.common.dao.entity.EnvDeviceEquipment;
+import com.huimv.env.common.dao.entity.EnvDeviceRegisterEntity;
+import com.huimv.env.common.dao.repo.EnvDeviceEqipmentRepo;
+import com.huimv.env.common.service.*;
+import com.huimv.env.common.utils.RegexUtil;
+import com.huimv.env.input.producer.Producer;
+import com.huimv.env.input.service.ICommandProcessorService;
+import com.huimv.env.input.utils.DateUtil2;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+
+import io.netty.channel.ChannelHandler;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInboundHandlerAdapter;
+import io.netty.util.CharsetUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.sql.Timestamp;
+import java.text.ParseException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@ChannelHandler.Sharable
+@Component
+@Slf4j
+public class EnvInputServerHandler extends ChannelInboundHandlerAdapter {
+    @Autowired
+    private RegexUtil regexUtil;
+    @Autowired
+    private ICommandProcessorService cmdProService;
+    @Autowired
+    private DateUtil2 dateUtil;
+    @Autowired
+    private Producer producer;
+    private StringBuilder askTextSb = null;
+    @Autowired
+    private ITempThresholdService tempThresholdService;
+
+    @Autowired
+    private EnvDeviceEqipmentRepo envDeviceEqipmentRepo;
+    @Autowired
+    private IBaseThresholdService baseThresholdService;
+
+
+    //
+    public void appendClientAsk(String text) {
+        if (this.askTextSb == null) {
+            askTextSb = new StringBuilder();
+        }
+        askTextSb.append(text);
+    }
+
+    @Override
+    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
+        ByteBuf data = (ByteBuf) msg;
+        String clientAskText = data.toString(CharsetUtil.UTF_8);
+        //保存实例内的客户端请求
+        appendClientAsk(clientAskText);
+        //临时写入耳标数据到文件
+//        writeTxt(clientAskText,"all");
+    }
+
+    @Override
+    public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
+        if (askTextSb.toString().indexOf("end") != -1) {
+            // {处理客户端消息}
+            handleClientAskCmd(askTextSb.toString(), ctx);
+            //清空重置;
+            askTextSb.delete(0, askTextSb.length());
+        }
+    }
+
+    @Override
+    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
+        if (cause.getMessage().indexOf("Connection reset") != -1) {
+            log.info("相关采集器设备正在重启:" + cause.toString());
+        }
+//        cause.printStackTrace();
+        ctx.close();
+    }
+
+    /**
+     * @Method : handleClientAskCmd
+     * @Description : 处理请求小心
+     * @Params : [clientAskText, ctx]
+     * @Return : void
+     * @Author : ZhuoNing
+     * @Date : 2022/3/28
+     * @Time : 17:36
+     */
+    private void handleClientAskCmd(String clientAskText, ChannelHandlerContext ctx) throws ParseException, IOException {
+        clientAskText = clientAskText.replaceAll("\r", "").replaceAll("\n", "");
+        //{处理非正常命令}
+//        int countPlus = regexUtil.countPlus(clientAskText);
+//        if (countPlus < 4) {
+//            System.out.println("当前数据为不完整数据,故丢弃.>>" + clientAskText);
+//        } else {
+        //--处理客户端请求数据
+        //{拆分粘包数据}
+        JSONArray askJa = parseAskCmdPackage(clientAskText);
+        for (int a = 0; a < askJa.size(); a++) {
+            String askText = askJa.getString(a);
+            //{处理请求命令}
+            askCmdActuator(askText, ctx);
+        }
+//        }
+    }
+
+    /**
+     * @Method : askCmdActuator
+     * @Description :
+     * @Params : [askText, ctx]
+     * @Return : void
+     * @Author : ZhuoNing
+     * @Date : 2022/3/23
+     * @Time : 18:08
+     */
+    private void askCmdActuator(String askText, ChannelHandlerContext ctx) throws ParseException, IOException {
+        System.out.println("======>接收设备请求:" + askText);
+        String[] dataArray = askText.split("\\+");
+        String cmdHeader = dataArray[0];
+        if (!cmdHeader.trim().equalsIgnoreCase("hm")) {
+            log.info("当前命令是非hm命令[" + askText + "]");
+            return;
+        }
+        //芯片id/设备编码
+        String idCode = dataArray[1];
+        String cmd = dataArray[2];
+        Map map = new HashMap();
+        map.put("askText", askText);
+        switch (cmd) {
+            case "1":
+                //获取远程设备编码
+                getDeviceCode(askText, idCode, ctx);
+                break;
+            case "2":
+                //同步时间
+                getServerTime(askText, idCode, ctx);
+                break;
+            case "3":
+                //温度上传数据
+                uploadTemp(askText, idCode, ctx);
+                break;
+            case "4":
+                //上传湿度数据
+                uploadHumi(askText, idCode, ctx);
+                break;
+            case "5":
+                //氨气数据上传
+                uploadAmmonia(askText, idCode, ctx);
+                break;
+            case "6":
+                //获取喷雾除臭配置
+                getSprayConfig(askText, idCode, ctx);
+                break;
+            case "7":
+                //上报喷雾除臭状态
+                uploadSprayEquipStatus(askText, idCode, ctx);
+                break;
+            case "8":
+                //水压
+                uploadWaterGege(askText, idCode, ctx);
+                break;
+            case "9":
+                //PH
+                uploadPH(askText, idCode, ctx);
+                break;
+            case "10":
+                //水表
+                uploadWaterMeter(askText, idCode, ctx);
+                break;
+            case "11":
+                //电表
+                uploadElectricityMeter(askText, idCode, ctx);
+                break;
+            case "12":
+                //获取设备开关
+                getSparySwitch(askText, idCode, ctx);
+                break;
+            case "13":
+                //上报设备状态
+                getSparyStatus(askText, idCode, ctx);
+                break;
+            case "14":
+                //获取报警使能
+                getAlarmConfig(askText, idCode, ctx);
+                break;
+            case "15":
+                //短信发送
+                uploadSendMessage(askText, idCode, ctx);
+                break;
+            case "16":
+                //声光报警短信
+                uploadAudibleAndVisualAlarmMessage(askText, idCode, ctx);
+                break;
+            case "17":
+                //报警器打电话
+                uploadTelephoneAlarm(askText, idCode, ctx);
+                break;
+            case "18":
+                //高温,低温报警参数请求
+                getTempThresholdConfig(askText, idCode, ctx);
+                break;
+            case "19":
+                //平台消息推送
+                uploadPlatformMessagePushInfo(askText, idCode, ctx);
+                break;
+            default:
+                System.out.println("==>未知命令");
+                log.error(">>当前数据为非法数据-未知命令>>" + askText);
+        }
+    }
+    //上报设备状态
+    private void getSparyStatus(String askText, String deviceCode, ChannelHandlerContext ctx) {
+        System.out.println("==>上报设备状态上传请求 askText>>" + askText);
+        if (!cmdProService.isEffectiveDevice(deviceCode)) {
+            System.out.println("##上报设备状态上传请求-未注册设备 deviceCode=" + deviceCode);
+            return;
+        }
+        List<EnvDeviceEquipment> list= envDeviceEqipmentRepo.findAllByDeviceCode(deviceCode);
+        saveDeviceStatus(askText,list);
+        //上报设备状态
+        String answerText = "hm+"+deviceCode+"+13+6+end";
+        log.info(">>上报设备状态上传请求-应答数据>>" + answerText);
+        answerCmd(answerText, ctx);
+    }
+
+    private void saveDeviceStatus(String askText, List<EnvDeviceEquipment> list) {
+        String[] split = askText.split("\\+");
+        String s = split[3];
+        for (EnvDeviceEquipment envDeviceEquipment : list) {
+            Integer equipmentPort = envDeviceEquipment.getEquipmentPort();
+            String c =s.charAt(equipmentPort - 1)+"";
+            envDeviceEquipment.setOpenStart(Integer.parseInt(c));
+            envDeviceEqipmentRepo.save(envDeviceEquipment);
+        }
+    }
+
+    //获取设备开关
+    private void getSparySwitch(String askText, String deviceCode, ChannelHandlerContext ctx) {
+        System.out.println("==>获取设备开关上传请求 askText>>" + askText);
+        if (!cmdProService.isEffectiveDevice(deviceCode)) {
+            System.out.println("##获取设备开关上传请求-未注册设备 deviceCode=" + deviceCode);
+            return;
+        }
+        List<EnvDeviceEquipment> list= envDeviceEqipmentRepo.findAllByDeviceCode(deviceCode);
+        String deviceStatus= getDeviceStatus(list);
+
+        //TODO 获取设备开关请求
+        String answerText = "hm+"+deviceCode+"+12+"+deviceStatus+"+6+end";
+        log.info(">>获取设备开关上传请求-应答数据>>" + answerText);
+        answerCmd(answerText, ctx);
+    }
+
+    private String getDeviceStatus(List<EnvDeviceEquipment> list) {
+        StringBuffer deviceStatus = new StringBuffer("0000000000000000");
+        for (EnvDeviceEquipment envDeviceEquipment : list) {
+
+            Integer equipmentPort = envDeviceEquipment.getEquipmentPort();
+            Integer openStart = envDeviceEquipment.getUploadStart();
+            deviceStatus.replace(equipmentPort -1,equipmentPort,openStart+"");
+        }
+        return deviceStatus.toString();
+    }
+
+    //电表
+    private void uploadElectricityMeter(String askText, String deviceCode, ChannelHandlerContext ctx) {
+        System.out.println("==>电表上传请求 askText>>" + askText);
+        if (!cmdProService.isEffectiveDevice(deviceCode)) {
+            System.out.println("##电表上传请求-未注册设备 deviceCode=" + deviceCode);
+            return;
+        }
+        //电表上传请求
+        String answerText = "hm+11+0+7+end";
+        log.info(">>电表上传请求-应答数据>>" + answerText);
+        answerCmd(answerText, ctx);
+        //电表请求到消息队列
+        producer.sendElectricityMeter(askText);
+    }
+
+    //水表
+    private void uploadWaterMeter(String askText, String deviceCode, ChannelHandlerContext ctx) {
+        System.out.println("==>水表上传请求 askText>>" + askText);
+        if (!cmdProService.isEffectiveDevice(deviceCode)) {
+            System.out.println("##水表上传请求-未注册设备 deviceCode=" + deviceCode);
+            return;
+        }
+        //水表上传请求
+        String answerText = "hm+10+0+7+end";
+        log.info(">>水表上传请求-应答数据>>" + answerText);
+        answerCmd(answerText, ctx);
+        //发送水表请求到消息队列
+        producer.sendWaterMeter(askText);
+    }
+
+    //PH
+    private void uploadPH(String askText, String deviceCode, ChannelHandlerContext ctx) {
+        System.out.println("==>PH上传请求 askText>>" + askText);
+        if (!cmdProService.isEffectiveDevice(deviceCode)) {
+            System.out.println("##PH上传请求-未注册设备 deviceCode=" + deviceCode);
+            return;
+        }
+        //PH传请求
+        String answerText = "hm+9+0+7+end";
+        log.info(">>PH上传请求-应答数据>>" + answerText);
+        answerCmd(answerText, ctx);
+        //发送PH请求到消息队列
+        producer.sendPHGege(askText);
+    }
+
+    //水压
+    private void uploadWaterGege(String askText, String deviceCode, ChannelHandlerContext ctx) {
+        System.out.println("==>水压上传请求 askText>>" + askText);
+        if (!cmdProService.isEffectiveDevice(deviceCode)) {
+            System.out.println("##水压上传请求-未注册设备 deviceCode=" + deviceCode);
+            return;
+        }
+        //水压上传请求
+        String answerText = "hm+8+0+7+end";
+        log.info(">>水压上传请求-应答数据>>" + answerText);
+        answerCmd(answerText, ctx);
+        //水压请求到消息队列
+        producer.sendWaterGege(askText);
+    }
+
+    //平台消息推送请求
+    private void uploadPlatformMessagePushInfo(String askText, String idCode, ChannelHandlerContext ctx) {
+        System.out.println("==>平台消息推送请求 askText>>" + askText);
+        if (!cmdProService.isEffectiveDevice(idCode)) {
+            System.out.println("##平台消息推送请求-未注册设备 idCode=" + idCode);
+            return;
+        }
+        String answerText = "hm+19+0+2+end";
+        log.info(">>平台消息推送请求-应答数据>>" + answerText);
+        answerCmd(answerText, ctx);
+
+        //发送喷雾设备状态到消息队列
+        producer.sendPushMessageToMQ(askText);
+    }
+
+    //高温,低温报警参数请求
+    private void getTempThresholdConfig(String askText, String idCode, ChannelHandlerContext ctx) {
+        System.out.println("==>高温,低温报警参数请求 askText>>" + askText);
+        if (!cmdProService.isEffectiveDevice(idCode)) {
+            System.out.println("##高温,低温报警参数请求-未注册设备 idCode=" + idCode);
+            return;
+        }
+//        String threshold = tempThresholdService.getTempThresholdByDeviceCode(idCode);
+        String threshold = baseThresholdService.getTempThresholdByDeviceCode(idCode);
+        String answerText = "hm+"+idCode+"+18+"+threshold+"+6+end";
+        log.info(">>高温,低温报警参数请求-应答数据>>" + answerText);
+        answerCmd(answerText, ctx);
+    }
+
+    //报警器打电话请求
+    private void uploadTelephoneAlarm(String askText, String idCode, ChannelHandlerContext ctx) {
+        System.out.println("==>报警器打电话请求 askText>>" + askText);
+        if (!cmdProService.isEffectiveDevice(idCode)) {
+            System.out.println("##报警器打电话请求-未注册设备 idCode=" + idCode);
+            return;
+        }
+        String answerText = "hm+17+0+2+end";
+        log.info(">>报警器打电话请求-应答数据>>" + answerText);
+        answerCmd(answerText, ctx);
+    }
+
+    //声光报警短信发送请求
+    private void uploadAudibleAndVisualAlarmMessage(String askText, String idCode, ChannelHandlerContext ctx) {
+        System.out.println("==>声光报警短信发送请求 askText>>" + askText);
+        if (!cmdProService.isEffectiveDevice(idCode)) {
+            System.out.println("##声光报警短信发送请求-未注册设备 idCode=" + idCode);
+            return;
+        }
+        String answerText = "hm+16+0+2+end";
+        log.info(">>声光报警短信发送请求-应答数据>>" + answerText);
+        answerCmd(answerText, ctx);
+    }
+
+    //短信发送请求
+    private void uploadSendMessage(String askText, String idCode, ChannelHandlerContext ctx) {
+        System.out.println("==>短信发送请求 askText>>" + askText);
+        if (!cmdProService.isEffectiveDevice(idCode)) {
+            System.out.println("##>短信发送请求-未注册设备 idCode=" + idCode);
+            return;
+        }
+        String answerText = "hm+15+0+2+end";
+        log.info(">>>短信发送请求-应答数据>>" + answerText);
+        answerCmd(answerText, ctx);
+    }
+
+    //获取报警使能请求
+    private void getAlarmConfig(String askText, String idCode, ChannelHandlerContext ctx) {
+        System.out.println("==>获取报警使能请求 askText>>" + askText);
+        if (!cmdProService.isEffectiveDevice(idCode)) {
+            System.out.println("##获取报警使能请求-未注册设备 idCode=" + idCode);
+            return;
+        }
+        //(声光报警、短信报警、语音报警) 1:关闭,2:打开
+        String answerText = "hm+"+idCode+"+14+2(111)2(111)2(111)2(111)2(111)+0+4+end";
+        log.info(">>获取报警使能请求-应答数据>>" + answerText);
+        answerCmd(answerText, ctx);
+    }
+
+    //上报喷雾除臭状态请求
+    private void uploadSprayEquipStatus(String askText, String idCode, ChannelHandlerContext ctx) {
+        System.out.println("==>上报喷雾除臭状态请求 askText>>" + askText);
+        if (!cmdProService.isEffectiveDevice(idCode)) {
+            System.out.println("##上报喷雾除臭状态请求-未注册设备 idCode=" + idCode);
+            return;
+        }
+        String answerText = "hm+" + idCode + "+7+6+end";
+        log.info(">>上报喷雾除臭状态请求-应答数据>>" + answerText);
+        answerCmd(answerText, ctx);
+        //发送喷雾设备状态到消息队列
+        producer.sendSprayEquipStatusToMQ(askText);
+    }
+
+    @Autowired
+    private ISprayConfigService sprayConfigService;
+    @Autowired
+    private ISprayTimeService sprayTimeService;
+    @Autowired
+    private IDeviceRegisterService deviceRegisterService;
+
+    //获取喷雾除臭配置请求
+    private void getSprayConfig(String askText, String deviceCode, ChannelHandlerContext ctx) {
+        System.out.println("==>获取喷雾除臭配置请求 askText>>" + askText);
+        if (!cmdProService.isEffectiveDevice(deviceCode)) {
+            System.out.println("##获取喷雾除臭配置请求-未注册设备 idCode=" + deviceCode);
+            return;
+        }
+        //读取设备注册信息
+        EnvDeviceRegisterEntity envDeviceRegisterEntity = deviceRegisterService.getDeviceRegisterByDeviceCode(deviceCode);
+        if (envDeviceRegisterEntity == null) {
+            log.error("该设备[" + deviceCode + "]未注册.");
+            return;
+        }
+        java.sql.Date todayDate = new java.sql.Date(new java.util.Date().getTime());
+        Timestamp nowTimestamp = new Timestamp(new java.util.Date().getTime());
+        String farmCode = envDeviceRegisterEntity.getFarmCode();
+
+        //读取喷雾配置表数据
+        JSONObject configJo = sprayConfigService.getSprayConfigByDeviceCode(deviceCode, farmCode);
+        int runMode = configJo.getInteger("runMode");
+        int deviceStatus = configJo.getInteger("deviceStatus");
+        int timeInterval = configJo.getInteger("timeInterval") * 60;
+        //读取定时时间配置表数据
+        String sprayTime = sprayTimeService.getSprayTimeByDeviceCode(deviceCode);
+//        String answerText = "hm+"+deviceCode+"+6+1+1+0101,60,10,10,0202,60,10,10,0303,60,10,10,0404,60,10,10+60+6+end";
+        String answerText = "hm+" + deviceCode + "+6+" + runMode + "+" + deviceStatus + "+" + sprayTime + "+" + timeInterval + "+6+end";
+        log.info("<<获取喷雾除臭配置请求-应答数据<<" + answerText);
+        answerCmd(answerText, ctx);
+    }
+
+    //氨气度上传请求
+    private void uploadAmmonia(String askText, String idCode, ChannelHandlerContext ctx) {
+        System.out.println("==>氨气度上传请求 askText>>" + askText);
+        if (!cmdProService.isEffectiveDevice(idCode)) {
+            System.out.println("##氨气度上传请求-未注册设备 idCode=" + idCode);
+            return;
+        }
+        String answerText = "hm+5+0+8+end";
+        log.info(">>氨气度上传请求-应答数据>>" + answerText);
+        answerCmd(answerText, ctx);
+
+        //发送氨气请求到消息队列
+        producer.sendAmmoniaAskToMQ(askText);
+    }
+
+    //湿度度上传请求
+    private void uploadHumi(String askText, String idCode, ChannelHandlerContext ctx) {
+        System.out.println("==>湿度度上传请求 askText>>" + askText);
+        if (!cmdProService.isEffectiveDevice(idCode)) {
+            System.out.println("##湿度度上传请求-未注册设备 idCode=" + idCode);
+            return;
+        }
+        String answerText = "hm+4+0+8+end";
+        log.info(">>湿度度上传请求-应答数据>>" + answerText);
+        answerCmd(answerText, ctx);
+        //发送湿度请求到消息队列
+        producer.sendHumiAskToMQ(askText);
+    }
+
+    // 温度度上传
+    private void uploadTemp(String askText, String deviceCode, ChannelHandlerContext ctx) {
+        System.out.println("==>温度度上传请求 askText>>" + askText);
+        if (!cmdProService.isEffectiveDevice(deviceCode)) {
+            System.out.println("##温度度上传请求-未注册设备 deviceCode=" + deviceCode);
+            return;
+        }
+        //温度度上传请求
+        String answerText = "hm+3+0+7+end";
+        log.info(">>温度度上传请求-应答数据>>" + answerText);
+        answerCmd(answerText, ctx);
+        //发送温度请求到消息队列
+        producer.sendTempAskToMQ(askText);
+    }
+
+    //时间同步请求
+    private void getServerTime(String askText, String deviceCode, ChannelHandlerContext ctx) throws ParseException {
+        System.out.println("==>时间同步请求:" + askText);
+        if (!cmdProService.isEffectiveDevice(deviceCode)) {
+            System.out.println("##时间同步请求-未注册设备 idCode=" + deviceCode);
+            return;
+        }
+        String answerText = "hm+2+" + dateUtil.getNowText() + "+0+4+end";
+        log.info(">>时间同步请求-应答数据>>" + answerText);
+        answerCmd(answerText, ctx);
+    }
+
+    //获取远程设备编码
+    private void getDeviceCode(String askText, String idCode, ChannelHandlerContext ctx) {
+        System.out.println("==>获取远程设备编码请求:" + askText.trim());
+        //{读取设备编码}
+        String deviceCode = cmdProService.getDeviceCodeByChipId(idCode);
+        log.info("获取远程设备编码请求,芯片id>>" + idCode + " ,deviceCode>>" + deviceCode);
+        if (deviceCode == null) {
+            log.error("该设备未注册,已舍弃请求.");
+            return;
+        }
+        String answerText = "hm+1+0+" + deviceCode + "+123+8+end";
+        log.info("<<获取远程设备编码请求-应答数据:" + answerText);
+        //{应答指令}
+        answerCmd(answerText, ctx);
+    }
+
+    //应答
+    public void answerCmd(String answerText, ChannelHandlerContext ctx) {
+        ctx.writeAndFlush(Unpooled.copiedBuffer(answerText.getBytes()));
+    }
+
+    //检查无效耳标
+    public boolean checkValidEarmark(String earmark) {
+        if (earmark.trim().equalsIgnoreCase("ffffffffffffffff") || earmark.trim().equalsIgnoreCase("0000000000000000")) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    //拆分粘包数据
+    public JSONArray parseAskCmdPackage(String text) {
+        String key = "end";
+        Pattern pattern = Pattern.compile(key);
+        Matcher matcher = pattern.matcher(text);
+        int count = 0;
+        while (matcher.find()) {
+            count++;
+        }
+        JSONArray dataJa = new JSONArray();
+        if (count == 1) {
+            dataJa.add(text);
+        } else {
+            for (int a = 0; a < count; a++) {
+                int p1 = text.indexOf("end");
+                dataJa.add(text.substring(0, p1 + 3));
+                text = text.substring(p1 + 3, text.length());
+            }
+        }
+        return dataJa;
+    }
+}

+ 8 - 0
huimv-env-input/src/main/java/com/huimv/env/input/service/ICommandProcessorService.java

@@ -0,0 +1,8 @@
+package com.huimv.env.input.service;
+
+public interface ICommandProcessorService {
+
+    String getDeviceCodeByChipId(String idCode);
+
+    boolean isEffectiveDevice(String idCode);
+}

+ 32 - 0
huimv-env-input/src/main/java/com/huimv/env/input/service/impl/CommandProcessorServiceImpl.java

@@ -0,0 +1,32 @@
+package com.huimv.env.input.service.impl;
+
+import com.huimv.env.input.service.ICommandProcessorService;
+import com.huimv.env.common.service.IDeviceRegisterService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@Service
+public class CommandProcessorServiceImpl implements ICommandProcessorService {
+
+    @Autowired
+    private IDeviceRegisterService iDeviceRegisterService;
+
+    @Override
+    public String getDeviceCodeByChipId(String idCode) {
+        //--{读取设备编码}
+        return iDeviceRegisterService.getDeviceCodeByChipId(idCode);
+    }
+
+    @Override
+    public boolean isEffectiveDevice(String idCode) {
+        return iDeviceRegisterService.isExistByDeviceCode(idCode);
+    }
+}

+ 187 - 0
huimv-env-input/src/main/java/com/huimv/env/input/utils/DateUtil2.java

@@ -0,0 +1,187 @@
+package com.huimv.env.input.utils;
+
+import cn.hutool.core.date.DateTime;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@Component
+@Slf4j
+public class DateUtil2 {
+
+    //格式化日期(Long --> Date)
+    public String formatLongToDate(Long longDate){
+        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Date date= new Date(longDate);
+        return df.format(date);
+    }
+
+    //格式化本年
+    public String getThisYear(){
+        Calendar cal = Calendar.getInstance();
+        int year = cal.get(Calendar.YEAR);
+        return String.valueOf(year);
+    }
+
+    //格式化本月
+    public String getThisMonth(){
+        Calendar cal = Calendar.getInstance();
+        int month = cal.get(Calendar.MONTH) + 1;
+        if(String.valueOf(month).length()==1)
+        {
+            return "0"+String.valueOf(month);
+        }else{
+            return String.valueOf(month);
+        }
+    }
+
+    //格式化日期时间
+    public String formatDateTime(String dateText) throws ParseException {
+        if(dateText.indexOf("T") != -1){
+            dateText = dateText.replace("T"," ");
+        }
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Date date = sdf.parse(dateText);
+        return sdf.format(date);
+    }
+
+    public Date parseDateTime(String dateText) throws ParseException {
+        if(dateText.indexOf("T") != -1){
+            dateText = dateText.replace("T"," ");
+        }
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        return sdf.parse(dateText);
+    }
+
+    public Long parseDateTimeLong(String dateText) throws ParseException {
+        if(dateText.indexOf("T") != -1){
+            dateText = dateText.replace("T"," ");
+        }
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Date date = sdf.parse(dateText);
+        return date.getTime();
+    }
+
+    //
+    public Date getTodayDate() throws ParseException {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        return sdf.parse(sdf.format(new Date()));
+    }
+
+    public Date getTodayDatetime() throws ParseException {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        return sdf.parse(sdf.format(new Date()));
+    }
+
+    public String getTodayDateText() throws ParseException {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        return sdf.format(new Date());
+    }
+
+    public String getTodayText() throws ParseException {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        return sdf.format(new Date());
+    }
+
+    public String getNowText() throws ParseException {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
+        return sdf.format(new Date());
+    }
+
+    public String getTodayMissionText() throws ParseException {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
+        return sdf.format(new Date());
+    }
+
+    public String getStartDateInThisMonth(){
+        DateTime date = cn.hutool.core.date.DateUtil.date();
+        return (cn.hutool.core.date.DateUtil.beginOfMonth(date) + "").substring(0, 10);
+    }
+
+    public String getEndDateInThisMonth(){
+        DateTime date = cn.hutool.core.date.DateUtil.date();
+        return (date + "").substring(0, 10);
+    }
+
+    /**
+     * 获取过去或者未来 任意天内的日期数组
+     * @param intervals      intervals天内
+     * @return              日期数组
+     */
+    public ArrayList<String> test(int intervals ) {
+        ArrayList<String> pastDaysList = new ArrayList<>();
+        ArrayList<String> fetureDaysList = new ArrayList<>();
+        for (int i = 0; i <intervals; i++) {
+            pastDaysList.add(getPastDate(i));
+            fetureDaysList.add(getFetureDate(i));
+        }
+        return pastDaysList;
+    }
+
+    /**
+     * 获取过去第几天的日期
+     *
+     * @param past
+     * @return
+     */
+    public String getPastDate(int past) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - past);
+        Date today = calendar.getTime();
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+        String result = format.format(today);
+        return result;
+    }
+
+    /**
+     * 获取未来 第 past 天的日期
+     * @param past
+     * @return
+     */
+    public String getFetureDate(int past) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) + past);
+        Date today = calendar.getTime();
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+        String result = format.format(today);
+        return result;
+    }
+
+    //重新构建日期
+    public String rebuildDateTime(String text){
+        return text.substring(0,4)+"-"+text.substring(4,6)+"-"+text.substring(6,8)+" "+text.substring(8,10)+":"+text.substring(10,12)+":"+text.substring(12,14);
+    }
+
+    public static void main(String[] args){
+        DateUtil2 du = new DateUtil2();
+        //
+        du.test1();
+    }
+
+    private void test1() {
+        String text = "20211201104300";
+//        String text = "1234567890abcd";
+        String date = text.substring(0,4)+"-"+text.substring(4,6)+"-"+text.substring(6,8)+" "+text.substring(8,10)+":"+text.substring(10,12)+":"+text.substring(12,14);
+        System.out.println("date="+date);
+    }
+
+    //获取long时间
+    public Long getNowLong(){
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(calendar.get(Calendar.YEAR),calendar.get(Calendar.MONTH),calendar.get(Calendar.DAY_OF_MONTH)-1,0,0,0);
+        return calendar.getTime().getTime();
+    }
+}

+ 105 - 0
huimv-env-input/src/main/resources/application-dev.yml

@@ -0,0 +1,105 @@
+server:
+  port: 8091
+
+spring:
+  application:
+    name: huimv-env-input
+
+  datasource:
+    url: jdbc:mysql://115.238.57.190:3306/huimv-env-platform?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+    username: root
+    password: hm123456
+    driver-class-name: com.mysql.cj.jdbc.Driver
+  jpa:
+    show-sql: true
+    database: mysql
+    hibernate:
+      ddl-auto: update
+    database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
+    open-in-view: true
+
+  #配置rabbitMq 服务器
+#  rabbitmq:
+#    host: 10.0.0.4
+#    port: 5672
+#    username: huimv
+#    password: hm123456
+#    #虚拟host 可以不设置,使用server默认host
+#    virtual-host: /
+  rabbitmq:
+#    host: 192.168.1.82
+    host: 121.36.134.218
+    port: 5672
+    username: admin
+    password: admin
+    #虚拟host 可以不设置,使用server默认host
+    virtual-host: /env
+
+    #确认消息已发送到交换机(Exchange)
+#    publisher-confirms: true #(过时、弃用)
+    publisher-confirm-type: correlated
+    #确认消息已发送到队列(Queue)
+    publisher-returns: true
+
+  #redis
+#  redis:
+#    database: 0
+#    host: 192.168.1.68
+#    port: 6379
+#    password: hm123456
+#    timeout: 5000ms
+#    jedis:
+#      pool:
+#        max-active: 20
+#        max-wait: -1
+#        max-idle: 10
+#        min-idle: 0
+#    lettuce:
+#      pool:
+#        max-active: 3
+#        min-idle: 2
+#        max-idle: 3
+#        max-wait: 1
+#      shutdown-timeout: 100
+
+#  data:
+#    redis:
+#      repositories:
+#        enabled: false
+
+  #是否缓存空值
+#  cache:
+#    redis:
+#      cache-null-values: false
+
+
+
+    #server:
+#  port: 9110
+#spring:
+#  application:
+#    name: huimv-hy-autoGetData
+#
+#  datasource:
+##    url: jdbc:mysql://47.98.175.112:3306/huimv_ql_farm_haiyan?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+#    #    url: jdbc:mysql://36.22.189.214:3306/huimv_ql_farm?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+#        url: jdbc:mysql://192.168.1.7:3306/huimv_ql_farm?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+#    username: root
+#    password: hm123456
+#    driver-class-name: com.mysql.cj.jdbc.Driver
+#  jpa:
+#    properties:
+#      hibernate:
+#        enable_lazy_load_no_trans: true
+#    show-sql: true
+#    database: mysql
+#    hibernate:
+#      ddl-auto: update
+#    database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
+#    open-in-view: true
+management:
+  endpoints:
+    web:
+      exposure:
+        include: "*"   # * 在yaml 文件属于关键字,所以需要加引号
+

+ 89 - 0
huimv-env-input/src/main/resources/application-prod.yml

@@ -0,0 +1,89 @@
+server:
+  port: 8091
+
+spring:
+  application:
+    name: huimv-env-input
+
+  datasource:
+    url: jdbc:mysql://122.112.224.199:3306/huimv-env-platform-qingshan?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+    username: qingshan
+    password: qingshan@2022
+    driver-class-name: com.mysql.cj.jdbc.Driver
+  jpa:
+    show-sql: true
+    database: mysql
+    hibernate:
+      ddl-auto: update
+    database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
+    open-in-view: true
+
+  #配置rabbitMq 服务器
+#  rabbitmq:
+#    host: 10.0.0.4
+#    port: 5672
+#    username: huimv
+#    password: hm123456
+#    #虚拟host 可以不设置,使用server默认host
+#    virtual-host: /
+  rabbitmq:
+    host: 121.36.134.218
+    port: 5672
+    username: admin
+    password: admin
+    #虚拟host 可以不设置,使用server默认host
+    virtual-host: /env
+
+    #确认消息已发送到交换机(Exchange)
+#    publisher-confirms: true #(过时、弃用)
+    publisher-confirm-type: correlated
+    #确认消息已发送到队列(Queue)
+    publisher-returns: true
+
+  #redis
+  redis:
+    host: 122.112.224.199
+    port: 6379
+    password: hm123456
+
+  data:
+    redis:
+      repositories:
+        enabled: false
+
+  #是否缓存空值
+  cache:
+    redis:
+      cache-null-values: false
+
+
+
+    #server:
+#  port: 9110
+#spring:
+#  application:
+#    name: huimv-hy-autoGetData
+#
+#  datasource:
+##    url: jdbc:mysql://47.98.175.112:3306/huimv_ql_farm_haiyan?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+#    #    url: jdbc:mysql://36.22.189.214:3306/huimv_ql_farm?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+#        url: jdbc:mysql://192.168.1.7:3306/huimv_ql_farm?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+#    username: root
+#    password: hm123456
+#    driver-class-name: com.mysql.cj.jdbc.Driver
+#  jpa:
+#    properties:
+#      hibernate:
+#        enable_lazy_load_no_trans: true
+#    show-sql: true
+#    database: mysql
+#    hibernate:
+#      ddl-auto: update
+#    database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
+#    open-in-view: true
+management:
+  endpoints:
+    web:
+      exposure:
+        include: "*"   # * 在yaml 文件属于关键字,所以需要加引号
+

+ 32 - 0
huimv-env-input/src/main/resources/application.properties

@@ -0,0 +1,32 @@
+spring.profiles.active=prod
+#spring.profiles.active=dev
+
+#\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD
+management.endpoints.web.exposure.include=*
+
+#########################################################
+###             \uFFFD\uFFFD\uFFFD\uFFFDundertow\u0221\uFFFD\uFFFDtomcat                ###
+#########################################################
+# \uFFFD\u01F7\uFFFD\uFFFD undertow \uFFFD\uFFFD\u05BE\uFFFD\uFFFD\u012C\uFFFD\uFFFD\u03AA false
+server.undertow.accesslog.enabled=false
+# \uFFFD\uFFFD\uFFFD\u00F7\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u05BE\uFFFD\uFFFD\uFFFD\uFFFD\u013F\u00BC
+server.undertow.accesslog.dir=logs
+# \u05B8\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u07F3\u0335\uFFFD I/0 \uFFFD\u07F3\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u012C\uFFFD\uFFFD\u03AA 2 \uFFFD\uFFFD\uFFFD\uFFFD CPU \uFFFD\u0138\uFFFD\uFFFD\uFFFD
+server.undertow.io-threads=
+# \u05B8\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u07F3\u0338\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u012C\uFFFD\uFFFD\u03AA I/O \uFFFD\u07F3\u0338\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD 8 \uFFFD\uFFFD
+server.undertow.worker-threads=
+# \uFFFD\uFFFD\uFFFD\uFFFD HTTP POST \uFFFD\uFFFD\uFFFD\u0775\uFFFD\uFFFD\uFFFD\uDB8E\uDD36\u0223\uFFFD\u012C\uFFFD\u03F2\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD
+server.undertow.max-http-post-size=0
+
+#########################################################
+###   Actuator Monitor  --   Actuator configuration   ###
+#########################################################
+management.security.enabled=false
+
+# \uFFFD\uFFFD\uFFFD\u0774\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD
+data.input.flow=2
+
+# \uFFFD\u01F7\uFFFD\u0434\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD(1:\u0434\uFFFD\uFFFD 0:\uFFFD\uFFFD\u0434\uFFFD\uFFFD)
+data.test.input=0
+
+

+ 24 - 0
huimv-env-input/src/main/resources/assembly.xml

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<assembly>
+    <id>jar-with-dependencies</id>
+    <formats>
+        <format>jar</format>
+    </formats>
+    <includeBaseDirectory>false</includeBaseDirectory>
+    <dependencySets>
+        <!-- 默认的配置 -->
+        <dependencySet>
+            <outputDirectory>/</outputDirectory>
+            <useProjectArtifact>true</useProjectArtifact>
+            <unpack>true</unpack>
+            <scope>runtime</scope>
+        </dependencySet>
+        <!-- 增加scope类型为system的配置 -->
+        <dependencySet>
+            <outputDirectory>/</outputDirectory>
+            <useProjectArtifact>true</useProjectArtifact>
+            <unpack>true</unpack>
+            <scope>system</scope>
+        </dependencySet>
+    </dependencySets>
+</assembly>