浏览代码

定时器修改

wwh 1 年之前
父节点
当前提交
8ebc2f782a

+ 58 - 0
huimv-admin/src/main/java/com/huimv/admin/timer/EnvTimer.java

@@ -285,6 +285,64 @@ public class EnvTimer {
             envData.setEnvHum(hum);
             envDataService.save(envData);
         }
+
+        Integer farmId5 = 22;
+        List<BasePigpen> list5 = basePigpenService.list(new QueryWrapper<BasePigpen>().eq("farm_id", farmId5).eq("f_type", 3));
+//        String url="https://restapi.amap.com/v3/weather/weatherInfo?parameters&key=c1d8179ed2dda7ed48c56bed06c0c86e&city=330782&extensions=base&output=JSON";
+//        String result = HttpUtil.get(url);
+//        WeatherDto weatherDto = JSONUtil.toBean(result, WeatherDto.class);
+//        List<WeatherLives> lives = weatherDto.getLives();
+//        WeatherLives weatherLives = lives.get(0);
+//        int humidity = Integer.parseInt(weatherLives.getHumidity());
+//        int temperature = Integer.parseInt(weatherLives.getTemperature());
+
+        for (BasePigpen basePigpen : list5) {
+            EnvData envData = new EnvData();
+            envData.setCreateTime(new Date());
+            envData.setFarmId(farmId5);
+            envData.setUnitId(basePigpen.getId());
+            EnvDevice envDevice = new EnvDevice();
+            envDevice.setUnitName(basePigpen.getBuildName());
+            envDevice.setUnitId(basePigpen.getId());
+            envDevice.setFarmId(farmId5);
+
+            String tem = NumberUtils.getNum(17, 23, 1);
+            String hum = NumberUtils.getNum(65, 80, 0);
+            saveTemWarning(tem, envWarningThreshold2, envDevice, farmId5);
+            envData.setEnvTemp(tem);
+            saveHumWarning(hum, envWarningThreshold2, envDevice, farmId5);
+            envData.setEnvHum(hum);
+            envDataService.save(envData);
+        }
+
+        Integer farmId6 = 28;
+        List<BasePigpen> list6 = basePigpenService.list(new QueryWrapper<BasePigpen>().eq("farm_id", farmId6).eq("f_type", 3));
+//        String url="https://restapi.amap.com/v3/weather/weatherInfo?parameters&key=c1d8179ed2dda7ed48c56bed06c0c86e&city=330782&extensions=base&output=JSON";
+//        String result = HttpUtil.get(url);
+//        WeatherDto weatherDto = JSONUtil.toBean(result, WeatherDto.class);
+//        List<WeatherLives> lives = weatherDto.getLives();
+//        WeatherLives weatherLives = lives.get(0);
+//        int humidity = Integer.parseInt(weatherLives.getHumidity());
+//        int temperature = Integer.parseInt(weatherLives.getTemperature());
+
+        for (BasePigpen basePigpen : list6) {
+            EnvData envData = new EnvData();
+            envData.setCreateTime(new Date());
+            envData.setFarmId(farmId6);
+            envData.setUnitId(basePigpen.getId());
+            EnvDevice envDevice = new EnvDevice();
+            envDevice.setUnitName(basePigpen.getBuildName());
+            envDevice.setUnitId(basePigpen.getId());
+            envDevice.setFarmId(farmId6);
+
+            String tem = NumberUtils.getNum(17, 23, 1);
+            String hum = NumberUtils.getNum(65, 80, 0);
+            saveTemWarning(tem, envWarningThreshold2, envDevice, farmId6);
+            envData.setEnvTemp(tem);
+            saveHumWarning(hum, envWarningThreshold2, envDevice, farmId6);
+            envData.setEnvHum(hum);
+            envDataService.save(envData);
+        }
     }
 
     public void saveHumWarning(String val, EnvWarningThreshold envWarningThreshold, EnvDevice envDevice, Integer farmId) {

+ 71 - 48
huimv-admin/src/main/java/com/huimv/admin/timer/GasTimer.java

@@ -18,7 +18,7 @@ import java.util.Date;
 
 @Configuration
 @EnableScheduling
-public class  GasTimer {
+public class GasTimer {
 
     @Autowired
     private GasDataMapper gasDataMapper;
@@ -28,10 +28,11 @@ public class  GasTimer {
     private GasThresholdMapper thresholdMapper;
 
     @Scheduled(cron = "0 0 */1 * * ? ")
+//    @Scheduled(cron = "0 0/2 * * * ? ")
     private void getShenChan() throws Exception {
 
         String type = NumberUtils.getNum(1, 5, 0);//loc_type
-        for (int i = 1; i < 21; i++) {
+        for (int i = 1; i < 29; i++) {
 
             String nh3n = NumberUtils.getNumFloat(0.0, 10.5);//NH3N
             String jlm = NumberUtils.getNumFloat(0.0, 10.5);//jlm
@@ -40,7 +41,7 @@ public class  GasTimer {
             String h2s = NumberUtils.getNumFloat(0.0, 10.5);//h2s
             String byx = NumberUtils.getNumFloat(0.0, 20.5);//byx
             String ch3 = NumberUtils.getNumFloat(0.0, 10.5);//ch3
-            String sja = NumberUtils.getNumFloat(0.0,10.5);//sja
+            String sja = NumberUtils.getNumFloat(0.0, 10.5);//sja
 
 
             GasData gasData = new GasData();
@@ -52,7 +53,13 @@ public class  GasTimer {
             gasData.setByx(byx);
             gasData.setCh3sh(ch3);
             gasData.setSja(sja);
-            if (i > 16) {
+            if (i > 24) {
+                gasData.setLoctionType(i - 24);//下水碓
+                gasData.setFarmId(22);
+            } else if (i > 20) {
+                gasData.setLoctionType(i - 20);//平望
+                gasData.setFarmId(28);
+            } else if (i > 16) {
                 gasData.setLoctionType(i - 16);//天台
                 gasData.setFarmId(27);
             } else if (i > 12) {
@@ -73,7 +80,7 @@ public class  GasTimer {
 
             QueryWrapper<GasThreshold> queryWrapper = new QueryWrapper<>();
             GasWarningInfo warningInfo = new GasWarningInfo();
-            if (i==1||i==5||i==9||i==13||i==17) {
+            if (i == 1 || i == 5 || i == 9 || i == 13 || i == 17 || i == 21 || i == 25) {
                 String cq = NumberUtils.getNumFloat(0.0, 1000.5);//cq
                 gasData.setCq(cq);
                 if (i == 1) {
@@ -84,12 +91,16 @@ public class  GasTimer {
                     queryWrapper.eq("farm_id", 23).eq("gas_type", 1);
                 } else if (i == 13) {
                     queryWrapper.eq("farm_id", 26).eq("gas_type", 1);
-                } else {
+                } else if (i == 17) {
                     queryWrapper.eq("farm_id", 27).eq("gas_type", 1);
+                } else if (i == 21) {
+                    queryWrapper.eq("farm_id", 28).eq("gas_type", 1);
+                } else {
+                    queryWrapper.eq("farm_id", 22).eq("gas_type", 1);
                 }
                 GasThreshold gasThreshold = thresholdMapper.selectOne(queryWrapper);
                 if (Double.parseDouble(nh3n) > Double.parseDouble(gasThreshold.getNh3N())) {
-                    warningInfo.setWarningContent("NH3N为"+nh3n + "超过阈值,系统预警提醒");
+                    warningInfo.setWarningContent("NH3N为" + nh3n + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(0);
                     warningInfo.setBuildLocation("屋顶");
                     warningInfo.setDate(new Date());
@@ -98,7 +109,7 @@ public class  GasTimer {
                     warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(jlm) > Double.parseDouble(gasThreshold.getJlm())) {
-                    warningInfo.setWarningContent("甲硫醚为"+jlm + "超过阈值,系统预警提醒");
+                    warningInfo.setWarningContent("甲硫醚为" + jlm + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(1);
                     warningInfo.setBuildLocation("屋顶");
                     warningInfo.setDate(new Date());
@@ -107,7 +118,7 @@ public class  GasTimer {
                     warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(elht) > Double.parseDouble(gasThreshold.getElht())) {
-                    warningInfo.setWarningContent("二硫化碳为"+elht + "超过阈值,系统预警提醒");
+                    warningInfo.setWarningContent("二硫化碳为" + elht + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(2);
                     warningInfo.setBuildLocation("屋顶");
                     warningInfo.setDate(new Date());
@@ -116,7 +127,7 @@ public class  GasTimer {
                     warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(ejel) > Double.parseDouble(gasThreshold.getEjel())) {
-                    warningInfo.setWarningContent("二甲二硫为"+ejel + "超过阈值,系统预警提醒");
+                    warningInfo.setWarningContent("二甲二硫为" + ejel + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(3);
                     warningInfo.setBuildLocation("屋顶");
                     warningInfo.setDate(new Date());
@@ -125,7 +136,7 @@ public class  GasTimer {
                     warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(h2s) > Double.parseDouble(gasThreshold.getH2s())) {
-                    warningInfo.setWarningContent("H2S为"+h2s + "超过阈值,系统预警提醒");
+                    warningInfo.setWarningContent("H2S为" + h2s + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(4);
                     warningInfo.setBuildLocation("屋顶");
                     warningInfo.setDate(new Date());
@@ -134,7 +145,7 @@ public class  GasTimer {
                     warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(byx) > Double.parseDouble(gasThreshold.getByx())) {
-                    warningInfo.setWarningContent("苯乙烯为"+byx + "超过阈值,系统预警提醒");
+                    warningInfo.setWarningContent("苯乙烯为" + byx + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(5);
                     warningInfo.setBuildLocation("屋顶");
                     warningInfo.setDate(new Date());
@@ -143,7 +154,7 @@ public class  GasTimer {
                     warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(ch3) > Double.parseDouble(gasThreshold.getCh3sh())) {
-                    warningInfo.setWarningContent("CH3SH为"+ch3 + "超过阈值,系统预警提醒");
+                    warningInfo.setWarningContent("CH3SH为" + ch3 + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(6);
                     warningInfo.setBuildLocation("屋顶");
                     warningInfo.setDate(new Date());
@@ -152,7 +163,7 @@ public class  GasTimer {
                     warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(sja) > Double.parseDouble(gasThreshold.getSja())) {
-                    warningInfo.setWarningContent("三甲胺为"+sja + "超过阈值,系统预警提醒");
+                    warningInfo.setWarningContent("三甲胺为" + sja + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(7);
                     warningInfo.setBuildLocation("屋顶");
                     warningInfo.setDate(new Date());
@@ -161,7 +172,7 @@ public class  GasTimer {
                     warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(cq) > Double.parseDouble(gasThreshold.getCq())) {
-                    warningInfo.setWarningContent("臭气为"+cq + "超过阈值,系统预警提醒");
+                    warningInfo.setWarningContent("臭气为" + cq + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(8);
                     warningInfo.setBuildLocation("屋顶");
                     warningInfo.setDate(new Date());
@@ -170,7 +181,7 @@ public class  GasTimer {
                     warningInfoMapper.insert(warningInfo);
                 }
 
-            } else if (i==2||i==6||i==10||i==14||i==18) {
+            } else if (i == 2 || i == 6 || i == 10 || i == 14 || i == 18 || i == 22 || i == 26) {
                 String cq = NumberUtils.getNumFloat(0.0, 5000.5);//cq
                 gasData.setCq(cq);
                 if (i == 2) {
@@ -181,12 +192,16 @@ public class  GasTimer {
                     queryWrapper.eq("farm_id", 23).eq("gas_type", 2);
                 } else if (i == 14) {
                     queryWrapper.eq("farm_id", 26).eq("gas_type", 2);
-                } else {
+                } else if (i == 18) {
                     queryWrapper.eq("farm_id", 27).eq("gas_type", 2);
+                } else if (i == 22) {
+                    queryWrapper.eq("farm_id", 28).eq("gas_type", 2);
+                } else {
+                    queryWrapper.eq("farm_id", 22).eq("gas_type", 2);
                 }
                 GasThreshold gasThreshold = thresholdMapper.selectOne(queryWrapper);
                 if (Double.parseDouble(nh3n) > Double.parseDouble(gasThreshold.getNh3N())) {
-                    warningInfo.setWarningContent("NH3N为"+nh3n + "超过阈值,系统预警提醒");
+                    warningInfo.setWarningContent("NH3N为" + nh3n + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(0);
                     warningInfo.setBuildLocation("厂界上");
                     warningInfo.setDate(new Date());
@@ -195,7 +210,7 @@ public class  GasTimer {
                     warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(jlm) > Double.parseDouble(gasThreshold.getJlm())) {
-                    warningInfo.setWarningContent("甲硫醚为"+jlm + "超过阈值,系统预警提醒");
+                    warningInfo.setWarningContent("甲硫醚为" + jlm + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(1);
                     warningInfo.setBuildLocation("厂界上");
                     warningInfo.setDate(new Date());
@@ -204,7 +219,7 @@ public class  GasTimer {
                     warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(elht) > Double.parseDouble(gasThreshold.getElht())) {
-                    warningInfo.setWarningContent("二硫化碳为"+elht + "超过阈值,系统预警提醒");
+                    warningInfo.setWarningContent("二硫化碳为" + elht + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(2);
                     warningInfo.setBuildLocation("厂界上");
                     warningInfo.setDate(new Date());
@@ -213,7 +228,7 @@ public class  GasTimer {
                     warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(ejel) > Double.parseDouble(gasThreshold.getEjel())) {
-                    warningInfo.setWarningContent("二甲二硫为"+ejel + "超过阈值,系统预警提醒");
+                    warningInfo.setWarningContent("二甲二硫为" + ejel + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(3);
                     warningInfo.setBuildLocation("厂界上");
                     warningInfo.setDate(new Date());
@@ -222,7 +237,7 @@ public class  GasTimer {
                     warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(h2s) > Double.parseDouble(gasThreshold.getH2s())) {
-                    warningInfo.setWarningContent("H2S为"+h2s + "超过阈值,系统预警提醒");
+                    warningInfo.setWarningContent("H2S为" + h2s + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(4);
                     warningInfo.setBuildLocation("厂界上");
                     warningInfo.setDate(new Date());
@@ -232,7 +247,7 @@ public class  GasTimer {
 
                 }
                 if (Double.parseDouble(byx) > Double.parseDouble(gasThreshold.getByx())) {
-                    warningInfo.setWarningContent("苯乙烯为"+byx + "超过阈值,系统预警提醒");
+                    warningInfo.setWarningContent("苯乙烯为" + byx + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(5);
                     warningInfo.setBuildLocation("厂界上");
                     warningInfo.setDate(new Date());
@@ -241,7 +256,7 @@ public class  GasTimer {
                     warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(ch3) > Double.parseDouble(gasThreshold.getCh3sh())) {
-                    warningInfo.setWarningContent("CH3SH为"+ch3 + "超过阈值,系统预警提醒");
+                    warningInfo.setWarningContent("CH3SH为" + ch3 + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(6);
                     warningInfo.setBuildLocation("厂界上");
                     warningInfo.setDate(new Date());
@@ -250,7 +265,7 @@ public class  GasTimer {
                     warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(sja) > Double.parseDouble(gasThreshold.getSja())) {
-                    warningInfo.setWarningContent("三甲胺为"+sja + "超过阈值,系统预警提醒");
+                    warningInfo.setWarningContent("三甲胺为" + sja + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(7);
                     warningInfo.setBuildLocation("厂界上");
                     warningInfo.setDate(new Date());
@@ -259,7 +274,7 @@ public class  GasTimer {
                     warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(cq) > Double.parseDouble(gasThreshold.getCq())) {
-                    warningInfo.setWarningContent("臭气为"+cq + "超过阈值,系统预警提醒");
+                    warningInfo.setWarningContent("臭气为" + cq + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(8);
                     warningInfo.setBuildLocation("厂界上");
                     warningInfo.setDate(new Date());
@@ -268,7 +283,7 @@ public class  GasTimer {
                     warningInfoMapper.insert(warningInfo);
                 }
 
-            } else if (i==3||i==7||i==11||i==15||i==19) {
+            } else if (i == 3 || i == 7 || i == 11 || i == 15 || i == 19||i==23||i==27) {
                 String cq = NumberUtils.getNumFloat(0.0, 1000.5);//cq
                 gasData.setCq(cq);
                 if (i == 3) {
@@ -279,12 +294,16 @@ public class  GasTimer {
                     queryWrapper.eq("farm_id", 23).eq("gas_type", 3);
                 } else if (i == 15) {
                     queryWrapper.eq("farm_id", 26).eq("gas_type", 3);
-                } else {
+                } else if (i==19){
                     queryWrapper.eq("farm_id", 27).eq("gas_type", 3);
+                }else if (i==23){
+                    queryWrapper.eq("farm_id", 28).eq("gas_type", 3);
+                }else {
+                    queryWrapper.eq("farm_id", 22).eq("gas_type", 3);
                 }
                 GasThreshold gasThreshold = thresholdMapper.selectOne(queryWrapper);
                 if (Double.parseDouble(nh3n) > Double.parseDouble(gasThreshold.getNh3N())) {
-                    warningInfo.setWarningContent("NH3N为"+nh3n + "超过阈值,系统预警提醒");
+                    warningInfo.setWarningContent("NH3N为" + nh3n + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(0);
                     warningInfo.setBuildLocation("厂界下");
                     warningInfo.setDate(new Date());
@@ -293,7 +312,7 @@ public class  GasTimer {
                     warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(jlm) > Double.parseDouble(gasThreshold.getJlm())) {
-                    warningInfo.setWarningContent("甲硫醚为"+jlm + "超过阈值,系统预警提醒");
+                    warningInfo.setWarningContent("甲硫醚为" + jlm + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(1);
                     warningInfo.setBuildLocation("厂界下");
                     warningInfo.setDate(new Date());
@@ -302,7 +321,7 @@ public class  GasTimer {
                     warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(elht) > Double.parseDouble(gasThreshold.getElht())) {
-                    warningInfo.setWarningContent("二硫化碳为"+elht + "超过阈值,系统预警提醒");
+                    warningInfo.setWarningContent("二硫化碳为" + elht + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(2);
                     warningInfo.setBuildLocation("厂界下");
                     warningInfo.setDate(new Date());
@@ -311,7 +330,7 @@ public class  GasTimer {
                     warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(ejel) > Double.parseDouble(gasThreshold.getEjel())) {
-                    warningInfo.setWarningContent("二甲二硫为"+ejel + "超过阈值,系统预警提醒");
+                    warningInfo.setWarningContent("二甲二硫为" + ejel + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(3);
                     warningInfo.setBuildLocation("厂界下");
                     warningInfo.setDate(new Date());
@@ -320,7 +339,7 @@ public class  GasTimer {
                     warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(h2s) > Double.parseDouble(gasThreshold.getH2s())) {
-                    warningInfo.setWarningContent("H2S为"+h2s + "超过阈值,系统预警提醒");
+                    warningInfo.setWarningContent("H2S为" + h2s + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(4);
                     warningInfo.setBuildLocation("厂界下");
                     warningInfo.setDate(new Date());
@@ -330,7 +349,7 @@ public class  GasTimer {
 
                 }
                 if (Double.parseDouble(byx) > Double.parseDouble(gasThreshold.getByx())) {
-                    warningInfo.setWarningContent("苯乙烯为"+byx + "超过阈值,系统预警提醒");
+                    warningInfo.setWarningContent("苯乙烯为" + byx + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(5);
                     warningInfo.setBuildLocation("厂界下");
                     warningInfo.setDate(new Date());
@@ -339,7 +358,7 @@ public class  GasTimer {
                     warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(ch3) > Double.parseDouble(gasThreshold.getCh3sh())) {
-                    warningInfo.setWarningContent("CH3SH为"+ch3 + "超过阈值,系统预警提醒");
+                    warningInfo.setWarningContent("CH3SH为" + ch3 + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(6);
                     warningInfo.setBuildLocation("厂界下");
                     warningInfo.setDate(new Date());
@@ -348,7 +367,7 @@ public class  GasTimer {
                     warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(sja) > Double.parseDouble(gasThreshold.getSja())) {
-                    warningInfo.setWarningContent("三甲胺为"+sja + "超过阈值,系统预警提醒");
+                    warningInfo.setWarningContent("三甲胺为" + sja + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(7);
                     warningInfo.setBuildLocation("厂界下");
                     warningInfo.setDate(new Date());
@@ -357,7 +376,7 @@ public class  GasTimer {
                     warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(cq) > Double.parseDouble(gasThreshold.getCq())) {
-                    warningInfo.setWarningContent("臭气为"+cq + "超过阈值,系统预警提醒");
+                    warningInfo.setWarningContent("臭气为" + cq + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(8);
                     warningInfo.setBuildLocation("厂界下");
                     warningInfo.setDate(new Date());
@@ -366,7 +385,7 @@ public class  GasTimer {
                     warningInfoMapper.insert(warningInfo);
                 }
 
-            } else if (i==4||i==8||i==12||i==16||i==20) {
+            } else if (i == 4 || i == 8 || i == 12 || i == 16 || i == 20||i==24||i==28) {
                 String cq = NumberUtils.getNumFloat(0.0, 10000.5);//cq
                 gasData.setCq(cq);
                 if (i == 4) {
@@ -377,12 +396,16 @@ public class  GasTimer {
                     queryWrapper.eq("farm_id", 23).eq("gas_type", 4);
                 } else if (i == 16) {
                     queryWrapper.eq("farm_id", 26).eq("gas_type", 4);
-                } else {
+                } else if (i==20){
                     queryWrapper.eq("farm_id", 27).eq("gas_type", 4);
+                } else if (i==24){
+                    queryWrapper.eq("farm_id", 28).eq("gas_type", 4);
+                } else {
+                    queryWrapper.eq("farm_id", 22).eq("gas_type", 4);
                 }
                 GasThreshold gasThreshold = thresholdMapper.selectOne(queryWrapper);
                 if (Double.parseDouble(nh3n) > Double.parseDouble(gasThreshold.getNh3N())) {
-                    warningInfo.setWarningContent("NH3N为"+nh3n + "超过阈值,系统预警提醒");
+                    warningInfo.setWarningContent("NH3N为" + nh3n + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(0);
                     warningInfo.setBuildLocation("厂界居民");
                     warningInfo.setDate(new Date());
@@ -391,7 +414,7 @@ public class  GasTimer {
                     warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(jlm) > Double.parseDouble(gasThreshold.getJlm())) {
-                    warningInfo.setWarningContent("甲硫醚为"+jlm + "超过阈值,系统预警提醒");
+                    warningInfo.setWarningContent("甲硫醚为" + jlm + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(1);
                     warningInfo.setBuildLocation("厂界居民");
                     warningInfo.setDate(new Date());
@@ -400,7 +423,7 @@ public class  GasTimer {
                     warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(elht) > Double.parseDouble(gasThreshold.getElht())) {
-                    warningInfo.setWarningContent("二硫化碳为"+elht + "超过阈值,系统预警提醒");
+                    warningInfo.setWarningContent("二硫化碳为" + elht + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(2);
                     warningInfo.setBuildLocation("厂界居民");
                     warningInfo.setDate(new Date());
@@ -409,7 +432,7 @@ public class  GasTimer {
                     warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(ejel) > Double.parseDouble(gasThreshold.getEjel())) {
-                    warningInfo.setWarningContent("二甲二硫为"+ejel + "超过阈值,系统预警提醒");
+                    warningInfo.setWarningContent("二甲二硫为" + ejel + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(3);
                     warningInfo.setBuildLocation("厂界居民");
                     warningInfo.setDate(new Date());
@@ -418,7 +441,7 @@ public class  GasTimer {
                     warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(h2s) > Double.parseDouble(gasThreshold.getH2s())) {
-                    warningInfo.setWarningContent("H2S为"+h2s + "超过阈值,系统预警提醒");
+                    warningInfo.setWarningContent("H2S为" + h2s + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(4);
                     warningInfo.setBuildLocation("厂界居民");
                     warningInfo.setDate(new Date());
@@ -427,7 +450,7 @@ public class  GasTimer {
                     warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(byx) > Double.parseDouble(gasThreshold.getByx())) {
-                    warningInfo.setWarningContent("苯乙烯为"+byx + "超过阈值,系统预警提醒");
+                    warningInfo.setWarningContent("苯乙烯为" + byx + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(5);
                     warningInfo.setBuildLocation("厂界居民");
                     warningInfo.setDate(new Date());
@@ -436,7 +459,7 @@ public class  GasTimer {
                     warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(ch3) > Double.parseDouble(gasThreshold.getCh3sh())) {
-                    warningInfo.setWarningContent("CH3SH为"+ch3 + "超过阈值,系统预警提醒");
+                    warningInfo.setWarningContent("CH3SH为" + ch3 + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(6);
                     warningInfo.setBuildLocation("厂界居民");
                     warningInfo.setDate(new Date());
@@ -445,7 +468,7 @@ public class  GasTimer {
                     warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(sja) > Double.parseDouble(gasThreshold.getSja())) {
-                    warningInfo.setWarningContent("三甲胺为"+sja + "超过阈值,系统预警提醒");
+                    warningInfo.setWarningContent("三甲胺为" + sja + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(7);
                     warningInfo.setBuildLocation("厂界居民");
                     warningInfo.setDate(new Date());
@@ -454,7 +477,7 @@ public class  GasTimer {
                     warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(cq) > Double.parseDouble(gasThreshold.getCq())) {
-                    warningInfo.setWarningContent("臭气为"+cq + "超过阈值,系统预警提醒");
+                    warningInfo.setWarningContent("臭气为" + cq + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(8);
                     warningInfo.setBuildLocation("厂界居民");
                     warningInfo.setDate(new Date());

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

@@ -28,10 +28,11 @@ public class ProtTimer {
 
     //    环保数据
     @Scheduled(cron = "0 0 */1 * * ? ")
+//    @Scheduled(cron = "0 0/2 * * * ? ")
     private void getShenChan() throws Exception {
 
 
-        for (int i = 1; i < 16; i++) {
+        for (int i = 1; i < 24; i++) {
             //假设已经拿到了数据
             String num = NumberUtils.getNumFloat(6.4, 8.6);//ph
 
@@ -50,16 +51,22 @@ public class ProtTimer {
             } else if (i < 13) {
                 protData.setLoctionType(i - 9);
                 protData.setFarmId(26);//横路
-            } else {
+            } else if (i < 16) {
                 protData.setLoctionType(i - 12);
                 protData.setFarmId(27);//天台
+            } else if (i < 19) {
+                protData.setLoctionType(i - 15);
+                protData.setFarmId(28);//平望
+            } else if (i < 22) {
+                protData.setLoctionType(i - 18);
+                protData.setFarmId(22);//下水碓
             }
 
             protData.setPh(num);
 
             QueryWrapper<ProtThreshold> queryWrapper = new QueryWrapper<>();
-            if (i == 1||i==4||i==7||i==10||i==13) {
-                String num1 = NumberUtils.getNum(8000, 20001,0);//cod
+            if (i == 1 || i == 4 || i == 7 || i == 10 || i == 13 || i == 16 || i == 19) {
+                String num1 = NumberUtils.getNum(8000, 20001, 0);//cod
                 String num2 = NumberUtils.getNumFloat(1000.0, 1501.0);//nh3n
                 String num3 = NumberUtils.getNumFloat(100.0, 260.0);//tp
                 String num4 = NumberUtils.getNum(1000, 1550, 0);//tn
@@ -80,8 +87,12 @@ public class ProtTimer {
                     queryWrapper.eq("farm_id", 23).eq("prot_type", 1);
                 } else if (i == 10) {
                     queryWrapper.eq("farm_id", 26).eq("prot_type", 1);
-                } else {
+                } else if (i == 13) {
                     queryWrapper.eq("farm_id", 27).eq("prot_type", 1);
+                } else if (i == 16) {
+                    queryWrapper.eq("farm_id", 28).eq("prot_type", 1);
+                } else {
+                    queryWrapper.eq("farm_id", 22).eq("prot_type", 1);
                 }
                 ProtThreshold protThreshold = protThresholdMapper.selectOne(queryWrapper);//进污口
                 if (Double.parseDouble(num) > Double.parseDouble(protThreshold.getPh2()) || Double.parseDouble(num) < Double.parseDouble(protThreshold.getOther3())) {
@@ -218,7 +229,7 @@ public class ProtTimer {
                 }
 
             }
-            if (i == 2 || i == 5 || i == 8||i==11||i==14) {
+            if (i == 2 || i == 5 || i == 8 || i == 11 || i == 14 || i == 17 || i == 20) {
                 String num1 = NumberUtils.getNum(0, 310, 0);//cod
                 String num2 = NumberUtils.getNumFloat(0.0, 31.0);//nh3n
                 String num3 = NumberUtils.getNumFloat(0.0, 3.6);//tp
@@ -240,8 +251,12 @@ public class ProtTimer {
                     queryWrapper.eq("farm_id", 23).eq("prot_type", 2);
                 } else if (i == 11) {
                     queryWrapper.eq("farm_id", 26).eq("prot_type", 2);
-                } else {
+                } else if (i == 14) {
                     queryWrapper.eq("farm_id", 27).eq("prot_type", 2);
+                } else if (i == 17) {
+                    queryWrapper.eq("farm_id", 28).eq("prot_type", 2);
+                } else {
+                    queryWrapper.eq("farm_id", 22).eq("prot_type", 2);
                 }
                 ProtThreshold protThreshold = protThresholdMapper.selectOne(queryWrapper);//污口
                 if (Double.parseDouble(num) > Double.parseDouble(protThreshold.getPh2()) || Double.parseDouble(num) < Double.parseDouble(protThreshold.getOther3())) {
@@ -378,7 +393,7 @@ public class ProtTimer {
                 }
 
             }
-            if (i == 3 || i == 6 || i == 9||i==12||i==15) {
+            if (i == 3 || i == 6 || i == 9 || i == 12 || i == 15 || i == 18 || i == 21) {
                 //排污口专用数据
                 String ph = NumberUtils.getNumFloat(6.6, 8.4);//ph
                 String cod = NumberUtils.getNum(0, 380, 0);//cod
@@ -404,8 +419,12 @@ public class ProtTimer {
                     queryWrapper.eq("farm_id", 23).eq("prot_type", 3);
                 } else if (i == 12) {
                     queryWrapper.eq("farm_id", 26).eq("prot_type", 3);
-                } else {
+                } else if (i == 15) {
                     queryWrapper.eq("farm_id", 27).eq("prot_type", 3);
+                } else if (i == 18) {
+                    queryWrapper.eq("farm_id", 28).eq("prot_type", 3);
+                } else {
+                    queryWrapper.eq("farm_id", 22).eq("prot_type", 3);
                 }
                 ProtThreshold protThreshold = protThresholdMapper.selectOne(queryWrapper);//进污口
                 if (Double.parseDouble(ph) > Double.parseDouble(protThreshold.getPh2()) || Double.parseDouble(ph) < Double.parseDouble(protThreshold.getOther3())) {