瀏覽代碼

【feat】 添加对外服务 api

523096025 1 年之前
父節點
當前提交
a3e07a6c8a
共有 39 個文件被更改,包括 840 次插入2185 次删除
  1. 0 69
      huimv-eartag2-platform/data-process/pom.xml
  2. 0 20
      huimv-eartag2-platform/data-process/src/main/java/com/huimv/dataprocess/DataProcessApplication.java
  3. 0 164
      huimv-eartag2-platform/data-process/src/main/java/com/huimv/dataprocess/dao/entity/EartagDataEntity.java
  4. 0 135
      huimv-eartag2-platform/data-process/src/main/java/com/huimv/dataprocess/dao/entity/EartagEartagRegister2Entity.java
  5. 0 9
      huimv-eartag2-platform/data-process/src/main/java/com/huimv/dataprocess/dao/repo/EartagDataEntityRepository.java
  6. 0 9
      huimv-eartag2-platform/data-process/src/main/java/com/huimv/dataprocess/dao/repo/EartagEartagRegister2EntityRepository.java
  7. 0 104
      huimv-eartag2-platform/data-process/src/main/resources/application-goldpig.yml
  8. 0 31
      huimv-eartag2-platform/data-process/src/main/resources/application.properties
  9. 0 62
      huimv-eartag2-platform/data-process/src/test/java/com/huimv/dataprocess/data/DataProcessTest.java
  10. 0 69
      huimv-eartag2-platform/data-process2/pom.xml
  11. 0 27
      huimv-eartag2-platform/data-process2/src/main/java/com/huimv/dataprocess2/DataProcess2Application.java
  12. 0 104
      huimv-eartag2-platform/data-process2/src/main/resources/application-eartag.yml
  13. 0 104
      huimv-eartag2-platform/data-process2/src/main/resources/application-eartag2.yml
  14. 0 31
      huimv-eartag2-platform/data-process2/src/main/resources/application.properties
  15. 0 408
      huimv-eartag2-platform/data-process2/src/test/java/com/huimv/dataprocess2/DataProcess2Test.java
  16. 37 37
      huimv-eartag2-platform/huimv-eartag2-api/src/main/java/com/huimv/eartag2/api/HuimvApiApplication.java
  17. 134 134
      huimv-eartag2-platform/huimv-eartag2-api/src/main/java/com/huimv/eartag2/api/controller/EartagAbnormalAlarmController.java
  18. 111 111
      huimv-eartag2-platform/huimv-eartag2-api/src/main/java/com/huimv/eartag2/api/netty/EartagServer.java
  19. 298 298
      huimv-eartag2-platform/huimv-eartag2-api/src/main/java/com/huimv/eartag2/api/netty/EartagServerHandler2.java
  20. 119 119
      huimv-eartag2-platform/huimv-eartag2-api/src/main/java/com/huimv/eartag2/api/service/impl/FarmerAssetServiceImpl.java
  21. 1 1
      huimv-eartag2-platform/huimv-eartag2-common/pom.xml
  22. 4 3
      huimv-eartag2-platform/huimv-eartag2-device/src/main/resources/application-prod2.yml
  23. 1 1
      huimv-eartag2-platform/huimv-eartag2-device/src/main/resources/application.properties
  24. 33 33
      huimv-eartag2-platform/huimv-eartag2-eartag/pom.xml
  25. 1 2
      huimv-eartag2-platform/huimv-eartag2-eartag/src/main/java/com/huimv/eartag2/eartag/listener/EartagListener.java
  26. 1 10
      huimv-eartag2-platform/huimv-eartag2-eartag/src/main/java/com/huimv/eartag2/eartag/service/impl/DeviceServiceImpl.java
  27. 5 9
      huimv-eartag2-platform/huimv-eartag2-eartag/src/main/java/com/huimv/eartag2/eartag/service/impl/EartagServiceImpl.java
  28. 7 4
      huimv-eartag2-platform/huimv-eartag2-eartag/src/main/resources/application-prod2.yml
  29. 6 6
      huimv-eartag2-platform/huimv-eartag2-eartag/src/main/resources/application.properties
  30. 54 54
      huimv-eartag2-platform/huimv-eartag2-input/pom.xml
  31. 1 0
      huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/server/EartagServerHandler2.java
  32. 1 0
      huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/service/impl/DataServiceImpl.java
  33. 9 8
      huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/service/impl/DeviceServiceImpl.java
  34. 5 0
      huimv-eartag2-platform/huimv-eartag2-input/src/main/resources/application-prod2.yml
  35. 2 2
      huimv-eartag2-platform/huimv-eartag2-input/src/main/resources/application.properties
  36. 5 3
      huimv-eartag2-platform/huimv-eartag2-manage2/src/main/java/com/huimv/eartag2/manage2/netty/EartagServerHandler2.java
  37. 2 2
      huimv-eartag2-platform/huimv-eartag2-manage2/src/main/resources/application-prod2.yml
  38. 2 2
      huimv-eartag2-platform/huimv-eartag2-manage2/src/main/resources/application.properties
  39. 1 0
      huimv-eartag2-platform/pom.xml

+ 0 - 69
huimv-eartag2-platform/data-process/pom.xml

@@ -1,69 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <parent>
-        <artifactId>huimv-eartag2-platform</artifactId>
-        <groupId>com.huimv</groupId>
-        <version>0.0.1-SNAPSHOT</version>
-    </parent>
-    <modelVersion>4.0.0</modelVersion>
-
-    <artifactId>data-process</artifactId>
-
-    <properties>
-        <java.version>1.8</java.version>
-    </properties>
-    <dependencies>
-        <!-- eartag2-common -->
-        <dependency>
-            <groupId>com.huimv</groupId>
-            <artifactId>huimv-eartag2-common</artifactId>
-            <version>0.0.2-SNAPSHOT</version>
-        </dependency>
-        <!-- 排除Tomcat容器 -->
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-web</artifactId>
-            <!-- 移除掉默认支持的 Tomcat -->
-            <exclusions>
-                <exclusion>
-                    <groupId>org.springframework.boot</groupId>
-                    <artifactId>spring-boot-starter-tomcat</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-        <!-- 添加 Undertow 容器 -->
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-undertow</artifactId>
-        </dependency>
-        <!-- netty -->
-        <dependency>
-            <groupId>io.netty</groupId>
-            <artifactId>netty-all</artifactId>
-            <version>4.1.45.Final</version>
-        </dependency>
-        <!--rabbitmq-->
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-amqp</artifactId>
-        </dependency>
-    </dependencies>
-
-    <build>
-        <plugins>
-            <!--  -->
-            <plugin>
-                <groupId>org.springframework.boot</groupId>
-                <artifactId>spring-boot-maven-plugin</artifactId>
-            </plugin>
-            <!--  -->
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-resources-plugin</artifactId>
-                <version>2.6</version>
-            </plugin>
-        </plugins>
-    </build>
-</project>

+ 0 - 20
huimv-eartag2-platform/data-process/src/main/java/com/huimv/dataprocess/DataProcessApplication.java

@@ -1,20 +0,0 @@
-package com.huimv.dataprocess;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.context.ApplicationContext;
-
-/**
- * @Project : huimv.shiwan
- * @Package : com.huimv.biosafety.uface.controller
- * @Description : TODO
- * @Version : 1.0
- * @Author : ZhuoNing
- * @Create : 2020-12-25
- **/
-@SpringBootApplication
-public class DataProcessApplication {
-    public static void main(String[] args) throws InterruptedException {
-        ApplicationContext applicationContext =   SpringApplication.run(DataProcessApplication.class, args);
-    }
-}

+ 0 - 164
huimv-eartag2-platform/data-process/src/main/java/com/huimv/dataprocess/dao/entity/EartagDataEntity.java

@@ -1,164 +0,0 @@
-package com.huimv.dataprocess.dao.entity;
-
-import javax.persistence.Entity;
-import javax.persistence.Column;
-import javax.persistence.GenerationType;
-import lombok.experimental.Accessors;
-import javax.persistence.Table;
-import javax.persistence.GeneratedValue;
-import java.sql.Timestamp;
-import lombok.Data;
-import java.io.Serializable;
-import javax.persistence.Id;
- 
-@Entity
-@Table(name = "eartag_data")
-@Data
-@Accessors(chain = true)
-public class EartagDataEntity implements Serializable {
-
-private static final long serialVersionUID = 1L;
-
-/**
- * 记录id(主键)
- */
-@Id
-@GeneratedValue(strategy = GenerationType.IDENTITY)@Column(name = "id", nullable = false)
-private Integer id;
-
-/**
- * 组织id
- */
-@Column(name = "org_id")
-private Long orgId;
-
-/**
- * 采集器编码
- */
-@Column(name = "device_code")
-private String deviceCode;
-
-/**
- * 耳标号
- */
-@Column(name = "eartag_no")
-private String eartagNo;
-
-/**
- * 采集时间
- */
-@Column(name = "time")
-private Timestamp time;
-
-/**
- * 耳根温度
- */
-@Column(name = "ear_temp")
-private Double earTemp;
-
-/**
- * 运动量
- */
-@Column(name = "exercise")
-private Integer exercise;
-
-/**
- * 栋舍
- */
-@Column(name = "pigpen")
-private String pigpen;
-
-/**
- * 单元ID
- */
-@Column(name = "unit_id")
-private Integer unitId;
-
-/**
- * 环境温度
- */
-@Column(name = "env_temp")
-private Double envTemp;
-
-/**
- * 电池电量
- */
-@Column(name = "bat")
-private Integer bat;
-
-/**
- * 信号强度
- */
-@Column(name = "rssi")
-private Integer rssi;
-
-/**
- * 命令头
- */
-@Column(name = "head")
-private String head;
-
-/**
- * 指令
- */
-@Column(name = "command")
-private String command;
-
-/**
- * 版本号
- */
-@Column(name = "version")
-private String version;
-
-/**
- * 耳标帧序号
- */
-@Column(name = "frame_serial_no")
-private Integer frameSerialNo;
-
-/**
- * 重启次数
- */
-@Column(name = "reboot_times")
-private Integer rebootTimes;
-
-/**
- * 预留字段
- */
-@Column(name = "prepare_field")
-private String prepareField;
-
-/**
- * 校验码
- */
-@Column(name = "chk")
-private String chk;
-
-/**
- * 命令尾
- */
-@Column(name = "tail")
-private String tail;
-
-/**
- * 牧场编码
- */
-@Column(name = "farm_code")
-private String farmCode;
-
-/**
- * 阶段
- */
-@Column(name = "stage")
-private Integer stage;
-
-@Column(name = "sport_gap")
-private Integer sportGap;
-
-/**
- * 耳标上传运动量
- */
-@Column(name = "old_exercise")
-private Integer oldExercise;
-
-}

+ 0 - 135
huimv-eartag2-platform/data-process/src/main/java/com/huimv/dataprocess/dao/entity/EartagEartagRegister2Entity.java

@@ -1,135 +0,0 @@
-package com.huimv.dataprocess.dao.entity;
-
-import lombok.Data;
-import lombok.experimental.Accessors;
-
-import javax.persistence.*;
-import java.io.Serializable;
-import java.sql.Date;
-import java.sql.Timestamp;
-
-@Entity
-@Data
-@Table(name = "eartag_eartag_register2")
-@Accessors(chain = true)
-public class EartagEartagRegister2Entity 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 String earmark;
-
-    @Column(name = "first_time")
-    private Timestamp firstTime;
-
-    @Column(name = "last_time")
-    private Timestamp lastTime;
-
-    @Column(name = "first_device")
-    private String firstDevice;
-
-    @Column(name = "belong_device")
-    private String belongDevice;
-
-    @Column(name = "last_device")
-    private String lastDevice;
-
-    @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 String farmId;
-
-    @Column(name = "active_status")
-    private Integer activeStatus;
-
-    @Column(name = "active_time")
-    private Timestamp activeTime;
-
-    @Column(name = "live_status")
-    private Integer liveStatus;
-
-    @Column(name = "create_date")
-    private Date createDate;
-
-    @Column(name = "bat")
-    private Integer bat;
-
-    @Column(name = "reboot_times")
-    private Integer rebootTimes;
-
-    @Column(name = "on_day_age")
-    private Integer onDayAge;
-
-    @Column(name = "day_age")
-    private Integer dayAge;
-
-    @Column(name = "stage_code")
-    private String stageCode;
-
-    @Column(name = "stage_name")
-    private String stageName;
-
-    @Column(name = "pigpen_id")
-    private Integer pigpenId;
-
-    @Column(name = "pigpen_name")
-    private String pigpenName;
-
-    @Column(name = "unit_id")
-    private Integer unitId;
-
-    @Column(name = "unit_name")
-    private String unitName;
-
-    @Column(name = "act_range")
-    private Integer actRange;
-
-    @Column(name = "ear_temp1")
-    private Float earTemp1;
-
-    @Column(name = "env_temp1")
-    private Float envTemp1;
-
-    @Column(name = "act")
-    private Long act;
-
-    @Column(name = "signal1")
-    private Integer signal1;
-
-    @Column(name = "other")
-    private String other;
-
-    @Column(name = "ask_time")
-    private String askTime;
-
-    @Column(name = "env_abnormal")
-    private Integer envAbnormal;
-
-    @Column(name = "ear_abnormal")
-    private Integer earAbnormal;
-
-    /**
-     * 可视码
-     */
-    @Column(name = "view_code")
-    private String viewCode;
-
-    /**
-     * RFID id号
-     */
-    @Column(name = "rfid_id")
-    private String rfidId;
-
-}

+ 0 - 9
huimv-eartag2-platform/data-process/src/main/java/com/huimv/dataprocess/dao/repo/EartagDataEntityRepository.java

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

+ 0 - 9
huimv-eartag2-platform/data-process/src/main/java/com/huimv/dataprocess/dao/repo/EartagEartagRegister2EntityRepository.java

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

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

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

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

@@ -1,31 +0,0 @@
-spring.profiles.active=goldpig
-
-#开启健康监控
-management.endpoints.web.exposure.include=*
-
-#########################################################
-###             配置undertow取代tomcat                ###
-#########################################################
-# 是否打开 undertow 日志,默认为 false
-server.undertow.accesslog.enabled=false
-# 设置访问日志所在目录
-server.undertow.accesslog.dir=logs
-# 指定工作者线程的 I/0 线程数,默认为 2 或者 CPU 的个数
-server.undertow.io-threads=
-# 指定工作者线程个数,默认为 I/O 线程个数的 8 倍
-server.undertow.worker-threads=
-# 设置 HTTP POST 内容的最大长度,默认不做限制
-server.undertow.max-http-post-size=0
-
-#########################################################
-###   Actuator Monitor  --   Actuator configuration   ###
-#########################################################
-management.security.enabled=false
-
-# 数据处理流程
-data.input.flow=2
-
-# 是否写入测试数据(1:写入 0:不写入)
-data.test.input=0
-
-

+ 0 - 62
huimv-eartag2-platform/data-process/src/test/java/com/huimv/dataprocess/data/DataProcessTest.java

@@ -1,62 +0,0 @@
-package com.huimv.dataprocess.data;
-
-import com.alibaba.fastjson.JSON;
-import com.huimv.dataprocess.dao.entity.EartagDataEntity;
-import com.huimv.dataprocess.dao.repo.EartagDataEntityRepository;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.text.ParseException;
-import java.util.List;
-
-/**
- * @Project : huimv.shiwan
- * @Package : com.huimv.biosafety.uface.controller
- * @Description : TODO
- * @Version : 1.0
- * @Author : ZhuoNing
- * @Create : 2020-12-25
- **/
-@SpringBootTest
-@RunWith(SpringRunner.class)
-public class DataProcessTest {
-    @Autowired
-    private EartagDataEntityRepository eartagDataEntityRepository;
-
-    @Test
-    public void exportData() throws IOException {
-        System.out.println("开始导出数据...");
-        List<EartagDataEntity> EartagDataEntityList = eartagDataEntityRepository.findAll();
-        System.out.println("EartagDataEntityList.size="+EartagDataEntityList.size());
-        for(EartagDataEntity eartagDataEntity:EartagDataEntityList){
-            System.out.println(""+eartagDataEntity.toString());
-            writeTxt(JSON.toJSONString(eartagDataEntity));
-        }
-        System.out.println("完成导出数据.");
-    }
-
-    @Test
-    public void importData(){
-        System.out.println("importData()");
-    }
-
-    public void writeTxt(String conent) throws IOException {
-        File f = new File("D:/6/goldpig.txt");
-        if (f.exists()) {
-        } else {
-            f.createNewFile();// 不存在则创建
-        }
-        BufferedWriter output = new BufferedWriter(new FileWriter(f, true));//true,则追加写入text文本
-        output.write(conent);
-        output.write("\r\n");//换行
-        output.flush();
-        output.close();
-    }
-}

+ 0 - 69
huimv-eartag2-platform/data-process2/pom.xml

