Browse Source

增加共享模块

zhuoning 3 years ago
parent
commit
323d33a77c
69 changed files with 5714 additions and 0 deletions
  1. 33 0
      huimv-eartag2-platform/.gitignore
  2. BIN
      huimv-eartag2-platform/.mvn/wrapper/maven-wrapper.jar
  3. 2 0
      huimv-eartag2-platform/.mvn/wrapper/maven-wrapper.properties
  4. 50 0
      huimv-eartag2-platform/huimv-eartag2-common/pom.xml
  5. 200 0
      huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/entity/EartagDataEntity.java
  6. 92 0
      huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/entity/EartagEnvEntity.java
  7. 56 0
      huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/entity/EartagHeartbeatEntity.java
  8. 96 0
      huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/entity/EartagRawEntity.java
  9. 12 0
      huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/repo/EartagDataRepo.java
  10. 9 0
      huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/repo/EartagEnvRepo.java
  11. 9 0
      huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/repo/EartagHeartbeatRepo.java
  12. 9 0
      huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/repo/EartagRawRepo.java
  13. 17 0
      huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/mq/Const.java
  14. 14 0
      huimv-eartag2-platform/huimv-eartag2-gateway/pom.xml
  15. 95 0
      huimv-eartag2-platform/huimv-eartag2-gateway/src/main/resources/application-dev.yml
  16. 2 0
      huimv-eartag2-platform/huimv-eartag2-gateway/src/main/resources/application.properties
  17. 121 0
      huimv-eartag2-platform/huimv-eartag2-input/pom.xml
  18. 27 0
      huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/HuimvEartagApplication.java
  19. 88 0
      huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/config/TopicRabbitMQConfig.java
  20. 163 0
      huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/controller/SendMessageController.java
  21. 42 0
      huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/producer/Producer.java
  22. 71 0
      huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/server/EartagServer.java
  23. 74 0
      huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/server/EartagServer2.java
  24. 70 0
      huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/server/EartagServerHandler.java
  25. 100 0
      huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/server/EartagServerHandler2.java
  26. 52 0
      huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/server/client/EchoClient.java
  27. 41 0
      huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/server/client/EchoClientHandler.java
  28. 56 0
      huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/server/client2/EchoClient.java
  29. 43 0
      huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/server/client2/EchoClientHandler.java
  30. 10 0
      huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/service/IDataService.java
  31. 14 0
      huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/service/IDeviceService.java
  32. 6 0
      huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/service/IEartagService.java
  33. 629 0
      huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/service/impl/DataServiceImpl.java
  34. 46 0
      huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/service/impl/DeviceServiceImpl.java
  35. 46 0
      huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/service/impl/EartagServiceImpl.java
  36. 12 0
      huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/utils/BaseTemplete.java
  37. 187 0
      huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/utils/DateUtil.java
  38. 516 0
      huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/utils/HttpTemplete.java
  39. 89 0
      huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/utils/MathUtil.java
  40. 266 0
      huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/utils/ip/AddressUtils.java
  41. 57 0
      huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/utils/ip/IPMain.java
  42. 62 0
      huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/utils/ip/IPUtils.java
  43. 60 0
      huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/utils/ip/MyTest.java
  44. 139 0
      huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/vo/EartagDataVo.java
  45. 99 0
      huimv-eartag2-platform/huimv-eartag2-input/src/main/resources/application-dev.yml
  46. 4 0
      huimv-eartag2-platform/huimv-eartag2-input/src/main/resources/application.properties
  47. 24 0
      huimv-eartag2-platform/huimv-eartag2-input/src/main/resources/assembly.xml
  48. 65 0
      huimv-eartag2-platform/huimv-eartag2-input/src/test/java/com/huimv/eartag2/DataTest.java
  49. 26 0
      huimv-eartag2-platform/huimv-eartag2-input/src/test/java/com/huimv/eartag2/utils/IPUtilsTest.java
  50. 15 0
      huimv-eartag2-platform/huimv-eartag2-manage/pom.xml
  51. 95 0
      huimv-eartag2-platform/huimv-eartag2-manage/src/main/resources/application-dev.yml
  52. 2 0
      huimv-eartag2-platform/huimv-eartag2-manage/src/main/resources/application.properties
  53. 60 0
      huimv-eartag2-platform/huimv-eartag2-process/pom.xml
  54. 23 0
      huimv-eartag2-platform/huimv-eartag2-process/src/main/java/com/huimv/eartag2/process/HuimvEartag2ProcessApplication.java
  55. 193 0
      huimv-eartag2-platform/huimv-eartag2-process/src/main/java/com/huimv/eartag2/process/listener/DeviceListener.java
  56. 29 0
      huimv-eartag2-platform/huimv-eartag2-process/src/main/java/com/huimv/eartag2/process/producer/ProcessProducer.java
  57. 14 0
      huimv-eartag2-platform/huimv-eartag2-process/src/main/java/com/huimv/eartag2/process/service/IDeviceService.java
  58. 10 0
      huimv-eartag2-platform/huimv-eartag2-process/src/main/java/com/huimv/eartag2/process/service/IEartagService.java
  59. 97 0
      huimv-eartag2-platform/huimv-eartag2-process/src/main/java/com/huimv/eartag2/process/service/impl/DeviceServiceImpl.java
  60. 103 0
      huimv-eartag2-platform/huimv-eartag2-process/src/main/java/com/huimv/eartag2/process/service/impl/EartagServiceImpl.java
  61. 12 0
      huimv-eartag2-platform/huimv-eartag2-process/src/main/java/com/huimv/eartag2/process/utils/BaseTemplete.java
  62. 187 0
      huimv-eartag2-platform/huimv-eartag2-process/src/main/java/com/huimv/eartag2/process/utils/DateUtil.java
  63. 89 0
      huimv-eartag2-platform/huimv-eartag2-process/src/main/java/com/huimv/eartag2/process/utils/MathUtil.java
  64. 104 0
      huimv-eartag2-platform/huimv-eartag2-process/src/main/resources/application-dev.yml
  65. 2 0
      huimv-eartag2-platform/huimv-eartag2-process/src/main/resources/application.properties
  66. 15 0
      huimv-eartag2-platform/huimv-eartag2-process2/pom.xml
  67. 331 0
      huimv-eartag2-platform/mvnw
  68. 188 0
      huimv-eartag2-platform/mvnw.cmd
  69. 144 0
      huimv-eartag2-platform/pom.xml

+ 33 - 0
huimv-eartag2-platform/.gitignore

@@ -0,0 +1,33 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/

BIN
huimv-eartag2-platform/.mvn/wrapper/maven-wrapper.jar


+ 2 - 0
huimv-eartag2-platform/.mvn/wrapper/maven-wrapper.properties

@@ -0,0 +1,2 @@
+distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.3/apache-maven-3.8.3-bin.zip
+wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar

+ 50 - 0
huimv-eartag2-platform/huimv-eartag2-common/pom.xml

@@ -0,0 +1,50 @@
+<?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-eartag2-platform</artifactId>
+        <groupId>com.huimv</groupId>
+        <version>0.0.1-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>com.huimv</groupId>
+    <artifactId>huimv-eartag2-common</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <packaging>jar</packaging>
+
+    <!-- 后加 -->
+    <build>
+        <resources>
+            <resource>
+                <directory>src/main/java</directory>
+                <includes>
+                    <include>**/*.*</include>
+                </includes>
+                <excludes>
+                    <exclude>**/*.java</exclude>
+                </excludes>
+                <filtering>false</filtering>
+            </resource>
+        </resources>
+    </build>
+<!--    <build>-->
+<!--        <finalName>${project.artifactId}</finalName>-->
+<!--    </build>-->
+<!--    <build>-->
+<!--        <plugins>-->
+<!--            &lt;!&ndash;  &ndash;&gt;-->
+<!--            <plugin>-->
+<!--                <groupId>org.springframework.boot</groupId>-->
+<!--                <artifactId>spring-boot-maven-plugin</artifactId>-->
+<!--            </plugin>-->
+<!--            &lt;!&ndash;  &ndash;&gt;-->
+<!--            <plugin>-->
+<!--                <groupId>org.apache.maven.plugins</groupId>-->
+<!--                <artifactId>maven-resources-plugin</artifactId>-->
+<!--                <version>2.6</version>-->
+<!--            </plugin>-->
+<!--        </plugins>-->
+<!--    </build>-->
+</project>

+ 200 - 0
huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/entity/EartagDataEntity.java

@@ -0,0 +1,200 @@
+package com.huimv.eartag2.common.dao.entity;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+@Entity
+@Table(name = "eartag_data")
+public class EartagDataEntity implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id", nullable = false)
+    private Integer id;
+
+    @Column(name = "cmd_header")
+    private String cmdHeader;
+
+    @Column(name = "device")
+    private String device;
+
+    @Column(name = "earmark")
+    private String earmark;
+
+    @Column(name = "bat")
+    private Integer bat;
+
+    @Column(name = "ear_temp")
+    private Integer earTemp;
+
+    @Column(name = "ear_temp1")
+    private Float earTemp1;
+
+    @Column(name = "env_temp")
+    private Integer envTemp;
+
+    @Column(name = "env_temp1")
+    private Integer envTemp1;
+
+    @Column(name = "act")
+    private Integer act;
+
+    @Column(name = "act1")
+    private Integer act1;
+
+    @Column(name = "signal1")
+    private Integer signal1;
+
+    @Column(name = "ask_time")
+    private String askTime;
+
+    @Column(name = "other")
+    private String other;
+
+    @Column(name = "add_time")
+    private Timestamp addTime;
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setCmdHeader(String cmdHeader) {
+        this.cmdHeader = cmdHeader;
+    }
+
+    public String getCmdHeader() {
+        return cmdHeader;
+    }
+
+    public void setDevice(String device) {
+        this.device = device;
+    }
+
+    public String getDevice() {
+        return device;
+    }
+
+    public void setEarmark(String earmark) {
+        this.earmark = earmark;
+    }
+
+    public String getEarmark() {
+        return earmark;
+    }
+
+    public void setBat(Integer bat) {
+        this.bat = bat;
+    }
+
+    public Integer getBat() {
+        return bat;
+    }
+
+    public void setEarTemp(Integer earTemp) {
+        this.earTemp = earTemp;
+    }
+
+    public Integer getEarTemp() {
+        return earTemp;
+    }
+
+    public void setEarTemp1(Float earTemp1) {
+        this.earTemp1 = earTemp1;
+    }
+
+    public Float getEarTemp1() {
+        return earTemp1;
+    }
+
+    public void setEnvTemp(Integer envTemp) {
+        this.envTemp = envTemp;
+    }
+
+    public Integer getEnvTemp() {
+        return envTemp;
+    }
+
+    public void setEnvTemp1(Integer envTemp1) {
+        this.envTemp1 = envTemp1;
+    }
+
+    public Integer getEnvTemp1() {
+        return envTemp1;
+    }
+
+    public void setAct(Integer act) {
+        this.act = act;
+    }
+
+    public Integer getAct() {
+        return act;
+    }
+
+    public void setAct1(Integer act1) {
+        this.act1 = act1;
+    }
+
+    public Integer getAct1() {
+        return act1;
+    }
+
+    public void setSignal1(Integer signal1) {
+        this.signal1 = signal1;
+    }
+
+    public Integer getSignal1() {
+        return signal1;
+    }
+
+    public void setAskTime(String askTime) {
+        this.askTime = askTime;
+    }
+
+    public String getAskTime() {
+        return askTime;
+    }
+
+    public void setOther(String other) {
+        this.other = other;
+    }
+
+    public String getOther() {
+        return other;
+    }
+
+    public void setAddTime(Timestamp addTime) {
+        this.addTime = addTime;
+    }
+
+    public Timestamp getAddTime() {
+        return addTime;
+    }
+
+    @Override
+    public String toString() {
+        return "EartagDataEntity{" +
+                "id=" + id + '\'' +
+                "cmdHeader=" + cmdHeader + '\'' +
+                "device=" + device + '\'' +
+                "earmark=" + earmark + '\'' +
+                "bat=" + bat + '\'' +
+                "earTemp=" + earTemp + '\'' +
+                "earTemp1=" + earTemp1 + '\'' +
+                "envTemp=" + envTemp + '\'' +
+                "envTemp1=" + envTemp1 + '\'' +
+                "act=" + act + '\'' +
+                "act1=" + act1 + '\'' +
+                "signal1=" + signal1 + '\'' +
+                "askTime=" + askTime + '\'' +
+                "other=" + other + '\'' +
+                "addTime=" + addTime + '\'' +
+                '}';
+    }
+}

+ 92 - 0
huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/entity/EartagEnvEntity.java

@@ -0,0 +1,92 @@
+package com.huimv.eartag2.common.dao.entity;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+@Entity
+@Table(name = "eartag_env")
+public class EartagEnvEntity implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id", nullable = false)
+    private Integer id;
+
+    @Column(name = "device_code")
+    private String deviceCode;
+
+    @Column(name = "temp1")
+    private Integer temp1;
+
+    @Column(name = "temp2")
+    private Float temp2;
+
+    @Column(name = "ask_time")
+    private Timestamp askTime;
+
+    @Column(name = "add_time")
+    private Timestamp addTime;
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setDeviceCode(String deviceCode) {
+        this.deviceCode = deviceCode;
+    }
+
+    public String getDeviceCode() {
+        return deviceCode;
+    }
+
+    public void setTemp1(Integer temp1) {
+        this.temp1 = temp1;
+    }
+
+    public Integer getTemp1() {
+        return temp1;
+    }
+
+    public void setTemp2(Float temp2) {
+        this.temp2 = temp2;
+    }
+
+    public Float getTemp2() {
+        return temp2;
+    }
+
+    public void setAskTime(Timestamp askTime) {
+        this.askTime = askTime;
+    }
+
+    public Timestamp getAskTime() {
+        return askTime;
+    }
+
+    public void setAddTime(Timestamp addTime) {
+        this.addTime = addTime;
+    }
+
+    public Timestamp getAddTime() {
+        return addTime;
+    }
+
+    @Override
+    public String toString() {
+        return "EartagEnvEntity{" +
+                "id=" + id + '\'' +
+                "deviceCode=" + deviceCode + '\'' +
+                "temp1=" + temp1 + '\'' +
+                "temp2=" + temp2 + '\'' +
+                "askTime=" + askTime + '\'' +
+                "addTime=" + addTime + '\'' +
+                '}';
+    }
+}

+ 56 - 0
huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/entity/EartagHeartbeatEntity.java

@@ -0,0 +1,56 @@
+package com.huimv.eartag2.common.dao.entity;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+@Entity
+@Table(name = "eartag_heartbeat")
+public class EartagHeartbeatEntity implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id", nullable = false)
+    private Integer id;
+
+    @Column(name = "device_code")
+    private String deviceCode;
+
+    @Column(name = "add_time")
+    private Timestamp addTime;
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setDeviceCode(String deviceCode) {
+        this.deviceCode = deviceCode;
+    }
+
+    public String getDeviceCode() {
+        return deviceCode;
+    }
+
+    public void setAddTime(Timestamp addTime) {
+        this.addTime = addTime;
+    }
+
+    public Timestamp getAddTime() {
+        return addTime;
+    }
+
+    @Override
+    public String toString() {
+        return "EartagHeartbeatEntity{" +
+                "id=" + id + '\'' +
+                "deviceCode=" + deviceCode + '\'' +
+                "addTime=" + addTime + '\'' +
+                '}';
+    }
+}

+ 96 - 0
huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/entity/EartagRawEntity.java

@@ -0,0 +1,96 @@
+package com.huimv.eartag2.common.dao.entity;
+
+import javax.persistence.Entity;
+import javax.persistence.Column;
+import javax.persistence.GenerationType;
+import javax.persistence.Table;
+import javax.persistence.GeneratedValue;
+import java.sql.Timestamp;
+import java.io.Serializable;
+import javax.persistence.Id;
+ 
+@Entity
+@Table(name = "eartag_raw")
+public class EartagRawEntity implements Serializable {
+
+private static final long serialVersionUID = 1L;
+
+@Id
+@GeneratedValue(strategy = GenerationType.IDENTITY)@Column(name = "id", nullable = false)
+private Integer id;
+
+@Column(name = "cmd_header")
+private String cmdHeader;
+
+@Column(name = "cmd")
+private String cmd;
+
+@Column(name = "device")
+private String device;
+
+@Column(name = "ask")
+private String ask;
+
+@Column(name = "add_time")
+private Timestamp addTime;
+
+public  void  setId(Integer id) {
+this.id = id;
+}
+
+public Integer getId() {
+return id;
+}
+
+public  void  setCmdHeader(String cmdHeader) {
+this.cmdHeader = cmdHeader;
+}
+
+public String getCmdHeader() {
+return cmdHeader;
+}
+
+public  void  setCmd(String cmd) {
+this.cmd = cmd;
+}
+
+public String getCmd() {
+return cmd;
+}
+
+public  void  setDevice(String device) {
+this.device = device;
+}
+
+public String getDevice() {
+return device;
+}
+
+public  void  setAsk(String ask) {
+this.ask = ask;
+}
+
+public String getAsk() {
+return ask;
+}
+
+public  void  setAddTime(Timestamp addTime) {
+this.addTime = addTime;
+}
+
+public Timestamp getAddTime() {
+return addTime;
+}
+
+@Override
+public String toString() {
+return "EartagRawEntity{" +
+    "id=" + id + '\'' +
+    "cmdHeader=" + cmdHeader + '\'' +
+    "cmd=" + cmd + '\'' +
+    "device=" + device + '\'' +
+    "ask=" + ask + '\'' +
+    "addTime=" + addTime + '\'' +
+    '}';
+}
+}

+ 12 - 0
huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/repo/EartagDataRepo.java

@@ -0,0 +1,12 @@
+package com.huimv.eartag2.common.dao.repo;
+
+import com.huimv.eartag2.common.dao.entity.EartagDataEntity;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Query;
+
+public interface EartagDataRepo extends JpaRepository<EartagDataEntity, Integer>, JpaSpecificationExecutor<EartagDataEntity> {
+    //--查询最新到耳标记录
+    @Query(nativeQuery = true,value = "SELECT * FROM eartag_data WHERE device=?1 ORDER BY id DESC LIMIT 1")
+    EartagDataEntity getLastEartagData(String deviceCode);
+}

+ 9 - 0
huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/repo/EartagEnvRepo.java

