wwh il y a 1 mois
Parent
commit
e235d6568a
23 fichiers modifiés avec 6564 ajouts et 6505 suppressions
  1. 131 131
      huimv-admin/src/main/java/com/huimv/admin/jinghongtimer/EnergyFeedTimer.java
  2. 86 86
      huimv-admin/src/main/java/com/huimv/admin/jinghongtimer/EnvTimer.java
  3. 101 101
      huimv-admin/src/main/java/com/huimv/admin/jinghongtimer/ProtTimer.java
  4. 8 5
      huimv-admin/src/main/java/com/huimv/admin/server/EnvInputServerHandler.java
  5. 3 2
      huimv-admin/src/main/java/com/huimv/admin/service/impl/ProtDataServiceImpl.java
  6. 103 103
      huimv-admin/src/main/java/com/huimv/admin/timer/CarmeraTimer.java
  7. 56 56
      huimv-admin/src/main/java/com/huimv/admin/timer/EnergyFeedTimer.java
  8. 159 159
      huimv-admin/src/main/java/com/huimv/admin/timer/EnergyTimer.java
  9. 524 524
      huimv-admin/src/main/java/com/huimv/admin/timer/EnvTimer.java
  10. 296 296
      huimv-admin/src/main/java/com/huimv/admin/timer/FeedTimer.java
  11. 50 50
      huimv-admin/src/main/java/com/huimv/admin/timer/FermentTimer.java
  12. 499 499
      huimv-admin/src/main/java/com/huimv/admin/timer/GasTimer.java
  13. 215 215
      huimv-admin/src/main/java/com/huimv/admin/timer/NewEnvTimer.java
  14. 184 184
      huimv-admin/src/main/java/com/huimv/admin/timer/ProdWarningTimer.java
  15. 569 569
      huimv-admin/src/main/java/com/huimv/admin/timer/ProtTimer.java
  16. 528 528
      huimv-admin/src/main/java/com/huimv/admin/timer/ShenChanTimer.java
  17. 2974 2974
      huimv-admin/src/main/java/com/huimv/admin/timer/WaterAndElcTimer.java
  18. 2 1
      huimv-receive/src/main/java/com/huimv/receive/service/impl/BaseProcessServiceImpl.java
  19. 10 10
      huimv-receive/src/main/java/com/huimv/receive/service/impl/BillCleanServiceImpl.java
  20. 42 0
      huimv-receive/src/main/java/com/huimv/receive/service/impl/BillPcrServiceImpl.java
  21. 12 0
      huimv-receive/src/main/java/com/huimv/receive/service/impl/BillPersonnelAdmissionServiceImpl.java
  22. 3 3
      huimv-receive/src/main/java/com/huimv/receive/timer/DiBangimer.java
  23. 9 9
      huimv-receive/src/main/resources/com/huimv/receive/mapper/BillCleanMapper.xml

+ 131 - 131
huimv-admin/src/main/java/com/huimv/admin/jinghongtimer/EnergyFeedTimer.java

@@ -1,136 +1,136 @@
-//package com.huimv.admin.jinghongtimer;
-//
-//import cn.hutool.core.date.DateTime;
-//import cn.hutool.core.date.DateUtil;
-//import cn.hutool.core.util.ObjectUtil;
-//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-//import com.huimv.admin.entity.EnergyData;
-//import com.huimv.admin.entity.EnergyEnvDevice;
-//import com.huimv.admin.jinghongtimer.Vo.EneryDataVo;
-//import com.huimv.admin.jinghongtimer.Vo.EneryDataVo3;
-//import com.huimv.admin.jinghongtimer.Vo.TokenVo;
-//import com.huimv.admin.mapper.EnergyDataMapper;
-//import com.huimv.admin.mapper.EnergyEnvDeviceMapper;
-//import org.springframework.beans.factory.annotation.Autowired;
-//import org.springframework.context.annotation.Configuration;
-//import org.springframework.http.HttpEntity;
-//import org.springframework.http.HttpHeaders;
-//import org.springframework.http.MediaType;
-//import org.springframework.http.ResponseEntity;
-//import org.springframework.scheduling.annotation.EnableScheduling;
-//import org.springframework.scheduling.annotation.Scheduled;
-//import org.springframework.util.LinkedMultiValueMap;
-//import org.springframework.util.MultiValueMap;
-//import org.springframework.util.StringUtils;
-//import org.springframework.web.bind.annotation.GetMapping;
-//import org.springframework.web.bind.annotation.RequestMapping;
-//import org.springframework.web.bind.annotation.RestController;
-//import org.springframework.web.client.RestTemplate;
-//
-//import java.util.Date;
-//import java.util.List;
-//
-//
-////@RestController
-////@RequestMapping("/test")
-//@Configuration
-//@EnableScheduling
-//public class EnergyFeedTimer {
-//    @Autowired
-//    private EnergyEnvDeviceMapper energyEnvDeviceMapper;
-//    @Autowired
-//    private EnergyDataMapper energyDataMapper;
-//    @Autowired
-//    private RestTemplate restTemplate;
-//
-//
-////    @GetMapping("/test3")
+package com.huimv.admin.jinghongtimer;
+
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.huimv.admin.entity.EnergyData;
+import com.huimv.admin.entity.EnergyEnvDevice;
+import com.huimv.admin.jinghongtimer.Vo.EneryDataVo;
+import com.huimv.admin.jinghongtimer.Vo.EneryDataVo3;
+import com.huimv.admin.jinghongtimer.Vo.TokenVo;
+import com.huimv.admin.mapper.EnergyDataMapper;
+import com.huimv.admin.mapper.EnergyEnvDeviceMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.Date;
+import java.util.List;
+
+
+//@RestController
+//@RequestMapping("/test")
+@Configuration
+@EnableScheduling
+public class EnergyFeedTimer {
+    @Autowired
+    private EnergyEnvDeviceMapper energyEnvDeviceMapper;
+    @Autowired
+    private EnergyDataMapper energyDataMapper;
+    @Autowired
+    private RestTemplate restTemplate;
+
+
+//    @GetMapping("/test3")
+    @Scheduled(cron = "0 0 * * * ? ")
+    public void action(){
+        DateTime dateTime = DateUtil.offsetHour(new Date(),-1);
+        DateTime endOfMonth = new DateTime();
+        List<EnergyEnvDevice> remark = energyEnvDeviceMapper.selectList(new QueryWrapper<EnergyEnvDevice>().eq("remark", 3));
+        String url = "http://api.infoexdata.cn/foreignApps/foreignerDevice/getDeviceInventoryList";
+        String token = getToke();
+        for (EnergyEnvDevice energyEnvDevice : remark) {
+
+            MultiValueMap<String, String> formData = new LinkedMultiValueMap<>();
+            formData.add("pageNum", "1");
+            formData.add("pageSize", "20");
+            formData.add("uniqueNo", energyEnvDevice.getDeviceCode());
+            formData.add("type", "2");
+            formData.add("compensate", "0");
+            formData.add("startTime", dateTime.toString("yyyy-MM-dd HH:mm:ss"));
+            formData.add("endTime", endOfMonth.toString("yyyy-MM-dd HH:mm:ss"));
+
+            // 设置请求头,指定内容类型为 form-data
+            HttpHeaders headers = new HttpHeaders();
+            headers.set("token",token);
+            headers.setContentType(MediaType.MULTIPART_FORM_DATA);
+            // 创建 HttpEntity
+            HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(formData, headers);
+            // 发送 POST 请求
+            ResponseEntity<EneryDataVo> response = restTemplate.postForEntity(url, requestEntity, EneryDataVo.class);
+            EneryDataVo body = response.getBody();
+            System.out.println(body);
+            if (ObjectUtil.isEmpty(body) || ObjectUtil.isEmpty(body.getData())){
+                continue;
+            }
+            if (body.getData().getRecords() !=null){
+                List<EneryDataVo3> records = body.getData().getRecords();
+                for (EneryDataVo3 record : records) {
+                    EnergyData energyData = new EnergyData();
+//                    energyData.setCreateDate(DateUtil.parse(record.getEndTime(),"yyyy-MM-dd HH:mm:ss"));
+                    energyData.setCreateDate(record.getEndTime());
+                    energyData.setDisplayType(0);
+                    energyData.setFeedValue(record.getNum()+"");
+                    energyData.setUnitId(energyEnvDevice.getUnitId());
+                    energyData.setUnitName(energyEnvDevice.getUnitName());
+                    energyData.setFarmId(energyEnvDevice.getFarmId());
+                    energyDataMapper.insert(energyData);
+                }
+            }
+        }
+
+    }
+
+
+    private  String getToke(){
+        String url = "http://api.infoexdata.cn/foreignApps/foreignApplications/getToken?appId=farnek23dxr5yk8ymvwuhbmup&appKey=x6re4jt63kcpyt3jhyjzb4ckj";
+        TokenVo forObject = restTemplate.getForObject(url, TokenVo.class);
+        if (ObjectUtil.isNotEmpty(forObject) &&forObject.getCode() ==200 ){
+            return forObject.getData();
+        }else {
+            return null;
+        }
+    }
+
+
+    //华统料塔
 //    @Scheduled(cron = "0 0 * * * ? ")
-//    public void action(){
-//        DateTime dateTime = DateUtil.offsetHour(new Date(),-1);
-//        DateTime endOfMonth = new DateTime();
-//        List<EnergyEnvDevice> remark = energyEnvDeviceMapper.selectList(new QueryWrapper<EnergyEnvDevice>().eq("remark", 3));
-//        String url = "http://api.infoexdata.cn/foreignApps/foreignerDevice/getDeviceInventoryList";
-//        String token = getToke();
-//        for (EnergyEnvDevice energyEnvDevice : remark) {
-//
-//            MultiValueMap<String, String> formData = new LinkedMultiValueMap<>();
-//            formData.add("pageNum", "1");
-//            formData.add("pageSize", "20");
-//            formData.add("uniqueNo", energyEnvDevice.getDeviceCode());
-//            formData.add("type", "2");
-//            formData.add("compensate", "0");
-//            formData.add("startTime", dateTime.toString("yyyy-MM-dd HH:mm:ss"));
-//            formData.add("endTime", endOfMonth.toString("yyyy-MM-dd HH:mm:ss"));
-//
-//            // 设置请求头,指定内容类型为 form-data
-//            HttpHeaders headers = new HttpHeaders();
-//            headers.set("token",token);
-//            headers.setContentType(MediaType.MULTIPART_FORM_DATA);
-//            // 创建 HttpEntity
-//            HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(formData, headers);
-//            // 发送 POST 请求
-//            ResponseEntity<EneryDataVo> response = restTemplate.postForEntity(url, requestEntity, EneryDataVo.class);
-//            EneryDataVo body = response.getBody();
-//            System.out.println(body);
-//            if (ObjectUtil.isEmpty(body) || ObjectUtil.isEmpty(body.getData())){
-//                continue;
+//    private void action(){
+//        BigDecimal feedConsume;
+//        BasePigpen basePigpen = basePigpenMapper.selectOne(new QueryWrapper<BasePigpen>().lambda()
+//                .eq(BasePigpen::getFType, 3)
+//                .eq(BasePigpen::getFarmId, 26).last("Limit 1"));
+//        if (ObjectUtil.isNotEmpty(basePigpen)){
+//            EnergyData energyData = new EnergyData();
+//            ProdStock prodStock = prodStockMapper.selectOne(new QueryWrapper<ProdStock>().lambda()
+//                    .eq(ProdStock::getFarmId, 26)
+//                    .eq(ProdStock::getDisplayType, 0).orderByDesc(ProdStock::getCreatTime).last("LIMIT 1"));
+//            if (ObjectUtil.isNotEmpty(prodStock)){
+//                feedConsume = BigDecimal.valueOf((800*2.5)*prodStock.getZcl()/1000/12);
+//                feedConsume = feedConsume.setScale(2, RoundingMode.UP);
+//                energyData.setFeedValue(feedConsume.toString());
+//                energyData.setFarmId(26);
+//                energyData.setCreateDate(new Date());
+//                energyData.setDisplayType(1);
+//                energyData.setUnitId(basePigpen.getId());
+//                energyData.setUnitName(basePigpen.getBuildName());
+//                energyDataMapper.insert(energyData);
 //            }
-//            if (body.getData().getRecords() !=null){
-//                List<EneryDataVo3> records = body.getData().getRecords();
-//                for (EneryDataVo3 record : records) {
-//                    EnergyData energyData = new EnergyData();
-////                    energyData.setCreateDate(DateUtil.parse(record.getEndTime(),"yyyy-MM-dd HH:mm:ss"));
-//                    energyData.setCreateDate(record.getEndTime());
-//                    energyData.setDisplayType(0);
-//                    energyData.setFeedValue(record.getNum()+"");
-//                    energyData.setUnitId(energyEnvDevice.getUnitId());
-//                    energyData.setUnitName(energyEnvDevice.getUnitName());
-//                    energyData.setFarmId(energyEnvDevice.getFarmId());
-//                    energyDataMapper.insert(energyData);
-//                }
-//            }
-//        }
-//
-//    }
 //
-//
-//    private  String getToke(){
-//        String url = "http://api.infoexdata.cn/foreignApps/foreignApplications/getToken?appId=farnek23dxr5yk8ymvwuhbmup&appKey=x6re4jt63kcpyt3jhyjzb4ckj";
-//        TokenVo forObject = restTemplate.getForObject(url, TokenVo.class);
-//        if (ObjectUtil.isNotEmpty(forObject) &&forObject.getCode() ==200 ){
-//            return forObject.getData();
-//        }else {
-//            return null;
 //        }
 //    }
-//
-//
-//    //华统料塔
-////    @Scheduled(cron = "0 0 * * * ? ")
-////    private void action(){
-////        BigDecimal feedConsume;
-////        BasePigpen basePigpen = basePigpenMapper.selectOne(new QueryWrapper<BasePigpen>().lambda()
-////                .eq(BasePigpen::getFType, 3)
-////                .eq(BasePigpen::getFarmId, 26).last("Limit 1"));
-////        if (ObjectUtil.isNotEmpty(basePigpen)){
-////            EnergyData energyData = new EnergyData();
-////            ProdStock prodStock = prodStockMapper.selectOne(new QueryWrapper<ProdStock>().lambda()
-////                    .eq(ProdStock::getFarmId, 26)
-////                    .eq(ProdStock::getDisplayType, 0).orderByDesc(ProdStock::getCreatTime).last("LIMIT 1"));
-////            if (ObjectUtil.isNotEmpty(prodStock)){
-////                feedConsume = BigDecimal.valueOf((800*2.5)*prodStock.getZcl()/1000/12);
-////                feedConsume = feedConsume.setScale(2, RoundingMode.UP);
-////                energyData.setFeedValue(feedConsume.toString());
-////                energyData.setFarmId(26);
-////                energyData.setCreateDate(new Date());
-////                energyData.setDisplayType(1);
-////                energyData.setUnitId(basePigpen.getId());
-////                energyData.setUnitName(basePigpen.getBuildName());
-////                energyDataMapper.insert(energyData);
-////            }
-////
-////        }
-////    }
-//    //景宏料塔
-//}
+    //景宏料塔
+}

+ 86 - 86
huimv-admin/src/main/java/com/huimv/admin/jinghongtimer/EnvTimer.java

@@ -1,86 +1,86 @@
-//package com.huimv.admin.jinghongtimer;
-//
-//import cn.hutool.core.date.DateTime;
-//import cn.hutool.core.date.DateUtil;
-//import cn.hutool.core.util.ObjectUtil;
-//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-//import com.huimv.admin.entity.EnergyData;
-//import com.huimv.admin.entity.EnergyEnvDevice;
-//import com.huimv.admin.entity.EnvData;
-//import com.huimv.admin.entity.EnvDevice;
-//import com.huimv.admin.jinghongtimer.Vo.*;
-//import com.huimv.admin.mapper.EnergyDataMapper;
-//import com.huimv.admin.mapper.EnergyEnvDeviceMapper;
-//import com.huimv.admin.mapper.EnvDataMapper;
-//import com.huimv.admin.mapper.EnvDeviceMapper;
-//import org.springframework.beans.factory.annotation.Autowired;
-//import org.springframework.context.annotation.Configuration;
-//import org.springframework.http.HttpEntity;
-//import org.springframework.http.HttpHeaders;
-//import org.springframework.http.MediaType;
-//import org.springframework.http.ResponseEntity;
-//import org.springframework.scheduling.annotation.EnableScheduling;
-//import org.springframework.scheduling.annotation.Scheduled;
-//import org.springframework.util.LinkedMultiValueMap;
-//import org.springframework.util.MultiValueMap;
-//import org.springframework.web.bind.annotation.*;
-//import org.springframework.web.client.RestTemplate;
-//
-//import java.io.IOException;
-//import java.util.Date;
-//import java.util.List;
-//
-//
-//@RestController
-//@RequestMapping("/test")
-//public class EnvTimer {
-//    @Autowired
-//    private EnvDataMapper envDataMapper;
-//    @Autowired
-//    private EnvDeviceMapper envDeviceMapper;
-//    @GetMapping("/test3")
-//    public Object test3(@RequestParam String verify) throws IOException {
-//        System.out.println(verify);
-//        return verify;
-//    }
-//    @PostMapping("/test3")
-//    public Object test3( @RequestBody JingHongWenShi data) throws IOException {
-//        System.out.println("test3");
-//        System.out.println(data.toString());
-//        JingHongWenShi2 data1 = data.getData();
-//        String deviceId = data1.getDeviceId();
-//        EnvDevice envDevice = envDeviceMapper.selectOne(new QueryWrapper<EnvDevice>().eq("device_code", deviceId));
-//
-//        EnvData envData = new EnvData();
-//        envData.setDeviceId(envDevice.getDeviceCode());
-//        envData.setCreateTime(new Date());
-//        envData.setFarmId(envDevice.getFarmId());
-//        envData.setEnvHum(getHum(data1));
-//        envData.setEnvTemp(getTem(data1));
-//        envData.setUnitId(envDevice.getUnitId());
-////        envData.setReceiveDate();
-//        envDataMapper.insert(envData);
-//        return data;
-//    }
-//
-//    private String getHum(JingHongWenShi2 data1) {
-//        List<JingHongWenShi3> dataPoints = data1.getDataPoints();
-//        for (JingHongWenShi3 dataPoint : dataPoints) {
-//            if ("湿度".equals(dataPoint.getVariableName())){
-//                return dataPoint.getValue();
-//            }
-//        }
-//        return "0";
-//    }
-//    private String getTem(JingHongWenShi2 data1) {
-//        List<JingHongWenShi3> dataPoints = data1.getDataPoints();
-//        for (JingHongWenShi3 dataPoint : dataPoints) {
-//            if ("温度".equals(dataPoint.getVariableName())){
-//                return dataPoint.getValue();
-//            }
-//        }
-//        return "0";
-//    }
-//
-//
-//}
+package com.huimv.admin.jinghongtimer;
+
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.huimv.admin.entity.EnergyData;
+import com.huimv.admin.entity.EnergyEnvDevice;
+import com.huimv.admin.entity.EnvData;
+import com.huimv.admin.entity.EnvDevice;
+import com.huimv.admin.jinghongtimer.Vo.*;
+import com.huimv.admin.mapper.EnergyDataMapper;
+import com.huimv.admin.mapper.EnergyEnvDeviceMapper;
+import com.huimv.admin.mapper.EnvDataMapper;
+import com.huimv.admin.mapper.EnvDeviceMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.client.RestTemplate;
+
+import java.io.IOException;
+import java.util.Date;
+import java.util.List;
+
+
+@RestController
+@RequestMapping("/test")
+public class EnvTimer {
+    @Autowired
+    private EnvDataMapper envDataMapper;
+    @Autowired
+    private EnvDeviceMapper envDeviceMapper;
+    @GetMapping("/test3")
+    public Object test3(@RequestParam String verify) throws IOException {
+        System.out.println(verify);
+        return verify;
+    }
+    @PostMapping("/test3")
+    public Object test3( @RequestBody JingHongWenShi data) throws IOException {
+        System.out.println("test3");
+        System.out.println(data.toString());
+        JingHongWenShi2 data1 = data.getData();
+        String deviceId = data1.getDeviceId();
+        EnvDevice envDevice = envDeviceMapper.selectOne(new QueryWrapper<EnvDevice>().eq("device_code", deviceId));
+
+        EnvData envData = new EnvData();
+        envData.setDeviceId(envDevice.getDeviceCode());
+        envData.setCreateTime(new Date());
+        envData.setFarmId(envDevice.getFarmId());
+        envData.setEnvHum(getHum(data1));
+        envData.setEnvTemp(getTem(data1));
+        envData.setUnitId(envDevice.getUnitId());
+//        envData.setReceiveDate();
+        envDataMapper.insert(envData);
+        return data;
+    }
+
+    private String getHum(JingHongWenShi2 data1) {
+        List<JingHongWenShi3> dataPoints = data1.getDataPoints();
+        for (JingHongWenShi3 dataPoint : dataPoints) {
+            if ("湿度".equals(dataPoint.getVariableName())){
+                return dataPoint.getValue();
+            }
+        }
+        return "0";
+    }
+    private String getTem(JingHongWenShi2 data1) {
+        List<JingHongWenShi3> dataPoints = data1.getDataPoints();
+        for (JingHongWenShi3 dataPoint : dataPoints) {
+            if ("温度".equals(dataPoint.getVariableName())){
+                return dataPoint.getValue();
+            }
+        }
+        return "0";
+    }
+
+
+}