@@ -1,69 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <parent>
-        <artifactId>huimv-eartag2-platform</artifactId>
-        <groupId>com.huimv</groupId>
-        <version>0.0.1-SNAPSHOT</version>
-    </parent>
-    <modelVersion>4.0.0</modelVersion>
-
-    <artifactId>data-process2</artifactId>
-
-    <properties>
-        <java.version>1.8</java.version>
-    </properties>
-    <dependencies>
-        <!-- eartag2-common -->
-        <dependency>
-            <groupId>com.huimv</groupId>
-            <artifactId>huimv-eartag2-common</artifactId>
-            <version>0.0.2-SNAPSHOT</version>
-        </dependency>
-        <!-- 排除Tomcat容器 -->
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-web</artifactId>
-            <!-- 移除掉默认支持的 Tomcat -->
-            <exclusions>
-                <exclusion>
-                    <groupId>org.springframework.boot</groupId>
-                    <artifactId>spring-boot-starter-tomcat</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-        <!-- 添加 Undertow 容器 -->
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-undertow</artifactId>
-        </dependency>
-        <!-- netty -->
-        <dependency>
-            <groupId>io.netty</groupId>
-            <artifactId>netty-all</artifactId>
-            <version>4.1.45.Final</version>
-        </dependency>
-        <!--rabbitmq-->
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-amqp</artifactId>
-        </dependency>
-    </dependencies>
-
-    <build>
-        <plugins>
-            <!--  -->
-            <plugin>
-                <groupId>org.springframework.boot</groupId>
-                <artifactId>spring-boot-maven-plugin</artifactId>
-            </plugin>
-            <!--  -->
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-resources-plugin</artifactId>
-                <version>2.6</version>
-            </plugin>
-        </plugins>
-    </build>
-</project>

+ 0 - 27
huimv-eartag2-platform/data-process2/src/main/java/com/huimv/dataprocess2/DataProcess2Application.java

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

+ 0 - 104
huimv-eartag2-platform/data-process2/src/main/resources/application-eartag.yml

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

+ 0 - 104
huimv-eartag2-platform/data-process2/src/main/resources/application-eartag2.yml

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

+ 0 - 31
huimv-eartag2-platform/data-process2/src/main/resources/application.properties

@@ -1,31 +0,0 @@
-spring.profiles.active=eartag
-
-#开启健康监控
-management.endpoints.web.exposure.include=*
-
-#########################################################
-###             配置undertow取代tomcat                ###
-#########################################################
-# 是否打开 undertow 日志,默认为 false
-server.undertow.accesslog.enabled=false
-# 设置访问日志所在目录
-server.undertow.accesslog.dir=logs
-# 指定工作者线程的 I/0 线程数,默认为 2 或者 CPU 的个数
-server.undertow.io-threads=
-# 指定工作者线程个数,默认为 I/O 线程个数的 8 倍
-server.undertow.worker-threads=
-# 设置 HTTP POST 内容的最大长度,默认不做限制
-server.undertow.max-http-post-size=0
-
-#########################################################
-###   Actuator Monitor  --   Actuator configuration   ###
-#########################################################
-management.security.enabled=false
-
-# 数据处理流程
-data.input.flow=2
-
-# 是否写入测试数据(1:写入 0:不写入)
-data.test.input=0
-
-

+ 0 - 408
huimv-eartag2-platform/data-process2/src/test/java/com/huimv/dataprocess2/DataProcess2Test.java

@@ -1,408 +0,0 @@
-package com.huimv.dataprocess2;
-
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.huimv.eartag2.common.dao.entity.*;
-import com.huimv.eartag2.common.dao.repo.*;
-import com.huimv.eartag2.common.service.IBaseConfigService;
-import com.huimv.eartag2.common.utils.DateUtil;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.data.domain.Example;
-import org.springframework.test.context.junit4.SpringRunner;
-
-import java.io.*;
-import java.sql.Array;
-import java.sql.Date;
-import java.sql.Timestamp;
-import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * @Project : huimv.shiwan
- * @Package : com.huimv.biosafety.uface.controller
- * @Description : TODO
- * @Version : 1.0
- * @Author : ZhuoNing
- * @Create : 2020-12-25
- **/
-@SpringBootTest
-@RunWith(SpringRunner.class)
-public class DataProcess2Test {
-    @Autowired
-    private EartagDataRepo2 eartagDataRepo2;
-    private static String eartagFile = "D:/6/goldpig.txt";
-    @Autowired
-    private IBaseConfigService iBaseConfigService;
-    @Autowired
-    private EartagHourActEntityRepo eartagHourActEntityRepo;
-    @Autowired
-    private EartagResetEntityRepo eartagResetEntityRepo;
-    @Autowired
-    private EartagResetCountEntityRepo eartagResetCountEntityRepo;
-    @Autowired
-    private EartagEartagRegister2EntityRepo eartagEartagRegister2EntityRepo;
-
-//    @Test
-//    public void exportData() throws IOException {
-//        System.out.println("开始导出数据...");
-//        List<EartagDataEntity2> EartagDataEntityList = eartagDataRepo2.findAll();
-//        System.out.println("EartagDataEntityList.size=" + EartagDataEntityList.size());
-//        for (EartagDataEntity2 eartagDataEntity : EartagDataEntityList) {
-//            System.out.println("" + eartagDataEntity.toString());
-//            writeTxt(JSON.toJSONString(eartagDataEntity));
-//        }
-//        System.out.println("完成导出数据.");
-//    }
-
-    // 导入耳标注册表
-    @Test
-    public void buildEartagRegisterData() throws IOException, ParseException {
-        List<EartagDataEntity2> EartagDataEntityList = eartagDataRepo2.findAllByGoldPig();
-        System.out.println("EartagDataEntityList.size="+EartagDataEntityList.size());
-        String farmCode = "330112004";
-        List<EartagEartagRegister2Entity> eartagRegisterList = eartagEartagRegister2EntityRepo.getEartagRegisterByFarmCode(farmCode);
-        System.out.println("eartagRegisterList.size="+eartagRegisterList.size());
-        List<EartagDataEntity2> newList = new ArrayList();
-        for(EartagDataEntity2 eartagDataEntity2:EartagDataEntityList) {
-//            System.out.println(a+" "+eartagDataEntity2.getEarmark()+","+eartagDataEntity2.getAddTime());
-            if (eartagDataEntity2.getEarmark().length() == 15 && (eartagDataEntity2.getEarmark().indexOf("1332022109003") != -1 || eartagDataEntity2.getEarmark().indexOf("1332022109004") != -1) && !judgeContainsStr(eartagDataEntity2.getEarmark())) {
-//                String earmark = eartagDataEntity2.getEarmark();
-                boolean isExist = false;
-                for(EartagDataEntity2 lastEartagDataEntity2:newList){
-                    if(eartagDataEntity2.getEarmark().trim().equalsIgnoreCase(lastEartagDataEntity2.getEarmark())){
-                        newList.remove(lastEartagDataEntity2);
-                        isExist = true;
-                        break;
-                    }
-                }
-                if(!isExist){
-                    newList.add(eartagDataEntity2);
-                }
-            }
-        }
-        System.out.println("newList.size="+newList.size());
-        List<EartagDataEntity2> newList2 = new ArrayList();
-        for(EartagDataEntity2 eartagDataEntity2:newList){
-            boolean isExist = false;
-            for(EartagEartagRegister2Entity eartagEartagRegister2Entity:eartagRegisterList){
-                if(eartagEartagRegister2Entity.getEarmark().trim().equalsIgnoreCase(eartagDataEntity2.getEarmark())){
-                    isExist = true;
-                    break;
-                }
-            }
-            if(!isExist){
-                newList2.add(eartagDataEntity2);
-            }
-        }
-        System.out.println("newList2.size="+newList2.size());
-        // 迁移之后未上传数据的耳标(未注册的耳标)
-        List<EartagEartagRegister2Entity> unregisterEartagList = new ArrayList();
-        for(EartagDataEntity2 uneartagDataEntity2:newList2){
-            System.out.println(""+uneartagDataEntity2.toString());
-            EartagEartagRegister2Entity newEartagEartagRegister2Entity = new EartagEartagRegister2Entity();
-            unregisterEartagList.add(newEartagEartagRegister2Entity);
-//            System.out.println("newEartagEartagRegister2Entity.getEarmark="+newEartagEartagRegister2Entity.getEarmark());
-//            if(newEartagEartagRegister2Entity.getEarmark() == null){
-//                System.out.println("==null");
-//            }else{
-//                System.out.println("!=null");
-//            }
-            for(EartagDataEntity2 eartagDataEntity2:EartagDataEntityList) {
-                if(uneartagDataEntity2.getEarmark().trim().equalsIgnoreCase(eartagDataEntity2.getEarmark())){
-                    if(newEartagEartagRegister2Entity.getEarmark() == null){
-                        newEartagEartagRegister2Entity.setEarmark(uneartagDataEntity2.getEarmark());
-                        newEartagEartagRegister2Entity.setFirstTime(eartagDataEntity2.getAddTime());
-                        newEartagEartagRegister2Entity.setFirstDevice(eartagDataEntity2.getDevice());
-                        newEartagEartagRegister2Entity.setRegisterTime(eartagDataEntity2.getAddTime());
-                        newEartagEartagRegister2Entity.setFarmId(farmCode);
-                        newEartagEartagRegister2Entity.setActiveStatus(1);
-                        newEartagEartagRegister2Entity.setActiveTime(eartagDataEntity2.getAddTime());
-                        newEartagEartagRegister2Entity.setLiveStatus(1);
-                        newEartagEartagRegister2Entity.setCreateDate(eartagDataEntity2.getCreateDate());
-                        newEartagEartagRegister2Entity.setBat(eartagDataEntity2.getBat());
-                        newEartagEartagRegister2Entity.setEarTemp1(eartagDataEntity2.getEarTemp1());
-                        newEartagEartagRegister2Entity.setEnvTemp1(eartagDataEntity2.getEnvTemp1());
-                        newEartagEartagRegister2Entity.setAct(new Long(eartagDataEntity2.getAct()));
-                        newEartagEartagRegister2Entity.setSignal1(eartagDataEntity2.getSignal1());
-                        newEartagEartagRegister2Entity.setOther(eartagDataEntity2.getOther());
-                        newEartagEartagRegister2Entity.setAskTime(eartagDataEntity2.getAskTime());
-                        newEartagEartagRegister2Entity.setPigpenId(51);
-                        newEartagEartagRegister2Entity.setPigpenName("测试一栋");
-                        newEartagEartagRegister2Entity.setUnitId(52);
-                        newEartagEartagRegister2Entity.setUnitName("测试一单元");
-                        newEartagEartagRegister2Entity.setStageCode("4");
-                        newEartagEartagRegister2Entity.setStageName("育成育肥");
-                    }else{
-                        newEartagEartagRegister2Entity.setLastTime(eartagDataEntity2.getAddTime());
-                        newEartagEartagRegister2Entity.setBelongDevice(eartagDataEntity2.getDevice());
-                        newEartagEartagRegister2Entity.setLastDevice(eartagDataEntity2.getDevice());
-                        newEartagEartagRegister2Entity.setActiveStatus(1);
-                        newEartagEartagRegister2Entity.setActiveTime(eartagDataEntity2.getAddTime());
-                        newEartagEartagRegister2Entity.setLiveStatus(1);
-                        newEartagEartagRegister2Entity.setBat(eartagDataEntity2.getBat());
-                        newEartagEartagRegister2Entity.setEarTemp1(eartagDataEntity2.getEarTemp1());
-                        newEartagEartagRegister2Entity.setEnvTemp1(eartagDataEntity2.getEnvTemp1());
-                        newEartagEartagRegister2Entity.setAct(new Long(eartagDataEntity2.getAct()));
-                        newEartagEartagRegister2Entity.setSignal1(eartagDataEntity2.getSignal1());
-                        newEartagEartagRegister2Entity.setOther(eartagDataEntity2.getOther());
-                        newEartagEartagRegister2Entity.setAskTime(eartagDataEntity2.getAskTime());
-                    }
-                }
-            }
-        }
-        int b=0;
-        for(EartagEartagRegister2Entity eartagEartagRegister2Entity:unregisterEartagList){
-            System.out.println((++b)+","+eartagEartagRegister2Entity.toString());
-            eartagEartagRegister2EntityRepo.saveAndFlush(eartagEartagRegister2Entity);
-        }
-    }
-
-    @Test
-    public void testList(){
-
-//        List<String> newList = new ArrayList();
-//        newList.add("1");
-//        newList.add("2");
-//        newList.add("3");
-//        newList.add("4");
-//
-//        for(int a=0;a<newList.size();a++){
-//            if(newList.get(a).trim().equalsIgnoreCase("3")){
-//                newList.remove(a);
-//                newList.add("5");
-//            }
-//        }
-
-//            System.out.println("newList.toString()="+newList.toString());
-
-        System.out.println("133202210900369a="+judgeContainsStr("133202210900369a"));
-    }
-
-    // 生成小时运动量数据
-    @Test
-    public void buildHourActData() throws IOException, ParseException {
-        DateUtil du = new DateUtil();
-//        int nowHour = du.getNowHour();
-        String farmId = "330112004";
-        // 小时
-        int eartagOfflineTime = 24;
-//        Optional<SysBaseConfigEntity> optionalConfig = sysBaseConfigEntityRepo.getConfigValue("dropDataEartagOffLineTime");
-//        if (optionalConfig.isPresent()) {
-//            eartagOfflineTime = Integer.parseInt(optionalConfig.get().getConfigValue());
-//            log.info("耳标离线过程丢弃数据时长=" + eartagOfflineTime);
-//        } else {
-//            log.error("耳标离线过程丢弃数据时长属性未配置.");
-//        }
-        Map configMap = iBaseConfigService.getConfigValue("dropDataEartagOffLineTime",farmId,"0");
-        System.out.println("configMap >>>>>>>>>>>>>>>>>>>>> "+configMap.toString());
-        if(configMap == null){
-            System.out.println("耳标离线过程丢弃数据时长属性未配置.采用默认配置参数 eartagOfflineTime="+eartagOfflineTime);
-        }else{
-            eartagOfflineTime = Integer.parseInt(configMap.get("configValue")+"");
-            System.out.println("eartagOfflineTime >>>>>>>>>>>> "+eartagOfflineTime);
-        }
-
-        List<EartagDataEntity2> EartagDataEntityList = eartagDataRepo2.findAllByGoldPig();
-        System.out.println("EartagDataEntityList.size="+EartagDataEntityList.size());
-        int a=0;
-//        String todayDateText = new DateUtil().getTodayDateText();
-//        java.sql.Date todayDate = new java.sql.Date(new java.util.Date().getTime());
-//        Timestamp nowTimestamp = new Timestamp(new java.util.Date().getTime());
-        List<EartagDataEntity2> newList = new ArrayList();
-        for(EartagDataEntity2 eartagDataEntity2:EartagDataEntityList){
-//            System.out.println(a+" "+eartagDataEntity2.getEarmark()+","+eartagDataEntity2.getAddTime());
-            if(eartagDataEntity2.getEarmark().length() == 15 && (eartagDataEntity2.getEarmark().indexOf("1332022109003") != -1 || eartagDataEntity2.getEarmark().indexOf("1332022109004") != -1) && !judgeContainsStr(eartagDataEntity2.getEarmark())){
-                String earmark = eartagDataEntity2.getEarmark();
-                Integer act = eartagDataEntity2.getAct();
-                System.out.println("earmark=" + earmark);
-                System.out.println("本次运动量=" + act);
-                System.out.println("farmId=" + farmId);
-                Timestamp nowTimestamp = eartagDataEntity2.getAddTime();
-                Date date = eartagDataEntity2.getCreateDate();
-                int nowHour = du.setCalendarNewTime(eartagDataEntity2.getAddTime());
-                System.out.println("nowHour=" + nowHour);
-
-                //生成运动量
-                for(EartagDataEntity2 lastEartagDataEntity2:newList){
-                    if(eartagDataEntity2.getEarmark().trim().equalsIgnoreCase(lastEartagDataEntity2.getEarmark())){
-                        Integer lastAct = lastEartagDataEntity2.getAct();
-                        System.out.println("上次运动量=" + lastAct);
-                        Timestamp lastAddTime = lastEartagDataEntity2.getAddTime();
-                        long timeDiff = nowTimestamp.getTime() - lastAddTime.getTime();
-                        if (timeDiff / (1000 * 60 * 60) < eartagOfflineTime) {
-                            long act1 = 0;
-                            boolean resetStatus = false;
-                            if (act < lastAct) {
-                                act1 = act;
-                                resetStatus = true;
-                            } else {
-                                act1 = act - lastAct;
-                            }
-                            System.out.println("本次运动量增量=" + act1);
-                            //{保存耳标小时运动量}
-                            saveEartagHourAct(farmId, earmark, act1, nowHour, date);
-                            //{保存耳标复位记录}
-                            saveEartagReset(resetStatus, farmId, earmark, nowTimestamp, date, null, lastAct, act);
-                        }
-
-                        //删除上一次数据
-                        newList.remove(lastEartagDataEntity2);
-                        break;
-                    }
-                }
-                newList.add(eartagDataEntity2);
-
-//            if(a==100){
-//                break;
-//            }
-                a++;
-            }
-        }
-
-        System.out.println("newList.size="+newList.size());
-        for(EartagDataEntity2 newEartagDataEntity2:newList){
-            System.out.println(""+newEartagDataEntity2.toString());
-        }
-    }
-
-    //{保存耳标复位记录}
-    private void saveEartagReset(boolean resetStatus, String farmId, String earmark, Timestamp nowTimestamp, java.sql.Date todayDate, Integer lastId, int lastAct, int act) {
-        if (resetStatus) {
-            // 保存复位记录
-            EartagResetEntity eartagResetEntity = new EartagResetEntity();
-            eartagResetEntity.setEarmark(earmark);
-            eartagResetEntity.setAddDate(todayDate);
-            eartagResetEntity.setResetTime(nowTimestamp);
-            eartagResetEntity.setFarmCode(farmId);
-            eartagResetEntity.setLastId(lastId);
-            eartagResetEntity.setLastAct(new Long(lastAct));
-            eartagResetEntity.setAct(new Long(act));
-            System.out.println("saveEartagReset:1 "+eartagResetEntity.toString());
-            eartagResetEntityRepo.save(eartagResetEntity);
-
-            // 复位统计次数
-            EartagResetCountEntity eartagResetCountEntity = new EartagResetCountEntity();
-            eartagResetCountEntity.setEarmark(earmark);
-            eartagResetCountEntity.setFarmCode(farmId);
-            eartagResetCountEntity.setAddDate(todayDate);
-            Example<EartagResetCountEntity> example = Example.of(eartagResetCountEntity);
-            Optional<EartagResetCountEntity> optionEartagResetCountEntity = eartagResetCountEntityRepo.findOne(example);
-            if (!optionEartagResetCountEntity.isPresent()) {
-                eartagResetCountEntity.setTimes(1);
-                System.out.println("saveEartagReset:2 "+eartagResetCountEntity.toString());
-                eartagResetCountEntityRepo.save(eartagResetCountEntity);
-            } else {
-                EartagResetCountEntity existEartagResetCountEntity = optionEartagResetCountEntity.get();
-                existEartagResetCountEntity.setTimes(existEartagResetCountEntity.getTimes() + 1);
-                System.out.println("saveEartagReset:3 "+existEartagResetCountEntity.toString());
-                eartagResetCountEntityRepo.save(existEartagResetCountEntity);
-            }
-        }
-    }
-
-    // {保存耳标小时运动量}
-    private void saveEartagHourAct(String farmId, String earmark, long act1, int nowHour, java.sql.Date todayDate) {
-        Optional<EartagHourActEntity> optionalHourAct = eartagHourActEntityRepo.findByFarmIdAndEarmarkAndHourAndDate(farmId, earmark, nowHour, todayDate);
-        if (!optionalHourAct.isPresent()) {
-            EartagHourActEntity newEartagHourActEntity = new EartagHourActEntity();
-            newEartagHourActEntity.setFarmCode(farmId);
-            newEartagHourActEntity.setEarmark(earmark);
-            newEartagHourActEntity.setAddDate(todayDate);
-            newEartagHourActEntity.setHour(nowHour);
-            newEartagHourActEntity.setAct(act1);
-            System.out.println("saveEartagHourAct:1 "+newEartagHourActEntity.toString());
-            eartagHourActEntityRepo.save(newEartagHourActEntity);
-        } else {
-            EartagHourActEntity eartagHourActEntity = optionalHourAct.get();
-            eartagHourActEntity.setAct(eartagHourActEntity.getAct() + act1);
-            System.out.println("saveEartagHourAct:2 "+eartagHourActEntity.toString());
-            eartagHourActEntityRepo.save(eartagHourActEntity);
-        }
-    }
-
-    public boolean judgeContainsStr(String str) {
-        String regex=".*[a-zA-Z]+.*";
-        Matcher m= Pattern.compile(regex).matcher(str);
-        return m.matches();
-    }
-
-    @Test
-    public void importData() throws IOException, ParseException {
-        System.out.println("开始导入数据>>");
-        JSONArray eartagJa = readLineTxt();
-        System.out.println("eartagJa.size=" + eartagJa.size());
-        for(int a=0;a<eartagJa.size();a++){
-            JSONObject dataJo =eartagJa.getJSONObject(a);
-//            System.out.println("time="+dataJo.getString("time"));
-            DateUtil du = new DateUtil();
-            String datetime = du.formatLongToDate(dataJo.getLong("time"));
-//            System.out.println("datetime="+datetime);
-            String date = du.formatDateText(datetime);
-//            System.out.println("date="+date);
-//            du.parseDate(date);
-//            System.out.println("time2 = "+new Date(dataJo.getLong("time")));
-//            if(a == 5){
-//                break;
-//            }
-            System.out.println(""+dataJo.toString());
-            EartagDataEntity2 eartagDataEntity2 = new EartagDataEntity2();
-            eartagDataEntity2.setAct(dataJo.getInteger("oldExercise"));
-            eartagDataEntity2.setAct1(dataJo.getInteger("exercise"));
-            eartagDataEntity2.setAddTime(new Timestamp(du.parseDateTime(datetime).getTime()));
-            eartagDataEntity2.setCreateDate(new Date(dataJo.getLong("time")));
-            eartagDataEntity2.setAskTime(datetime);
-            eartagDataEntity2.setAskDate(new Date(dataJo.getLong("time")));
-            eartagDataEntity2.setBat(dataJo.getInteger("bat"));
-            eartagDataEntity2.setCmdHeader(dataJo.getString("head"));
-
-            eartagDataEntity2.setDevice(dataJo.getString("deviceCode"));
-            eartagDataEntity2.setEarmark(dataJo.getString("eartagNo"));
-            eartagDataEntity2.setEarTemp(1);
-            eartagDataEntity2.setEarTemp1(dataJo.getFloat("earTemp"));
-//            eartagDataEntity2.setEnvTemp();
-            eartagDataEntity2.setEnvTemp1(dataJo.getFloat("envTemp"));
-            eartagDataEntity2.setFarmId("330112004");
-            eartagDataEntity2.setOther(dataJo.getString("prepareField"));
-            eartagDataEntity2.setSignal1(dataJo.getInteger("rssi"));
-//            eartagDataRepo2.saveAndFlush(eartagDataEntity2);
-        }
-        System.out.println("完成导出数据<<");
-    }
-
-    public JSONArray readLineTxt() throws IOException {
-        String s = "";
-        InputStreamReader in = new InputStreamReader(new FileInputStream(new File(eartagFile)), "UTF-8");
-        BufferedReader br = new BufferedReader(in);
-        StringBuffer content = new StringBuffer();
-        JSONArray eartaJa = new JSONArray();
-        while ((s = br.readLine()) != null) {
-//            content = content.append(s);
-//            System.out.println("content=" + s);
-            JSONObject dataJo = JSON.parseObject(s);
-            eartaJa.add(dataJo);
-        }
-        return eartaJa;
-    }
-
-    public void writeTxt(String conent) throws IOException {
-        File f = new File(eartagFile);
-        if (f.exists()) {
-        } else {
-            f.createNewFile();// 不存在则创建
-        }
-        BufferedWriter output = new BufferedWriter(new FileWriter(f, true));//true,则追加写入text文本
-        output.write(conent);
-        output.write("\r\n");//换行
-        output.flush();
-        output.close();
-    }
-}