@@ -0,0 +1,9 @@
+package com.huimv.eartag2.common.dao.repo;
+
+import com.huimv.eartag2.common.dao.entity.EartagEnvEntity;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+public interface EartagEnvRepo extends JpaRepository<EartagEnvEntity, Integer>, JpaSpecificationExecutor<EartagEnvEntity> {
+
+}

+ 9 - 0
huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/repo/EartagHeartbeatRepo.java

@@ -0,0 +1,9 @@
+package com.huimv.eartag2.common.dao.repo;
+
+import com.huimv.eartag2.common.dao.entity.EartagHeartbeatEntity;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+public interface EartagHeartbeatRepo extends JpaRepository<EartagHeartbeatEntity, Integer>, JpaSpecificationExecutor<EartagHeartbeatEntity> {
+
+}

+ 9 - 0
huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/repo/EartagRawRepo.java

@@ -0,0 +1,9 @@
+package com.huimv.eartag2.common.dao.repo;
+
+import com.huimv.eartag2.common.dao.entity.EartagRawEntity;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+public interface EartagRawRepo extends JpaRepository<EartagRawEntity, Integer>, JpaSpecificationExecutor<EartagRawEntity> {
+
+}

+ 17 - 0
huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/mq/Const.java

@@ -0,0 +1,17 @@
+package com.huimv.eartag2.common.mq;
+
+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
+ **/
+public class Const {
+    public final static String ROUTING_KEY_ASK = "topic.ask.key";
+    public final static String QUEUE_NAME_ASK = "topic.ask.queue";
+    public final static String EXCHANGE_NAME_ASK = "topic.ask.exchange";
+}

+ 14 - 0
huimv-eartag2-platform/huimv-eartag2-gateway/pom.xml

@@ -0,0 +1,14 @@
+<?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-eartag2-platform</artifactId>
+        <groupId>com.huimv</groupId>
+        <version>0.0.1-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>huimv-eartag2-gateway</artifactId>
+
+</project>

+ 95 - 0
huimv-eartag2-platform/huimv-eartag2-gateway/src/main/resources/application-dev.yml

@@ -0,0 +1,95 @@
+server:
+  port: 8092
+spring:
+  application:
+    name: huimv-goldpig-eartag
+
+  datasource:
+    url: jdbc:mysql://192.168.1.7:3306/huimv-demo-eartag20?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: /
+  #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
+
+  #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
+

+ 2 - 0
huimv-eartag2-platform/huimv-eartag2-gateway/src/main/resources/application.properties

@@ -0,0 +1,2 @@
+spring.profiles.active=dev
+        

+ 121 - 0
huimv-eartag2-platform/huimv-eartag2-input/pom.xml

@@ -0,0 +1,121 @@
+<?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-eartag2-platform</artifactId>
+        <groupId>com.huimv</groupId>
+        <version>0.0.1-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>huimv-eartag2-input</artifactId>
+    <packaging>jar</packaging>
+
+    <properties>
+        <java.version>1.8</java.version>
+        <!--        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>-->
+    </properties>
+    <dependencies>
+        <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>
+
+        <!-- eartag2-common -->
+        <dependency>
+            <groupId>com.huimv</groupId>
+            <artifactId>huimv-eartag2-common</artifactId>
+            <version>0.0.1-SNAPSHOT</version>
+        </dependency>
+
+<!--        &lt;!&ndash; JPA &ndash;&gt;-->
+<!--        <dependency>-->
+<!--            <groupId>org.springframework.boot</groupId>-->
+<!--            <artifactId>spring-boot-starter-data-jpa</artifactId>-->
+<!--        </dependency>-->
+<!--        &lt;!&ndash; mysql &ndash;&gt;-->
+<!--        <dependency>-->
+<!--            <groupId>mysql</groupId>-->
+<!--            <artifactId>mysql-connector-java</artifactId>-->
+<!--        </dependency>-->
+
+<!--        &lt;!&ndash; redis &ndash;&gt;-->
+<!--        <dependency>-->
+<!--            <groupId>org.springframework.boot</groupId>-->
+<!--            <artifactId>spring-boot-starter-data-redis</artifactId>-->
+<!--        </dependency>-->
+
+        <!-- netty -->
+        <dependency>
+            <groupId>io.netty</groupId>
+            <artifactId>netty-all</artifactId>
+            <version>4.1.45.Final</version>
+        </dependency>
+        <!-- lombok -->
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <version>1.16.18</version>
+            <scope>provided</scope>
+        </dependency>
+        <!--hutool-->
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+            <version>5.6.5</version>
+        </dependency>
+        <!-- httpclient -->
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.5.5</version>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <!--rabbitmq-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-amqp</artifactId>
+        </dependency>
+
+        <!--rabbitmq.client-->
+<!--        <dependency>-->
+<!--            <groupId>com.rabbitmq</groupId>-->
+<!--            <artifactId>amqp-client</artifactId>-->
+<!--            <version>3.4.1</version>-->
+<!--        </dependency>-->
+
+        <!-- actuator -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-actuator</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>

+ 27 - 0
huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/HuimvEartagApplication.java

@@ -0,0 +1,27 @@
+package com.huimv.eartag2;
+
+import com.huimv.eartag2.server.EartagServer2;
+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
+ **/
+@SpringBootApplication
+public class HuimvEartagApplication {
+    public static void main(String[] args) throws InterruptedException {
+//        SpringApplication.run(HuimvEartagApplication.class, args);
+        ApplicationContext applicationContext = SpringApplication.run(HuimvEartagApplication.class, args);
+        //EartagServer
+//        applicationContext.getBean(EartagServer.class).start();
+        //EartagServer2
+        applicationContext.getBean(EartagServer2.class).run();
+    }
+
+}

+ 88 - 0
huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/config/TopicRabbitMQConfig.java

@@ -0,0 +1,88 @@
+package com.huimv.eartag2.config;
+
+import com.huimv.eartag2.common.mq.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 askQueue() {
+//        return new Queue(ask);
+//    }
+    public Queue askQueue() {
+        return new Queue(Const.QUEUE_NAME_ASK);
+    }
+
+    //原始交换机
+    @Bean
+//    TopicExchange askExchange() {
+//        return new TopicExchange("askExchange");
+//    }
+    TopicExchange askExchange() {
+        return new TopicExchange(Const.EXCHANGE_NAME_ASK);
+    }
+
+    @Bean
+    Binding bindingEartagExchangeMessage() {
+        return BindingBuilder.bind(askQueue()).to(askExchange()).with(Const.ROUTING_KEY_ASK);
+    }
+
+//    //采集器注册队列路由键
+//    public final static String deviceRegister = "topic.device.register";
+//    //采集器在线记录队列路由键
+//    public final static String deviceOnline = "topic.device.online";
+//    //采集器总状态队列路由键
+//    public final static String deviceAllState = "topic.device.allstate";
+//    //采集器温度路由键
+//    public final static String deviceTemp = "topic.device.temp";
+//    //采集器心跳路由键
+//    public final static String deviceHeartbeat = "topic.device.heartbeat";
+//    //采集器原始数据
+//    public final static String deviceRawData = "topic.device.rawdata";
+//    //耳标原始数据
+//    public final static String eartagRawData = "topic.eartag.rawdata";
+    //
+
+//    //采集器注册队列
+//    @Bean
+//    public Queue deviceQueue() {
+//        return new Queue(deviceRegister);
+//    }
+//    //采集器在线记录队列
+//    @Bean
+//    public Queue deviceOnlineQueue() {
+//        return new Queue(deviceOnline);
+//    }
+//    //采集器总状态队列
+//    @Bean
+//    public Queue deviceAllStateQueue() {
+//        return new Queue(deviceAllState);
+//    }
+
+//    //设备交换机
+//    @Bean
+//    TopicExchange deviceExchange() {
+//        return new TopicExchange("deviceTopicExchange");
+//    }
+//    //耳标交换机
+//    @Bean
+//    TopicExchange eartagExchange() {
+//        return new TopicExchange("eartagTopicExchange");
+//    }
+
+
+}

+ 163 - 0
huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/controller/SendMessageController.java

@@ -0,0 +1,163 @@
+package com.huimv.eartag2.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@RestController
+public class SendMessageController {
+    @Autowired
+    RabbitTemplate rabbitTemplate;  //使用RabbitTemplate,这提供了接收/发送等等方法
+
+    @GetMapping("/sendDirectMessage")
+    public String sendDirectMessage() {
+        String messageId = String.valueOf(java.util.UUID.randomUUID());
+        String messageData = "test message, hello!";
+        String createTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+        Map<String,Object> map=new HashMap<>();
+        map.put("messageId",messageId);
+        map.put("messageData",messageData);
+        map.put("createTime",createTime);
+        //将消息携带绑定键值:TestDirectRouting 发送到交换机TestDirectExchange
+        rabbitTemplate.convertAndSend("TestDirectExchange", "TestDirectRouting", map);
+        return "ok";
+    }
+
+    @GetMapping("/sendTopicMessage1")
+    public String sendTopicMessage1() {
+        String messageId = String.valueOf(UUID.randomUUID());
+        String messageData = "message: M A N ";
+        String createTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+        Map<String, Object> manMap = new HashMap<>();
+        manMap.put("messageId", messageId);
+        manMap.put("messageData", messageData);
+        manMap.put("createTime", createTime);
+        rabbitTemplate.convertAndSend("topicExchange", "topic.man", manMap);
+        return "ok";
+    }
+
+    @GetMapping("/sendTopicMessage2")
+    public String sendTopicMessage2() {
+        String messageId = String.valueOf(UUID.randomUUID());
+        String messageData = "message: woman is all ";
+        String createTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+        Map<String, Object> womanMap = new HashMap<>();
+        womanMap.put("messageId", messageId);
+        womanMap.put("messageData", messageData);
+        womanMap.put("createTime", createTime);
+        rabbitTemplate.convertAndSend("topicExchange", "topic.woman", womanMap);
+        return "ok";
+    }
+
+    @GetMapping("/sendFanoutMessage")
+    public String sendFanoutMessage() {
+        String messageId = String.valueOf(UUID.randomUUID());
+        String messageData = "message: testFanoutMessage ";
+        String createTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+        Map<String, Object> map = new HashMap<>();
+        map.put("messageId", messageId);
+        map.put("messageData", messageData);
+        map.put("createTime", createTime);
+        rabbitTemplate.convertAndSend("fanoutExchange", null, map);
+        return "ok";
+    }
+
+    @GetMapping("/TestMessageAck")
+    public String TestMessageAck() {
+        String messageId = String.valueOf(UUID.randomUUID());
+        String messageData = "message: non-existent-exchange test message ";
+        String createTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+        Map<String, Object> map = new HashMap<>();
+        map.put("messageId", messageId);
+        map.put("messageData", messageData);
+        map.put("createTime", createTime);
+        rabbitTemplate.convertAndSend("non-existent-exchange", "TestDirectRouting", map);
+        return "ok";
+    }
+
+    @GetMapping("/TestMessageAck2")
+    public String TestMessageAck2() {
+        String messageId = String.valueOf(UUID.randomUUID());
+        String messageData = "message: lonelyDirectExchange test message ";
+        String createTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+        Map<String, Object> map = new HashMap<>();
+        map.put("messageId", messageId);
+        map.put("messageData", messageData);
+        map.put("createTime", createTime);
+        rabbitTemplate.convertAndSend("lonelyDirectExchange", "TestDirectRouting", map);
+        return "ok";
+    }
+
+    //topic()
+    @GetMapping("/testEartag")
+    public String testEartag() {
+        String messageId = String.valueOf(UUID.randomUUID());
+        String messageData = "message: topic1 ";
+        String createTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+        Map<String, Object> map = new HashMap<>();
+        map.put("messageId", messageId);
+        map.put("messageData", messageData);
+        map.put("createTime", createTime);
+
+        JSONObject dataJo = new JSONObject();
+        dataJo.put("name","tony");
+        dataJo.put("age","25");
+        Map<String,Object> deviceMap = new HashMap<>();
+        deviceMap.put("textData",dataJo.toString());
+        rabbitTemplate.convertAndSend("deviceTopicExchange", "topic.device", "hello.");
+        return "ok";
+    }
+
+    @GetMapping("/testEartag2")
+    public String testEartag2() {
+        JSONObject dataJo = new JSONObject();
+        dataJo.put("name","tony");
+        dataJo.put("age","25");
+        rabbitTemplate.convertAndSend("deviceTopicExchange", "topic.device", dataJo);
+        return "ok";
+    }
+
+    @GetMapping("/testRegister")
+    public String testRegister() {
+        JSONObject dataJo = new JSONObject();
+        dataJo.put("name","tony");
+        dataJo.put("age","25");
+        rabbitTemplate.convertAndSend("deviceTopicExchange", "topic.device.register", dataJo);
+        return "ok";
+    }
+
+    @GetMapping("/testRegister2")
+    public String testRegister2() {
+        Map map = new HashMap();
+        map.put("name","tony");
+        map.put("age","25");
+        rabbitTemplate.convertAndSend("deviceTopicExchange", "topic.device.register", map);
+        return "ok";
+    }
+
+    @GetMapping("/testRawdata")
+    public String testRawdata() {
+        Map map = new HashMap();
+        map.put("name","tony");
+        map.put("age","25");
+        rabbitTemplate.convertAndSend("rawdataExchange", "topic.rawdata", map);
+        return "ok";
+    }
+
+}

+ 42 - 0
huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/producer/Producer.java

@@ -0,0 +1,42 @@
+package com.huimv.eartag2.producer;
+
+import com.huimv.eartag2.common.mq.Const;
+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
+public class Producer {
+    @Autowired
+    RabbitTemplate rabbitTemplate;  //使用RabbitTemplate,这提供了接收/发送等等方法
+
+    /**
+     * @Method      : saveRawdata
+     * @Description : 保存原始数据到rabbitmq
+     * @Params      : [askText]
+     * @Return      : java.lang.String
+     *
+     * @Author      : ZhuoNing
+     * @Date        : 2022/2/8
+     * @Time        : 17:39
+     */
+    public String sendClientAsk(String askText){
+        Map map = new HashMap();
+        map.put("askText",askText);
+//        rabbitTemplate.convertAndSend("askExchange", "topic.askText.key", map);
+        rabbitTemplate.convertAndSend(Const.EXCHANGE_NAME_ASK, Const.ROUTING_KEY_ASK, map);
+        System.out.println("保存原始数据到rabbitMQ>>"+askText);
+        return "ok";
+    }
+}

+ 71 - 0
huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/server/EartagServer.java

@@ -0,0 +1,71 @@
+package com.huimv.eartag2.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.Service;
+
+import java.net.InetSocketAddress;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+
+//@Component
+@Service
+public class EartagServer {
+    private final static int LISTEN_PORT = 8011;
+    @Autowired
+    private EartagServerHandler serverHandler;
+
+    public static void main(String[] args) {
+        EartagServer dataServer = new EartagServer();
+        dataServer.start();
+    }
+
+    public void start() {
+        System.out.println("# 监听端口      :" + LISTEN_PORT);
+//        final EnvironServerHandler serverHandler = new EnvironServerHandler();
+        // 创建EventLoopGroup
+        EventLoopGroup bossGroup = new NioEventLoopGroup();
+        EventLoopGroup workerGroup = new NioEventLoopGroup();
+        // 创建EventLoopGroup
+        ServerBootstrap b = new ServerBootstrap();
+        b.group(bossGroup, workerGroup)
+                //指定所使用的NIO传输Channel
+                .channel(NioServerSocketChannel.class)
+                //使用指定的端口设置套接字地址
+                .localAddress(new InetSocketAddress(LISTEN_PORT))
+                // 添加一个EchoServerHandler到Channle的ChannelPipeline
+                .childHandler(new ChannelInitializer<SocketChannel>() {
+                    @Override
+                    protected void initChannel(SocketChannel socketChannel) throws Exception {
+                        //EchoServerHandler被标注为@shareable,所以我们可以总是使用同样的案例
+                        socketChannel.pipeline().addLast(serverHandler);
+                    }
+                });
+
+        try {
+            // 异步地绑定服务器;调用sync方法阻塞等待直到绑定完成
+            ChannelFuture f = b.bind().sync();
+            // 获取Channel的CloseFuture,并且阻塞当前线程直到它完成
+            f.channel().closeFuture().sync();
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        } finally {
+            // 优雅的关闭EventLoopGroup,释放所有的资源
+            bossGroup.shutdownGracefully();
+            workerGroup.shutdownGracefully();
+        }
+    }
+}

+ 74 - 0
huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/server/EartagServer2.java

@@ -0,0 +1,74 @@
+package com.huimv.eartag2.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 EartagServer2 {
+    @Autowired
+    private EartagServerHandler2 serverHandler;
+    //监听端口
+    private int port = 8012;
+    //创建构造方法
+    public EartagServer2(){
+    }
+
+    public static void main(String[] args) throws InterruptedException {
+        new EartagServer2().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("# 耳标及采集器设备数据接收服务器已经启动。#");
+            System.out.println("# 准备接收数据:");
+            //绑定端口,同步等待成功
+            ChannelFuture cf = serverBootstrap.bind(port).sync();
+            // 等待服务端监听端口关闭
+            cf.channel().closeFuture().sync();
+        }finally {
+            //优雅的退出
+            bossGroup.shutdownGracefully();
+            workGroup.shutdownGracefully();
+        }
+    }
+}

+ 70 - 0
huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/server/EartagServerHandler.java

@@ -0,0 +1,70 @@
+package com.huimv.eartag2.server;
+
+import com.huimv.eartag2.service.IDataService;
+import com.huimv.eartag2.utils.DateUtil;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelHandler.Sharable;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInboundHandlerAdapter;
+import io.netty.util.CharsetUtil;
+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
+ **/
+@Sharable
+@Component
+public class EartagServerHandler extends ChannelInboundHandlerAdapter {
+    @Autowired
+    private IDataService eartagDataService;
+    @Autowired
+    private DateUtil dateUtil;
+
+    @Override
+    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
+        //将客户端传入的消息转换为Netty的ByteBuf类型
+        ByteBuf in = (ByteBuf) msg;
+        // 在控制台打印传入的消息
+//        System.out.println(
+//                "Server received: " + in.toString(CharsetUtil.UTF_8)
+//        );
+        String askText = in.toString(CharsetUtil.UTF_8);
+        System.out.println("askText>>"+askText);
+
+        //处理接收环保实时数据
+//        eartagDataService.handleAsk(askText,ctx);
+
+        //将接收到的消息写给发送者,而不冲刷出站消息 (应答)
+//        ctx.write(askText);
+        ctx.writeAndFlush(askText);
+    }
+
+    @Override
+    public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
+        // 将未处决消息冲刷到远程节点, 并且关闭该Channel
+//        ctx.writeAndFlush(Unpooled.EMPTY_BUFFER)
+//                .addListener(ChannelFutureListener.CLOSE);
+        ctx.writeAndFlush("111");
+    }
+
+    /**
+     * 异常处理
+     *
+     * @param ctx
+     * @param cause
+     * @throws Exception
+     */
+    @Override
+    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
+        //打印异常栈跟踪
+        cause.printStackTrace();
+        // 关闭该Channel
+        ctx.close();
+    }
+}

