|
|
@@ -2,14 +2,20 @@ package com.huimv.admin.server;
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.huimv.admin.entity.ProtData;
|
|
|
+import com.huimv.admin.entity.ProtThreshold;
|
|
|
+import com.huimv.admin.entity.ProtWarningInfo;
|
|
|
import com.huimv.admin.mapper.ProtDataMapper;
|
|
|
+import com.huimv.admin.service.IProtThresholdService;
|
|
|
+import com.huimv.admin.service.IProtWarningInfoService;
|
|
|
import io.netty.buffer.ByteBuf;
|
|
|
import io.netty.channel.ChannelHandler;
|
|
|
import io.netty.channel.ChannelHandlerContext;
|
|
|
import io.netty.channel.ChannelInboundHandlerAdapter;
|
|
|
import io.netty.util.CharsetUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
@@ -101,11 +107,14 @@ public class EnvInputServerHandler extends ChannelInboundHandlerAdapter {
|
|
|
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)){
|
|
|
protData.setFarmId(30);
|
|
|
+ saveWarning(protData,30,3);
|
|
|
}else {
|
|
|
protData.setFarmId(28);
|
|
|
+ saveWarning(protData,28,3);
|
|
|
}
|
|
|
protData.setOther3(clientAskText);
|
|
|
protData.setCreateDate(new Date());
|
|
|
@@ -120,6 +129,71 @@ public class EnvInputServerHandler extends ChannelInboundHandlerAdapter {
|
|
|
|
|
|
|
|
|
}
|
|
|
+ @Autowired
|
|
|
+ private IProtThresholdService protThresholdService;
|
|
|
+ @Autowired
|
|
|
+ private IProtWarningInfoService warningInfoService;
|
|
|
+
|
|
|
+ private void saveWarning(ProtData protData,Integer farmId,Integer protType) {
|
|
|
+ ProtThreshold one = protThresholdService.getOne(new QueryWrapper<ProtThreshold>().eq("farm_id", farmId).eq("prot_type", protType));
|
|
|
+ ProtWarningInfo protWarningInfo = new ProtWarningInfo();
|
|
|
+ protWarningInfo.setDate(new Date());
|
|
|
+ protWarningInfo.setFarmId(farmId);
|
|
|
+ boolean ble = false;
|
|
|
+ if (comperStringAndString(protData.getCod(),one.getCod2())){
|
|
|
+ protWarningInfo.setWarningType(0);
|
|
|
+ protWarningInfo.setWarningContent("cod浓度为 "+protData.getCod()+",超过阈值"+one.getCod2()+"红色预警");
|
|
|
+ } else if (comperStringAndString(protData.getCod(),one.getCod1()) ) {
|
|
|
+ protWarningInfo.setWarningType(0);
|
|
|
+ protWarningInfo.setWarningContent("cod浓度为 "+protData.getCod()+",超过阈值"+one.getCod2()+"黄色预警");
|
|
|
+ ble = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (comperStringAndString(protData.getFlow(),one.getFlow2())){
|
|
|
+ protWarningInfo.setWarningType(5);
|
|
|
+ protWarningInfo.setWarningContent("流量为 "+protData.getFlow()+",超过阈值"+one.getFlow2()+"红色预警");
|
|
|
+ ble = true;
|
|
|
+ } else if (comperStringAndString(protData.getFlow(),one.getFlow1()) ) {
|
|
|
+
|
|
|
+ protWarningInfo.setWarningType(5);
|
|
|
+ protWarningInfo.setWarningContent("流量为 "+protData.getFlow()+",超过阈值"+one.getFlow1()+"黄色预警");
|
|
|
+ ble = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (comperStringAndString(protData.getNh3n(),one.getNh3n2())){
|
|
|
+ protWarningInfo.setWarningType(2);
|
|
|
+ protWarningInfo.setWarningContent("氨氮为 "+protData.getNh3n()+",超过阈值"+one.getNh3n2()+"红色预警");
|
|
|
+ ble = true;
|
|
|
+ } else if (comperStringAndString(protData.getNh3n(),one.getNh3n1()) ) {
|
|
|
+ protWarningInfo.setWarningType(2);
|
|
|
+ protWarningInfo.setWarningContent("氨氮为 "+protData.getNh3n()+",超过阈值"+one.getNh3n1()+"黄色预警");
|
|
|
+ ble = true;
|
|
|
+ }
|
|
|
+ if (comperStringAndString(protData.getPh(),"8.8")){
|
|
|
+ protWarningInfo.setWarningType(1);
|
|
|
+ protWarningInfo.setWarningContent("ph为 "+protData.getPh()+",超过阈值8.8红色预警");
|
|
|
+ ble = true;
|
|
|
+ }else if (comperStringAndString("6.2",protData.getPh()) ) {
|
|
|
+ protWarningInfo.setWarningType(1);
|
|
|
+ protWarningInfo.setWarningContent("ph为 "+protData.getPh()+",低于阈值6.2红色色预警");
|
|
|
+ ble = true;
|
|
|
+ } else if (!(comperStringAndString(protData.getPh(),one.getOther2()) && comperStringAndString(one.getPh1() ,protData.getPh()) )) {
|
|
|
+ protWarningInfo.setWarningType(1);
|
|
|
+ protWarningInfo.setWarningContent("ph为 "+protData.getPh()+"黄色预警");
|
|
|
+ ble = true;
|
|
|
+ }
|
|
|
+ if (ble){
|
|
|
+ warningInfoService.save(protWarningInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ private boolean comperStringAndString(String value ,String th){
|
|
|
+ if (StringUtils.isBlank(value) || StringUtils.isBlank(th)){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return Double.parseDouble(value) > Double.parseDouble(th);
|
|
|
+
|
|
|
+ }
|
|
|
//QN 20250412142007184 请求编号(21位时间戳:2025-04-12 14:20:07.184)
|
|
|
//ST 32 系统类型(32表示污水处理设施)
|
|
|
//CN 2051 命令编号(2051表示实时数据上报)
|