+ 101 - 101
huimv-admin/src/main/java/com/huimv/admin/jinghongtimer/ProtTimer.java

@@ -1,101 +1,101 @@
-//package com.huimv.admin.jinghongtimer;
-//
-//import com.huimv.admin.entity.ProtData;
-//import com.huimv.admin.jinghongtimer.Vo.JinghongWater;
-//import com.huimv.admin.mapper.*;
-//import org.springframework.beans.factory.annotation.Autowired;
-//import org.springframework.context.annotation.Configuration;
-//import org.springframework.http.ResponseEntity;
-//import org.springframework.scheduling.annotation.EnableScheduling;
-//import org.springframework.scheduling.annotation.Scheduled;
-//import org.springframework.web.bind.annotation.GetMapping;
-//import org.springframework.web.bind.annotation.RequestMapping;
-//import org.springframework.web.bind.annotation.RestController;
-//import org.springframework.web.client.RestClientException;
-//import org.springframework.web.client.RestTemplate;
-//
-//import java.util.List;
-//import java.util.Objects;
-//
-////@RestController
-////@RequestMapping("/test")
-//@Configuration
-//@EnableScheduling
-//public class ProtTimer {
-//
-//    @Autowired
-//    private ProtDataMapper protDataMapper;
-//    @Autowired
-//    private RestTemplate restTemplate;
-//
-//    @Scheduled(cron = "0 0/10 * * * ? ")
-////    @GetMapping("/test3")
-//    public void action(){
-//        String url = "http://139.9.172.209:8085/getFlow"; // 更好的做法是从配置中读取这个URL
-//        try {
-//            // 使用泛型来指定返回类型
-//            ResponseEntity<List<JinghongWater>> response = restTemplate.exchange(
-//                    url,
-//                    org.springframework.http.HttpMethod.GET,
-//                    null,
-//                    new org.springframework.core.ParameterizedTypeReference<List<JinghongWater>>() {}
-//            );
-//
-//            for (JinghongWater jinghongWater : Objects.requireNonNull(response.getBody())) {
-//                ProtData protData = new ProtData();
-//                protData.setCreateDate(jinghongWater.getCreateTime());
-//                protData.setFarmId(getFarmId(jinghongWater.getDeviceId()));
-//                protData.setFlow(jinghongWater.getValueA());
-//
-//                if ("861213058872158".equals(jinghongWater.getDeviceId())){
-//                    protData.setLoctionType(2);
-//                }else {
-//                    protData.setLoctionType(1);
-//                }
-//
-//                protData.setCod("0");
-//                protData.setNh3n("0");
-//                protData.setPh("0");
-//                protData.setTn("0");
-//                protData.setTp("0");
-//                protDataMapper.insert(protData);
-//            }
-//
-//        } catch (RestClientException e) {
-//            // 处理异常,比如记录日志或抛出更具体的业务异常
-//            e.printStackTrace();
-//            throw new RuntimeException("Failed to fetch flows", e);
-//        }
-//    }
-//    private Integer getFarmId(String deivceId){
-//        switch (deivceId){
-//            case "861213058861409":
-//                return 28;
-//            case "861213058829596":
-//                return 31;
-//            case "861213058846764":
-//                return 29;
-//            case "861213058846640":
-//                return 30;
-//            default: //"861213058872158":
-//                return 28;
-//        }
-//
-//    }
-//    private String getDevice(String deivceId){
-//        switch (deivceId){
-//            case "861213058861409":
-//                return "芙江";
-//            case "861213058829596":
-//                return "凤行";
-//            case "861213058846764":
-//                return "庙贝";
-//            case "861213058846640":
-//                return "潞水";
-//            default: //"861213058872158"
-//                return "芙江2";
-//        }
-//
-//
-//    }
-//}
+package com.huimv.admin.jinghongtimer;
+
+import com.huimv.admin.entity.ProtData;
+import com.huimv.admin.jinghongtimer.Vo.JinghongWater;
+import com.huimv.admin.mapper.*;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.ResponseEntity;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.client.RestClientException;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.List;
+import java.util.Objects;
+
+//@RestController
+//@RequestMapping("/test")
+@Configuration
+@EnableScheduling
+public class ProtTimer {
+
+    @Autowired
+    private ProtDataMapper protDataMapper;
+    @Autowired
+    private RestTemplate restTemplate;
+
+    @Scheduled(cron = "0 0/10 * * * ? ")
+//    @GetMapping("/test3")
+    public void action(){
+        String url = "http://139.9.172.209:8085/getFlow"; // 更好的做法是从配置中读取这个URL
+        try {
+            // 使用泛型来指定返回类型
+            ResponseEntity<List<JinghongWater>> response = restTemplate.exchange(
+                    url,
+                    org.springframework.http.HttpMethod.GET,
+                    null,
+                    new org.springframework.core.ParameterizedTypeReference<List<JinghongWater>>() {}
+            );
+
+            for (JinghongWater jinghongWater : Objects.requireNonNull(response.getBody())) {
+                ProtData protData = new ProtData();
+                protData.setCreateDate(jinghongWater.getCreateTime());
+                protData.setFarmId(getFarmId(jinghongWater.getDeviceId()));
+                protData.setFlow(jinghongWater.getValueA());
+
+                if ("861213058872158".equals(jinghongWater.getDeviceId())){
+                    protData.setLoctionType(2);
+                }else {
+                    protData.setLoctionType(1);
+                }
+
+                protData.setCod("0");
+                protData.setNh3n("0");
+                protData.setPh("0");
+                protData.setTn("0");
+                protData.setTp("0");
+                protDataMapper.insert(protData);
+            }
+
+        } catch (RestClientException e) {
+            // 处理异常,比如记录日志或抛出更具体的业务异常
+            e.printStackTrace();
+            throw new RuntimeException("Failed to fetch flows", e);
+        }
+    }
+    private Integer getFarmId(String deivceId){
+        switch (deivceId){
+            case "861213058861409":
+                return 28;
+            case "861213058829596":
+                return 31;
+            case "861213058846764":
+                return 29;
+            case "861213058846640":
+                return 30;
+            default: //"861213058872158":
+                return 28;
+        }
+
+    }
+    private String getDevice(String deivceId){
+        switch (deivceId){
+            case "861213058861409":
+                return "芙江";
+            case "861213058829596":
+                return "凤行";
+            case "861213058846764":
+                return "庙贝";
+            case "861213058846640":
+                return "潞水";
+            default: //"861213058872158"
+                return "芙江2";
+        }
+
+
+    }
+}

+ 8 - 5
huimv-admin/src/main/java/com/huimv/admin/server/EnvInputServerHandler.java

@@ -1,5 +1,6 @@
 package com.huimv.admin.server;
 
+import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson.JSONArray;
 import com.huimv.admin.entity.ProtData;
 import com.huimv.admin.mapper.ProtDataMapper;
@@ -12,7 +13,6 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
-import javax.sound.midi.Soundbank;
 import java.io.IOException;
 import java.text.ParseException;
 import java.util.Date;
@@ -91,12 +91,15 @@ public class EnvInputServerHandler extends ChannelInboundHandlerAdapter {
             System.out.println("接收到消息: " + clientAskText + "  时间: " + System.currentTimeMillis());
             EnvironmentalData parse = HJ212Parser.parse(clientAskText.replace("##", ""));
             ProtData protData = new ProtData();
+            if (ObjectUtil.isEmpty(parse.getCpData().getParameters().get("w01001").getAvg() )){
+                askTextSb.delete(0, askTextSb.length());
+                return;
+            }
             protData.setPh(parse.getCpData().getParameters().get("w01001").getAvg());
 //        protData.setOther1(parse.getCpData().getParameters().get("w01010").getAvg());
             protData.setCod(parse.getCpData().getParameters().get("w01018").getAvg());
             protData.setNh3n(parse.getCpData().getParameters().get("w21003").getAvg());
             protData.setOther2(parse.getCpData().getParameters().get("w00000").getAvg());
-
             protData.setLoctionType(1);
             String mn = parse.getHeader().getMn();
             if ("01523162079470".equals(mn)){
@@ -106,15 +109,15 @@ public class EnvInputServerHandler extends ChannelInboundHandlerAdapter {
             }
             protData.setOther3(clientAskText);
             protData.setCreateDate(new Date());
-
             protDataMapper.insert(protData);
-            askTextSb.delete(0, askTextSb.length());
+
+
         }catch (Exception e){
             System.out.println(e);
             askTextSb.delete(0, askTextSb.length());
+
         }
 
-        //##0349QN=20250414111200085;ST=32;CN=2011;PW=123456;MN=01523162079470;Flag=4;CP=&&DataTime=20250414111200;w01018-SampleTime=20250414100000,w01018-Rtd=74.2,w01018-Flag=N;w00000-SampleTime=20250414111048,w00000-Rtd=1.968,w00000-Flag=N;w01001-Rtd=7.26,w01001-Flag=N;w01010-Rtd=21,w01010-Flag=N;w21003-SampleTime=20250414100000,w21003-Rtd=0.422,w21003-Flag=N&&3600
 
     }
     //QN	20250412142007184	请求编号(21位时间戳:2025-04-12 14:20:07.184)

+ 3 - 2
huimv-admin/src/main/java/com/huimv/admin/service/impl/ProtDataServiceImpl.java

@@ -1102,10 +1102,11 @@ public class ProtDataServiceImpl extends ServiceImpl<ProtDataMapper, ProtData> i
         String farmId = paramsMap.get("farmId");
         QueryWrapper<ProtData> queryWrapper = new QueryWrapper<ProtData>().eq("farm_id", farmId);
         Date date = new Date();