+ 100 - 0
huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/server/EartagServerHandler2.java

@@ -0,0 +1,100 @@
+package com.huimv.eartag2.server;
+
+import com.alibaba.fastjson.JSONArray;
+import com.huimv.eartag2.service.IDataService;
+import com.huimv.eartag2.utils.DateUtil;
+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.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
+ **/
+@ChannelHandler.Sharable
+@Component
+@Slf4j
+public class EartagServerHandler2 extends ChannelInboundHandlerAdapter {
+    @Autowired
+    private IDataService eartagDataService;
+    @Autowired
+    private DateUtil dateUtil;
+
+//    @Override
+//    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
+//        ByteBuf data = (ByteBuf) msg;
+//        System.out.println("收到的信息为:"+data.toString(CharsetUtil.UTF_8));
+//        ctx.writeAndFlush(msg);
+////        ctx.write(msg);
+    // ctx.writeAndFlush(msg);
+// ctx.writeAndFlush(data);
+// ctx.writeAndFlush(Unpooled.copiedBuffer(askText.getBytes()));
+//    }
+
+    @Override
+    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
+        ByteBuf data = (ByteBuf) msg;
+        String clientAsk = data.toString(CharsetUtil.UTF_8);
+        //--拆分粘包数据
+        JSONArray askJa = getPerData(clientAsk);
+        for (int a = 0; a < askJa.size(); a++) {
+            //--处理客户端请求数据
+            String answer = eartagDataService.handleClientAsk(askJa.getString(a), ctx);
+//            String answer = eartagDataService.handleClientAsk(clientAsk, ctx);
+            if (answer != null) {
+                log.info("###应答响应>>" + answer + "\n");
+                ctx.writeAndFlush(Unpooled.copiedBuffer(answer.getBytes()));
+            } else {
+                log.info("###应答数据>>" + answer + ",不需要应答。\n");
+            }
+        }
+    }
+
+    //拆分粘包数据
+    public JSONArray getPerData(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;
+    }
+
+    @Override
+    public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
+//        ctx.writeAndFlush("111");
+//        System.out.println("EchoServerHandle channelReadComplete");
+    }
+
+    @Override
+    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
+        cause.printStackTrace();
+        ctx.close();
+
+    }
+}

+ 52 - 0
huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/server/client/EchoClient.java

@@ -0,0 +1,52 @@
+package com.huimv.eartag2.server.client;
+
+
+import io.netty.bootstrap.Bootstrap;
+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.NioSocketChannel;
+
+import java.net.InetSocketAddress;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+public class EchoClient {
+    private final static String HOST = "115.238.57.190";
+    private final static int PORT = 8011;
+
+    public static void start() {
+        EventLoopGroup group = new NioEventLoopGroup();
+        Bootstrap bootstrap = new Bootstrap();
+        bootstrap.group(group)
+                .channel(NioSocketChannel.class)
+                .remoteAddress(new InetSocketAddress(HOST, PORT))
+                .handler(new ChannelInitializer<SocketChannel>() {
+                    @Override
+                    protected void initChannel(SocketChannel socketChannel) throws Exception {
+                        socketChannel.pipeline().addLast(new EchoClientHandler());
+                    }
+                });
+        try {
+            ChannelFuture f = bootstrap.connect().sync();
+            f.channel().closeFuture().sync();
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }finally {
+            group.shutdownGracefully();
+        }
+    }
+
+    public static void main(String[] args) {
+        start();
+    }
+
+}

+ 41 - 0
huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/server/client/EchoClientHandler.java

@@ -0,0 +1,41 @@
+package com.huimv.eartag2.server.client;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.ChannelHandler.Sharable;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.SimpleChannelInboundHandler;
+import io.netty.util.CharsetUtil;
+
+@Sharable
+public class EchoClientHandler extends SimpleChannelInboundHandler<ByteBuf> {
+    @Override
+    public void channelActive(ChannelHandlerContext ctx) throws Exception {
+        System.out.println("ctx.name()>>"+ctx.name());
+        //当被通知Channel是活跃的时候,发送一条消息
+        ctx.writeAndFlush(Unpooled.copiedBuffer("Netty rocks!>>>>>>>>>>>>>>>>>>>>>>>>>", CharsetUtil.UTF_8));
+    }
+
+    @Override
+    protected void channelRead0(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf) throws Exception {
+        System.out.println(
+                "Client received: " + byteBuf.toString(CharsetUtil.UTF_8)
+        );
+    }
+
+    @Override
+    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
+        cause.printStackTrace();
+        ctx.close();
+    }
+
+}

+ 56 - 0
huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/server/client2/EchoClient.java

@@ -0,0 +1,56 @@
+package com.huimv.eartag2.server.client2;
+
+import io.netty.bootstrap.Bootstrap;
+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.NioSocketChannel;
+
+import java.net.InetSocketAddress;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+public class EchoClient {
+    private  String host;
+    private int port;
+    public EchoClient(String host,int port){
+        this.port=port;
+        this.host=host;
+    }
+
+    public static void main(String[] args) throws InterruptedException {
+        new EchoClient("127.0.0.1",8011).start();
+    }
+
+    private void start() throws InterruptedException {
+        EventLoopGroup loopGroup = new NioEventLoopGroup();
+        try{
+            Bootstrap bootstrap = new Bootstrap();
+            bootstrap.group(loopGroup)
+                    .channel(NioSocketChannel.class)
+                    .remoteAddress(new InetSocketAddress(host, port))
+                    .handler(new ChannelInitializer<SocketChannel>() {
+                        @Override
+                        protected void initChannel(SocketChannel socketChannel) throws Exception {
+                            socketChannel.pipeline().addLast(new EchoClientHandler());
+                        }
+                    });
+            //连接到服务端,connect是异步连接,调用sync同步等待连接成功
+            ChannelFuture channelFuture = bootstrap.connect().sync();
+
+            //阻塞直到客户端通道关闭
+            channelFuture.channel().closeFuture().sync();
+        }finally {
+            loopGroup.shutdownGracefully();
+        }
+    }
+
+}

+ 43 - 0
huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/server/client2/EchoClientHandler.java

@@ -0,0 +1,43 @@
+package com.huimv.eartag2.server.client2;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.SimpleChannelInboundHandler;
+import io.netty.util.CharsetUtil;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+public class EchoClientHandler  extends SimpleChannelInboundHandler<ByteBuf> {
+    @Override
+    protected void channelRead0(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf) throws Exception {
+        System.out.println("EchoClient :receive"+byteBuf.toString(CharsetUtil.UTF_8));
+
+    }
+
+    @Override
+    public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
+
+        ctx.writeAndFlush("read complete");
+        System.out.println("client read ok");
+    }
+
+    @Override
+    public void channelActive(ChannelHandlerContext ctx) throws Exception {
+        System.out.println("client is sign in ");
+        ctx.writeAndFlush(Unpooled.copiedBuffer("哈哈",CharsetUtil.UTF_8));
+    }
+
+    @Override
+    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
+        cause.printStackTrace();
+        ctx.close();
+    }
+
+}

+ 10 - 0
huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/service/IDataService.java

@@ -0,0 +1,10 @@
+package com.huimv.eartag2.service;
+
+import io.netty.channel.ChannelHandlerContext;
+
+import java.text.ParseException;
+
+public interface IDataService {
+    //
+    String handleClientAsk(String receiveData, ChannelHandlerContext ctx) throws ParseException;
+}

+ 14 - 0
huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/service/IDeviceService.java

@@ -0,0 +1,14 @@
+package com.huimv.eartag2.service;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+public interface IDeviceService {
+    //处理采集器设备信息
+    void handleDeviceInfo();
+}

+ 6 - 0
huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/service/IEartagService.java

@@ -0,0 +1,6 @@
+package com.huimv.eartag2.service;
+
+public interface IEartagService {
+    //处理耳标信息
+    void handleEartagInfo();
+}

+ 629 - 0
huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/service/impl/DataServiceImpl.java

