Pārlūkot izejas kodu

添加部分设备处理

zhuoning 3 gadi atpakaļ
vecāks
revīzija
328aa1fece
43 mainītis faili ar 2945 papildinājumiem un 19 dzēšanām
  1. 103 0
      huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/entity/BaseFarmEntity.java
  2. 67 0
      huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/entity/BaseFarmServerConfigEntity.java
  3. 104 0
      huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/entity/EartagDeviceDayStatusEntity.java
  4. 165 0
      huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/entity/EartagDeviceOnlineEntity.java
  5. 236 0
      huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/entity/EartagDeviceRegisterEntity.java
  6. 104 0
      huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/entity/EartagEartagDayStatusEntity.java
  7. 129 0
      huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/entity/EartagEartagOnlineEntity.java
  8. 140 0
      huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/entity/EartagEartagRegisterEntity.java
  9. 153 0
      huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/entity/EartagTotalStatusEntity.java
  10. 153 0
      huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/entity/EartarFarmAllStatusEntity.java
  11. 9 0
      huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/repo/BaseFarmRepo.java
  12. 9 0
      huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/repo/BaseFarmServerConfigRepo.java
  13. 9 0
      huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/repo/EartagDeviceDayStatusRepo.java
  14. 14 0
      huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/repo/EartagDeviceOnlineRepo.java
  15. 15 0
      huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/repo/EartagDeviceRegisterRepo.java
  16. 9 0
      huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/repo/EartagEartagDayStatusRepo.java
  17. 9 0
      huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/repo/EartagEartagOnlineRepo.java
  18. 9 0
      huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/repo/EartagEartagRegisterRepo.java
  19. 9 0
      huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/repo/EartagTotalStatusRepo.java
  20. 12 0
      huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/repo/EartarFarmAllStatusRepo.java
  21. 35 0
      huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/utils/BizConst.java
  22. 1 1
      huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/utils/DateUtil.java
  23. 0 6
      huimv-eartag2-platform/huimv-eartag2-process/src/main/java/com/huimv/eartag2/process/service/impl/EartagServiceImpl.java
  24. 0 1
      huimv-eartag2-platform/huimv-eartag2-process/src/main/resources/application.properties
  25. 2 0
      huimv-eartag2-platform/huimv-eartag2-process2/src/main/java/com/huimv/eartag2/process2/HuimvEartag2Process2Application.java
  26. 60 8
      huimv-eartag2-platform/huimv-eartag2-process2/src/main/java/com/huimv/eartag2/process2/listener/DeviceListener.java
  27. 10 0
      huimv-eartag2-platform/huimv-eartag2-process2/src/main/java/com/huimv/eartag2/process2/service/IDeviceService.java
  28. 20 0
      huimv-eartag2-platform/huimv-eartag2-process2/src/main/java/com/huimv/eartag2/process2/service/IRedisService.java
  29. 379 2
      huimv-eartag2-platform/huimv-eartag2-process2/src/main/java/com/huimv/eartag2/process2/service/impl/DeviceServiceImpl.java
  30. 105 0
      huimv-eartag2-platform/huimv-eartag2-process2/src/main/java/com/huimv/eartag2/process2/service/impl/RedisServiceImpl.java
  31. 187 0
      huimv-eartag2-platform/huimv-eartag2-process2/src/main/java/com/huimv/eartag2/process2/utils/DateUtil.java
  32. 1 1
      huimv-eartag2-platform/huimv-eartag2-process2/src/main/resources/application.properties
  33. 39 0
      huimv-eartag2-platform/huimv-eartag2-process2/src/test/java/com/huimv/eartag2/process2/utils/RedisUtil.java
  34. 26 0
      huimv-eartag2-platform/huimv-eartag2-process2/src/test/java/com/huimv/eartag2/process2/utils/TypeTest.java
  35. 33 0
      huimv-eartag2-platform/writeCode/.gitignore
  36. BIN
      huimv-eartag2-platform/writeCode/.mvn/wrapper/maven-wrapper.jar
  37. 2 0
      huimv-eartag2-platform/writeCode/.mvn/wrapper/maven-wrapper.properties
  38. 331 0
      huimv-eartag2-platform/writeCode/mvnw
  39. 188 0
      huimv-eartag2-platform/writeCode/mvnw.cmd
  40. 41 0
      huimv-eartag2-platform/writeCode/pom.xml
  41. 13 0
      huimv-eartag2-platform/writeCode/src/main/java/com/example/demo/DemoApplication.java
  42. 1 0
      huimv-eartag2-platform/writeCode/src/main/resources/application.properties
  43. 13 0
      huimv-eartag2-platform/writeCode/src/test/java/com/example/demo/DemoApplicationTests.java

+ 103 - 0
huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/entity/BaseFarmEntity.java

@@ -0,0 +1,103 @@
+package com.huimv.eartag2.common.dao.entity;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+@Entity
+@Table(name = "base_farm")
+public class BaseFarmEntity implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id", nullable = false)
+    private Integer id;
+
+    @Column(name = "farm_id")
+    private Integer farmId;
+
+    @Column(name = "farm_name")
+    private String farmName;
+
+    @Column(name = "location")
+    private String location;
+
+    @Column(name = "leader")
+    private String leader;
+
+    @Column(name = "phone")
+    private String phone;
+
+    @Column(name = "remark")
+    private String remark;
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setFarmId(Integer farmId) {
+        this.farmId = farmId;
+    }
+
+    public Integer getFarmId() {
+        return farmId;
+    }
+
+    public void setFarmName(String farmName) {
+        this.farmName = farmName;
+    }
+
+    public String getFarmName() {
+        return farmName;
+    }
+
+    public void setLocation(String location) {
+        this.location = location;
+    }
+
+    public String getLocation() {
+        return location;
+    }
+
+    public void setLeader(String leader) {
+        this.leader = leader;
+    }
+
+    public String getLeader() {
+        return leader;
+    }
+
+    public void setPhone(String phone) {
+        this.phone = phone;
+    }
+
+    public String getPhone() {
+        return phone;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    @Override
+    public String toString() {
+        return "BaseFarmEntity{" +
+                "id=" + id + '\'' +
+                "farmId=" + farmId + '\'' +
+                "farmName=" + farmName + '\'' +
+                "location=" + location + '\'' +
+                "leader=" + leader + '\'' +
+                "phone=" + phone + '\'' +
+                "remark=" + remark + '\'' +
+                '}';
+    }
+}

+ 67 - 0
huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/entity/BaseFarmServerConfigEntity.java

@@ -0,0 +1,67 @@
+package com.huimv.eartag2.common.dao.entity;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+@Entity
+@Table(name = "base_farm_server_config")
+public class BaseFarmServerConfigEntity implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id", nullable = false)
+    private Integer id;
+
+    @Column(name = "farm_id")
+    private Integer farmId;
+
+    @Column(name = "server_ip")
+    private String serverIp;
+
+    @Column(name = "server_port")
+    private Integer serverPort;
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setFarmId(Integer farmId) {
+        this.farmId = farmId;
+    }
+
+    public Integer getFarmId() {
+        return farmId;
+    }
+
+    public void setServerIp(String serverIp) {
+        this.serverIp = serverIp;
+    }
+
+    public String getServerIp() {
+        return serverIp;
+    }
+
+    public void setServerPort(Integer serverPort) {
+        this.serverPort = serverPort;
+    }
+
+    public Integer getServerPort() {
+        return serverPort;
+    }
+
+    @Override
+    public String toString() {
+        return "BaseFarmServerConfigEntity{" +
+                "id=" + id + '\'' +
+                "farmId=" + farmId + '\'' +
+                "serverIp=" + serverIp + '\'' +
+                "serverPort=" + serverPort + '\'' +
+                '}';
+    }
+}

+ 104 - 0
huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/entity/EartagDeviceDayStatusEntity.java

@@ -0,0 +1,104 @@
+package com.huimv.eartag2.common.dao.entity;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.sql.Date;
+
+@Entity
+@Table(name = "eartag_device_day_status")
+public class EartagDeviceDayStatusEntity implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id", nullable = false)
+    private Integer id;
+
+    @Column(name = "farm_id")
+    private Integer farmId;
+
+    @Column(name = "total")
+    private Integer total;
+
+    @Column(name = "online")
+    private Integer online;
+
+    @Column(name = "offline")
+    private Integer offline;
+
+    @Column(name = "online_rate")
+    private Float onlineRate;
+
+    @Column(name = "add_date")
+    private Date addDate;
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setFarmId(Integer farmId) {
+        this.farmId = farmId;
+    }
+
+    public Integer getFarmId() {
+        return farmId;
+    }
+
+    public void setTotal(Integer total) {
+        this.total = total;
+    }
+
+    public Integer getTotal() {
+        return total;
+    }
+
+    public void setOnline(Integer online) {
+        this.online = online;
+    }
+
+    public Integer getOnline() {
+        return online;
+    }
+
+    public void setOffline(Integer offline) {
+        this.offline = offline;
+    }
+
+    public Integer getOffline() {
+        return offline;
+    }
+
+    public void setOnlineRate(Float onlineRate) {
+        this.onlineRate = onlineRate;
+    }
+
+    public Float getOnlineRate() {
+        return onlineRate;
+    }
+
+    public void setAddDate(Date addDate) {
+        this.addDate = addDate;
+    }
+
+    public Date getAddDate() {
+        return addDate;
+    }
+
+    @Override
+    public String toString() {
+        return "EartagDeviceDayStatusEntity{" +
+                "id=" + id + '\'' +
+                "farmId=" + farmId + '\'' +
+                "total=" + total + '\'' +
+                "online=" + online + '\'' +
+                "offline=" + offline + '\'' +
+                "onlineRate=" + onlineRate + '\'' +
+                "addDate=" + addDate + '\'' +
+                '}';
+    }
+}