-        List list   = new ArrayList();
+        List<ProtData> list   = new ArrayList();
         for (int i = 0; i < 8; i++) {
             DateTime dateTime = DateUtil.offsetDay(date, -i);
-            queryWrapper.select("create_date,MAX(CAST(ph AS DECIMAL(10,3) )) ph , MAX(CAST(cod AS DECIMAL(10,2) )) cod, MAX(CAST(NH3N AS DECIMAL(10,3) )) NH3N");
+            queryWrapper.select("create_date,MAX(CAST(ph AS DECIMAL(10,3) )) ph , MAX(CAST(cod AS DECIMAL(10,2) )) cod, MAX(CAST(NH3N AS DECIMAL(10,3) )) NH3N " +
+                    ",MAX(CAST(other2 AS DECIMAL(10,3) )) other2 ");
             queryWrapper.between("create_date",DateUtil.beginOfDay(dateTime),DateUtil.endOfDay(dateTime));
             ProtData protData = protDataMapper.selectOne(queryWrapper);
             if (ObjectUtil.isEmpty(protData)){

+ 103 - 103
huimv-admin/src/main/java/com/huimv/admin/timer/CarmeraTimer.java

@@ -1,103 +1,103 @@
-package com.huimv.admin.timer;
-
-import cn.hutool.core.codec.Base64;
-import cn.hutool.core.util.ObjectUtil;
-import cn.hutool.json.JSONUtil;
-import com.alibaba.fastjson.JSON;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.toolkit.StringUtils;
-import com.huimv.admin.common.utils.Digests;
-import com.huimv.admin.common.utils.HttpClientSSLUtils;
-import com.huimv.admin.entity.EnvData;
-import com.huimv.admin.entity.EnvDevice;
-import com.huimv.admin.entity.EnvWarningInfo;
-import com.huimv.admin.entity.EnvWarningThreshold;
-import com.huimv.admin.entity.hkwsdto.CameraDto1;
-import com.huimv.admin.entity.hkwsdto.HkvsCameraDto;
-import com.huimv.admin.entity.zengxindto.*;
-import com.huimv.admin.service.*;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.http.*;
-import org.springframework.scheduling.annotation.EnableScheduling;
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.client.RestTemplate;
-
-import java.lang.invoke.MethodHandleProxies;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.LocalTime;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-@Configuration
-@EnableScheduling
-public class CarmeraTimer {
-    private static final String APPKEY = "1c9ee657";
-    private static final String SECRET = "a5d723941c804a429447e71db2707ce8";
-    private static final String OPENAPI_IP_PORT_HTTP = "http://61.153.248.106:100";
-    private static final String OPENAPI_IP_PORT_HTTPS = "https://61.153.248.106:4430";
-    private static final String ITF_ADDRESS_GET_CAMERAS = "/openapi/service/vss/res/getCameras";
-    private static final String OP_USER_UUID = "5b2eb534696b11e89c2e438f92627767";
-
-    @Autowired
-    private ICameraBaseService cameraBaseService;
-        //数据库账号密码加密
-    //更新摄像头状态
-    @Scheduled(cron = "0 0/10 * * * ? ")
-    private void updateCameraOnlin() throws Exception {
-        String cameras = testGetCameras();
-        HkvsCameraDto hkvsCameraDto = JSONUtil.toBean(cameras, HkvsCameraDto.class);
-        if (ObjectUtil.isNotEmpty(hkvsCameraDto) && hkvsCameraDto.getErrorCode() ==0 ){
-            List<CameraDto1> list = hkvsCameraDto.getData().getList();
-            if (ObjectUtil.isNotEmpty(list)){
-                cameraBaseService.updateCameraOnlin(list);
-            }
-            System.out.println("更新成功");
-        }else {
-            System.out.println("摄像头信息为空");
-        }
-    }
-    /**
-     * HTTP方式
-     * 分页获取监控点信息 测试
-     * @return
-     * @throws Exception
-     */
-    private static String testGetCameras() throws Exception{
-        String url = OPENAPI_IP_PORT_HTTP + ITF_ADDRESS_GET_CAMERAS;
-        Map<String, Object> map = new HashMap<String, Object>();
-        map.put("appkey", APPKEY);//设置APPKEY
-        map.put("time", System.currentTimeMillis());//设置时间参数
-        map.put("pageNo", 1);//设置分页参数
-        map.put("pageSize", 1000);//设置分页参数
-        map.put("opUserUuid", OP_USER_UUID);//设置操作用户UUID
-        String params = JSON.toJSONString(map);
-        System.out.println(" ====== getCameras请求参数:【" + params + "】");
-        String data = HttpClientSSLUtils.doPost(url + "?token=" + Digests.buildToken(url + "?" + params, null, SECRET), params);
-        System.out.println(" ====== getCameras请求返回结果:【{" + data + "}】");
-        return data;
-    }
-
-
-    public static void main(String[] args) {
-        RestTemplate restTemplate = new RestTemplate();
-        String envUrl = "https://dnqyt.envchina.com/api/public/station-data";
-        LocalDate previousDay = LocalDate.now().minusDays(1);
-        LocalDateTime previousDayStart = LocalDateTime.of(previousDay, LocalTime.MIN);
-
-        String sgToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJkYW9ub25nIiwidWlkIjozLCJ1biI6IlpYUUxZWktKMjMwN0EyIiwiZXhwIjoxNjg5MDcwNTYxLCJqdGkiOiIzIn0.BEFESZrKOwBej4rxOfoj7qPcHGomh6KN7xbXdjOB__w";
-        HttpHeaders headers = new HttpHeaders();
-        headers.add("token",sgToken);
-        headers.setContentType(MediaType.APPLICATION_JSON);
-        HttpEntity<Map<String, Object>> formEntity = new HttpEntity<Map<String, Object>>(headers);
-
-        String urlWithParams = envUrl + "?type=D&mn=33330424001391" + "&startTime=" + "2023-07-10 00:00:00" + "&endTime=" + "2023-07-10 00:00:00";
-        ResponseEntity<String> result = restTemplate.exchange(urlWithParams, HttpMethod.GET,formEntity,String.class);
-        System.out.println(result);
-    }
-
-}
+//package com.huimv.admin.timer;
+//
+//import cn.hutool.core.codec.Base64;
+//import cn.hutool.core.util.ObjectUtil;
+//import cn.hutool.json.JSONUtil;
+//import com.alibaba.fastjson.JSON;
+//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+//import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+//import com.huimv.admin.common.utils.Digests;
+//import com.huimv.admin.common.utils.HttpClientSSLUtils;
+//import com.huimv.admin.entity.EnvData;
+//import com.huimv.admin.entity.EnvDevice;
+//import com.huimv.admin.entity.EnvWarningInfo;
+//import com.huimv.admin.entity.EnvWarningThreshold;
+//import com.huimv.admin.entity.hkwsdto.CameraDto1;
+//import com.huimv.admin.entity.hkwsdto.HkvsCameraDto;
+//import com.huimv.admin.entity.zengxindto.*;
+//import com.huimv.admin.service.*;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.context.annotation.Configuration;
+//import org.springframework.http.*;
+//import org.springframework.scheduling.annotation.EnableScheduling;
+//import org.springframework.scheduling.annotation.Scheduled;
+//import org.springframework.transaction.annotation.Transactional;
+//import org.springframework.web.client.RestTemplate;
+//
+//import java.lang.invoke.MethodHandleProxies;
+//import java.time.LocalDate;
+//import java.time.LocalDateTime;
+//import java.time.LocalTime;
+//import java.util.Date;
+//import java.util.HashMap;
+//import java.util.List;
+//import java.util.Map;
+//
+//@Configuration
+//@EnableScheduling
+//public class CarmeraTimer {
+//    private static final String APPKEY = "1c9ee657";
+//    private static final String SECRET = "a5d723941c804a429447e71db2707ce8";
+//    private static final String OPENAPI_IP_PORT_HTTP = "http://61.153.248.106:100";
+//    private static final String OPENAPI_IP_PORT_HTTPS = "https://61.153.248.106:4430";
+//    private static final String ITF_ADDRESS_GET_CAMERAS = "/openapi/service/vss/res/getCameras";
+//    private static final String OP_USER_UUID = "5b2eb534696b11e89c2e438f92627767";
+//
+//    @Autowired
+//    private ICameraBaseService cameraBaseService;
+//        //数据库账号密码加密
+//    //更新摄像头状态
+//    @Scheduled(cron = "0 0/10 * * * ? ")
+//    private void updateCameraOnlin() throws Exception {
+//        String cameras = testGetCameras();
+//        HkvsCameraDto hkvsCameraDto = JSONUtil.toBean(cameras, HkvsCameraDto.class);
+//        if (ObjectUtil.isNotEmpty(hkvsCameraDto) && hkvsCameraDto.getErrorCode() ==0 ){
+//            List<CameraDto1> list = hkvsCameraDto.getData().getList();
+//            if (ObjectUtil.isNotEmpty(list)){
+//                cameraBaseService.updateCameraOnlin(list);
+//            }
+//            System.out.println("更新成功");
+//        }else {
+//            System.out.println("摄像头信息为空");
+//        }
+//    }
+//    /**
+//     * HTTP方式
+//     * 分页获取监控点信息 测试
+//     * @return
+//     * @throws Exception
+//     */
+//    private static String testGetCameras() throws Exception{
+//        String url = OPENAPI_IP_PORT_HTTP + ITF_ADDRESS_GET_CAMERAS;
+//        Map<String, Object> map = new HashMap<String, Object>();
+//        map.put("appkey", APPKEY);//设置APPKEY
+//        map.put("time", System.currentTimeMillis());//设置时间参数
+//        map.put("pageNo", 1);//设置分页参数
+//        map.put("pageSize", 1000);//设置分页参数
+//        map.put("opUserUuid", OP_USER_UUID);//设置操作用户UUID
+//        String params = JSON.toJSONString(map);
+//        System.out.println(" ====== getCameras请求参数:【" + params + "】");
+//        String data = HttpClientSSLUtils.doPost(url + "?token=" + Digests.buildToken(url + "?" + params, null, SECRET), params);
+//        System.out.println(" ====== getCameras请求返回结果:【{" + data + "}】");
+//        return data;
+//    }
+//
+//
+//    public static void main(String[] args) {
+//        RestTemplate restTemplate = new RestTemplate();
+//        String envUrl = "https://dnqyt.envchina.com/api/public/station-data";
+//        LocalDate previousDay = LocalDate.now().minusDays(1);
+//        LocalDateTime previousDayStart = LocalDateTime.of(previousDay, LocalTime.MIN);
+//
+//        String sgToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJkYW9ub25nIiwidWlkIjozLCJ1biI6IlpYUUxZWktKMjMwN0EyIiwiZXhwIjoxNjg5MDcwNTYxLCJqdGkiOiIzIn0.BEFESZrKOwBej4rxOfoj7qPcHGomh6KN7xbXdjOB__w";
+//        HttpHeaders headers = new HttpHeaders();
+//        headers.add("token",sgToken);
+//        headers.setContentType(MediaType.APPLICATION_JSON);
+//        HttpEntity<Map<String, Object>> formEntity = new HttpEntity<Map<String, Object>>(headers);
+//
+//        String urlWithParams = envUrl + "?type=D&mn=33330424001391" + "&startTime=" + "2023-07-10 00:00:00" + "&endTime=" + "2023-07-10 00:00:00";
+//        ResponseEntity<String> result = restTemplate.exchange(urlWithParams, HttpMethod.GET,formEntity,String.class);
+//        System.out.println(result);
+//    }
+//
+//}

+ 56 - 56
huimv-admin/src/main/java/com/huimv/admin/timer/EnergyFeedTimer.java

@@ -1,57 +1,57 @@
-package com.huimv.admin.timer;
-
-import cn.hutool.core.util.ObjectUtil;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.huimv.admin.entity.BasePigpen;
-import com.huimv.admin.entity.EnergyData;
-import com.huimv.admin.entity.ProdStock;
-import com.huimv.admin.mapper.BaseFarmMapper;
-import com.huimv.admin.mapper.BasePigpenMapper;
-import com.huimv.admin.mapper.EnergyDataMapper;
-import com.huimv.admin.mapper.ProdStockMapper;
-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.math.BigDecimal;
-import java.math.RoundingMode;
-import java.util.Date;
-
-@Configuration
-@EnableScheduling
-public class EnergyFeedTimer {
-    @Autowired
-    private BasePigpenMapper basePigpenMapper;
-    @Autowired
-    private EnergyDataMapper energyDataMapper;
-    @Autowired
-    private ProdStockMapper prodStockMapper;
-    //华统料塔
-//    @Scheduled(cron = "0 0 * * * ? ")
-//    private void action(){
-//        BigDecimal feedConsume;
-//        BasePigpen basePigpen = basePigpenMapper.selectOne(new QueryWrapper<BasePigpen>().lambda()
-//                .eq(BasePigpen::getFType, 3)
-//                .eq(BasePigpen::getFarmId, 26).last("Limit 1"));
-//        if (ObjectUtil.isNotEmpty(basePigpen)){
-//            EnergyData energyData = new EnergyData();
-//            ProdStock prodStock = prodStockMapper.selectOne(new QueryWrapper<ProdStock>().lambda()
-//                    .eq(ProdStock::getFarmId, 26)
-//                    .eq(ProdStock::getDisplayType, 0).orderByDesc(ProdStock::getCreatTime).last("LIMIT 1"));
-//            if (ObjectUtil.isNotEmpty(prodStock)){
-//                feedConsume = BigDecimal.valueOf((800*2.5)*prodStock.getZcl()/1000/12);
-//                feedConsume = feedConsume.setScale(2, RoundingMode.UP);
-//                energyData.setFeedValue(feedConsume.toString());
-//                energyData.setFarmId(26);
-//                energyData.setCreateDate(new Date());
-//                energyData.setDisplayType(1);
-//                energyData.setUnitId(basePigpen.getId());
-//                energyData.setUnitName(basePigpen.getBuildName());
-//                energyDataMapper.insert(energyData);
-//            }
+//package com.huimv.admin.timer;
 //
-//        }
-//    }
-    //景宏料塔
-}
+//import cn.hutool.core.util.ObjectUtil;
+//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+//import com.huimv.admin.entity.BasePigpen;
+//import com.huimv.admin.entity.EnergyData;
+//import com.huimv.admin.entity.ProdStock;
+//import com.huimv.admin.mapper.BaseFarmMapper;
+//import com.huimv.admin.mapper.BasePigpenMapper;
+//import com.huimv.admin.mapper.EnergyDataMapper;
+//import com.huimv.admin.mapper.ProdStockMapper;
+//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.math.BigDecimal;
+//import java.math.RoundingMode;
+//import java.util.Date;
+//
+//@Configuration
+//@EnableScheduling
+//public class EnergyFeedTimer {
+//    @Autowired
+//    private BasePigpenMapper basePigpenMapper;
+//    @Autowired
+//    private EnergyDataMapper energyDataMapper;
+//    @Autowired
+//    private ProdStockMapper prodStockMapper;
+//    //华统料塔
+////    @Scheduled(cron = "0 0 * * * ? ")
+////    private void action(){
+////        BigDecimal feedConsume;
+////        BasePigpen basePigpen = basePigpenMapper.selectOne(new QueryWrapper<BasePigpen>().lambda()
+////                .eq(BasePigpen::getFType, 3)
+////                .eq(BasePigpen::getFarmId, 26).last("Limit 1"));
+////        if (ObjectUtil.isNotEmpty(basePigpen)){
+////            EnergyData energyData = new EnergyData();
+////            ProdStock prodStock = prodStockMapper.selectOne(new QueryWrapper<ProdStock>().lambda()
+////                    .eq(ProdStock::getFarmId, 26)
+////                    .eq(ProdStock::getDisplayType, 0).orderByDesc(ProdStock::getCreatTime).last("LIMIT 1"));
+////            if (ObjectUtil.isNotEmpty(prodStock)){
+////                feedConsume = BigDecimal.valueOf((800*2.5)*prodStock.getZcl()/1000/12);
+////                feedConsume = feedConsume.setScale(2, RoundingMode.UP);
+////                energyData.setFeedValue(feedConsume.toString());
+////                energyData.setFarmId(26);
+////                energyData.setCreateDate(new Date());
+////                energyData.setDisplayType(1);
+////                energyData.setUnitId(basePigpen.getId());
+////                energyData.setUnitName(basePigpen.getBuildName());
+////                energyDataMapper.insert(energyData);
+////            }
+////
+////        }
+////    }
+//    //景宏料塔
+//}

+ 159 - 159
huimv-admin/src/main/java/com/huimv/admin/timer/EnergyTimer.java

@@ -1,159 +1,159 @@
-package com.huimv.admin.timer;
-
-import cn.hutool.core.date.DateTime;
-import cn.hutool.core.date.DateUtil;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.huimv.admin.common.utils.NumberUtils;
-import com.huimv.admin.entity.*;
-import com.huimv.admin.mapper.*;
-import org.apache.commons.lang.time.DateUtils;
-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.DecimalFormat;
-import java.util.Date;
-import java.util.List;
-
-@Configuration
-@EnableScheduling
-public class EnergyTimer {
-
-    @Autowired
-    private EnergyEnvDeviceMapper deviceMapper;
-    @Autowired
-    private EnergyDataMapper dataMapper;
-    @Autowired
-    private BasePigpenMapper basePigpenMapper;
-    @Autowired
-    private EnergyWarningThresholdMapper warningThresholdMapper;
-    @Autowired
-    private EnergyWarningInfoMapper infoMapper;
-    @Autowired
-    private BaseFarmMapper baseFarmMapper;
-
-    //    能耗数据
-    @Scheduled(cron = "0 0 */1 * * ? ")
-//    @Scheduled(cron = "0 */1 * * * ? ")
-    private void getShenChan() throws Exception {
-        List<EnergyEnvDevice> energyEnvDevices = deviceMapper.selectList(new QueryWrapper<EnergyEnvDevice>().ne("farm_id",26)
-                .ne("farm_id",29).ne("farm_id",21).ne("farm_id",28).ne("farm_id",27).
-                        ne("farm_id",35).ne("farm_id",33).ne("farm_id",22).ne("farm_id",23)
-                .ne("farm_id",34) .ne("farm_id",36) .ne("farm_id",37).ne("farm_id",38)
-                .ne("farm_id",40).ne("farm_id",41).ne("farm_id",39).ne("farm_id",42)
-                .ne("farm_id",24));
-
-        for (EnergyEnvDevice energyEnvDevice : energyEnvDevices) {
-            QueryWrapper<BasePigpen> basePigpenQueryWrapper = new QueryWrapper<>();
-            basePigpenQueryWrapper.eq("id", energyEnvDevice.getUnitId()).eq("farm_id", energyEnvDevice.getFarmId());
-            BasePigpen basePigpen1 = basePigpenMapper.selectOne(basePigpenQueryWrapper);
-            QueryWrapper<BasePigpen> queryWrapper = new QueryWrapper<>();
-            queryWrapper.eq("id", basePigpen1.getParentId());
-            BasePigpen basePigpen = basePigpenMapper.selectOne(queryWrapper);
-
-            String feed = NumberUtils.getNumFloat2(6.00, 6.50);
-            String water = NumberUtils.getNumFloat2(0.08, 0.15);
-//            String gas = NumberUtils.getNum(200, 280, 1);
-            String gas = "0";
-            String electricity = NumberUtils.getNumFloat2(1.0, 1.45);
-
-            EnergyData energyData = new EnergyData();
-            energyData.setCreateDate(new Date());
-            energyData.setFarmId(energyEnvDevice.getFarmId());
-            energyData.setUnitId(energyEnvDevice.getUnitId());
-            if (energyEnvDevice.getFarmId() == 23) {
-                energyData.setFeedValue("0");
-            } else {
-                energyData.setFeedValue(feed);
-            }
-
-            energyData.setWaterValue(water);
-            energyData.setGasValue(gas);
-            energyData.setElectricityValue(electricity);
-            if (energyEnvDevice.getFarmId() == 24) {
-                String feed1 = NumberUtils.getNumFloat2(1.40, 1.50);
-                String water1 = NumberUtils.getNumFloat2(20.80, 20.84);
-                String electricity1 = NumberUtils.getNumFloat2(333.30, 333.34);
-                energyData.setElectricityValue(electricity1);
-                energyData.setWaterValue(water1);
-                energyData.setFeedValue(feed1);
-            }
-            dataMapper.insert(energyData);
-
-            QueryWrapper<EnergyWarningThreshold> wrapper = new QueryWrapper<>();
-            wrapper.eq("other1", basePigpen.getStageCode()).eq("farm_id", energyEnvDevice.getFarmId());
-            EnergyWarningThreshold threshold = warningThresholdMapper.selectOne(wrapper);
-
-            QueryWrapper<EnergyData> dataQueryWrapper = new QueryWrapper<>();
-            dataQueryWrapper.eq("farm_id", energyEnvDevice.getFarmId()).eq("unit_id", energyEnvDevice.getUnitId());
-            DateTime dateTime = DateUtil.beginOfDay(new Date());
-            dataQueryWrapper.ge("create_date", dateTime);
-            EnergyData energyData1 = dataMapper.listDataCount(dataQueryWrapper);
-
-            if (Float.parseFloat(energyData1.getWaterValue()) + Float.parseFloat(water) > Float.parseFloat(threshold.getMaxWater())) {
-                float waterCount = Float.parseFloat(energyData1.getWaterValue()) + Float.parseFloat(water);
-                DecimalFormat df = new DecimalFormat("#.00");
-                String format = df.format(waterCount);
-                EnergyWarningInfo warningInfo = new EnergyWarningInfo();
-                warningInfo.setWarningType(1);
-                warningInfo.setWarningContent("今日累计用水量" + format + "t,超过阈值");
-                warningInfo.setUnitName(basePigpen1.getBuildName());
-                warningInfo.setUnitId(energyEnvDevice.getUnitId());
-                warningInfo.setDeviceId(energyEnvDevice.getId());
-                warningInfo.setDate(new Date());
-                warningInfo.setFarmId(energyEnvDevice.getFarmId());
-                warningInfo.setUserIds(threshold.getUserIds());
-                infoMapper.insert(warningInfo);
-            }
-            if (Float.parseFloat(energyData1.getElectricityValue()) + Float.parseFloat(electricity) > Float.parseFloat(threshold.getMaxElectricity())) {
-                float electricityCount = Float.parseFloat(energyData1.getElectricityValue()) + Float.parseFloat(electricity);
-                DecimalFormat df = new DecimalFormat("#.00");
-                String format = df.format(electricityCount);
-                EnergyWarningInfo warningInfo = new EnergyWarningInfo();
-                warningInfo.setWarningType(2);
-                warningInfo.setWarningContent("今日累计用电量" + format + "kw/h,超过阈值");
-                warningInfo.setUnitName(basePigpen1.getBuildName());
-                warningInfo.setUnitId(energyEnvDevice.getUnitId());
-                warningInfo.setDeviceId(energyEnvDevice.getId());
-                warningInfo.setDate(new Date());
-                warningInfo.setFarmId(energyEnvDevice.getFarmId());
-                warningInfo.setUserIds(threshold.getUserIds());
-                infoMapper.insert(warningInfo);
-            }
-            if (Float.parseFloat(energyData1.getFeedValue()) + Float.parseFloat(feed) > Float.parseFloat(threshold.getMaxFeed())) {
-                float feedCount = Float.parseFloat(energyData1.getFeedValue()) + Float.parseFloat(feed);
-                DecimalFormat df = new DecimalFormat("#.00");
-                String format = df.format(feedCount);
-                EnergyWarningInfo warningInfo = new EnergyWarningInfo();
-                warningInfo.setWarningType(3);
-                warningInfo.setWarningContent("今日累计用料量" + format + "kg,超过阈值");
-                warningInfo.setUnitName(basePigpen.getBuildName());
-                warningInfo.setUnitId(energyEnvDevice.getUnitId());
-                warningInfo.setDeviceId(energyEnvDevice.getId());
-                warningInfo.setDate(new Date());
-                warningInfo.setFarmId(energyEnvDevice.getFarmId());
-                warningInfo.setUserIds(threshold.getUserIds());
-                infoMapper.insert(warningInfo);
-            }
-            if (Float.parseFloat(energyData1.getGasValue()) + Float.parseFloat(gas) > Float.parseFloat(threshold.getMaxGas())) {
-                float gasCount = Float.parseFloat(energyData1.getGasValue()) + Float.parseFloat(gas);
-                DecimalFormat df = new DecimalFormat("#.00");
-                String format = df.format(gasCount);
-                EnergyWarningInfo warningInfo = new EnergyWarningInfo();
-                warningInfo.setWarningType(4);
-                warningInfo.setWarningContent("今日累计用气量" + format + "m³,超过阈值");
-                warningInfo.setUnitName(basePigpen.getBuildName());
-                warningInfo.setUnitId(energyEnvDevice.getUnitId());
-                warningInfo.setDeviceId(energyEnvDevice.getId());
-                warningInfo.setDate(new Date());
-                warningInfo.setFarmId(energyEnvDevice.getFarmId());
-                warningInfo.setUserIds(threshold.getUserIds());
-                infoMapper.insert(warningInfo);
-            }
-
-        }
-
-
-    }
-}
+//package com.huimv.admin.timer;
+//
+//import cn.hutool.core.date.DateTime;
+//import cn.hutool.core.date.DateUtil;
+//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+//import com.huimv.admin.common.utils.NumberUtils;
+//import com.huimv.admin.entity.*;
+//import com.huimv.admin.mapper.*;
+//import org.apache.commons.lang.time.DateUtils;
+//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.DecimalFormat;
+//import java.util.Date;
+//import java.util.List;
+//
+//@Configuration
+//@EnableScheduling
+//public class EnergyTimer {
+//
+//    @Autowired
+//    private EnergyEnvDeviceMapper deviceMapper;
+//    @Autowired
+//    private EnergyDataMapper dataMapper;
+//    @Autowired
+//    private BasePigpenMapper basePigpenMapper;
+//    @Autowired
+//    private EnergyWarningThresholdMapper warningThresholdMapper;
+//    @Autowired
+//    private EnergyWarningInfoMapper infoMapper;
+//    @Autowired
+//    private BaseFarmMapper baseFarmMapper;
+//
+//    //    能耗数据
+//    @Scheduled(cron = "0 0 */1 * * ? ")
+////    @Scheduled(cron = "0 */1 * * * ? ")
+//    private void getShenChan() throws Exception {
+//        List<EnergyEnvDevice> energyEnvDevices = deviceMapper.selectList(new QueryWrapper<EnergyEnvDevice>().ne("farm_id",26)
+//                .ne("farm_id",29).ne("farm_id",21).ne("farm_id",28).ne("farm_id",27).
+//                        ne("farm_id",35).ne("farm_id",33).ne("farm_id",22).ne("farm_id",23)
+//                .ne("farm_id",34) .ne("farm_id",36) .ne("farm_id",37).ne("farm_id",38)
+//                .ne("farm_id",40).ne("farm_id",41).ne("farm_id",39).ne("farm_id",42)
+//                .ne("farm_id",24));
+//
+//        for (EnergyEnvDevice energyEnvDevice : energyEnvDevices) {
+//            QueryWrapper<BasePigpen> basePigpenQueryWrapper = new QueryWrapper<>();
+//            basePigpenQueryWrapper.eq("id", energyEnvDevice.getUnitId()).eq("farm_id", energyEnvDevice.getFarmId());
+//            BasePigpen basePigpen1 = basePigpenMapper.selectOne(basePigpenQueryWrapper);
+//            QueryWrapper<BasePigpen> queryWrapper = new QueryWrapper<>();
+//            queryWrapper.eq("id", basePigpen1.getParentId());
+//            BasePigpen basePigpen = basePigpenMapper.selectOne(queryWrapper);
+//
+//            String feed = NumberUtils.getNumFloat2(6.00, 6.50);
+//            String water = NumberUtils.getNumFloat2(0.08, 0.15);
+////            String gas = NumberUtils.getNum(200, 280, 1);
+//            String gas = "0";
+//            String electricity = NumberUtils.getNumFloat2(1.0, 1.45);
+//
+//            EnergyData energyData = new EnergyData();
+//            energyData.setCreateDate(new Date());
+//            energyData.setFarmId(energyEnvDevice.getFarmId());
+//            energyData.setUnitId(energyEnvDevice.getUnitId());
+//            if (energyEnvDevice.getFarmId() == 23) {
+//                energyData.setFeedValue("0");
+//            } else {
+//                energyData.setFeedValue(feed);
+//            }
+//
+//            energyData.setWaterValue(water);
+//            energyData.setGasValue(gas);
+//            energyData.setElectricityValue(electricity);
+//            if (energyEnvDevice.getFarmId() == 24) {
+//                String feed1 = NumberUtils.getNumFloat2(1.40, 1.50);
+//                String water1 = NumberUtils.getNumFloat2(20.80, 20.84);
+//                String electricity1 = NumberUtils.getNumFloat2(333.30, 333.34);
+//                energyData.setElectricityValue(electricity1);
+//                energyData.setWaterValue(water1);
+//                energyData.setFeedValue(feed1);
+//            }
+//            dataMapper.insert(energyData);
+//
+//            QueryWrapper<EnergyWarningThreshold> wrapper = new QueryWrapper<>();
+//            wrapper.eq("other1", basePigpen.getStageCode()).eq("farm_id", energyEnvDevice.getFarmId());
+//            EnergyWarningThreshold threshold = warningThresholdMapper.selectOne(wrapper);
+//
+//            QueryWrapper<EnergyData> dataQueryWrapper = new QueryWrapper<>();
+//            dataQueryWrapper.eq("farm_id", energyEnvDevice.getFarmId()).eq("unit_id", energyEnvDevice.getUnitId());
+//            DateTime dateTime = DateUtil.beginOfDay(new Date());
+//            dataQueryWrapper.ge("create_date", dateTime);
+//            EnergyData energyData1 = dataMapper.listDataCount(dataQueryWrapper);
+//
+//            if (Float.parseFloat(energyData1.getWaterValue()) + Float.parseFloat(water) > Float.parseFloat(threshold.getMaxWater())) {
+//                float waterCount = Float.parseFloat(energyData1.getWaterValue()) + Float.parseFloat(water);
+//                DecimalFormat df = new DecimalFormat("#.00");
+//                String format = df.format(waterCount);
+//                EnergyWarningInfo warningInfo = new EnergyWarningInfo();
+//                warningInfo.setWarningType(1);
+//                warningInfo.setWarningContent("今日累计用水量" + format + "t,超过阈值");
+//                warningInfo.setUnitName(basePigpen1.getBuildName());
+//                warningInfo.setUnitId(energyEnvDevice.getUnitId());
+//                warningInfo.setDeviceId(energyEnvDevice.getId());
+//                warningInfo.setDate(new Date());
+//                warningInfo.setFarmId(energyEnvDevice.getFarmId());
+//                warningInfo.setUserIds(threshold.getUserIds());
+//                infoMapper.insert(warningInfo);
+//            }
+//            if (Float.parseFloat(energyData1.getElectricityValue()) + Float.parseFloat(electricity) > Float.parseFloat(threshold.getMaxElectricity())) {
+//                float electricityCount = Float.parseFloat(energyData1.getElectricityValue()) + Float.parseFloat(electricity);
+//                DecimalFormat df = new DecimalFormat("#.00");
+//                String format = df.format(electricityCount);
+//                EnergyWarningInfo warningInfo = new EnergyWarningInfo();
+//                warningInfo.setWarningType(2);
+//                warningInfo.setWarningContent("今日累计用电量" + format + "kw/h,超过阈值");
+//                warningInfo.setUnitName(basePigpen1.getBuildName());
+//                warningInfo.setUnitId(energyEnvDevice.getUnitId());
+//                warningInfo.setDeviceId(energyEnvDevice.getId());
+//                warningInfo.setDate(new Date());
+//                warningInfo.setFarmId(energyEnvDevice.getFarmId());
+//                warningInfo.setUserIds(threshold.getUserIds());
+//                infoMapper.insert(warningInfo);
+//            }
+//            if (Float.parseFloat(energyData1.getFeedValue()) + Float.parseFloat(feed) > Float.parseFloat(threshold.getMaxFeed())) {
+//                float feedCount = Float.parseFloat(energyData1.getFeedValue()) + Float.parseFloat(feed);
+//                DecimalFormat df = new DecimalFormat("#.00");
+//                String format = df.format(feedCount);
+//                EnergyWarningInfo warningInfo = new EnergyWarningInfo();
+//                warningInfo.setWarningType(3);
+//                warningInfo.setWarningContent("今日累计用料量" + format + "kg,超过阈值");
+//                warningInfo.setUnitName(basePigpen.getBuildName());
+//                warningInfo.setUnitId(energyEnvDevice.getUnitId());
+//                warningInfo.setDeviceId(energyEnvDevice.getId());
+//                warningInfo.setDate(new Date());
+//                warningInfo.setFarmId(energyEnvDevice.getFarmId());
+//                warningInfo.setUserIds(threshold.getUserIds());
+//                infoMapper.insert(warningInfo);
+//            }
+//            if (Float.parseFloat(energyData1.getGasValue()) + Float.parseFloat(gas) > Float.parseFloat(threshold.getMaxGas())) {
+//                float gasCount = Float.parseFloat(energyData1.getGasValue()) + Float.parseFloat(gas);
+//                DecimalFormat df = new DecimalFormat("#.00");
+//                String format = df.format(gasCount);
+//                EnergyWarningInfo warningInfo = new EnergyWarningInfo();
+//                warningInfo.setWarningType(4);
+//                warningInfo.setWarningContent("今日累计用气量" + format + "m³,超过阈值");
+//                warningInfo.setUnitName(basePigpen.getBuildName());
+//                warningInfo.setUnitId(energyEnvDevice.getUnitId());
+//                warningInfo.setDeviceId(energyEnvDevice.getId());
+//                warningInfo.setDate(new Date());
+//                warningInfo.setFarmId(energyEnvDevice.getFarmId());
+//                warningInfo.setUserIds(threshold.getUserIds());
+//                infoMapper.insert(warningInfo);
+//            }
+//
+//        }
+//
+//
+//    }
+//}

Fichier diff supprimé car celui-ci est trop grand
+ 524 - 524
huimv-admin/src/main/java/com/huimv/admin/timer/EnvTimer.java


+ 296 - 296
huimv-admin/src/main/java/com/huimv/admin/timer/FeedTimer.java

@@ -1,302 +1,302 @@
-package com.huimv.admin.timer;
-
-
-import cn.hutool.core.codec.Base64;
-import cn.hutool.core.date.DateTime;
-import cn.hutool.core.date.DateUtil;
-import cn.hutool.core.io.FileUtil;
-import cn.hutool.core.util.ObjectUtil;
-import cn.hutool.http.HttpRequest;
-import cn.hutool.http.HttpUtil;
-import cn.hutool.json.JSONUtil;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.toolkit.StringUtils;
-import com.huimv.admin.common.utils.HttpClientSSLUtils;
-import com.huimv.admin.common.utils.NumberUtils;
-import com.huimv.admin.common.utils.Result;
-import com.huimv.admin.entity.*;
-import com.huimv.admin.entity.zengxindto.*;
-import com.huimv.admin.mapper.FeedAreaMapper;
-import com.huimv.admin.mapper.FeedPigMapper;
-import com.huimv.admin.mapper.FeedingDataMapper;
-import com.huimv.admin.mapper.FeedingEnvMapper;
-import com.huimv.admin.service.*;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.ResponseEntity;
-import org.springframework.scheduling.annotation.EnableScheduling;
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.client.RestTemplate;
-
-import java.text.DecimalFormat;
-import java.text.NumberFormat;
-import java.text.SimpleDateFormat;
-import java.time.Duration;
-import java.time.LocalDateTime;
-import java.util.*;
-import java.util.concurrent.ThreadLocalRandom;
-
-@Configuration
-@EnableScheduling
-public class FeedTimer {
-
-    @Autowired
-    private FeedAreaMapper feedAreaMapper;
-    @Autowired
-    private FeedingEnvMapper envMapper;
-    @Autowired
-    private FeedingDataMapper dataMapper;
-    @Autowired
-    private FeedPigMapper pigMapper;
-
-
-    //    @Scheduled(cron = "0 0 */1 * * ? ")
-    @Scheduled(cron = "0 0/59 * * * ? ")
-    @Transactional
-    public void getFeed() throws Exception {
-        QueryWrapper<FeedArea> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("farm_id", 26);
-        List<FeedArea> feedAreas = feedAreaMapper.selectList(queryWrapper);
-//        Date now = new Date(); // 获取当前时间
-//        long oneHour = 1 * 60 * 60 * 1000; // 1小时的毫秒数
-//        Date oneHourAgo = new Date(now.getTime() - oneHour); // 获取1小时前的时间
-//        List<String> time = new ArrayList<>();
-//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-//        time.add(sdf.format(oneHourAgo));
-//        time.add(sdf.format(new Date()));
-//        System.out.println("这个是传入的时间数组:" + time);
-        for (FeedArea feedArea : feedAreas) {
-            HashMap<String, String> paramMap = new HashMap<>();
-            JSONObject jsonObject = new JSONObject();
-//            jsonObject.put("pageNum", "1");
-//            jsonObject.put("pageSize", "50");
-//            jsonObject.put("createTime", time);
-            jsonObject.put("fdQrcode", "");
-            jsonObject.put("fenceNum", "");
-            jsonObject.put("gatewayNo", feedArea.getGatewayNo());
-            jsonObject.put("areaId", feedArea.getAreaId());
-            paramMap.put("Content-Type", "application/json;charset=utf-8");
-            paramMap.put("AuthorizationF", getToken());
-            String post = HttpRequest.post("http://znsw.zxkj2006.com/feed/api/mqtt/pageQryRealtime?pageNum=1&pageSize=50").headerMap(paramMap, false).body(jsonObject.toJSONString()).timeout(30 * 1000).execute().body();
-            JSONObject jsonObject1 = JSONObject.parseObject(post);
-            Map map = (Map) jsonObject1.get("data");
-            List<Map<String, Object>> list = (List) map.get("records");
-            System.out.println("取到了记录:" + list);
-            if (null != list) {
-                for (Map<String, Object> stringMap : list) {
-                    FeedingData data = new FeedingData();
-                    data.setFarmId(26);
-                    data.setUnitName(feedArea.getName());
-                    data.setDeviceCode(stringMap.get("fdQrcode").toString());
-
-                    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
-                    data.setUploadTime(dateFormat.parse(stringMap.get("createTime").toString()));
-                    data.setBlanking(stringMap.get("zkAlram").toString());
-                    data.setDeviceType(feedArea.getType());
-
-                    QueryWrapper<FeedingEnv> queryWrapper1 = new QueryWrapper<>();
-                    queryWrapper1.eq("device_code", stringMap.get("fdQrcode"));
-                    FeedingEnv env = envMapper.selectOne(queryWrapper1);
-                    if (ObjectUtil.isNotEmpty(env)) {
-                        data.setEartag(env.getEartag());
-                    }
-                    data.setMeals(Integer.parseInt(stringMap.get("dayDeliver").toString()));
-                    Integer intFdWeight = Integer.parseInt(stringMap.get("intFdWeight").toString());
-                    Double feed = Double.valueOf(intFdWeight) / 100;
-                    DecimalFormat def = new DecimalFormat("0.00");
-                    data.setFoodIntake(def.format(feed));
-                    data.setWater(stringMap.get("intDwWeight").toString());
-                    data.setDayNum(stringMap.get("dayOld").toString());
-                    data.setBodySize(stringMap.get("backfat").toString());
-                    dataMapper.insert(data);
-                }
-            }
-
-        }
-    }
-
-    public String getToken() {
-        HashMap<String, String> paramMap = new HashMap<>();
-        JSONObject jsonObject = new JSONObject();
-        jsonObject.put("username", "ruanzong");
-        jsonObject.put("password", "123456");
-        paramMap.put("Content-Type", "application/json;charset=utf-8");
-        String post = HttpRequest.post("http://znsw.zxkj2006.com/feed/api/admin/appLogin").headerMap(paramMap, false).body(jsonObject.toJSONString()).timeout(30 * 1000).execute().body();
-        JSONObject jsonObject1 = JSONObject.parseObject(post);
-        Map map = (Map) jsonObject1.get("data");
-        String s = map.get("tokenHead") + " " + map.get("token");
-        return s;
-    }
-
-    public static void main(String[] args) {
-//        Date now = new Date(); // 获取当前时间
-//        long oneHour = 1 * 30 * 1000; // 1小时的毫秒数
-//        Date oneHourAgo = new Date(now.getTime() - oneHour); // 获取1小时前的时间
-//        List<String> time = new ArrayList<>();
-//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-//        time.add(sdf.format(oneHourAgo));
-//        time.add(sdf.format(new Date()));
+//package com.huimv.admin.timer;
+//
+//
+//import cn.hutool.core.codec.Base64;
+//import cn.hutool.core.date.DateTime;
+//import cn.hutool.core.date.DateUtil;
+//import cn.hutool.core.io.FileUtil;
+//import cn.hutool.core.util.ObjectUtil;
+//import cn.hutool.http.HttpRequest;
+//import cn.hutool.http.HttpUtil;
+//import cn.hutool.json.JSONUtil;
+//import com.alibaba.fastjson.JSON;
+//import com.alibaba.fastjson.JSONArray;
+//import com.alibaba.fastjson.JSONObject;
+//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+//import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+//import com.huimv.admin.common.utils.HttpClientSSLUtils;
+//import com.huimv.admin.common.utils.NumberUtils;
+//import com.huimv.admin.common.utils.Result;
+//import com.huimv.admin.entity.*;
+//import com.huimv.admin.entity.zengxindto.*;
+//import com.huimv.admin.mapper.FeedAreaMapper;
+//import com.huimv.admin.mapper.FeedPigMapper;
+//import com.huimv.admin.mapper.FeedingDataMapper;
+//import com.huimv.admin.mapper.FeedingEnvMapper;
+//import com.huimv.admin.service.*;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.context.annotation.Configuration;
+//import org.springframework.http.HttpEntity;
+//import org.springframework.http.HttpHeaders;
+//import org.springframework.http.HttpMethod;
+//import org.springframework.http.ResponseEntity;
+//import org.springframework.scheduling.annotation.EnableScheduling;
+//import org.springframework.scheduling.annotation.Scheduled;
+//import org.springframework.transaction.annotation.Transactional;
+//import org.springframework.web.client.RestTemplate;
+//
+//import java.text.DecimalFormat;
+//import java.text.NumberFormat;
+//import java.text.SimpleDateFormat;
+//import java.time.Duration;
+//import java.time.LocalDateTime;
+//import java.util.*;
+//import java.util.concurrent.ThreadLocalRandom;
+//
+//@Configuration
+//@EnableScheduling
+//public class FeedTimer {
+//
+//    @Autowired
+//    private FeedAreaMapper feedAreaMapper;
+//    @Autowired
+//    private FeedingEnvMapper envMapper;
+//    @Autowired
+//    private FeedingDataMapper dataMapper;
+//    @Autowired
+//    private FeedPigMapper pigMapper;
+//
+//
+//    //    @Scheduled(cron = "0 0 */1 * * ? ")
+//    @Scheduled(cron = "0 0/59 * * * ? ")
+//    @Transactional
+//    public void getFeed() throws Exception {
+//        QueryWrapper<FeedArea> queryWrapper = new QueryWrapper<>();
+//        queryWrapper.eq("farm_id", 26);
+//        List<FeedArea> feedAreas = feedAreaMapper.selectList(queryWrapper);
+////        Date now = new Date(); // 获取当前时间
+////        long oneHour = 1 * 60 * 60 * 1000; // 1小时的毫秒数
+////        Date oneHourAgo = new Date(now.getTime() - oneHour); // 获取1小时前的时间
+////        List<String> time = new ArrayList<>();
+////        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+////        time.add(sdf.format(oneHourAgo));
+////        time.add(sdf.format(new Date()));
+////        System.out.println("这个是传入的时间数组:" + time);
+//        for (FeedArea feedArea : feedAreas) {
+//            HashMap<String, String> paramMap = new HashMap<>();
+//            JSONObject jsonObject = new JSONObject();
+////            jsonObject.put("pageNum", "1");
+////            jsonObject.put("pageSize", "50");
+////            jsonObject.put("createTime", time);
+//            jsonObject.put("fdQrcode", "");
+//            jsonObject.put("fenceNum", "");
+//            jsonObject.put("gatewayNo", feedArea.getGatewayNo());
+//            jsonObject.put("areaId", feedArea.getAreaId());
+//            paramMap.put("Content-Type", "application/json;charset=utf-8");
+//            paramMap.put("AuthorizationF", getToken());
+//            String post = HttpRequest.post("http://znsw.zxkj2006.com/feed/api/mqtt/pageQryRealtime?pageNum=1&pageSize=50").headerMap(paramMap, false).body(jsonObject.toJSONString()).timeout(30 * 1000).execute().body();
+//            JSONObject jsonObject1 = JSONObject.parseObject(post);
+//            Map map = (Map) jsonObject1.get("data");
+//            List<Map<String, Object>> list = (List) map.get("records");
+//            System.out.println("取到了记录:" + list);
+//            if (null != list) {
+//                for (Map<String, Object> stringMap : list) {
+//                    FeedingData data = new FeedingData();
+//                    data.setFarmId(26);
+//                    data.setUnitName(feedArea.getName());
+//                    data.setDeviceCode(stringMap.get("fdQrcode").toString());
+//
+//                    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+//                    data.setUploadTime(dateFormat.parse(stringMap.get("createTime").toString()));
+//                    data.setBlanking(stringMap.get("zkAlram").toString());
+//                    data.setDeviceType(feedArea.getType());
+//
+//                    QueryWrapper<FeedingEnv> queryWrapper1 = new QueryWrapper<>();
+//                    queryWrapper1.eq("device_code", stringMap.get("fdQrcode"));
+//                    FeedingEnv env = envMapper.selectOne(queryWrapper1);
+//                    if (ObjectUtil.isNotEmpty(env)) {
+//                        data.setEartag(env.getEartag());
+//                    }
+//                    data.setMeals(Integer.parseInt(stringMap.get("dayDeliver").toString()));
+//                    Integer intFdWeight = Integer.parseInt(stringMap.get("intFdWeight").toString());
+//                    Double feed = Double.valueOf(intFdWeight) / 100;
+//                    DecimalFormat def = new DecimalFormat("0.00");
+//                    data.setFoodIntake(def.format(feed));
+//                    data.setWater(stringMap.get("intDwWeight").toString());
+//                    data.setDayNum(stringMap.get("dayOld").toString());
+//                    data.setBodySize(stringMap.get("backfat").toString());
+//                    dataMapper.insert(data);
+//                }
+//            }
+//
+//        }
+//    }
+//
+//    public String getToken() {
 //        HashMap<String, String> paramMap = new HashMap<>();
 //        JSONObject jsonObject = new JSONObject();
-//        jsonObject.put("pageNum", 1);
-//        jsonObject.put("pageSize", 20);
-//        jsonObject.put("createTime", time);
-//        jsonObject.put("areaId","1017517");
+//        jsonObject.put("username", "ruanzong");
+//        jsonObject.put("password", "123456");
 //        paramMap.put("Content-Type", "application/json;charset=utf-8");
-//        paramMap.put("AuthorizationF","Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJoZW5sdSIsImNyZWF0ZWQiOjE2OTUzNjg1OTE4MjEsImV4cCI6MTY5NTQ1NDk5MX0.63A5FNJD714MVLp2cdH9HLyN25lYtAzsXHysXLEp1eR-FfkQZel6FnuoLfkIoFbgaht1OsEN-2ERabw0Lby7Pg");
-//        String post = HttpRequest.post("http://znsw.zxkj2006.com/feed/api/mqtt/pageQryRealtime").headerMap(paramMap, false).body(jsonObject.toJSONString()).timeout(30 * 1000).execute().body();
+//        String post = HttpRequest.post("http://znsw.zxkj2006.com/feed/api/admin/appLogin").headerMap(paramMap, false).body(jsonObject.toJSONString()).timeout(30 * 1000).execute().body();
 //        JSONObject jsonObject1 = JSONObject.parseObject(post);
 //        Map map = (Map) jsonObject1.get("data");
-//        System.out.println(map);
-//        List<Map<String, String>> list = (List) map.get("records");
-//        System.out.println(list);
-//        List<String> jsonArray = (ArrayList) map.get("records");
-//        System.out.println(jsonArray);
-    }
-
-
-    //饲养器添加
-    @Scheduled(cron = "0 0/57 * * * ? ")
-    @Transactional
-    public void getFeedEnv() throws Exception {
-        QueryWrapper<FeedArea> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("farm_id", 26);
-        List<FeedArea> feedAreas = feedAreaMapper.selectList(queryWrapper);
-        for (FeedArea feedArea : feedAreas) {
-            HashMap<String, String> paramMap = new HashMap<>();
-            JSONObject jsonObject = new JSONObject();
-            jsonObject.put("pageNum", "1");
-            jsonObject.put("pageSize", "200");
-            jsonObject.put("areaId", feedArea.getAreaId());
-            paramMap.put("Content-Type", "application/json;charset=utf-8");
-            paramMap.put("AuthorizationF", getToken());
-            String post = HttpRequest.post("http://znsw.zxkj2006.com/feed/api/api/v1/feeder/pageQry?pageNum=1&pageSize=50").headerMap(paramMap, false).body(jsonObject.toJSONString()).timeout(30 * 1000).execute().body();
-            JSONObject jsonObject1 = JSONObject.parseObject(post);
-            Map map = (Map) jsonObject1.get("data");
-            List<Map<String, Object>> list = (List) map.get("records");
-            for (Map<String, Object> stringMap : list) {
-                QueryWrapper<FeedingEnv> queryWrapper1 = new QueryWrapper<>();
-                queryWrapper1.eq("farm_id", 26).eq("device_code", stringMap.get("qrcode"));
-                if (ObjectUtil.isEmpty(envMapper.selectOne(queryWrapper1))) {
-                    FeedingEnv feedingEnv = new FeedingEnv();
-                    feedingEnv.setFarmId(26);
-                    feedingEnv.setUnitName(feedArea.getName());
-                    feedingEnv.setUnitId(Integer.parseInt(feedArea.getUnitId()));
-                    feedingEnv.setDeviceType(feedArea.getType());
-                    feedingEnv.setDeviceCode(stringMap.get("qrcode").toString());
-                    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
-                    feedingEnv.setLastTime(dateFormat.parse((String) stringMap.get("createTime")));
-                    feedingEnv.setOnlineStatus((Integer) stringMap.get("feedStatus"));
-                    envMapper.insert(feedingEnv);
-                } else {
-                    if (StringUtils.isNotBlank(stringMap.get("earTag").toString())) {
-                        FeedingEnv feedingEnv = envMapper.selectOne(queryWrapper1);
-                        feedingEnv.setEartag(stringMap.get("earTag").toString());
-                        envMapper.updateById(feedingEnv);
-                    }
-                }
-
-            }
-        }
-    }
-
-
-    //猪群数量变动
-    @Scheduled(cron = "0 0 1 * * ? ")
-    @Transactional
-    public void getPigCount() throws Exception {
-        List<FeedingEnv> envs = envMapper.selectList(null);
-        Integer number = 0;
-        String type = "";
-        for (FeedingEnv env : envs) {
-            String url = "http://znsw.zxkj2006.com/feed/api/api/v1/pig/list/" + env.getEartag();
-            Map<String, String> heads = new HashMap<>();
-            heads.put("Authorizationf", getToken());
-            String body = HttpRequest.get(url).addHeaders(heads).execute().body();
-            JSONObject jsonObject1 = JSONObject.parseObject(body);
-            System.out.println("这个是转换为json的" + jsonObject1);
-            List<JSONObject> data = (List<JSONObject>) jsonObject1.get("data");
-            System.out.println(data);
-            if (data.size() > 0) {
-                JSONObject jsonObject = data.get(0);
-                String num = jsonObject.get("litterNum").toString();
-                number = number + Integer.parseInt(num);
-                type = jsonObject.get("pigType").toString();//类型
-            }
-        }
-        List<FeedPig> feedPigs = pigMapper.selectList(null);
-        for (FeedPig feedPig : feedPigs) {
-            if (type.equals(feedPig.getType())) {
-                feedPig.setNumber(number.toString());
-                pigMapper.updateById(feedPig);
-            }
-//            else {
-//                FeedPig pig = new FeedPig();
-//                pig.setType(type);
-//                pig.setNumber(number.toString());
-//                pigMapper.insert(pig);
+//        String s = map.get("tokenHead") + " " + map.get("token");
+//        return s;
+//    }
+//
+//    public static void main(String[] args) {
+////        Date now = new Date(); // 获取当前时间
+////        long oneHour = 1 * 30 * 1000; // 1小时的毫秒数
+////        Date oneHourAgo = new Date(now.getTime() - oneHour); // 获取1小时前的时间
+////        List<String> time = new ArrayList<>();
+////        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+////        time.add(sdf.format(oneHourAgo));
+////        time.add(sdf.format(new Date()));
+////        HashMap<String, String> paramMap = new HashMap<>();
+////        JSONObject jsonObject = new JSONObject();
+////        jsonObject.put("pageNum", 1);
+////        jsonObject.put("pageSize", 20);
+////        jsonObject.put("createTime", time);
+////        jsonObject.put("areaId","1017517");
+////        paramMap.put("Content-Type", "application/json;charset=utf-8");
+////        paramMap.put("AuthorizationF","Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJoZW5sdSIsImNyZWF0ZWQiOjE2OTUzNjg1OTE4MjEsImV4cCI6MTY5NTQ1NDk5MX0.63A5FNJD714MVLp2cdH9HLyN25lYtAzsXHysXLEp1eR-FfkQZel6FnuoLfkIoFbgaht1OsEN-2ERabw0Lby7Pg");
+////        String post = HttpRequest.post("http://znsw.zxkj2006.com/feed/api/mqtt/pageQryRealtime").headerMap(paramMap, false).body(jsonObject.toJSONString()).timeout(30 * 1000).execute().body();
+////        JSONObject jsonObject1 = JSONObject.parseObject(post);
+////        Map map = (Map) jsonObject1.get("data");
+////        System.out.println(map);
+////        List<Map<String, String>> list = (List) map.get("records");
+////        System.out.println(list);
+////        List<String> jsonArray = (ArrayList) map.get("records");
+////        System.out.println(jsonArray);
+//    }
+//
+//
+//    //饲养器添加
+//    @Scheduled(cron = "0 0/57 * * * ? ")
+//    @Transactional
+//    public void getFeedEnv() throws Exception {
+//        QueryWrapper<FeedArea> queryWrapper = new QueryWrapper<>();
+//        queryWrapper.eq("farm_id", 26);
+//        List<FeedArea> feedAreas = feedAreaMapper.selectList(queryWrapper);
+//        for (FeedArea feedArea : feedAreas) {
+//            HashMap<String, String> paramMap = new HashMap<>();
+//            JSONObject jsonObject = new JSONObject();
+//            jsonObject.put("pageNum", "1");
+//            jsonObject.put("pageSize", "200");
+//            jsonObject.put("areaId", feedArea.getAreaId());
+//            paramMap.put("Content-Type", "application/json;charset=utf-8");
+//            paramMap.put("AuthorizationF", getToken());
+//            String post = HttpRequest.post("http://znsw.zxkj2006.com/feed/api/api/v1/feeder/pageQry?pageNum=1&pageSize=50").headerMap(paramMap, false).body(jsonObject.toJSONString()).timeout(30 * 1000).execute().body();
+//            JSONObject jsonObject1 = JSONObject.parseObject(post);
+//            Map map = (Map) jsonObject1.get("data");
+//            List<Map<String, Object>> list = (List) map.get("records");
+//            for (Map<String, Object> stringMap : list) {
+//                QueryWrapper<FeedingEnv> queryWrapper1 = new QueryWrapper<>();
+//                queryWrapper1.eq("farm_id", 26).eq("device_code", stringMap.get("qrcode"));
+//                if (ObjectUtil.isEmpty(envMapper.selectOne(queryWrapper1))) {
+//                    FeedingEnv feedingEnv = new FeedingEnv();
+//                    feedingEnv.setFarmId(26);
+//                    feedingEnv.setUnitName(feedArea.getName());
+//                    feedingEnv.setUnitId(Integer.parseInt(feedArea.getUnitId()));
+//                    feedingEnv.setDeviceType(feedArea.getType());
+//                    feedingEnv.setDeviceCode(stringMap.get("qrcode").toString());
+//                    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+//                    feedingEnv.setLastTime(dateFormat.parse((String) stringMap.get("createTime")));
+//                    feedingEnv.setOnlineStatus((Integer) stringMap.get("feedStatus"));
+//                    envMapper.insert(feedingEnv);
+//                } else {
+//                    if (StringUtils.isNotBlank(stringMap.get("earTag").toString())) {
+//                        FeedingEnv feedingEnv = envMapper.selectOne(queryWrapper1);
+//                        feedingEnv.setEartag(stringMap.get("earTag").toString());
+//                        envMapper.updateById(feedingEnv);
+//                    }
+//                }
+//
+//            }
+//        }
+//    }
+//
+//
+//    //猪群数量变动
+//    @Scheduled(cron = "0 0 1 * * ? ")
+//    @Transactional
+//    public void getPigCount() throws Exception {
+//        List<FeedingEnv> envs = envMapper.selectList(null);
+//        Integer number = 0;
+//        String type = "";
+//        for (FeedingEnv env : envs) {
+//            String url = "http://znsw.zxkj2006.com/feed/api/api/v1/pig/list/" + env.getEartag();
+//            Map<String, String> heads = new HashMap<>();
+//            heads.put("Authorizationf", getToken());
+//            String body = HttpRequest.get(url).addHeaders(heads).execute().body();
+//            JSONObject jsonObject1 = JSONObject.parseObject(body);
+//            System.out.println("这个是转换为json的" + jsonObject1);
+//            List<JSONObject> data = (List<JSONObject>) jsonObject1.get("data");
+//            System.out.println(data);
+//            if (data.size() > 0) {
+//                JSONObject jsonObject = data.get(0);
+//                String num = jsonObject.get("litterNum").toString();
+//                number = number + Integer.parseInt(num);
+//                type = jsonObject.get("pigType").toString();//类型
+//            }
+//        }
+//        List<FeedPig> feedPigs = pigMapper.selectList(null);
+//        for (FeedPig feedPig : feedPigs) {
+//            if (type.equals(feedPig.getType())) {
+//                feedPig.setNumber(number.toString());
+//                pigMapper.updateById(feedPig);
+//            }
+////            else {
+////                FeedPig pig = new FeedPig();
+////                pig.setType(type);
+////                pig.setNumber(number.toString());
+////                pigMapper.insert(pig);
+////            }
+//        }
+//
+//    }
+//
+//
+//    //饲养器状态修改
+//    @Scheduled(cron = "0 0/5 * * * ? ")
+//    @Transactional
+//    public void getFeedEnvStatus() throws Exception {
+//        QueryWrapper<FeedArea> queryWrapper = new QueryWrapper<>();
+//        queryWrapper.eq("farm_id", 26);
+//        List<FeedArea> feedAreas = feedAreaMapper.selectList(queryWrapper);
+//        for (FeedArea feedArea : feedAreas) {
+//            HashMap<String, String> paramMap = new HashMap<>();
+//            JSONObject jsonObject = new JSONObject();
+//            jsonObject.put("pageNum", "1");
+//            jsonObject.put("pageSize", "20");
+//            jsonObject.put("areaId", feedArea.getAreaId());
+//            paramMap.put("Content-Type", "application/json;charset=utf-8");
+//            paramMap.put("AuthorizationF", getToken());
+//            String post = HttpRequest.post("http://znsw.zxkj2006.com/feed/api/api/v1/feeder/pageQry?pageNum=1&pageSize=50").headerMap(paramMap, false).body(jsonObject.toJSONString()).timeout(30 * 1000).execute().body();
+//            JSONObject jsonObject1 = JSONObject.parseObject(post);
+//            Map map = (Map) jsonObject1.get("data");
+//            List<Map<String, Object>> list = (List) map.get("records");
+//            for (Map<String, Object> stringMap : list) {
+//                QueryWrapper<FeedingEnv> queryWrapper1 = new QueryWrapper<>();
+//                queryWrapper1.eq("farm_id", 26).eq("device_code", stringMap.get("qrcode"));
+//                if (ObjectUtil.isEmpty(envMapper.selectOne(queryWrapper1))) {
+//                    FeedingEnv feedingEnv = new FeedingEnv();
+//                    feedingEnv.setFarmId(26);
+//                    feedingEnv.setUnitName(feedArea.getName());
+//                    feedingEnv.setUnitId(Integer.parseInt(feedArea.getUnitId()));
+//                    feedingEnv.setDeviceType(feedArea.getType());
+//                    feedingEnv.setDeviceCode(stringMap.get("qrcode").toString());
+//                    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+//                    feedingEnv.setLastTime(dateFormat.parse((String) stringMap.get("createTime")));
+//                    feedingEnv.setOnlineStatus((Integer) stringMap.get("feedStatus"));
+//                    envMapper.insert(feedingEnv);
+//                } else {
+//                    if (StringUtils.isNotBlank(stringMap.get("earTag").toString())) {
+//                        FeedingEnv feedingEnv = envMapper.selectOne(queryWrapper1);
+//                        feedingEnv.setEartag(stringMap.get("earTag").toString());
+//                        String status = stringMap.get("swAlram").toString();
+//                        if ("0".equals(status)) {
+//                            feedingEnv.setOnlineStatus(0);
+//                        } else {
+//                            feedingEnv.setOnlineStatus(1);
+//                        }
+//                        envMapper.updateById(feedingEnv);
+//                    }
+//
+//                }
+//
 //            }
-        }
-
-    }
-
-
-    //饲养器状态修改
-    @Scheduled(cron = "0 0/5 * * * ? ")
-    @Transactional
-    public void getFeedEnvStatus() throws Exception {
-        QueryWrapper<FeedArea> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("farm_id", 26);
-        List<FeedArea> feedAreas = feedAreaMapper.selectList(queryWrapper);
-        for (FeedArea feedArea : feedAreas) {
-            HashMap<String, String> paramMap = new HashMap<>();
-            JSONObject jsonObject = new JSONObject();
-            jsonObject.put("pageNum", "1");
-            jsonObject.put("pageSize", "20");
-            jsonObject.put("areaId", feedArea.getAreaId());
-            paramMap.put("Content-Type", "application/json;charset=utf-8");
-            paramMap.put("AuthorizationF", getToken());
-            String post = HttpRequest.post("http://znsw.zxkj2006.com/feed/api/api/v1/feeder/pageQry?pageNum=1&pageSize=50").headerMap(paramMap, false).body(jsonObject.toJSONString()).timeout(30 * 1000).execute().body();
-            JSONObject jsonObject1 = JSONObject.parseObject(post);
-            Map map = (Map) jsonObject1.get("data");
-            List<Map<String, Object>> list = (List) map.get("records");
-            for (Map<String, Object> stringMap : list) {
-                QueryWrapper<FeedingEnv> queryWrapper1 = new QueryWrapper<>();
-                queryWrapper1.eq("farm_id", 26).eq("device_code", stringMap.get("qrcode"));
-                if (ObjectUtil.isEmpty(envMapper.selectOne(queryWrapper1))) {
-                    FeedingEnv feedingEnv = new FeedingEnv();
-                    feedingEnv.setFarmId(26);
-                    feedingEnv.setUnitName(feedArea.getName());
-                    feedingEnv.setUnitId(Integer.parseInt(feedArea.getUnitId()));
-                    feedingEnv.setDeviceType(feedArea.getType());
-                    feedingEnv.setDeviceCode(stringMap.get("qrcode").toString());
-                    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
-                    feedingEnv.setLastTime(dateFormat.parse((String) stringMap.get("createTime")));
-                    feedingEnv.setOnlineStatus((Integer) stringMap.get("feedStatus"));
-                    envMapper.insert(feedingEnv);
-                } else {
-                    if (StringUtils.isNotBlank(stringMap.get("earTag").toString())) {
-                        FeedingEnv feedingEnv = envMapper.selectOne(queryWrapper1);
-                        feedingEnv.setEartag(stringMap.get("earTag").toString());
-                        String status = stringMap.get("swAlram").toString();
-                        if ("0".equals(status)) {
-                            feedingEnv.setOnlineStatus(0);
-                        } else {
-                            feedingEnv.setOnlineStatus(1);
-                        }
-                        envMapper.updateById(feedingEnv);
-                    }
-
-                }
-
-            }
-        }
-    }
-}
+//        }
+//    }
+//}

+ 50 - 50
huimv-admin/src/main/java/com/huimv/admin/timer/FermentTimer.java

@@ -1,50 +1,50 @@
-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.ProdFermentData;
-import com.huimv.admin.entity.ProdFermentDevice;
-import com.huimv.admin.mapper.ProdFermentDataMapper;
-import com.huimv.admin.mapper.ProdFermentDeviceMapper;
-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;
-import java.util.List;
-
-@Configuration
-@EnableScheduling
-public class FermentTimer {
-    @Autowired
-    private ProdFermentDeviceMapper deviceMapper;
-    @Autowired
-    private ProdFermentDataMapper dataMapper;
-
-    @Scheduled(cron = "0 0/30 * * * ? ")
-    private void getFerment() {
-        QueryWrapper<ProdFermentDevice> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("farm_id", 26);
-        List<ProdFermentDevice> devices = deviceMapper.selectList(queryWrapper);
-        for (ProdFermentDevice device : devices) {
-            String temp = NumberUtils.getNumFloat(20.0, 50.0);//温度20-50
-            String hum = NumberUtils.getNumFloat(50.0, 90.0);//湿度50-90
-            String ph = NumberUtils.getNumFloat(6.5, 7.5);//PH6.5-7.5
-            String o2 = NumberUtils.getNumFloat(50.0, 500.0);//氧气
-            String co2 = NumberUtils.getNumFloat(50.0, 500.0);//二氧化碳
-            ProdFermentData data = new ProdFermentData();
-            data.setDeviceCode(device.getDeviceCode());
-            data.setBuildName(device.getBuildName());
-            data.setFarmId(device.getFarmId());
-            data.setCreateTime(new Date());
-            data.setCo2(co2);
-            data.setHum(hum);
-            data.setPh(ph);
-            data.setO2(o2);
-            data.setTemp(temp);
-            dataMapper.insert(data);
-        }
-
-    }
-}
+//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.ProdFermentData;
+//import com.huimv.admin.entity.ProdFermentDevice;
+//import com.huimv.admin.mapper.ProdFermentDataMapper;
+//import com.huimv.admin.mapper.ProdFermentDeviceMapper;
+//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;
+//import java.util.List;
+//
+//@Configuration
+//@EnableScheduling
+//public class FermentTimer {
+//    @Autowired
+//    private ProdFermentDeviceMapper deviceMapper;
+//    @Autowired
+//    private ProdFermentDataMapper dataMapper;
+//
+//    @Scheduled(cron = "0 0/30 * * * ? ")
+//    private void getFerment() {
+//        QueryWrapper<ProdFermentDevice> queryWrapper = new QueryWrapper<>();
+//        queryWrapper.eq("farm_id", 26);
+//        List<ProdFermentDevice> devices = deviceMapper.selectList(queryWrapper);
+//        for (ProdFermentDevice device : devices) {
+//            String temp = NumberUtils.getNumFloat(20.0, 50.0);//温度20-50
+//            String hum = NumberUtils.getNumFloat(50.0, 90.0);//湿度50-90
+//            String ph = NumberUtils.getNumFloat(6.5, 7.5);//PH6.5-7.5
+//            String o2 = NumberUtils.getNumFloat(50.0, 500.0);//氧气
+//            String co2 = NumberUtils.getNumFloat(50.0, 500.0);//二氧化碳
+//            ProdFermentData data = new ProdFermentData();
+//            data.setDeviceCode(device.getDeviceCode());
+//            data.setBuildName(device.getBuildName());
+//            data.setFarmId(device.getFarmId());
+//            data.setCreateTime(new Date());
+//            data.setCo2(co2);
+//            data.setHum(hum);
+//            data.setPh(ph);
+//            data.setO2(o2);
+//            data.setTemp(temp);
+//            dataMapper.insert(data);
+//        }
+//
+//    }
+//}

Fichier diff supprimé car celui-ci est trop grand
+ 499 - 499
huimv-admin/src/main/java/com/huimv/admin/timer/GasTimer.java


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

@@ -1,215 +1,215 @@
-package com.huimv.admin.timer;
-
-import cn.hutool.core.util.ObjectUtil;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.huimv.admin.entity.*;
-import com.huimv.admin.service.*;
-import org.apache.commons.lang.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.ResponseEntity;
-import org.springframework.scheduling.annotation.EnableScheduling;
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.util.LinkedMultiValueMap;
-import org.springframework.util.MultiValueMap;
-import org.springframework.web.client.RestTemplate;
-
-import java.math.BigDecimal;
-import java.text.ParseException;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
-
-@Configuration
-@EnableScheduling
-public class NewEnvTimer {
-    @Autowired
-    private RestTemplate restTemplate;
-
-    @Autowired
-    private IEnvDeviceService envDeviceService;
-
-    @Autowired
-    private IEnvDataService envDataService;
-
-    @Autowired
-    private IEnvWarningThresholdService envWarningThresholdService;
-
-    @Autowired
-    private IEnvWarningInfoService envWarningInfoService;
-
-    @Autowired
-    private IEnvNh3nService nh3nService;
-
-
-    @Scheduled(cron = "0 0/59 * * * ?")  //每10分钟执行一次
-//    @Scheduled(cron = "0 * * * * ?")  //每10分钟执行一次
-//    @Scheduled(cron = "*/5 * * * * ?")  //每10秒钟执行一次
-    public void getDeviceFlowData() throws ParseException {
-        String userId = "-1618620464";
-        String farmCode = "26";
-
-        List<EnvDevice> farm_id = envDeviceService.list(new QueryWrapper<EnvDevice>().eq("farm_id", farmCode));
-        EnvWarningThreshold envWarningThreshold = envWarningThresholdService.getOne(new QueryWrapper<EnvWarningThreshold>().eq("farm_id", farmCode));
-        System.out.println("开始");
-        Date date = new Date();
-        for (EnvDevice envDevice : farm_id) {
-            String deviceCode = envDevice.getDeviceCode();
-            if (StringUtils.isNotBlank(deviceCode)) {
-                JSONObject resultJo = JSONObject.parseObject(getDeviceFlowFromRemoteURL(userId, deviceCode));
-                System.out.println("resultJo >>>>>>>>>>>> =" + resultJo);
-                if (resultJo.getInteger("code") != 1000) {
-                    System.out.println("牧场[" + farmCode + "]设备组编号(" + deviceCode + ")调用远程接口返回结果出错.");
-                } else {
-                    JSONArray dataJa = resultJo.getJSONArray("data");
-                    JSONObject dataJo = dataJa.getJSONObject(0);
-                    JSONArray realTimeDataJa = dataJo.getJSONArray("realTimeData");
-                    JSONObject tempJo = realTimeDataJa.getJSONObject(0);
-                    String temp = tempJo.getString("dataValue");
-                    JSONObject humiJo = realTimeDataJa.getJSONObject(1);
-                    String humi = humiJo.getString("dataValue");
-                    if (StringUtils.isBlank(humi)) {
-                        humi = "0";
-                    }
-                    if (StringUtils.isBlank(temp)) {
-                        temp = "0";
-                    }
-                    EnvData envData = new EnvData();
-                    envData.setUnitId(envDevice.getUnitId());
-                    envData.setEnvTemp(temp);
-                    envData.setEnvHum(humi);
-                    envData.setFarmId(envDevice.getFarmId());
-                    envData.setCreateTime(date);
-                    envData.setDeviceId(envDevice.getDeviceCode());
-                    saveTemWarning(temp, envWarningThreshold, envDevice);
-                    saveHumWarning(humi, envWarningThreshold, envDevice);
-                    envDataService.save(envData);
-                    String remark = envDevice.getRemark();
-                    if (StringUtils.isNotBlank(remark)) {
-                        QueryWrapper<EnvNh3n> queryWrapper = new QueryWrapper<>();
-                        queryWrapper.eq("farm_id", farmCode).eq("device_code", remark);
-                        Calendar calendar = Calendar.getInstance();
-                        calendar.setTime(new Date());
-                        calendar.add(Calendar.MINUTE, -40);//
-                        queryWrapper.between("create_date", calendar.getTime(), new Date());
-                        List<EnvNh3n> list = nh3nService.list(queryWrapper);
-                        if (list.size() == 0 && humi.equals("0") && temp.equals("0")) {
-                            envDevice.setDeviceStatus(0);
-                        } else {
-                            envDevice.setDeviceStatus(1);
-                        }
-                        envDeviceService.updateById(envDevice);
-                    }
-                }
-            }
-        }
-
-    }
-
-
-    //获取远程数据
-    private String getDeviceFlowFromRemoteURL(String userId, String groupId) {
-        //请求头
-        HttpHeaders headers = new HttpHeaders();
-        headers.add("userId", userId);
-        //Body参数
-        MultiValueMap<String, Object> paramsMap = new LinkedMultiValueMap<String, Object>();
-        HttpEntity<MultiValueMap> objectHttpEntity = new HttpEntity<MultiValueMap>(paramsMap, headers);
-        System.out.println("URL_ENVIRON_DEVICE_SERVICE=" + "http://www.0531yun.com/app/GetDeviceData");
-        ResponseEntity<String> result = restTemplate.exchange("http://www.0531yun.com/app/GetDeviceData?groupId=" + groupId, HttpMethod.GET, objectHttpEntity, String.class);
-        System.out.println("result.getBody()=" + result.getBody());
-        return result.getBody();
-    }
-
-    private void saveTemWarning(String val, EnvWarningThreshold envWarningThreshold, EnvDevice envDevice) {
-        if (com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotBlank(val)) {
-            String maxTem;
-            String minTem;
-            if (ObjectUtil.isEmpty(envWarningThreshold) || com.baomidou.mybatisplus.core.toolkit.StringUtils.isBlank(envWarningThreshold.getMaxTem())) {
-                maxTem = "40";
-            } else {
-                maxTem = envWarningThreshold.getMaxTem();
-            }
-            if (ObjectUtil.isEmpty(envWarningThreshold) || com.baomidou.mybatisplus.core.toolkit.StringUtils.isBlank(envWarningThreshold.getMinTem())) {
-                minTem = "0";
-            } else {
-                minTem = envWarningThreshold.getMinTem();
-            }
-            System.out.println("maxTem:" + Double.parseDouble(maxTem) + "  minTem:" + Double.parseDouble(minTem) + "   val:" + Double.parseDouble(val));
-            if (Double.parseDouble(maxTem) < Double.parseDouble(val)) {
-                EnvWarningInfo envWarningInfo = new EnvWarningInfo();
-                envWarningInfo.setBuildLocation(envDevice.getUnitName());
-                envWarningInfo.setDate(new Date());
-                envWarningInfo.setDeviceId(envDevice.getDeviceCode());
-                envWarningInfo.setFarmId(envDevice.getFarmId());
-                envWarningInfo.setUnitId(envDevice.getUnitId());
-                envWarningInfo.setUnitName(envDevice.getUnitName());
-                envWarningInfo.setUserIds(envWarningThreshold.getUserIds());
-                envWarningInfo.setWarningContent("当前温度为" + val + "°超过阈值,请及时检查");
-                envWarningInfo.setWarningType(1);
-                envWarningInfoService.save(envWarningInfo);
-            }
-            if (Double.parseDouble(minTem) > Double.parseDouble(val)) {
-                EnvWarningInfo envWarningInfo = new EnvWarningInfo();
-                envWarningInfo.setBuildLocation(envDevice.getUnitName());
-                envWarningInfo.setDate(new Date());
-                envWarningInfo.setDeviceId(envDevice.getDeviceCode());
-                envWarningInfo.setFarmId(envDevice.getFarmId());
-                envWarningInfo.setUnitId(envDevice.getUnitId());
-                envWarningInfo.setUnitName(envDevice.getUnitName());
-                envWarningInfo.setUserIds(envWarningThreshold.getUserIds());
-                envWarningInfo.setWarningContent("当前温度为" + val + "°低于阈值,请及时检查");
-                envWarningInfo.setWarningType(1);
-                envWarningInfoService.save(envWarningInfo);
-            }
-        }
-    }
-
-    public void saveHumWarning(String val, EnvWarningThreshold envWarningThreshold, EnvDevice envDevice) {
-        if (com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotBlank(val)) {
-            String maxHum;
-            String minHum;
-            if (ObjectUtil.isEmpty(envWarningThreshold) || com.baomidou.mybatisplus.core.toolkit.StringUtils.isBlank(envWarningThreshold.getMaxHum())) {
-                maxHum = "90";
-            } else {
-                maxHum = envWarningThreshold.getMaxHum();
-            }
-            if (ObjectUtil.isEmpty(envWarningThreshold) || com.baomidou.mybatisplus.core.toolkit.StringUtils.isBlank(envWarningThreshold.getMinHum())) {
-                minHum = "0";
-            } else {
-                minHum = envWarningThreshold.getMinHum();
-            }
-            if (Double.parseDouble(maxHum) < Double.parseDouble(val)) {
-                EnvWarningInfo envWarningInfo = new EnvWarningInfo();
-                envWarningInfo.setBuildLocation(envDevice.getUnitName());
-                envWarningInfo.setDate(new Date());
-                envWarningInfo.setDeviceId(envDevice.getDeviceCode());
-                envWarningInfo.setFarmId(envDevice.getFarmId());
-                envWarningInfo.setUnitId(envDevice.getUnitId());
-                envWarningInfo.setUnitName(envDevice.getUnitName());
-                envWarningInfo.setUserIds(envWarningThreshold.getUserIds());
-                envWarningInfo.setWarningContent("当前湿度为" + val + "%超过阈值,请及时检查");
-                envWarningInfo.setWarningType(2);
-                envWarningInfoService.save(envWarningInfo);
-            }
-            if (Double.parseDouble(minHum) > Double.parseDouble(val)) {
-                EnvWarningInfo envWarningInfo = new EnvWarningInfo();
-                envWarningInfo.setBuildLocation(envDevice.getUnitName());
-                envWarningInfo.setDate(new Date());
-                envWarningInfo.setDeviceId(envDevice.getDeviceCode());
-                envWarningInfo.setFarmId(envDevice.getFarmId());
-                envWarningInfo.setUnitId(envDevice.getUnitId());
-                envWarningInfo.setUnitName(envDevice.getUnitName());
-                envWarningInfo.setUserIds(envWarningThreshold.getUserIds());
-                envWarningInfo.setWarningContent("当前湿度为" + val + "%低于阈值,请及时检查");
-                envWarningInfo.setWarningType(2);
-                envWarningInfoService.save(envWarningInfo);
-            }
-        }
-    }
-}
+//package com.huimv.admin.timer;
+//
+//import cn.hutool.core.util.ObjectUtil;
+//import com.alibaba.fastjson.JSONArray;
+//import com.alibaba.fastjson.JSONObject;
+//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+//import com.huimv.admin.entity.*;
+//import com.huimv.admin.service.*;
+//import org.apache.commons.lang.StringUtils;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.context.annotation.Configuration;
+//import org.springframework.http.HttpEntity;
+//import org.springframework.http.HttpHeaders;
+//import org.springframework.http.HttpMethod;
+//import org.springframework.http.ResponseEntity;
+//import org.springframework.scheduling.annotation.EnableScheduling;
+//import org.springframework.scheduling.annotation.Scheduled;
+//import org.springframework.util.LinkedMultiValueMap;
+//import org.springframework.util.MultiValueMap;
+//import org.springframework.web.client.RestTemplate;
+//
+//import java.math.BigDecimal;
+//import java.text.ParseException;
+//import java.util.Calendar;
+//import java.util.Date;
+//import java.util.List;
+//
+//@Configuration
+//@EnableScheduling
+//public class NewEnvTimer {
+//    @Autowired
+//    private RestTemplate restTemplate;
+//
+//    @Autowired
+//    private IEnvDeviceService envDeviceService;
+//
+//    @Autowired
+//    private IEnvDataService envDataService;
+//
+//    @Autowired
+//    private IEnvWarningThresholdService envWarningThresholdService;
+//
+//    @Autowired
+//    private IEnvWarningInfoService envWarningInfoService;
+//
+//    @Autowired
+//    private IEnvNh3nService nh3nService;
+//
+//
+//    @Scheduled(cron = "0 0/59 * * * ?")  //每10分钟执行一次
+////    @Scheduled(cron = "0 * * * * ?")  //每10分钟执行一次
+////    @Scheduled(cron = "*/5 * * * * ?")  //每10秒钟执行一次
+//    public void getDeviceFlowData() throws ParseException {
+//        String userId = "-1618620464";
+//        String farmCode = "26";
+//
+//        List<EnvDevice> farm_id = envDeviceService.list(new QueryWrapper<EnvDevice>().eq("farm_id", farmCode));
+//        EnvWarningThreshold envWarningThreshold = envWarningThresholdService.getOne(new QueryWrapper<EnvWarningThreshold>().eq("farm_id", farmCode));
+//        System.out.println("开始");
+//        Date date = new Date();
+//        for (EnvDevice envDevice : farm_id) {
+//            String deviceCode = envDevice.getDeviceCode();
+//            if (StringUtils.isNotBlank(deviceCode)) {
+//                JSONObject resultJo = JSONObject.parseObject(getDeviceFlowFromRemoteURL(userId, deviceCode));
+//                System.out.println("resultJo >>>>>>>>>>>> =" + resultJo);
+//                if (resultJo.getInteger("code") != 1000) {
+//                    System.out.println("牧场[" + farmCode + "]设备组编号(" + deviceCode + ")调用远程接口返回结果出错.");
+//                } else {
+//                    JSONArray dataJa = resultJo.getJSONArray("data");
+//                    JSONObject dataJo = dataJa.getJSONObject(0);
+//                    JSONArray realTimeDataJa = dataJo.getJSONArray("realTimeData");
+//                    JSONObject tempJo = realTimeDataJa.getJSONObject(0);
+//                    String temp = tempJo.getString("dataValue");
+//                    JSONObject humiJo = realTimeDataJa.getJSONObject(1);
+//                    String humi = humiJo.getString("dataValue");
+//                    if (StringUtils.isBlank(humi)) {
+//                        humi = "0";
+//                    }
+//                    if (StringUtils.isBlank(temp)) {
+//                        temp = "0";
+//                    }
+//                    EnvData envData = new EnvData();
+//                    envData.setUnitId(envDevice.getUnitId());
+//                    envData.setEnvTemp(temp);
+//                    envData.setEnvHum(humi);
+//                    envData.setFarmId(envDevice.getFarmId());
+//                    envData.setCreateTime(date);
+//                    envData.setDeviceId(envDevice.getDeviceCode());
+//                    saveTemWarning(temp, envWarningThreshold, envDevice);
+//                    saveHumWarning(humi, envWarningThreshold, envDevice);
+//                    envDataService.save(envData);
+//                    String remark = envDevice.getRemark();
+//                    if (StringUtils.isNotBlank(remark)) {
+//                        QueryWrapper<EnvNh3n> queryWrapper = new QueryWrapper<>();
+//                        queryWrapper.eq("farm_id", farmCode).eq("device_code", remark);
+//                        Calendar calendar = Calendar.getInstance();
+//                        calendar.setTime(new Date());
+//                        calendar.add(Calendar.MINUTE, -40);//
+//                        queryWrapper.between("create_date", calendar.getTime(), new Date());
+//                        List<EnvNh3n> list = nh3nService.list(queryWrapper);
+//                        if (list.size() == 0 && humi.equals("0") && temp.equals("0")) {
+//                            envDevice.setDeviceStatus(0);
+//                        } else {
+//                            envDevice.setDeviceStatus(1);
+//                        }
+//                        envDeviceService.updateById(envDevice);
+//                    }
+//                }
+//            }
+//        }
+//
+//    }
+//
+//
+//    //获取远程数据
+//    private String getDeviceFlowFromRemoteURL(String userId, String groupId) {
+//        //请求头
+//        HttpHeaders headers = new HttpHeaders();
+//        headers.add("userId", userId);
+//        //Body参数
+//        MultiValueMap<String, Object> paramsMap = new LinkedMultiValueMap<String, Object>();
+//        HttpEntity<MultiValueMap> objectHttpEntity = new HttpEntity<MultiValueMap>(paramsMap, headers);
+//        System.out.println("URL_ENVIRON_DEVICE_SERVICE=" + "http://www.0531yun.com/app/GetDeviceData");
+//        ResponseEntity<String> result = restTemplate.exchange("http://www.0531yun.com/app/GetDeviceData?groupId=" + groupId, HttpMethod.GET, objectHttpEntity, String.class);
+//        System.out.println("result.getBody()=" + result.getBody());
+//        return result.getBody();
+//    }
+//
+//    private void saveTemWarning(String val, EnvWarningThreshold envWarningThreshold, EnvDevice envDevice) {
+//        if (com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotBlank(val)) {
+//            String maxTem;
+//            String minTem;
+//            if (ObjectUtil.isEmpty(envWarningThreshold) || com.baomidou.mybatisplus.core.toolkit.StringUtils.isBlank(envWarningThreshold.getMaxTem())) {
+//                maxTem = "40";
+//            } else {
+//                maxTem = envWarningThreshold.getMaxTem();
+//            }
+//            if (ObjectUtil.isEmpty(envWarningThreshold) || com.baomidou.mybatisplus.core.toolkit.StringUtils.isBlank(envWarningThreshold.getMinTem())) {
+//                minTem = "0";
+//            } else {
+//                minTem = envWarningThreshold.getMinTem();
+//            }
+//            System.out.println("maxTem:" + Double.parseDouble(maxTem) + "  minTem:" + Double.parseDouble(minTem) + "   val:" + Double.parseDouble(val));
+//            if (Double.parseDouble(maxTem) < Double.parseDouble(val)) {
+//                EnvWarningInfo envWarningInfo = new EnvWarningInfo();
+//                envWarningInfo.setBuildLocation(envDevice.getUnitName());
+//                envWarningInfo.setDate(new Date());
+//                envWarningInfo.setDeviceId(envDevice.getDeviceCode());
+//                envWarningInfo.setFarmId(envDevice.getFarmId());
+//                envWarningInfo.setUnitId(envDevice.getUnitId());
+//                envWarningInfo.setUnitName(envDevice.getUnitName());
+//                envWarningInfo.setUserIds(envWarningThreshold.getUserIds());
+//                envWarningInfo.setWarningContent("当前温度为" + val + "°超过阈值,请及时检查");
+//                envWarningInfo.setWarningType(1);
+//                envWarningInfoService.save(envWarningInfo);
+//            }
+//            if (Double.parseDouble(minTem) > Double.parseDouble(val)) {
+//                EnvWarningInfo envWarningInfo = new EnvWarningInfo();
+//                envWarningInfo.setBuildLocation(envDevice.getUnitName());
+//                envWarningInfo.setDate(new Date());
+//                envWarningInfo.setDeviceId(envDevice.getDeviceCode());
+//                envWarningInfo.setFarmId(envDevice.getFarmId());
+//                envWarningInfo.setUnitId(envDevice.getUnitId());
+//                envWarningInfo.setUnitName(envDevice.getUnitName());
+//                envWarningInfo.setUserIds(envWarningThreshold.getUserIds());
+//                envWarningInfo.setWarningContent("当前温度为" + val + "°低于阈值,请及时检查");
+//                envWarningInfo.setWarningType(1);
+//                envWarningInfoService.save(envWarningInfo);
+//            }
+//        }
+//    }
+//
+//    public void saveHumWarning(String val, EnvWarningThreshold envWarningThreshold, EnvDevice envDevice) {
+//        if (com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotBlank(val)) {
+//            String maxHum;
+//            String minHum;
+//            if (ObjectUtil.isEmpty(envWarningThreshold) || com.baomidou.mybatisplus.core.toolkit.StringUtils.isBlank(envWarningThreshold.getMaxHum())) {
+//                maxHum = "90";
+//            } else {
+//                maxHum = envWarningThreshold.getMaxHum();
+//            }
+//            if (ObjectUtil.isEmpty(envWarningThreshold) || com.baomidou.mybatisplus.core.toolkit.StringUtils.isBlank(envWarningThreshold.getMinHum())) {
+//                minHum = "0";
+//            } else {
+//                minHum = envWarningThreshold.getMinHum();
+//            }
+//            if (Double.parseDouble(maxHum) < Double.parseDouble(val)) {
+//                EnvWarningInfo envWarningInfo = new EnvWarningInfo();
+//                envWarningInfo.setBuildLocation(envDevice.getUnitName());
+//                envWarningInfo.setDate(new Date());
+//                envWarningInfo.setDeviceId(envDevice.getDeviceCode());
+//                envWarningInfo.setFarmId(envDevice.getFarmId());
+//                envWarningInfo.setUnitId(envDevice.getUnitId());
+//                envWarningInfo.setUnitName(envDevice.getUnitName());
+//                envWarningInfo.setUserIds(envWarningThreshold.getUserIds());
+//                envWarningInfo.setWarningContent("当前湿度为" + val + "%超过阈值,请及时检查");
+//                envWarningInfo.setWarningType(2);
+//                envWarningInfoService.save(envWarningInfo);
+//            }
+//            if (Double.parseDouble(minHum) > Double.parseDouble(val)) {
+//                EnvWarningInfo envWarningInfo = new EnvWarningInfo();
+//                envWarningInfo.setBuildLocation(envDevice.getUnitName());
+//                envWarningInfo.setDate(new Date());
+//                envWarningInfo.setDeviceId(envDevice.getDeviceCode());
+//                envWarningInfo.setFarmId(envDevice.getFarmId());
+//                envWarningInfo.setUnitId(envDevice.getUnitId());
+//                envWarningInfo.setUnitName(envDevice.getUnitName());
+//                envWarningInfo.setUserIds(envWarningThreshold.getUserIds());
+//                envWarningInfo.setWarningContent("当前湿度为" + val + "%低于阈值,请及时检查");
+//                envWarningInfo.setWarningType(2);
+//                envWarningInfoService.save(envWarningInfo);
+//            }
+//        }
+//    }
+//}

+ 184 - 184
huimv-admin/src/main/java/com/huimv/admin/timer/ProdWarningTimer.java

@@ -1,184 +1,184 @@
-package com.huimv.admin.timer;
-
-import cn.hutool.core.util.ObjectUtil;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.huimv.admin.entity.*;
-import com.huimv.admin.mapper.*;
-import com.huimv.admin.service.IDisplayTypeService;
-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.time.LocalDateTime;
-import java.util.List;
-
-@Configuration
-@EnableScheduling
-public class ProdWarningTimer {
-    @Autowired
-    private BaseFarmMapper baseFarmMapper;
-    @Autowired
-    private ProdWarningInfoMapper prodWarningInfoMapper;
-    @Autowired
-    private ProdProductionMapper prodProductionMapper;
-    @Autowired
-    private ProdProductionThresholdMapper prodProductionThresholdMapper;
-    @Autowired
-    private ProdStockMapper prodStockMapper;
-    @Autowired
-    private ProdStockThresholdMapper prodStockThresholdMapper;
-    @Autowired
-    private IDisplayTypeService displayTypeService;
-
-//    @Scheduled(cron = "*/5 * * * * ?")
-    @Scheduled(cron = "0 0 0 * * ?")
-    private void action(){
-        Integer type1 = 0;
-        List<BaseFarm> baseFarms = baseFarmMapper.selectList(new QueryWrapper<BaseFarm>().lambda().ne(BaseFarm::getId, 25));
-        for (BaseFarm baseFarm : baseFarms) {
-            Integer farmId = baseFarm.getId();
-            DisplayType displayType1 = displayTypeService.getOne(new QueryWrapper<DisplayType>().lambda().eq(DisplayType::getFarmId, farmId).eq(DisplayType::getEventType, 3));
-            if (ObjectUtil.isNotEmpty(displayType1)){
-                type1 = displayType1.getDisplayType();
-            }
-            ProdStock prodStock = prodStockMapper.selectOne(new QueryWrapper<ProdStock>().lambda()
-                    .eq(ProdStock::getDisplayType, type1)
-                    .eq(ProdStock::getFarmId, farmId)
-                    .orderByDesc(ProdStock::getCreatTime).last("LIMIT 1"));
-            if (ObjectUtil.isNotEmpty(prodStock)){
-                ProdStockThreshold threshold = prodStockThresholdMapper.selectOne(new QueryWrapper<ProdStockThreshold>().lambda().eq(ProdStockThreshold::getFarmId, farmId));
-                if (ObjectUtil.isNotEmpty(threshold)){
-                    Integer minBrzcl = threshold.getMinBrzcl();
-                    Integer minByzcl = threshold.getMinByzcl();
-                    Integer minGzcl = threshold.getMinGzcl();
-                    Integer minHbzcl = threshold.getMinHbzcl();
-                    Integer minMzcl = threshold.getMinMzcl();
-                    Integer minYfzcl = threshold.getMinYfzcl();
-                    if (ObjectUtil.isNotEmpty(minBrzcl)){
-                        if (ObjectUtil.isNotEmpty(prodStock.getBrzcl())){
-                            if (prodStock.getBrzcl().compareTo(minBrzcl) < 0){
-                                ProdWarningInfo prodWarningInfo = new ProdWarningInfo();
-                                prodWarningInfo.setDate(LocalDateTime.now());
-                                prodWarningInfo.setFarmId(farmId);
-                                prodWarningInfo.setWarningContent("哺乳猪存栏小于阈值!");
-                                prodWarningInfo.setWarningType(0);
-                                prodWarningInfoMapper.insert(prodWarningInfo);
-                            }
-                        }
-                    }
-                    if (ObjectUtil.isNotEmpty(minByzcl)){
-                        if (ObjectUtil.isNotEmpty(prodStock.getByzcl())){
-                            if (prodStock.getByzcl().compareTo(minByzcl) < 0){
-                                ProdWarningInfo prodWarningInfo = new ProdWarningInfo();
-                                prodWarningInfo.setDate(LocalDateTime.now());
-                                prodWarningInfo.setFarmId(farmId);
-                                prodWarningInfo.setWarningContent("保育猪存栏小于阈值!");
-                                prodWarningInfo.setWarningType(0);
-                                prodWarningInfoMapper.insert(prodWarningInfo);
-                            }
-                        }
-                    }
-                    if (ObjectUtil.isNotEmpty(minGzcl)){
-                        if (ObjectUtil.isNotEmpty(prodStock.getGzcl())){
-                            if (prodStock.getGzcl().compareTo(minGzcl) < 0){
-                                ProdWarningInfo prodWarningInfo = new ProdWarningInfo();
-                                prodWarningInfo.setDate(LocalDateTime.now());
-                                prodWarningInfo.setFarmId(farmId);
-                                prodWarningInfo.setWarningContent("公猪存栏小于阈值!");
-                                prodWarningInfo.setWarningType(0);
-                                prodWarningInfoMapper.insert(prodWarningInfo);
-                            }
-                        }
-                    }
-                    if (ObjectUtil.isNotEmpty(minHbzcl)){
-                        if (ObjectUtil.isNotEmpty(prodStock.getHbzcl())){
-                            if (prodStock.getHbzcl().compareTo(minHbzcl) < 0){
-                                ProdWarningInfo prodWarningInfo = new ProdWarningInfo();
-                                prodWarningInfo.setDate(LocalDateTime.now());
-                                prodWarningInfo.setFarmId(farmId);
-                                prodWarningInfo.setWarningContent("后备猪存栏小于阈值!");
-                                prodWarningInfo.setWarningType(0);
-                                prodWarningInfoMapper.insert(prodWarningInfo);
-                            }
-                        }
-                    }
-                    if (ObjectUtil.isNotEmpty(minMzcl)){
-                        if (ObjectUtil.isNotEmpty(prodStock.getMzcl())){
-                            if (prodStock.getMzcl().compareTo(minMzcl) < 0){
-                                ProdWarningInfo prodWarningInfo = new ProdWarningInfo();
-                                prodWarningInfo.setDate(LocalDateTime.now());
-                                prodWarningInfo.setFarmId(farmId);
-                                prodWarningInfo.setWarningContent("母猪存栏小于阈值!");
-                                prodWarningInfo.setWarningType(0);
-                                prodWarningInfoMapper.insert(prodWarningInfo);
-                            }
-                        }
-                    }
-                    if (ObjectUtil.isNotEmpty(minYfzcl)){
-                        if (ObjectUtil.isNotEmpty(prodStock.getYfzcl())){
-                            if (prodStock.getYfzcl().compareTo(minYfzcl) < 0){
-                                ProdWarningInfo prodWarningInfo = new ProdWarningInfo();
-                                prodWarningInfo.setDate(LocalDateTime.now());
-                                prodWarningInfo.setFarmId(farmId);
-                                prodWarningInfo.setWarningContent("育肥猪存栏小于阈值!");
-                                prodWarningInfo.setWarningType(0);
-                                prodWarningInfoMapper.insert(prodWarningInfo);
-                            }
-                        }
-                    }
-                }
-            }
-            ProdProduction prodProduction = prodProductionMapper.selectOne(new QueryWrapper<ProdProduction>().lambda()
-                    .eq(ProdProduction::getFarmId, farmId).orderByDesc(ProdProduction::getCreatTime).last("LIMIT 1"));
-            if (ObjectUtil.isNotEmpty(prodProduction)){
-                ProdProductionThreshold prodProductionThreshold = prodProductionThresholdMapper.selectOne(new QueryWrapper<ProdProductionThreshold>().lambda().eq(ProdProductionThreshold::getFarmId,farmId));
-                if (ObjectUtil.isNotEmpty(prodProductionThreshold)){
-                    checkAndWarn(prodProductionThreshold.getMinBychl(), prodProduction.getBychl(),farmId, 1, "保育成活率小于阈值!");
-                    checkAndWarn(prodProductionThreshold.getMinCfchl(), prodProduction.getCfchl(),farmId, 1, "产房成活率小于阈值!");
-                    checkAndWarn2(prodProductionThreshold.getMinFccts(), prodProduction.getFccts(),farmId, 1, "非生产天数大于阈值!");
-                    checkAndWarn(prodProductionThreshold.getMinFzchl(), prodProduction.getFzchl(),farmId, 1, "肥猪成活率小于阈值!");
-                    checkAndWarn(prodProductionThreshold.getMinMrwll(), prodProduction.getMrwll(),farmId, 1, "每日喂料量小于阈值!");
-                    checkAndWarn(prodProductionThreshold.getMinPjwchzs(), prodProduction.getPjwchzs(),farmId, 1, "平均窝产活仔数小于阈值!");
-                    checkAndWarn(prodProductionThreshold.getMinPjwczczs(), prodProduction.getPjwczczs(),farmId, 1, "平均窝产正常仔数小于阈值!");
-                    checkAndWarn(prodProductionThreshold.getMinPjwdnz(), prodProduction.getPjwdnz(),farmId, 1, "平均窝断奶窝重小于阈值!");
-                    checkAndWarn(prodProductionThreshold.getMinPsy(), prodProduction.getPsy(),farmId, 1, "PSY小于阈值!");
-                    checkAndWarn(prodProductionThreshold.getMinPzfml(), prodProduction.getPzfml(),farmId, 1, "配种分娩率小于阈值!");
-                    checkAndWarn(prodProductionThreshold.getMinQrdpl(), prodProduction.getQrdpl(),farmId, 1, "7日断配率小于阈值!");
-                    checkAndWarn(prodProductionThreshold.getMinRzz(), prodProduction.getRzz(),farmId, 1, "日增重小于阈值!");
-                    checkAndWarn(prodProductionThreshold.getMinScws(), prodProduction.getScws(),farmId, 1, "年产窝数小于阈值!");
-                    checkAndWarn(prodProductionThreshold.getMinWdnzzs(), prodProduction.getWdnzzs(),farmId, 1, "窝断奶仔猪数小于阈值!");
-                    checkAndWarn(prodProductionThreshold.getMinYfchl(), prodProduction.getYfchl(),farmId, 1, "育肥成活率小于阈值!");
-                    checkAndWarn(prodProductionThreshold.getMinPjwczs(), prodProduction.getPjwczs(),farmId, 1, "平均窝产仔数小于阈值!");
-                }
-            }
-        }
-    }
-
-    private void checkAndWarn(String threshold, String actualValue,Integer farmId, int warningType, String warningContent) {
-        if (ObjectUtil.isNotEmpty(threshold) && ObjectUtil.isNotEmpty(actualValue)) {
-            if (Double.valueOf(actualValue).compareTo(Double.valueOf(threshold)) < 0) {
-                ProdWarningInfo prodWarningInfo = new ProdWarningInfo();
-                prodWarningInfo.setDate(LocalDateTime.now());
-                prodWarningInfo.setFarmId(farmId);
-                prodWarningInfo.setWarningContent(warningContent);
-                prodWarningInfo.setWarningType(warningType);
-                prodWarningInfoMapper.insert(prodWarningInfo);
-            }
-        }
-    }
-
-    private void checkAndWarn2(String threshold, String actualValue,Integer farmId, int warningType, String warningContent) {
-        if (ObjectUtil.isNotEmpty(threshold) && ObjectUtil.isNotEmpty(actualValue)) {
-            if (Double.valueOf(actualValue).compareTo(Double.valueOf(threshold)) > 0) {
-                ProdWarningInfo prodWarningInfo = new ProdWarningInfo();
-                prodWarningInfo.setDate(LocalDateTime.now());
-                prodWarningInfo.setFarmId(farmId);
-                prodWarningInfo.setWarningContent(warningContent);
-                prodWarningInfo.setWarningType(warningType);
-                prodWarningInfoMapper.insert(prodWarningInfo);
-            }
-        }
-    }
-
-}
+//package com.huimv.admin.timer;
+//
+//import cn.hutool.core.util.ObjectUtil;
+//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+//import com.huimv.admin.entity.*;
+//import com.huimv.admin.mapper.*;
+//import com.huimv.admin.service.IDisplayTypeService;
+//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.time.LocalDateTime;
+//import java.util.List;
+//
+//@Configuration
+//@EnableScheduling
+//public class ProdWarningTimer {
+//    @Autowired
+//    private BaseFarmMapper baseFarmMapper;
+//    @Autowired
+//    private ProdWarningInfoMapper prodWarningInfoMapper;
+//    @Autowired
+//    private ProdProductionMapper prodProductionMapper;
+//    @Autowired
+//    private ProdProductionThresholdMapper prodProductionThresholdMapper;
+//    @Autowired
+//    private ProdStockMapper prodStockMapper;
+//    @Autowired
+//    private ProdStockThresholdMapper prodStockThresholdMapper;
+//    @Autowired
+//    private IDisplayTypeService displayTypeService;
+//
+////    @Scheduled(cron = "*/5 * * * * ?")
+//    @Scheduled(cron = "0 0 0 * * ?")
+//    private void action(){
+//        Integer type1 = 0;
+//        List<BaseFarm> baseFarms = baseFarmMapper.selectList(new QueryWrapper<BaseFarm>().lambda().ne(BaseFarm::getId, 25));
+//        for (BaseFarm baseFarm : baseFarms) {
+//            Integer farmId = baseFarm.getId();
+//            DisplayType displayType1 = displayTypeService.getOne(new QueryWrapper<DisplayType>().lambda().eq(DisplayType::getFarmId, farmId).eq(DisplayType::getEventType, 3));
+//            if (ObjectUtil.isNotEmpty(displayType1)){
+//                type1 = displayType1.getDisplayType();
+//            }
+//            ProdStock prodStock = prodStockMapper.selectOne(new QueryWrapper<ProdStock>().lambda()
+//                    .eq(ProdStock::getDisplayType, type1)
+//                    .eq(ProdStock::getFarmId, farmId)
+//                    .orderByDesc(ProdStock::getCreatTime).last("LIMIT 1"));
+//            if (ObjectUtil.isNotEmpty(prodStock)){
+//                ProdStockThreshold threshold = prodStockThresholdMapper.selectOne(new QueryWrapper<ProdStockThreshold>().lambda().eq(ProdStockThreshold::getFarmId, farmId));
+//                if (ObjectUtil.isNotEmpty(threshold)){
+//                    Integer minBrzcl = threshold.getMinBrzcl();
+//                    Integer minByzcl = threshold.getMinByzcl();
+//                    Integer minGzcl = threshold.getMinGzcl();
+//                    Integer minHbzcl = threshold.getMinHbzcl();
+//                    Integer minMzcl = threshold.getMinMzcl();
+//                    Integer minYfzcl = threshold.getMinYfzcl();
+//                    if (ObjectUtil.isNotEmpty(minBrzcl)){
+//                        if (ObjectUtil.isNotEmpty(prodStock.getBrzcl())){
+//                            if (prodStock.getBrzcl().compareTo(minBrzcl) < 0){
+//                                ProdWarningInfo prodWarningInfo = new ProdWarningInfo();
+//                                prodWarningInfo.setDate(LocalDateTime.now());
+//                                prodWarningInfo.setFarmId(farmId);
+//                                prodWarningInfo.setWarningContent("哺乳猪存栏小于阈值!");
+//                                prodWarningInfo.setWarningType(0);
+//                                prodWarningInfoMapper.insert(prodWarningInfo);
+//                            }
+//                        }
+//                    }
+//                    if (ObjectUtil.isNotEmpty(minByzcl)){
+//                        if (ObjectUtil.isNotEmpty(prodStock.getByzcl())){
+//                            if (prodStock.getByzcl().compareTo(minByzcl) < 0){
+//                                ProdWarningInfo prodWarningInfo = new ProdWarningInfo();
+//                                prodWarningInfo.setDate(LocalDateTime.now());
+//                                prodWarningInfo.setFarmId(farmId);
+//                                prodWarningInfo.setWarningContent("保育猪存栏小于阈值!");
+//                                prodWarningInfo.setWarningType(0);
+//                                prodWarningInfoMapper.insert(prodWarningInfo);
+//                            }
+//                        }
+//                    }
+//                    if (ObjectUtil.isNotEmpty(minGzcl)){
+//                        if (ObjectUtil.isNotEmpty(prodStock.getGzcl())){
+//                            if (prodStock.getGzcl().compareTo(minGzcl) < 0){
+//                                ProdWarningInfo prodWarningInfo = new ProdWarningInfo();
+//                                prodWarningInfo.setDate(LocalDateTime.now());
+//                                prodWarningInfo.setFarmId(farmId);
+//                                prodWarningInfo.setWarningContent("公猪存栏小于阈值!");
+//                                prodWarningInfo.setWarningType(0);
+//                                prodWarningInfoMapper.insert(prodWarningInfo);
+//                            }
+//                        }
+//                    }
+//                    if (ObjectUtil.isNotEmpty(minHbzcl)){
+//                        if (ObjectUtil.isNotEmpty(prodStock.getHbzcl())){
+//                            if (prodStock.getHbzcl().compareTo(minHbzcl) < 0){
+//                                ProdWarningInfo prodWarningInfo = new ProdWarningInfo();
+//                                prodWarningInfo.setDate(LocalDateTime.now());
+//                                prodWarningInfo.setFarmId(farmId);
+//                                prodWarningInfo.setWarningContent("后备猪存栏小于阈值!");
+//                                prodWarningInfo.setWarningType(0);
+//                                prodWarningInfoMapper.insert(prodWarningInfo);
+//                            }
+//                        }
+//                    }
+//                    if (ObjectUtil.isNotEmpty(minMzcl)){
+//                        if (ObjectUtil.isNotEmpty(prodStock.getMzcl())){
+//                            if (prodStock.getMzcl().compareTo(minMzcl) < 0){
+//                                ProdWarningInfo prodWarningInfo = new ProdWarningInfo();
+//                                prodWarningInfo.setDate(LocalDateTime.now());
+//                                prodWarningInfo.setFarmId(farmId);
+//                                prodWarningInfo.setWarningContent("母猪存栏小于阈值!");
+//                                prodWarningInfo.setWarningType(0);
+//                                prodWarningInfoMapper.insert(prodWarningInfo);
+//                            }
+//                        }
+//                    }
+//                    if (ObjectUtil.isNotEmpty(minYfzcl)){
+//                        if (ObjectUtil.isNotEmpty(prodStock.getYfzcl())){
+//                            if (prodStock.getYfzcl().compareTo(minYfzcl) < 0){
+//                                ProdWarningInfo prodWarningInfo = new ProdWarningInfo();
+//                                prodWarningInfo.setDate(LocalDateTime.now());
+//                                prodWarningInfo.setFarmId(farmId);
+//                                prodWarningInfo.setWarningContent("育肥猪存栏小于阈值!");
+//                                prodWarningInfo.setWarningType(0);
+//                                prodWarningInfoMapper.insert(prodWarningInfo);
+//                            }
+//                        }
+//                    }
+//                }
+//            }
+//            ProdProduction prodProduction = prodProductionMapper.selectOne(new QueryWrapper<ProdProduction>().lambda()
+//                    .eq(ProdProduction::getFarmId, farmId).orderByDesc(ProdProduction::getCreatTime).last("LIMIT 1"));
+//            if (ObjectUtil.isNotEmpty(prodProduction)){
+//                ProdProductionThreshold prodProductionThreshold = prodProductionThresholdMapper.selectOne(new QueryWrapper<ProdProductionThreshold>().lambda().eq(ProdProductionThreshold::getFarmId,farmId));
+//                if (ObjectUtil.isNotEmpty(prodProductionThreshold)){
+//                    checkAndWarn(prodProductionThreshold.getMinBychl(), prodProduction.getBychl(),farmId, 1, "保育成活率小于阈值!");
+//                    checkAndWarn(prodProductionThreshold.getMinCfchl(), prodProduction.getCfchl(),farmId, 1, "产房成活率小于阈值!");
+//                    checkAndWarn2(prodProductionThreshold.getMinFccts(), prodProduction.getFccts(),farmId, 1, "非生产天数大于阈值!");
+//                    checkAndWarn(prodProductionThreshold.getMinFzchl(), prodProduction.getFzchl(),farmId, 1, "肥猪成活率小于阈值!");
+//                    checkAndWarn(prodProductionThreshold.getMinMrwll(), prodProduction.getMrwll(),farmId, 1, "每日喂料量小于阈值!");
+//                    checkAndWarn(prodProductionThreshold.getMinPjwchzs(), prodProduction.getPjwchzs(),farmId, 1, "平均窝产活仔数小于阈值!");
+//                    checkAndWarn(prodProductionThreshold.getMinPjwczczs(), prodProduction.getPjwczczs(),farmId, 1, "平均窝产正常仔数小于阈值!");
+//                    checkAndWarn(prodProductionThreshold.getMinPjwdnz(), prodProduction.getPjwdnz(),farmId, 1, "平均窝断奶窝重小于阈值!");
+//                    checkAndWarn(prodProductionThreshold.getMinPsy(), prodProduction.getPsy(),farmId, 1, "PSY小于阈值!");
+//                    checkAndWarn(prodProductionThreshold.getMinPzfml(), prodProduction.getPzfml(),farmId, 1, "配种分娩率小于阈值!");
+//                    checkAndWarn(prodProductionThreshold.getMinQrdpl(), prodProduction.getQrdpl(),farmId, 1, "7日断配率小于阈值!");
+//                    checkAndWarn(prodProductionThreshold.getMinRzz(), prodProduction.getRzz(),farmId, 1, "日增重小于阈值!");
+//                    checkAndWarn(prodProductionThreshold.getMinScws(), prodProduction.getScws(),farmId, 1, "年产窝数小于阈值!");
+//                    checkAndWarn(prodProductionThreshold.getMinWdnzzs(), prodProduction.getWdnzzs(),farmId, 1, "窝断奶仔猪数小于阈值!");
+//                    checkAndWarn(prodProductionThreshold.getMinYfchl(), prodProduction.getYfchl(),farmId, 1, "育肥成活率小于阈值!");
+//                    checkAndWarn(prodProductionThreshold.getMinPjwczs(), prodProduction.getPjwczs(),farmId, 1, "平均窝产仔数小于阈值!");
+//                }
+//            }
+//        }
+//    }
+//
+//    private void checkAndWarn(String threshold, String actualValue,Integer farmId, int warningType, String warningContent) {
+//        if (ObjectUtil.isNotEmpty(threshold) && ObjectUtil.isNotEmpty(actualValue)) {
+//            if (Double.valueOf(actualValue).compareTo(Double.valueOf(threshold)) < 0) {
+//                ProdWarningInfo prodWarningInfo = new ProdWarningInfo();
+//                prodWarningInfo.setDate(LocalDateTime.now());
+//                prodWarningInfo.setFarmId(farmId);
+//                prodWarningInfo.setWarningContent(warningContent);
+//                prodWarningInfo.setWarningType(warningType);
+//                prodWarningInfoMapper.insert(prodWarningInfo);
+//            }
+//        }
+//    }
+//
+//    private void checkAndWarn2(String threshold, String actualValue,Integer farmId, int warningType, String warningContent) {
+//        if (ObjectUtil.isNotEmpty(threshold) && ObjectUtil.isNotEmpty(actualValue)) {
+//            if (Double.valueOf(actualValue).compareTo(Double.valueOf(threshold)) > 0) {
+//                ProdWarningInfo prodWarningInfo = new ProdWarningInfo();
+//                prodWarningInfo.setDate(LocalDateTime.now());
+//                prodWarningInfo.setFarmId(farmId);
+//                prodWarningInfo.setWarningContent(warningContent);
+//                prodWarningInfo.setWarningType(warningType);
+//                prodWarningInfoMapper.insert(prodWarningInfo);
+//            }
+//        }
+//    }
+//
+//}

Fichier diff supprimé car celui-ci est trop grand
+ 569 - 569
huimv-admin/src/main/java/com/huimv/admin/timer/ProtTimer.java


Fichier diff supprimé car celui-ci est trop grand
+ 528 - 528
huimv-admin/src/main/java/com/huimv/admin/timer/ShenChanTimer.java


Fichier diff supprimé car celui-ci est trop grand
+ 2974 - 2974
huimv-admin/src/main/java/com/huimv/admin/timer/WaterAndElcTimer.java


+ 2 - 1
huimv-receive/src/main/java/com/huimv/receive/service/impl/BaseProcessServiceImpl.java

@@ -104,7 +104,6 @@ public class BaseProcessServiceImpl extends ServiceImpl<BaseProcessMapper, BaseP
             type = "0";
         }
         QueryWrapper<BaseProcess> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("a.farm_id", farmId);
         if ("0".equals(type)) {
             queryWrapper.in("a.process_type", 0, 1, 2,3);
         } else if ("1".equals(type)) {
@@ -121,9 +120,11 @@ public class BaseProcessServiceImpl extends ServiceImpl<BaseProcessMapper, BaseP
                 queryWrapper1.eq("process_type", 0);
             } else {
                 queryWrapper1.eq("farm_id", farmId).eq("process_type", 0);
+                queryWrapper.eq("a.farm_id", farmId);
             }
         } else {
             queryWrapper1.eq("farm_id", farmId).eq("process_type", 0);
+            queryWrapper.eq("a.farm_id", farmId);
         }
 
         return new Result(ResultCode.SUCCESS, baseProcessMapper.listAll(queryWrapper, page),baseProcessMapper.selectCount(queryWrapper1));