+ 37 - 37
huimv-eartag2-platform/huimv-eartag2-api/src/main/java/com/huimv/eartag2/api/HuimvApiApplication.java

@@ -1,37 +1,37 @@
-package com.huimv.eartag2.api;
-
-import com.huimv.eartag2.api.netty.EartagServer;
-import org.mybatis.spring.annotation.MapperScan;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.autoconfigure.domain.EntityScan;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.annotation.Bean;
-import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
-import org.springframework.scheduling.annotation.EnableScheduling;
-import org.springframework.web.client.RestTemplate;
-
-/**
- * @Project : huimv.shiwan
- * @Package : com.huimv.biosafety.uface.controller
- * @Description : TODO
- * @Version : 1.0
- * @Author : ZhuoNing
- * @Create : 2020-12-25
- **/
-@SpringBootApplication
-@EnableScheduling
-@MapperScan("com.huimv.eartag2.api.mapper")
-@EntityScan(value = "com.huimv.eartag2.common.dao.entity")
-@EnableJpaRepositories(basePackages = "com.huimv.eartag2.common.dao.repo")
-//@Import(InterceptorConfig.class)
-public class HuimvApiApplication {
-    public static void main(String[] args) throws InterruptedException {
-        ApplicationContext applicationContext =SpringApplication.run(HuimvApiApplication.class, args);
-        applicationContext.getBean(EartagServer.class).run();
-    }
-    @Bean
-    public static RestTemplate getRestTemplate(){
-        return new RestTemplate();
-    }
-}
+//package com.huimv.eartag2.api;
+//
+////import com.huimv.eartag2.api.netty.EartagServer;
+//import org.mybatis.spring.annotation.MapperScan;
+//import org.springframework.boot.SpringApplication;
+//import org.springframework.boot.autoconfigure.SpringBootApplication;
+//import org.springframework.boot.autoconfigure.domain.EntityScan;
+//import org.springframework.context.ApplicationContext;
+//import org.springframework.context.annotation.Bean;
+//import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
+//import org.springframework.scheduling.annotation.EnableScheduling;
+//import org.springframework.web.client.RestTemplate;
+//
+///**
+// * @Project : huimv.shiwan
+// * @Package : com.huimv.biosafety.uface.controller
+// * @Description : TODO
+// * @Version : 1.0
+// * @Author : ZhuoNing
+// * @Create : 2020-12-25
+// **/
+//@SpringBootApplication
+//@EnableScheduling
+//@MapperScan("com.huimv.eartag2.api.mapper")
+//@EntityScan(value = "com.huimv.eartag2.common.dao.entity")
+//@EnableJpaRepositories(basePackages = "com.huimv.eartag2.common.dao.repo")
+////@Import(InterceptorConfig.class)
+//public class HuimvApiApplication {
+//    public static void main(String[] args) throws InterruptedException {
+//        ApplicationContext applicationContext =SpringApplication.run(HuimvApiApplication.class, args);
+//        applicationContext.getBean(EartagServer.class).run();
+//    }
+//    @Bean
+//    public static RestTemplate getRestTemplate(){
+//        return new RestTemplate();
+//    }
+//}

+ 134 - 134
huimv-eartag2-platform/huimv-eartag2-api/src/main/java/com/huimv/eartag2/api/controller/EartagAbnormalAlarmController.java

@@ -1,134 +1,134 @@
-package com.huimv.eartag2.api.controller;
-
-
-import com.huimv.eartag2.api.service.*;
-import com.huimv.eartag2.common.utils.Result;
-import com.huimv.eartag2.common.utils.ResultCode;
-import com.huimv.eartag2.api.pojo.BaseMap;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.servlet.http.HttpServletRequest;
-import java.text.ParseException;
-import java.util.Map;
-
-/**
- * <p>
- *  前端控制器
- * </p>
- *
- * @author zn
- * @since 2022-08-30
- */
-@RestController
-@RequestMapping("/pig")
-public class EartagAbnormalAlarmController {
-    @Autowired
-    private EartagAbnormalAlarmService eartagAbnormalAlarmService;
-    @Autowired
-    private FarmerAssetService farmerAssetService;
-    @Autowired
-    private IEartagEartagRegister2Service eartagRegisterService;
-    @Autowired
-    private IBaseMapService baseMapService;
-
-    //美维首页健康监测
-    @PostMapping("/getHealthy")
-    public Result getHealthy(@RequestBody Map<String, String> paramsMap) throws ParseException {
-        return eartagAbnormalAlarmService.getHealthy(paramsMap);
-    }
-
-    //美维首页群体健康
-    @PostMapping("/allHealthy")
-    public Result healthy(@RequestBody Map<String, String> paramsMap) throws ParseException {
-        return eartagAbnormalAlarmService.allHealthy(paramsMap);
-    }
-    //美维首页羊只健康
-    @PostMapping("/getSheepHealthy")
-    public Result getSheepHealthy(@RequestBody Map<String, String> paramsMap) throws ParseException {
-        return eartagAbnormalAlarmService.getSheepHealthy(paramsMap);
-    }
-    //获取报警接口
-    @PostMapping("/getWarning")
-    public Result getWarning(@RequestBody Map<String, String> paramsMap) throws ParseException {
-        return eartagAbnormalAlarmService.getWarning(paramsMap);
-    }
-
-    //下面是之前接口,暂时不动
-    @PostMapping("/getEarTemWarning")
-    public Result getEarTemWarning(@RequestBody Map<String, Object> paramsMap) throws ParseException {
-        return eartagAbnormalAlarmService.getEarTemWarning(paramsMap);
-    }
-    @PostMapping("/listFarmer")
-    public Result listFarmer() throws ParseException {
-        return eartagAbnormalAlarmService.listFarmer();
-    }
-    @PostMapping("/getNewPig")
-    public Result getNewPig(@RequestBody Map<String, String> paramsMap) throws ParseException {
-        return eartagAbnormalAlarmService.getNewPig(paramsMap);
-    }
-
-    @PostMapping("/getAssetStatistics")
-    public Result getAssetStatistics(@RequestBody Map<String, Object> paramsMap) throws ParseException {
-        return farmerAssetService.getAssetStatistics(paramsMap);
-    }
-
-    @PostMapping("/countAll")
-    public Result countAll(@RequestBody Map<String, Object> paramsMap)   {
-        return eartagAbnormalAlarmService.countAll(paramsMap);
-    }
-
-    @PostMapping("/pigMonitor")
-    public Result pigMonitor(@RequestBody Map<String, Object> paramsMap)  {
-        return eartagAbnormalAlarmService.pigMonitor(paramsMap);
-    }
-
-    @PostMapping("/getFarmerAndPig")
-    public Result getFarmerAndPig(@RequestBody Map<String, Object> paramsMap)  {
-        return eartagAbnormalAlarmService.getFarmerAndPig(paramsMap);
-    }
-
-    @Autowired
-    private IEartagData2Service eartagDataService;
-    @PostMapping("/getEnvByTime")
-    public Result getEnvByTime(@RequestBody Map<String,String> map, HttpServletRequest request){
-        return eartagDataService.getEnvByTimePanan(map);
-    }
-
-    @PostMapping("/getEnvLast")
-    public Result getEnvLast(@RequestBody Map<String,String> map){
-        return eartagDataService.getEnvLast(map);
-    }
-
-    @RequestMapping("/listFarmUnitEartagData")
-    public Result listFarmUnitEartagData(@RequestBody Map<String, String> params, HttpServletRequest req){
-//        Integer userId = TokenSign.getMemberIdByJwtToken(req);
-//        params.put("userId",userId+"");
-        return eartagRegisterService.listFarmUnitEartagDataQingshan(params);
-    }
-    @PostMapping("/mapAdd")
-    public Result mapAdd(@RequestBody BaseMap baseMap){
-        baseMapService.save(baseMap);
-        return new Result(10000,"添加成功",true);
-    }
-    @PostMapping("/mapUpdate")
-    public Result mmapUpdateapAdd(@RequestBody BaseMap baseMap){
-        baseMapService.updateById(baseMap);
-        return new Result(10000,"删除成功",true);
-    }
-    @PostMapping("/mapDelete")
-    public Result mapDelete(@RequestBody BaseMap baseMap){
-        baseMapService.removeById(baseMap);
-        return new Result(10000,"删除成功",true);
-    }
-    @PostMapping("/mapList")
-    public Result mapList(@RequestBody Map<String,Integer> map){
-        return new Result(ResultCode.SUCCESS, baseMapService.list());
-    }
-
-}
-
+//package com.huimv.eartag2.api.controller;
+//
+//
+//import com.huimv.eartag2.api.service.*;
+//import com.huimv.eartag2.common.utils.Result;
+//import com.huimv.eartag2.common.utils.ResultCode;
+//import com.huimv.eartag2.api.pojo.BaseMap;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.web.bind.annotation.PostMapping;
+//import org.springframework.web.bind.annotation.RequestBody;
+//import org.springframework.web.bind.annotation.RequestMapping;
+//
+//import org.springframework.web.bind.annotation.RestController;
+//
+//import javax.servlet.http.HttpServletRequest;
+//import java.text.ParseException;
+//import java.util.Map;
+//
+///**
+// * <p>
+// *  前端控制器
+// * </p>
+// *
+// * @author zn
+// * @since 2022-08-30
+// */
+//@RestController
+//@RequestMapping("/pig")
+//public class EartagAbnormalAlarmController {
+//    @Autowired
+//    private EartagAbnormalAlarmService eartagAbnormalAlarmService;
+//    @Autowired
+//    private FarmerAssetService farmerAssetService;
+//    @Autowired
+//    private IEartagEartagRegister2Service eartagRegisterService;
+//    @Autowired
+//    private IBaseMapService baseMapService;
+//
+//    //美维首页健康监测
+//    @PostMapping("/getHealthy")
+//    public Result getHealthy(@RequestBody Map<String, String> paramsMap) throws ParseException {
+//        return eartagAbnormalAlarmService.getHealthy(paramsMap);
+//    }
+//
+//    //美维首页群体健康
+//    @PostMapping("/allHealthy")
+//    public Result healthy(@RequestBody Map<String, String> paramsMap) throws ParseException {
+//        return eartagAbnormalAlarmService.allHealthy(paramsMap);
+//    }
+//    //美维首页羊只健康
+//    @PostMapping("/getSheepHealthy")
+//    public Result getSheepHealthy(@RequestBody Map<String, String> paramsMap) throws ParseException {
+//        return eartagAbnormalAlarmService.getSheepHealthy(paramsMap);
+//    }
+//    //获取报警接口
+//    @PostMapping("/getWarning")
+//    public Result getWarning(@RequestBody Map<String, String> paramsMap) throws ParseException {
+//        return eartagAbnormalAlarmService.getWarning(paramsMap);
+//    }
+//
+//    //下面是之前接口,暂时不动
+//    @PostMapping("/getEarTemWarning")
+//    public Result getEarTemWarning(@RequestBody Map<String, Object> paramsMap) throws ParseException {
+//        return eartagAbnormalAlarmService.getEarTemWarning(paramsMap);
+//    }
+//    @PostMapping("/listFarmer")
+//    public Result listFarmer() throws ParseException {
+//        return eartagAbnormalAlarmService.listFarmer();
+//    }
+//    @PostMapping("/getNewPig")
+//    public Result getNewPig(@RequestBody Map<String, String> paramsMap) throws ParseException {
+//        return eartagAbnormalAlarmService.getNewPig(paramsMap);
+//    }
+//
+//    @PostMapping("/getAssetStatistics")
+//    public Result getAssetStatistics(@RequestBody Map<String, Object> paramsMap) throws ParseException {
+//        return farmerAssetService.getAssetStatistics(paramsMap);
+//    }
+//
+//    @PostMapping("/countAll")
+//    public Result countAll(@RequestBody Map<String, Object> paramsMap)   {
+//        return eartagAbnormalAlarmService.countAll(paramsMap);
+//    }
+//
+//    @PostMapping("/pigMonitor")
+//    public Result pigMonitor(@RequestBody Map<String, Object> paramsMap)  {
+//        return eartagAbnormalAlarmService.pigMonitor(paramsMap);
+//    }
+//
+//    @PostMapping("/getFarmerAndPig")
+//    public Result getFarmerAndPig(@RequestBody Map<String, Object> paramsMap)  {
+//        return eartagAbnormalAlarmService.getFarmerAndPig(paramsMap);
+//    }
+//
+//    @Autowired
+//    private IEartagData2Service eartagDataService;
+//    @PostMapping("/getEnvByTime")
+//    public Result getEnvByTime(@RequestBody Map<String,String> map, HttpServletRequest request){
+//        return eartagDataService.getEnvByTimePanan(map);
+//    }
+//
+//    @PostMapping("/getEnvLast")
+//    public Result getEnvLast(@RequestBody Map<String,String> map){
+//        return eartagDataService.getEnvLast(map);
+//    }
+//
+//    @RequestMapping("/listFarmUnitEartagData")
+//    public Result listFarmUnitEartagData(@RequestBody Map<String, String> params, HttpServletRequest req){
+////        Integer userId = TokenSign.getMemberIdByJwtToken(req);
+////        params.put("userId",userId+"");
+//        return eartagRegisterService.listFarmUnitEartagDataQingshan(params);
+//    }
+//    @PostMapping("/mapAdd")
+//    public Result mapAdd(@RequestBody BaseMap baseMap){
+//        baseMapService.save(baseMap);
+//        return new Result(10000,"添加成功",true);
+//    }
+//    @PostMapping("/mapUpdate")
+//    public Result mmapUpdateapAdd(@RequestBody BaseMap baseMap){
+//        baseMapService.updateById(baseMap);
+//        return new Result(10000,"删除成功",true);
+//    }
+//    @PostMapping("/mapDelete")
+//    public Result mapDelete(@RequestBody BaseMap baseMap){
+//        baseMapService.removeById(baseMap);
+//        return new Result(10000,"删除成功",true);
+//    }
+//    @PostMapping("/mapList")
+//    public Result mapList(@RequestBody Map<String,Integer> map){
+//        return new Result(ResultCode.SUCCESS, baseMapService.list());
+//    }
+//
+//}
+//

