瀏覽代碼

气体定时器模拟数据

wwh 2 年之前
父節點
當前提交
a4cf8488fe

+ 8 - 2
huimv-admin/src/main/java/com/huimv/admin/controller/GasThresholdController.java

@@ -43,12 +43,18 @@ public class GasThresholdController {
     public Result list(HttpServletRequest httpServletRequest, @RequestBody GasThresholdVo gasThresholdVo) {
         String farmId = gasThresholdVo.getFarmId();
         GasThreshold gasThreshold = gasThresholdVo.getPigpen().setFarmId(Integer.parseInt(farmId));
-        GasThreshold gasThreshold1 = gasThresholdVo.getPigpen().setFarmId(Integer.parseInt(farmId));
-        GasThreshold gasThreshold2 = gasThresholdVo.getPigpen().setFarmId(Integer.parseInt(farmId));
+        gasThreshold.setGasType(1);
+        GasThreshold gasThreshold1 = gasThresholdVo.getPeople().setFarmId(Integer.parseInt(farmId));
+        GasThreshold gasThreshold2 = gasThresholdVo.getAbove().setFarmId(Integer.parseInt(farmId));
+        GasThreshold gasThreshold3 = gasThresholdVo.getUnder().setFarmId(Integer.parseInt(farmId));
+        gasThreshold1.setGasType(4);
+        gasThreshold2.setGasType(2);
+        gasThreshold3.setGasType(3);
         List<GasThreshold> gasThresholds = new LinkedList<>();
         gasThresholds.add(gasThreshold);
         gasThresholds.add(gasThreshold1);
         gasThresholds.add(gasThreshold2);
+        gasThresholds.add(gasThreshold3);
         return gasThresholdService.edit(httpServletRequest, gasThresholds);
     }
 }

+ 2 - 1
huimv-admin/src/main/java/com/huimv/admin/entity/GasData.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import java.time.LocalDateTime;
 import java.io.Serializable;
