Procházet zdrojové kódy

增加读取温度接口

zhuoning před 3 roky
rodič
revize
4eef7f5aa6

+ 29 - 0
huimv-eartag-location/src/main/java/com/huimv/location/controller/BeaconController.java

@@ -1,5 +1,6 @@
 package com.huimv.location.controller;
 
+import com.alibaba.fastjson.JSONObject;
 import com.huimv.location.dao.entity.BeaconEntity;
 import com.huimv.location.service.BeaconService;
 import com.huimv.location.utils.HttpClient;
@@ -30,11 +31,39 @@ public class BeaconController {
 //        httpClient.doGet("http://192.168.1.17:44444/beacons/32b00ae08dfc");
 //    }
 
+    /**
+     * @Method      : getOneBeaconInfo
+     * @Description : 
+     * @Params      : [mac, startTime, endTime]
+     * @Return      : java.util.List<com.huimv.location.dao.entity.BeaconEntity>
+     * 
+     * @Author      : ZhuoNing
+     * @Date        : 2021/9/29       
+     * @Time        : 19:30
+     */
     @RequestMapping(value = "/getOneBeacon",method = RequestMethod.GET)
     public List<BeaconEntity> getOneBeaconInfo(@RequestParam(name = "id") String mac, @RequestParam(name = "startTime") String startTime, @RequestParam(name = "endTime") String endTime){
         return beaconService.getOneBeacons(mac,startTime,endTime);
     }
 
+    /*
+     * @Method      : getTemp
+     * @Description : 获取温度
+     * @Params      : [mac, startTime, endTime]
+     * @Return      : java.util.List<com.huimv.location.dao.entity.BeaconEntity>
+     * 
+     * @Author      : ZhuoNing
+     * @Date        : 2021/9/29       
+     * @Time        : 18:55
+     */
+    @RequestMapping(value = "/getTemp",method = RequestMethod.GET)
+    public JSONObject getTemp(@RequestParam(name = "mac") String mac,@RequestParam(name = "sum") String sum){
+        int quantity = 10;
+        if(sum != null){
+            quantity = Integer.parseInt(sum);
+        }
+        return beaconService.getTemp(mac,quantity);
+    }
 
 
 }

+ 92 - 0
huimv-eartag-location/src/main/java/com/huimv/location/dao/entity/BindEartagEntity.java

@@ -0,0 +1,92 @@
+package com.huimv.location.dao.entity;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+@Entity
+@Table(name = "bind_eartag")
+public class BindEartagEntity implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id", nullable = false)
+    private Integer id;
+
+    @Column(name = "eartag_no")
+    private String eartagNo;
+
+    @Column(name = "beacon_no")
+    private String beaconNo;
+
+    @Column(name = "bind_time")
+    private Timestamp bindTime;
+
+    @Column(name = "status")
+    private Integer status;
+
+    @Column(name = "remark")
+    private String remark;
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setEartagNo(String eartagNo) {
+        this.eartagNo = eartagNo;
+    }
+
+    public String getEartagNo() {
+        return eartagNo;
+    }
+
+    public void setBeaconNo(String beaconNo) {
+        this.beaconNo = beaconNo;
+    }
+
+    public String getBeaconNo() {
+        return beaconNo;
+    }
+
+    public void setBindTime(Timestamp bindTime) {
+        this.bindTime = bindTime;
+    }
+
+    public Timestamp getBindTime() {
+        return bindTime;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    @Override
+    public String toString() {
+        return "BindEartagEntity{" +
+                "id=" + id + '\'' +
+                "eartagNo=" + eartagNo + '\'' +
+                "beaconNo=" + beaconNo + '\'' +
+                "bindTime=" + bindTime + '\'' +
+                "status=" + status + '\'' +
+                "remark=" + remark + '\'' +
+                '}';
+    }
+}

+ 128 - 0
huimv-eartag-location/src/main/java/com/huimv/location/dao/entity/EartagDampnessEntity.java