+ 111 - 111
huimv-eartag2-platform/huimv-eartag2-api/src/main/java/com/huimv/eartag2/api/netty/EartagServer.java

@@ -1,111 +1,111 @@
-package com.huimv.eartag2.api.netty;
-
-import io.netty.bootstrap.ServerBootstrap;
-import io.netty.buffer.ByteBuf;
-import io.netty.channel.*;
-import io.netty.channel.nio.NioEventLoopGroup;
-import io.netty.channel.socket.SocketChannel;
-import io.netty.channel.socket.nio.NioServerSocketChannel;
-import io.netty.handler.logging.LogLevel;
-import io.netty.handler.logging.LoggingHandler;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * @Project : huimv.shiwan
- * @Package : com.huimv.biosafety.uface.controller
- * @Description : TODO
- * @Version : 1.0
- * @Author : ZhuoNing
- * @Create : 2020-12-25
- **/
-@Component
-public class EartagServer {
-    @Autowired
-    private EartagServerHandler2 serverHandler;
-    //监听端口
-    private int port = 10023;
-//    private int port2 = 10024;
-    //创建构造方法
-    public EartagServer(){
-    }
-
-    public static void main(String[] args) throws InterruptedException {
-        new EartagServer().run();
-    }
-/**
- *
- * 功能描述: 启动方法前台多个服务  处理多个线程
- *
- * @param:
- * @return:
- * @auther: LiGang
- * @date: 2019/3/26 11:31
- */
-    /**
-     * 启动流程
-     */
-    public void run() throws InterruptedException {
-        //配置服务端线程组
-        EventLoopGroup bossGroup=new NioEventLoopGroup();
-        EventLoopGroup workGroup=new NioEventLoopGroup();
-
-        try{
-            //引导整个server的启动
-            ServerBootstrap serverBootstrap = new ServerBootstrap();
-
-           serverBootstrap.group(bossGroup, workGroup)
-                    .channel(NioServerSocketChannel.class)    //指定处理的连接类型
-                    .option(ChannelOption.SO_REUSEADDR, true)
-                    .childHandler(new ChannelInitializer<SocketChannel>() {
-                        @Override
-                        protected void initChannel(SocketChannel socketChannel) throws Exception {
-                            socketChannel.pipeline().addLast(serverHandler);
-                        }
-                    });
-            System.out.println("# 耳标及采集器设备数据接收服务器已经启动。#");
-            System.out.println("# 准备接收数据:");
-            //绑定端口,同步等待成功
-            ChannelFuture cf = serverBootstrap.bind(port).sync();
-//            ChannelFuture cf2 = serverBootstrap.bind(port2).sync();
-            // 等待服务端监听端口关闭
-            cf.channel().closeFuture().sync();
-//            cf2.channel().closeFuture().sync();
-        }finally {
-            //优雅的退出
-            bossGroup.shutdownGracefully();
-            workGroup.shutdownGracefully();
-        }
-    }
-
-    public void run2() throws InterruptedException {
-        ServerBootstrap b = new ServerBootstrap();
-        EventLoopGroup bossGroup = new NioEventLoopGroup();
-        EventLoopGroup workerGroup = new NioEventLoopGroup();
-
-        b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class)
-                .option(ChannelOption.SO_REUSEADDR, true)
-                .childHandler(new ChannelInitializer() {
-                    @Override
-                    protected void initChannel(Channel ch) throws Exception {
-                        ch.pipeline()
-                                .addLast("logging", new LoggingHandler(LogLevel.INFO))
-                                .addLast(new SimpleChannelInboundHandler() {
-                                    @Override
-                                    protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
-                                        ByteBuf data = (ByteBuf) msg;
-                                        String clientAskText = data.toString(io.netty.util.CharsetUtil.UTF_8);
-//                                        String strMsg = msg.toString(CharsetUtil.UTF_8);
-                                        System.out.println("clientAskText>>"+clientAskText);
-                                    }
-                                });
-                    }
-                });
-
-//        b.bind(port).sync();
-//        System.out.println("tcp server("+port+") is started..");
-
-//        b.bind(port2).sync();
-//        System.out.println("tcp server("+port2+") is started..");
-    }
-}
+//package com.huimv.eartag2.api.netty;
+//
+//import io.netty.bootstrap.ServerBootstrap;
+//import io.netty.buffer.ByteBuf;
+//import io.netty.channel.*;
+//import io.netty.channel.nio.NioEventLoopGroup;
+//import io.netty.channel.socket.SocketChannel;
+//import io.netty.channel.socket.nio.NioServerSocketChannel;
+//import io.netty.handler.logging.LogLevel;
+//import io.netty.handler.logging.LoggingHandler;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.stereotype.Component;
+//
+///**
+// * @Project : huimv.shiwan
+// * @Package : com.huimv.biosafety.uface.controller
+// * @Description : TODO
+// * @Version : 1.0
+// * @Author : ZhuoNing
+// * @Create : 2020-12-25
+// **/
+//@Component
+//public class EartagServer {
+//    @Autowired
+//    private EartagServerHandler2 serverHandler;
+//    //监听端口
+//    private int port = 10023;
+////    private int port2 = 10024;
+//    //创建构造方法
+//    public EartagServer(){
+//    }
+//
+//    public static void main(String[] args) throws InterruptedException {
+//        new EartagServer().run();
+//    }
+///**
+// *
+// * 功能描述: 启动方法前台多个服务  处理多个线程
+// *
+// * @param:
+// * @return:
+// * @auther: LiGang
+// * @date: 2019/3/26 11:31
+// */
+//    /**
+//     * 启动流程
+//     */
+//    public void run() throws InterruptedException {
+//        //配置服务端线程组
+//        EventLoopGroup bossGroup=new NioEventLoopGroup();
+//        EventLoopGroup workGroup=new NioEventLoopGroup();
+//
+//        try{
+//            //引导整个server的启动
+//            ServerBootstrap serverBootstrap = new ServerBootstrap();
+//
+//           serverBootstrap.group(bossGroup, workGroup)
+//                    .channel(NioServerSocketChannel.class)    //指定处理的连接类型
+//                    .option(ChannelOption.SO_REUSEADDR, true)
+//                    .childHandler(new ChannelInitializer<SocketChannel>() {
+//                        @Override
+//                        protected void initChannel(SocketChannel socketChannel) throws Exception {
+//                            socketChannel.pipeline().addLast(serverHandler);
+//                        }
+//                    });
+//            System.out.println("# 耳标及采集器设备数据接收服务器已经启动。#");
+//            System.out.println("# 准备接收数据:");
+//            //绑定端口,同步等待成功
+//            ChannelFuture cf = serverBootstrap.bind(port).sync();
+////            ChannelFuture cf2 = serverBootstrap.bind(port2).sync();
+//            // 等待服务端监听端口关闭
+//            cf.channel().closeFuture().sync();
+////            cf2.channel().closeFuture().sync();
+//        }finally {
+//            //优雅的退出
+//            bossGroup.shutdownGracefully();
+//            workGroup.shutdownGracefully();
+//        }
+//    }
+//
+//    public void run2() throws InterruptedException {
+//        ServerBootstrap b = new ServerBootstrap();
+//        EventLoopGroup bossGroup = new NioEventLoopGroup();
+//        EventLoopGroup workerGroup = new NioEventLoopGroup();
+//
+//        b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class)
+//                .option(ChannelOption.SO_REUSEADDR, true)
+//                .childHandler(new ChannelInitializer() {
+//                    @Override
+//                    protected void initChannel(Channel ch) throws Exception {
+//                        ch.pipeline()
+//                                .addLast("logging", new LoggingHandler(LogLevel.INFO))
+//                                .addLast(new SimpleChannelInboundHandler() {
+//                                    @Override
+//                                    protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
+//                                        ByteBuf data = (ByteBuf) msg;
+//                                        String clientAskText = data.toString(io.netty.util.CharsetUtil.UTF_8);
+////                                        String strMsg = msg.toString(CharsetUtil.UTF_8);
+//                                        System.out.println("clientAskText>>"+clientAskText);
+//                                    }
+//                                });
+//                    }
+//                });
+//
+////        b.bind(port).sync();
+////        System.out.println("tcp server("+port+") is started..");
+//
+////        b.bind(port2).sync();
+////        System.out.println("tcp server("+port2+") is started..");
+//    }
+//}

+ 298 - 298
huimv-eartag2-platform/huimv-eartag2-api/src/main/java/com/huimv/eartag2/api/netty/EartagServerHandler2.java