+ 10 - 10
huimv-receive/src/main/java/com/huimv/receive/service/impl/BillCleanServiceImpl.java

@@ -123,9 +123,9 @@ public class BillCleanServiceImpl extends ServiceImpl<BillCleanMapper, BillClean
                 String[] s = {TokenSign.getWorkIdByJwtToken(httpServletRequest)};
                 System.out.println("传入自定义sql的位置参数形式:" + s);
                 if (Integer.parseInt(TokenSign.getWorkIdByJwtToken(httpServletRequest)) == 47) {
-                    cleanDryGoodPage = cleanMapper.listCleanDryGoodsNo(page, type, "0,1".split(","), s);
+                    cleanDryGoodPage = cleanMapper.listCleanDryGoodsNo(page, type, "0,1,2,3".split(","), s);
                 } else {
-                    cleanDryGoodPage = cleanMapper.listCleanDryGoods(page, farmId, type, "0,1".split(","), s);
+                    cleanDryGoodPage = cleanMapper.listCleanDryGoods(page, farmId, type, "0,1,2,3".split(","), s);
                 }
                 queryWrapper.in("test_location_id", TokenSign.getWorkIdByJwtToken(httpServletRequest));
                 queryWrapper2.in("test_location_id", TokenSign.getWorkIdByJwtToken(httpServletRequest));