@@ -0,0 +1,128 @@
+package com.huimv.location.dao.entity;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+@Entity
+@Table(name = "eartag_dampness")
+public class EartagDampnessEntity implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id", nullable = false)
+    private Integer id;
+
+    @Column(name = "header")
+    private String header;
+
+    @Column(name = "device_id")
+    private Integer deviceId;
+
+    @Column(name = "cmd")
+    private Integer cmd;
+
+    @Column(name = "serial_no")
+    private Integer serialNo;
+
+    @Column(name = "value")
+    private Double value;
+
+    @Column(name = "create_date")
+    private Timestamp createDate;
+
+    @Column(name = "check_number")
+    private Integer checkNumber;
+
+    @Column(name = "tail")
+    private String tail;
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setHeader(String header) {
+        this.header = header;
+    }
+
+    public String getHeader() {
+        return header;
+    }
+
+    public void setDeviceId(Integer deviceId) {
+        this.deviceId = deviceId;
+    }
+
+    public Integer getDeviceId() {
+        return deviceId;
+    }
+
+    public void setCmd(Integer cmd) {
+        this.cmd = cmd;
+    }
+
+    public Integer getCmd() {
+        return cmd;
+    }
+
+    public void setSerialNo(Integer serialNo) {
+        this.serialNo = serialNo;
+    }
+
+    public Integer getSerialNo() {
+        return serialNo;
+    }
+
+    public void setValue(Double value) {
+        this.value = value;
+    }
+
+    public Double getValue() {
+        return value;
+    }
+
+    public void setCreateDate(Timestamp createDate) {
+        this.createDate = createDate;
+    }
+
+    public Timestamp getCreateDate() {
+        return createDate;
+    }
+
+    public void setCheckNumber(Integer checkNumber) {
+        this.checkNumber = checkNumber;
+    }
+
+    public Integer getCheckNumber() {
+        return checkNumber;
+    }
+
+    public void setTail(String tail) {
+        this.tail = tail;
+    }
+
+    public String getTail() {
+        return tail;
+    }
+
+    @Override
+    public String toString() {
+        return "EartagDampnessEntity{" +
+                "id=" + id + '\'' +
+                "header=" + header + '\'' +
+                "deviceId=" + deviceId + '\'' +
+                "cmd=" + cmd + '\'' +
+                "serialNo=" + serialNo + '\'' +
+                "value=" + value + '\'' +
+                "createDate=" + createDate + '\'' +
+                "checkNumber=" + checkNumber + '\'' +
+                "tail=" + tail + '\'' +
+                '}';
+    }
+}

+ 386 - 0
huimv-eartag-location/src/main/java/com/huimv/location/dao/entity/EartagDataEntity.java