@@ -0,0 +1,629 @@
+package com.huimv.eartag2.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+
+import com.huimv.eartag2.common.dao.entity.EartagDataEntity;
+import com.huimv.eartag2.common.dao.entity.EartagEnvEntity;
+import com.huimv.eartag2.common.dao.entity.EartagHeartbeatEntity;
+import com.huimv.eartag2.common.dao.entity.EartagRawEntity;
+import com.huimv.eartag2.common.dao.repo.EartagDataRepo;
+import com.huimv.eartag2.common.dao.repo.EartagEnvRepo;
+import com.huimv.eartag2.common.dao.repo.EartagHeartbeatRepo;
+import com.huimv.eartag2.common.dao.repo.EartagRawRepo;
+import com.huimv.eartag2.producer.Producer;
+import com.huimv.eartag2.service.IDataService;
+import com.huimv.eartag2.service.IDeviceService;
+import com.huimv.eartag2.service.IEartagService;
+import com.huimv.eartag2.utils.DateUtil;
+import io.netty.channel.ChannelHandlerContext;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.core.ValueOperations;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.sql.Timestamp;
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+import java.text.ParseException;
+import java.util.Date;
+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
+ **/
+@Service
+@Slf4j
+public class DataServiceImpl implements IDataService {
+    @Autowired
+    private DateUtil dateUtil;
+    @Autowired
+    private RedisTemplate redisTemplate;
+    @Autowired
+    private EartagRawRepo rawRepo;
+    @Autowired
+    private EartagHeartbeatRepo heartbeatRepo;
+    @Autowired
+    private EartagEnvRepo envRepo;
+    @Autowired
+    private EartagDataRepo eartagDataRepo;
+    @Autowired
+    RabbitTemplate rabbitTemplate;  //使用RabbitTemplate,这提供了接收/发送等等方法
+    @Autowired
+    private IDeviceService deviceService;
+    @Autowired
+    private IEartagService eartagService;
+    @Autowired
+    private Producer producer;
+
+    //处理接收数据
+    @Override
+    public String handleClientAsk(String askText, ChannelHandlerContext ctx) throws ParseException {
+        //--对接收的上报数据解析
+        String answer = parseAskText2(askText);
+        //--将原始数据保存到rabbitMQ
+        producer.sendClientAsk(askText);
+        return answer;
+    }
+
+    //--处理客户端请求
+    public String handleClientAsk_old(String askText, ChannelHandlerContext ctx) throws ParseException {
+        //原始数据
+        Map rawMap = new HashMap();
+        //心跳数据
+        Map heartbeatMap = new HashMap();
+        //温度数据
+        Map envtempMap = new HashMap();
+        //耳标数据
+        JSONObject eartagJo = new JSONObject();
+        //--对接收的上报数据解析
+        String answer = parseAskText(askText, rawMap, heartbeatMap, envtempMap, eartagJo);
+        //--保存数据
+        save(rawMap, heartbeatMap, envtempMap, eartagJo);
+        //--处理分支流程
+//        handleBranch();
+        //--处理采集器信息
+        deviceService.handleDeviceInfo();
+        //--处理耳标信息
+        eartagService.handleEartagInfo();
+        return answer;
+    }
+
+    /**
+     * @Method : handleBranch
+     * @Description : 处理分支流程
+     * @Params : []
+     * @Return : void
+     * @Author : ZhuoNing
+     * @Date : 2022/1/24
+     * @Time : 11:35
+     */
+    private void handleBranch() {
+        //--处理注册表数据
+        handleRegister();
+        //--处理在线记录数据
+        handleOnline();
+        //--处理状态数据
+        handleAllState();
+    }
+
+    /**
+     * @Method : handleAllState
+     * @Description : 处理状态数据
+     * @Params : []
+     * @Return : void
+     * @Author : ZhuoNing
+     * @Date : 2022/1/24
+     * @Time : 14:26
+     */
+    private void handleAllState() {
+
+    }
+
+    /**
+     * @Method : handleOnline
+     * @Description : 处理在线记录数据
+     * @Params : []
+     * @Return : void
+     * @Author : ZhuoNing
+     * @Date : 2022/1/24
+     * @Time : 14:26
+     */
+    private void handleOnline() {
+
+    }
+
+    /**
+     * @Method : handleRegister
+     * @Description : 处理注册表数据
+     * @Params : []
+     * @Return : void
+     * @Author : ZhuoNing
+     * @Date : 2022/1/24
+     * @Time : 14:26
+     */
+    private void handleRegister() {
+        Map map = new HashMap();
+
+        //将消息携带绑定键值:topic.device.register 发送到交换机TestDirectExchange
+        rabbitTemplate.convertAndSend("deviceTopicExchange", "topic.device.register", map);
+    }
+
+    /**
+     * @Method : save
+     * @Description : 保存数据
+     * @Params : [rawMap, heartbeatMap, envtempMap, eartagJo]
+     * @Return : void
+     * @Author : ZhuoNing
+     * @Date : 2022/1/24
+     * @Time : 11:35
+     */
+    private void save(Map rawMap, Map heartbeatMap, Map envtempMap, JSONObject eartagJo) throws ParseException {
+        //--保存原始数据
+        saveRawData(rawMap);
+        //心跳
+        if (heartbeatMap.size() > 0) {
+            //--保存心跳流水数据
+            saveHeartBeat(heartbeatMap);
+        }
+        //采集器温度
+        if (envtempMap.size() > 0) {
+            //--保存采集器温度流水数据
+            saveEnvTempData(envtempMap);
+        }
+        //耳标
+        if (eartagJo.size() > 0) {
+            //--保存耳标流水数据
+            saveEartagData(eartagJo);
+        }
+    }
+
+    /**
+     * 保存心跳数据
+     */
+    private void saveHeartBeat(Map heartbeatMap) {
+        String deviceCode = heartbeatMap.get("device").toString();
+        EartagHeartbeatEntity addHeartbeatEntity = new EartagHeartbeatEntity();
+        addHeartbeatEntity.setDeviceCode(deviceCode);
+        addHeartbeatEntity.setAddTime(new Timestamp(new Date().getTime()));
+        heartbeatRepo.saveAndFlush(addHeartbeatEntity);
+    }
+
+    /**
+     * 保存采集器温度数据
+     */
+    private void saveEnvTempData(Map tempMap) throws ParseException {
+        EartagEnvEntity envEntity = new EartagEnvEntity();
+        envEntity.setDeviceCode(tempMap.get("device").toString());
+        envEntity.setTemp1(Integer.parseInt(tempMap.get("temp").toString()));
+        envEntity.setTemp2(0F);
+        envEntity.setAddTime(new Timestamp(new Date().getTime()));
+        envRepo.saveAndFlush(envEntity);
+    }
+
+    /**
+     * 保存耳标数据
+     */
+    private void saveEartagData(JSONObject eartagJo) {
+        EartagDataEntity dataEntity = new EartagDataEntity();
+        dataEntity.setCmdHeader(eartagJo.getString("cmdHeader"));
+        dataEntity.setDevice(eartagJo.getString("device"));
+        dataEntity.setEarmark(eartagJo.getString("earmark"));
+        dataEntity.setBat(Integer.parseInt(eartagJo.getString("bat")));
+        dataEntity.setEarTemp(Integer.parseInt(eartagJo.getString("earTemp")));
+        dataEntity.setEarTemp1(eartagJo.getFloat("earTemp1"));
+        dataEntity.setEnvTemp(Integer.parseInt(eartagJo.getString("envTemp")));
+        dataEntity.setEnvTemp1(Integer.parseInt(eartagJo.getString("envTemp")));
+        dataEntity.setAct(Integer.parseInt(eartagJo.getString("act")));
+        dataEntity.setAct1(Integer.parseInt(eartagJo.getString("act1")));
+        dataEntity.setSignal1(Integer.parseInt(eartagJo.getString("signal")));
+        dataEntity.setAskTime(getAskTime(eartagJo.getString("askTime")));
+        dataEntity.setOther(eartagJo.getString("other"));
+        dataEntity.setAddTime(new Timestamp(new Date().getTime()));
+        eartagDataRepo.saveAndFlush(dataEntity);
+
+        //最新的耳标数据覆盖老数据
+        Map<String, String> map = new HashMap<>();
+        map.put("cmdHeader", dataEntity.getCmdHeader());
+        map.put("device", dataEntity.getDevice());
+        map.put("earmark", dataEntity.getEarmark());
+        map.put("bat", dataEntity.getBat().toString());
+        map.put("earTemp", dataEntity.getEarTemp().toString());
+        map.put("earTemp1", dataEntity.getEarTemp1().toString());
+        map.put("envTemp", dataEntity.getEnvTemp().toString());
+        map.put("envTemp1", dataEntity.getEnvTemp1().toString());
+        map.put("act", dataEntity.getAct().toString());
+        map.put("act1", dataEntity.getAct1().toString());
+        map.put("signal1", dataEntity.getSignal1().toString());
+        map.put("askTime", dataEntity.getAskTime());
+        map.put("other", dataEntity.getOther());
+        map.put("addTime", dataEntity.getAddTime().toString());
+        //为hash结构设置多个键值对(hmset)
+        redisTemplate.opsForHash().putAll(dataEntity.getDevice(), map);
+    }
+
+    //
+    public String getAskTime(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;
+    }
+
+    /**
+     * 保存原始数据
+     */
+    private void saveRawData(Map rawMap) {
+        //类型、设备、命令、数据内容、日期
+        EartagRawEntity addRawEntity = new EartagRawEntity();
+        addRawEntity.setCmdHeader(rawMap.get("cmdHeader").toString());
+        addRawEntity.setDevice(rawMap.get("device").toString());
+        addRawEntity.setCmd(rawMap.get("cmd").toString());
+        addRawEntity.setAsk(rawMap.get("ask").toString());
+        addRawEntity.setAddTime(new Timestamp(new Date().getTime()));
+        rawRepo.saveAndFlush(addRawEntity);
+    }
+
+    //处理耳标数据
+    private void handleEartag(Map dataMap) {
+        log.info("耳标数据>>" + dataMap.toString());
+    }
+
+    /* 根本设备id获取设备编码 */
+    private String getDeviceCode(String deviceId) {
+        ValueOperations ops = redisTemplate.opsForValue();
+        ops.set("deviceCode", "202007239999869");
+        String deviceCode = (String) ops.get("deviceCode");
+        System.out.println("redis->deviceCode>>" + deviceCode);
+        return deviceCode;
+    }
+
+    /**
+     * 解析接收数据
+     */
+    private String parseAskText2(String askText) throws ParseException {
+        log.info("#开始解析Ask请求数据>>" + askText.trim().replace("\n", ""));
+        String[] dataArray = askText.split("\\+");
+        String cmdHeader = dataArray[0];
+        String answer = null;
+        if (cmdHeader.trim().equalsIgnoreCase("hm")) {
+            //采集器原始数据
+            String device = dataArray[1];
+            String cmd = dataArray[2];
+            //采集器应答数据
+            if (cmd.trim().equalsIgnoreCase("0")) {
+                //不需要处理
+                answer = null;
+            } else if (cmd.trim().equalsIgnoreCase("1")) {
+                //获取设备编码
+                /* 读取设备编码 */
+                String deviceCode = getDeviceCode(device);
+                answer = "hm+1+0+" + deviceCode + "+123+8+end";
+                log.info("##获取设备编码-应答数据>>" + answer);
+            } else if (cmd.trim().equalsIgnoreCase("2")) {
+                //获取服务器时间命令
+//                answer = "hm+2+0+"+dateUtil.getNowText()+"+4+end";
+                answer = "hm+2+" + dateUtil.getNowText() + "+4+end";
+                log.info("##获取服务器时间-应答数据>>" + answer);
+            } else if (cmd.trim().equalsIgnoreCase("3")) {
+                //心跳包命令
+//                heartbeatMap = new HashMap();
+//                answer = "hm+3+0+6+end";
+                answer = "hm+3+6+end";
+                log.info("##心跳包-应答数据>>" + answer);
+            } else if (cmd.trim().equalsIgnoreCase("4")) {
+                //环境温度-设备、数值、上传时间
+//                answer = "hm+4+0+7+end";
+                answer = "hm+4+7+end";
+                log.info("##环境温度-应答数据>>" + answer);
+            } else {
+                log.error("##当前数据为非法数据>>" + askText);
+            }
+            return answer;
+        } else if (cmdHeader.trim().equalsIgnoreCase("zj")) {
+            //应答数据
+            answer = null;
+        } else {
+            log.error("##当前请求数据为非法数据>>" + askText);
+        }
+        return answer;
+    }
+
+    //old
+    private String parseAskText(String askText, Map rawMap, Map heartbeatMap, Map envTempMap, JSONObject eartagJo) throws ParseException {
+        log.info("#开始解析Ask请求数据>>" + askText.trim().replace("\n", ""));
+        String[] dataArray = askText.split("\\+");
+        String cmdHeader = dataArray[0];
+        String answer = null;
+        if (cmdHeader.trim().equalsIgnoreCase("hm")) {
+            //采集器原始数据
+            String device = dataArray[1];
+            String cmd = dataArray[2];
+            rawMap.put("cmdHeader", cmdHeader);
+            rawMap.put("device", device);
+            rawMap.put("cmd", cmd);
+            rawMap.put("ask", askText);
+            //耳标数据
+            //采集器应答数据
+            if (cmd.trim().equalsIgnoreCase("0")) {
+                //不需要处理
+                answer = null;
+            } else if (cmd.trim().equalsIgnoreCase("1")) {
+                //获取设备编码
+                /* 读取设备编码 */
+                String deviceCode = getDeviceCode(device);
+                answer = "hm+1+0+" + deviceCode + "+123+8+end";
+                log.info("##获取设备编码-应答数据>>" + answer);
+            } else if (cmd.trim().equalsIgnoreCase("2")) {
+                //获取服务器时间命令
+                //应答数据
+//                answer = "hm+2+0+"+dateUtil.getNowText()+"+4+end";
+                answer = "hm+2+" + dateUtil.getNowText() + "+4+end";
+                log.info("##获取服务器时间-应答数据>>" + answer);
+            } else if (cmd.trim().equalsIgnoreCase("3")) {
+                //心跳包命令
+//                heartbeatMap = new HashMap();
+                heartbeatMap.put("device", device);
+//                answer = "hm+3+0+6+end";
+                answer = "hm+3+6+end";
+                log.info("##心跳包-应答数据>>" + answer);
+            } else if (cmd.trim().equalsIgnoreCase("4")) {
+                //环境温度-设备、数值、上传时间
+                envTempMap.put("device", dataArray[1]);
+                envTempMap.put("temp", dataArray[4]);
+                envTempMap.put("askTime", dataArray[5]);
+                //应答数据
+//                answer = "hm+4+0+7+end";
+                answer = "hm+4+7+end";
+                log.info("##环境温度-应答数据>>" + answer);
+            } else {
+                log.error("##当前数据为非法数据>>" + askText);
+            }
+            return answer;
+        } else if (cmdHeader.trim().equalsIgnoreCase("zj")) {
+            //应答数据
+            answer = null;
+            //采集器原始数据
+            String device = dataArray[1];
+            rawMap.put("cmdHeader", cmdHeader);
+            rawMap.put("device", device);
+            rawMap.put("cmd", "");
+            rawMap.put("ask", askText);
+            rawMap.put("addTime", dateUtil.getTodayMissionText());
+            //-- 耳标数据 --//
+            //计算耳标温度
+            Double earTemp = 0D;
+            String other = dataArray[9];
+            if (other != null && other.trim().length() > 0) {
+                String[] otherArray = other.split("#");
+                String resi = otherArray[2];
+                Double temp = ln(Integer.parseInt(resi));
+                earTemp = new BigDecimal(temp).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue();
+            }
+            //--计算运动量
+            Integer act1Int = countAct(dataArray[1], dataArray[6]);
+            //命令头
+            eartagJo.put("cmdHeader", dataArray[0]);
+            //采集器id
+            eartagJo.put("device", dataArray[1]);
+            //耳标号
+            eartagJo.put("earmark", dataArray[2]);
+            //电池电量
+            eartagJo.put("bat", dataArray[3]);
+            //耳标温度
+            eartagJo.put("earTemp", dataArray[4]);
+            eartagJo.put("earTemp1", earTemp);
+            //环境温度
+            eartagJo.put("envTemp", dataArray[5]);
+            //运动量
+            eartagJo.put("act", dataArray[6]);
+            eartagJo.put("act1", act1Int);
+            //信号强度
+            eartagJo.put("signal", dataArray[7]);
+            //采集时间
+            eartagJo.put("askTime", dataArray[8]);
+            //预留字段
+            eartagJo.put("other", dataArray[9]);
+        } else {
+            log.error("##当前请求数据为非法数据>>" + askText);
+            //采集器原始数据
+            String device = dataArray[1];
+            rawMap.put("cmdHeader", cmdHeader);
+            rawMap.put("device", device);
+            rawMap.put("cmd", "");
+            rawMap.put("ask", askText);
+//            rawMap.put("addTime",dateUtil.getTodayMissionText());
+        }
+        return answer;
+    }
+
+    /**
+     * @Method : countAct
+     * @Description : 计算act数值
+     * @Params : [deviceCode, nowAct0]
+     * @Return : java.lang.Integer
+     * @Author : ZhuoNing
+     * @Date : 2022/1/18
+     * @Time : 15:25
+     */
+    private Integer countAct(String deviceCode, String nowAct) {
+        //读取hash
+        Object actObj = redisTemplate.opsForHash().get(deviceCode, "act");
+        if (actObj == null) {
+            //--初始化最新的redis记录
+            initRedisObj(deviceCode);
+            Object lastAct = redisTemplate.opsForHash().get(deviceCode, "act");
+            if (lastAct == null) {
+                log.error("#--- redis数据库有问题,请检查redis是否能正常连接 ---# ");
+                return 0;
+            }
+        }
+        Object lastAct = redisTemplate.opsForHash().get(deviceCode, "act");
+        Integer act1 = Integer.parseInt(nowAct) - Integer.parseInt(lastAct.toString());
+//        redisTemplate.opsForHash().put(deviceCode, "act1", act1);
+        return act1;
+    }
+
+    /**
+     * 初始化redis最新记录
+     */
+    private void initRedisObj(String deviceCode) {
+        System.out.println("deviceCode>>" + deviceCode);
+        //
+//        Optional optional = eartagDataRepo.getLastEartagData(deviceCode);
+        EartagDataEntity lastEartagDataEntity = eartagDataRepo.getLastEartagData(deviceCode);
+        if (lastEartagDataEntity != null) {
+//            EartagDataEntity lastEartagDataEntity = (EartagDataEntity) optional.get();
+            System.out.println("## lastEartagDataEntity.toString>>" + lastEartagDataEntity.toString());
+            //--从数据库读取最新记录并覆盖redis
+            Map<String, String> map = new HashMap<>();
+            map.put("cmdHeader", lastEartagDataEntity.getCmdHeader());
+            map.put("device", lastEartagDataEntity.getDevice());
+            map.put("earmark", lastEartagDataEntity.getEarmark());
+            map.put("bat", lastEartagDataEntity.getBat().toString());
+            map.put("earTemp", lastEartagDataEntity.getEarTemp().toString());
+            map.put("earTemp1", lastEartagDataEntity.getEarTemp1().toString());
+            map.put("envTemp", lastEartagDataEntity.getEnvTemp().toString());
+            map.put("envTemp1", lastEartagDataEntity.getEnvTemp1().toString());
+            map.put("act", lastEartagDataEntity.getAct().toString());
+            map.put("act1", lastEartagDataEntity.getAct1().toString());
+            map.put("signal1", lastEartagDataEntity.getSignal1().toString());
+            map.put("askTime", lastEartagDataEntity.getAskTime());
+            map.put("other", lastEartagDataEntity.getOther());
+            map.put("addTime", lastEartagDataEntity.getAddTime().toString());
+            //为hash结构设置多个键值对(hmset)
+            redisTemplate.opsForHash().putAll(deviceCode, map);
+        }
+    }
+
+    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 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);
+        //保留一位小数
+        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;
+    }
+
+    //暂存老代码
+    private String parseAskText_0(String askText, Map rawMap, Map heartbeatMap, Map envTempMap, Map eartagMap) throws ParseException {
+        log.info("#开始解析Ask请求数据>>" + askText.trim().replace("\n", ""));
+        String[] dataArray = askText.split("\\+");
+        String cmdHeader = dataArray[0];
+        String answer = null;
+        heartbeatMap = null;
+        envTempMap = null;
+        eartagMap = null;
+        if (cmdHeader.trim().equalsIgnoreCase("hm")) {
+            //采集器原始数据
+            String device = dataArray[1];
+            String cmd = dataArray[2];
+            rawMap.put("cmdHeader", cmdHeader);
+            rawMap.put("device", device);
+            rawMap.put("cmd", cmd);
+            rawMap.put("ask", askText);
+//            rawMap.put("addTime",dateUtil.getTodayMissionText());
+            //耳标数据
+            eartagMap = null;
+            //采集器应答数据
+            if (cmd.trim().equalsIgnoreCase("0")) {
+                //需要不处理,默认cmdHeader = null
+                answer = null;
+            } else if (cmd.trim().equalsIgnoreCase("1")) {
+                //获取设备编码
+                /* 读取设备编码 */
+                String deviceCode = getDeviceCode(device);
+                answer = "hm+1+0+" + deviceCode + "+123+8+end";
+                log.info("##获取设备编码-应答数据>>" + answer);
+            } else if (cmd.trim().equalsIgnoreCase("2")) {
+                //获取服务器时间命令
+                //应答数据
+//                answer = "hm+2+0+"+dateUtil.getNowText()+"+4+end";
+                answer = "hm+2+" + dateUtil.getNowText() + "+4+end";
+                log.info("##获取服务器时间-应答数据>>" + answer);
+            } else if (cmd.trim().equalsIgnoreCase("3")) {
+                //心跳包命令
+                heartbeatMap = new HashMap();
+                heartbeatMap.put("device", device);
+//                answer = "hm+3+0+6+end";
+                answer = "hm+3+6+end";
+                log.info("##心跳包-应答数据>>" + answer);
+            } else if (cmd.trim().equalsIgnoreCase("4")) {
+                //环境温度-设备、数值、上传时间
+                envTempMap = new HashMap();
+                envTempMap.put("device", dataArray[1]);
+                envTempMap.put("temp", dataArray[4]);
+                envTempMap.put("askTime", dataArray[5]);
+                System.out.println("envTempMap.toString()>>" + envTempMap.toString());
+                //应答数据
+//                answer = "hm+4+0+7+end";
+                answer = "hm+4+7+end";
+                log.info("##环境温度-应答数据>>" + answer);
+            } else {
+                log.error("##当前数据为非法数据>>" + askText);
+            }
+            return answer;
+        } else if (cmdHeader.trim().equalsIgnoreCase("zj")) {
+            //应答数据
+            answer = null;
+            //采集器原始数据
+            String device = dataArray[1];
+            rawMap.put("cmdHeader", cmdHeader);
+            rawMap.put("device", device);
+            rawMap.put("cmd", "");
+            rawMap.put("ask", askText);
+            rawMap.put("addTime", dateUtil.getTodayMissionText());
+            //耳标数据
+            eartagMap = new HashMap();
+            //命令头
+            eartagMap.put("cmdHeader", dataArray[0]);
+            //采集器id
+            eartagMap.put("device", dataArray[1]);
+            //耳标号
+            eartagMap.put("earmark", dataArray[2]);
+            //电池电量
+            eartagMap.put("bat", dataArray[3]);
+            //耳标温度
+            eartagMap.put("earTemp", dataArray[4]);
+            //环境温度
+            eartagMap.put("envTemp", dataArray[5]);
+            //运动量
+            eartagMap.put("act", dataArray[6]);
+            //信号强度
+            eartagMap.put("signal", dataArray[7]);
+            //采集时间
+            eartagMap.put("askTime", dataArray[8]);
+            //预留字段
+            eartagMap.put("other", dataArray[9]);
+            System.out.println("11111111111111111 >>" + eartagMap.toString());
+        } else {
+            log.error("##当前请求数据为非法数据>>" + askText);
+            //采集器原始数据
+            String device = dataArray[1];
+            rawMap.put("cmdHeader", cmdHeader);
+            rawMap.put("device", device);
+            rawMap.put("cmd", "");
+            rawMap.put("ask", askText);
+//            rawMap.put("addTime",dateUtil.getTodayMissionText());
+        }
+        return answer;
+    }
+
+}

+ 46 - 0
huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/service/impl/DeviceServiceImpl.java

@@ -0,0 +1,46 @@
+package com.huimv.eartag2.service.impl;
+
+import com.huimv.eartag2.service.IDeviceService;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
+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 DeviceServiceImpl implements IDeviceService {
+    @Autowired
+    RabbitTemplate rabbitTemplate;  //使用RabbitTemplate,这提供了接收/发送等等方法
+
+    //处理采集器设备信息
+    @Override
+    public void handleDeviceInfo() {
+        //--处理注册表数据
+        handleEartagRegister();
+        //--处理在线记录数据
+        handleEartagOnline();
+        //--处理状态数据
+        handleEartagAllState();
+    }
+
+    //--处理状态数据
+    private void handleEartagAllState() {
+
+    }
+
+    //--处理在线记录数据
+    private void handleEartagOnline() {
+
+    }
+
+    //--处理注册表数据
+    private void handleEartagRegister() {
+
+    }
+}

+ 46 - 0
huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/service/impl/EartagServiceImpl.java

@@ -0,0 +1,46 @@
+package com.huimv.eartag2.service.impl;
+
+import com.huimv.eartag2.service.IEartagService;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
+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 EartagServiceImpl implements IEartagService {
+    @Autowired
+    RabbitTemplate rabbitTemplate;  //使用RabbitTemplate,这提供了接收/发送等等方法
+
+    //处理耳标信息
+    @Override
+    public void handleEartagInfo() {
+        //--处理注册表数据
+        handleDeviceRegister();
+        //--处理在线记录数据
+        handleDeviceOnline();
+        //--处理状态数据
+        handleDeviceAllState();
+    }
+
+    //--处理状态数据
+    private void handleDeviceAllState() {
+
+    }
+
+    //--处理在线记录数据
+    private void handleDeviceOnline() {
+
+    }
+
+    //--处理注册表数据
+    private void handleDeviceRegister() {
+
+    }
+}

+ 12 - 0
huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/utils/BaseTemplete.java

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

+ 187 - 0
huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/utils/DateUtil.java

@@ -0,0 +1,187 @@
+package com.huimv.eartag2.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 DateUtil {
+
+    //格式化日期(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){
+        DateUtil du = new DateUtil();
+        //
+        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();
+    }
+}

+ 516 - 0
huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/utils/HttpTemplete.java