@@ -1,298 +1,298 @@
-package com.huimv.eartag2.api.netty;
-
-import cn.hutool.core.util.ObjectUtil;
-import cn.hutool.json.JSONObject;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.huimv.eartag2.api.config.WebSocket;
-import com.huimv.eartag2.api.pojo.EartagDeviceRegister;
-import com.huimv.eartag2.api.pojo.EartagEartagRegister2;
-import com.huimv.eartag2.api.pojo.PliersDemo;
-import com.huimv.eartag2.api.pojo.StationLib;
-import com.huimv.eartag2.api.service.IEartagDeviceRegisterService;
-import com.huimv.eartag2.api.service.IEartagEartagRegister2Service;
-import com.huimv.eartag2.api.service.IPliersDemoService;
-import com.huimv.eartag2.api.service.IStationLibService;
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
-import io.netty.channel.ChannelHandler;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
-import io.netty.util.CharsetUtil;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.ResponseEntity;
-import org.springframework.stereotype.Component;
-import org.springframework.web.client.RestTemplate;
-
-import java.text.ParseException;
-import java.util.Date;
-
-/**
- * @Project : huimv.shiwan
- * @Package : com.huimv.biosafety.uface.controller
- * @Description : TODO
- * @Version : 1.0
- * @Author : ZhuoNing
- * @Create : 2020-12-25
- **/
-@ChannelHandler.Sharable
-@Component
-@Slf4j
-public class EartagServerHandler2 extends ChannelInboundHandlerAdapter {
-    private StringBuilder askTextSb = null;
-@Autowired
-private IEartagEartagRegister2Service eartagRegisterService;
-    @Autowired
-    private IEartagDeviceRegisterService deviceRegisterService;
-
-    @Autowired
-    private IStationLibService stationLibService;
-
-    @Autowired
-    private IPliersDemoService pliersDemoService;
-
-    @Autowired
-    private RestTemplate restTemplate ;
-    //
-    public void appendClientAsk(String text){
-        if(this.askTextSb == null){
-            askTextSb = new StringBuilder();
-        }
-        askTextSb.append(text);
-    }
-
-    @Override
-    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
-        ByteBuf data = (ByteBuf) msg;
-        String clientAskText = data.toString(CharsetUtil.UTF_8);
-//        System.out.println((++num)+"次, 客户端消息clientAskText>>"+clientAskText);
-        //保存实例内的客户端请求
-        appendClientAsk(clientAskText);
-    }
-
-    @Override
-    public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
-//        ctx.writeAndFlush("111");
-//        System.out.println("EchoServerHandle channelReadComplete");
-        if(askTextSb.toString().indexOf("end") != -1){
-//            System.out.println("askTextSb.内容()>>"+askTextSb.toString());
-//            System.out.println("askTextSb.内容长度>>"+askTextSb.length());
-//            System.out.println("输入完成.");
-            // 处理客户端消息
-            handleClientEartagMessage(askTextSb.toString(),ctx);
-            //清空重置;
-            askTextSb.delete(0,askTextSb.length());
-//            System.out.println("清空sb实例. 长度>>"+askTextSb.length());
-        }
-    }
-
-    @Override
-    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
-//        System.out.println("cause.getMessage()>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"+cause.getMessage());
-        if(cause.getMessage().indexOf("Connection reset") != -1){
-            log.info("相关采集器设备正在重启:"+cause.toString());
-        }
-//        cause.printStackTrace();
-        ctx.close();
-    }
-
-
-
-    private   void handleClientEartagMessage(String clientAskText, ChannelHandlerContext ctx) throws ParseException, JsonProcessingException {
-        clientAskText = clientAskText.replaceAll("\r","").replaceAll("\n","");
-        System.out.println("clientAskText--------------->" +clientAskText);
-//hm+7+868977051335099+122083123610011+0+end
-
-        String[] split = clientAskText.split("\\+");
-
-        if ("6".equals(split[1])){
-            System.out.println("pliersDemo------------->" +clientAskText);
-            ctx.writeAndFlush(Unpooled.copiedBuffer("hm+6+0+119.3.44.183+10023+8+end".getBytes()));
-        }
-        if ("7".equals(split[1])){
-            System.out.println("1");
-            ctx.writeAndFlush(Unpooled.copiedBuffer("hm+7+8+end".getBytes()));
-            String device = split[2];
-            String eartag = split[3];
-            EartagDeviceRegister deviceRegister = deviceRegisterService.getOne(new QueryWrapper<EartagDeviceRegister>().eq("chip_id", device));
-            System.out.println("2");
-            if(ObjectUtil.isNotEmpty(deviceRegister)){
-                Integer upgrade = deviceRegister.getUpgrade();
-                if (upgrade ==1){
-                    saveMoneyData(split,deviceRegister.getChipId());
-                }else {
-                    saveData(split);
-                }
-                EartagEartagRegister2 eartagRegister = eartagRegisterService.getOne(new QueryWrapper<EartagEartagRegister2>().eq("earmark", eartag));
-                if (ObjectUtil.isNotEmpty(eartagRegister)){
-                    eartagRegister.setEarmark(eartag);
-                    eartagRegister.setFirstDevice(device);
-                    eartagRegister.setRegisterTime(new Date());
-                    eartagRegister.setRegisterType(2);
-                    eartagRegister.setFarmId(deviceRegister.getFarmId());
-                    eartagRegister.setCreateDate(new Date());
-                    eartagRegisterService.updateById(eartagRegister);
-                }else {
-                    EartagEartagRegister2 eartagEartagRegister = new EartagEartagRegister2();
-                    eartagEartagRegister.setEarmark(eartag);
-                    eartagEartagRegister.setFirstDevice(device);
-                    eartagEartagRegister.setRegisterTime(new Date());
-                    eartagEartagRegister.setRegisterType(2);
-                    eartagEartagRegister.setFarmId(deviceRegister.getFarmId());
-                    eartagEartagRegister.setCreateDate(new Date());
-                    eartagRegisterService.save(eartagEartagRegister);
-                }
-                WebSocket.sendMessage("true");
-            }
-        }
-    }
-    private  final  String URL = "http://apilocate.amap.com/position";
-    private  final  String KEY = "9ccbad3db267cd800084179fe58c5ce9";
-
-    private void saveMoneyData(String[] split,String imei ) {
-        String eartag = split[3];
-        String device = split[2];
-        String lac = split[4];
-        String ci = split[5];
-        StationLib stationLib = stationLibService.getOne(new QueryWrapper<StationLib>().eq("ci", ci).eq("lac", lac));
-        String lat ="";
-        String lon ="";
-        String address ="";
-        JSONObject body= new JSONObject();
-        if (ObjectUtil.isEmpty(stationLib)){
-            try {
-                ResponseEntity<JSONObject>  forEntity = restTemplate.getForEntity(URL+"?accesstype=0&imei="+imei+"&cdma=0&bts=460,0,"+lac+","+ci+",-30&output=json&key="+KEY+"&network=GSM", JSONObject.class);
-                System.out.println("forEntity" + forEntity);
-                body = forEntity.getBody();
-            }catch (Exception e){
-                System.out.println(e);
-            }
-            if (ObjectUtil.isNotEmpty(body)){
-                Object infocode = body.get("infocode");
-                if ("10000".equals(infocode)){
-                    JSONObject result = (JSONObject)body.get("result");
-                    address = (String) result.get("desc");
-                    String radius = (String) result.get("radius");
-                    String locations = (String) result.get("location");
-                    String[] location = locations.split(",");
-
-                    lat = location[1];
-                    lon = location[0];
-
-                    StationLib stationLib1 = new StationLib();
-                    stationLib1.setAddress(address);
-                    stationLib1.setCi(ci);
-                    stationLib1.setLac(lac);
-                    stationLib1.setLat(lat);
-                    stationLib1.setLon(lon);
-                    stationLib1.setRadius(Integer.parseInt(radius));
-                    stationLibService.save(stationLib1);
-                }else {
-                    StationLib id = stationLibService.getOne(new QueryWrapper<StationLib>().orderByDesc("id").last("limit 1"));
-                    lat = id.getLat();
-                    lon = id.getLon();
-                    address = id.getAddress();
-                    System.out.println(body);
-                    System.out.println("高德接口出错,取上一个记录接口");
-                }
-            }
-
-        }else {
-            lat = stationLib.getLat();
-            lon = stationLib.getLon();
-            address = stationLib.getAddress();
-        }
-
-        int countEarmark = (int)pliersDemoService.count(new QueryWrapper<PliersDemo>().eq("earmark", eartag));
-        PliersDemo pliersDemo = new PliersDemo();
-        pliersDemo.setEarmark(eartag);
-        pliersDemo.setPliersId(device);
-        pliersDemo.setUpdateTime(new Date());
-        pliersDemo.setUsegeTimes(1+countEarmark);
-
-        pliersDemo.setLat(lat);
-        pliersDemo.setLon(lon);
-        pliersDemo.setAddress(address);
-        pliersDemoService.save(pliersDemo);
-        System.out.println("存储成功");
-    }
-
-    private void saveData( String[] split  ) {
-
-            //耳标记录,加上webSoket
-            //hm+7+868977051335099+122083123610011+22450+184902913+0+end
-        String eartag = split[3];
-            String lac = split[4];
-            String ci = split[5];
-            String pliersId = split[2];
-            StationLib stationLib = stationLibService.getOne(new QueryWrapper<StationLib>().eq("ci", ci).eq("lac", lac));
-            String lat ="";
-            String lon ="";
-            String address ="";
-
-            JSONObject body= new JSONObject();
-            if (ObjectUtil.isEmpty(stationLib)){
-                try {
-                    ResponseEntity<JSONObject>  forEntity = restTemplate.getForEntity("http://api.cellocation.com:82/cell/?mcc=460&mnc=1&lac="+lac+"&ci="+ci+"&output=json", JSONObject.class);
-                    System.out.println("forEntity"+forEntity);
-                    body = forEntity.getBody();
-                }catch (Exception e){
-                    System.out.println(e);
-                }
-
-                lat = (String)body.get("lat");
-                lon =  (String)body.get("lon");
-                address = (String)body.get("address");
-                String    radius = (String)body.get("radius");
-                Integer  errcode = (Integer)body.get("errcode");
-                if (errcode == 0){
-                    StationLib stationLib1 = new StationLib();
-                    stationLib1.setAddress(address);
-                    stationLib1.setCi(ci);
-                    stationLib1.setErrcode(errcode+"");
-                    stationLib1.setLac(lac);
-                    stationLib1.setLat(lat);
-                    stationLib1.setLon(lon);
-                    stationLib1.setRadius(Integer.parseInt(radius));
-
-                    stationLibService.save(stationLib1);
-                }
-                if (errcode == 10001){
-                    StationLib id = stationLibService.getOne(new QueryWrapper<StationLib>().orderByDesc("id").last("limit 1"));
-                    lat = id.getLat();
-                    lon = id.getLon();
-                    address = id.getAddress();
-                }
-
-            }else {
-                lat = stationLib.getLat();
-                lon = stationLib.getLon();
-                address = stationLib.getAddress();
-            }
-
-
-            int countEarmark = (int)pliersDemoService.count(new QueryWrapper<PliersDemo>().eq("earmark", eartag));
-            PliersDemo pliersDemo = new PliersDemo();
-            pliersDemo.setEarmark(eartag);
-            pliersDemo.setPliersId(pliersId);
-            pliersDemo.setUpdateTime(new Date());
-            pliersDemo.setUsegeTimes(1+countEarmark);
-
-
-            pliersDemo.setLat(lat);
-            pliersDemo.setLon(lon);
-            pliersDemo.setAddress(address);
-            pliersDemoService.save(pliersDemo);
-
-//                List<PliersDemo> id = pliersDemoService.list(new QueryWrapper<PliersDemo>().eq("pliers_id",pliersId).orderByDesc("id").last("limit 50"));
-//                String resultJson= new ObjectMapper().writeValueAsString(true);
-
-
-    }
-
-
-//hm+7+868977051335099+122083123610011+0+end
-    //hm+6+868977051335099+0+end
-
-}
+//package com.huimv.eartag2.api.netty;
+//
+//import cn.hutool.core.util.ObjectUtil;
+//import cn.hutool.json.JSONObject;
+//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+//import com.fasterxml.jackson.core.JsonProcessingException;
+//import com.huimv.eartag2.api.config.WebSocket;
+//import com.huimv.eartag2.api.pojo.EartagDeviceRegister;
+//import com.huimv.eartag2.api.pojo.EartagEartagRegister2;
+//import com.huimv.eartag2.api.pojo.PliersDemo;
+//import com.huimv.eartag2.api.pojo.StationLib;
+//import com.huimv.eartag2.api.service.IEartagDeviceRegisterService;
+//import com.huimv.eartag2.api.service.IEartagEartagRegister2Service;
+//import com.huimv.eartag2.api.service.IPliersDemoService;
+//import com.huimv.eartag2.api.service.IStationLibService;
+//import io.netty.buffer.ByteBuf;
+//import io.netty.buffer.Unpooled;
+//import io.netty.channel.ChannelHandler;
+//import io.netty.channel.ChannelHandlerContext;
+//import io.netty.channel.ChannelInboundHandlerAdapter;
+//import io.netty.util.CharsetUtil;
+//import lombok.extern.slf4j.Slf4j;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.http.ResponseEntity;
+//import org.springframework.stereotype.Component;
+//import org.springframework.web.client.RestTemplate;
+//
+//import java.text.ParseException;
+//import java.util.Date;
+//
+///**
+// * @Project : huimv.shiwan
+// * @Package : com.huimv.biosafety.uface.controller
+// * @Description : TODO
+// * @Version : 1.0
+// * @Author : ZhuoNing
+// * @Create : 2020-12-25
+// **/
+//@ChannelHandler.Sharable
+//@Component
+//@Slf4j
+//public class EartagServerHandler2 extends ChannelInboundHandlerAdapter {
+//    private StringBuilder askTextSb = null;
+//@Autowired
+//private IEartagEartagRegister2Service eartagRegisterService;
+//    @Autowired
+//    private IEartagDeviceRegisterService deviceRegisterService;
+//
+//    @Autowired
+//    private IStationLibService stationLibService;
+//
+//    @Autowired
+//    private IPliersDemoService pliersDemoService;
+//
+//    @Autowired
+//    private RestTemplate restTemplate ;
+//    //
+//    public void appendClientAsk(String text){
+//        if(this.askTextSb == null){
+//            askTextSb = new StringBuilder();
+//        }
+//        askTextSb.append(text);
+//    }
+//
+//    @Override
+//    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
+//        ByteBuf data = (ByteBuf) msg;
+//        String clientAskText = data.toString(CharsetUtil.UTF_8);
+////        System.out.println((++num)+"次, 客户端消息clientAskText>>"+clientAskText);
+//        //保存实例内的客户端请求
+//        appendClientAsk(clientAskText);
+//    }
+//
+//    @Override
+//    public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
+////        ctx.writeAndFlush("111");
+////        System.out.println("EchoServerHandle channelReadComplete");
+//        if(askTextSb.toString().indexOf("end") != -1){
+////            System.out.println("askTextSb.内容()>>"+askTextSb.toString());
+////            System.out.println("askTextSb.内容长度>>"+askTextSb.length());
+////            System.out.println("输入完成.");
+//            // 处理客户端消息
+//            handleClientEartagMessage(askTextSb.toString(),ctx);
+//            //清空重置;
+//            askTextSb.delete(0,askTextSb.length());
+////            System.out.println("清空sb实例. 长度>>"+askTextSb.length());
+//        }
+//    }
+//
+//    @Override
+//    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
+////        System.out.println("cause.getMessage()>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"+cause.getMessage());
+//        if(cause.getMessage().indexOf("Connection reset") != -1){
+//            log.info("相关采集器设备正在重启:"+cause.toString());
+//        }
+////        cause.printStackTrace();
+//        ctx.close();
+//    }
+//
+//
+//
+//    private   void handleClientEartagMessage(String clientAskText, ChannelHandlerContext ctx) throws ParseException, JsonProcessingException {
+//        clientAskText = clientAskText.replaceAll("\r","").replaceAll("\n","");
+//        System.out.println("clientAskText--------------->" +clientAskText);
+////hm+7+868977051335099+122083123610011+0+end
+//
+//        String[] split = clientAskText.split("\\+");
+//
+//        if ("6".equals(split[1])){
+//            System.out.println("pliersDemo------------->" +clientAskText);
+//            ctx.writeAndFlush(Unpooled.copiedBuffer("hm+6+0+119.3.44.183+10023+8+end".getBytes()));
+//        }
+//        if ("7".equals(split[1])){
+//            System.out.println("1");
+//            ctx.writeAndFlush(Unpooled.copiedBuffer("hm+7+8+end".getBytes()));
+//            String device = split[2];
+//            String eartag = split[3];
+//            EartagDeviceRegister deviceRegister = deviceRegisterService.getOne(new QueryWrapper<EartagDeviceRegister>().eq("chip_id", device));
+//            System.out.println("2");
+//            if(ObjectUtil.isNotEmpty(deviceRegister)){
+//                Integer upgrade = deviceRegister.getUpgrade();
+//                if (upgrade ==1){
+//                    saveMoneyData(split,deviceRegister.getChipId());
+//                }else {
+//                    saveData(split);
+//                }
+//                EartagEartagRegister2 eartagRegister = eartagRegisterService.getOne(new QueryWrapper<EartagEartagRegister2>().eq("earmark", eartag));
+//                if (ObjectUtil.isNotEmpty(eartagRegister)){
+//                    eartagRegister.setEarmark(eartag);
+//                    eartagRegister.setFirstDevice(device);
+//                    eartagRegister.setRegisterTime(new Date());
+//                    eartagRegister.setRegisterType(2);
+//                    eartagRegister.setFarmId(deviceRegister.getFarmId());
+//                    eartagRegister.setCreateDate(new Date());
+//                    eartagRegisterService.updateById(eartagRegister);
+//                }else {
+//                    EartagEartagRegister2 eartagEartagRegister = new EartagEartagRegister2();
+//                    eartagEartagRegister.setEarmark(eartag);
+//                    eartagEartagRegister.setFirstDevice(device);
+//                    eartagEartagRegister.setRegisterTime(new Date());
+//                    eartagEartagRegister.setRegisterType(2);
+//                    eartagEartagRegister.setFarmId(deviceRegister.getFarmId());
+//                    eartagEartagRegister.setCreateDate(new Date());
+//                    eartagRegisterService.save(eartagEartagRegister);
+//                }
+//                WebSocket.sendMessage("true");
+//            }
+//        }
+//    }
+//    private  final  String URL = "http://apilocate.amap.com/position";
+//    private  final  String KEY = "9ccbad3db267cd800084179fe58c5ce9";
+//
+//    private void saveMoneyData(String[] split,String imei ) {
+//        String eartag = split[3];
+//        String device = split[2];
+//        String lac = split[4];
+//        String ci = split[5];
+//        StationLib stationLib = stationLibService.getOne(new QueryWrapper<StationLib>().eq("ci", ci).eq("lac", lac));
+//        String lat ="";
+//        String lon ="";
+//        String address ="";
+//        JSONObject body= new JSONObject();
+//        if (ObjectUtil.isEmpty(stationLib)){
+//            try {
+//                ResponseEntity<JSONObject>  forEntity = restTemplate.getForEntity(URL+"?accesstype=0&imei="+imei+"&cdma=0&bts=460,0,"+lac+","+ci+",-30&output=json&key="+KEY+"&network=GSM", JSONObject.class);
+//                System.out.println("forEntity" + forEntity);
+//                body = forEntity.getBody();
+//            }catch (Exception e){
+//                System.out.println(e);
+//            }
+//            if (ObjectUtil.isNotEmpty(body)){
+//                Object infocode = body.get("infocode");
+//                if ("10000".equals(infocode)){
+//                    JSONObject result = (JSONObject)body.get("result");
+//                    address = (String) result.get("desc");
+//                    String radius = (String) result.get("radius");
+//                    String locations = (String) result.get("location");
+//                    String[] location = locations.split(",");
+//
+//                    lat = location[1];
+//                    lon = location[0];
+//
+//                    StationLib stationLib1 = new StationLib();
+//                    stationLib1.setAddress(address);
+//                    stationLib1.setCi(ci);
+//                    stationLib1.setLac(lac);
+//                    stationLib1.setLat(lat);
+//                    stationLib1.setLon(lon);
+//                    stationLib1.setRadius(Integer.parseInt(radius));
+//                    stationLibService.save(stationLib1);
+//                }else {
+//                    StationLib id = stationLibService.getOne(new QueryWrapper<StationLib>().orderByDesc("id").last("limit 1"));
+//                    lat = id.getLat();
+//                    lon = id.getLon();
+//                    address = id.getAddress();
+//                    System.out.println(body);
+//                    System.out.println("高德接口出错,取上一个记录接口");
+//                }
+//            }
+//
+//        }else {
+//            lat = stationLib.getLat();
+//            lon = stationLib.getLon();
+//            address = stationLib.getAddress();
+//        }
+//
+//        int countEarmark = (int)pliersDemoService.count(new QueryWrapper<PliersDemo>().eq("earmark", eartag));
+//        PliersDemo pliersDemo = new PliersDemo();
+//        pliersDemo.setEarmark(eartag);
+//        pliersDemo.setPliersId(device);
+//        pliersDemo.setUpdateTime(new Date());
+//        pliersDemo.setUsegeTimes(1+countEarmark);
+//
+//        pliersDemo.setLat(lat);
+//        pliersDemo.setLon(lon);
+//        pliersDemo.setAddress(address);
+//        pliersDemoService.save(pliersDemo);
+//        System.out.println("存储成功");
+//    }
+//
+//    private void saveData( String[] split  ) {
+//
+//            //耳标记录,加上webSoket
+//            //hm+7+868977051335099+122083123610011+22450+184902913+0+end
+//        String eartag = split[3];
+//            String lac = split[4];
+//            String ci = split[5];
+//            String pliersId = split[2];
+//            StationLib stationLib = stationLibService.getOne(new QueryWrapper<StationLib>().eq("ci", ci).eq("lac", lac));
+//            String lat ="";
+//            String lon ="";
+//            String address ="";
+//
+//            JSONObject body= new JSONObject();
+//            if (ObjectUtil.isEmpty(stationLib)){
+//                try {
+//                    ResponseEntity<JSONObject>  forEntity = restTemplate.getForEntity("http://api.cellocation.com:82/cell/?mcc=460&mnc=1&lac="+lac+"&ci="+ci+"&output=json", JSONObject.class);
+//                    System.out.println("forEntity"+forEntity);
+//                    body = forEntity.getBody();
+//                }catch (Exception e){
+//                    System.out.println(e);
+//                }
+//
+//                lat = (String)body.get("lat");
+//                lon =  (String)body.get("lon");
+//                address = (String)body.get("address");
+//                String    radius = (String)body.get("radius");
+//                Integer  errcode = (Integer)body.get("errcode");
+//                if (errcode == 0){
+//                    StationLib stationLib1 = new StationLib();
+//                    stationLib1.setAddress(address);
+//                    stationLib1.setCi(ci);
+//                    stationLib1.setErrcode(errcode+"");
+//                    stationLib1.setLac(lac);
+//                    stationLib1.setLat(lat);
+//                    stationLib1.setLon(lon);
+//                    stationLib1.setRadius(Integer.parseInt(radius));
+//
+//                    stationLibService.save(stationLib1);
+//                }
+//                if (errcode == 10001){
+//                    StationLib id = stationLibService.getOne(new QueryWrapper<StationLib>().orderByDesc("id").last("limit 1"));
+//                    lat = id.getLat();
+//                    lon = id.getLon();
+//                    address = id.getAddress();
+//                }
+//
+//            }else {
+//                lat = stationLib.getLat();
+//                lon = stationLib.getLon();
+//                address = stationLib.getAddress();
+//            }
+//
+//
+//            int countEarmark = (int)pliersDemoService.count(new QueryWrapper<PliersDemo>().eq("earmark", eartag));
+//            PliersDemo pliersDemo = new PliersDemo();
+//            pliersDemo.setEarmark(eartag);
+//            pliersDemo.setPliersId(pliersId);
+//            pliersDemo.setUpdateTime(new Date());
+//            pliersDemo.setUsegeTimes(1+countEarmark);
+//
+//
+//            pliersDemo.setLat(lat);
+//            pliersDemo.setLon(lon);
+//            pliersDemo.setAddress(address);
+//            pliersDemoService.save(pliersDemo);
+//
+////                List<PliersDemo> id = pliersDemoService.list(new QueryWrapper<PliersDemo>().eq("pliers_id",pliersId).orderByDesc("id").last("limit 50"));
+////                String resultJson= new ObjectMapper().writeValueAsString(true);
+//
+//
+//    }
+//
+//
+////hm+7+868977051335099+122083123610011+0+end
+//    //hm+6+868977051335099+0+end
+//
+//}