@@ -0,0 +1,386 @@
+package com.huimv.location.dao.entity;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+@Entity
+@Table(name = "eartag_data")
+public class EartagDataEntity implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id", nullable = false)
+    private Integer id;
+
+    @Column(name = "header")
+    private String header;
+
+    /**
+     * 设备id
+     */
+    @Column(name = "SBID")
+    private String SBID;
+
+    /**
+     * 命令
+     */
+    @Column(name = "CMD")
+    private Integer CMD;
+
+    /**
+     * 版本
+     */
+    @Column(name = "version")
+    private String version;
+
+    /**
+     * 序列号
+     */
+    @Column(name = "serial")
+    private Integer serial;
+
+    /**
+     * 耳标id
+     */
+    @Column(name = "eartag_id")
+    private String eartagId;
+
+    /**
+     * 电量
+     */
+    @Column(name = "dl")
+    private Integer dl;
+
+    /**
+     * 环境温度
+     */
+    @Column(name = "NBWD")
+    private Double NBWD;
+
+    /**
+     * 耳标温度
+     */
+    @Column(name = "EBWD")
+    private Double EBWD;
+
+    /**
+     * ntc
+     */
+    @Column(name = "ntc")
+    private Integer ntc;
+
+    /**
+     * 运动量
+     */
+    @Column(name = "YDL")
+    private Integer YDL;
+
+    /**
+     * 区间运动量
+     */
+    @Column(name = "qjydl")
+    private Integer qjydl;
+
+    /**
+     * 重启数
+     */
+    @Column(name = "CQS")
+    private Integer CQS;
+
+    /**
+     * rssi
+     */
+    @Column(name = "RSSYI")
+    private Integer RSSYI;
+
+    /**
+     * 时间戳
+     */
+    @Column(name = "timestamp", nullable = false)
+//    @JsonFormat(shape= JsonFormat.Shape.STRING,pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
+//    @Temporal(TemporalType.TIMESTAMP)
+//    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Timestamp timestamp;
+
+    /**
+     * 校验码
+     */
+    @Column(name = "check_number")
+    private Integer checkNumber;
+
+    /**
+     * 命令尾
+     */
+    @Column(name = "MLW")
+    private String MLW;
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setHeader(String header) {
+        this.header = header;
+    }
+
+    public String getHeader() {
+        return header;
+    }
+
+    /**
+     * 设备id
+     */
+    public void setSBID(String SBID) {
+        this.SBID = SBID;
+    }
+
+    /**
+     * 设备id
+     */
+    public String getSBID() {
+        return SBID;
+    }
+
+    /**
+     * 命令
+     */
+    public void setCMD(Integer CMD) {
+        this.CMD = CMD;
+    }
+
+    /**
+     * 命令
+     */
+    public Integer getCMD() {
+        return CMD;
+    }
+
+    /**
+     * 版本
+     */
+    public void setVersion(String version) {
+        this.version = version;
+    }
+
+    /**
+     * 版本
+     */
+    public String getVersion() {
+        return version;
+    }
+
+    /**
+     * 序列号
+     */
+    public void setSerial(Integer serial) {
+        this.serial = serial;
+    }
+
+    /**
+     * 序列号
+     */
+    public Integer getSerial() {
+        return serial;
+    }
+
+    /**
+     * 耳标id
+     */
+    public void setEartagId(String eartagId) {
+        this.eartagId = eartagId;
+    }
+
+    /**
+     * 耳标id
+     */
+    public String getEartagId() {
+        return eartagId;
+    }
+
+    /**
+     * 电量
+     */
+    public void setDl(Integer dl) {
+        this.dl = dl;
+    }
+
+    /**
+     * 电量
+     */
+    public Integer getDl() {
+        return dl;
+    }
+
+    /**
+     * 环境温度
+     */
+    public void setNBWD(Double NBWD) {
+        this.NBWD = NBWD;
+    }
+
+    /**
+     * 环境温度
+     */
+    public Double getNBWD() {
+        return NBWD;
+    }
+
+    /**
+     * 耳标温度
+     */
+    public void setEBWD(Double EBWD) {
+        this.EBWD = EBWD;
+    }
+
+    /**
+     * 耳标温度
+     */
+    public Double getEBWD() {
+        return EBWD;
+    }
+
+    /**
+     * ntc
+     */
+    public void setNtc(Integer ntc) {
+        this.ntc = ntc;
+    }
+
+    /**
+     * ntc
+     */
+    public Integer getNtc() {
+        return ntc;
+    }
+
+    /**
+     * 运动量
+     */
+    public void setYDL(Integer YDL) {
+        this.YDL = YDL;
+    }
+
+    /**
+     * 运动量
+     */
+    public Integer getYDL() {
+        return YDL;
+    }
+
+    /**
+     * 区间运动量
+     */
+    public void setQjydl(Integer qjydl) {
+        this.qjydl = qjydl;
+    }
+
+    /**
+     * 区间运动量
+     */
+    public Integer getQjydl() {
+        return qjydl;
+    }
+
+    /**
+     * 重启数
+     */
+    public void setCQS(Integer CQS) {
+        this.CQS = CQS;
+    }
+
+    /**
+     * 重启数
+     */
+    public Integer getCQS() {
+        return CQS;
+    }
+
+    /**
+     * rssi
+     */
+    public void setRSSYI(Integer RSSYI) {
+        this.RSSYI = RSSYI;
+    }
+
+    /**
+     * rssi
+     */
+    public Integer getRSSYI() {
+        return RSSYI;
+    }
+
+    /**
+     * 时间戳
+     */
+    public void setTimestamp(Timestamp timestamp) {
+        this.timestamp = timestamp;
+    }
+
+    /**
+     * 时间戳
+     */
+    public Timestamp getTimestamp() {
+        return timestamp;
+    }
+
+    /**
+     * 校验码
+     */
+    public void setCheckNumber(Integer checkNumber) {
+        this.checkNumber = checkNumber;
+    }
+
+    /**
+     * 校验码
+     */
+    public Integer getCheckNumber() {
+        return checkNumber;
+    }
+
+    /**
+     * 命令尾
+     */
+    public void setMLW(String MLW) {
+        this.MLW = MLW;
+    }
+
+    /**
+     * 命令尾
+     */
+    public String getMLW() {
+        return MLW;
+    }
+
+    @Override
+    public String toString() {
+        return "EartagDataEntity{" +
+                "id=" + id + '\'' +
+                "header=" + header + '\'' +
+                "SBID=" + SBID + '\'' +
+                "CMD=" + CMD + '\'' +
+                "version=" + version + '\'' +
+                "serial=" + serial + '\'' +
+                "eartagId=" + eartagId + '\'' +
+                "dl=" + dl + '\'' +
+                "NBWD=" + NBWD + '\'' +
+                "EBWD=" + EBWD + '\'' +
+                "ntc=" + ntc + '\'' +
+                "YDL=" + YDL + '\'' +
+                "qjydl=" + qjydl + '\'' +
+                "CQS=" + CQS + '\'' +
+                "RSSYI=" + RSSYI + '\'' +
+                "timestamp=" + timestamp + '\'' +
+                "checkNumber=" + checkNumber + '\'' +
+                "MLW=" + MLW + '\'' +
+                '}';
+    }
+}