@@ -0,0 +1,516 @@
+package com.huimv.eartag2.utils;
+
+import com.alibaba.fastjson.JSONObject;
+import org.apache.http.HttpEntity;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.*;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+import org.springframework.stereotype.Component;
+
+import java.io.IOException;
+import java.util.*;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@Component
+public class HttpTemplete {
+    private String testHttpIp = "http://localhost:9105";
+
+//    public static void main(String[] args) throws Exception {
+//        //
+//        HttpTemplete client = new HttpTemplete();
+////        client.testGetRequest1();
+//        client.testGetRequest2();
+//    }
+    private Integer connectTimeout = null;
+    private Integer requestTimeout = null;
+    private Integer socketTimeout = null;
+
+    static {
+    }
+
+    //发送简单数据
+    public void doPostSimple(String serviceUrl,String data){
+        System.out.println("推送数据地址:"+serviceUrl);
+        //
+        Map<String,String> paramsMap = new HashMap<String,String>();
+        paramsMap.put("data", data);
+        //
+        Map<String,Integer> timeoutMap = new HashMap<String,Integer>();
+        timeoutMap.put("connectTimeout", 5000);
+        timeoutMap.put("requestTimeout", 5000);
+        timeoutMap.put("socketTimeout", 5000);
+        try{
+            // 用Post方法推送接口数据
+            doPost(serviceUrl,paramsMap,timeoutMap);
+        } catch (IOException e) {
+            System.out.println("###错误信息:"+e.getMessage());
+        }
+    }
+
+
+    /**
+     * @Method      : doPost
+     * @Description : post方式推送接口
+     * @Params      : [url, paramsMap, timeoutMap]
+     * @Return      : com.alibaba.fastjson.JSONObject
+     * 
+     * @Author      : ZhuoNing
+     * @Date        : 2021/11/19       
+     * @Time        : 14:55
+     */
+    public JSONObject doPost(String url, Map<String, String> paramsMap, Map<String, Integer> timeoutMap) throws IOException {
+        // 创建默认的httpClient实例.
+        CloseableHttpClient httpClient = getHttpClientConnection();
+        //
+        int connectTimeout = timeoutMap.get("connectTimeout");
+        int requestTimeout = timeoutMap.get("requestTimeout");
+        int socketTimeout = timeoutMap.get("socketTimeout");
+        // 创建httpPost
+        HttpPost httpPost = new HttpPost(url);
+        RequestConfig requestConfig = RequestConfig.custom()
+                .setSocketTimeout(socketTimeout) //服务器响应超时时间
+                .setConnectTimeout(connectTimeout) //连接服务器超时时间
+                .setConnectionRequestTimeout(requestTimeout)
+                .build();
+        httpPost.setConfig(requestConfig);
+        // 创建参数队列
+        List<NameValuePair> paramsList = new ArrayList<NameValuePair>();
+        Set<Map.Entry<String, String>> entrySet = paramsMap.entrySet();
+        for (Map.Entry<String, String> e : entrySet) {
+            String name = e.getKey();
+            String value = e.getValue();
+            NameValuePair pair = new BasicNameValuePair(name, value);
+            paramsList.add(pair);
+        }
+        UrlEncodedFormEntity content = new UrlEncodedFormEntity(paramsList, "UTF-8");
+        //处理乱码
+//        StringEntity content = new StringEntity(paramsList.toString(), Charset.forName("UTF-8"));// 第二个参数,设置后才会对,内容进行编码
+//        content.setContentType("application/soap+xml; charset=UTF-8");
+//        content.setContentEncoding("UTF-8");
+        httpPost.setEntity(content);
+//        HttpUriRequest httpPost = RequestBuilder.post().setUri(url).setEntity(content).setConfig(requestConfig);
+        CloseableHttpResponse response = httpClient.execute(httpPost);
+        // 获取响应实体
+        HttpEntity entity = response.getEntity();
+        try {
+            if (response.getStatusLine().getStatusCode() == 200) {
+                // 打印响应内容
+                String text = EntityUtils.toString(entity, "utf-8");
+                JSONObject resultJo = new JSONObject();
+                resultJo.put("status", true);
+                resultJo.put("content", text);
+                return resultJo;
+            }else{
+                String text = EntityUtils.toString(entity, "utf-8");
+                JSONObject resultJo = new JSONObject();
+                resultJo.put("status", false);
+                resultJo.put("content", text);
+                return resultJo;
+            }
+        } finally {
+            //释放资源
+            if (response != null) {
+                response.close();
+            }
+            if (httpClient != null) {
+                httpClient.close();
+            }
+        }
+    }
+
+    /**
+     * @Method      : setTimeout
+     * @Description : 
+     * @Params      : [connectTimeout, requestTimeout, socketTimeout]
+     * @Return      : void
+     * 
+     * @Author      : ZhuoNing
+     * @Date        : 2021/11/23       
+     * @Time        : 9:36
+     */
+    public Map<String, Integer> setTimeout(Integer connectTimeout, Integer requestTimeout, Integer socketTimeout){
+        //
+        if(connectTimeout == null){
+            this.connectTimeout = 3000;
+        }else{
+            this.connectTimeout = connectTimeout;
+        }
+        //
+        if(requestTimeout == null){
+            this.requestTimeout = 3000;
+        }else{
+            this.requestTimeout = requestTimeout;
+        }
+        //
+        if(socketTimeout == null){
+            this.socketTimeout = 3000;
+        }else{
+            this.socketTimeout = socketTimeout;
+        }
+        Map<String, Integer> timeoutMap = new HashMap<String, Integer>();
+        timeoutMap.put("connectTimeout", this.connectTimeout);
+        timeoutMap.put("requestTimeout", this.requestTimeout);
+        timeoutMap.put("socketTimeout", this.socketTimeout);
+        return timeoutMap;
+    }
+
+    /**
+     * @Method      : setTimeout
+     * @Description : 
+     * @Params      : [connectTimeout, requestTimeout, socketTimeout]
+     * @Return      : java.util.Map<java.lang.String,java.lang.Integer>
+     * 
+     * @Author      : ZhuoNing
+     * @Date        : 2021/11/23       
+     * @Time        : 9:41
+     */
+    public Map<String, Integer> setTimeout(String connectTimeout, String requestTimeout, String socketTimeout){
+        //
+        if(connectTimeout == null){
+            this.connectTimeout = 3000;
+        }else{
+            this.connectTimeout = Integer.parseInt(connectTimeout);
+        }
+        //
+        if(requestTimeout == null){
+            this.requestTimeout = 3000;
+        }else{
+            this.requestTimeout = Integer.parseInt(requestTimeout);
+        }
+        //
+        if(socketTimeout == null){
+            this.socketTimeout = 3000;
+        }else{
+            this.socketTimeout = Integer.parseInt(socketTimeout);
+        }
+        Map<String, Integer> timeoutMap = new HashMap<String, Integer>();
+        timeoutMap.put("connectTimeout", this.connectTimeout);
+        timeoutMap.put("requestTimeout", this.requestTimeout);
+        timeoutMap.put("socketTimeout", this.socketTimeout);
+        return timeoutMap;
+    }
+
+    /**
+     * @Method      : doGet
+     * @Description : 
+     * @Params      : [url, paramsMap]
+     * @Return      : com.alibaba.fastjson.JSONObject
+     * 
+     * @Author      : ZhuoNing
+     * @Date        : 2021/11/23       
+     * @Time        : 9:34
+     */
+    public JSONObject doGet(String url, Map<String, String> paramsMap) throws IOException {
+        //
+        if(this.connectTimeout == null){
+            this.connectTimeout = 3000;
+        }
+        //
+        if(this.requestTimeout == null)
+        {
+            this.requestTimeout = 3000;
+        }
+        //
+        if(this.socketTimeout == null){
+            this.socketTimeout = 3000;
+        }
+        Map<String, Integer> timeoutMap = new HashMap<String, Integer>();
+        timeoutMap.put("connectTimeout", this.connectTimeout);
+        timeoutMap.put("requestTimeout", this.requestTimeout);
+        timeoutMap.put("socketTimeout", this.socketTimeout);
+        //
+        CloseableHttpClient httpClient = getHttpClientConnection();
+        //执行//获取请求内容
+        CloseableHttpResponse response = httpClient.execute(getHttpRequest(url, paramsMap, timeoutMap));
+        try {
+            // 获取响应实体
+            HttpEntity entity = response.getEntity();
+            // 打印响应状态
+            if (response.getStatusLine().getStatusCode() == 200) {
+                // 打印响应内容
+                String text = EntityUtils.toString(entity, "utf-8");
+                JSONObject resultJo = new JSONObject();
+                resultJo.put("status", true);
+                resultJo.put("content", text);
+                return resultJo;
+            } else {
+                String text = EntityUtils.toString(entity, "utf-8");
+                JSONObject resultJo = new JSONObject();
+                resultJo.put("status", false);
+                resultJo.put("content", text);
+                return resultJo;
+            }
+        } finally {
+            //释放资源
+            if (response != null) {
+                response.close();
+            }
+            if (httpClient != null) {
+                httpClient.close();
+            }
+        }
+    }
+
+    private CloseableHttpClient httpClient = null;
+    private CloseableHttpResponse response = null;
+
+    public JSONObject doGetBatch(String url, Map<String, String> paramsMap) throws IOException {
+        //
+        if(this.connectTimeout == null){
+            this.connectTimeout = 3000;
+        }
+        //
+        if(this.requestTimeout == null)
+        {
+            this.requestTimeout = 3000;
+        }
+        //
+        if(this.socketTimeout == null){
+            this.socketTimeout = 3000;
+        }
+        Map<String, Integer> timeoutMap = new HashMap<String, Integer>();
+        timeoutMap.put("connectTimeout", this.connectTimeout);
+        timeoutMap.put("requestTimeout", this.requestTimeout);
+        timeoutMap.put("socketTimeout", this.socketTimeout);
+        //
+        httpClient = getHttpClientConnection();
+        //执行//获取请求内容
+        response = httpClient.execute(getHttpRequest(url, paramsMap, timeoutMap));
+        // 获取响应实体
+        HttpEntity entity = response.getEntity();
+        // 打印响应状态
+        if (response.getStatusLine().getStatusCode() == 200) {
+                // 打印响应内容
+                String text = EntityUtils.toString(entity, "utf-8");
+                JSONObject resultJo = new JSONObject();
+                resultJo.put("status", true);
+                resultJo.put("content", text);
+                return resultJo;
+        } else {
+                String text = EntityUtils.toString(entity, "utf-8");
+                JSONObject resultJo = new JSONObject();
+                resultJo.put("status", false);
+                resultJo.put("content", text);
+                return resultJo;
+        }
+    }
+
+    //关闭http连接
+    public void closeHttpConn() throws IOException {
+        System.out.println("开始释放http连接资源");
+        //释放资源
+        if (response != null) {
+            response.close();
+        }
+        if (httpClient != null) {
+            httpClient.close();
+        }
+    }
+
+    /**
+     * @Method : doGet
+     * @Description :get方式推送接口
+     * @Params : [url, paramsMap, timeoutMap]
+     * @Return : com.alibaba.fastjson.JSONObject
+     * @Author : ZhuoNing
+     * @Date : 2021/11/18
+     * @Time : 17:39
+     */
+    public JSONObject doGet(String url, Map<String, String> paramsMap, Map<String, Integer> timeoutMap) throws IOException {
+        if (timeoutMap == null) {
+            timeoutMap.put("connectTimeout", 5000);
+            timeoutMap.put("requestTimeout", 5000);
+            timeoutMap.put("socketTimeout", 5000);
+        }
+        //
+        CloseableHttpClient httpClient = getHttpClientConnection();
+        //执行//获取请求内容
+        CloseableHttpResponse response = httpClient.execute(getHttpRequest(url, paramsMap, timeoutMap));
+        try {
+            // 获取响应实体
+            HttpEntity entity = response.getEntity();
+            // 打印响应状态
+            if (response.getStatusLine().getStatusCode() == 200) {
+                // 打印响应内容
+                String text = EntityUtils.toString(entity, "utf-8");
+                JSONObject resultJo = new JSONObject();
+                resultJo.put("status", true);
+                resultJo.put("content", text);
+                return resultJo;
+            } else {
+                String text = EntityUtils.toString(entity, "utf-8");
+                JSONObject resultJo = new JSONObject();
+                resultJo.put("status", false);
+                resultJo.put("content", text);
+                return resultJo;
+            }
+        } finally {
+            //释放资源
+            if (response != null) {
+                response.close();
+            }
+            if (httpClient != null) {
+                httpClient.close();
+            }
+        }
+    }
+
+    private void testGetRequest1() throws IOException {
+        Map<String, Integer> timeoutMap = new HashMap<String, Integer>();
+        timeoutMap.put("connectTimeout", 5000);
+        timeoutMap.put("requestTimeout", 5000);
+        timeoutMap.put("socketTimeout", 5000);
+        String url = testHttpIp + "/token/getToken?userId=20210501&timestamp=45546546454&random=1156&sign=7fa431325504e01e9fa87ed0e274c40c";
+        // test error
+        url = testHttpIp + "/token/getToken?userId=20210501&timestamp=45546546454&random=1156&sign=7fa431325504e01e9fa87ed0e274c40c&userId=20210501&timestamp=45546546454&random=1156&sign=7fa431325504e01e9fa87ed0e274c40c";
+        CloseableHttpClient httpClient = getHttpClientConnection();
+        CloseableHttpResponse response = httpClient.execute(getHttpRequest(url, timeoutMap));
+        // 打印响应状态
+        System.out.println("响应状态1 =" + response.getStatusLine());
+        try {
+            if (response.getStatusLine().getStatusCode() == 200) {
+                // 获取响应实体
+                HttpEntity entity = response.getEntity();
+                // 打印响应内容
+                String text = EntityUtils.toString(entity, "utf-8");
+                System.out.println("响应内容=" + text);
+
+                JSONObject resultJo = JSONObject.parseObject(text);
+                System.out.println("accessToken=" + resultJo.getString("accessToken"));
+            } else {
+                System.out.println("请求失败");
+            }
+        } finally {
+            //释放资源
+            if (response != null) {
+                response.close();
+            }
+            if (httpClient != null) {
+                httpClient.close();
+            }
+        }
+    }
+
+    //
+    private CloseableHttpClient getHttpClientConnection() {
+        //创建默认实例
+        CloseableHttpClient httpclient = HttpClients.createDefault();
+        //
+//        CloseableHttpClient httpClient = HttpClientBuilder.create().build();
+        return httpclient;
+    }
+    //
+    private HttpUriRequest getHttpRequest(String url, Map<String, String> map, Map<String, Integer> timeoutMap) {
+        int connectTimeout = timeoutMap.get("connectTimeout");
+        int requestTimeout = timeoutMap.get("requestTimeout");
+        int socketTimeout = timeoutMap.get("socketTimeout");
+//        System.out.println("core connectTimeout="+connectTimeout);
+//        System.out.println("core requestTimeout="+requestTimeout);
+//        System.out.println("core socketTimeout="+socketTimeout);
+
+        List<NameValuePair> params = new ArrayList<NameValuePair>();
+        Set<Map.Entry<String, String>> entrySet = map.entrySet();
+        for (Map.Entry<String, String> e : entrySet) {
+            String name = e.getKey();
+            String value = e.getValue();
+            NameValuePair pair = new BasicNameValuePair(name, value);
+            params.add(pair);
+        }
+        //
+        RequestConfig requestConfig = RequestConfig.custom()
+                .setConnectTimeout(connectTimeout).setConnectionRequestTimeout(requestTimeout)
+                .setSocketTimeout(socketTimeout).build();
+        HttpUriRequest httpGet = RequestBuilder.get().setUri(url)
+                .addParameters(params.toArray(new BasicNameValuePair[params.size()]))
+                .setConfig(requestConfig).build();
+        return httpGet;
+    }
+    //
+    private HttpGet getHttpRequest(String url, Map<String, Integer> timeoutMap) {
+        int connectTimeout = timeoutMap.get("connectTimeout");
+        int requestTimeout = timeoutMap.get("requestTimeout");
+        int socketTimeout = timeoutMap.get("socketTimeout");
+
+        HttpGet httpGet = new HttpGet(url);
+        //设置超时时间
+        RequestConfig requestConfig = RequestConfig.custom()
+                .setConnectTimeout(connectTimeout).setConnectionRequestTimeout(requestTimeout)
+                .setSocketTimeout(socketTimeout).build();
+        httpGet.setConfig(requestConfig);
+        return httpGet;
+    }
+
+    //test
+    private void get() {
+//        CloseableHttpClient httpclient = HttpClients.createDefault();
+//        try {
+//            // 创建httpget.
+//            HttpGet httpget = new HttpGet(httpIp + "/token/getToken?userId=20210501&timestamp=45546546454&random=1156&sign=7fa431325504e01e9fa87ed0e274c40c");
+//            System.out.println("executing request " + httpget.getURI());
+//            // 执行get请求.
+//            CloseableHttpResponse response = httpclient.execute(httpget);
+//            try {
+//                // 获取响应实体
+//                HttpEntity entity = response.getEntity();
+//                System.out.println("--------------------------------------");
+//                // 打印响应状态
+//                System.out.println(response.getStatusLine());
+//                if (entity != null) {
+//                    // 打印响应内容长度
+//                    System.out.println("Response content length: " + entity.getContentLength());
+//                    // 打印响应内容
+//                    System.out.println("Response content: " + EntityUtils.toString(entity));
+//                }
+//                System.out.println("------------------------------------");
+//            } finally {
+//                response.close();
+//            }
+//        } catch (ClientProtocolException e) {
+//            e.printStackTrace();
+//        } catch (ParseException e) {
+//            e.printStackTrace();
+//        } catch (IOException e) {
+//            e.printStackTrace();
+//        } finally {
+//            // 关闭连接,释放资源
+//            try {
+//                httpclient.close();
+//            } catch (IOException e) {
+//                e.printStackTrace();
+//            }
+//        }
+    }
+
+
+    private void getRequest() throws IOException {
+//        //1.打开浏览器
+//        CloseableHttpClient httpClient = HttpClients.createDefault();
+//        //2.声明get请求
+//        HttpGet httpGet = new HttpGet(httpIp + "/token/getToken?userId=20210501&timestamp=45546546454&random=1156&sign=7fa431325504e01e9fa87ed0e274c40c");
+//        //3.发送请求
+//        CloseableHttpResponse response = httpClient.execute(httpGet);
+//        System.out.println("StatusCode=" + response.getStatusLine().getStatusCode());
+//        //4.判断状态码
+//        if (response.getStatusLine().getStatusCode() == 200) {
+//            HttpEntity entity = response.getEntity();
+//            //使用工具类EntityUtils,从响应中取出实体表示的内容并转换成字符串
+//            String string = EntityUtils.toString(entity, "utf-8");
+//            System.out.println(string);
+//        }
+//        //5.关闭资源
+//        response.close();
+//        httpClient.close();
+    }
+}

+ 89 - 0
huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/utils/MathUtil.java

@@ -0,0 +1,89 @@
+package com.huimv.eartag2.utils;
+
+import org.springframework.stereotype.Component;
+
+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 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);
+        //保留一位小数
+        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);
+    }
+
+}

+ 266 - 0
huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/utils/ip/AddressUtils.java

