|
@@ -0,0 +1,450 @@
|
|
|
+package com.huimv.management.socket.eartagrecive.service.impl;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.huimv.management.dao.EartagDataDao;
|
|
|
+import com.huimv.management.dao.ThresholdManagementDao;
|
|
|
+import com.huimv.management.dao.YearPigBaseDao;
|
|
|
+import com.huimv.management.entity.EartagDataEntity;
|
|
|
+import com.huimv.management.entity.ThresholdManagementEntity;
|
|
|
+import com.huimv.management.entity.WarningInfoEntity;
|
|
|
+import com.huimv.management.entity.YearPigBaseEntity;
|
|
|
+import com.huimv.management.service.*;
|
|
|
+import com.huimv.management.socket.eartagrecive.constant.CofigConstant;
|
|
|
+import com.huimv.management.socket.eartagrecive.constant.EarTagThresholdConstant;
|
|
|
+import com.huimv.management.util.DateUtils;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.text.*;
|
|
|
+import java.time.Duration;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.ZoneId;
|
|
|
+import java.time.temporal.ChronoUnit;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Project : huimv.ql
|
|
|
+ * @Package : com.huimv.biosafety.uface.controller
|
|
|
+ * @Description : TODO
|
|
|
+ * @Version : 1.0
|
|
|
+ * @Author : ZhuoNing
|
|
|
+ * @Create : 2020-12-25
|
|
|
+ **/
|
|
|
+@Slf4j
|
|
|
+@Component
|
|
|
+public class ReceivePackageSerivce {
|
|
|
+
|
|
|
+
|
|
|
+ //耳标数据查询
|
|
|
+ @Autowired
|
|
|
+ private EartagDataService eartagDataService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private EartagDataDao eartagDataDao ;
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private YearPigBaseDao yearPigBaseDao ;
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ThresholdManagementDao thresholdManagementDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private WarningInfoService warningInfoService;
|
|
|
+
|
|
|
+
|
|
|
+ public String handleEartagData(String[] clientMessageArray) throws ParseException {
|
|
|
+
|
|
|
+ log.info("开始添加耳标数据......");
|
|
|
+
|
|
|
+ String commandHeader = clientMessageArray[0]; // header =hm
|
|
|
+ String deviceId = clientMessageArray[1]; // SBID = 1234
|
|
|
+ String cmd = clientMessageArray[2]; //CMD=6
|
|
|
+ String version = clientMessageArray[3]; //version =1.0
|
|
|
+ String eartagId = clientMessageArray[4]; //eartagId = 77eb1e9e
|
|
|
+ String serial = clientMessageArray[5]; //serial =2321
|
|
|
+ String dl = clientMessageArray[6]; //DL =90
|
|
|
+ String nbwd = clientMessageArray[7]; //内部温度 2700
|
|
|
+ //新添加的环境温度 现在的8
|
|
|
+ String environment_temp = clientMessageArray[8];
|
|
|
+ Double environment_temp_newAdd= (double) Integer.parseInt(environment_temp) / 100;
|
|
|
+ System.out.println("环境温度初值" + environment_temp);
|
|
|
+ //19944 用来计算耳标温度
|
|
|
+ String ntc = clientMessageArray[9];
|
|
|
+ //当前运动量
|
|
|
+ String ydl = clientMessageArray[10];
|
|
|
+
|
|
|
+
|
|
|
+ //数据库CMD字段没什么用,用来放环境温度了
|
|
|
+ //计算区间运动量 --查找区间运动量
|
|
|
+ //由于机器矫正时间或发生时间翻转问题,造成负运动量,因此直接清洗掉这些数据
|
|
|
+ washDirtyRecord(eartagId);
|
|
|
+
|
|
|
+ //判断年猪表中是否有这一只耳标的数据
|
|
|
+ LambdaQueryWrapper<YearPigBaseEntity> wrapper1 = Wrappers.lambdaQuery();
|
|
|
+ wrapper1.eq(YearPigBaseEntity::getEartag, eartagId );
|
|
|
+ YearPigBaseEntity yearPigBaseEntity = yearPigBaseDao.selectOne(wrapper1);
|
|
|
+ if (yearPigBaseEntity==null){
|
|
|
+ System.out.println("年猪登记表中没有这只猪的信息,请先注册");
|
|
|
+ return "年猪登记表中没有这只猪的信息,请先注册";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //判断是否进行报警
|
|
|
+ setWarningInfo(eartagId, ln(Integer.parseInt(ntc)), dl);
|
|
|
+ //查最后一条
|
|
|
+ LambdaQueryWrapper<EartagDataEntity> wrapper = Wrappers.lambdaQuery();
|
|
|
+ wrapper.eq(EartagDataEntity::getEartagId, eartagId ).orderByDesc( EartagDataEntity::getId ).last( "limit 1");
|
|
|
+ EartagDataEntity lastEarTagDate = eartagDataDao.selectOne(wrapper);
|
|
|
+
|
|
|
+ //第二:防止数据有太大的波动,需要对时间进行处理,有时候时间会发生跳动
|
|
|
+ //获取两条数据时间差 查过去五秒
|
|
|
+ String date = "";
|
|
|
+ if (lastEarTagDate == null) {
|
|
|
+ Date date1 = DateUtils.getPassedsecond();
|
|
|
+ date = date1.toString();
|
|
|
+ System.out.println("自动获取时间为" + date);
|
|
|
+ } else {
|
|
|
+ date = lastEarTagDate.getCreateTime().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
|
|
|
+ Date d = sdf.parse(date);
|
|
|
+ String formatDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(d);
|
|
|
+ Date date1 = new Date();
|
|
|
+ Date d1 = sdf.parse(String.valueOf(date1));
|
|
|
+ String formatDate001 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(d1);
|
|
|
+ System.out.println("现在的时间就是" + formatDate001);
|
|
|
+ System.out.println("上一条数据的时间是" + formatDate);
|
|
|
+ //算出间隔时间
|
|
|
+ DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ Date startTime = dateFormat.parse(formatDate);
|
|
|
+ //end是大一点的时间
|
|
|
+ Date endTime = dateFormat.parse(formatDate001);
|
|
|
+ long diff = endTime.getTime() - startTime.getTime();
|
|
|
+ //间隔时间为多少毫秒,除以上传时时间间隔五秒
|
|
|
+ System.out.println("时间间隔为" + diff + "毫秒");
|
|
|
+ double second = diff/CofigConstant.UPDATA_TIME_GAP;
|
|
|
+ //需要除以五秒钟作为时间间隔
|
|
|
+ System.out.println("有多少个五秒" + second);
|
|
|
+ //String cqs = clientMessageArray[11];
|
|
|
+ String rssi = clientMessageArray[12];
|
|
|
+ String timestamp = clientMessageArray[13];
|
|
|
+ String checkNumber = clientMessageArray[14];
|
|
|
+ //String commandTail = clientMessageArray[15];
|
|
|
+
|
|
|
+ EartagDataEntity eartagDataEntity = new EartagDataEntity();
|
|
|
+ eartagDataEntity.setSleepGap(0);
|
|
|
+ int save_date ; //计算结束之后的平均运动量的值 平均运动量
|
|
|
+ if (lastEarTagDate == null) {
|
|
|
+ //运动量为空自己造数据
|
|
|
+ System.out.println("运动量为空,新运动量" + ydl + "---老运动量为空");
|
|
|
+ save_date = (int) (10 / second);
|
|
|
+ System.out.println("存储平均运动量" + save_date);
|
|
|
+ eartagDataEntity.setGapSport(save_date);
|
|
|
+ //setSleepGap---这个是睡眠区间结束的标志位,当上一条为睡眠,这一条为运动时,设置一个睡眠周期结束,将上一条睡眠的这个标志位置为1
|
|
|
+
|
|
|
+ eartagDataEntity.setSleepStatus(0);//统一不算睡眠
|
|
|
+ } else if (Integer.parseInt(ydl) - lastEarTagDate.getCountSport()>= 0) {
|
|
|
+ //存在翻转的情况,数据从 6000 突然变成3这种情况
|
|
|
+ System.out.println("运动量还未翻转,新运动量" + ydl + "---老运动量" + lastEarTagDate.getCountSport());
|
|
|
+ save_date = (int) Math.ceil((Integer.parseInt(ydl) -lastEarTagDate.getCountSport()) / second);
|
|
|
+ System.out.println("存储平均运动量" + save_date);
|
|
|
+ eartagDataEntity.setGapSport(save_date);
|
|
|
+ int sleepstatus = save_date >= 1 ? 0:1;
|
|
|
+ eartagDataEntity.setSleepStatus(sleepstatus);
|
|
|
+ //同时间处理睡眠时间
|
|
|
+ } else {
|
|
|
+ System.out.println("运动量翻转,新运动量" + ydl + "---老运动量" + lastEarTagDate.getCountSport());
|
|
|
+ save_date = (int) Math.ceil(Integer.parseInt(ydl) / second);
|
|
|
+ System.out.println("存储平均运动量" + save_date);
|
|
|
+ eartagDataEntity.setGapSport(save_date);
|
|
|
+ int sleepstatus = save_date >=1 ? 0:1;
|
|
|
+ eartagDataEntity.setSleepStatus(sleepstatus);
|
|
|
+ }
|
|
|
+ //判断睡眠时间,进行处理 192.168.1.171 8888
|
|
|
+ //所有区间结束时间都为当前时间,因此不用纠结
|
|
|
+ eartagDataEntity.setSleepEnd(DateUtils.parseDateTime(DateUtils.buildDateTimeString(timestamp )));
|
|
|
+ //若之前的数据为空,新数据开始结束都为当前时间,区间睡眠设置为运动
|
|
|
+ if (lastEarTagDate == null) {
|
|
|
+ eartagDataEntity.setSleepGap(0);//设置为0 只有检测到睡眠结束的时候将其设置为1
|
|
|
+ eartagDataEntity.setSleepBegin(DateUtils.parseDateTime(DateUtils.buildDateTimeString(timestamp )));
|
|
|
+ //存在翻转的情况,数据从 6000 突然变成3这种情况
|
|
|
+ //1.没有翻转
|
|
|
+ } else if (Integer.parseInt(ydl) - lastEarTagDate.getCountSport()>= 0) {
|
|
|
+ //1.有历史数据,而且这一条为运动
|
|
|
+ if ( save_date >=1 ){ //这一为运动
|
|
|
+ //当前设已经设置成运动 ,查看上一条状态
|
|
|
+ //1.上一条也为运动
|
|
|
+ if(lastEarTagDate.getSleepStatus()==0){
|
|
|
+ //将开始时间,结束时间都设置为当前时间
|
|
|
+ eartagDataEntity.setSleepBegin(DateUtils.parseDateTime(DateUtils.buildDateTimeString(timestamp )));
|
|
|
+ }else {
|
|
|
+ //上一条为睡眠,这一条为运动.有且只有这种情况,睡眠状态会计算为1
|
|
|
+ eartagDataEntity.setSleepBegin(DateUtils.parseDateTime(DateUtils.buildDateTimeString(timestamp )));
|
|
|
+ //同时上一条数据是一个睡眠阶段结束,将上一个周期睡眠结束标志置为1
|
|
|
+ lastEarTagDate.setSleepGap(1);
|
|
|
+ //存储睡眠时间..传入上一条的开始时间,结束时间.通过方法计算后存储粗--放到remark 字段
|
|
|
+ lastEarTagDate.setRemark(calculatetimegap(lastEarTagDate.getSleepBegin(),lastEarTagDate.getSleepEnd()) );
|
|
|
+ //上一条数据标志位改变,需要重新保存一下
|
|
|
+ eartagDataService.save(lastEarTagDate);
|
|
|
+ }
|
|
|
+ }else { //若这一条为睡眠
|
|
|
+ if(lastEarTagDate.getSleepStatus()==0){//上一条为运动
|
|
|
+ eartagDataEntity.setSleepBegin(lastEarTagDate.getSleepEnd());//开始时间用上一条结束时间
|
|
|
+ }else {//上一条为睡眠--这一条还是睡眠,睡眠结束标志位为0
|
|
|
+ eartagDataEntity.setSleepBegin(lastEarTagDate.getSleepBegin());//开始时间用上一条结束时间
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //同时间处理睡眠时间
|
|
|
+ //2.有翻转
|
|
|
+ eartagDataEntity.setMessageHead(commandHeader);
|
|
|
+ eartagDataEntity.setMessageCmd(cmd);
|
|
|
+ eartagDataEntity.setBoxInsideTemp(25.0);
|
|
|
+ eartagDataEntity.setBoxId(deviceId);
|
|
|
+ eartagDataEntity.setBoxVersion(version);
|
|
|
+ eartagDataEntity.setEartagId(eartagId);
|
|
|
+ eartagDataEntity.setEartagPower(Integer.parseInt(dl));
|
|
|
+ eartagDataEntity.setEartagTemp(ln(Integer.parseInt(ntc)));
|
|
|
+ eartagDataEntity.setNtc(Integer.parseInt(ntc));
|
|
|
+ eartagDataEntity.setCountSport(Integer.parseInt(ydl));
|
|
|
+ eartagDataEntity.setRssyi(Integer.parseInt(rssi));
|
|
|
+ eartagDataEntity.setCreateTime(DateUtils.parseDateTime(DateUtils.buildDateTimeString(timestamp)));
|
|
|
+ eartagDataEntity.setCheckNumber(Integer.parseInt(checkNumber));
|
|
|
+ eartagDataEntity.setEnvironmentTemp(environment_temp_newAdd);
|
|
|
+ eartagDataEntity.setFarmName(yearPigBaseEntity.getFarmId());
|
|
|
+ eartagDataEntity.setMessageEnd("end");
|
|
|
+ eartagDataService.save(eartagDataEntity);
|
|
|
+ return "hm+6+0+6+end";
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static String swapHex(String src) {
|
|
|
+ String target = "";
|
|
|
+ for (int i = src.length() - 1; i > 0; i -= 2) {
|
|
|
+ target += src.substring(i - 1, i + 1);
|
|
|
+ }
|
|
|
+ return target;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String numberFormater(double d) {
|
|
|
+ DecimalFormat nf = new DecimalFormat();
|
|
|
+ nf.setMaximumFractionDigits(2);
|
|
|
+ return nf.format(d);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static double A = 0.00335396319311466;
|
|
|
+ public static double B = 0.000256376549039663;
|
|
|
+ public static double C = 0.00000248933580817244;
|
|
|
+ public static double D = 0.0000000753805242068686;
|
|
|
+ public static double E = -0.0000000204758173596178;
|
|
|
+
|
|
|
+ //保留一位小数
|
|
|
+ public static double changeDouble(Double dou) {
|
|
|
+ NumberFormat nf = new DecimalFormat("0.0 ");
|
|
|
+ dou = Double.parseDouble(nf.format(dou));
|
|
|
+ return dou;
|
|
|
+ }
|
|
|
+
|
|
|
+ //温度转换
|
|
|
+ public static double ln(int rv) {
|
|
|
+ int R_REF = 10000;
|
|
|
+ double ln = Math.log((double) rv / R_REF);
|
|
|
+ //保留一位小数
|
|
|
+ return changeDouble(1 / (A + B * ln + C * Math.pow(ln, 2) + D * Math.pow(ln, 3) + E * Math.pow(ln, 4)) - 273.15);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //由于机器矫正时间或发生时间翻转问题,造成负运动量,因此直接清洗掉这些数据
|
|
|
+ public void washDirtyRecord(String eartagId ){
|
|
|
+ LambdaQueryWrapper<EartagDataEntity> wrapper = Wrappers.lambdaQuery();
|
|
|
+ wrapper.eq(EartagDataEntity::getEartagId, eartagId ).orderByDesc( EartagDataEntity::getId ).last( "limit 5");
|
|
|
+ List<EartagDataEntity> EartagDataEntityList = eartagDataDao.selectList(wrapper);
|
|
|
+ if (EartagDataEntityList != null) {
|
|
|
+ for (EartagDataEntity eartagData : EartagDataEntityList) {
|
|
|
+ if (eartagData.getGapSport() < 0 || eartagData.getGapSport() > 15 || eartagData.getGapSport() < 0) {
|
|
|
+ eartagDataService.removeById(eartagData.getId());
|
|
|
+ log.info("删除了脏一条数据");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ System.out.println("没有脏数据");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //进行高温低温以及电量报警
|
|
|
+ public void setWarningInfo(String eartagId , double eartagtemp , String eartagPower ) throws ParseException {
|
|
|
+ LambdaQueryWrapper<YearPigBaseEntity> wrapper = Wrappers.lambdaQuery();
|
|
|
+ wrapper.eq(YearPigBaseEntity::getEartag, eartagId );
|
|
|
+ YearPigBaseEntity yearPigBaseEntity = yearPigBaseDao.selectOne(wrapper);
|
|
|
+
|
|
|
+ //新阈值方法//设置为1
|
|
|
+ // Map<String, Double> ThreadHold = getThreadHold(yearPigBaseEntity.getFarmId()); //放的1 目前.传入牧场ID获取专属阈值
|
|
|
+ Map<String, Double> ThreadHold = getThreadHold(1); //放的1 目前.传入牧场ID获取专属阈值
|
|
|
+
|
|
|
+ //三元表达式,防止报警表没有对应的值.没有对应值就用默认值
|
|
|
+ Double highTemp = ThreadHold.get("耳标温度高阈值")==null ? EarTagThresholdConstant.Ear_Tag_Max_TEMP_VALU : ThreadHold.get("耳标温度高阈值");
|
|
|
+ Double lowTemp = ThreadHold.get("耳标温度低阈值")==null ? EarTagThresholdConstant.Ear_Tag_Min_TEMP_VALU : ThreadHold.get("耳标温度低阈值");
|
|
|
+ Double powerValu= ThreadHold.get("耳标电量低阈值")==null ? EarTagThresholdConstant.Ear_Tag_Min_Power_VALU : ThreadHold.get("耳标电量低阈值");
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (eartagtemp > highTemp|| eartagtemp < lowTemp|| Double.parseDouble(eartagPower) < powerValu) {
|
|
|
+
|
|
|
+ System.out.println("耳标号为"+eartagId+yearPigBaseEntity.toString());
|
|
|
+ WarningInfoEntity WarningInfo = new WarningInfoEntity();
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd ");
|
|
|
+ String TimeNow = sdf.format(Calendar.getInstance().getTime());
|
|
|
+ Date parse = sdf.parse(TimeNow);
|
|
|
+ WarningInfo.setNowDate(parse);
|
|
|
+ WarningInfo.setFarmId(1);
|
|
|
+ System.out.println("牧场编号====>"+yearPigBaseEntity.getFarmId());
|
|
|
+ WarningInfo.setPigstyId(yearPigBaseEntity.getPigstyId());
|
|
|
+ System.out.println("猪舍编号====>"+yearPigBaseEntity.getPigstyId());
|
|
|
+ WarningInfo.setUnitId(yearPigBaseEntity.getUnitId());
|
|
|
+ WarningInfo.setEarTag(eartagId);
|
|
|
+ WarningInfo.setWarningTime(new Date());
|
|
|
+ WarningInfo.setVerifyStatus(true);
|
|
|
+
|
|
|
+ if (eartagtemp > highTemp) {
|
|
|
+ System.out.println("存储耳标温度过高报警");
|
|
|
+ //存储报警类型
|
|
|
+ WarningInfo.setNowValue(eartagtemp);
|
|
|
+ WarningInfo.setWarningType( "耳标温度高阈值");
|
|
|
+ //所属范围 1.室内 2.室外 3.体温
|
|
|
+ WarningInfo.setBelongTo((short) 3);
|
|
|
+ warningInfoService.save(WarningInfo);
|
|
|
+ }
|
|
|
+ if (eartagtemp < lowTemp) {
|
|
|
+ WarningInfo.setNowValue(eartagtemp);
|
|
|
+ System.out.println("存猪只耳标温度过低报警");
|
|
|
+ //存储报警类型
|
|
|
+ WarningInfo.setWarningType("耳标温度低阈值");
|
|
|
+ //所属范围 1.室内 2.室外 3.体温
|
|
|
+ WarningInfo.setBelongTo((short) 3);
|
|
|
+ warningInfoService.save(WarningInfo);
|
|
|
+ }
|
|
|
+ if ( Double.parseDouble(eartagPower) < powerValu) {
|
|
|
+ WarningInfo.setNowValue(Double.parseDouble(eartagPower));
|
|
|
+ System.out.println("存储低电量报警");
|
|
|
+ //存储报警类型
|
|
|
+ WarningInfo.setWarningType("耳标电量低阈值");
|
|
|
+ //所属范围 1.室内 2.室外 3.体温
|
|
|
+ WarningInfo.setBelongTo((short) 3);
|
|
|
+ warningInfoService.save(WarningInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //存储上传的时间间隔
|
|
|
+public String calculatetimegap(Date beginDate, Date endDate){
|
|
|
+
|
|
|
+ LocalDateTime inDate1= LocalDateTime.ofInstant(beginDate.toInstant(), ZoneId.systemDefault());
|
|
|
+ LocalDateTime nowDate1= LocalDateTime.ofInstant(endDate.toInstant(), ZoneId.systemDefault());
|
|
|
+
|
|
|
+ Duration duration = java.time.Duration.between(inDate1, nowDate1);
|
|
|
+ log.info("时间差:" + duration.getSeconds());
|
|
|
+ long hour = duration.getSeconds() / ChronoUnit.HOURS.getDuration().getSeconds();
|
|
|
+ long minute = (duration.getSeconds() - ChronoUnit.HOURS.getDuration().getSeconds() * hour) / ChronoUnit.MINUTES.getDuration().getSeconds();
|
|
|
+ long second = (duration.getSeconds() - ChronoUnit.HOURS.getDuration().getSeconds() * hour) - minute * ChronoUnit.MINUTES.getDuration().getSeconds();
|
|
|
+ log.info("时间:" + hour + "小时" + minute + "分" + second+"秒");
|
|
|
+ return hour + "小时" + minute + "分" + second+"秒";
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+ //获取阈值 牧场ID是有用的,需要判断是哪个牧场的阈值数据
|
|
|
+ public Map<String, Double> getThreadHold(int farmId) {
|
|
|
+ //ThresholdManagementEntity
|
|
|
+ LambdaQueryWrapper<ThresholdManagementEntity> wrapper = Wrappers.lambdaQuery();
|
|
|
+ wrapper.eq(ThresholdManagementEntity::getDeleted, 0);//未删除的阈值
|
|
|
+ wrapper.eq(ThresholdManagementEntity::getBelongTo, 1);//室 的阈值
|
|
|
+ wrapper.eq(ThresholdManagementEntity::getFarmId, farmId);//室外的阈值
|
|
|
+ List<ThresholdManagementEntity> thresholdManagementEntityList = thresholdManagementDao.selectList(wrapper);
|
|
|
+
|
|
|
+ Map<String, Double> thresholdManagementEntityMap = new HashMap<>();
|
|
|
+ for (ThresholdManagementEntity c : thresholdManagementEntityList) {
|
|
|
+ thresholdManagementEntityMap.put(c.getThresholdType(), c.getThresholdValue());
|
|
|
+ }
|
|
|
+ return thresholdManagementEntityMap;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Method : _handleEartagDampness
|
|
|
+ * @Description : 处理网关湿度
|
|
|
+ * @Params : [clientMessageArray]
|
|
|
+ * @Return : java.lang.String
|
|
|
+ * @Author : ZhuoNing
|
|
|
+ * @Date : 2021/1/15
|
|
|
+ * @Time : 17:47
|
|
|
+ */
|
|
|
+ public String handleEartagDampness(String[] clientMessageArray) throws ParseException {
|
|
|
+ /* String header = clientMessageArray[0];
|
|
|
+ String deviceId = clientMessageArray[1];
|
|
|
+ String cmd = clientMessageArray[2];
|
|
|
+ String serialNo = clientMessageArray[3];
|
|
|
+ String value = clientMessageArray[4];
|
|
|
+ String timestamp = clientMessageArray[5];
|
|
|
+ String checkCode = clientMessageArray[6];
|
|
|
+ String tail = clientMessageArray[7];
|
|
|
+ EartagDampness eartagDampnessPojo = new EartagDampness();
|
|
|
+ eartagDampnessPojo.setHeader(header);
|
|
|
+ eartagDampnessPojo.setDeviceId(Integer.parseInt(deviceId));
|
|
|
+ eartagDampnessPojo.setCmd(Integer.parseInt(cmd));
|
|
|
+ eartagDampnessPojo.setSerialNo(Integer.parseInt(serialNo));
|
|
|
+ eartagDampnessPojo.setValue(Double.parseDouble(value));
|
|
|
+ eartagDampnessPojo.setCreateDate(DateUtil.parseDateTime(DateUtil.buildDateTimeString(timestamp)));
|
|
|
+ eartagDampnessPojo.setCheckNumber(Integer.parseInt(checkCode));
|
|
|
+ eartagDampnessPojo.setTail(tail);
|
|
|
+ dampnessMapper.insert(eartagDampnessPojo);
|
|
|
+// dampnessService.add(eartagDampnessPojo);
|
|
|
+ log.info(Const.SAVE_DAMPNESS_SUCCESS);*/
|
|
|
+ return "hm+5+0+8+end";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Method : _handleEartagTemperature
|
|
|
+ * @Description : 处理网关温度
|
|
|
+ * @Params : [clientMessageArray]
|
|
|
+ * @Return : java.lang.String
|
|
|
+ * @Author : ZhuoNing
|
|
|
+ * @Date : 2021/1/15
|
|
|
+ * @Time : 17:46
|
|
|
+ */
|
|
|
+ public String handleEartagTemperature(String[] clientMessageArray) throws ParseException {
|
|
|
+ /* String header = clientMessageArray[0];
|
|
|
+ String deviceId = clientMessageArray[1];
|
|
|
+ String cmd = clientMessageArray[2];
|
|
|
+ String serialNo = clientMessageArray[3];
|
|
|
+ String value = clientMessageArray[4];
|
|
|
+ String timestamp = clientMessageArray[5];
|
|
|
+ String checkCode = clientMessageArray[6];
|
|
|
+ String tail = clientMessageArray[7];
|
|
|
+ EartagTemperature EartagTemperaturePojo = new EartagTemperature();
|
|
|
+ EartagTemperaturePojo.setHeader(header);
|
|
|
+ EartagTemperaturePojo.setDeviceId(Integer.parseInt(deviceId));
|
|
|
+ EartagTemperaturePojo.setCmd(Integer.parseInt(cmd));
|
|
|
+ EartagTemperaturePojo.setSerialNo(Integer.parseInt(serialNo));
|
|
|
+ EartagTemperaturePojo.setValue(Double.parseDouble(value) / 10);
|
|
|
+ EartagTemperaturePojo.setCreateDate(DateUtil.parseDateTime(DateUtil.buildDateTimeString(timestamp)));
|
|
|
+ EartagTemperaturePojo.setCheckNumber(Integer.parseInt(checkCode));
|
|
|
+ EartagTemperaturePojo.setTail(tail);
|
|
|
+ temperatureMapper.insert(EartagTemperaturePojo);
|
|
|
+// temperatureService.add(EartagTemperaturePojo);
|
|
|
+ log.info(Const.SAVE_TEMPERATURE_SUCCESS);*/
|
|
|
+ return "hm+4+0+7+end";
|
|
|
+ }
|
|
|
+
|
|
|
+}
|