+ 165 - 0
huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/entity/EartagDeviceOnlineEntity.java

@@ -0,0 +1,165 @@
+package com.huimv.eartag2.common.dao.entity;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.sql.Date;
+import java.sql.Timestamp;
+
+@Entity
+@Table(name = "eartag_device_online")
+public class EartagDeviceOnlineEntity 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 = "alias")
+    private String alias;
+
+    @Column(name = "heartbeat_total")
+    private Integer heartbeatTotal;
+
+    @Column(name = "envtemp_total")
+    private Integer envtempTotal;
+
+    @Column(name = "eartag_total")
+    private Integer eartagTotal;
+
+    @Column(name = "first_time")
+    private Timestamp firstTime;
+
+    @Column(name = "last_time")
+    private Timestamp lastTime;
+
+    @Column(name = "last_envtemp")
+    private Float lastEnvtemp;
+
+    @Column(name = "last_eartag")
+    private Float lastEartag;
+
+    @Column(name = "add_date")
+    private Date addDate;
+
+    @Column(name = "farm_id")
+    private Integer farmId;
+
+    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 setAlias(String alias) {
+        this.alias = alias;
+    }
+
+    public String getAlias() {
+        return alias;
+    }
+
+    public void setHeartbeatTotal(Integer heartbeatTotal) {
+        this.heartbeatTotal = heartbeatTotal;
+    }
+
+    public Integer getHeartbeatTotal() {
+        return heartbeatTotal;
+    }
+
+    public void setEnvtempTotal(Integer envtempTotal) {
+        this.envtempTotal = envtempTotal;
+    }
+
+    public Integer getEnvtempTotal() {
+        return envtempTotal;
+    }
+
+    public void setEartagTotal(Integer eartagTotal) {
+        this.eartagTotal = eartagTotal;
+    }
+
+    public Integer getEartagTotal() {
+        return eartagTotal;
+    }
+
+    public void setFirstTime(Timestamp firstTime) {
+        this.firstTime = firstTime;
+    }
+
+    public Timestamp getFirstTime() {
+        return firstTime;
+    }
+
+    public void setLastTime(Timestamp lastTime) {
+        this.lastTime = lastTime;
+    }
+
+    public Timestamp getLastTime() {
+        return lastTime;
+    }
+
+    public void setLastEnvtemp(Float lastEnvtemp) {
+        this.lastEnvtemp = lastEnvtemp;
+    }
+
+    public Float getLastEnvtemp() {
+        return lastEnvtemp;
+    }
+
+    public void setLastEartag(Float lastEartag) {
+        this.lastEartag = lastEartag;
+    }
+
+    public Float getLastEartag() {
+        return lastEartag;
+    }
+
+    public void setAddDate(Date addDate) {
+        this.addDate = addDate;
+    }
+
+    public Date getAddDate() {
+        return addDate;
+    }
+
+    public void setFarmId(Integer farmId) {
+        this.farmId = farmId;
+    }
+
+    public Integer getFarmId() {
+        return farmId;
+    }
+
+    @Override
+    public String toString() {
+        return "EartagDeviceOnlineEntity{" +
+                "id=" + id + '\'' +
+                "deviceCode=" + deviceCode + '\'' +
+                "alias=" + alias + '\'' +
+                "heartbeatTotal=" + heartbeatTotal + '\'' +
+                "envtempTotal=" + envtempTotal + '\'' +
+                "eartagTotal=" + eartagTotal + '\'' +
+                "firstTime=" + firstTime + '\'' +
+                "lastTime=" + lastTime + '\'' +
+                "lastEnvtemp=" + lastEnvtemp + '\'' +
+                "lastEartag=" + lastEartag + '\'' +
+                "addDate=" + addDate + '\'' +
+                "farmId=" + farmId + '\'' +
+                '}';
+    }
+}

+ 236 - 0
huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/entity/EartagDeviceRegisterEntity.java

@@ -0,0 +1,236 @@
+package com.huimv.eartag2.common.dao.entity;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+@Entity
+@Table(name = "eartag_device_register")
+public class EartagDeviceRegisterEntity 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 = "county_code")
+    private String countyCode;
+
+    @Column(name = "county_name")
+    private String countyName;
+
+    @Column(name = "farm_id")
+    private String farmId;
+
+    @Column(name = "farm_name")
+    private String farmName;
+
+    @Column(name = "type_f")
+    private Integer typeF;
+
+    @Column(name = "stage")
+    private Integer stage;
+
+    @Column(name = "pigpen_id")
+    private Integer pigpenId;
+
+    @Column(name = "unit_id")
+    private Integer unitId;
+
+    @Column(name = "register_time")
+    private Timestamp registerTime;
+
+    @Column(name = "last_time")
+    private Timestamp lastTime;
+
+    @Column(name = "active_status")
+    private Integer activeStatus;
+
+    @Column(name = "active_time")
+    private Timestamp activeTime;
+
+    @Column(name = "device_status")
+    private Integer deviceStatus;
+
+    @Column(name = "device_alias")
+    private String deviceAlias;
+
+    @Column(name = "location")
+    private String location;
+
+    @Column(name = "remark")
+    private String remark;
+
+    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 setCountyCode(String countyCode) {
+        this.countyCode = countyCode;
+    }
+
+    public String getCountyCode() {
+        return countyCode;
+    }
+
+    public void setCountyName(String countyName) {
+        this.countyName = countyName;
+    }
+
+    public String getCountyName() {
+        return countyName;
+    }
+
+    public void setFarmId(String farmId) {
+        this.farmId = farmId;
+    }
+
+    public String getFarmId() {
+        return farmId;
+    }
+
+    public void setFarmName(String farmName) {
+        this.farmName = farmName;
+    }
+
+    public String getFarmName() {
+        return farmName;
+    }
+
+    public void setTypeF(Integer typeF) {
+        this.typeF = typeF;
+    }
+
+    public Integer getTypeF() {
+        return typeF;
+    }
+
+    public void setStage(Integer stage) {
+        this.stage = stage;
+    }
+
+    public Integer getStage() {
+        return stage;
+    }
+
+    public void setPigpenId(Integer pigpenId) {
+        this.pigpenId = pigpenId;
+    }
+
+    public Integer getPigpenId() {
+        return pigpenId;
+    }
+
+    public void setUnitId(Integer unitId) {
+        this.unitId = unitId;
+    }
+
+    public Integer getUnitId() {
+        return unitId;
+    }
+
+    public void setRegisterTime(Timestamp registerTime) {
+        this.registerTime = registerTime;
+    }
+
+    public Timestamp getRegisterTime() {
+        return registerTime;
+    }
+
+    public void setLastTime(Timestamp lastTime) {
+        this.lastTime = lastTime;
+    }
+
+    public Timestamp getLastTime() {
+        return lastTime;
+    }
+
+    public void setActiveStatus(Integer activeStatus) {
+        this.activeStatus = activeStatus;
+    }
+
+    public Integer getActiveStatus() {
+        return activeStatus;
+    }
+
+    public void setActiveTime(Timestamp activeTime) {
+        this.activeTime = activeTime;
+    }
+
+    public Timestamp getActiveTime() {
+        return activeTime;
+    }
+
+    public void setDeviceStatus(Integer deviceStatus) {
+        this.deviceStatus = deviceStatus;
+    }
+
+    public Integer getDeviceStatus() {
+        return deviceStatus;
+    }
+
+    public void setDeviceAlias(String deviceAlias) {
+        this.deviceAlias = deviceAlias;
+    }
+
+    public String getDeviceAlias() {
+        return deviceAlias;
+    }
+
+    public void setLocation(String location) {
+        this.location = location;
+    }
+
+    public String getLocation() {
+        return location;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    @Override
+    public String toString() {
+        return "EartagDeviceRegisterEntity{" +
+                "id=" + id + '\'' +
+                "deviceCode=" + deviceCode + '\'' +
+                "countyCode=" + countyCode + '\'' +
+                "countyName=" + countyName + '\'' +
+                "farmId=" + farmId + '\'' +
+                "farmName=" + farmName + '\'' +
+                "typeF=" + typeF + '\'' +
+                "stage=" + stage + '\'' +
+                "pigpenId=" + pigpenId + '\'' +
+                "unitId=" + unitId + '\'' +
+                "registerTime=" + registerTime + '\'' +
+                "lastTime=" + lastTime + '\'' +
+                "activeStatus=" + activeStatus + '\'' +
+                "activeTime=" + activeTime + '\'' +
+                "deviceStatus=" + deviceStatus + '\'' +
+                "deviceAlias=" + deviceAlias + '\'' +
+                "location=" + location + '\'' +
+                "remark=" + remark + '\'' +
+                '}';
+    }
+}

