瀏覽代碼

新牧场数据添加

wwh 1 年之前
父節點
當前提交
d94675d848

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

@@ -66,7 +66,7 @@ public class EnvTimer {
     String passwordMD5 = "21218cca77804d2ba1922c33e0151105";
     String baseurl = "https://yzwlw.loongk.com/";
 
-    @Scheduled(cron = "0 0/11 * * * ? ")
+    @Scheduled(cron = "0 0/30 * * * ? ")
 //    @Scheduled(cron = "0 * * * * ? ")
     @Transactional
     public void getHuanKong() throws Exception {
@@ -134,7 +134,7 @@ public class EnvTimer {
         }
     }
 
-    @Scheduled(cron = "0 0/12 * * * ?")
+    @Scheduled(cron = "0 0/59 * * * ?")
     @Transactional
     public void getHuanKongs()  {
         Integer farmId = 21;
@@ -343,6 +343,35 @@ public class EnvTimer {
             envData.setEnvHum(hum);
             envDataService.save(envData);
         }
+
+        Integer farmId7 = 39;
+        List<BasePigpen> list7 = basePigpenService.list(new QueryWrapper<BasePigpen>().eq("farm_id", farmId7).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 : list7) {
+            EnvData envData = new EnvData();
+            envData.setCreateTime(new Date());
+            envData.setFarmId(farmId7);
+            envData.setUnitId(basePigpen.getId());
+            EnvDevice envDevice = new EnvDevice();
+            envDevice.setUnitName(basePigpen.getBuildName());
+            envDevice.setUnitId(basePigpen.getId());
+            envDevice.setFarmId(farmId7);
+
+            String tem = NumberUtils.getNum(17, 23, 1);
+            String hum = NumberUtils.getNum(65, 80, 0);
+            saveTemWarning(tem, envWarningThreshold2, envDevice, farmId7);
+            envData.setEnvTemp(tem);
+            saveHumWarning(hum, envWarningThreshold2, envDevice, farmId7);
+            envData.setEnvHum(hum);
+            envDataService.save(envData);
+        }
     }
 
     public void saveHumWarning(String val, EnvWarningThreshold envWarningThreshold, EnvDevice envDevice, Integer farmId) {

+ 16 - 11
huimv-admin/src/main/java/com/huimv/admin/timer/GasTimer.java

@@ -32,7 +32,7 @@ public class GasTimer {
     private void getShenChan() throws Exception {
 
         String type = NumberUtils.getNum(1, 5, 0);//loc_type
-        for (int i = 1; i < 29; i++) {
+        for (int i = 1; i < 33; i++) {
 
             String nh3n = NumberUtils.getNumFloat(0.0, 10.5);//NH3N
             String jlm = NumberUtils.getNumFloat(0.0, 10.5);//jlm
@@ -53,7 +53,10 @@ public class GasTimer {
             gasData.setByx(byx);
             gasData.setCh3sh(ch3);
             gasData.setSja(sja);
-            if (i > 24) {
+            if (i > 28) {
+                gasData.setLoctionType(i - 28);//下水碓
+                gasData.setFarmId(39);
+            } else if (i > 24) {
                 gasData.setLoctionType(i - 24);//下水碓
                 gasData.setFarmId(22);
             } else if (i > 20) {
@@ -80,7 +83,7 @@ public class GasTimer {
 
             QueryWrapper<GasThreshold> queryWrapper = new QueryWrapper<>();
             GasWarningInfo warningInfo = new GasWarningInfo();
-            if (i == 1 || i == 5 || i == 9 || i == 13 || i == 17 || i == 21 || i == 25) {
+            if (i == 1 || i == 5 || i == 9 || i == 13 || i == 17 || i == 21 || i == 25|| i == 29) {
                 String cq = NumberUtils.getNumFloat(0.0, 1000.5);//cq
                 gasData.setCq(cq);
                 if (i == 1) {
@@ -95,8 +98,10 @@ public class GasTimer {
                     queryWrapper.eq("farm_id", 27).eq("gas_type", 1);
                 } else if (i == 21) {
                     queryWrapper.eq("farm_id", 28).eq("gas_type", 1);
-                } else {
+                }else if (i == 25) {
                     queryWrapper.eq("farm_id", 22).eq("gas_type", 1);
+                } else {
+                    queryWrapper.eq("farm_id", 39).eq("gas_type", 1);
                 }
                 GasThreshold gasThreshold = thresholdMapper.selectOne(queryWrapper);
                 if (Double.parseDouble(nh3n) > Double.parseDouble(gasThreshold.getNh3N())) {
@@ -283,7 +288,7 @@ public class GasTimer {
                     warningInfoMapper.insert(warningInfo);
                 }
 
-            } else if (i == 3 || i == 7 || i == 11 || i == 15 || i == 19||i==23||i==27) {
+            } 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) {
@@ -294,11 +299,11 @@ 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 if (i==19){
+                } else if (i == 19) {
                     queryWrapper.eq("farm_id", 27).eq("gas_type", 3);
-                }else if (i==23){
+                } else if (i == 23) {
                     queryWrapper.eq("farm_id", 28).eq("gas_type", 3);
-                }else {
+                } else {
                     queryWrapper.eq("farm_id", 22).eq("gas_type", 3);
                 }
                 GasThreshold gasThreshold = thresholdMapper.selectOne(queryWrapper);
@@ -385,7 +390,7 @@ public class GasTimer {
                     warningInfoMapper.insert(warningInfo);
                 }
 
-            } else if (i == 4 || i == 8 || i == 12 || i == 16 || i == 20||i==24||i==28) {
+            } 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) {
@@ -396,9 +401,9 @@ 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 if (i==20){
+                } else if (i == 20) {
                     queryWrapper.eq("farm_id", 27).eq("gas_type", 4);
-                } else if (i==24){
+                } else if (i == 24) {
                     queryWrapper.eq("farm_id", 28).eq("gas_type", 4);
                 } else {
                     queryWrapper.eq("farm_id", 22).eq("gas_type", 4);

+ 1 - 1
huimv-admin/src/main/java/com/huimv/admin/timer/NewEnvTimer.java

@@ -47,7 +47,7 @@ public class NewEnvTimer {
     private IEnvNh3nService nh3nService;
 
 
-    @Scheduled(cron = "0 0/20 * * * ?")  //每10分钟执行一次
+    @Scheduled(cron = "0 0/59 * * * ?")  //每10分钟执行一次
 //    @Scheduled(cron = "0 * * * * ?")  //每10分钟执行一次
 //    @Scheduled(cron = "*/5 * * * * ?")  //每10秒钟执行一次
     public void getDeviceFlowData() throws ParseException {

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

@@ -32,7 +32,7 @@ public class ProtTimer {
     private void getShenChan() throws Exception {
 
 
-        for (int i = 1; i < 24; i++) {
+        for (int i = 1; i < 27; i++) {
             //假设已经拿到了数据
             String num = NumberUtils.getNumFloat(6.4, 8.6);//ph
 
@@ -60,12 +60,15 @@ public class ProtTimer {
             } else if (i < 22) {
                 protData.setLoctionType(i - 18);
                 protData.setFarmId(22);//下水碓
+            } else if (i < 25) {
+                protData.setLoctionType(i - 21);
+                protData.setFarmId(39);//下水碓
             }
 
             protData.setPh(num);
 
             QueryWrapper<ProtThreshold> queryWrapper = new QueryWrapper<>();
-            if (i == 1 || i == 4 || i == 7 || i == 10 || i == 13 || i == 16 || i == 19) {
+            if (i == 1 || i == 4 || i == 7 || i == 10 || i == 13 || i == 16 || i == 19|| i == 22) {
                 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
@@ -229,7 +232,7 @@ public class ProtTimer {
                 }
 
             }
-            if (i == 2 || i == 5 || i == 8 || i == 11 || i == 14 || i == 17 || i == 20) {
+            if (i == 2 || i == 5 || i == 8 || i == 11 || i == 14 || i == 17 || i == 20|| i == 23) {
                 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
@@ -393,7 +396,7 @@ public class ProtTimer {
                 }
 
             }
-            if (i == 3 || i == 6 || i == 9 || i == 12 || i == 15 || i == 18 || i == 21) {
+            if (i == 3 || i == 6 || i == 9 || i == 12 || i == 15 || i == 18 || i == 21|| i == 24) {
                 //排污口专用数据
                 String ph = NumberUtils.getNumFloat(6.6, 8.4);//ph
                 String cod = NumberUtils.getNum(0, 380, 0);//cod

+ 54 - 54
huimv-admin/src/main/java/com/huimv/admin/timer/SafeTimer.java

@@ -1,54 +1,54 @@
-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.BillIsolate;
-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 com.huimv.admin.service.IBillIsolateService;
-import com.huimv.admin.service.IBillPcrService;
-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.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.List;
-
-@Configuration
-@EnableScheduling
-public class SafeTimer {
-
-
-    @Autowired
-    private IBillPcrService pcrService;
-    @Autowired
-    private IBillIsolateService isolateService;
-
-
-    @Scheduled(cron = "0 0/1 * * * ? ")
-    private void getShenChan() throws Exception {
-        QueryWrapper<BillIsolate> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("bill_status", 1);
-        List<BillIsolate> isolates = isolateService.list(queryWrapper);
-        Date date = new Date();
-        for (BillIsolate isolate : isolates) {
-            if (isolate.getIsolateEndDate().getTime() <= date.getTime()) {
-                isolate.setIsolateRealEndDate(date);
-                isolate.setIsolateRealDayNum(isolate.getIsolateDayNum());
-                isolate.setBillStatus(2);
-                isolate.setPassUserName("自然解除隔离");
-                isolate.setPassDate(date);
-                isolateService.updateById(isolate);
-            }
-        }
-    }
-
-}
+//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.BillIsolate;
+//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 com.huimv.admin.service.IBillIsolateService;
+//import com.huimv.admin.service.IBillPcrService;
+//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.text.ParseException;
+//import java.text.SimpleDateFormat;
+//import java.util.Date;
+//import java.util.List;
+//
+//@Configuration
+//@EnableScheduling
+//public class SafeTimer {
+//
+//
+//    @Autowired
+//    private IBillPcrService pcrService;
+//    @Autowired
+//    private IBillIsolateService isolateService;
+//
+//
+//    @Scheduled(cron = "0 0/1 * * * ? ")
+//    private void getShenChan() throws Exception {
+//        QueryWrapper<BillIsolate> queryWrapper = new QueryWrapper<>();
+//        queryWrapper.eq("bill_status", 1);
+//        List<BillIsolate> isolates = isolateService.list(queryWrapper);
+//        Date date = new Date();
+//        for (BillIsolate isolate : isolates) {
+//            if (isolate.getIsolateEndDate().getTime() <= date.getTime()) {
+//                isolate.setIsolateRealEndDate(date);
+//                isolate.setIsolateRealDayNum(isolate.getIsolateDayNum());
+//                isolate.setBillStatus(2);
+//                isolate.setPassUserName("自然解除隔离");
+//                isolate.setPassDate(date);
+//                isolateService.updateById(isolate);
+//            }
+//        }
+//    }
+//
+//}