+ 119 - 119
huimv-eartag2-platform/huimv-eartag2-api/src/main/java/com/huimv/eartag2/api/service/impl/FarmerAssetServiceImpl.java

@@ -1,119 +1,119 @@
-package com.huimv.eartag2.api.service.impl;
-
-import com.alibaba.fastjson.JSONObject;
-import com.huimv.eartag2.api.mapper.BaseFarmerMapper;
-import com.huimv.eartag2.api.mapper.EartagDeviceRegisterMapper;
-import com.huimv.eartag2.api.mapper.EartagEartagRegister2Mapper;
-import com.huimv.eartag2.api.mapper.FarmerAssetMapper;
-import com.huimv.eartag2.api.pojo.EartagEartagRegister2;
-import com.huimv.eartag2.api.pojo.FarmerAsset;
-import com.huimv.eartag2.common.utils.DateUtil;
-import com.huimv.eartag2.common.utils.Result;
-import com.huimv.eartag2.common.utils.ResultCode;
-import com.huimv.eartag2.api.service.FarmerAssetService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Service;
-
-import java.math.BigDecimal;
-import java.text.ParseException;
-import java.util.*;
-
-/**
- * <p>
- *  服务实现类
- * </p>
- *
- * @author zn
- * @since 2022-08-29
- */
-@Service
-@Slf4j
-public class FarmerAssetServiceImpl extends ServiceImpl<FarmerAssetMapper, FarmerAsset> implements FarmerAssetService {
-    @Autowired
-    private FarmerAssetMapper farmerAssetMapper;
-    @Autowired
-    private EartagEartagRegister2Mapper eartagEartagRegister2Mapper;
-    @Autowired
-    private EartagDeviceRegisterMapper eartagDeviceRegisterMapper;
-
-    @Autowired
-    private BaseFarmerMapper baseFarmerMapper;
-    @Value("${farmer.pig.price}")
-    private String pigPrice;
-
-    @Override
-    public List<FarmerAsset> getLastManyMonthAssets(String farmCode, String manyMonth) {
-        //{}
-        return farmerAssetMapper.getLastManyMonthAssets(farmCode,manyMonth);
-    }
-
-    @Override
-    public Result getAssetStatistics(Map<String, Object> paramsMap) throws ParseException {
-        //--农户
-        String farmerId = paramsMap.get("farmerId")+"";
-        System.out.println("farmerId="+farmerId);
-
-        //{根据农户读取采集器}
-        String deviceCode = eartagDeviceRegisterMapper.getDeviceIdByFarmerId(farmerId);
-        //{读取最后一批猪信息}
-        JSONObject lastBatchJo = _getlastBatchAdoptPig(deviceCode);
-        //读取资产信息
-        List<FarmerAsset> farmerAssetList = farmerAssetMapper.getAssetByMonth(6,farmerId);
-        List reverseList = new ArrayList();
-        //--反转排序
-        for(int a=farmerAssetList.size()-1;a>=0;a--){
-            reverseList.add(farmerAssetList.get(a));
-        }
-        if(lastBatchJo != null){
-            lastBatchJo.put("estimated",reverseList);
-            return new Result(ResultCode.SUCCESS,lastBatchJo);
-        }else{
-            JSONObject nullLastBatchJo = new JSONObject();
-            nullLastBatchJo.put("adoptTime","");
-            nullLastBatchJo.put("husbandryTime","");
-            nullLastBatchJo.put("currentPrices",0);
-            nullLastBatchJo.put("expectedEarning",0);
-            nullLastBatchJo.put("estimated",reverseList);
-            return new Result(ResultCode.SUCCESS,nullLastBatchJo);
-        }
-
-    }
-
-
-
-    //{读取最后一批猪信息}
-    private JSONObject _getlastBatchAdoptPig(String deviceCode) throws ParseException {
-        //{获取最后一条记录create_date日期}
-        Date createDate = eartagEartagRegister2Mapper.getLastBatchCreateDate(deviceCode);
-        if(createDate == null){
-            log.error("该采集器["+deviceCode+"]没有耳标注册数据.");
-            return null;
-        }else{
-            DateUtil dateUtil = new DateUtil();
-            List<EartagEartagRegister2> eartagEartagRegister2List = eartagEartagRegister2Mapper.getLastBatchPig(deviceCode,createDate);
-            if(eartagEartagRegister2List.size()>0){
-                long diff = dateUtil.getTodayDate().getTime()-createDate.getTime();
-                long days = diff / (1000 * 60 * 60 * 24);
-                //读取重量
-                BigDecimal weightBd = farmerAssetMapper.getPigWeightByDayage(days);
-                BigDecimal planValue = weightBd.multiply(new BigDecimal(pigPrice)).multiply(new BigDecimal(eartagEartagRegister2List.size())).setScale(2,BigDecimal.ROUND_HALF_UP);
-                JSONObject outJo = new JSONObject();
-                outJo.put("adoptTime",dateUtil.formatDateText(createDate));
-                outJo.put("husbandryTime",days);
-                outJo.put("currentPrices",pigPrice);
-                outJo.put("expectedEarning",planValue.toString());
-                return outJo;
-            }else{
-                JSONObject outJo = new JSONObject();
-                outJo.put("adoptTime",null);
-                outJo.put("husbandryTime",null);
-                outJo.put("currentPrices",0);
-                outJo.put("expectedEarning",0);
-                return outJo;
-            }
-        }
-    }
-}
+//package com.huimv.eartag2.api.service.impl;
+//
+//import com.alibaba.fastjson.JSONObject;
+//import com.huimv.eartag2.api.mapper.BaseFarmerMapper;
+//import com.huimv.eartag2.api.mapper.EartagDeviceRegisterMapper;
+//import com.huimv.eartag2.api.mapper.EartagEartagRegister2Mapper;
+//import com.huimv.eartag2.api.mapper.FarmerAssetMapper;
+//import com.huimv.eartag2.api.pojo.EartagEartagRegister2;
+//import com.huimv.eartag2.api.pojo.FarmerAsset;
+//import com.huimv.eartag2.common.utils.DateUtil;
+//import com.huimv.eartag2.common.utils.Result;
+//import com.huimv.eartag2.common.utils.ResultCode;
+//import com.huimv.eartag2.api.service.FarmerAssetService;
+//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+//import lombok.extern.slf4j.Slf4j;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.beans.factory.annotation.Value;
+//import org.springframework.stereotype.Service;
+//
+//import java.math.BigDecimal;
+//import java.text.ParseException;
+//import java.util.*;
+//
+///**
+// * <p>
+// *  服务实现类
+// * </p>
+// *
+// * @author zn
+// * @since 2022-08-29
+// */
+//@Service
+//@Slf4j
+//public class FarmerAssetServiceImpl extends ServiceImpl<FarmerAssetMapper, FarmerAsset> implements FarmerAssetService {
+//    @Autowired
+//    private FarmerAssetMapper farmerAssetMapper;
+//    @Autowired
+//    private EartagEartagRegister2Mapper eartagEartagRegister2Mapper;
+//    @Autowired
+//    private EartagDeviceRegisterMapper eartagDeviceRegisterMapper;
+//
+//    @Autowired
+//    private BaseFarmerMapper baseFarmerMapper;
+//    @Value("${farmer.pig.price}")
+//    private String pigPrice;
+//
+//    @Override
+//    public List<FarmerAsset> getLastManyMonthAssets(String farmCode, String manyMonth) {
+//        //{}
+//        return farmerAssetMapper.getLastManyMonthAssets(farmCode,manyMonth);
+//    }
+//
+//    @Override
+//    public Result getAssetStatistics(Map<String, Object> paramsMap) throws ParseException {
+//        //--农户
+//        String farmerId = paramsMap.get("farmerId")+"";
+//        System.out.println("farmerId="+farmerId);
+//
+//        //{根据农户读取采集器}
+//        String deviceCode = eartagDeviceRegisterMapper.getDeviceIdByFarmerId(farmerId);
+//        //{读取最后一批猪信息}
+//        JSONObject lastBatchJo = _getlastBatchAdoptPig(deviceCode);
+//        //读取资产信息
+//        List<FarmerAsset> farmerAssetList = farmerAssetMapper.getAssetByMonth(6,farmerId);
+//        List reverseList = new ArrayList();
+//        //--反转排序
+//        for(int a=farmerAssetList.size()-1;a>=0;a--){
+//            reverseList.add(farmerAssetList.get(a));
+//        }
+//        if(lastBatchJo != null){
+//            lastBatchJo.put("estimated",reverseList);
+//            return new Result(ResultCode.SUCCESS,lastBatchJo);
+//        }else{
+//            JSONObject nullLastBatchJo = new JSONObject();
+//            nullLastBatchJo.put("adoptTime","");
+//            nullLastBatchJo.put("husbandryTime","");
+//            nullLastBatchJo.put("currentPrices",0);
+//            nullLastBatchJo.put("expectedEarning",0);
+//            nullLastBatchJo.put("estimated",reverseList);
+//            return new Result(ResultCode.SUCCESS,nullLastBatchJo);
+//        }
+//
+//    }
+//
+//
+//
+//    //{读取最后一批猪信息}
+//    private JSONObject _getlastBatchAdoptPig(String deviceCode) throws ParseException {
+//        //{获取最后一条记录create_date日期}
+//        Date createDate = eartagEartagRegister2Mapper.getLastBatchCreateDate(deviceCode);
+//        if(createDate == null){
+//            log.error("该采集器["+deviceCode+"]没有耳标注册数据.");
+//            return null;
+//        }else{
+//            DateUtil dateUtil = new DateUtil();
+//            List<EartagEartagRegister2> eartagEartagRegister2List = eartagEartagRegister2Mapper.getLastBatchPig(deviceCode,createDate);
+//            if(eartagEartagRegister2List.size()>0){
+//                long diff = dateUtil.getTodayDate().getTime()-createDate.getTime();
+//                long days = diff / (1000 * 60 * 60 * 24);
+//                //读取重量
+//                BigDecimal weightBd = farmerAssetMapper.getPigWeightByDayage(days);
+//                BigDecimal planValue = weightBd.multiply(new BigDecimal(pigPrice)).multiply(new BigDecimal(eartagEartagRegister2List.size())).setScale(2,BigDecimal.ROUND_HALF_UP);
+//                JSONObject outJo = new JSONObject();
+//                outJo.put("adoptTime",dateUtil.formatDateText(createDate));
+//                outJo.put("husbandryTime",days);
+//                outJo.put("currentPrices",pigPrice);
+//                outJo.put("expectedEarning",planValue.toString());
+//                return outJo;
+//            }else{
+//                JSONObject outJo = new JSONObject();
+//                outJo.put("adoptTime",null);
+//                outJo.put("husbandryTime",null);
+//                outJo.put("currentPrices",0);
+//                outJo.put("expectedEarning",0);
+//                return outJo;
+//            }
+//        }
+//    }
+//}

+ 1 - 1
huimv-eartag2-platform/huimv-eartag2-common/pom.xml

@@ -13,7 +13,7 @@
 
 
     <groupId>com.huimv</groupId>
     <groupId>com.huimv</groupId>
     <artifactId>huimv-eartag2-common</artifactId>
     <artifactId>huimv-eartag2-common</artifactId>
-    <version>0.0.2-SNAPSHOT</version>
+    <version>0.0.1-SNAPSHOT</version>
 
 
 <!--    <distributionManagement>-->
 <!--    <distributionManagement>-->
 <!--        <repository>-->
 <!--        <repository>-->

+ 4 - 3
huimv-eartag2-platform/huimv-eartag2-device/src/main/resources/application-prod2.yml

@@ -5,7 +5,8 @@ spring:
     name: huimv-eartag2-device
     name: huimv-eartag2-device
 
 
   datasource:
   datasource:
-    url: jdbc:mysql://10.0.0.77:3309/huimv-demo-eartag20?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+#    url: jdbc:mysql://10.0.0.77:3309/huimv-demo-eartag20?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+    url: jdbc:mysql://139.9.172.209:3309/huimv-demo-eartag20?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
     username: eartag
     username: eartag
     password: eartag@2022
     password: eartag@2022
     driver-class-name: com.mysql.cj.jdbc.Driver
     driver-class-name: com.mysql.cj.jdbc.Driver
@@ -26,9 +27,9 @@ spring:
 #    #虚拟host 可以不设置,使用server默认host
 #    #虚拟host 可以不设置,使用server默认host
 #    virtual-host: /
 #    virtual-host: /
   rabbitmq:
   rabbitmq:
-#    host: 121.36.134.218
+    host: 121.36.134.218
 #    host: 10.0.0.14
 #    host: 10.0.0.14
-    host: 10.0.0.77
+#    host: 10.0.0.77
     port: 5672
     port: 5672
     username: admin
     username: admin
     password: admin
     password: admin

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

@@ -1,5 +1,5 @@
 #spring.profiles.active=test
 #spring.profiles.active=test
-spring.profiles.active=prod3
+spring.profiles.active=prod2
 
 
 
 
 service.farmAllStatus.url=/deviceController/updateFarmAllStatus
 service.farmAllStatus.url=/deviceController/updateFarmAllStatus

+ 33 - 33
huimv-eartag2-platform/huimv-eartag2-eartag/pom.xml

@@ -25,37 +25,37 @@
 <!--            <version>0.0.1-SNAPSHOT</version>-->
 <!--            <version>0.0.1-SNAPSHOT</version>-->
 <!--        </dependency>-->
 <!--        </dependency>-->
         <!-- 排除Tomcat容器 -->
         <!-- 排除Tomcat容器 -->
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-web</artifactId>
-            <!-- 移除掉默认支持的 Tomcat -->
-            <exclusions>
-                <exclusion>
-                    <groupId>org.springframework.boot</groupId>
-                    <artifactId>spring-boot-starter-tomcat</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
+<!--        <dependency>-->
+<!--            <groupId>org.springframework.boot</groupId>-->
+<!--            <artifactId>spring-boot-starter-web</artifactId>-->
+<!--            &lt;!&ndash; 移除掉默认支持的 Tomcat &ndash;&gt;-->
+<!--            <exclusions>-->
+<!--                <exclusion>-->
+<!--                    <groupId>org.springframework.boot</groupId>-->
+<!--                    <artifactId>spring-boot-starter-tomcat</artifactId>-->
+<!--                </exclusion>-->
+<!--            </exclusions>-->
+<!--        </dependency>-->
         <!-- 添加 Undertow 容器 -->
         <!-- 添加 Undertow 容器 -->
         <dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-undertow</artifactId>
             <artifactId>spring-boot-starter-undertow</artifactId>
         </dependency>
         </dependency>
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-test</artifactId>
-            <scope>test</scope>
-        </dependency>
+<!--        <dependency>-->
+<!--            <groupId>org.springframework.boot</groupId>-->
+<!--            <artifactId>spring-boot-starter-test</artifactId>-->
+<!--            <scope>test</scope>-->
+<!--        </dependency>-->
         <!--rabbitmq-->
         <!--rabbitmq-->
         <dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-amqp</artifactId>
             <artifactId>spring-boot-starter-amqp</artifactId>
         </dependency>
         </dependency>
         <!-- actuator -->
         <!-- actuator -->
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-actuator</artifactId>
-        </dependency>
+<!--        <dependency>-->
+<!--            <groupId>org.springframework.boot</groupId>-->
+<!--            <artifactId>spring-boot-starter-actuator</artifactId>-->
+<!--        </dependency>-->
 <!--        <dependency>-->
 <!--        <dependency>-->
 <!--            <groupId>com.huimv</groupId>-->
 <!--            <groupId>com.huimv</groupId>-->
 <!--            <artifactId>huimv-eartag2-common</artifactId>-->
 <!--            <artifactId>huimv-eartag2-common</artifactId>-->
@@ -79,12 +79,12 @@
             </plugin>
             </plugin>
 
 
             <!--  代码混淆proguard maven插件  -->
             <!--  代码混淆proguard maven插件  -->
-            <plugin>
+           <!-- <plugin>
                 <groupId>com.github.wvengen</groupId>
                 <groupId>com.github.wvengen</groupId>
                 <artifactId>proguard-maven-plugin</artifactId>
                 <artifactId>proguard-maven-plugin</artifactId>
                 <version>2.6.0</version>
                 <version>2.6.0</version>
                 <executions>
                 <executions>
-                    <!--   package时执行proguard   -->
+                    &lt;!&ndash;   package时执行proguard   &ndash;&gt;
                     <execution>
                     <execution>
                         <phase>package</phase>
                         <phase>package</phase>
                         <goals>
                         <goals>
@@ -94,28 +94,28 @@
                 </executions>
                 </executions>
                 <configuration>
                 <configuration>
                     <putLibraryJarsInTempDir>true</putLibraryJarsInTempDir>
                     <putLibraryJarsInTempDir>true</putLibraryJarsInTempDir>
-                    <!--  输入的jar包  -->
+                    &lt;!&ndash;  输入的jar包  &ndash;&gt;
                     <injar>${project.build.finalName}.jar</injar>
                     <injar>${project.build.finalName}.jar</injar>
-                    <!--  输出的jar包  -->
+                    &lt;!&ndash;  输出的jar包  &ndash;&gt;
                     <outjar>${project.build.finalName}.jar</outjar>
                     <outjar>${project.build.finalName}.jar</outjar>
-                    <!--  是否进行混淆,默认为true  -->
+                    &lt;!&ndash;  是否进行混淆,默认为true  &ndash;&gt;
                     <obfuscate>true</obfuscate>
                     <obfuscate>true</obfuscate>
-                    <!--  配置文件,通常为proguard.cfg,主要对options选项进行配置,所有的options选项都可以进行配置  -->
+                    &lt;!&ndash;  配置文件,通常为proguard.cfg,主要对options选项进行配置,所有的options选项都可以进行配置  &ndash;&gt;
                     <proguardInclude>../huimv-eartag2-eartag/proguard.cfg</proguardInclude>
                     <proguardInclude>../huimv-eartag2-eartag/proguard.cfg</proguardInclude>
-                    <!--  额外的jar,项目编译所需的jar  -->
+                    &lt;!&ndash;  额外的jar,项目编译所需的jar  &ndash;&gt;
                     <libs>
                     <libs>
                         <lib>${java.home}/lib/rt.jar</lib>
                         <lib>${java.home}/lib/rt.jar</lib>
-                        <!--<lib>${java.home}/lib/jce.jar</lib>-->
+                        &lt;!&ndash;<lib>${java.home}/lib/jce.jar</lib>&ndash;&gt;
                         <lib>${java.home}/lib/jsse.jar</lib>
                         <lib>${java.home}/lib/jsse.jar</lib>
                     </libs>
                     </libs>
-                    <!--  对输入jar进行过滤,如对META-INFO文件不处理  -->
+                    &lt;!&ndash;  对输入jar进行过滤,如对META-INFO文件不处理  &ndash;&gt;
                     <inLibsFilter>!META-INF/**,!META-INF/versions/**</inLibsFilter>
                     <inLibsFilter>!META-INF/**,!META-INF/versions/**</inLibsFilter>
-                    <!--  输出路径配置,必须包含injar标签中填写的jar  -->
+                    &lt;!&ndash;  输出路径配置,必须包含injar标签中填写的jar  &ndash;&gt;
                     <outputDirectory>${project.build.directory}</outputDirectory>
                     <outputDirectory>${project.build.directory}</outputDirectory>
-                    <!--  上面使用了conf配置文件,options无需配置  -->
-                    <!--<options></options>-->
+                    &lt;!&ndash;  上面使用了conf配置文件,options无需配置  &ndash;&gt;
+                    &lt;!&ndash;<options></options>&ndash;&gt;
                 </configuration>
                 </configuration>
-            </plugin>
+            </plugin>-->
         </plugins>
         </plugins>
     </build>
     </build>
 </project>
 </project>

+ 1 - 2
huimv-eartag2-platform/huimv-eartag2-eartag/src/main/java/com/huimv/eartag2/eartag/listener/EartagListener.java

@@ -76,9 +76,8 @@ public class EartagListener {
         String type = askMap.get("type").toString();
         String type = askMap.get("type").toString();
         JSONObject dataJo = (JSONObject) askMap.get("data");
         JSONObject dataJo = (JSONObject) askMap.get("data");
         System.out.println("######## eartagJo="+dataJo);
         System.out.println("######## eartagJo="+dataJo);
-        if (type.trim().equalsIgnoreCase("eartag") &&  getAskTime(dataJo.getString("askTime"))) {
+        if (type.trim().equalsIgnoreCase("eartag") /*&&  getAskTime(dataJo.getString("askTime"))*/) {
             //{处理耳标数据}
             //{处理耳标数据}
-
             eartagService.handleEartag(dataJo);
             eartagService.handleEartag(dataJo);
             //调用省平台的接口,将耳标数据发送到省平台
             //调用省平台的接口,将耳标数据发送到省平台
 //            eartagService.sendSowProvincePlatform(dataJo,askText);
 //            eartagService.sendSowProvincePlatform(dataJo,askText);

+ 1 - 10
huimv-eartag2-platform/huimv-eartag2-eartag/src/main/java/com/huimv/eartag2/eartag/service/impl/DeviceServiceImpl.java

@@ -114,16 +114,7 @@ public class DeviceServiceImpl implements IDeviceService {
         }
         }
     }
     }
 
 