+ 104 - 0
huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/entity/EartagEartagDayStatusEntity.java

@@ -0,0 +1,104 @@
+package com.huimv.eartag2.common.dao.entity;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.sql.Date;
+
+@Entity
+@Table(name = "eartag_eartag_day_status")
+public class EartagEartagDayStatusEntity implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id", nullable = false)
+    private Integer id;
+
+    @Column(name = "total")
+    private Integer total;
+
+    @Column(name = "online")
+    private Integer online;
+
+    @Column(name = "offline")
+    private Integer offline;
+
+    @Column(name = "online_rate")
+    private Float onlineRate;
+
+    @Column(name = "add_date")
+    private Date addDate;
+
+    @Column(name = "farm_id")
+    private Integer farmId;
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setTotal(Integer total) {
+        this.total = total;
+    }
+
+    public Integer getTotal() {
+        return total;
+    }
+
+    public void setOnline(Integer online) {
+        this.online = online;
+    }
+
+    public Integer getOnline() {
+        return online;
+    }
+
+    public void setOffline(Integer offline) {
+        this.offline = offline;
+    }
+
+    public Integer getOffline() {
+        return offline;
+    }
+
+    public void setOnlineRate(Float onlineRate) {
+        this.onlineRate = onlineRate;
+    }
+
+    public Float getOnlineRate() {
+        return onlineRate;
+    }
+
+    public void setAddDate(Date addDate) {
+        this.addDate = addDate;
+    }
+
+    public Date getAddDate() {
+        return addDate;
+    }
+
+    public void setFarmId(Integer farmId) {
+        this.farmId = farmId;
+    }
+
+    public Integer getFarmId() {
+        return farmId;
+    }
+
+    @Override
+    public String toString() {
+        return "EartagEartagDayStatusEntity{" +
+                "id=" + id + '\'' +
+                "total=" + total + '\'' +
+                "online=" + online + '\'' +
+                "offline=" + offline + '\'' +
+                "onlineRate=" + onlineRate + '\'' +
+                "addDate=" + addDate + '\'' +
+                "farmId=" + farmId + '\'' +
+                '}';
+    }
+}

+ 129 - 0
huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/entity/EartagEartagOnlineEntity.java

@@ -0,0 +1,129 @@
+package com.huimv.eartag2.common.dao.entity;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.sql.Date;
+import java.sql.Timestamp;
+
+@Entity
+@Table(name = "eartag_eartag_online")
+public class EartagEartagOnlineEntity 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 Integer deviceCode;
+
+    @Column(name = "total")
+    private Integer total;
+
+    @Column(name = "first_time")
+    private Timestamp firstTime;
+
+    @Column(name = "last_time")
+    private Timestamp lastTime;
+
+    @Column(name = "env_temp")
+    private Float envTemp;
+
+    @Column(name = "eartag_temp")
+    private Float eartagTemp;
+
+    @Column(name = "add_date")
+    private Date addDate;
+
+    @Column(name = "farm_id")
+    private Integer farmId;
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setDeviceCode(Integer deviceCode) {
+        this.deviceCode = deviceCode;
+    }
+
+    public Integer getDeviceCode() {
+        return deviceCode;
+    }
+
+    public void setTotal(Integer total) {
+        this.total = total;
+    }
+
+    public Integer getTotal() {
+        return total;
+    }
+
+    public void setFirstTime(Timestamp firstTime) {
+        this.firstTime = firstTime;
+    }
+
+    public Timestamp getFirstTime() {
+        return firstTime;
+    }
+
+    public void setLastTime(Timestamp lastTime) {
+        this.lastTime = lastTime;
+    }
+
+    public Timestamp getLastTime() {
+        return lastTime;
+    }
+
+    public void setEnvTemp(Float envTemp) {
+        this.envTemp = envTemp;
+    }
+
+    public Float getEnvTemp() {
+        return envTemp;
+    }
+
+    public void setEartagTemp(Float eartagTemp) {
+        this.eartagTemp = eartagTemp;
+    }
+
+    public Float getEartagTemp() {
+        return eartagTemp;
+    }
+
+    public void setAddDate(Date addDate) {
+        this.addDate = addDate;
+    }
+
+    public Date getAddDate() {
+        return addDate;
+    }
+
+    public void setFarmId(Integer farmId) {
+        this.farmId = farmId;
+    }
+
+    public Integer getFarmId() {
+        return farmId;
+    }
+
+    @Override
+    public String toString() {
+        return "EartagEartagOnlineEntity{" +
+                "id=" + id + '\'' +
+                "deviceCode=" + deviceCode + '\'' +
+                "total=" + total + '\'' +
+                "firstTime=" + firstTime + '\'' +
+                "lastTime=" + lastTime + '\'' +
+                "envTemp=" + envTemp + '\'' +
+                "eartagTemp=" + eartagTemp + '\'' +
+                "addDate=" + addDate + '\'' +
+                "farmId=" + farmId + '\'' +
+                '}';
+    }
+}

+ 140 - 0
huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/entity/EartagEartagRegisterEntity.java

@@ -0,0 +1,140 @@
+package com.huimv.eartag2.common.dao.entity;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+@Entity
+@Table(name = "eartag_eartag_register")
+public class EartagEartagRegisterEntity implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id", nullable = false)
+    private Integer id;
+
+    @Column(name = "earmark")
+    private Integer earmark;
+
+    @Column(name = "first_time")
+    private Timestamp firstTime;
+
+    @Column(name = "last_time")
+    private Timestamp lastTime;
+
+    @Column(name = "first_device")
+    private Integer firstDevice;
+
+    @Column(name = "belong_device")
+    private Integer belongDevice;
+
+    @Column(name = "register_time")
+    private Timestamp registerTime;
+
+    @Column(name = "register_type")
+    private Integer registerType;
+
+    @Column(name = "remark")
+    private String remark;
+
+    @Column(name = "farm_id")
+    private Integer farmId;
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setEarmark(Integer earmark) {
+        this.earmark = earmark;
+    }
+
+    public Integer getEarmark() {
+        return earmark;
+    }
+
+    public void setFirstTime(Timestamp firstTime) {
+        this.firstTime = firstTime;
+    }
+
+    public Timestamp getFirstTime() {
+        return firstTime;
+    }
+
+    public void setLastTime(Timestamp lastTime) {
+        this.lastTime = lastTime;
+    }
+
+    public Timestamp getLastTime() {
+        return lastTime;
+    }
+
+    public void setFirstDevice(Integer firstDevice) {
+        this.firstDevice = firstDevice;
+    }
+
+    public Integer getFirstDevice() {
+        return firstDevice;
+    }
+
+    public void setBelongDevice(Integer belongDevice) {
+        this.belongDevice = belongDevice;
+    }
+
+    public Integer getBelongDevice() {
+        return belongDevice;
+    }
+
+    public void setRegisterTime(Timestamp registerTime) {
+        this.registerTime = registerTime;
+    }
+
+    public Timestamp getRegisterTime() {
+        return registerTime;
+    }
+
+    public void setRegisterType(Integer registerType) {
+        this.registerType = registerType;
+    }
+
+    public Integer getRegisterType() {
+        return registerType;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setFarmId(Integer farmId) {
+        this.farmId = farmId;
+    }
+
+    public Integer getFarmId() {
+        return farmId;
+    }
+
+    @Override
+    public String toString() {
+        return "EartagEartagRegisterEntity{" +
+                "id=" + id + '\'' +
+                "earmark=" + earmark + '\'' +
+                "firstTime=" + firstTime + '\'' +
+                "lastTime=" + lastTime + '\'' +
+                "firstDevice=" + firstDevice + '\'' +
+                "belongDevice=" + belongDevice + '\'' +
+                "registerTime=" + registerTime + '\'' +
+                "registerType=" + registerType + '\'' +
+                "remark=" + remark + '\'' +
+                "farmId=" + farmId + '\'' +
+                '}';
+    }
+}

+ 153 - 0
huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/entity/EartagTotalStatusEntity.java