+ 137 - 0
huimv-eartag-location/src/main/java/com/huimv/location/dao/entity/EartagTemperatureEntity.java

@@ -0,0 +1,137 @@
+package com.huimv.location.dao.entity;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+@Entity
+@Table(name = "eartag_temperature")
+public class EartagTemperatureEntity implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * id
+     */
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id", nullable = false)
+    private Integer id;
+
+    @Column(name = "header")
+    private String header;
+
+    @Column(name = "device_id")
+    private Integer deviceId;
+
+    @Column(name = "cmd")
+    private Integer cmd;
+
+    @Column(name = "serial_no")
+    private Integer serialNo;
+
+    @Column(name = "value")
+    private Double value;
+
+    @Column(name = "create_date", nullable = false)
+    private Timestamp createDate;
+
+    @Column(name = "check_number")
+    private Integer checkNumber;
+
+    @Column(name = "tail")
+    private String tail;
+
+    /**
+     * id
+     */
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    /**
+     * id
+     */
+    public Integer getId() {
+        return id;
+    }
+
+    public void setHeader(String header) {
+        this.header = header;
+    }
+
+    public String getHeader() {
+        return header;
+    }
+
+    public void setDeviceId(Integer deviceId) {
+        this.deviceId = deviceId;
+    }
+
+    public Integer getDeviceId() {
+        return deviceId;
+    }
+
+    public void setCmd(Integer cmd) {
+        this.cmd = cmd;
+    }
+
+    public Integer getCmd() {
+        return cmd;
+    }
+
+    public void setSerialNo(Integer serialNo) {
+        this.serialNo = serialNo;
+    }
+
+    public Integer getSerialNo() {
+        return serialNo;
+    }
+
+    public void setValue(Double value) {
+        this.value = value;
+    }
+
+    public Double getValue() {
+        return value;
+    }
+
+    public void setCreateDate(Timestamp createDate) {
+        this.createDate = createDate;
+    }
+
+    public Timestamp getCreateDate() {
+        return createDate;
+    }
+
+    public void setCheckNumber(Integer checkNumber) {
+        this.checkNumber = checkNumber;
+    }
+
+    public Integer getCheckNumber() {
+        return checkNumber;
+    }
+
+    public void setTail(String tail) {
+        this.tail = tail;
+    }
+
+    public String getTail() {
+        return tail;
+    }
+
+    @Override
+    public String toString() {
+        return "EartagTemperatureEntity{" +
+                "id=" + id + '\'' +
+                "header=" + header + '\'' +
+                "deviceId=" + deviceId + '\'' +
+                "cmd=" + cmd + '\'' +
+                "serialNo=" + serialNo + '\'' +
+                "value=" + value + '\'' +
+                "createDate=" + createDate + '\'' +
+                "checkNumber=" + checkNumber + '\'' +
+                "tail=" + tail + '\'' +
+                '}';
+    }
+}

