Selaa lähdekoodia

修改bug,添加预警功能

523096025 2 vuotta sitten
vanhempi
commit
21fca1ef5a

+ 1 - 0
huimv-env-platform/huimv-env-common/src/main/java/com/huimv/env/common/service/IBaseThresholdService.java

@@ -19,4 +19,5 @@ public interface IBaseThresholdService extends IService<BaseThreshold> {
     Result listThreshold(Map<String,String> map);
 
 
+    String getTempThresholdByDeviceCode(String idCode);
 }

+ 3 - 0
huimv-env-platform/huimv-env-common/src/main/java/com/huimv/env/common/service/IEnvPushMessageService.java

@@ -3,6 +3,8 @@ package com.huimv.env.common.service;
 import com.huimv.env.common.entity.EnvPushMessage;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.sql.Timestamp;
+
 /**
  * <p>
  *  服务类
@@ -13,4 +15,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface IEnvPushMessageService extends IService<EnvPushMessage> {
 
+    void saveHumi(String deviceCode, Timestamp nowTimestamp, String humi, String farmCode);
 }

+ 22 - 0
huimv-env-platform/huimv-env-common/src/main/java/com/huimv/env/common/service/impl/BaseThresholdServiceImpl.java

@@ -5,15 +5,20 @@ import cn.hutool.core.util.RandomUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.huimv.common.utils.Result;
 import com.huimv.common.utils.ResultCode;
+import com.huimv.env.common.dao.entity.EnvDeviceRegisterEntity;
+import com.huimv.env.common.dao.entity.EnvTempThresholdEntity;
+import com.huimv.env.common.dao.repo.EnvDeviceRegisterEntityRepo;
 import com.huimv.env.common.entity.BaseThreshold;
 import com.huimv.env.common.mapper.BaseThresholdMapper;
 import com.huimv.env.common.service.IBaseThresholdService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Example;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
 import java.util.Map;
+import java.util.Optional;
 
 /**
  * <p>
@@ -29,6 +34,9 @@ public class BaseThresholdServiceImpl extends ServiceImpl<BaseThresholdMapper, B
     @Autowired
     private BaseThresholdMapper baseThresholdMapper;
 
+    @Autowired
+    private EnvDeviceRegisterEntityRepo envDeviceRegisterEntityRepo;
+
     @Override
     public Result listThreshold(Map<String,String> map) {
         String farmCode = map.get("farmCode");
@@ -52,4 +60,18 @@ public class BaseThresholdServiceImpl extends ServiceImpl<BaseThresholdMapper, B
 
         return new Result(ResultCode.SUCCESS,baseThreshold);
     }
+
+    @Override
+    public String getTempThresholdByDeviceCode(String idCode) {
+        EnvDeviceRegisterEntity envDeviceRegisterEntity = new EnvDeviceRegisterEntity();
+        envDeviceRegisterEntity.setDeviceCode(idCode);
+        Example<EnvDeviceRegisterEntity> example = Example.of(envDeviceRegisterEntity);
+        EnvDeviceRegisterEntity envDeviceRegisterEntity1 = envDeviceRegisterEntityRepo.findOne(example).get();
+        String farmCode = envDeviceRegisterEntity1.getFarmCode();
+        BaseThreshold baseThreshold = baseThresholdMapper.selectOne(new QueryWrapper<BaseThreshold>().eq("farm_code", farmCode));
+        if (ObjectUtil.isNotEmpty(baseThreshold)){
+             return  (baseThreshold.getMaxTemp().multiply(new BigDecimal(10))).intValue() +"+"+(baseThreshold.getMinTemp().multiply(new BigDecimal(10))).intValue();
+        }
+        return "0";
+    }
 }

+ 6 - 0
huimv-env-platform/huimv-env-common/src/main/java/com/huimv/env/common/service/impl/EnvPushMessageServiceImpl.java

@@ -6,6 +6,8 @@ import com.huimv.env.common.service.IEnvPushMessageService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
+import java.sql.Timestamp;
+
 /**
  * <p>
  *  服务实现类
@@ -17,4 +19,8 @@ import org.springframework.stereotype.Service;
 @Service
 public class EnvPushMessageServiceImpl extends ServiceImpl<EnvPushMessageMapper, EnvPushMessage> implements IEnvPushMessageService {
 
+    @Override
+    public void saveHumi(String deviceCode, Timestamp nowTimestamp, String humi, String farmCode) {
+
+    }
 }

+ 1 - 0
huimv-env-platform/huimv-env-device/src/main/java/com/huimv/env/device/listener/DeviceListener.java

@@ -248,6 +248,7 @@ public class DeviceListener {
         deviceService.sendSensorToMQ(deviceCode, dataJo.getInteger("sensorSn"), nowTimestamp, todayDate, humi, farmCode, sensorSort);
         //保存湿度流水数据
         deviceService.saveHumiFlow(dataJo, envDeviceRegisterEntity, nowTimestamp, todayDate, farmCode);
+        envPushMessageService.saveHumi(deviceCode,nowTimestamp,humi,farmCode);
     }
 
     @RabbitListener(queues = Const.QUEUE_AMMONIA)

+ 5 - 5
huimv-env-platform/huimv-env-input/src/main/java/com/huimv/env/input/server/EnvInputServerHandler.java

@@ -5,10 +5,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.huimv.env.common.dao.entity.EnvDeviceEquipment;
 import com.huimv.env.common.dao.entity.EnvDeviceRegisterEntity;
 import com.huimv.env.common.dao.repo.EnvDeviceEqipmentRepo;
-import com.huimv.env.common.service.IDeviceRegisterService;
-import com.huimv.env.common.service.ISprayConfigService;
-import com.huimv.env.common.service.ISprayTimeService;
-import com.huimv.env.common.service.ITempThresholdService;
+import com.huimv.env.common.service.*;
 import com.huimv.env.common.utils.RegexUtil;
 import com.huimv.env.input.producer.Producer;
 import com.huimv.env.input.service.ICommandProcessorService;
@@ -63,6 +60,8 @@ public class EnvInputServerHandler extends ChannelInboundHandlerAdapter {
 
     @Autowired
     private EnvDeviceEqipmentRepo envDeviceEqipmentRepo;
+    @Autowired
+    private IBaseThresholdService baseThresholdService;
 
 
     //
@@ -369,7 +368,8 @@ public class EnvInputServerHandler extends ChannelInboundHandlerAdapter {
             System.out.println("##高温,低温报警参数请求-未注册设备 idCode=" + idCode);
             return;
         }
-        String threshold = tempThresholdService.getTempThresholdByDeviceCode(idCode);
+//        String threshold = tempThresholdService.getTempThresholdByDeviceCode(idCode);
+        String threshold = baseThresholdService.getTempThresholdByDeviceCode(idCode);
         String answerText = "hm+"+idCode+"+18+"+threshold+"+6+end";
         log.info(">>高温,低温报警参数请求-应答数据>>" + answerText);
         answerCmd(answerText, ctx);

+ 0 - 13
huimv-env-platform/huimv-env-manage/src/main/java/com/huimv/env/manage/controller/EnvPushMessgeController.java

@@ -30,25 +30,19 @@ public class EnvPushMessgeController {
     @PostMapping("/listMessge")
     public Result listMessge(@RequestBody Map<String,String> paramMap){
         return  envPushMessgeService.listMessge(paramMap);
-
     }
-
-
     @PostMapping("/countMessgeAndDevice")
     public Result countMessgeAndDevice(@RequestBody Map<String,String> paramMap){
         return  envPushMessgeService.countMessgeAndDevice(paramMap);
-
     }
     @GetMapping("/getById")
     public Result listMessge(@RequestParam(name = "id")Integer id){
         return  new Result(ResultCode.SUCCESS,envPushMessgeService.getById(id));
-
     }
     @PostMapping("/update")
     public Result update(@RequestBody EnvPushMessage envPushMessage){
         envPushMessgeService.updateById(envPushMessage);
         return  new Result(10000,"修改成功",true);
-
     }
     @GetMapping("/updateAll")
     public Result update(@RequestParam(name = "farmCode")Integer farmCode){
@@ -58,25 +52,18 @@ public class EnvPushMessgeController {
         envPushMessage.setReadStatus(1);
         envPushMessgeService.update(envPushMessage,wrapper);
         return  new Result(10000,"修改成功",true);
-
     }
-
-
     @GetMapping("/delete")
     public Result delete(@RequestParam(name = "id")Integer id){
-
         EnvPushMessage envPushMessage = new EnvPushMessage();
         envPushMessage.setId(id);
         envPushMessage.setDisplay(0);
         envPushMessgeService.updateById(envPushMessage);
         return new Result(10000,"删除成功",true) ;
-
     }
     @GetMapping("/countRead")
     public Result countRead(@RequestParam(name = "farmCode")Integer farmCode){
-
         return envPushMessgeService.countRead(farmCode);
-
     }
 
 }

+ 1 - 1
huimv-env-platform/huimv-env-manage/src/main/java/com/huimv/env/manage/service/impl/EnvPushMessgeServiceImpl.java

@@ -72,7 +72,7 @@ public class EnvPushMessgeServiceImpl extends ServiceImpl<EnvPushMessgeMapper, E
         String farmCode = paramMap.get("farmCode");
         Map map = new HashMap();
         Long deviceCount = envDeviceRegisterMapper.selectCount(new QueryWrapper<EnvDeviceRegister>().eq("farm_code", farmCode));
-        long messgeCount = this.count(new QueryWrapper<EnvPushMessage>().eq("farm_code", farmCode));
+        long messgeCount = this.count(new QueryWrapper<EnvPushMessage>().eq("farm_code", farmCode).eq("read_status",0).eq("display",1));
 
         map.put("deviceCount",deviceCount);
         map.put("messgeCount",messgeCount);

+ 2 - 5
huimv-env-platform/huimv-env-produce/src/main/java/com/huimv/env/produce/controller/BoardController.java

@@ -6,11 +6,7 @@ import com.huimv.common.utils.Result;
 import com.huimv.common.utils.ResultCode;
 import com.huimv.env.produce.service.*;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.text.ParseException;
 import java.util.Map;
@@ -25,6 +21,7 @@ import java.util.Map;
  */
 @RestController
 @RequestMapping("/v1.0.0/board")
+@CrossOrigin
 public class BoardController {
     @Autowired
     private WarningInfoService warningInfoService;

+ 2 - 5
huimv-env-platform/huimv-env-produce/src/main/java/com/huimv/env/produce/controller/EliminateDetailController.java

@@ -4,11 +4,7 @@ package com.huimv.env.produce.controller;
 import com.huimv.common.utils.Result;
 import com.huimv.env.produce.service.EliminateDetailService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.text.ParseException;
 import java.util.Map;
@@ -23,6 +19,7 @@ import java.util.Map;
  */
 @RestController
 @RequestMapping("/v1.0.0/eliminate")
+@CrossOrigin
 public class EliminateDetailController {
     @Autowired
     private EliminateDetailService eliminateDetailService;

+ 2 - 2
huimv-env-platform/huimv-env-produce/src/main/resources/application.properties

@@ -1,5 +1,5 @@
-spring.profiles.active=dev
-#spring.profiles.active=prod
+#spring.profiles.active=dev
+spring.profiles.active=prod
 
 # mysql:/cache:
 device.online.access_mode=mysql