@@ -0,0 +1,266 @@
+package com.huimv.eartag2.utils.ip;
+
+import java.io.*;
+import java.net.*;
+import java.util.Enumeration;
+import java.util.Scanner;
+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
+ **/
+public class AddressUtils {
+    /**
+     * 获取本机的内网ip地址
+     *
+     * @return
+     * @throws
+     */
+    public String getInnetIp() throws SocketException {
+        String localip = null;// 本地IP,如果没有配置外网IP则返回它
+        String netip = null;// 外网IP
+        Enumeration<NetworkInterface> netInterfaces;
+        netInterfaces = NetworkInterface.getNetworkInterfaces();
+        InetAddress ip = null;
+        boolean finded = false;// 是否找到外网IP
+        while (netInterfaces.hasMoreElements() && !finded) {
+            NetworkInterface ni = netInterfaces.nextElement();
+            Enumeration<InetAddress> address = ni.getInetAddresses();
+            while (address.hasMoreElements()) {
+                ip = address.nextElement();
+                if (!ip.isSiteLocalAddress()
+                        &&!ip.isLoopbackAddress()
+                        &&ip.getHostAddress().indexOf(":") == -1){// 外网IP
+                    netip = ip.getHostAddress();
+                    finded = true;
+                    break;
+                } else if (ip.isSiteLocalAddress()
+                        &&!ip.isLoopbackAddress()
+                        &&ip.getHostAddress().indexOf(":") == -1){// 内网IP
+                    localip = ip.getHostAddress();
+                }
+            }
+        }
+        if (netip != null && !"".equals(netip)) {
+            return netip;
+        } else {
+            return localip;
+        }
+    }
+
+    /**
+     * 获取本机的外网ip地址
+     *
+     * @return
+     */
+    public String getV4IP() {
+        String ip = "";
+        String chinaz = "http://ip.chinaz.com";
+
+        StringBuilder inputLine = new StringBuilder();
+        String read = "";
+        URL url = null;
+        HttpURLConnection urlConnection = null;
+        BufferedReader in = null;
+        try {
+            url = new URL(chinaz);
+            urlConnection = (HttpURLConnection) url.openConnection();
+            in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream(), "UTF-8"));
+            while ((read = in.readLine()) != null) {
+                inputLine.append(read + "\r\n");
+            }
+            //System.out.println(inputLine.toString());
+        } catch (MalformedURLException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            if (in != null) {
+                try {
+                    in.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        Pattern p = Pattern.compile("\\<dd class\\=\"fz24\">(.*?)\\<\\/dd>");
+        Matcher m = p.matcher(inputLine.toString());
+        if (m.find()) {
+            String ipstr = m.group(1);
+            ip = ipstr;
+            //System.out.println(ipstr);
+        }
+        System.out.println("## ip>>"+ip);
+        return ip;
+    }
+
+
+    /**
+     * 解析ip地址
+     *
+     * 设置访问地址为http://ip.taobao.com/service/getIpInfo.php
+     * 设置请求参数为ip=[已经获得的ip地址]
+     * 设置解码方式为UTF-8
+     *
+     *
+     * @param content   请求的参数 格式为:ip=192.168.1.101
+     * @param encoding 服务器端请求编码。如GBK,UTF-8等
+     * @return
+     * @throws
+     */
+    public String getAddresses(String content, String encoding) throws UnsupportedEncodingException {
+        //设置访问地址
+        String urlStr = "http://ip.taobao.com/service/getIpInfo.php";
+        // 从http://whois.pconline.com.cn取得IP所在的省市区信息
+        String returnStr = this.getResult(urlStr, content, encoding);
+        if (returnStr != null) {
+            // 处理返回的省市区信息
+            // System.out.println(returnStr);
+            String[] temp = returnStr.split(",");
+            if (temp.length < 3) {
+                return "0";// 无效IP,局域网测试
+            }
+
+            String country = ""; //国家
+            String area = ""; //地区
+            String region = ""; //省份
+            String city = ""; //市区
+            String county = ""; //地区
+            String isp = ""; //ISP公司
+            for (int i = 0; i < temp.length; i++) {
+                switch (i) {
+                    case 2:
+                        country = (temp[i].split(":"))[1].replaceAll("\"", "");
+                        country = URLDecoder.decode(country, encoding);// 国家
+                        break;
+                    case 3:
+                        area = (temp[i].split(":"))[1].replaceAll("\"", "");
+                        area = URLDecoder.decode(area, encoding);// 地区
+                        break;
+                    case 4:
+                        region = (temp[i].split(":"))[1].replaceAll("\"", "");
+                        region = URLDecoder.decode(region, encoding);// 省份
+                        break;
+                    case 5:
+                        city = (temp[i].split(":"))[1].replaceAll("\"", "");
+                        city = URLDecoder.decode(city, encoding);// 市区
+                        if ("内网IP".equals(city)) {
+                            return "地址为:内网IP";
+                        }
+                        break;
+                    case 6:
+                        county = (temp[i].split(":"))[1].replaceAll("\"", "");
+                        county = URLDecoder.decode(county, encoding);// 地区
+                        break;
+                    case 7:
+                        isp = (temp[i].split(":"))[1].replaceAll("\"", "");
+                        isp = URLDecoder.decode(isp, encoding); // ISP公司
+                        break;
+                }
+            }
+            return new StringBuffer("地址为:" + country + ",").append(region + "省,").append(city + "市,").append(county + ",").append("ISP公司:" + isp)
+                    .toString();
+        }
+        return null;
+    }
+
+
+    /**
+     * 访问目标地址并获取返回值
+     *
+     * @param urlStr   请求的地址
+     * @param content  请求的参数 格式为:ip=192.168.1.101
+     * @param encoding 服务器端请求编码。如GBK,UTF-8等
+     * @return
+     */
+    private String getResult(String urlStr, String content, String encoding) {
+        URL url = null;
+        HttpURLConnection connection = null;
+        try {
+            url = new URL(urlStr);
+            connection = (HttpURLConnection) url.openConnection();// 新建连接实例
+            connection.setConnectTimeout(2000);// 设置连接超时时间,单位毫秒
+            connection.setReadTimeout(33000);// 设置读取数据超时时间,单位毫秒
+            connection.setDoOutput(true);// 是否打开输出流 true|false
+            connection.setDoInput(true);// 是否打开输入流true|false
+            connection.setRequestMethod("POST");// 提交方法POST|GET
+            connection.setUseCaches(false);// 是否缓存true|false
+            connection.connect();// 打开连接端口
+            DataOutputStream out = new DataOutputStream(connection.getOutputStream());// 打开输出流往对端服务器写数据
+            out.writeBytes(content);// 写数据,也就是提交你的表单 name=xxx&pwd=xxx
+            out.flush();// 刷新
+            out.close();// 关闭输出流
+            BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), encoding));
+            // 往对端写完数据对端服务器返回数据
+            // ,以BufferedReader流来读取
+            StringBuffer buffer = new StringBuffer();
+            String line = "";
+            while ((line = reader.readLine()) != null) {
+                buffer.append(line);
+            }
+            reader.close();
+            return buffer.toString();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            if (connection != null) {
+                connection.disconnect();// 关闭连接
+            }
+        }
+        return null;
+    }
+
+
+    /**
+     * 测试方法
+     * 获取本机的内网ip,外网ip和指定ip的地址
+     *
+     * @param args
+     */
+    public static void main(String[] args) {
+        AddressUtils addressUtils = new AddressUtils();
+        //step1.获得内网ip和外网ip,并输出到控制台
+        String ip1 = "";
+        try {
+            ip1 = addressUtils.getInnetIp(); //局域网的ip地址,比如:192.168.1.101
+        } catch (SocketException e1) {
+            e1.printStackTrace();
+        }
+        System.out.println("内网ip:" + ip1);
+        String ip2 = addressUtils.getV4IP(); //用于实际判断地址的ip
+        System.out.println("外网ip:" + ip2);
+        //step2.根据外网ip地址,得到市级地理位置
+        String address = "";
+        try {
+            address = addressUtils.getAddresses("ip=" + ip2, "utf-8");
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+        // 输出地址,比如:中国,山东省,济南市,联通
+        System.out.println("您的" + address);
+        System.out.println("******************************");
+        System.out.println("请输入想要查询的ip地址(输入exit退出):");
+        Scanner scan = new Scanner(System.in);
+        String ip = "";
+        while (!"exit".equals(ip = scan.next())) {
+            try {
+                address = addressUtils.getAddresses("ip=" + ip, "utf-8");
+            } catch (UnsupportedEncodingException e) {
+                e.printStackTrace();
+            }
+            // 输出地址,比如:中国,山东省,济南市,联通
+            System.out.println(ip + "的" + address);
+            System.out.println("******************************");
+            System.out.println("请输入想要查询的ip地址(输入exit退出):");
+        }
+        scan.close();
+        System.out.println("再见");
+    }
+
+}

+ 57 - 0
huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/utils/ip/IPMain.java