+ 2 - 0
huimv-eartag-location/src/main/java/com/huimv/location/dao/repo/BeaconRepo.java

@@ -21,4 +21,6 @@ public interface BeaconRepo extends JpaRepository<BeaconEntity, Integer>, JpaSpe
      */
     @Query(nativeQuery = true,value = "SELECT * FROM beacon WHERE mac=?1 AND up_last_time >= ?2 AND up_last_time <= ?3 ORDER BY up_last_time2 ASC ")
     List<BeaconEntity> getByIdAndStartTimeAndEndTime(String mac, String startTime, String endTime);
+
+
 }

+ 12 - 0
huimv-eartag-location/src/main/java/com/huimv/location/dao/repo/BindEartagRepo.java

@@ -0,0 +1,12 @@
+package com.huimv.location.dao.repo;
+
+import com.huimv.location.dao.entity.BindEartagEntity;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Query;
+
+public interface BindEartagRepo extends JpaRepository<BindEartagEntity, Integer>, JpaSpecificationExecutor<BindEartagEntity> {
+
+    @Query(nativeQuery = true,value = "SELECT * FROM bind_eartag WHERE beacon_no=?1")
+    BindEartagEntity getEartagIdByMac(String mac);
+}

+ 9 - 0
huimv-eartag-location/src/main/java/com/huimv/location/dao/repo/EartagDampnessRepo.java

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

+ 15 - 0
huimv-eartag-location/src/main/java/com/huimv/location/dao/repo/EartagDataRepo.java

@@ -0,0 +1,15 @@
+package com.huimv.location.dao.repo;
+
+import com.huimv.location.dao.entity.BeaconEntity;
+import com.huimv.location.dao.entity.EartagDataEntity;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Query;
+
+import java.util.List;
+
+public interface EartagDataRepo extends JpaRepository<EartagDataEntity, Integer>, JpaSpecificationExecutor<EartagDataEntity> {
+
+    @Query(nativeQuery = true,value = "SELECT id,ebwd,timestamp,cmd,cqs,mlw,nbwd,rssyi,sbid,ydl,check_number,dl,eartag_id,header,ntc,qjydl,serial,version  FROM eartag_data WHERE eartag_id=?1 ORDER BY id DESC LIMIT ?2")
+    List<EartagDataEntity> getTempById(String eartagNo,int sum);
+}

+ 9 - 0
huimv-eartag-location/src/main/java/com/huimv/location/dao/repo/EartagTemperatureEntityRepository.java

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

+ 3 - 0
huimv-eartag-location/src/main/java/com/huimv/location/service/BeaconService.java