@@ -167,8 +167,8 @@ public class BillCleanServiceImpl extends ServiceImpl<BillCleanMapper, BillClean
                 queryWrapper3.in("test_location_id", TokenSign.getWorkIdByJwtToken(httpServletRequest));
             }
 
-            queryWrapper.eq("img_status", 0);
-            queryWrapper2.eq("img_status", 0);
+            queryWrapper.eq("bill_status", 0);
+            queryWrapper2.eq("bill_status", 0);
             queryWrapper3.eq("bill_status", 0);
             Integer integer = cleanMapper.selectCount(queryWrapper);
             Integer integer1 = dryMapper.selectCount(queryWrapper2);
@@ -224,8 +224,8 @@ public class BillCleanServiceImpl extends ServiceImpl<BillCleanMapper, BillClean
                 queryWrapper.in("test_location_id", TokenSign.getWorkIdByJwtToken(httpServletRequest));
                 queryWrapper2.in("test_location_id", TokenSign.getWorkIdByJwtToken(httpServletRequest));
             }
-            queryWrapper.eq("img_status", 0);
-            queryWrapper2.eq("img_status", 0);
+            queryWrapper.eq("bill_status", 0);
+            queryWrapper2.eq("bill_status", 0);
             Integer integer = cleanMapper.selectCount(queryWrapper);
             Integer integer1 = dryMapper.selectCount(queryWrapper2);
             return new Result(ResultCode.SUCCESS, cleanAndDryVo2Page, integer + integer1);