@@ -0,0 +1,153 @@
+package com.huimv.eartag2.common.dao.entity;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.sql.Date;
+import java.sql.Timestamp;
+
+@Entity
+@Table(name = "eartag_total_status")
+public class EartagTotalStatusEntity implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id", nullable = false)
+    private Integer id;
+
+    @Column(name = "device_total")
+    private Integer deviceTotal;
+
+    @Column(name = "device_online")
+    private Integer deviceOnline;
+
+    @Column(name = "device_offline")
+    private Integer deviceOffline;
+
+    @Column(name = "device_rate")
+    private Float deviceRate;
+
+    @Column(name = "device_cancel")
+    private Integer deviceCancel;
+
+    @Column(name = "eartag_total")
+    private Integer eartagTotal;
+
+    @Column(name = "eartag_online")
+    private Integer eartagOnline;
+
+    @Column(name = "farm_id")
+    private Integer farmId;
+
+    @Column(name = "update_time")
+    private Timestamp updateTime;
+
+    @Column(name = "create_date")
+    private Date createDate;
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setDeviceTotal(Integer deviceTotal) {
+        this.deviceTotal = deviceTotal;
+    }
+
+    public Integer getDeviceTotal() {
+        return deviceTotal;
+    }
+
+    public void setDeviceOnline(Integer deviceOnline) {
+        this.deviceOnline = deviceOnline;
+    }
+
+    public Integer getDeviceOnline() {
+        return deviceOnline;
+    }
+
+    public void setDeviceOffline(Integer deviceOffline) {
+        this.deviceOffline = deviceOffline;
+    }
+
+    public Integer getDeviceOffline() {
+        return deviceOffline;
+    }
+
+    public void setDeviceRate(Float deviceRate) {
+        this.deviceRate = deviceRate;
+    }
+
+    public Float getDeviceRate() {
+        return deviceRate;
+    }
+
+    public void setDeviceCancel(Integer deviceCancel) {
+        this.deviceCancel = deviceCancel;
+    }
+
+    public Integer getDeviceCancel() {
+        return deviceCancel;
+    }
+
+    public void setEartagTotal(Integer eartagTotal) {
+        this.eartagTotal = eartagTotal;
+    }
+
+    public Integer getEartagTotal() {
+        return eartagTotal;
+    }
+
+    public void setEartagOnline(Integer eartagOnline) {
+        this.eartagOnline = eartagOnline;
+    }
+
+    public Integer getEartagOnline() {
+        return eartagOnline;
+    }
+
+    public void setFarmId(Integer farmId) {
+        this.farmId = farmId;
+    }
+
+    public Integer getFarmId() {
+        return farmId;
+    }
+
+    public void setUpdateTime(Timestamp updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public Timestamp getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setCreateDate(Date createDate) {
+        this.createDate = createDate;
+    }
+
+    public Date getCreateDate() {
+        return createDate;
+    }
+
+    @Override
+    public String toString() {
+        return "EartagTotalStatusEntity{" +
+                "id=" + id + '\'' +
+                "deviceTotal=" + deviceTotal + '\'' +
+                "deviceOnline=" + deviceOnline + '\'' +
+                "deviceOffline=" + deviceOffline + '\'' +
+                "deviceRate=" + deviceRate + '\'' +
+                "deviceCancel=" + deviceCancel + '\'' +
+                "eartagTotal=" + eartagTotal + '\'' +
+                "eartagOnline=" + eartagOnline + '\'' +
+                "farmId=" + farmId + '\'' +
+                "updateTime=" + updateTime + '\'' +
+                "createDate=" + createDate + '\'' +
+                '}';
+    }
+}

+ 153 - 0
huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/entity/EartarFarmAllStatusEntity.java

@@ -0,0 +1,153 @@
+package com.huimv.eartag2.common.dao.entity;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.sql.Date;
+import java.sql.Timestamp;
+
+@Entity
+@Table(name = "eartar_farm_all_status")
+public class EartarFarmAllStatusEntity implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id", nullable = false)
+    private Integer id;
+
+    @Column(name = "device_total")
+    private Integer deviceTotal;
+
+    @Column(name = "device_online")
+    private Integer deviceOnline;
+
+    @Column(name = "device_offline")
+    private Integer deviceOffline;
+
+    @Column(name = "device_rate")
+    private Float deviceRate;
+
+    @Column(name = "device_cancel")
+    private Integer deviceCancel;
+
+    @Column(name = "eartag_total")
+    private Integer eartagTotal;
+
+    @Column(name = "eartag_online")
+    private Integer eartagOnline;
+
+    @Column(name = "farm_id")
+    private Integer farmId;
+
+    @Column(name = "update_time")
+    private Timestamp updateTime;
+
+    @Column(name = "create_date")
+    private Date createDate;
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setDeviceTotal(Integer deviceTotal) {
+        this.deviceTotal = deviceTotal;
+    }
+
+    public Integer getDeviceTotal() {
+        return deviceTotal;
+    }
+
+    public void setDeviceOnline(Integer deviceOnline) {
+        this.deviceOnline = deviceOnline;
+    }
+
+    public Integer getDeviceOnline() {
+        return deviceOnline;
+    }
+
+    public void setDeviceOffline(Integer deviceOffline) {
+        this.deviceOffline = deviceOffline;
+    }
+
+    public Integer getDeviceOffline() {
+        return deviceOffline;
+    }
+
+    public void setDeviceRate(Float deviceRate) {
+        this.deviceRate = deviceRate;
+    }
+
+    public Float getDeviceRate() {
+        return deviceRate;
+    }
+
+    public void setDeviceCancel(Integer deviceCancel) {
+        this.deviceCancel = deviceCancel;
+    }
+
+    public Integer getDeviceCancel() {
+        return deviceCancel;
+    }
+
+    public void setEartagTotal(Integer eartagTotal) {
+        this.eartagTotal = eartagTotal;
+    }
+
+    public Integer getEartagTotal() {
+        return eartagTotal;
+    }
+
+    public void setEartagOnline(Integer eartagOnline) {
+        this.eartagOnline = eartagOnline;
+    }
+
+    public Integer getEartagOnline() {
+        return eartagOnline;
+    }
+
+    public void setFarmId(Integer farmId) {
+        this.farmId = farmId;
+    }
+
+    public Integer getFarmId() {
+        return farmId;
+    }
+
+    public void setUpdateTime(Timestamp updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public Timestamp getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setCreateDate(Date createDate) {
+        this.createDate = createDate;
+    }
+
+    public Date getCreateDate() {
+        return createDate;
+    }
+
+    @Override
+    public String toString() {
+        return "EartarFarmAllStatusEntity{" +
+                "id=" + id + '\'' +
+                "deviceTotal=" + deviceTotal + '\'' +
+                "deviceOnline=" + deviceOnline + '\'' +
+                "deviceOffline=" + deviceOffline + '\'' +
+                "deviceRate=" + deviceRate + '\'' +
+                "deviceCancel=" + deviceCancel + '\'' +
+                "eartagTotal=" + eartagTotal + '\'' +
+                "eartagOnline=" + eartagOnline + '\'' +
+                "farmId=" + farmId + '\'' +
+                "updateTime=" + updateTime + '\'' +
+                "createDate=" + createDate + '\'' +
+                '}';
+    }
+}

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

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

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

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

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

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

+ 14 - 0
huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/repo/EartagDeviceOnlineRepo.java

@@ -0,0 +1,14 @@
+package com.huimv.eartag2.common.dao.repo;
+
+import com.huimv.eartag2.common.dao.entity.EartagDeviceOnlineEntity;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Query;
+
+import java.util.Queue;
+
+public interface EartagDeviceOnlineRepo extends JpaRepository<EartagDeviceOnlineEntity, Integer>, JpaSpecificationExecutor<EartagDeviceOnlineEntity> {
+
+    @Query(nativeQuery = true,value = "SELECT * FROM eartag_device_online WHERE device_code=?1 AND DATE_FORMAT(add_date,'%Y-%m-%d')=DATE_FORMAT(?2,'%Y-%m-%d') limit 1")
+    EartagDeviceOnlineEntity getDeviceOnline(String deviceCode,String todayText);
+}

+ 15 - 0
huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/dao/repo/EartagDeviceRegisterRepo.java

@@ -0,0 +1,15 @@
+package com.huimv.eartag2.common.dao.repo;
+
+import com.huimv.eartag2.common.dao.entity.EartagDeviceRegisterEntity;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Query;
+
+public interface EartagDeviceRegisterRepo extends JpaRepository<EartagDeviceRegisterEntity, Integer>, JpaSpecificationExecutor<EartagDeviceRegisterEntity> {
+
+//    @Query(nativeQuery = true,value = "UPDATE ")
+//    void updateActiveStatus(String deviceCode);
+
+    @Query(nativeQuery = true,value = "SELECT * FROM eartag_device_register WHERE device_code=?1")
+    EartagDeviceRegisterEntity getDeviceRegister(String deviceCode);
+}

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

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

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

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

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

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

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

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

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

@@ -0,0 +1,12 @@
+package com.huimv.eartag2.common.dao.repo;
+
+import com.huimv.eartag2.common.dao.entity.EartarFarmAllStatusEntity;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Query;
+
+public interface EartarFarmAllStatusRepo extends JpaRepository<EartarFarmAllStatusEntity, Integer>, JpaSpecificationExecutor<EartarFarmAllStatusEntity> {
+
+    @Query(nativeQuery = true,value = "SELECT * FROM eartar_farm_all_status WHERE farm_id=?1 AND DATE_FORMAT(create_date,'%Y-%m-%d')=DATE_FORMAT(?2,'%Y-%m-%d')")
+    EartarFarmAllStatusEntity getOneByFarmIdAndCreateDate(String farmId,String todayDateText);
+}

+ 35 - 0
huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/utils/BizConst.java