@@ -0,0 +1,57 @@
+package com.huimv.eartag2.utils.ip;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+
+public class IPMain {
+    public static void main(String args[]) {
+        System.out.println(getip.publicip());
+    }
+}
+class getip {
+    public static String publicip() {
+        URL url = null;
+        URLConnection urlconn = null;
+        BufferedReader br = null;
+        try {
+            url = new URL("http://2017.ip138.com/ic.asp");//爬取的网站是百度搜索ip时排名第一的那个
+            urlconn = url.openConnection();
+            br = new BufferedReader(new InputStreamReader(
+                    urlconn.getInputStream()));
+            String buf = null;
+            String get= null;
+            while ((buf = br.readLine()) != null) {
+                get+=buf;
+            }
+            int where,end;
+            for(where=0;where<get.length()&&get.charAt(where)!='[';where++);
+            for(end=where;end<get.length()&&get.charAt(end)!=']';end++);
+            get=get.substring(where+1,end);
+            return get;
+        } catch (MalformedURLException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                br.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return null;
+    }
+}

+ 62 - 0
huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/utils/ip/IPUtils.java

@@ -0,0 +1,62 @@
+package com.huimv.eartag2.utils.ip;
+
+import org.springframework.stereotype.Component;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+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 IPUtils {
+
+    public String getV4IP() {
+        String ip = "";
+        String chinaz = "ht" + "tp" + ":/" + "/i" + "p.ch" + "in" + "az." + "co" + "m";
+        StringBuilder inputLine = new StringBuilder();
+        String read = "";
+        URL url = null;
+        HttpURLConnection urlConnection = null;
+        BufferedReader in = null;
+        try {
+            url = new URL(chinaz);
+            urlConnection = (HttpURLConnection) url.openConnection();
+            in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream(), "UTF-8"));
+            while ((read = in.readLine()) != null) {
+                inputLine.append(read + "\r\n");
+            }
+        } catch (MalformedURLException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            if (in != null) {
+                try {
+                    in.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        System.out.println("inputLine.toString()>>"+inputLine.toString());
+//        Pattern p = Pattern.compile("\\<dd class\\="\&quot;fz24\&quot;">(.*?)\\&lt;\\/dd&gt;");
+//        Matcher m = p.matcher(inputLine.toString());
+//        if (m.find()) {
+//            String ipstr = m.group(1);
+//            ip = ipstr;
+//        }
+        return ip;
+    }
+}

+ 60 - 0
huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/utils/ip/MyTest.java

@@ -0,0 +1,60 @@
+package com.huimv.eartag2.utils.ip;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLConnection;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+public class MyTest {
+    public static void main(String[] args) throws Exception {
+        System.out.print(getV4IP());
+    }
+
+    public static String getV4IP() {
+        String ip=null;
+        try {
+            URL url = new URL("http://www.taobao.com/help/getip.php");
+            URLConnection URLconnection = url.openConnection();
+            HttpURLConnection httpConnection = (HttpURLConnection) URLconnection;
+            int responseCode = httpConnection.getResponseCode();
+            if (responseCode == HttpURLConnection.HTTP_OK) {
+                System.out.println("成功");
+                InputStream in = httpConnection.getInputStream();
+                InputStreamReader isr = new InputStreamReader(in);
+                BufferedReader bufr = new BufferedReader(isr);
+                String str;
+                while ((str = bufr.readLine()) != null) {
+                    ip=str;
+                    System.out.println(str);
+                }
+                bufr.close();
+            } else {
+                System.err.println("失败");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        if(ip!=null){
+
+            char[] chs=ip.toCharArray();
+            ip="";
+            for(int i=0;i<chs.length;i++){
+                if((chs[i]>=48&&chs[i]<=57)||chs[i]==46){
+                    ip+=chs[i];
+                }
+            }
+        }
+        return ip;
+    }
+}

+ 139 - 0
huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/vo/EartagDataVo.java

@@ -0,0 +1,139 @@
+package com.huimv.eartag2.vo;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+public class EartagDataVo {
+    String cmdHeader = "";
+    String device = "";
+    String earmark = "";
+    Integer bat ;
+    Integer earTemp;
+    Integer earTemp1;
+    Integer envTemp;
+    Integer envTemp1;
+    Integer act;
+    Integer signal;
+    String askTime = "";
+
+    public String getOther() {
+        return other;
+    }
+
+    public void setOther(String other) {
+        this.other = other;
+    }
+
+    String other = "";
+
+    public String getCmdHeader() {
+        return cmdHeader;
+    }
+
+    public void setCmdHeader(String cmdHeader) {
+        this.cmdHeader = cmdHeader;
+    }
+
+    public String getDevice() {
+        return device;
+    }
+
+    public void setDevice(String device) {
+        this.device = device;
+    }
+
+    public String getEarmark() {
+        return earmark;
+    }
+
+    public void setEarmark(String earmark) {
+        this.earmark = earmark;
+    }
+
+    public Integer getBat() {
+        return bat;
+    }
+
+    public void setBat(Integer bat) {
+        this.bat = bat;
+    }
+
+    public Integer getEarTemp() {
+        return earTemp;
+    }
+
+    public void setEarTemp(Integer earTemp) {
+        this.earTemp = earTemp;
+    }
+
+    public Integer getEarTemp1() {
+        return earTemp1;
+    }
+
+    public void setEarTemp1(Integer earTemp1) {
+        this.earTemp1 = earTemp1;
+    }
+
+    public Integer getEnvTemp() {
+        return envTemp;
+    }
+
+    public void setEnvTemp(Integer envTemp) {
+        this.envTemp = envTemp;
+    }
+
+    public Integer getEnvTemp1() {
+        return envTemp1;
+    }
+
+    public void setEnvTemp1(Integer envTemp1) {
+        this.envTemp1 = envTemp1;
+    }
+
+    public Integer getAct() {
+        return act;
+    }
+
+    public void setAct(Integer act) {
+        this.act = act;
+    }
+
+    public Integer getSignal() {
+        return signal;
+    }
+
+    public void setSignal(Integer signal) {
+        this.signal = signal;
+    }
+
+    public String getAskTime() {
+        return askTime;
+    }
+
+    public void setAskTime(String askTime) {
+        this.askTime = askTime;
+    }
+
+    @Override
+    public String toString() {
+        return "EartagDataVo{" +
+                "cmdHeader='" + cmdHeader + '\'' +
+                ", device='" + device + '\'' +
+                ", earmark='" + earmark + '\'' +
+                ", bat=" + bat +
+                ", earTemp=" + earTemp +
+                ", earTemp1=" + earTemp1 +
+                ", envTemp=" + envTemp +
+                ", envTemp1=" + envTemp1 +
+                ", act=" + act +
+                ", signal=" + signal +
+                ", askTime='" + askTime + '\'' +
+                ", other='" + other + '\'' +
+                '}';
+    }
+}

+ 99 - 0
huimv-eartag2-platform/huimv-eartag2-input/src/main/resources/application-dev.yml

@@ -0,0 +1,99 @@
+server:
+  port: 8090
+
+spring:
+  application:
+    name: huimv-eartag2-input
+
+  datasource:
+    url: jdbc:mysql://192.168.1.7:3306/huimv-eartag2-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.170
+    port: 5672
+    username: admin
+    password: admin
+    #虚拟host 可以不设置,使用server默认host
+    virtual-host: /
+
+    #确认消息已发送到交换机(Exchange)
+    publisher-confirms: true
+    #确认消息已发送到队列(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
+
+

+ 4 - 0
huimv-eartag2-platform/huimv-eartag2-input/src/main/resources/application.properties

@@ -0,0 +1,4 @@
+spring.profiles.active=dev
+
+#¿ªÆô½¡¿µ¼à¿Ø
+management.endpoints.web.exposure.include=*

+ 24 - 0
huimv-eartag2-platform/huimv-eartag2-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>

+ 65 - 0
huimv-eartag2-platform/huimv-eartag2-input/src/test/java/com/huimv/eartag2/DataTest.java

@@ -0,0 +1,65 @@
+package com.huimv.eartag2;
+
+import com.alibaba.fastjson.JSONArray;
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+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
+ **/
+@SpringBootTest
+public class DataTest {
+
+    @Test
+    public void testData() {
+        String text = "zj+202007239999869+133083123611032+93+0+2368+216+67+20220119172038+1.1#1.0#10464+0+endzj+202111111111111111+133083123611032+93+0+2368+216+67+20220119172038+1.1#1.0#10464+0+endzj+2023333333333333+133083123611032+93+0+2368+216+67+20220119172038+1.1#1.0#10464+0+endzj+202444444444444+133083123611032+93+0+2368+216+67+20220119172038+1.1#1.0#10464+0+end";
+//        String text = "zj+202007239999869+133083123611032+93+0+2368+216+67+20220119172038+1.1#1.0#10464+0+end";
+//        int p1 = text.indexOf("end");
+//        System.out.println("p1=" + p1);
+//        String d1 = text.substring(0, p1 + 3);
+//        System.out.println("d1>>" + d1);
+////
+//        String d2 = text.substring(p1 + 3, text.length());
+//        System.out.println("d2>>" + d2);
+
+
+        //判断位置
+        //获取数据,保存
+        //截取剩下文本作为下一次文本
+        JSONArray dataJa = getPerData(text);
+        for(int a=0;a<dataJa.size();a++){
+            System.out.println(a+","+dataJa.getString(a));
+        }
+
+    }
+
+    public JSONArray getPerData(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;
+    }
+
+}

+ 26 - 0
huimv-eartag2-platform/huimv-eartag2-input/src/test/java/com/huimv/eartag2/utils/IPUtilsTest.java

@@ -0,0 +1,26 @@
+package com.huimv.eartag2.utils;
+
+import com.huimv.eartag2.utils.ip.IPUtils;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@SpringBootTest
+public class IPUtilsTest {
+    @Autowired
+    private IPUtils ipUtils;
+
+    @Test
+    public void test_1(){
+        ipUtils.getV4IP();
+
+    }
+}

+ 15 - 0
huimv-eartag2-platform/huimv-eartag2-manage/pom.xml

@@ -0,0 +1,15 @@
+<?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-eartag2-platform</artifactId>
+        <groupId>com.huimv</groupId>
+        <version>0.0.1-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>huimv-eartag2-manage</artifactId>
+
+
+</project>

+ 95 - 0
huimv-eartag2-platform/huimv-eartag2-manage/src/main/resources/application-dev.yml

@@ -0,0 +1,95 @@
+server:
+  port: 8094
+spring:
+  application:
+    name: huimv-eartag2-manage
+
+  datasource:
+    url: jdbc:mysql://192.168.1.7:3306/huimv-demo-eartag20?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: /
+  #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
+
+  #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
+

+ 2 - 0
huimv-eartag2-platform/huimv-eartag2-manage/src/main/resources/application.properties

@@ -0,0 +1,2 @@
+spring.profiles.active=dev
+        

+ 60 - 0
huimv-eartag2-platform/huimv-eartag2-process/pom.xml

@@ -0,0 +1,60 @@
+<?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-eartag2-platform</artifactId>
+        <groupId>com.huimv</groupId>
+        <version>0.0.1-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>huimv-eartag2-process</artifactId>
+
+    <dependencies>
+        <!-- eartag2-common -->
+        <dependency>
+            <groupId>com.huimv</groupId>
+            <artifactId>huimv-eartag2-common</artifactId>
+            <version>0.0.1-SNAPSHOT</version>
+        </dependency>
+        <!--rabbitmq-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-amqp</artifactId>
+        </dependency>
+        <!-- eartag2-common -->
+        <dependency>
+            <groupId>com.huimv</groupId>
+            <artifactId>huimv-eartag2-common</artifactId>
+            <version>0.0.1-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+        <!-- lombok -->
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <version>1.16.18</version>
+            <scope>provided</scope>
+        </dependency>
+        <!--hutool-->
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+            <version>LATEST</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.5.5</version>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+</project>

+ 23 - 0
huimv-eartag2-platform/huimv-eartag2-process/src/main/java/com/huimv/eartag2/process/HuimvEartag2ProcessApplication.java

@@ -0,0 +1,23 @@
+package com.huimv.eartag2.process;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.domain.EntityScan;
+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
+ **/
+@SpringBootApplication
+@EntityScan(value = "com.huimv.eartag2.common.dao.entity")
+@EnableJpaRepositories(basePackages = "com.huimv.eartag2.common.dao.repo")
+public class HuimvEartag2ProcessApplication {
+    public static void main(String[] args) {
+        SpringApplication.run(HuimvEartag2ProcessApplication.class, args);
+    }
+}

+ 193 - 0
huimv-eartag2-platform/huimv-eartag2-process/src/main/java/com/huimv/eartag2/process/listener/DeviceListener.java

@@ -0,0 +1,193 @@
+package com.huimv.eartag2.process.listener;
+
+import com.alibaba.fastjson.JSONObject;
+import com.huimv.eartag2.common.mq.Const;
+import com.huimv.eartag2.process.producer.ProcessProducer;
+import com.huimv.eartag2.process.service.IDeviceService;
+import com.huimv.eartag2.process.service.IEartagService;
+import com.huimv.eartag2.process.utils.DateUtil;
+import com.huimv.eartag2.process.utils.MathUtil;
+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.math.BigDecimal;
+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
+//@RabbitListener(queues = "topic.device")
+public class DeviceListener {
+    @Autowired
+    private MathUtil mathUtil;
+    @Autowired
+    private DateUtil dateUtil;
+    @Autowired
+    private IDeviceService deviceService;
+    @Autowired
+    private IEartagService eartagService;
+    @Autowired
+    private ProcessProducer processProducer;
+
+//    @RabbitHandler
+//    public void process(Map deviceMap) {
+//        System.out.println("TopicDevice消费者收到消息  : " + deviceMap.toString());
+//    }
+
+    @RabbitListener(queues = "topic.device.register")
+    @RabbitHandler
+    public void processDeviceStatus(Map registerMap) {
+        System.out.println("TopicDevice消费者收到消息  : " + registerMap);
+    }
+
+//    @RabbitListener(queues = "topic.askText.queue")
+    @RabbitListener(queues = Const.QUEUE_NAME_ASK)
+    @RabbitHandler
+    public void processRawdata(Map RawMap) throws ParseException {
+        String askText = RawMap.get("askText").toString();
+        System.out.println("askText>>"+askText);
+        //--保存原始数据
+        //--保存设备心跳数据
+        //--保存设备环境数据
+        //--保存耳标数据
+
+        //--处理请求报文
+        Map askMap = handleAskText(askText);
+        String type = askMap.get("type").toString();
+        JSONObject dataJo = (JSONObject) askMap.get("data");
+        switch (type){
+            case "device-heartbeat":
+                //--(1)处理心跳数据
+                //保存设备注册数据(MySQL,Redis)-processProducer
+                //保存设备在线数据(MySQL,Redis)-processProducer
+                //保存设备状态数据(MySQL,Redis)-processProducer
+                //保存设备心跳流水数据(MySQL)
+                //++++++++++++++++++++++++++++++++++++++++++++++
+                //
+                deviceService.saveDeviceHartbeat(dataJo);
+                //
+                processProducer.sendDeviceMain(dataJo);
+                break;
+            case "device-temp":
+                //--(2)处理环境数据
+                //保存设备注册数据(MySQL,Redis)-processProducer
+                //保存设备环境流水数据(MySQL)
+                //++++++++++++++++++++++++++++++++++++++++++++++
+                //
+                deviceService.saveDeviceTemp(dataJo);
+                //
+                processProducer.sendRegisterMain(dataJo);
+                break;
+            case "eartag":
+                //--(3)处理耳标数据
+                //保存耳标注册数据(MySQL,Redis)-processProducer
+                //保存耳标在线数据(MySQL,Redis)-processProducer
+                //保存耳标状态数据(MySQL,Redis)-processProducer
+                //保存耳标流水数据(MySQL)
+                //++++++++++++++++++++++++++++++++++++++++++++++
+                //
+                eartagService.saveEartag(dataJo);
+                //
+                processProducer.sendEartagMain(dataJo);
+                break;
+            default:
+        }
+        System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
+        //保存原始数据//
+        deviceService.saveRawdata(askText);
+    }
+
+    /**
+     * @Method      : handleAskText
+     * @Description : 处理请求
+     * @Params      : [askText]
+     * @Return      : java.util.Map
+     *
+     * @Author      : ZhuoNing
+     * @Date        : 2022/2/9
+     * @Time        : 13:38
+     */
+    private Map handleAskText(String askText) {
+        Map outMap = new HashMap();
+        JSONObject dataJo = new JSONObject();
+        String type = "";
+        String[] dataArray = askText.split("\\+");
+        String cmdHeader = dataArray[0];
+        if (cmdHeader.trim().equalsIgnoreCase("hm")) {
+            //采集器原始数据
+            String device = dataArray[1];
+            String cmd = dataArray[2];
+            if (cmd.trim().equalsIgnoreCase("0")) {
+                //不需要处理
+            } else if (cmd.trim().equalsIgnoreCase("1")) {
+                //获取设备编码
+            } else if (cmd.trim().equalsIgnoreCase("2")) {
+                //获取服务器时间命令
+            } else if (cmd.trim().equalsIgnoreCase("3")) {
+                //心跳包命令
+                dataJo.put("device", device);
+                type = "device-heartbeat";
+            } else if (cmd.trim().equalsIgnoreCase("4")) {
+                //环境温度-设备、数值、上传时间
+                dataJo.put("device", dataArray[1]);
+                dataJo.put("temp", dataArray[4]);
+                dataJo.put("askTime", dataArray[5]);
+                type = "device-temp";
+            } else {
+                log.error("##当前数据为非法数据>>" + askText);
+            }
+        } else if (cmdHeader.trim().equalsIgnoreCase("zj")) {
+            String device = dataArray[1];
+            //-- 耳标数据 --//
+            //计算耳标温度
+            Double earTemp = 0D;
+            String other = dataArray[9];
+            if (other != null && other.trim().length() > 0) {
+                String[] otherArray = other.split("#");
+                String resi = otherArray[2];
+                Double temp = MathUtil.ln(Integer.parseInt(resi));
+                earTemp = new BigDecimal(temp).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue();
+            }
+            //计算运动量//
+            Integer act1Int = eartagService.countAct(dataArray[1], dataArray[6]);
+            //命令头
+            dataJo.put("cmdHeader", dataArray[0]);
+            //采集器id
+            dataJo.put("device", dataArray[1]);
+            //耳标号
+            dataJo.put("earmark", dataArray[2]);
+            //电池电量
+            dataJo.put("bat", dataArray[3]);
+            //耳标温度
+            dataJo.put("earTemp", dataArray[4]);
+            dataJo.put("earTemp1", earTemp);
+            //环境温度
+            dataJo.put("envTemp", dataArray[5]);
+            //运动量
+            dataJo.put("act", dataArray[6]);
+            dataJo.put("act1", act1Int);
+            //信号强度
+            dataJo.put("signal", dataArray[7]);
+            //采集时间
+            dataJo.put("askTime", dataArray[8]);
+            //预留字段
+            dataJo.put("other", dataArray[9]);
+            type = "eartag";
+        }
+        outMap.put("type",type);
+        outMap.put("data",dataJo);
+        return outMap;
+    }
+}

+ 29 - 0
huimv-eartag2-platform/huimv-eartag2-process/src/main/java/com/huimv/eartag2/process/producer/ProcessProducer.java

@@ -0,0 +1,29 @@
+package com.huimv.eartag2.process.producer;
+
+import com.alibaba.fastjson.JSONObject;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
+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 ProcessProducer {
+    @Autowired
+    RabbitTemplate rabbitTemplate;  //使用RabbitTemplate,这提供了接收/发送等等方法
+
+    public void sendDeviceMain(JSONObject dataJo) {
+    }
+
+    public void sendRegisterMain(JSONObject dataJo) {
+    }
+
+    public void sendEartagMain(JSONObject dataJo) {
+    }
+}

+ 14 - 0
huimv-eartag2-platform/huimv-eartag2-process/src/main/java/com/huimv/eartag2/process/service/IDeviceService.java

@@ -0,0 +1,14 @@
+package com.huimv.eartag2.process.service;
+
+import com.alibaba.fastjson.JSONObject;
+
+import java.text.ParseException;
+
+public interface IDeviceService {
+    //保存心跳数据
+    void saveDeviceHartbeat(JSONObject dataJo);
+    //保存设备温度数据
+    void saveDeviceTemp(JSONObject dataJo);
+    //保存采集器上传的原始数据
+    void saveRawdata(String askText) throws ParseException;
+}

+ 10 - 0
huimv-eartag2-platform/huimv-eartag2-process/src/main/java/com/huimv/eartag2/process/service/IEartagService.java

@@ -0,0 +1,10 @@
+package com.huimv.eartag2.process.service;
+
+import com.alibaba.fastjson.JSONObject;
+
+public interface IEartagService {
+    //计算运动量
+    Integer countAct(String deviceCode, String nowAct);
+    //保存耳标数据
+    void saveEartag(JSONObject dataJo);
+}

+ 97 - 0
huimv-eartag2-platform/huimv-eartag2-process/src/main/java/com/huimv/eartag2/process/service/impl/DeviceServiceImpl.java

@@ -0,0 +1,97 @@
+package com.huimv.eartag2.process.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.huimv.eartag2.common.dao.entity.EartagRawEntity;
+import com.huimv.eartag2.common.dao.repo.EartagRawRepo;
+import com.huimv.eartag2.process.service.IDeviceService;
+import com.huimv.eartag2.process.utils.DateUtil;
+import com.huimv.eartag2.process.utils.MathUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.sql.Timestamp;
+import java.text.ParseException;
+import java.util.Date;
+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
+ **/
+@Service
+@Slf4j
+public class DeviceServiceImpl implements IDeviceService {
+    @Autowired
+    private MathUtil mathUtil;
+    @Autowired
+    private DateUtil dateUtil;
+    @Autowired
+    private EartagRawRepo rawRepo;
+
+    @Override
+    public void saveDeviceHartbeat(JSONObject dataJo) {
+
+    }
+
+    @Override
+    public void saveDeviceTemp(JSONObject dataJo) {
+
+    }
+
+    /**
+     * @Method      : saveRawdata
+     * @Description : 保存原始数据
+     * @Params      : [askText]
+     * @Return      : void
+     *
+     * @Author      : ZhuoNing
+     * @Date        : 2022/2/9
+     * @Time        : 13:38
+     */
+    @Override
+    public void saveRawdata(String askText) throws ParseException {
+//        log.info("#开始解析Ask请求数据>>" + askText.trim().replace("\n", ""));
+        String[] dataArray = askText.split("\\+");
+        String cmdHeader = dataArray[0];
+        Map rawMap = new HashMap();
+        if (cmdHeader.trim().equalsIgnoreCase("hm")) {
+            //采集器原始数据
+            String device = dataArray[1];
+            String cmd = dataArray[2];
+            rawMap.put("cmdHeader", cmdHeader);
+            rawMap.put("device", device);
+            rawMap.put("cmd", cmd);
+            rawMap.put("ask", askText);
+        } else if (cmdHeader.trim().equalsIgnoreCase("zj")) {
+            //采集器原始数据
+            String device = dataArray[1];
+            rawMap.put("cmdHeader", cmdHeader);
+            rawMap.put("device", device);
+            rawMap.put("cmd", "");
+            rawMap.put("ask", askText);
+            rawMap.put("addTime", dateUtil.getTodayMissionText());
+        } else {
+            //采集器原始数据
+            String device = dataArray[1];
+            rawMap.put("cmdHeader", cmdHeader);
+            rawMap.put("device", device);
+            rawMap.put("cmd", "");
+            rawMap.put("ask", askText);
+        }
+        //保存原始数据
+        //类型、设备、命令、数据内容、日期
+        EartagRawEntity addRawEntity = new EartagRawEntity();
+        addRawEntity.setCmdHeader(rawMap.get("cmdHeader").toString());
+        addRawEntity.setDevice(rawMap.get("device").toString());
+        addRawEntity.setCmd(rawMap.get("cmd").toString());
+        addRawEntity.setAsk(rawMap.get("ask").toString());
+        addRawEntity.setAddTime(new Timestamp(new Date().getTime()));
+        rawRepo.saveAndFlush(addRawEntity);
+    }
+}

+ 103 - 0
huimv-eartag2-platform/huimv-eartag2-process/src/main/java/com/huimv/eartag2/process/service/impl/EartagServiceImpl.java

@@ -0,0 +1,103 @@
+package com.huimv.eartag2.process.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.huimv.eartag2.common.dao.entity.EartagDataEntity;
+import com.huimv.eartag2.common.dao.repo.EartagDataRepo;
+import com.huimv.eartag2.process.service.IEartagService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+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
+ **/
+@Service
+@Slf4j
+public class EartagServiceImpl implements IEartagService {
+    @Autowired
+    private RedisTemplate redisTemplate;
+    @Autowired
+    private EartagDataRepo eartagDataRepo;
+
+    /**
+     * @Method : countAct
+     * @Description : 计算act数值
+     * @Params : [deviceCode, nowAct0]
+     * @Return : java.lang.Integer
+     * @Author : ZhuoNing
+     * @Date : 2022/1/18
+     * @Time : 15:25
+     */
+    @Override
+    public Integer countAct(String deviceCode, String nowAct) {
+        //读取hash
+        Object actObj = redisTemplate.opsForHash().get(deviceCode, "act");
+        if (actObj == null) {
+            //--初始化最新的redis记录
+            initRedisObj(deviceCode);
+            Object lastAct = redisTemplate.opsForHash().get(deviceCode, "act");
+            if (lastAct == null) {
+                log.error("#--- redis数据库有问题,请检查redis是否能正常连接 ---# ");
+                return 0;
+            }
+        }
+        Object lastAct = redisTemplate.opsForHash().get(deviceCode, "act");
+        Integer act1 = Integer.parseInt(nowAct) - Integer.parseInt(lastAct.toString());
+//        redisTemplate.opsForHash().put(deviceCode, "act1", act1);
+        return act1;
+    }
+
+    /**
+     * @Method      : saveEartag
+     * @Description : 保存耳标数据
+     * @Params      : [dataJo]
+     * @Return      : void
+     *
+     * @Author      : ZhuoNing
+     * @Date        : 2022/2/9
+     * @Time        : 14:33
+     */
+    @Override
+    public void saveEartag(JSONObject dataJo) {
+
+    }
+
+    /**
+     * 初始化redis最新记录
+     */
+    private void initRedisObj(String deviceCode) {
+        System.out.println("deviceCode>>" + deviceCode);
+        EartagDataEntity lastEartagDataEntity = eartagDataRepo.getLastEartagData(deviceCode);
+        if (lastEartagDataEntity != null) {
+            System.out.println("## lastEartagDataEntity.toString>>" + lastEartagDataEntity.toString());
+            //--从数据库读取最新记录并覆盖redis
+            Map<String, String> map = new HashMap<>();
+            map.put("cmdHeader", lastEartagDataEntity.getCmdHeader());
+            map.put("device", lastEartagDataEntity.getDevice());
+            map.put("earmark", lastEartagDataEntity.getEarmark());
+            map.put("bat", lastEartagDataEntity.getBat().toString());
+            map.put("earTemp", lastEartagDataEntity.getEarTemp().toString());
+            map.put("earTemp1", lastEartagDataEntity.getEarTemp1().toString());
+            map.put("envTemp", lastEartagDataEntity.getEnvTemp().toString());
+            map.put("envTemp1", lastEartagDataEntity.getEnvTemp1().toString());
+            map.put("act", lastEartagDataEntity.getAct().toString());
+            map.put("act1", lastEartagDataEntity.getAct1().toString());
+            map.put("signal1", lastEartagDataEntity.getSignal1().toString());
+            map.put("askTime", lastEartagDataEntity.getAskTime());
+            map.put("other", lastEartagDataEntity.getOther());
+            map.put("addTime", lastEartagDataEntity.getAddTime().toString());
+            //为hash结构设置多个键值对(hmset)
+            redisTemplate.opsForHash().putAll(deviceCode, map);
+        }
+    }
+}

+ 12 - 0
huimv-eartag2-platform/huimv-eartag2-process/src/main/java/com/huimv/eartag2/process/utils/BaseTemplete.java

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

+ 187 - 0
huimv-eartag2-platform/huimv-eartag2-process/src/main/java/com/huimv/eartag2/process/utils/DateUtil.java

@@ -0,0 +1,187 @@
+package com.huimv.eartag2.process.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 DateUtil {
+
+    //格式化日期(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){
+        DateUtil du = new DateUtil();
+        //
+        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();
+    }
+}

+ 89 - 0
huimv-eartag2-platform/huimv-eartag2-process/src/main/java/com/huimv/eartag2/process/utils/MathUtil.java

@@ -0,0 +1,89 @@
+package com.huimv.eartag2.process.utils;
+
+import org.springframework.stereotype.Component;
+
+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 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);
+        //保留一位小数
+        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);
+    }
+
+}

+ 104 - 0
huimv-eartag2-platform/huimv-eartag2-process/src/main/resources/application-dev.yml

@@ -0,0 +1,104 @@
+server:
+  port: 8092
+spring:
+  application:
+    name: huimv-eartag2-process
+
+  datasource:
+    url: jdbc:mysql://192.168.1.7:3306/huimv-demo-eartag20?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.170
+    port: 5672
+    username: admin
+    password: admin
+    #虚拟host 可以不设置,使用server默认host
+    virtual-host: /
+
+  #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
+
+  #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
+
+