@@ -1,6 +1,7 @@
 package com.huimv.location.service;
 
 import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.huimv.location.dao.entity.BeaconEntity;
 
 import java.io.UnsupportedEncodingException;
@@ -15,6 +16,8 @@ public interface BeaconService {
 
     // 获取单个信标(耳标)数据
     List<BeaconEntity> getOneBeacons(String mac, String startTime, String endTime);
+
+    JSONObject getTemp(String mac,int sum);
 //
 //    saveLocation();
 }

+ 39 - 0
huimv-eartag-location/src/main/java/com/huimv/location/service/impl/BeaconServiceImpl.java

@@ -3,7 +3,11 @@ package com.huimv.location.service.impl;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.huimv.location.dao.entity.BeaconEntity;
+import com.huimv.location.dao.entity.BindEartagEntity;
+import com.huimv.location.dao.entity.EartagDataEntity;
 import com.huimv.location.dao.repo.BeaconRepo;
+import com.huimv.location.dao.repo.BindEartagRepo;
+import com.huimv.location.dao.repo.EartagDataRepo;
 import com.huimv.location.service.BeaconService;
 import com.huimv.location.utils.DataUtil;
 import com.huimv.location.utils.HttpClient;
@@ -13,6 +17,9 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import java.io.UnsupportedEncodingException;
+import java.sql.Timestamp;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -33,6 +40,12 @@ public class BeaconServiceImpl implements BeaconService {
     private com.huimv.location.utils.StringUtils stringUtils;
     @Autowired
     private BeaconRepo beaconRepo;
+    @Autowired
+    private BindEartagRepo bindEartagRepo;
+    @Autowired
+    private EartagDataRepo eartagDataRepo;
+
+    public static final String dateFormaterPattern1 = "yyyy-MM-dd HH:mm:ss";
 
 //    private final String host_url = "http://192.168.1.17:44444";
 //    private final String host_url = "http://localhost:44444";
@@ -140,6 +153,32 @@ public class BeaconServiceImpl implements BeaconService {
         return beaconRepo.getByIdAndStartTimeAndEndTime(mac,startTime,endTime);
     }
 
+    public static String formatDate(Date date, String pattern){
+        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
+        return sdf.format(date);
+    }
+
+    @Override
+    public JSONObject getTemp(String mac,int sum) {
+//        beaconRepo.getEartagIdByMac(mac);
+        BindEartagEntity bindEartagEntity = bindEartagRepo.getEartagIdByMac(mac);
+//        System.out.println("bindEartagEntity.getEartagNo()="+bindEartagEntity.getEartagNo());
+        //读取温度数据
+        List<EartagDataEntity> eartagList = eartagDataRepo.getTempById(bindEartagEntity.getEartagNo(),sum);
+        JSONObject eartagJo = new JSONObject();
+        JSONArray tempJa = new JSONArray();
+        JSONArray timeJa = new JSONArray();
+        for(int a=eartagList.size()-1;a>=0;a--){
+            EartagDataEntity eartagDataEntity = eartagList.get(a);
+            tempJa.add(eartagDataEntity.getEBWD());
+            Date date = eartagDataEntity.getTimestamp();
+            timeJa.add(formatDate(date,dateFormaterPattern1));
+        }
+        eartagJo.put("temp",tempJa);
+        eartagJo.put("time",timeJa);
+        return eartagJo;
+    }
+
     public JSONArray getBeaconMac(String data){
         JSONArray beaconMacJa = new JSONArray();
         String[] dataArray = data.split("\":\\{");

+ 1 - 1
huimv-eartag-location/src/main/java/com/huimv/location/task/LocationTask.java

@@ -35,6 +35,6 @@ public class LocationTask {
 //        String beacons = httpClient.doGet(host_url);
 //        System.out.println("=====>>>>>使用cron  {}"+ System.currentTimeMillis()+",i="+(i++)+" "+outData);
 
-        beaconService.saveBeacon();
+//        beaconService.saveBeacon();
     }
 }