wwh 2 лет назад
Родитель
Сommit
aad7f2ee55

+ 1 - 1
huimv-admin/src/main/java/com/huimv/admin/common/utils/NumberUtils.java

@@ -29,7 +29,7 @@ public class NumberUtils {
     // 是小数位数
     public static String getNumFloat(Double min, Double max) {
         double v = Math.random() * (max - min) + min;
-        DecimalFormat df = new DecimalFormat("0.0000");
+        DecimalFormat df = new DecimalFormat("0.0");
         return df.format(v);
     }
 

+ 18 - 12
huimv-admin/src/main/java/com/huimv/admin/service/impl/ProtThresholdServiceImpl.java

@@ -71,6 +71,8 @@ public class ProtThresholdServiceImpl extends ServiceImpl<ProtThresholdMapper, P
             jsonObject.put("FLOW2", 0);
             jsonObject.put("userIds", 0);
             jsonObject.put("dataType", 0);
+            jsonObject.put("other2", 0);
+            jsonObject.put("other3", 0);
             return new Result(ResultCode.SUCCESS, jsonObject);
         } else {
             JSONObject jsonObject = new JSONObject();
@@ -133,22 +135,26 @@ public class ProtThresholdServiceImpl extends ServiceImpl<ProtThresholdMapper, P
                 protThreshold1.setTn2(protThreshold.getTn2());
                 protThreshold1.setFlow1(protThreshold.getFlow1());
                 protThreshold1.setFlow2(protThreshold.getFlow2());
+                protThreshold1.setOther2(protThreshold.getOther2());//低ph中较大的ph=6.5
+                protThreshold1.setOther3(protThreshold.getOther3());//ph=6
                 protThreshold1.setUserIds(oldUsersIds.stream().map(String::valueOf).collect(Collectors.joining(",")));
                 protThreshold1.setDataType(protThreshold.getDataType());
 
 
-                if (Integer.parseInt(protThreshold.getCod2()) <= Integer.parseInt(protThreshold.getCod1())) {
-                    return new Result(ResultCode.FAIL, "红色预警浓度不能低于橙色预警浓度");
-                } else if (Integer.parseInt(protThreshold.getPh2()) <= Integer.parseInt(protThreshold.getPh1())) {
-                    return new Result(ResultCode.FAIL, "红色预警浓度不能低于橙色预警浓度");
-                } else if (Integer.parseInt(protThreshold.getNh3n2()) <= Integer.parseInt(protThreshold.getNh3n1())) {
-                    return new Result(ResultCode.FAIL, "红色预警浓度不能低于橙色预警浓度");
-                } else if (Integer.parseInt(protThreshold.getTp2()) <= Integer.parseInt(protThreshold.getTp1())) {
-                    return new Result(ResultCode.FAIL, "红色预警浓度不能低于橙色预警浓度");
-                } else if (Integer.parseInt(protThreshold.getTn2()) <= Integer.parseInt(protThreshold.getTn1())) {
-                    return new Result(ResultCode.FAIL, "红色预警浓度不能低于橙色预警浓度");
-                } else if (Integer.parseInt(protThreshold.getFlow2()) <= Integer.parseInt(protThreshold.getFlow1())) {
-                    return new Result(ResultCode.FAIL, "红色预警浓度不能低于橙色预警浓度");
+                if (Double.parseDouble(protThreshold.getCod2()) <= Double.parseDouble(protThreshold.getCod1())) {
+                    return new Result(ResultCode.FAIL, "Cod红色预警浓度不能低于橙色预警浓度");
+                } else if (Double.parseDouble(protThreshold.getPh2()) <= Double.parseDouble(protThreshold.getPh1())) {
+                    return new Result(ResultCode.FAIL, "高值ph红色预警浓度不能低于橙色预警浓度");
+                } else if (Double.parseDouble(protThreshold.getOther3()) >= Double.parseDouble(protThreshold.getOther2())) {
+                    return new Result(ResultCode.FAIL, "低值ph红色预警浓度不能低于橙色预警浓度");
+                } else if (Double.parseDouble(protThreshold.getNh3n2()) <= Double.parseDouble(protThreshold.getNh3n1())) {
+                    return new Result(ResultCode.FAIL, "NH3NH2红色预警浓度不能低于橙色预警浓度");
+                } else if (Double.parseDouble(protThreshold.getTp2()) <= Double.parseDouble(protThreshold.getTp1())) {
+                    return new Result(ResultCode.FAIL, "TP红色预警浓度不能低于橙色预警浓度");
+                } else if (Double.parseDouble(protThreshold.getTn2()) <= Double.parseDouble(protThreshold.getTn1())) {
+                    return new Result(ResultCode.FAIL, "TN红色预警浓度不能低于橙色预警浓度");
+                } else if (Double.parseDouble(protThreshold.getFlow2()) <= Double.parseDouble(protThreshold.getFlow1())) {
+                    return new Result(ResultCode.FAIL, "流量红色预警浓度不能低于橙色预警浓度");
                 } else {
 
                     if (ObjectUtil.isEmpty(threshold)) {

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

@@ -33,15 +33,15 @@ public class  GasTimer {
         String type = NumberUtils.getNum(1, 5, 0);//loc_type
         for (int i = 1; i < 5; i++) {
 
-            String nh3n = NumberUtils.getNumFloat(0.01, 0.0501);//NH3N
-            String jlm = NumberUtils.getNumFloat(0.01, 0.0701);//jlm
-            String elht = NumberUtils.getNumFloat(1.00, 2.5001);//elht
-            String ejel = NumberUtils.getNumFloat(0.01, 0.0501);//ejel
-            String h2s = NumberUtils.getNumFloat(0.01, 0.0501);//h2s
-            String byx = NumberUtils.getNumFloat(1.0, 4.5001);//byx
-            String ch3 = NumberUtils.getNumFloat(0.001, 0.0062);//ch3
-            String sja = NumberUtils.getNumFloat(0.01, 0.0701);//sja
-            String cq = NumberUtils.getNumFloat(10.0, 18.001);//cq
+            String nh3n = NumberUtils.getNumFloat(0.0, 10.5);//NH3N
+            String jlm = NumberUtils.getNumFloat(0.0, 10.5);//jlm
+            String elht = NumberUtils.getNumFloat(0.0, 10.5);//elht
+            String ejel = NumberUtils.getNumFloat(0.0, 10.5);//ejel
+            String h2s = NumberUtils.getNumFloat(0.0, 10.5);//h2s
+            String byx = NumberUtils.getNumFloat(0.0, 20.5);//byx
+            String ch3 = NumberUtils.getNumFloat(0.0, 10.5);//ch3
+            String sja = NumberUtils.getNumFloat(0.0,10.5);//sja
+
 
             GasData gasData = new GasData();
             gasData.setLoctionType(i);
@@ -53,14 +53,16 @@ public class  GasTimer {
             gasData.setByx(byx);
             gasData.setCh3sh(ch3);
             gasData.setSja(sja);
-            gasData.setCq(cq);
             gasData.setFarmId(21);
             gasData.setCreateTime(new Date());
-            gasDataMapper.insert(gasData);
+
 
             QueryWrapper<GasThreshold> queryWrapper = new QueryWrapper<>();
             GasWarningInfo warningInfo = new GasWarningInfo();
             if (i==1) {
+                String cq = NumberUtils.getNumFloat(0.0, 1000.5);//cq
+                gasData.setCq(cq);
+
                 queryWrapper.eq("farm_id", 21).eq("gas_type", 1);
                 GasThreshold gasThreshold = thresholdMapper.selectOne(queryWrapper);
                 if (Double.parseDouble(nh3n) > Double.parseDouble(gasThreshold.getNh3N())) {
@@ -146,6 +148,9 @@ public class  GasTimer {
                 }
 
             } else if (i==2) {
+                String cq = NumberUtils.getNumFloat(0.0, 5000.5);//cq
+                gasData.setCq(cq);
+
                 queryWrapper.eq("farm_id", 21).eq("gas_type", 2);
                 GasThreshold gasThreshold = thresholdMapper.selectOne(queryWrapper);
                 if (Double.parseDouble(nh3n) > Double.parseDouble(gasThreshold.getNh3N())) {
@@ -232,6 +237,9 @@ public class  GasTimer {
                 }
 
             } else if (i==3) {
+                String cq = NumberUtils.getNumFloat(0.0, 1000.5);//cq
+                gasData.setCq(cq);
+
                 queryWrapper.eq("farm_id", 21).eq("gas_type", 3);
                 GasThreshold gasThreshold = thresholdMapper.selectOne(queryWrapper);
                 if (Double.parseDouble(nh3n) > Double.parseDouble(gasThreshold.getNh3N())) {
@@ -318,6 +326,9 @@ public class  GasTimer {
                 }
 
             } else if (i==4) {
+                String cq = NumberUtils.getNumFloat(0.0, 10000.5);//cq
+                gasData.setCq(cq);
+
                 queryWrapper.eq("farm_id", 21).eq("gas_type", 4);
                 GasThreshold gasThreshold = thresholdMapper.selectOne(queryWrapper);
                 if (Double.parseDouble(nh3n) > Double.parseDouble(gasThreshold.getNh3N())) {
@@ -403,6 +414,7 @@ public class  GasTimer {
                 }
 
             }
+            gasDataMapper.insert(gasData);
         }
     }
 }

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

@@ -35,43 +35,41 @@ public class ProtTimer {
     private void getShenChan() throws Exception {
 
 
-
         for (int i = 1; i < 4; i++) {
 
             //假设已经拿到了数据
-            String num = NumberUtils.getNumFloat(4.0,6.0002);//ph
-            String num1 = NumberUtils.getNum(300, 361, 1);//cod
-            String num2 = NumberUtils.getNum(40, 61,1);//nh3n
-            String num3 = NumberUtils.getNumFloat(4.0, 6.5002);//tp
-            String num4 = NumberUtils.getNum(7000, 8001,0);//tn
-            String num5 = NumberUtils.getNum(220, 301,0);//flow
+            String num = NumberUtils.getNumFloat(6.4, 8.6);//ph
+
+
 
-            //排污口专用数据
-            String ph = NumberUtils.getNumFloat(5.0,5.9);//ph
-            String cod = NumberUtils.getNum(350, 360, 1);//cod
-            String nh3n = NumberUtils.getNum(55, 60, 1);//nh3n
-            String tp = NumberUtils.getNumFloat(5.0, 6.49);//tp
-            String tn = NumberUtils.getNum(7800, 8000, 1);//tn
-            String flow = NumberUtils.getNum(290, 300, 1);//flow
 
 
             ProtData protData = new ProtData();
             protData.setLoctionType(i);
             protData.setCreateDate(new Date());
             protData.setFarmId(21);
-            protData.setCod(num1);
             protData.setPh(num);
-            protData.setNh3n(num2);
-            protData.setTp(num3);
-            protData.setTn(num4);
-            protData.setFlow(num5);
-            protDataMapper.insert(protData);
+
+
 
             QueryWrapper<ProtThreshold> queryWrapper = new QueryWrapper<>();
             if (i == 1) {
+                String num1 = NumberUtils.getNum(8000, 20001,0);//cod
+                String num2 = NumberUtils.getNumFloat(1000.0, 1550.0);//nh3n
+                String num3 = NumberUtils.getNumFloat(100.0, 260.0);//tp
+                String num4 = NumberUtils.getNum(1000, 1550, 0);//tn
+                String num5 = NumberUtils.getNum(0, 100, 0);//flow
+
+                protData.setCod(num1);
+                protData.setNh3n(num2);
+                protData.setTp(num3);
+                protData.setTn(num4);
+                protData.setFlow(num5);
+                protDataMapper.insert(protData);
+
                 queryWrapper.eq("farm_id", 21).eq("prot_type", 1);
                 ProtThreshold protThreshold = protThresholdMapper.selectOne(queryWrapper);//进污口
-                if (Double.parseDouble(num) > Double.parseDouble(protThreshold.getPh2())) {
+                if (Double.parseDouble(num) > Double.parseDouble(protThreshold.getPh2()) || Double.parseDouble(num) < Double.parseDouble(protThreshold.getOther3())) {
                     ProtWarningInfo protWarningInfo = new ProtWarningInfo();
                     protWarningInfo.setWarningContent("进污口ph值为" + num + "达到红色预警");
                     protWarningInfo.setWarningType(1);
@@ -82,7 +80,7 @@ public class ProtTimer {
                     protWarningInfo.setBuildLocation("进污口");
                     warningInfoMapper.insert(protWarningInfo);
                 }
-                if (Double.parseDouble(num) > Double.parseDouble(protThreshold.getPh1())) {
+                if (Double.parseDouble(num) > Double.parseDouble(protThreshold.getPh1()) || Double.parseDouble(num) < Double.parseDouble(protThreshold.getOther2())) {
                     ProtWarningInfo protWarningInfo = new ProtWarningInfo();
                     protWarningInfo.setWarningContent("进污口ph值为" + num + "达到橙色预警");
                     protWarningInfo.setWarningType(1);
@@ -203,11 +201,25 @@ public class ProtTimer {
                     protWarningInfo.setBuildLocation("进污口");
                     warningInfoMapper.insert(protWarningInfo);
                 }
+
             }
             if (i == 2) {
+                String num1 = NumberUtils.getNum(0, 310,0);//cod
+                String num2 = NumberUtils.getNumFloat(0.0, 35.0);//nh3n
+                String num3 = NumberUtils.getNumFloat(0.0, 4.0);//tp
+                String num4 = NumberUtils.getNum(0, 32, 0);//tn
+                String num5 = NumberUtils.getNum(0, 55, 0);//flow
+
+                protData.setCod(num1);
+                protData.setNh3n(num2);
+                protData.setTp(num3);
+                protData.setTn(num4);
+                protData.setFlow(num5);
+                protDataMapper.insert(protData);
+
                 queryWrapper.eq("farm_id", 21).eq("prot_type", 2);
                 ProtThreshold protThreshold = protThresholdMapper.selectOne(queryWrapper);//污口
-                if (Double.parseDouble(num) > Double.parseDouble(protThreshold.getPh2())) {
+                if (Double.parseDouble(num) > Double.parseDouble(protThreshold.getPh2()) || Double.parseDouble(num) < Double.parseDouble(protThreshold.getOther3())) {
                     ProtWarningInfo protWarningInfo = new ProtWarningInfo();
                     protWarningInfo.setWarningContent("处理口ph值为" + num + "达到红色预警");
                     protWarningInfo.setWarningType(1);
@@ -219,7 +231,7 @@ public class ProtTimer {
                     protWarningInfo.setBuildLocation("处理口");
                     warningInfoMapper.insert(protWarningInfo);
                 }
-                if (Double.parseDouble(num) > Double.parseDouble(protThreshold.getPh1())) {
+                if (Double.parseDouble(num) > Double.parseDouble(protThreshold.getPh1()) || Double.parseDouble(num) < Double.parseDouble(protThreshold.getOther2())) {
                     ProtWarningInfo protWarningInfo = new ProtWarningInfo();
                     protWarningInfo.setWarningContent("处理口ph值为" + num + "达到橙色预警");
                     protWarningInfo.setWarningType(1);
@@ -255,7 +267,7 @@ public class ProtTimer {
                     protWarningInfo.setBuildLocation("处理口");
                     warningInfoMapper.insert(protWarningInfo);
                 }
-                if (Double.parseDouble(num2) > Double.parseDouble(protThreshold.getNh3n2())) {
+                if (Double.parseDouble(num2) < Double.parseDouble(protThreshold.getNh3n2())) {
                     ProtWarningInfo protWarningInfo = new ProtWarningInfo();
                     protWarningInfo.setWarningContent("处理口NH3N值为" + num2 + "达到红色预警");
                     protWarningInfo.setWarningType(2);
@@ -267,7 +279,7 @@ public class ProtTimer {
                     protWarningInfo.setBuildLocation("处理口");
                     warningInfoMapper.insert(protWarningInfo);
                 }
-                if (Double.parseDouble(num2) > Double.parseDouble(protThreshold.getNh3n1())) {
+                if (Double.parseDouble(num2) < Double.parseDouble(protThreshold.getNh3n1())) {
                     ProtWarningInfo protWarningInfo = new ProtWarningInfo();
                     protWarningInfo.setWarningContent("处理口NH3N值为" + num2 + "达到橙色预警");
                     protWarningInfo.setWarningType(2);
@@ -354,9 +366,27 @@ public class ProtTimer {
 
             }
             if (i == 3) {
+                //排污口专用数据
+                String ph = NumberUtils.getNumFloat(6.6, 8.4);//ph
+                String cod = NumberUtils.getNum(0, 380, 0);//cod
+                String nh3n = NumberUtils.getNum(0, 50, 1);//nh3n
+                String tp = NumberUtils.getNumFloat(0.0, 10.0);//tp
+                String tn = NumberUtils.getNum(0, 150, 1);//tn
+                String flow = NumberUtils.getNum(0, 100, 1);//flow
+
+                protData.setPh(ph);
+                protData.setFlow(flow);
+                protData.setTp(tp);
+                protData.setTn(tn);
+                protData.setCod(cod);
+                protData.setNh3n(nh3n);
+
+                protDataMapper.insert(protData);
+
+
                 queryWrapper.eq("farm_id", 21).eq("prot_type", 3);
                 ProtThreshold protThreshold = protThresholdMapper.selectOne(queryWrapper);//进污口
-                if (Double.parseDouble(ph) > Double.parseDouble(protThreshold.getPh2())) {
+                if (Double.parseDouble(ph) > Double.parseDouble(protThreshold.getPh2()) || Double.parseDouble(ph) < Double.parseDouble(protThreshold.getOther3())) {
                     ProtWarningInfo protWarningInfo = new ProtWarningInfo();
                     protWarningInfo.setWarningContent("排污口ph值为" + ph + "达到红色预警");
                     protWarningInfo.setWarningType(1);
@@ -368,7 +398,7 @@ public class ProtTimer {
                     protWarningInfo.setBuildLocation("排污口");
                     warningInfoMapper.insert(protWarningInfo);
                 }
-                if (Double.parseDouble(ph) > Double.parseDouble(protThreshold.getPh1())) {
+                if (Double.parseDouble(ph) > Double.parseDouble(protThreshold.getPh1()) || Double.parseDouble(ph) < Double.parseDouble(protThreshold.getOther2())) {
                     ProtWarningInfo protWarningInfo = new ProtWarningInfo();
                     protWarningInfo.setWarningContent("排污口ph值为" + ph + "达到橙色预警");
                     protWarningInfo.setWarningType(1);