+ 2 - 0
huimv-eartag2-platform/huimv-eartag2-process/src/main/resources/application.properties

@@ -0,0 +1,2 @@
+spring.profiles.active=dev
+        

+ 15 - 0
huimv-eartag2-platform/huimv-eartag2-process2/pom.xml

@@ -0,0 +1,15 @@
+<?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-eartag2-platform</artifactId>
+        <groupId>com.huimv</groupId>
+        <version>0.0.1-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>huimv-eartag2-process2</artifactId>
+
+
+</project>

+ 331 - 0
huimv-eartag2-platform/mvnw

@@ -0,0 +1,331 @@
+#!/bin/sh
+# ----------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#    https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# ----------------------------------------------------------------------------
+
+# ----------------------------------------------------------------------------
+# Maven Start Up Batch script
+#
+# Required ENV vars:
+# ------------------
+#   JAVA_HOME - location of a JDK home dir
+#
+# Optional ENV vars
+# -----------------
+#   M2_HOME - location of maven2's installed home dir
+#   MAVEN_OPTS - parameters passed to the Java VM when running Maven
+#     e.g. to debug Maven itself, use
+#       set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+#   MAVEN_SKIP_RC - flag to disable loading of mavenrc files
+# ----------------------------------------------------------------------------
+
+if [ -z "$MAVEN_SKIP_RC" ]; then
+
+  if [ -f /usr/local/etc/mavenrc ]; then
+    . /usr/local/etc/mavenrc
+  fi
+
+  if [ -f /etc/mavenrc ]; then
+    . /etc/mavenrc
+  fi
+
+  if [ -f "$HOME/.mavenrc" ]; then
+    . "$HOME/.mavenrc"
+  fi
+
+fi
+
+# OS specific support.  $var _must_ be set to either true or false.
+cygwin=false
+darwin=false
+mingw=false
+case "$(uname)" in
+CYGWIN*) cygwin=true ;;
+MINGW*) mingw=true ;;
+Darwin*)
+  darwin=true
+  # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
+  # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
+  if [ -z "$JAVA_HOME" ]; then
+    if [ -x "/usr/libexec/java_home" ]; then
+      export JAVA_HOME="$(/usr/libexec/java_home)"
+    else
+      export JAVA_HOME="/Library/Java/Home"
+    fi
+  fi
+  ;;
+esac
+
+if [ -z "$JAVA_HOME" ]; then
+  if [ -r /etc/gentoo-release ]; then
+    JAVA_HOME=$(java-config --jre-home)
+  fi
+fi
+
+if [ -z "$M2_HOME" ]; then
+  ## resolve links - $0 may be a link to maven's home
+  PRG="$0"
+
+  # need this for relative symlinks
+  while [ -h "$PRG" ]; do
+    ls=$(ls -ld "$PRG")
+    link=$(expr "$ls" : '.*-> \(.*\)$')
+    if expr "$link" : '/.*' >/dev/null; then
+      PRG="$link"
+    else
+      PRG="$(dirname "$PRG")/$link"
+    fi
+  done
+
+  saveddir=$(pwd)
+
+  M2_HOME=$(dirname "$PRG")/..
+
+  # make it fully qualified
+  M2_HOME=$(cd "$M2_HOME" && pwd)
+
+  cd "$saveddir"
+  # echo Using m2 at $M2_HOME
+fi
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched
+if $cygwin; then
+  [ -n "$M2_HOME" ] &&
+    M2_HOME=$(cygpath --unix "$M2_HOME")
+  [ -n "$JAVA_HOME" ] &&
+    JAVA_HOME=$(cygpath --unix "$JAVA_HOME")
+  [ -n "$CLASSPATH" ] &&
+    CLASSPATH=$(cygpath --path --unix "$CLASSPATH")
+fi
+
+# For Mingw, ensure paths are in UNIX format before anything is touched
+if $mingw; then
+  [ -n "$M2_HOME" ] &&
+    M2_HOME="$( (
+      cd "$M2_HOME"
+      pwd
+    ))"
+  [ -n "$JAVA_HOME" ] &&
+    JAVA_HOME="$( (
+      cd "$JAVA_HOME"
+      pwd
+    ))"
+fi
+
+if [ -z "$JAVA_HOME" ]; then
+  javaExecutable="$(which javac)"
+  if [ -n "$javaExecutable" ] && ! [ "$(expr \"$javaExecutable\" : '\([^ ]*\)')" = "no" ]; then
+    # readlink(1) is not available as standard on Solaris 10.
+    readLink=$(which readlink)
+    if [ ! $(expr "$readLink" : '\([^ ]*\)') = "no" ]; then
+      if $darwin; then
+        javaHome="$(dirname \"$javaExecutable\")"
+        javaExecutable="$(cd \"$javaHome\" && pwd -P)/javac"
+      else
+        javaExecutable="$(readlink -f \"$javaExecutable\")"
+      fi
+      javaHome="$(dirname \"$javaExecutable\")"
+      javaHome=$(expr "$javaHome" : '\(.*\)/bin')
+      JAVA_HOME="$javaHome"
+      export JAVA_HOME
+    fi
+  fi
+fi
+
+if [ -z "$JAVACMD" ]; then
+  if [ -n "$JAVA_HOME" ]; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ]; then
+      # IBM's JDK on AIX uses strange locations for the executables
+      JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+      JAVACMD="$JAVA_HOME/bin/java"
+    fi
+  else
+    JAVACMD="$(
+      \unset -f command
+      \command -v java
+    )"
+  fi
+fi
+
+if [ ! -x "$JAVACMD" ]; then
+  echo "Error: JAVA_HOME is not defined correctly." >&2
+  echo "  We cannot execute $JAVACMD" >&2
+  exit 1
+fi
+
+if [ -z "$JAVA_HOME" ]; then
+  echo "Warning: JAVA_HOME environment variable is not set."
+fi
+
+CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
+
+# traverses directory structure from process work directory to filesystem root
+# first directory with .mvn subdirectory is considered project base directory
+find_maven_basedir() {
+
+  if [ -z "$1" ]; then
+    echo "Path not specified to find_maven_basedir"
+    return 1
+  fi
+
+  basedir="$1"
+  wdir="$1"
+  while [ "$wdir" != '/' ]; do
+    if [ -d "$wdir"/.mvn ]; then
+      basedir=$wdir
+      break
+    fi
+    # workaround for JBEAP-8937 (on Solaris 10/Sparc)
+    if [ -d "${wdir}" ]; then
+      wdir=$(
+        cd "$wdir/.."
+        pwd
+      )
+    fi
+    # end of workaround
+  done
+  echo "${basedir}"
+}
+
+# concatenates all lines of a file
+concat_lines() {
+  if [ -f "$1" ]; then
+    echo "$(tr -s '\n' ' ' <"$1")"
+  fi
+}
+
+BASE_DIR=$(find_maven_basedir "$(pwd)")
+if [ -z "$BASE_DIR" ]; then
+  exit 1
+fi
+
+##########################################################################################
+# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
+# This allows using the maven wrapper in projects that prohibit checking in binary data.
+##########################################################################################
+if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
+  if [ "$MVNW_VERBOSE" = true ]; then
+    echo "Found .mvn/wrapper/maven-wrapper.jar"
+  fi
+else
+  if [ "$MVNW_VERBOSE" = true ]; then
+    echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
+  fi
+  if [ -n "$MVNW_REPOURL" ]; then
+    jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
+  else
+    jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
+  fi
+  while IFS="=" read key value; do
+    case "$key" in wrapperUrl)
+      jarUrl="$value"
+      break
+      ;;
+    esac
+  done <"$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
+  if [ "$MVNW_VERBOSE" = true ]; then
+    echo "Downloading from: $jarUrl"
+  fi
+  wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
+  if $cygwin; then
+    wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath")
+  fi
+
+  if command -v wget >/dev/null; then
+    if [ "$MVNW_VERBOSE" = true ]; then
+      echo "Found wget ... using wget"
+    fi
+    if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
+      wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
+    else
+      wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
+    fi
+  elif command -v curl >/dev/null; then
+    if [ "$MVNW_VERBOSE" = true ]; then
+      echo "Found curl ... using curl"
+    fi
+    if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
+      curl -o "$wrapperJarPath" "$jarUrl" -f
+    else
+      curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
+    fi
+
+  else
+    if [ "$MVNW_VERBOSE" = true ]; then
+      echo "Falling back to using Java to download"
+    fi
+    javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
+    # For Cygwin, switch paths to Windows format before running javac
+    if $cygwin; then
+      javaClass=$(cygpath --path --windows "$javaClass")
+    fi
+    if [ -e "$javaClass" ]; then
+      if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
+        if [ "$MVNW_VERBOSE" = true ]; then
+          echo " - Compiling MavenWrapperDownloader.java ..."
+        fi
+        # Compiling the Java class
+        ("$JAVA_HOME/bin/javac" "$javaClass")
+      fi
+      if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
+        # Running the downloader
+        if [ "$MVNW_VERBOSE" = true ]; then
+          echo " - Running MavenWrapperDownloader.java ..."
+        fi
+        ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
+      fi
+    fi
+  fi
+fi
+##########################################################################################
+# End of extension
+##########################################################################################
+
+export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
+if [ "$MVNW_VERBOSE" = true ]; then
+  echo $MAVEN_PROJECTBASEDIR
+fi
+MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin; then
+  [ -n "$M2_HOME" ] &&
+    M2_HOME=$(cygpath --path --windows "$M2_HOME")
+  [ -n "$JAVA_HOME" ] &&
+    JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME")
+  [ -n "$CLASSPATH" ] &&
+    CLASSPATH=$(cygpath --path --windows "$CLASSPATH")
+  [ -n "$MAVEN_PROJECTBASEDIR" ] &&
+    MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR")
+fi
+
+# Provide a "standardized" way to retrieve the CLI args that will
+# work with both Windows and non-Windows executions.
+MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
+export MAVEN_CMD_LINE_ARGS
+
+WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+exec "$JAVACMD" \
+  $MAVEN_OPTS \
+  $MAVEN_DEBUG_OPTS \
+  -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
+  "-Dmaven.home=${M2_HOME}" \
+  "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
+  ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"

+ 188 - 0
huimv-eartag2-platform/mvnw.cmd

@@ -0,0 +1,188 @@
+@REM ----------------------------------------------------------------------------
+@REM Licensed to the Apache Software Foundation (ASF) under one
+@REM or more contributor license agreements.  See the NOTICE file
+@REM distributed with this work for additional information
+@REM regarding copyright ownership.  The ASF licenses this file
+@REM to you under the Apache License, Version 2.0 (the
+@REM "License"); you may not use this file except in compliance
+@REM with the License.  You may obtain a copy of the License at
+@REM
+@REM    https://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing,
+@REM software distributed under the License is distributed on an
+@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+@REM KIND, either express or implied.  See the License for the
+@REM specific language governing permissions and limitations
+@REM under the License.
+@REM ----------------------------------------------------------------------------
+
+@REM ----------------------------------------------------------------------------
+@REM Maven Start Up Batch script
+@REM
+@REM Required ENV vars:
+@REM JAVA_HOME - location of a JDK home dir
+@REM
+@REM Optional ENV vars
+@REM M2_HOME - location of maven2's installed home dir
+@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
+@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
+@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
+@REM     e.g. to debug Maven itself, use
+@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
+@REM ----------------------------------------------------------------------------
+
+@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
+@echo off
+@REM set title of command window
+title %0
+@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
+@if "%MAVEN_BATCH_ECHO%" == "on"  echo %MAVEN_BATCH_ECHO%
+
+@REM set %HOME% to equivalent of $HOME
+if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
+
+@REM Execute a user defined script before this one
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
+@REM check for pre script, once with legacy .bat ending and once with .cmd ending
+if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
+if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
+:skipRcPre
+
+@setlocal
+
+set ERROR_CODE=0
+
+@REM To isolate internal variables from possible post scripts, we use another setlocal
+@setlocal
+
+@REM ==== START VALIDATION ====
+if not "%JAVA_HOME%" == "" goto OkJHome
+
+echo.
+echo Error: JAVA_HOME not found in your environment. >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo.
+goto error
+
+:OkJHome
+if exist "%JAVA_HOME%\bin\java.exe" goto init
+
+echo.
+echo Error: JAVA_HOME is set to an invalid directory. >&2
+echo JAVA_HOME = "%JAVA_HOME%" >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo.
+goto error
+
+@REM ==== END VALIDATION ====
+
+:init
+
+@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
+@REM Fallback to current working directory if not found.
+
+set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
+IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
+
+set EXEC_DIR=%CD%
+set WDIR=%EXEC_DIR%
+:findBaseDir
+IF EXIST "%WDIR%"\.mvn goto baseDirFound
+cd ..
+IF "%WDIR%"=="%CD%" goto baseDirNotFound
+set WDIR=%CD%
+goto findBaseDir
+
+:baseDirFound
+set MAVEN_PROJECTBASEDIR=%WDIR%
+cd "%EXEC_DIR%"
+goto endDetectBaseDir
+
+:baseDirNotFound
+set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
+cd "%EXEC_DIR%"
+
+:endDetectBaseDir
+
+IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
+
+@setlocal EnableExtensions EnableDelayedExpansion
+for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
+@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
+
+:endReadAdditionalConfig
+
+SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
+set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
+set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
+
+FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
+    IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
+)
+
+@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
+@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
+if exist %WRAPPER_JAR% (
+    if "%MVNW_VERBOSE%" == "true" (
+        echo Found %WRAPPER_JAR%
+    )
+) else (
+    if not "%MVNW_REPOURL%" == "" (
+        SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
+    )
+    if "%MVNW_VERBOSE%" == "true" (
+        echo Couldn't find %WRAPPER_JAR%, downloading it ...
+        echo Downloading from: %DOWNLOAD_URL%
+    )
+
+    powershell -Command "&{"^
+		"$webclient = new-object System.Net.WebClient;"^
+		"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
+		"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
+		"}"^
+		"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
+		"}"
+    if "%MVNW_VERBOSE%" == "true" (
+        echo Finished downloading %WRAPPER_JAR%
+    )
+)
+@REM End of extension
+
+@REM Provide a "standardized" way to retrieve the CLI args that will
+@REM work with both Windows and non-Windows executions.
+set MAVEN_CMD_LINE_ARGS=%*
+
+%MAVEN_JAVA_EXE% ^
+  %JVM_CONFIG_MAVEN_PROPS% ^
+  %MAVEN_OPTS% ^
+  %MAVEN_DEBUG_OPTS% ^
+  -classpath %WRAPPER_JAR% ^
+  "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
+  %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
+if ERRORLEVEL 1 goto error
+goto end
+
+:error
+set ERROR_CODE=1
+
+:end
+@endlocal & set ERROR_CODE=%ERROR_CODE%
+
+if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
+@REM check for post script, once with legacy .bat ending and once with .cmd ending
+if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
+if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
+:skipRcPost
+
+@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
+if "%MAVEN_BATCH_PAUSE%"=="on" pause
+
+if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
+
+cmd /C exit /B %ERROR_CODE%

+ 144 - 0
huimv-eartag2-platform/pom.xml

@@ -0,0 +1,144 @@
+<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <modules>
+        <module>huimv-eartag2-input</module>
+        <module>huimv-eartag2-process</module>
+        <module>huimv-eartag2-manage</module>
+        <module>huimv-eartag2-gateway</module>
+        <module>huimv-eartag2-common</module>
+        <module>huimv-eartag2-process2</module>
+    </modules>
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.6.2</version>
+<!--        <relativePath/> &lt;!&ndash; lookup parent from repository &ndash;&gt;-->
+    </parent>
+    <groupId>com.huimv</groupId>
+    <artifactId>huimv-eartag2-platform</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <name>huimv-eartag2-platform</name>
+    <description>Demo project for Spring Boot</description>
+    <packaging>pom</packaging>
+
+    <properties>
+        <java.version>1.8</java.version>
+    </properties>
+    <dependencies>
+        <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>
+        <!-- fastjson -->
+        <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>
+        <!-- redis -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-redis</artifactId>
+        </dependency>
+    </dependencies>
+
+<!--    <build>-->
+<!--        <plugins>-->
+<!--            &lt;!&ndash;  &ndash;&gt;-->
+<!--            <plugin>-->
+<!--                <groupId>org.springframework.boot</groupId>-->
+<!--                <artifactId>spring-boot-maven-plugin</artifactId>-->
+<!--            </plugin>-->
+<!--            &lt;!&ndash;  &ndash;&gt;-->
+<!--            <plugin>-->
+<!--                <groupId>org.apache.maven.plugins</groupId>-->
+<!--                <artifactId>maven-resources-plugin</artifactId>-->
+<!--                <version>2.6</version>-->
+<!--            </plugin>-->
+<!--        </plugins>-->
+<!--    </build>-->
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.1</version>
+                <configuration>
+                    <source>${java.version}</source>
+                    <target>${java.version}</target>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-resources-plugin</artifactId>
+                <version>2.6</version>
+                <configuration>
+                    <delimiters>
+                        <delimiter>@</delimiter>
+                    </delimiters>
+                    <useDefaultDelimiters>false</useDefaultDelimiters>
+                </configuration>
+            </plugin>
+        </plugins>
+        <resources>
+            <resource>
+                <directory>src/main/webapp</directory>
+                <filtering>false</filtering>
+            </resource>
+            <resource>
+                <directory>src/main/resources</directory>
+                <filtering>true</filtering>
+            </resource>
+            <resource>
+                <directory>src/main/java</directory>
+                <includes>
+                    <include>**/*.xml</include>
+                </includes>
+            </resource>
+        </resources>
+    </build>
+
+<!--    <profiles>-->
+<!--        <profile>-->
+<!--            <id>local</id>-->
+<!--            <properties>-->
+<!--                <spring.active>local</spring.active>-->
+<!--            </properties>-->
+<!--        </profile>-->
+<!--        <profile>-->
+<!--            <id>dev</id>-->
+<!--            <properties>-->
+<!--                <spring.active>dev</spring.active>-->
+<!--            </properties>-->
+<!--        </profile>-->
+<!--        <profile>-->
+<!--            <id>prod</id>-->
+<!--            <properties>-->
+<!--                <spring.active>prod</spring.active>-->
+<!--            </properties>-->
+<!--            <activation>-->
+<!--                <activeByDefault>true</activeByDefault>-->
+<!--            </activation>-->
+<!--        </profile>-->
+<!--    </profiles>-->
+
+</project>