-    /**
-     * @Method      : saveDeviceHeartbeat
-     * @Description : 保存设备心跳数据
-     * @Params      : [dataJo]
-     * @Return      : void
-     * 
-     * @Author      : ZhuoNing
-     * @Date        : 2022/2/15       
-     * @Time        : 14:39
-     */
+
     @Override
     @Override
     public void saveDeviceHeartbeat(JSONObject dataJo) {
     public void saveDeviceHeartbeat(JSONObject dataJo) {
         String deviceCode = dataJo.getString("device");
         String deviceCode = dataJo.getString("device");

+ 5 - 9
huimv-eartag2-platform/huimv-eartag2-eartag/src/main/java/com/huimv/eartag2/eartag/service/impl/EartagServiceImpl.java

@@ -85,7 +85,7 @@ public class EartagServiceImpl implements IEartagService {
     private EartagAbnormalAlarmEntityRepo eartagAbnormalAlarmEntityRepo;
     private EartagAbnormalAlarmEntityRepo eartagAbnormalAlarmEntityRepo;
     @Autowired
     @Autowired
     private EartagAbnormalCountEntityRepo eartagAbnormalCountEntityRepo;
     private EartagAbnormalCountEntityRepo eartagAbnormalCountEntityRepo;
-    //    @Value("${alarm.maxTemp}")
+//        @Value("${alarm.maxTemp}")
 //    private String defaultMaxTemp;
 //    private String defaultMaxTemp;
 //    @Value("${alarm.minTemp}")
 //    @Value("${alarm.minTemp}")
 //    private String defaultMinTemp;
 //    private String defaultMinTemp;
@@ -133,7 +133,7 @@ public class EartagServiceImpl implements IEartagService {
             updateDeviceRegister(deviceCode, nowTimestamp, todayDate, farmId);
             updateDeviceRegister(deviceCode, nowTimestamp, todayDate, farmId);
 
 
             //{更新耳标注册信息}
             //{更新耳标注册信息}
-//            updateEartagRegister(earmark, deviceCode, bat, nowTimestamp, todayDate, farmId);
+            updateEartagRegister(earmark, deviceCode, bat, nowTimestamp, todayDate, farmId);
 
 
             //{更新耳标注册信息}
             //{更新耳标注册信息}
             updateEartagRegister2(earmark, deviceCode, bat, nowTimestamp, todayDate, farmId, dataJo);
             updateEartagRegister2(earmark, deviceCode, bat, nowTimestamp, todayDate, farmId, dataJo);
@@ -143,19 +143,15 @@ public class EartagServiceImpl implements IEartagService {
 
 
             //{更新设备在线统计}
             //{更新设备在线统计}
             updateDeviceOnline(earmark, deviceCode, todayDateText, nowTimestamp, todayDate, dataJo, farmId);
             updateDeviceOnline(earmark, deviceCode, todayDateText, nowTimestamp, todayDate, dataJo, farmId);
-
             //{更新耳标在线统计}
             //{更新耳标在线统计}
             updateEartagOnline(earmark, deviceCode, todayDateText, todayDate, nowTimestamp, dataJo, farmId);
             updateEartagOnline(earmark, deviceCode, todayDateText, todayDate, nowTimestamp, dataJo, farmId);
-
             //{更新耳标连线状态}
             //{更新耳标连线状态}
             updateEartagLiveStatus(earmark, deviceCode, todayDateText, todayDate, nowTimestamp, dataJo, farmId);
             updateEartagLiveStatus(earmark, deviceCode, todayDateText, todayDate, nowTimestamp, dataJo, farmId);
-
             //{更新耳标设备在线关联统计}
             //{更新耳标设备在线关联统计}
             updateEartagDeviceOnlineCount(earmark, deviceCode, todayDateText, todayDate, nowTimestamp, farmId);
             updateEartagDeviceOnlineCount(earmark, deviceCode, todayDateText, todayDate, nowTimestamp, farmId);
 
 
             //{异常统计和异常报警}
             //{异常统计和异常报警}
 //            abnormalCountAndAlarm(dataJo, todayDate, nowTimestamp, farmId);
 //            abnormalCountAndAlarm(dataJo, todayDate, nowTimestamp, farmId);
-
             //判断该设备编号是否存在牧场缓存在线集合当中;
             //判断该设备编号是否存在牧场缓存在线集合当中;
             if (!cacheService.isExistEartagOnlineSet(farmId, earmark, todayDateText)) {
             if (!cacheService.isExistEartagOnlineSet(farmId, earmark, todayDateText)) {
                 //更新总状态数据
                 //更新总状态数据
@@ -779,6 +775,7 @@ public class EartagServiceImpl implements IEartagService {
             log.info("该耳标不存在(earmark=" + earmark + ",farmId=" + farmId + ")");
             log.info("该耳标不存在(earmark=" + earmark + ",farmId=" + farmId + ")");
             return;
             return;
         }
         }
+        System.out.println("test->1");
         Integer unitId = eartagEartagRegister2Entity.getUnitId();
         Integer unitId = eartagEartagRegister2Entity.getUnitId();
         Optional<EartagOnlineStatusEntity> optionEartagStatus = eartagOnlineStatusEntityRepo.findLastOne(farmId, unitId);
         Optional<EartagOnlineStatusEntity> optionEartagStatus = eartagOnlineStatusEntityRepo.findLastOne(farmId, unitId);
         if (!optionEartagStatus.isPresent()) {
         if (!optionEartagStatus.isPresent()) {
@@ -786,8 +783,6 @@ public class EartagServiceImpl implements IEartagService {
             return;
             return;
         }
         }
         EartagOnlineStatusEntity eartagOnlineStatusEntity = optionEartagStatus.get();
         EartagOnlineStatusEntity eartagOnlineStatusEntity = optionEartagStatus.get();
-//        System.out.println("onlineEarmark=" + eartagOnlineStatusEntity.getOnlineEarmark());
-//        System.out.println("offlineEarmark=" + eartagOnlineStatusEntity.getOfflineEarmark());
         if (eartagOnlineStatusEntity.getOnlineEarmark().indexOf(earmark) == -1 && eartagOnlineStatusEntity.getOfflineEarmark().indexOf(earmark) == -1) {
         if (eartagOnlineStatusEntity.getOnlineEarmark().indexOf(earmark) == -1 && eartagOnlineStatusEntity.getOfflineEarmark().indexOf(earmark) == -1) {
             //新耳标(在线,离线都不包含该耳标)
             //新耳标(在线,离线都不包含该耳标)
             log.info("耳标连线状态统计:增加新耳标[" + earmark + "]");
             log.info("耳标连线状态统计:增加新耳标[" + earmark + "]");
@@ -799,6 +794,7 @@ public class EartagServiceImpl implements IEartagService {
             eartagOnlineStatusEntity.setTotal(eartagOnlineStatusEntity.getTotal() + 1);
             eartagOnlineStatusEntity.setTotal(eartagOnlineStatusEntity.getTotal() + 1);
             eartagOnlineStatusEntity.setOnline(eartagOnlineStatusEntity.getOnline() + 1);
             eartagOnlineStatusEntity.setOnline(eartagOnlineStatusEntity.getOnline() + 1);
             eartagOnlineStatusEntity.setOnlineEarmark(onlineEarmark);
             eartagOnlineStatusEntity.setOnlineEarmark(onlineEarmark);
+            System.out.println("test->3");
             eartagOnlineStatusEntityRepo.saveAndFlush(eartagOnlineStatusEntity);
             eartagOnlineStatusEntityRepo.saveAndFlush(eartagOnlineStatusEntity);
         } else if (eartagOnlineStatusEntity.getOfflineEarmark().indexOf(earmark) != -1) {
         } else if (eartagOnlineStatusEntity.getOfflineEarmark().indexOf(earmark) != -1) {
             log.info("耳标连线状态统计:耳标离线--在线[" + earmark + "]");
             log.info("耳标连线状态统计:耳标离线--在线[" + earmark + "]");
@@ -1396,7 +1392,7 @@ public class EartagServiceImpl implements IEartagService {
             eartagRegisterEntity.setStageName(stageName);
             eartagRegisterEntity.setStageName(stageName);
             eartagRegisterEntity.setEarTemp2(eartagJo.getFloat("earTemp2"));
             eartagRegisterEntity.setEarTemp2(eartagJo.getFloat("earTemp2"));
             eartagRegisterEntity.setEarTemp1(eartagJo.getFloat("earTemp1"));
             eartagRegisterEntity.setEarTemp1(eartagJo.getFloat("earTemp1"));
-//            eartagRegisterEntity.setEnvTemp1(eartagJo.getFloat("envTemp1"));
+            eartagRegisterEntity.setEnvTemp1(eartagJo.getFloat("envTemp1"));
             //相对运动量
             //相对运动量
             eartagRegisterEntity.setAct(lastAct);
             eartagRegisterEntity.setAct(lastAct);
             eartagRegisterEntity.setSignal1(Integer.parseInt(eartagJo.getString("signal")));
             eartagRegisterEntity.setSignal1(Integer.parseInt(eartagJo.getString("signal")));

+ 7 - 4
huimv-eartag2-platform/huimv-eartag2-eartag/src/main/resources/application-prod2.yml

@@ -20,9 +20,8 @@ spring:
     open-in-view: true
     open-in-view: true
 
 
   rabbitmq:
   rabbitmq:
-    host: 121.36.134.218
 #    host: 139.9.172.209
 #    host: 139.9.172.209
-#    host: 10.0.0.14
+    host: 121.36.134.218
     port: 5672
     port: 5672
     username: admin
     username: admin
     password: admin
     password: admin
@@ -33,9 +32,10 @@ spring:
     listener:
     listener:
       simple:
       simple:
         acknowledge-mode: none  #消费端不需要确认
         acknowledge-mode: none  #消费端不需要确认
+        concurrency: 10 # 消费端的监听个数(即@RabbitListener开启几个线程去处理数据。)
+        max-concurrency: 100 # 消费端的监听最大个数
+        prefetch: 10
 #        acknowledge-mode: auto
 #        acknowledge-mode: auto
-
-
   #redis
   #redis
   redis:
   redis:
     database: 0
     database: 0
@@ -141,3 +141,6 @@ mybatis-plus:
 #    database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
 #    database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
 #    open-in-view: true
 #    open-in-view: true
 
 
+redis:
+  expire:
+    eartag_online_set: 25

+ 6 - 6
huimv-eartag2-platform/huimv-eartag2-eartag/src/main/resources/application.properties

@@ -1,13 +1,13 @@
 #spring.profiles.active=test
 #spring.profiles.active=test
 #spring.profiles.active=local
 #spring.profiles.active=local
 #spring.profiles.active=dev
 #spring.profiles.active=dev
-#spring.profiles.active=prod2
-spring.profiles.active=prod3
+spring.profiles.active=prod2
+#spring.profiles.active=prod3
 #spring.profiles.active=test2
 #spring.profiles.active=test2
 
 
-device.register.prefix=device_register_
-redis.expire.eartag_online_set=25
+#device.register.prefix=device_register_
+#redis.expire.eartag_online_set=25
 
 
 #
 #
-alarm.maxTemp=40
-alarm.minTemp=30
+#alarm.maxTemp=40
+#alarm.minTemp=30

+ 54 - 54
huimv-eartag2-platform/huimv-eartag2-input/pom.xml

@@ -20,7 +20,7 @@
         <dependency>
         <dependency>
             <groupId>com.huimv</groupId>
             <groupId>com.huimv</groupId>
             <artifactId>huimv-eartag2-common</artifactId>
             <artifactId>huimv-eartag2-common</artifactId>
-            <version>0.0.2-SNAPSHOT</version>
+            <version>0.0.1-SNAPSHOT</version>
         </dependency>
         </dependency>
         <!-- 排除Tomcat容器 -->
         <!-- 排除Tomcat容器 -->
         <dependency>
         <dependency>
@@ -52,58 +52,58 @@
         </dependency>
         </dependency>
     </dependencies>
     </dependencies>
 
 
-        <build>
-            <plugins>
-                <!--  -->
-                <plugin>
-                    <groupId>org.springframework.boot</groupId>
-                    <artifactId>spring-boot-maven-plugin</artifactId>
-                </plugin>
-                <!--  -->
-                <plugin>
-                    <groupId>org.apache.maven.plugins</groupId>
-                    <artifactId>maven-resources-plugin</artifactId>
-                    <version>2.6</version>
-                </plugin>
+<!--        <build>-->
+<!--            <plugins>-->
+<!--                &lt;!&ndash;  &ndash;&gt;-->
+<!--                <plugin>-->
+<!--                    <groupId>org.springframework.boot</groupId>-->
+<!--                    <artifactId>spring-boot-maven-plugin</artifactId>-->
+<!--                </plugin>-->
+<!--                &lt;!&ndash;  &ndash;&gt;-->
+<!--                <plugin>-->
+<!--                    <groupId>org.apache.maven.plugins</groupId>-->
+<!--                    <artifactId>maven-resources-plugin</artifactId>-->
+<!--                    <version>2.6</version>-->
+<!--                </plugin>-->
 
 
-                <!--  代码混淆proguard maven插件  -->
-                <plugin>
-                    <groupId>com.github.wvengen</groupId>
-                    <artifactId>proguard-maven-plugin</artifactId>
-                    <version>2.6.0</version>
-                    <executions>
-                        <!--   package时执行proguard   -->
-                        <execution>
-                            <phase>package</phase>
-                            <goals>
-                                <goal>proguard</goal>
-                            </goals>
-                        </execution>
-                    </executions>
-                    <configuration>
-                        <putLibraryJarsInTempDir>true</putLibraryJarsInTempDir>
-                        <!--  输入的jar包  -->
-                        <injar>${project.build.finalName}.jar</injar>
-                        <!--  输出的jar包  -->
-                        <outjar>${project.build.finalName}.jar</outjar>
-                        <!--  是否进行混淆,默认为true  -->
-                        <obfuscate>true</obfuscate>
-                        <!--  配置文件,通常为proguard.cfg,主要对options选项进行配置,所有的options选项都可以进行配置  -->
-                        <proguardInclude>../huimv-eartag2-eartag/proguard.cfg</proguardInclude>
-                        <!--  额外的jar,项目编译所需的jar  -->
-                        <libs>
-                            <lib>${java.home}/lib/rt.jar</lib>
-                            <!--<lib>${java.home}/lib/jce.jar</lib>-->
-                            <lib>${java.home}/lib/jsse.jar</lib>
-                        </libs>
-                        <!--  对输入jar进行过滤,如对META-INFO文件不处理  -->
-                        <inLibsFilter>!META-INF/**,!META-INF/versions/**</inLibsFilter>
-                        <!--  输出路径配置,必须包含injar标签中填写的jar  -->
-                        <outputDirectory>${project.build.directory}</outputDirectory>
-                        <!--  上面使用了conf配置文件,options无需配置  -->
-                        <!--<options></options>-->
-                    </configuration>
-                </plugin>
-            </plugins>
-        </build>
+<!--                &lt;!&ndash;  代码混淆proguard maven插件  &ndash;&gt;-->
+<!--                <plugin>-->
+<!--                    <groupId>com.github.wvengen</groupId>-->
+<!--                    <artifactId>proguard-maven-plugin</artifactId>-->
+<!--                    <version>2.6.0</version>-->
+<!--                    <executions>-->
+<!--                        &lt;!&ndash;   package时执行proguard   &ndash;&gt;-->
+<!--                        <execution>-->
+<!--                            <phase>package</phase>-->
+<!--                            <goals>-->
+<!--                                <goal>proguard</goal>-->
+<!--                            </goals>-->
+<!--                        </execution>-->
+<!--                    </executions>-->
+<!--                    <configuration>-->
+<!--                        <putLibraryJarsInTempDir>true</putLibraryJarsInTempDir>-->
+<!--                        &lt;!&ndash;  输入的jar包  &ndash;&gt;-->
+<!--                        <injar>${project.build.finalName}.jar</injar>-->
+<!--                        &lt;!&ndash;  输出的jar包  &ndash;&gt;-->
+<!--                        <outjar>${project.build.finalName}.jar</outjar>-->
+<!--                        &lt;!&ndash;  是否进行混淆,默认为true  &ndash;&gt;-->
+<!--                        <obfuscate>true</obfuscate>-->
+<!--                        &lt;!&ndash;  配置文件,通常为proguard.cfg,主要对options选项进行配置,所有的options选项都可以进行配置  &ndash;&gt;-->
+<!--                        <proguardInclude>../huimv-eartag2-eartag/proguard.cfg</proguardInclude>-->
+<!--                        &lt;!&ndash;  额外的jar,项目编译所需的jar  &ndash;&gt;-->
+<!--                        <libs>-->
+<!--                            <lib>${java.home}/lib/rt.jar</lib>-->
+<!--                            &lt;!&ndash;<lib>${java.home}/lib/jce.jar</lib>&ndash;&gt;-->
+<!--                            <lib>${java.home}/lib/jsse.jar</lib>-->
+<!--                        </libs>-->
+<!--                        &lt;!&ndash;  对输入jar进行过滤,如对META-INFO文件不处理  &ndash;&gt;-->
+<!--                        <inLibsFilter>!META-INF/**,!META-INF/versions/**</inLibsFilter>-->
+<!--                        &lt;!&ndash;  输出路径配置,必须包含injar标签中填写的jar  &ndash;&gt;-->
+<!--                        <outputDirectory>${project.build.directory}</outputDirectory>-->
+<!--                        &lt;!&ndash;  上面使用了conf配置文件,options无需配置  &ndash;&gt;-->
+<!--                        &lt;!&ndash;<options></options>&ndash;&gt;-->
+<!--                    </configuration>-->
+<!--                </plugin>-->
+<!--            </plugins>-->
+<!--        </build>-->
 </project>
 </project>

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

@@ -162,6 +162,7 @@ public class EartagServerHandler2 extends ChannelInboundHandlerAdapter {
                 //处理获取设备编码命令
                 //处理获取设备编码命令
                 //{读取设备编码}
                 //{读取设备编码}
                 String deviceCode = dataService.getDeviceCodeByChipId(idCode);
                 String deviceCode = dataService.getDeviceCodeByChipId(idCode);
+//                String deviceCode = getDeviceCodeByChipIdFromMySQL(idCode);
                 log.info("获取设备编码结果,芯片id>>" + idCode + " ,deviceCode>>" + deviceCode);
                 log.info("获取设备编码结果,芯片id>>" + idCode + " ,deviceCode>>" + deviceCode);
                 if (deviceCode != null) {
                 if (deviceCode != null) {
                     String answer = "hm+1+0+" + deviceCode + "+123+8+end";
                     String answer = "hm+1+0+" + deviceCode + "+123+8+end";

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

@@ -299,6 +299,7 @@ public class DataServiceImpl implements IDataService {
 //            log.info("开始发送消息");
 //            log.info("开始发送消息");
 //            correlationData.setId("100");
 //            correlationData.setId("100");
             //发送到耳标处理消息队列
             //发送到耳标处理消息队列
+
             rabbitTemplate.convertAndSend(Const.EXCHANGE_ASK_EARTAG, Const.ROUTING_KEY_ASK_EARTAG, map);
             rabbitTemplate.convertAndSend(Const.EXCHANGE_ASK_EARTAG, Const.ROUTING_KEY_ASK_EARTAG, map);
 //        } catch (AmqpTimeoutException e) {
 //        } catch (AmqpTimeoutException e) {
 //            log.error("met timeout exception: ", e);
 //            log.error("met timeout exception: ", e);

+ 9 - 8
huimv-eartag2-platform/huimv-eartag2-input/src/main/java/com/huimv/eartag2/service/impl/DeviceServiceImpl.java

@@ -59,15 +59,16 @@ public class DeviceServiceImpl implements IDeviceService {
 
 
     @Override
     @Override
     public String getDeviceCodeByChipId(String chipId) {
     public String getDeviceCodeByChipId(String chipId) {
+        return getDeviceCodeByChipIdFromMySQL(chipId);
         //{}
         //{}
-        Object deviceCodeObj = cacheService.getDeviceCodeByChipId(chipId);
-        if(deviceCodeObj != null){
-            return (String)deviceCodeObj;
-        }else{
-//            return null;
-            //{从数据库读取设备编码返回}
-            return getDeviceCodeByChipIdFromMySQL(chipId);
-        }
+//        Object deviceCodeObj = cacheService.getDeviceCodeByChipId(chipId);
+//        if(deviceCodeObj != null){
+//            return (String)deviceCodeObj;
+//        }else{
+////            return null;
+//            //{从数据库读取设备编码返回}
+//            return getDeviceCodeByChipIdFromMySQL(chipId);
+//        }
     }
     }
 
 
     //从数据库读取deviceCode
     //从数据库读取deviceCode

+ 5 - 0
huimv-eartag2-platform/huimv-eartag2-input/src/main/resources/application-prod2.yml

@@ -33,6 +33,11 @@ spring:
     publisher-confirm-type: correlated
     publisher-confirm-type: correlated
     #确认消息已发送到队列(Queue)
     #确认消息已发送到队列(Queue)
     publisher-returns: true
     publisher-returns: true
+    listener:
+      simple:
+        concurrency: 10 # 消费端的监听个数(即@RabbitListener开启几个线程去处理数据。)
+        max-concurrency: 100 # 消费端的监听最大个数
+        prefetch: 10
 
 
 
 
   #redis
   #redis

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

@@ -1,5 +1,5 @@
-spring.profiles.active=prod3
-#spring.profiles.active=prod2
+#spring.profiles.active=prod3
+spring.profiles.active=prod2
 #spring.profiles.active=dev
 #spring.profiles.active=dev
 
 
 #¿ªÆô½¡¿µ¼à¿Ø
 #¿ªÆô½¡¿µ¼à¿Ø

+ 5 - 3
huimv-eartag2-platform/huimv-eartag2-manage2/src/main/java/com/huimv/eartag2/manage2/netty/EartagServerHandler2.java

@@ -41,8 +41,10 @@ import java.util.Date;
 @Slf4j
 @Slf4j
 public class EartagServerHandler2 extends ChannelInboundHandlerAdapter {
 public class EartagServerHandler2 extends ChannelInboundHandlerAdapter {
     private StringBuilder askTextSb = null;
     private StringBuilder askTextSb = null;
-@Autowired
-private IEartagEartagRegister2Service eartagRegisterService;
+
+    @Autowired
+    private IEartagEartagRegister2Service eartagRegisterService;
+
     @Autowired
     @Autowired
     private IEartagDeviceRegisterService deviceRegisterService;
     private IEartagDeviceRegisterService deviceRegisterService;
 
 
@@ -143,7 +145,7 @@ private IEartagEartagRegister2Service eartagRegisterService;
                     eartagEartagRegister.setCreateDate(new Date());
                     eartagEartagRegister.setCreateDate(new Date());
                     eartagRegisterService.save(eartagEartagRegister);
                     eartagRegisterService.save(eartagEartagRegister);
                 }
                 }
-//                WebSocket.sendMessage("true");
+                WebSocket.sendMessage("true");
             }
             }
         }
         }
     }
     }

+ 2 - 2
huimv-eartag2-platform/huimv-eartag2-manage2/src/main/resources/application-prod2.yml

@@ -47,7 +47,7 @@ spring:
 
 
 mybatis-plus:
 mybatis-plus:
   configuration:
   configuration:
-      log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
-#    log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
+#      log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+    log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
   # mapper.xml文件所存放的位置
   # mapper.xml文件所存放的位置
   mapper-locations: classpath*:com/huimv/eartag2/manage2/mapper/xml/*.xml  # 不加这一行出错:“org.apache.ibatis.binding.BindingException:  Invalid bound statement (not found)”
   mapper-locations: classpath*:com/huimv/eartag2/manage2/mapper/xml/*.xml  # 不加这一行出错:“org.apache.ibatis.binding.BindingException:  Invalid bound statement (not found)”

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

@@ -1,7 +1,7 @@
 #spring.profiles.active=dev2
 #spring.profiles.active=dev2
-#spring.profiles.active=prod3
+spring.profiles.active=prod3
 #spring.profiles.active=prod
 #spring.profiles.active=prod
-spring.profiles.active=prod2
+#spring.profiles.active=prod2
 
 
 # mysql:/cache:
 # mysql:/cache:
 device.online.access_mode=mysql
 device.online.access_mode=mysql

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

@@ -17,6 +17,7 @@
         <groupId>org.springframework.boot</groupId>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-parent</artifactId>
         <artifactId>spring-boot-starter-parent</artifactId>
         <version>2.6.2</version>
         <version>2.6.2</version>
+<!--        <version>2.3.1.RELEASE</version>-->
     </parent>
     </parent>
     <groupId>com.huimv</groupId>
     <groupId>com.huimv</groupId>
     <artifactId>huimv-eartag2-platform</artifactId>
     <artifactId>huimv-eartag2-platform</artifactId>