@@ -0,0 +1,35 @@
+package com.huimv.eartag2.common.utils;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+public class BizConst {
+    //所有设备注册信息都要加入缓存
+    public final static String DEVICE_REGISTER_PREFIX = "device_register_";
+
+    //在线设备统计信息加入缓存
+    public final static String DEVICE_ONLINE_PREFIX = "device_online_";
+
+    //牧场所有采集器设备编号集合+牧场id(Set)
+    public final static String FARM_DEVICE_ALL_PREFIX = "farm_device_all_";
+
+    //牧场在线采集器设备编号集合+牧场id(Set)
+    public final static String FARM_DEVICE_DAY_PREFIX = "farm_device_day_";
+
+    //牧场所有耳标编号集合+牧场id(Set)
+    public final static String FARM_EARMARK_ALL_PREFIX = "farm_earmark_all_";
+
+    //牧场在线耳标编号集合+牧场id(Set)
+    public final static String FARM_EARMARK_DAY_PREFIX = "farm_earmark_day_";
+
+    //牧场总状态表+牧场id
+    public final static String FARM_ALL_STATUS_PREFIX = "farm_all_status_";
+
+
+
+}

+ 1 - 1
huimv-eartag2-platform/huimv-eartag2-common/src/main/java/com/huimv/eartag2/common/utils/DateUtil.java

@@ -19,7 +19,7 @@ import java.util.Date;
  * @Create : 2020-12-25
  **/
 @Component