@@ -345,7 +345,7 @@ public class BillCleanServiceImpl extends ServiceImpl<BillCleanMapper, BillClean
                 billClean.setTestLocationId(baseLocation.getId());
                 billClean.setCheckDate(sdf.parse(date));
                 billClean.setPassDate(sdf.parse(sdf.format(new Date())));
-                billClean.setCleanTime("10");
+                billClean.setCleanTime("20");
 
                 if (exist.getExist() == 0) {
                     if (baseLocation.getId() == 1 && baseProcess.getDestId() > 2) {
@@ -542,7 +542,7 @@ public class BillCleanServiceImpl extends ServiceImpl<BillCleanMapper, BillClean
                 billClean.setTestLocationId(baseLocation.getId());
                 billClean.setCheckDate(sdf.parse(date));
                 billClean.setPassDate(sdf.parse(sdf.format(new Date())));
-                billClean.setCleanTime("10");
+                billClean.setCleanTime("20");
 
 
                 if (baseProcess.getDestId() == 1) {
@@ -617,7 +617,7 @@ public class BillCleanServiceImpl extends ServiceImpl<BillCleanMapper, BillClean
             billClean.setTestLocationId(baseLocation.getId());
             billClean.setCheckDate(sdf.parse(date));
             billClean.setPassDate(sdf.parse(sdf.format(new Date())));
-            billClean.setCleanTime("10");
+            billClean.setCleanTime("20");
 
             baseProcess.setUpdateDate(baseProcess.getUpdateDate() + "," + sdf.format(new Date()));
             baseProcess.setCurrentLocation(baseProcess.getCurrentLocation());
@@ -952,7 +952,7 @@ public class BillCleanServiceImpl extends ServiceImpl<BillCleanMapper, BillClean
                 billClean.setPassDate(sdf.parse(sdf.format(new Date())));
                 billClean.setImgUrl(s);
                 billClean.setImgStatus(1);
-                billClean.setCleanTime("10");
+                billClean.setCleanTime("20");
                 cleanMapper.updateById(billClean);
 
                 Object newObject = BillPcrServiceImpl.getNewObject(nextId, billClean.getDestName(), billClean.getDestId(), billClean.getAdmissionUserName(),

+ 42 - 0
huimv-receive/src/main/java/com/huimv/receive/service/impl/BillPcrServiceImpl.java

@@ -493,6 +493,20 @@ public class BillPcrServiceImpl extends ServiceImpl<BillPcrMapper, BillPcr> impl
                                 SysAccountMultilevel sysAccountMultilevel = multilevelMapper.selectById(billPcr.getAdmissionUserId());
                                 peopleList.setImgUrl(sysAccountMultilevel.getImgUrl());
                                 peopleListMapper.insert(peopleList);
+                                if ("31".equals(farmId)) {
+                                    //凤行门禁单独的
+                                    PeopleList peopleList1 = new PeopleList();
+                                    peopleList1.setFarmId("31");
+                                    peopleList1.setDeviceCode(deviceList.getDeviceCode());
+                                    peopleList1.setUserId(billPcr.getProcessId().toString());
+                                    peopleList1.setUserName(billPcr.getAdmissionUserName());
+                                    peopleList1.setPassword("123456");
+                                    peopleList1.setType(0);
+                                    peopleList1.setCreateTime(new Date());
+                                    peopleList.setOutTime(date1);
+                                    peopleList.setImgUrl(sysAccountMultilevel.getImgUrl());
+                                    peopleListMapper.insert(peopleList1);
+                                }
                             }
                             //人员基地外围
                             if (billPcr.getMidId() == 17 || billPcr.getMidId() == 30 || billPcr.getMidId() == 42 || billPcr.getMidId() == 54) {
@@ -566,6 +580,20 @@ public class BillPcrServiceImpl extends ServiceImpl<BillPcrMapper, BillPcr> impl
                                     SysAccountMultilevel sysAccountMultilevel = multilevelMapper.selectById(billPcr.getAdmissionUserId());
                                     peopleList.setImgUrl(sysAccountMultilevel.getImgUrl());
                                     peopleListMapper.insert(peopleList);
+                                    if ("31".equals(farmId)) {
+                                        //凤行门禁单独的
+                                        PeopleList peopleList1 = new PeopleList();
+                                        peopleList1.setFarmId("31");
+                                        peopleList1.setDeviceCode(deviceList.getDeviceCode());
+                                        peopleList1.setUserId(billPcr.getProcessId().toString());
+                                        peopleList1.setUserName(billPcr.getAdmissionUserName());
+                                        peopleList1.setPassword("123456");
+                                        peopleList1.setType(0);
+                                        peopleList1.setCreateTime(new Date());
+                                        peopleList.setOutTime(date1);
+                                        peopleList.setImgUrl(sysAccountMultilevel.getImgUrl());
+                                        peopleListMapper.insert(peopleList1);
+                                    }
                                 }
                                 //人员基地外围
                                 if (billPcr.getMidId() == 17 || billPcr.getMidId() == 30 || billPcr.getMidId() == 42 || billPcr.getMidId() == 54) {
@@ -739,6 +767,20 @@ public class BillPcrServiceImpl extends ServiceImpl<BillPcrMapper, BillPcr> impl
                             SysAccountMultilevel sysAccountMultilevel = multilevelMapper.selectById(billPcr.getAdmissionUserId());
                             peopleList.setImgUrl(sysAccountMultilevel.getImgUrl());
                             peopleListMapper.insert(peopleList);
+                            if ("31".equals(farmId)) {
+                                //凤行门禁单独的
+                                PeopleList peopleList1 = new PeopleList();
+                                peopleList1.setFarmId("31");
+                                peopleList1.setDeviceCode(deviceList.getDeviceCode());
+                                peopleList1.setUserId(billPcr.getProcessId().toString());
+                                peopleList1.setUserName(billPcr.getAdmissionUserName());
+                                peopleList1.setPassword("123456");
+                                peopleList1.setType(0);
+                                peopleList1.setCreateTime(new Date());
+                                peopleList.setOutTime(date1);
+                                peopleList.setImgUrl(sysAccountMultilevel.getImgUrl());
+                                peopleListMapper.insert(peopleList1);
+                            }
                         }
                         //人员基地外围
                         if (billPcr.getMidId() == 17 || billPcr.getMidId() == 30 || billPcr.getMidId() == 42 || billPcr.getMidId() == 54) {

+ 12 - 0
huimv-receive/src/main/java/com/huimv/receive/service/impl/BillPersonnelAdmissionServiceImpl.java

@@ -606,6 +606,12 @@ public class BillPersonnelAdmissionServiceImpl extends ServiceImpl<BillPersonnel
                 baseProcess.setAllLocationStatus(split1[0] + status.substring(1));
                 baseProcessMapper.updateById(baseProcess);
                 billPersonnelAdmissionMapper.updateById(billPersonnelAdmission);
+                //如果有物资,则把物资的申请单给结束
+                BillGoodsInventory goodsInventory = billGoodsInventoryMapper.selectOne(new QueryWrapper<BillGoodsInventory>().eq("process_id", baseProcess.getId()));
+                if (ObjectUtil.isNotEmpty(goodsInventory)) {
+                    goodsInventory.setBillStatus(3);
+                    billGoodsInventoryMapper.updateById(goodsInventory);
+                }
                 return Result.SUCCESS();
             }
 
@@ -1534,6 +1540,12 @@ public class BillPersonnelAdmissionServiceImpl extends ServiceImpl<BillPersonnel
                     baseProcess.setAllLocationStatus(split1[0] + status.substring(1));
                     baseProcessMapper.updateById(baseProcess);
                     billPersonnelAdmissionMapper.updateById(billPersonnelAdmission);
+                    //如果有物资,则把物资的申请单给结束
+                    BillGoodsInventory goodsInventory = billGoodsInventoryMapper.selectOne(new QueryWrapper<BillGoodsInventory>().eq("process_id", baseProcess.getId()));
+                    if (ObjectUtil.isNotEmpty(goodsInventory)) {
+                        goodsInventory.setBillStatus(3);
+                        billGoodsInventoryMapper.updateById(goodsInventory);
+                    }
                     return Result.SUCCESS();
                 }
                 //通过

+ 3 - 3
huimv-receive/src/main/java/com/huimv/receive/timer/DiBangimer.java

@@ -23,7 +23,7 @@ public class DiBangimer {
     private BillGateMapper billGateMapper;
 
     //多利托地磅
-    @Scheduled(cron = "0 * * * * ? ")
+    @Scheduled(cron = "0 0 * * * ? ")
     private void getShenChan() throws Exception {
         String url = "jdbc:jtds:sqlserver://218.76.168.4:1433/CMTWeight"; // 使用 jTDS 连接字符串
         String user = "sa";
@@ -47,10 +47,10 @@ public class DiBangimer {
                     if (ObjectUtil.isNotEmpty(billGate1)){
                         billGate = billGate1.get(0);
                         billGate.setGross(resultSet.getDouble("F_Gross")+"");
-                        billGate.setTare(resultSet.getDouble("F_Money")+"");
+                        billGate.setTare(resultSet.getDouble("F_Tare")+"");
                         billGate.setNet(resultSet.getDouble("F_Net")+"");
                         billGate.setStdno(resultSet.getString("F_StdNo"));
-                        billGateMapper.insert(billGate);
+                        billGateMapper.updateById(billGate);
                     }
                 }
 

+ 9 - 9
huimv-receive/src/main/resources/com/huimv/receive/mapper/BillCleanMapper.xml

@@ -56,7 +56,7 @@
         <foreach collection="locations" item="location" separator="," open="(" close=")">
             #{location}
         </foreach>
-        and img_status in
+        and bill_status in
         <foreach collection="status" item="statu" separator="," open="(" close=")">
             #{statu}
         </foreach>
@@ -66,7 +66,7 @@
         <foreach collection="locations" item="location" separator="," open="(" close=")">
             #{location}
         </foreach>
-        and img_status in
+        and bill_status in
         <foreach collection="status" item="statu" separator="," open="(" close=")">
             #{statu}
         </foreach>
@@ -78,7 +78,7 @@
         <foreach collection="locations" item="location" separator="," open="(" close=")">
             #{location}
         </foreach>
-        and img_status in
+        and bill_status in
         <foreach collection="status" item="statu" separator="," open="(" close=")">
             #{statu}
         </foreach>
@@ -88,7 +88,7 @@
         <foreach collection="locations" item="location" separator="," open="(" close=")">
             #{location}
         </foreach>
-        and img_status in
+        and bill_status in
         <foreach collection="status" item="statu" separator="," open="(" close=")">
             #{statu}
         </foreach>
@@ -148,7 +148,7 @@ ORDER BY
         <foreach collection="locations" item="location" separator="," open="(" close=")">
             #{location}
         </foreach>
-        and img_status in
+        and bill_status in
         <foreach collection="status" item="statu" separator="," open="(" close=")">
             #{statu}
         </foreach>
@@ -158,12 +158,12 @@ ORDER BY
         <foreach collection="locations" item="location" separator="," open="(" close=")">
             #{location}
         </foreach>
-        and img_status in
+        and bill_status in
         <foreach collection="status" item="statu" separator="," open="(" close=")">
             #{statu}
         </foreach>
         union all
-        select id,'5' as 'vistitType',test_location as 'testLocation',admission_user_name,car_num,null as 'cleanTime',null as 'dryTime',null as 'checkDate' ,sub_date,bill_status as 'billStatus' ,null,3 AS 'type' from bill_goods_inventory where farm_id=#{farmId}
+        select id,'0' as 'vistitType',test_location as 'testLocation',admission_user_name,car_num,null as 'cleanTime',null as 'dryTime',null as 'checkDate' ,sub_date,bill_status as 'billStatus' ,null,3 AS 'type' from bill_goods_inventory where farm_id=#{farmId}
         and test_location_id in
         <foreach collection="locations" item="location" separator="," open="(" close=")">
             #{location}
@@ -180,7 +180,7 @@ ORDER BY
         <foreach collection="locations" item="location" separator="," open="(" close=")">
             #{location}
         </foreach>
-        and img_status in
+        and bill_status in
         <foreach collection="status" item="statu" separator="," open="(" close=")">
             #{statu}
         </foreach>
@@ -190,7 +190,7 @@ ORDER BY
         <foreach collection="locations" item="location" separator="," open="(" close=")">
             #{location}
         </foreach>
-        and img_status in
+        and bill_status in
         <foreach collection="status" item="statu" separator="," open="(" close=")">
             #{statu}
         </foreach>