+import java.util.Date;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
@@ -86,7 +87,7 @@ public class GasData implements Serializable {
     private String originalData;
 
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
-    private LocalDateTime createTime;
+    private Date createTime;
 
     private String other1;
 

+ 5 - 1
huimv-admin/src/main/java/com/huimv/admin/entity/GasWarningInfo.java

@@ -5,6 +5,9 @@ import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import java.time.LocalDateTime;
 import java.io.Serializable;
+import java.util.Date;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
@@ -51,7 +54,8 @@ public class GasWarningInfo implements Serializable {
     /**
      * 日期
      */
-    private LocalDateTime date;
+    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMt+8")
+    private Date date;
 
     /**
      * 人员id

+ 194 - 3
huimv-admin/src/main/java/com/huimv/admin/timer/GasTimer.java

@@ -1,18 +1,209 @@
 package com.huimv.admin.timer;
 
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.huimv.admin.common.utils.NumberUtils;
+import com.huimv.admin.entity.GasData;
+import com.huimv.admin.entity.GasThreshold;
+import com.huimv.admin.entity.GasWarningInfo;
+import com.huimv.admin.mapper.GasDataMapper;
+import com.huimv.admin.mapper.GasThresholdMapper;
+import com.huimv.admin.mapper.GasWarningInfoMapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
 
+import java.util.Date;
+
 @Configuration
 @EnableScheduling
 public class GasTimer {
-//    @Autowired
-//    private Gas
-    @Scheduled(cron = "0 0 * * * ? ")
+
+    @Autowired
+    private GasDataMapper gasDataMapper;
+    @Autowired
+    private GasWarningInfoMapper warningInfoMapper;
+    @Autowired
+    private GasThresholdMapper thresholdMapper;
+
+    @Scheduled(cron = "0 0/10 * * * ? ")
     private void getShenChan() throws Exception {
 
+        String type = NumberUtils.getNum(1, 5, 0);//loc_type
+        String nh3n = NumberUtils.getNum(10, 20, 1);//NH3N
+        String jlm = NumberUtils.getNum(10, 20, 1);//jlm
+        String elht = NumberUtils.getNum(10, 20, 1);//elht
+        String ejel = NumberUtils.getNum(10, 20, 1);//ejel
+        String h2s = NumberUtils.getNum(10, 20, 1);//h2s
+        String byx = NumberUtils.getNum(10, 20, 1);//byx
+        String ch3 = NumberUtils.getNum(10, 20, 1);//ch3
+        String sja = NumberUtils.getNum(10, 20, 1);//sja
+        String cq = NumberUtils.getNum(10, 20, 1);//cq
+
+        GasData gasData = new GasData();
+        gasData.setLoctionType(Integer.parseInt(type));
+        gasData.setNh3N(nh3n);
+        gasData.setJlm(jlm);
+        gasData.setElht(elht);
+        gasData.setEjel(ejel);
+        gasData.setH2s(h2s);
+        gasData.setByx(byx);
+        gasData.setCh3sh(ch3);
+        gasData.setSja(sja);
+        gasData.setCq(cq);
+        gasData.setFarmId(21);
+        gasData.setCreateTime(new Date());
+        gasDataMapper.insert(gasData);
+
+        GasWarningInfo warningInfo = new GasWarningInfo();
+
+        QueryWrapper<GasThreshold> queryWrapper = new QueryWrapper<>();
+        if ("1".equals(type)) {
+            queryWrapper.eq("farm_id", 21).eq("gas_type", 1);
+            GasThreshold gasThreshold = thresholdMapper.selectOne(queryWrapper);
+            if (Double.parseDouble(nh3n) > Double.parseDouble(gasThreshold.getNh3N())) {
+                warningInfo.setWarningContent(nh3n + "超过阈值,系统预警提醒");
+            }
+            if (Double.parseDouble(jlm) > Double.parseDouble(gasThreshold.getJlm())) {
+                warningInfo.setWarningContent(jlm + "超过阈值,系统预警提醒");
+            }
+            if (Double.parseDouble(elht) > Double.parseDouble(gasThreshold.getElht())) {
+                warningInfo.setWarningContent(elht + "超过阈值,系统预警提醒");
+            }
+            if (Double.parseDouble(ejel) > Double.parseDouble(gasThreshold.getEjel())) {
+                warningInfo.setWarningContent(ejel + "超过阈值,系统预警提醒");
+            }
+            if (Double.parseDouble(h2s) > Double.parseDouble(gasThreshold.getH2s())) {
+                warningInfo.setWarningContent(h2s + "超过阈值,系统预警提醒");
+            }
+            if (Double.parseDouble(byx) > Double.parseDouble(gasThreshold.getByx())) {
+                warningInfo.setWarningContent(byx + "超过阈值,系统预警提醒");
+            }
+            if (Double.parseDouble(ch3) > Double.parseDouble(gasThreshold.getCh3sh())) {
+                warningInfo.setWarningContent(ch3 + "超过阈值,系统预警提醒");
+            }
+            if (Double.parseDouble(sja) > Double.parseDouble(gasThreshold.getSja())) {
+                warningInfo.setWarningContent(sja + "超过阈值,系统预警提醒");
+            }
+            if (Double.parseDouble(cq) > Double.parseDouble(gasThreshold.getCq())) {
+                warningInfo.setWarningContent(cq + "超过阈值,系统预警提醒");
+            }
+            warningInfo.setWarningType(1);
+            warningInfo.setBuildLocation("屋顶");
+            warningInfo.setDate(new Date());
+            warningInfo.setFarmId(21);
+            warningInfo.setUserIds("1,2");
+            warningInfoMapper.insert(warningInfo);
+
+        } else if ("2".equals(type)) {
+            queryWrapper.eq("farm_id", 21).eq("gas_type", 2);
+            GasThreshold gasThreshold = thresholdMapper.selectOne(queryWrapper);
+            if (Double.parseDouble(nh3n) > Double.parseDouble(gasThreshold.getNh3N())) {
+                warningInfo.setWarningContent(nh3n + "超过阈值,系统预警提醒");
+            }
+            if (Double.parseDouble(jlm) > Double.parseDouble(gasThreshold.getJlm())) {
+                warningInfo.setWarningContent(jlm + "超过阈值,系统预警提醒");
+            }
+            if (Double.parseDouble(elht) > Double.parseDouble(gasThreshold.getElht())) {
+                warningInfo.setWarningContent(elht + "超过阈值,系统预警提醒");
+            }
+            if (Double.parseDouble(ejel) > Double.parseDouble(gasThreshold.getEjel())) {
+                warningInfo.setWarningContent(ejel + "超过阈值,系统预警提醒");
+            }
+            if (Double.parseDouble(h2s) > Double.parseDouble(gasThreshold.getH2s())) {
+                warningInfo.setWarningContent(h2s + "超过阈值,系统预警提醒");
+            }
+            if (Double.parseDouble(byx) > Double.parseDouble(gasThreshold.getByx())) {
+                warningInfo.setWarningContent(byx + "超过阈值,系统预警提醒");
+            }
+            if (Double.parseDouble(ch3) > Double.parseDouble(gasThreshold.getCh3sh())) {
+                warningInfo.setWarningContent(ch3 + "超过阈值,系统预警提醒");
+            }
+            if (Double.parseDouble(sja) > Double.parseDouble(gasThreshold.getSja())) {
+                warningInfo.setWarningContent(sja + "超过阈值,系统预警提醒");
+            }
+            if (Double.parseDouble(cq) > Double.parseDouble(gasThreshold.getCq())) {
+                warningInfo.setWarningContent(cq + "超过阈值,系统预警提醒");
+            }
+            warningInfo.setWarningType(2);
+            warningInfo.setBuildLocation("厂界上");
+            warningInfo.setDate(new Date());
+            warningInfo.setFarmId(21);
+            warningInfo.setUserIds("1,2");
+            warningInfoMapper.insert(warningInfo);
+        } else if ("3".equals(type)) {
+            queryWrapper.eq("farm_id", 21).eq("gas_type", 3);
+            GasThreshold gasThreshold = thresholdMapper.selectOne(queryWrapper);
+            if (Double.parseDouble(nh3n) > Double.parseDouble(gasThreshold.getNh3N())) {
+                warningInfo.setWarningContent(nh3n + "超过阈值,系统预警提醒");
+            }
+            if (Double.parseDouble(jlm) > Double.parseDouble(gasThreshold.getJlm())) {
+                warningInfo.setWarningContent(jlm + "超过阈值,系统预警提醒");
+            }
+            if (Double.parseDouble(elht) > Double.parseDouble(gasThreshold.getElht())) {
+                warningInfo.setWarningContent(elht + "超过阈值,系统预警提醒");
+            }
+            if (Double.parseDouble(ejel) > Double.parseDouble(gasThreshold.getEjel())) {
+                warningInfo.setWarningContent(ejel + "超过阈值,系统预警提醒");
+            }
+            if (Double.parseDouble(h2s) > Double.parseDouble(gasThreshold.getH2s())) {
+                warningInfo.setWarningContent(h2s + "超过阈值,系统预警提醒");
+            }
+            if (Double.parseDouble(byx) > Double.parseDouble(gasThreshold.getByx())) {
+                warningInfo.setWarningContent(byx + "超过阈值,系统预警提醒");
+            }
+            if (Double.parseDouble(ch3) > Double.parseDouble(gasThreshold.getCh3sh())) {
+                warningInfo.setWarningContent(ch3 + "超过阈值,系统预警提醒");
+            }
+            if (Double.parseDouble(sja) > Double.parseDouble(gasThreshold.getSja())) {
+                warningInfo.setWarningContent(sja + "超过阈值,系统预警提醒");
+            }
+            if (Double.parseDouble(cq) > Double.parseDouble(gasThreshold.getCq())) {
+                warningInfo.setWarningContent(cq + "超过阈值,系统预警提醒");
+            }
+            warningInfo.setWarningType(3);
+            warningInfo.setBuildLocation("厂界下");
+            warningInfo.setDate(new Date());
+            warningInfo.setFarmId(21);
+            warningInfo.setUserIds("1,2");
+            warningInfoMapper.insert(warningInfo);
+        } else if ("4".equals(type)) {
+            queryWrapper.eq("farm_id", 21).eq("gas_type", 4);
+            GasThreshold gasThreshold = thresholdMapper.selectOne(queryWrapper);
+            if (Double.parseDouble(nh3n) > Double.parseDouble(gasThreshold.getNh3N())) {
+                warningInfo.setWarningContent(nh3n + "超过阈值,系统预警提醒");
+            }
+            if (Double.parseDouble(jlm) > Double.parseDouble(gasThreshold.getJlm())) {
+                warningInfo.setWarningContent(jlm + "超过阈值,系统预警提醒");
+            }
+            if (Double.parseDouble(elht) > Double.parseDouble(gasThreshold.getElht())) {
+                warningInfo.setWarningContent(elht + "超过阈值,系统预警提醒");
+            }
+            if (Double.parseDouble(ejel) > Double.parseDouble(gasThreshold.getEjel())) {
+                warningInfo.setWarningContent(ejel + "超过阈值,系统预警提醒");
+            }
+            if (Double.parseDouble(h2s) > Double.parseDouble(gasThreshold.getH2s())) {
+                warningInfo.setWarningContent(h2s + "超过阈值,系统预警提醒");
+            }
+            if (Double.parseDouble(byx) > Double.parseDouble(gasThreshold.getByx())) {
+                warningInfo.setWarningContent(byx + "超过阈值,系统预警提醒");
+            }
+            if (Double.parseDouble(ch3) > Double.parseDouble(gasThreshold.getCh3sh())) {
+                warningInfo.setWarningContent(ch3 + "超过阈值,系统预警提醒");
+            }
+            if (Double.parseDouble(sja) > Double.parseDouble(gasThreshold.getSja())) {
+                warningInfo.setWarningContent(sja + "超过阈值,系统预警提醒");
+            }
+            if (Double.parseDouble(cq) > Double.parseDouble(gasThreshold.getCq())) {
+                warningInfo.setWarningContent(cq + "超过阈值,系统预警提醒");
+            }
+            warningInfo.setWarningType(4);
+            warningInfo.setBuildLocation("厂界居民");
+            warningInfo.setDate(new Date());
+            warningInfo.setFarmId(21);
+            warningInfo.setUserIds("1,2");
+            warningInfoMapper.insert(warningInfo);
+        }
     }
 }

+ 2 - 2
huimv-admin/src/main/java/com/huimv/admin/timer/ProtTimer.java

@@ -31,7 +31,7 @@ public class ProtTimer {
     private ProtWarningInfoMapper warningInfoMapper;
 
     //    环保数据
-    @Scheduled(cron = "0 * * * * ? ")
+    @Scheduled(cron = "0 0/10 * * * ? ")
     private void getShenChan() throws Exception {
 
         //假设已经拿到了数据
@@ -41,7 +41,7 @@ public class ProtTimer {
         String num3 = NumberUtils.getNum(65, 85, 1);//tp
         String num4 = NumberUtils.getNum(65, 85, 1);//tn
         String num5 = NumberUtils.getNum(90, 210, 0);//flow
-        String num6 = NumberUtils.getNum(1, 3, 0);//loc_type
+        String num6 = NumberUtils.getNum(1, 4, 0);//loc_type
 
         ProtWarningInfo protWarningInfo = new ProtWarningInfo();