|
@@ -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);
|
|
|
+ }
|
|
|
}
|
|
|
}
|