-@Slf4j
+//@Slf4j
 public class DateUtil {
 
     //格式化日期(Long --> Date)

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

@@ -60,11 +60,6 @@ public class EartagServiceImpl implements IEartagService {
     }
 
     /**
-     * @Method      : saveEartag
-     * @Description : 保存耳标数据
-     * @Params      : [dataJo]
-     * @Return      : void
-     *
      * @Author      : ZhuoNing
      * @Date        : 2022/2/9
      * @Time        : 14:33
@@ -118,7 +113,6 @@ public class EartagServiceImpl implements IEartagService {
      * 初始化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());

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

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

+ 2 - 0
huimv-eartag2-platform/huimv-eartag2-process2/src/main/java/com/huimv/eartag2/process2/HuimvEartag2Process2Application.java

@@ -3,6 +3,7 @@ package com.huimv.eartag2.process2;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.autoconfigure.domain.EntityScan;
+import org.springframework.context.annotation.ComponentScan;
 import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
 
 /**
@@ -14,6 +15,7 @@ import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
  * @Create : 2020-12-25
  **/
 @SpringBootApplication
+//@ComponentScan(basePackages = {"com.huimv.eartag2.common.utils"})
 @EntityScan(value = "com.huimv.eartag2.common.dao.entity")
 @EnableJpaRepositories(basePackages = "com.huimv.eartag2.common.dao.repo")
 public class HuimvEartag2Process2Application {

+ 60 - 8
huimv-eartag2-platform/huimv-eartag2-process2/src/main/java/com/huimv/eartag2/process2/listener/DeviceListener.java

@@ -1,12 +1,19 @@
 package com.huimv.eartag2.process2.listener;
 
+import cn.hutool.core.text.csv.CsvUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.huimv.eartag2.common.mq.Const;
+import com.huimv.eartag2.process2.service.IDeviceService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.amqp.rabbit.annotation.RabbitHandler;
 import org.springframework.amqp.rabbit.annotation.RabbitListener;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Component;
 
 import java.text.ParseException;
+import java.util.HashMap;
 import java.util.Map;
 
 /**
@@ -20,6 +27,10 @@ import java.util.Map;
 @Component
 @Slf4j
 public class DeviceListener {
+    @Autowired
+    private RedisTemplate redisTemplate;
+    @Autowired
+    private IDeviceService deviceService;
 
     /**
      * @Method      : processDeviceHeartbeat
@@ -33,13 +44,45 @@ public class DeviceListener {
      */
     @RabbitListener(queues = Const.QUEUE_DEVICE_HEARTBEAT)
     @RabbitHandler
-    public void processDeviceHeartbeat(Map RawMap) throws ParseException {
-        System.out.println("222 <<<<<<<<<<<<<<< 处理设备心跳数据>>"+RawMap.toString());
-        //--保存设备注册数据(MySQL,Redis)-
-        //--保存设备在线数据(MySQL,Redis)-
+    public void processDeviceHeartbeat(Map DeviceMap) throws ParseException {
+        System.out.println("222 <<<<<<<<<<<<<<< 处理设备心跳数据>>"+DeviceMap.toString());
+        //--更新设备注册数据(MySQL,Redis)-
+        //--保存设备在线统计数据(MySQL,Redis)-
         //--保存设备状态数据(MySQL,Redis)-
+        JSONObject deviceJo = JSON.parseObject(DeviceMap.get("heartbeat").toString());
+        String deviceCode = deviceJo.getString("device");
+        System.out.println("deviceCode>>"+deviceCode);
+        //--设备在线统计表
+        //--设备状态每日统计表
+        //--设备和耳标总状态表
 
+//        test1();
 
+        //# 心跳数加1,更改在线统计数据表(MySQL),更新Redis; #
+        deviceService.updateDeviceRegister(deviceCode);
+
+        //# 心跳数加1,更改在线统计数据表(MySQL),更新Redis; #
+        deviceService.updateDeviceOnline(deviceCode);
+
+        //# 处理状态数据 #
+        deviceService.updateFarmDeviceStatus(deviceCode);
+    }
+
+    private void test1() {
+            String deviceCode = "202007239999869";
+//            Map map = new HashMap<>();
+//            map.put("name","栋舍");
+//            map.put("id","001");
+//            System.out.println("map>>"+map.toString());
+            String deviceRegHashKey = "device_register_"+deviceCode;
+            //为hash结构设置多个键值对(hmset)
+//        redisTemplate.opsForHash().putAll(deviceRegHashKey, map);
+
+
+//            Object actObj = redisTemplate.opsForHash().get(deviceCode, "act");
+//            System.out.println("actObj>>"+actObj);
+        Object nameObj = redisTemplate.opsForHash().get(deviceRegHashKey,"name");
+        System.out.println("nameObj>>"+nameObj.toString());
     }
 
     /**
@@ -54,12 +97,21 @@ public class DeviceListener {
      */
     @RabbitListener(queues = Const.QUEUE_DEVICE_TEMP)
     @RabbitHandler
-    public void processDeviceTemp(Map RawMap) throws ParseException {
-        System.out.println("333 <<<<<<<<<<<<<<< 处理设备温度数据>>"+RawMap.toString());
-        //--保存设备注册数据(MySQL,Redis)-processProducer
-        //--保存设备状态数据(MySQL,Redis)-processProducer
+    public void processDeviceTemp(Map DeviceTempMap) throws ParseException {
+        System.out.println("333 <<<<<<<<<<<<<<< 处理设备温度数据>>"+DeviceTempMap.toString());
+        JSONObject deviceJo = JSON.parseObject(DeviceTempMap.get("deviceTemp").toString());
+        String deviceCode = deviceJo.getString("device");
+        System.out.println("333 设备编号>>"+deviceCode);
+        //--保存设备注册数据(MySQL,Redis)
+        //--保存设备状态数据(MySQL,Redis)
 
+        //--设备在线统计表
+        //--设备状态每日统计表
+        //--设备和耳标总状态表
 
+//        test1();
+        //# 处理状态数据 #
+        deviceService.updateFarmDeviceStatus(deviceCode);
 
     }
 }

+ 10 - 0
huimv-eartag2-platform/huimv-eartag2-process2/src/main/java/com/huimv/eartag2/process2/service/IDeviceService.java

@@ -1,5 +1,6 @@
 package com.huimv.eartag2.process2.service;
 
+import java.text.ParseException;
 import java.util.Map;
 
 public interface IDeviceService {
@@ -8,4 +9,13 @@ public interface IDeviceService {
 
     //保存状态数据
     void saveDeviceStatus(Map deviceMap);
+
+    //更新设备注册数据
+    void updateDeviceRegister(String deviceCode);
+
+    //更新设备在线数据
+    void updateDeviceOnline(String deviceCode) throws ParseException;
+
+    //处理状态数据
+    void updateFarmDeviceStatus(String deviceCode) throws ParseException;
 }

+ 20 - 0
huimv-eartag2-platform/huimv-eartag2-process2/src/main/java/com/huimv/eartag2/process2/service/IRedisService.java

@@ -0,0 +1,20 @@
+package com.huimv.eartag2.process2.service;
+
+import com.huimv.eartag2.common.dao.entity.EartarFarmAllStatusEntity;
+
+import java.text.ParseException;
+import java.util.Map;
+
+public interface IRedisService {
+    //证是否存在当天总状态数据
+    Boolean isExistTodayFarmAllStatus(String deviceCode) throws ParseException;
+
+    //
+    Object getFarmIdByDeviceCode(String deviceCode);
+
+    //
+    Object getCreateDateByFarmId(String farmId);
+
+    //
+    void putFarmAllStatusCache(String farmId, EartarFarmAllStatusEntity farmAllStatusEntity) throws ParseException;
+}

+ 379 - 2
huimv-eartag2-platform/huimv-eartag2-process2/src/main/java/com/huimv/eartag2/process2/service/impl/DeviceServiceImpl.java

@@ -1,8 +1,26 @@
 package com.huimv.eartag2.process2.service.impl;
 
+//import cn.hutool.core.date.DateUtil;
+
+import com.huimv.eartag2.common.dao.entity.EartagDeviceOnlineEntity;
+import com.huimv.eartag2.common.dao.entity.EartagDeviceRegisterEntity;
+import com.huimv.eartag2.common.dao.entity.EartarFarmAllStatusEntity;
+import com.huimv.eartag2.common.dao.repo.*;
+import com.huimv.eartag2.common.utils.BizConst;
+import com.huimv.eartag2.common.utils.DateUtil;
 import com.huimv.eartag2.process2.service.IDeviceService;
+//import com.huimv.eartag2.process2.utils.DateUtil;
+import com.huimv.eartag2.process2.service.IRedisService;
+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 java.math.BigDecimal;
+import java.sql.Timestamp;
+import java.text.ParseException;
+import java.util.Date;
+import java.util.HashMap;
 import java.util.Map;
 
 /**
@@ -14,18 +32,377 @@ import java.util.Map;
  * @Create : 2020-12-25
  **/
 @Service
+@Slf4j
 public class DeviceServiceImpl implements IDeviceService {
+    @Autowired
+    private RedisTemplate redisTemplate;
+    @Autowired
+    private EartagDeviceRegisterRepo deviceRegisterRepo;
+    @Autowired
+    private EartagHeartbeatRepo heartbeatRepo;
+    @Autowired
+    private EartagEnvRepo envRepo;
+    //    @Value("#{device.register.prefix}")
+//    private String deviceRegisterPrefix;
+    @Autowired
+    private EartagDeviceOnlineRepo eartagDeviceOnlineRepo;
+    @Autowired
+    private IRedisService redisService;
+    @Autowired
+    private EartarFarmAllStatusRepo eartagFarmAllStatusRepo;
+    @Autowired
+    private EartagEartagRegisterRepo eartagRegisterRepo;
+    @Autowired
+    private EartagDeviceRegisterRepo eartagDeviceRegisterRepo;
+
 
     // 保存在线数据
     @Override
-    public void saveDeviceOnline(Map deviceMap){
+    public void saveDeviceOnline(Map deviceMap) {
 
     }
 
     //保存状态数据
     @Override
-    public void saveDeviceStatus(Map deviceMap){
+    public void saveDeviceStatus(Map deviceMap) {
+
+    }
+
+    /**
+     * @Method : updateDeviceRegister
+     * @Description : 更新设备注册数据
+     * @Params : [deviceCode]
+     * @Return : void
+     * @Author : ZhuoNing
+     * @Date : 2022/2/21
+     * @Time : 15:13
+     */
+    @Override
+    public void updateDeviceRegister(String deviceCode) {
+        System.out.println("updateDeviceRegister");
+        //--更新设备注册表(eartag_device_register.active_status)同时更新对应的Redis
+        updateRegisterActiveStatus(deviceCode);
+    }
+
+    /**
+     * @Method : updateRegisterActiveStatus
+     * @Description : 更新注册表中的心跳状态
+     * @Params : [deviceCode]
+     * @Return : void
+     * @Author : ZhuoNing
+     * @Date : 2022/2/21
+     * @Time : 15:13
+     */
+    void updateRegisterActiveStatus(String deviceCode) {
+        //--更新mysql
+        EartagDeviceRegisterEntity deviceRegisterEntity = deviceRegisterRepo.getDeviceRegister(deviceCode);
+        if (deviceRegisterEntity != null) {
+//            if(deviceRegisterEntity.getActiveStatus() == 0){
+            deviceRegisterEntity.setActiveStatus(1);
+            deviceRegisterEntity.setActiveTime(new Timestamp(new Date().getTime()));
+            deviceRegisterRepo.saveAndFlush(deviceRegisterEntity);
+//            }
+        }
+        //--更新redis中注册表数据
+        String deviceRegHashKey = BizConst.DEVICE_REGISTER_PREFIX + deviceCode;
+        //将Entity转为Map
+        Map registerMap = RegisterEntityToMap(deviceRegisterEntity);
+        redisTemplate.opsForHash().putAll(deviceRegHashKey, registerMap);
+
+//        Object nameObj = redisTemplate.opsForHash().get(deviceRegHashKey,"activeTime");
+//        System.out.println("activeTime>>"+nameObj.toString());
+    }
 
+    /**
+     * @Method : RegisterEntityToMap
+     * @Description :
+     * @Params : [deviceRegisterEntity]
+     * @Return : java.util.Map
+     * @Author : ZhuoNing
+     * @Date : 2022/2/21
+     * @Time : 14:03
+     */
+    private Map RegisterEntityToMap(EartagDeviceRegisterEntity deviceRegisterEntity) {
+        Map map = new HashMap();
+        map.put("Id", deviceRegisterEntity.getId());
+        map.put("deviceCode", deviceRegisterEntity.getDeviceCode());
+        map.put("farmId", deviceRegisterEntity.getFarmId());
+        map.put("farmName", deviceRegisterEntity.getFarmName());
+        map.put("typeF", deviceRegisterEntity.getTypeF());
+        map.put("stage", deviceRegisterEntity.getStage());
+        map.put("pigpenId", deviceRegisterEntity.getPigpenId());
+        map.put("unitId", deviceRegisterEntity.getUnitId());
+        map.put("registerTime", deviceRegisterEntity.getRegisterTime());
+        map.put("lastTime", deviceRegisterEntity.getLastTime());
+        map.put("activeStatus", deviceRegisterEntity.getActiveStatus());
+        map.put("activeTime", deviceRegisterEntity.getActiveTime());
+        map.put("deviceStatus", deviceRegisterEntity.getDeviceStatus());
+        map.put("deviceAlias", deviceRegisterEntity.getDeviceAlias());
+        map.put("location", deviceRegisterEntity.getLocation());
+        map.put("remark", deviceRegisterEntity.getRemark());
+        return map;
     }
 
+    //更新设备在线数据
+    @Override
+    public void updateDeviceOnline(String deviceCode) throws ParseException {
+        //设备在线表 eartag_device_online.heartbeat_total
+        //更新mysql
+        //更新redis
+        //# 更新设备在线数据 #
+        updateDeviceOnlineCount(deviceCode);
+
+        //# 更新设备注册表(eartag_device_register.active_status)同时更新对应的Redis #
+//        updateRegisterActiveStatus(deviceCode);
+    }
+
+    //更新设备在线Static
+    private void updateDeviceOnlineCount(String deviceCode) throws ParseException {
+        String todayText = new DateUtil().getTodayDateText();
+        //读取在线日期
+        EartagDeviceOnlineEntity eartagDeviceOnlineEntity = eartagDeviceOnlineRepo.getDeviceOnline(deviceCode, todayText);
+        String deviceOnlineHashKey = BizConst.DEVICE_ONLINE_PREFIX + deviceCode;
+        if (eartagDeviceOnlineEntity == null) {
+            //# 新建今天在线记录(1),并将记录同步到redis(2) #
+            //查询别名
+            Object deviceAliasObj = redisTemplate.opsForHash().get(BizConst.DEVICE_REGISTER_PREFIX + deviceCode, "deviceAlias");
+            System.out.println("TEST deviceAliasObj>>" + deviceAliasObj.toString());
+            String deviceAlias = "";
+            if (deviceAliasObj != null) {
+                deviceAlias = deviceAliasObj.toString();
+            } else {
+                //从设备注册表读取设备别名
+                //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+            }
+            //# 查询牧场id #
+//            Object farmIdObj = redisTemplate.opsForHash().get(BizConst.DEVICE_REGISTER_PREFIX + deviceCode,"farmId");
+            Object farmIdObj = redisService.getFarmIdByDeviceCode(deviceCode);
+            System.out.println("TEST farmIdObj>>" + farmIdObj.toString());
+            //(1)
+            EartagDeviceOnlineEntity newEartagDeviceOnlineEntity = new EartagDeviceOnlineEntity();
+            newEartagDeviceOnlineEntity.setDeviceCode(deviceCode);
+            newEartagDeviceOnlineEntity.setAlias(deviceAlias);
+            newEartagDeviceOnlineEntity.setHeartbeatTotal(1);
+            newEartagDeviceOnlineEntity.setEnvtempTotal(0);
+            newEartagDeviceOnlineEntity.setEartagTotal(0);
+            newEartagDeviceOnlineEntity.setFirstTime(new Timestamp(new Date().getTime()));
+            newEartagDeviceOnlineEntity.setLastTime(new Timestamp(new Date().getTime()));
+            newEartagDeviceOnlineEntity.setAddDate(new java.sql.Date(new Date().getTime()));
+            newEartagDeviceOnlineEntity.setFarmId(Integer.parseInt(farmIdObj.toString()));
+            eartagDeviceOnlineRepo.saveAndFlush(newEartagDeviceOnlineEntity);
+            //(2)
+            //将onlineEntity转为Map
+            Map onlineMap = fromOnlineEntityToMap(newEartagDeviceOnlineEntity);
+            redisTemplate.opsForHash().putAll(deviceOnlineHashKey, onlineMap);
+        } else {
+            //# 修改今天在线记录(1),并将记录同步到redis(2) #
+            //(1)
+            int total = eartagDeviceOnlineEntity.getHeartbeatTotal();
+            eartagDeviceOnlineEntity.setHeartbeatTotal(total + 1);
+            eartagDeviceOnlineRepo.saveAndFlush(eartagDeviceOnlineEntity);
+            //(2)
+            //将onlineEntity转为Map
+            Map onlineMap = fromOnlineEntityToMap(eartagDeviceOnlineEntity);
+            redisTemplate.opsForHash().putAll(deviceOnlineHashKey, onlineMap);
+        }
+    }
+
+    //--将onlineEntity转为Map
+    private Map fromOnlineEntityToMap(EartagDeviceOnlineEntity newEartagDeviceOnlineEntity) {
+        Map map = new HashMap();
+        map.put("id", newEartagDeviceOnlineEntity.getId());
+        map.put("deviceCode", newEartagDeviceOnlineEntity.getDeviceCode());
+        map.put("alias", newEartagDeviceOnlineEntity.getAlias());
+        map.put("heartbeatTotal", newEartagDeviceOnlineEntity.getHeartbeatTotal());
+        map.put("envtempTotal", newEartagDeviceOnlineEntity.getEnvtempTotal());
+        map.put("eartagTotal", newEartagDeviceOnlineEntity.getEartagTotal());
+        map.put("firstTime", newEartagDeviceOnlineEntity.getFirstTime());
+        map.put("lastTime", newEartagDeviceOnlineEntity.getLastTime());
+        map.put("lastEnvtemp", newEartagDeviceOnlineEntity.getLastEnvtemp());
+        map.put("lastEartag", newEartagDeviceOnlineEntity.getLastEartag());
+        map.put("addDate", newEartagDeviceOnlineEntity.getAddDate());
+        map.put("farmId", newEartagDeviceOnlineEntity.getFarmId());
+        return map;
+    }
+
+    /**
+     * @Method : updateDeviceStatus
+     * @Description : 更新设备状态数据
+     * @Params : [deviceCode]
+     * @Return : void
+     * @Author : ZhuoNing
+     * @Date : 2022/2/21
+     * @Time : 16:04
+     */
+    @Override
+    public void updateFarmDeviceStatus(String deviceCode) throws ParseException {
+        System.out.println("updateDeviceStatus 1.deviceCode>>" + deviceCode);
+        String todayDateText = new DateUtil().getTodayDateText();
+        System.out.println("1.todayDateText>>" + todayDateText);
+
+        //(1)判断牧场总状态缓存是否存在
+        Object createDateObj = checkIsExistFarmAllStatusCache(deviceCode);
+        if (createDateObj == null) {
+            log.error("这个设备(" + deviceCode + ")的注册数据不存在,请检查具体原因.");
+            System.out.println("1.");
+            //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+        } else if (createDateObj.toString().equalsIgnoreCase("0")) {
+            System.out.println("牧场总状态缓存记录不存在.");
+            // B流程
+            handleDeviceStatus(deviceCode);
+            System.out.println("2.");
+        }else if (createDateObj.toString().trim().equalsIgnoreCase(todayDateText)) {
+            //计算在线状态,并同步到缓存
+            Object farmIdObj = redisService.getFarmIdByDeviceCode(deviceCode);
+            countDeviceStatus(farmIdObj.toString(),deviceCode,todayDateText);
+            System.out.println("3.");
+            //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+        } else {
+            //缓存日期非当日日期
+            // B流程
+            handleDeviceStatus(deviceCode);
+            System.out.println("4.");
+            //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+        }
+    }
+
+    //# 处理设备状态 #
+    private void handleDeviceStatus(String deviceCode) throws ParseException {
+        //(1)判断今天的牧场总状态记录是否存在
+        //从设备注册表读取牧场id
+        EartagDeviceRegisterEntity deviceRegisterEntity = eartagDeviceRegisterRepo.getDeviceRegister(deviceCode);
+        String farmId = "";
+        if(deviceRegisterEntity == null){
+            log.error("这个设备(" + deviceCode + ")的注册数据不存在,请检查具体原因.");
+        }else{
+            farmId = deviceRegisterEntity.getFarmId();
+        }
+        String todayDateText = new DateUtil().getTodayDateText();
+        EartarFarmAllStatusEntity farmAllStatusEntity = eartagFarmAllStatusRepo.getOneByFarmIdAndCreateDate(farmId,todayDateText);
+        if(farmAllStatusEntity == null){
+            //设备注册表信息不存在
+            //创建设备状态记录并更新缓存cache()
+            createFarmAllStatus(deviceCode);
+            //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+        }else{
+            //设备注册表信息存在
+            //计算设备状态并更新缓存cache()
+            countDeviceStatus(farmId,deviceCode,todayDateText);
+        }
+    }
+
+    //# 计算在线状态,并同步到缓存 #
+    private void countDeviceStatus(String farmId,String deviceCode,String todayDateText) throws ParseException {
+        //读取牧场总状态数据
+        EartarFarmAllStatusEntity farmAllStatusEntity = eartagFarmAllStatusRepo.getOneByFarmIdAndCreateDate(farmId,todayDateText);
+        //在线数+1,离线数-1,计算设备在线率
+        int onlineNum = farmAllStatusEntity.getDeviceOnline();
+        int offlineNum = farmAllStatusEntity.getDeviceOffline();
+        int total = farmAllStatusEntity.getDeviceTotal();
+        onlineNum++;
+        offlineNum--;
+        BigDecimal reateBd= new BigDecimal(onlineNum).divide(new BigDecimal(total),1,BigDecimal.ROUND_HALF_UP);
+        farmAllStatusEntity.setDeviceOnline(onlineNum);
+        farmAllStatusEntity.setDeviceOffline(offlineNum);
+        farmAllStatusEntity.setDeviceRate(Float.parseFloat(reateBd.toString()));
+        System.out.println("## farmAllStatusEntity>>"+farmAllStatusEntity);
+        eartagFarmAllStatusRepo.saveAndFlush(farmAllStatusEntity);
+        //# 设置牧场总状态缓存相关字段 #
+        redisService.putFarmAllStatusCache(farmId,farmAllStatusEntity);
+    }
+
+
+    //断牧场总状态缓存是否存在
+    private Object checkIsExistFarmAllStatusCache(String deviceCode) {
+        //从缓存中获取farmId
+        Object farmIdObj = redisService.getFarmIdByDeviceCode(deviceCode);
+        System.out.println("22.farmIdObj>>" + farmIdObj);
+        String farmId = "";
+        if (farmIdObj != null) {
+            farmId = farmIdObj.toString();
+        } else {
+            log.info("设备注册缓存里没有设备编号为" + deviceCode + "的设备注册信息");
+            //(2)
+            EartagDeviceRegisterEntity eartagDeviceRegisterEntity = eartagDeviceRegisterRepo.getDeviceRegister(deviceCode);
+            System.out.println("22.eartagDeviceRegisterEntity>>" + eartagDeviceRegisterEntity.toString());
+            if (eartagDeviceRegisterEntity == null) {
+                log.error("设备注册记录不存在设备编号为" + deviceCode + "的设备注册信息.");
+                return null;
+            } else {
+                farmId = eartagDeviceRegisterEntity.getFarmId();
+            }
+        }
+        System.out.println("22.farmId>>" + farmId);
+        //从牧场总状态缓存中获取最近一次日期
+        Object createDateObj = redisService.getCreateDateByFarmId(farmId);
+        System.out.println("22.createDateObj>>" + createDateObj);
+        if (createDateObj == null) {
+            return "0";
+        } else {
+            return createDateObj;
+        }
+    }
+
+//    public void updateDeviceStatus_old1(String deviceCode) throws ParseException {
+//        System.out.println("updateDeviceStatus 1.deviceCode>>" + deviceCode);
+//        //# 验证是否存在当天总状态记录
+//        //(1)
+//        if (redisService.isExistTodayFarmAllStatus(deviceCode)) {
+//            //缓存中存在该牧场当当天的总状态记录
+//            System.out.println("缓存中存在该记录:Yes");
+//            //更新总状态记录
+////            autoUpdateFarmAllStatus(deviceCode);
+//        } else {
+//            System.out.println("缓存中存在该记录:No");
+//            //# 创建总状态记录 #(缓存中没有今天的记录)
+//            createFarmAllStatus(deviceCode);
+//        }
+//    }
+
+    //# 创建总状态记录 #
+    private void createFarmAllStatus(String deviceCode) {
+        //#从farm_all_status读取最近一天的数据
+        Map lastFarmAllStatusMap = getLastFarmAllStatus(deviceCode);
+
+        //MySQL:farm_all_status
+
+
+        //Redis:farm_all_status_farmId
+
+
+    }
+
+    //#
+    private Map getLastFarmAllStatus(String deviceCode) {
+//        farmAllStatusRepo.getLastFarmAllStatus();
+        //获取farmId,然后用farmId获取最近一天的数据
+        Object farmIdObj = redisService.getFarmIdByDeviceCode(deviceCode);
+        System.out.println("redis.farmIdObj>>" + farmIdObj);
+        if (farmIdObj == null) {
+            //# 初始化MySQL:farm_all_status
+            initFarmAllStatus();
+        }
+
+        //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+        return null;
+    }
+
+    //# 初始化总状态表
+    private void initFarmAllStatus() {
+        //# 计算设备总数(设备注册表)
+        int deviceTotal = 0;
+//        deviceRegisterRepo.countTotal();
+
+        //# 计算耳标总数(耳标注册表)
+        int eartagTotal = 0;
+
+        EartarFarmAllStatusEntity farmAllStatusEntity = new EartarFarmAllStatusEntity();
+        farmAllStatusEntity.setDeviceTotal(deviceTotal);
+        farmAllStatusEntity.setEartagTotal(eartagTotal);
+        eartagFarmAllStatusRepo.saveAndFlush(farmAllStatusEntity);
+
+        //同步更新redis缓存
+
+        //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+    }
 }

+ 105 - 0
huimv-eartag2-platform/huimv-eartag2-process2/src/main/java/com/huimv/eartag2/process2/service/impl/RedisServiceImpl.java

@@ -0,0 +1,105 @@
+package com.huimv.eartag2.process2.service.impl;
+
+import com.huimv.eartag2.common.dao.entity.EartagDeviceRegisterEntity;
+import com.huimv.eartag2.common.dao.entity.EartarFarmAllStatusEntity;
+import com.huimv.eartag2.common.dao.repo.EartagDeviceRegisterRepo;
+import com.huimv.eartag2.common.utils.BizConst;
+import com.huimv.eartag2.common.utils.DateUtil;
+import com.huimv.eartag2.process2.service.IRedisService;
+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 java.text.ParseException;
+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 RedisServiceImpl implements IRedisService {
+    @Autowired
+    private RedisTemplate redisTemplate;
+    @Autowired
+    private EartagDeviceRegisterRepo eartagDeviceRegisterRepo;
+
+    @Override
+    public Boolean isExistTodayFarmAllStatus(String deviceCode) throws ParseException {
+        System.out.println("isExistTodayFarmAllStatus 2.deviceCode>>"+deviceCode);
+
+        //(1)从注册表缓存中(device_register_牧场id)取出牧场id,(2)如果缓存没有则从注册表(eartag_device_register)中查询00
+        //(1)
+        Object farmIdObj = redisTemplate.opsForHash().get(BizConst.DEVICE_REGISTER_PREFIX + deviceCode,"farmId");
+        System.out.println("2.farmIdObj>>"+farmIdObj);
+        String farmId = "";
+        if(farmIdObj != null){
+            farmId = farmIdObj.toString();
+        }else{
+            //(2)
+            EartagDeviceRegisterEntity eartagDeviceRegisterEntity = eartagDeviceRegisterRepo.getDeviceRegister(deviceCode);
+            System.out.println("2.eartagDeviceRegisterEntity>>"+eartagDeviceRegisterEntity.toString());
+            if(eartagDeviceRegisterEntity == null){
+                log.error("设备编号:"+deviceCode+",不存在.");
+                return null;
+            }
+            farmId = eartagDeviceRegisterEntity.getFarmId();
+        }
+        System.out.println("2.farmId>>"+farmId);
+        //从牧场总状态缓存中获取最近一次日期
+        Object createDateObj = redisTemplate.opsForHash().get(BizConst.FARM_ALL_STATUS_PREFIX + farmId,"createDate");
+        System.out.println("2.createDateObj>>"+createDateObj);
+        if(createDateObj == null){
+            //--总状态记录记录不存在
+            System.out.println("A.");
+            return false;
+        }else{
+            //
+            String createDate = createDateObj.toString();
+            System.out.println("缓存中上次操作日期 createDate>>"+createDate);
+            if(new DateUtil().getTodayDateText().trim().equalsIgnoreCase(createDate)){
+                //--当天记录存在,就返回true;
+                System.out.println("B.");
+                return true;
+            }else{
+                //--当天记录不存在,就返回false;
+                System.out.println("C.");
+                return false;
+            }
+        }
+    }
+
+    //# 读根据设备编码读取牧场id
+    @Override
+    public Object getFarmIdByDeviceCode(String deviceCode) {
+        Object farmIdObj = redisTemplate.opsForHash().get(BizConst.DEVICE_REGISTER_PREFIX + deviceCode,"farmId");
+        return farmIdObj;
+    }
+
+    @Override
+    public Object getCreateDateByFarmId(String farmId) {
+        return redisTemplate.opsForHash().get(BizConst.FARM_ALL_STATUS_PREFIX + farmId,"createDate");
+    }
+
+    @Override
+    public void putFarmAllStatusCache(String farmId, EartarFarmAllStatusEntity farmAllStatusEntity) throws ParseException {
+        DateUtil duObj = new DateUtil();
+//        redisTemplate.opsForHash().putAll(BizConst.FARM_ALL_STATUS_PREFIX+farmId, allStatusMap);
+        redisTemplate.opsForHash().put(BizConst.FARM_ALL_STATUS_PREFIX+farmId,"deviceOnline",farmAllStatusEntity.getDeviceOnline());
+        redisTemplate.opsForHash().put(BizConst.FARM_ALL_STATUS_PREFIX+farmId,"deviceOffline",farmAllStatusEntity.getDeviceOffline());
+        redisTemplate.opsForHash().put(BizConst.FARM_ALL_STATUS_PREFIX+farmId,"deviceRate",farmAllStatusEntity.getDeviceRate());
+        redisTemplate.opsForHash().put(BizConst.FARM_ALL_STATUS_PREFIX+farmId,"updateTime",duObj.formatDateTime(duObj.getTodayText()));
+    }
+
+    //#
+    public Object getValByKey(String hashKey,String key){
+        Object valueObj = redisTemplate.opsForHash().get(hashKey,key);
+        return valueObj;
+    }
+}

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

@@ -0,0 +1,187 @@
+package com.huimv.eartag2.process2.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();
+    }
+}

+ 1 - 1
huimv-eartag2-platform/huimv-eartag2-process2/src/main/resources/application.properties

@@ -1,2 +1,2 @@
 spring.profiles.active=dev
-        
+device.register.prefix=device_register_

+ 39 - 0
huimv-eartag2-platform/huimv-eartag2-process2/src/test/java/com/huimv/eartag2/process2/utils/RedisUtil.java

@@ -0,0 +1,39 @@
+package com.huimv.eartag2.process2.utils;
+
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.data.redis.core.RedisTemplate;
+
+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
+ **/
+@SpringBootTest
+public class RedisUtil {
+    @Autowired
+    private RedisTemplate redisTemplate;
+
+    @Test
+    public void test1(){
+        System.out.println("test1");
+        String deviceCode = "202007239999869";
+        Map map = new HashMap<>();
+        map.put("name","栋舍");
+        map.put("id","001");
+        System.out.println("map>>"+map.toString());
+        //为hash结构设置多个键值对(hmset)
+//        redisTemplate.opsForHash().putAll("device_register_"+deviceCode, map);
+
+
+        Object actObj = redisTemplate.opsForHash().get(deviceCode, "act");
+        System.out.println("actObj>>"+actObj);
+    }
+}

+ 26 - 0
huimv-eartag2-platform/huimv-eartag2-process2/src/test/java/com/huimv/eartag2/process2/utils/TypeTest.java

@@ -0,0 +1,26 @@
+package com.huimv.eartag2.process2.utils;
+
+import org.junit.Test;
+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 TypeTest {
+    @Test
+    public void test(){
+        String deviceCode= "202007239999869";
+        System.out.println("deviceCode>>"+deviceCode);
+//        int deviceCodeInt = Integer.parseInt(deviceCode);
+//        System.out.println("deviceCodeInt>>"+deviceCodeInt);
+        Long deviceCodeLong = Long.parseLong(deviceCode);
+        System.out.println("deviceCodeLong>>"+deviceCodeLong);
+
+    }
+}

+ 33 - 0
huimv-eartag2-platform/writeCode/.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/writeCode/.mvn/wrapper/maven-wrapper.jar


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

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

+ 331 - 0
huimv-eartag2-platform/writeCode/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/writeCode/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%

+ 41 - 0
huimv-eartag2-platform/writeCode/pom.xml

@@ -0,0 +1,41 @@
+<?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>
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.6.3</version>
+        <relativePath/> <!-- lookup parent from repository -->
+    </parent>
+    <groupId>com.example</groupId>
+    <artifactId>demo</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <name>demo</name>
+    <description>Demo project for Spring Boot</description>
+    <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>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

+ 13 - 0
huimv-eartag2-platform/writeCode/src/main/java/com/example/demo/DemoApplication.java

@@ -0,0 +1,13 @@
+package com.example.demo;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class DemoApplication {
+
+    public static void main(String[] args) {
+        SpringApplication.run(DemoApplication.class, args);
+    }
+
+}

+ 1 - 0
huimv-eartag2-platform/writeCode/src/main/resources/application.properties

@@ -0,0 +1 @@
+

+ 13 - 0
huimv-eartag2-platform/writeCode/src/test/java/com/example/demo/DemoApplicationTests.java

@@ -0,0 +1,13 @@
+package com.example.demo;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class DemoApplicationTests {
+
+    @Test
+    void contextLoads() {
+    }
+
+}