Ver Fonte

生成数据修改

wwh há 2 anos atrás
pai
commit
915ff4c3b5

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

@@ -25,4 +25,15 @@ public class NumberUtils {
         }
         return  result+"";
     }
+
+    // 是小数位数
+    public static String getNumFloat(Double min, Double max) {
+        double v = Math.random() * (max - min) + min;
+        DecimalFormat df = new DecimalFormat("0.0000");
+        return df.format(v);
+    }
+
+    public static void main(String[] args) {
+        System.out.println(getNumFloat(0.00, 0.006));
+    }
 }

+ 9 - 9
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.getNum(10, 20, 1);//NH3N
-            String jlm = NumberUtils.getNum(10, 20, 1);//jlm
-            String elht = NumberUtils.getNum(10, 20, 1);//elht
-            String ejel = NumberUtils.getNum(10, 20, 1);//ejel
-            String h2s = NumberUtils.getNum(10, 20, 1);//h2s
-            String byx = NumberUtils.getNum(10, 20, 1);//byx
-            String ch3 = NumberUtils.getNum(10, 20, 1);//ch3
-            String sja = NumberUtils.getNum(10, 20, 1);//sja
-            String cq = NumberUtils.getNum(10, 20, 1);//cq
+            String nh3n = NumberUtils.getNumFloat(0.04, 0.051);//NH3N
+            String jlm = NumberUtils.getNumFloat(0.05, 0.071);//jlm
+            String elht = NumberUtils.getNumFloat(2.00, 2.501);//elht
+            String ejel = NumberUtils.getNumFloat(0.04, 0.051);//ejel
+            String h2s = NumberUtils.getNumFloat(0.04, 0.051);//h2s
+            String byx = NumberUtils.getNumFloat(4.0, 4.501);//byx
+            String ch3 = NumberUtils.getNumFloat(0.005, 0.0062);//ch3
+            String sja = NumberUtils.getNumFloat(0.05, 0.071);//sja
+            String cq = NumberUtils.getNumFloat(15.0, 18.01);//cq
 
             GasData gasData = new GasData();
             gasData.setLoctionType(i);

+ 51 - 29
huimv-admin/src/main/java/com/huimv/admin/timer/ProtTimer.java

@@ -34,17 +34,17 @@ public class ProtTimer {
     @Scheduled(cron = "0 0 */1 * * ? ")
     private void getShenChan() throws Exception {
 
-        String num6 = NumberUtils.getNum(1, 4, 0);//loc_type
+
 
         for (int i = 1; i < 4; i++) {
 
             //假设已经拿到了数据
-            String num = NumberUtils.getNum(1, 14, 1);//ph
-            String num1 = NumberUtils.getNum(30, 60, 1);//cod
-            String num2 = NumberUtils.getNum(15, 35, 1);//nh3n
-            String num3 = NumberUtils.getNum(65, 85, 1);//tp
-            String num4 = NumberUtils.getNum(65, 85, 1);//tn
-            String num5 = NumberUtils.getNum(90, 210, 0);//flow
+            String num = NumberUtils.getNumFloat(5.0,6.1);//ph
+            String num1 = NumberUtils.getNum(350, 381, 1);//cod
+            String num2 = NumberUtils.getNum(55, 61, 1);//nh3n
+            String num3 = NumberUtils.getNumFloat(5.0, 6.51);//tp
+            String num4 = NumberUtils.getNum(7800, 8001, 1);//tn
+            String num5 = NumberUtils.getNum(290, 301, 1);//flow
 
 
             ProtData protData = new ProtData();
@@ -73,7 +73,8 @@ public class ProtTimer {
                     protWarningInfo.setDeviceId(i);
                     protWarningInfo.setBuildLocation("进污口");
                     warningInfoMapper.insert(protWarningInfo);
-                } else if (Double.parseDouble(num) > Double.parseDouble(protThreshold.getPh1())) {
+                }
+                if (Double.parseDouble(num) > Double.parseDouble(protThreshold.getPh1())) {
                     ProtWarningInfo protWarningInfo = new ProtWarningInfo();
                     protWarningInfo.setWarningContent("进污口ph值为" + num + "达到橙色预警");
                     protWarningInfo.setWarningType(1);
@@ -83,7 +84,8 @@ public class ProtTimer {
                     protWarningInfo.setDeviceId(i);
                     protWarningInfo.setBuildLocation("进污口");
                     warningInfoMapper.insert(protWarningInfo);
-                } else if (Double.parseDouble(num1) > Double.parseDouble(protThreshold.getCod2())) {
+                }
+                if (Double.parseDouble(num1) > Double.parseDouble(protThreshold.getCod2())) {
                     ProtWarningInfo protWarningInfo = new ProtWarningInfo();
                     protWarningInfo.setWarningContent("进污口cod值为" + num1 + "达到红色预警");
                     protWarningInfo.setWarningType(0);
@@ -93,7 +95,8 @@ public class ProtTimer {
                     protWarningInfo.setDeviceId(i);
                     protWarningInfo.setBuildLocation("进污口");
                     warningInfoMapper.insert(protWarningInfo);
-                } else if (Double.parseDouble(num1) > Double.parseDouble(protThreshold.getCod1())) {
+                }
+                if (Double.parseDouble(num1) > Double.parseDouble(protThreshold.getCod1())) {
                     ProtWarningInfo protWarningInfo = new ProtWarningInfo();
                     protWarningInfo.setWarningContent("进污口cod值为" + num1 + "达到橙色预警");
                     protWarningInfo.setWarningType(0);
@@ -103,7 +106,8 @@ public class ProtTimer {
                     protWarningInfo.setDeviceId(i);
                     protWarningInfo.setBuildLocation("进污口");
                     warningInfoMapper.insert(protWarningInfo);
-                } else 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);
@@ -113,7 +117,8 @@ public class ProtTimer {
                     protWarningInfo.setDeviceId(i);
                     protWarningInfo.setBuildLocation("进污口");
                     warningInfoMapper.insert(protWarningInfo);
-                } else 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);
@@ -123,7 +128,8 @@ public class ProtTimer {
                     protWarningInfo.setDeviceId(i);
                     protWarningInfo.setBuildLocation("进污口");
                     warningInfoMapper.insert(protWarningInfo);
-                } else if (Double.parseDouble(num3) > Double.parseDouble(protThreshold.getTp2())) {
+                }
+                if (Double.parseDouble(num3) > Double.parseDouble(protThreshold.getTp2())) {
                     ProtWarningInfo protWarningInfo = new ProtWarningInfo();
                     protWarningInfo.setWarningContent("进污口TP值为" + num3 + "达到红色预警");
                     protWarningInfo.setWarningType(3);
@@ -133,7 +139,8 @@ public class ProtTimer {
                     protWarningInfo.setDeviceId(i);
                     protWarningInfo.setBuildLocation("进污口");
                     warningInfoMapper.insert(protWarningInfo);
-                } else if (Double.parseDouble(num3) > Double.parseDouble(protThreshold.getTp1())) {
+                }
+                if (Double.parseDouble(num3) > Double.parseDouble(protThreshold.getTp1())) {
                     ProtWarningInfo protWarningInfo = new ProtWarningInfo();
                     protWarningInfo.setWarningContent("进污口TP值为" + num3 + "达到橙色预警");
                     protWarningInfo.setWarningType(3);
@@ -143,7 +150,8 @@ public class ProtTimer {
                     protWarningInfo.setDeviceId(i);
                     protWarningInfo.setBuildLocation("进污口");
                     warningInfoMapper.insert(protWarningInfo);
-                } else if (Double.parseDouble(num4) > Double.parseDouble(protThreshold.getTn2())) {
+                }
+                if (Double.parseDouble(num4) > Double.parseDouble(protThreshold.getTn2())) {
                     ProtWarningInfo protWarningInfo = new ProtWarningInfo();
                     protWarningInfo.setWarningContent("进污口TN值为" + num4 + "达到红色预警");
                     protWarningInfo.setWarningType(4);
@@ -153,7 +161,8 @@ public class ProtTimer {
                     protWarningInfo.setDeviceId(i);
                     protWarningInfo.setBuildLocation("进污口");
                     warningInfoMapper.insert(protWarningInfo);
-                } else if (Double.parseDouble(num4) > Double.parseDouble(protThreshold.getTn1())) {
+                }
+                if (Double.parseDouble(num4) > Double.parseDouble(protThreshold.getTn1())) {
                     ProtWarningInfo protWarningInfo = new ProtWarningInfo();
                     protWarningInfo.setWarningContent("进污口TN值为" + num4 + "达到橙色预警");
                     protWarningInfo.setWarningType(4);
@@ -163,7 +172,8 @@ public class ProtTimer {
                     protWarningInfo.setDeviceId(i);
                     protWarningInfo.setBuildLocation("进污口");
                     warningInfoMapper.insert(protWarningInfo);
-                } else if (Double.parseDouble(num5) > Double.parseDouble(protThreshold.getFlow2())) {
+                }
+                if (Double.parseDouble(num5) > Double.parseDouble(protThreshold.getFlow2())) {
                     ProtWarningInfo protWarningInfo = new ProtWarningInfo();
                     protWarningInfo.setWarningContent("进污口累计流量值为" + num5 + "达到红色预警");
                     protWarningInfo.setWarningType(5);
@@ -173,7 +183,8 @@ public class ProtTimer {
                     protWarningInfo.setDeviceId(i);
                     protWarningInfo.setBuildLocation("进污口");
                     warningInfoMapper.insert(protWarningInfo);
-                } else if (Double.parseDouble(num5) > Double.parseDouble(protThreshold.getFlow1())) {
+                }
+                if (Double.parseDouble(num5) > Double.parseDouble(protThreshold.getFlow1())) {
                     ProtWarningInfo protWarningInfo = new ProtWarningInfo();
                     protWarningInfo.setWarningContent("进污口累计流量值为" + num5 + "达到橙色预警");
                     protWarningInfo.setWarningType(5);
@@ -348,7 +359,8 @@ public class ProtTimer {
                     protWarningInfo.setDeviceId(i);
                     protWarningInfo.setBuildLocation("排污口");
                     warningInfoMapper.insert(protWarningInfo);
-                } else if (Double.parseDouble(num) > Double.parseDouble(protThreshold.getPh1())) {
+                }
+                if (Double.parseDouble(num) > Double.parseDouble(protThreshold.getPh1())) {
                     ProtWarningInfo protWarningInfo = new ProtWarningInfo();
                     protWarningInfo.setWarningContent("排污口ph值为" + num + "达到橙色预警");
                     protWarningInfo.setWarningType(1);
@@ -359,7 +371,8 @@ public class ProtTimer {
                     protWarningInfo.setDeviceId(i);
                     protWarningInfo.setBuildLocation("排污口");
                     warningInfoMapper.insert(protWarningInfo);
-                } else if (Double.parseDouble(num1) > Double.parseDouble(protThreshold.getCod2())) {
+                }
+                if (Double.parseDouble(num1) > Double.parseDouble(protThreshold.getCod2())) {
                     ProtWarningInfo protWarningInfo = new ProtWarningInfo();
                     protWarningInfo.setWarningContent("排污口cod值为" + num1 + "达到红色预警");
                     protWarningInfo.setWarningType(0);
@@ -370,7 +383,8 @@ public class ProtTimer {
                     protWarningInfo.setDeviceId(i);
                     protWarningInfo.setBuildLocation("排污口");
                     warningInfoMapper.insert(protWarningInfo);
-                } else if (Double.parseDouble(num1) > Double.parseDouble(protThreshold.getCod1())) {
+                }
+                if (Double.parseDouble(num1) > Double.parseDouble(protThreshold.getCod1())) {
                     ProtWarningInfo protWarningInfo = new ProtWarningInfo();
                     protWarningInfo.setWarningContent("排污口cod值为" + num1 + "达到橙色预警");
                     protWarningInfo.setWarningType(0);
@@ -381,7 +395,8 @@ public class ProtTimer {
                     protWarningInfo.setDeviceId(i);
                     protWarningInfo.setBuildLocation("排污口");
                     warningInfoMapper.insert(protWarningInfo);
-                } else 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);
@@ -392,7 +407,8 @@ public class ProtTimer {
                     protWarningInfo.setDeviceId(i);
                     protWarningInfo.setBuildLocation("排污口");
                     warningInfoMapper.insert(protWarningInfo);
-                } else 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);
@@ -403,7 +419,8 @@ public class ProtTimer {
                     protWarningInfo.setDeviceId(i);
                     protWarningInfo.setBuildLocation("排污口");
                     warningInfoMapper.insert(protWarningInfo);
-                } else if (Double.parseDouble(num3) > Double.parseDouble(protThreshold.getTp2())) {
+                }
+                if (Double.parseDouble(num3) > Double.parseDouble(protThreshold.getTp2())) {
                     ProtWarningInfo protWarningInfo = new ProtWarningInfo();
                     protWarningInfo.setWarningContent("排污口TP值为" + num3 + "达到红色预警");
                     protWarningInfo.setWarningType(3);
@@ -414,7 +431,8 @@ public class ProtTimer {
                     protWarningInfo.setDeviceId(i);
                     protWarningInfo.setBuildLocation("排污口");
                     warningInfoMapper.insert(protWarningInfo);
-                } else if (Double.parseDouble(num3) > Double.parseDouble(protThreshold.getTp1())) {
+                }
+                if (Double.parseDouble(num3) > Double.parseDouble(protThreshold.getTp1())) {
                     ProtWarningInfo protWarningInfo = new ProtWarningInfo();
                     protWarningInfo.setWarningContent("排污口TP值为" + num3 + "达到橙色预警");
                     protWarningInfo.setWarningType(3);
@@ -425,7 +443,8 @@ public class ProtTimer {
                     protWarningInfo.setDeviceId(i);
                     protWarningInfo.setBuildLocation("排污口");
                     warningInfoMapper.insert(protWarningInfo);
-                } else if (Double.parseDouble(num4) > Double.parseDouble(protThreshold.getTn2())) {
+                }
+                if (Double.parseDouble(num4) > Double.parseDouble(protThreshold.getTn2())) {
                     ProtWarningInfo protWarningInfo = new ProtWarningInfo();
                     protWarningInfo.setWarningContent("排污口TN值为" + num4 + "达到红色预警");
                     protWarningInfo.setWarningType(4);
@@ -436,7 +455,8 @@ public class ProtTimer {
                     protWarningInfo.setDeviceId(i);
                     protWarningInfo.setBuildLocation("排污口");
                     warningInfoMapper.insert(protWarningInfo);
-                } else if (Double.parseDouble(num4) > Double.parseDouble(protThreshold.getTn1())) {
+                }
+                if (Double.parseDouble(num4) > Double.parseDouble(protThreshold.getTn1())) {
                     ProtWarningInfo protWarningInfo = new ProtWarningInfo();
                     protWarningInfo.setWarningContent("排污口TN值为" + num4 + "达到橙色预警");
                     protWarningInfo.setWarningType(4);
@@ -447,7 +467,8 @@ public class ProtTimer {
                     protWarningInfo.setDeviceId(i);
                     protWarningInfo.setBuildLocation("排污口");
                     warningInfoMapper.insert(protWarningInfo);
-                } else if (Double.parseDouble(num5) > Double.parseDouble(protThreshold.getFlow2())) {
+                }
+                if (Double.parseDouble(num5) > Double.parseDouble(protThreshold.getFlow2())) {
                     ProtWarningInfo protWarningInfo = new ProtWarningInfo();
                     protWarningInfo.setWarningContent("排污口累计流量值为" + num5 + "达到红色预警");
                     protWarningInfo.setWarningType(5);
@@ -458,7 +479,8 @@ public class ProtTimer {
                     protWarningInfo.setDeviceId(i);
                     protWarningInfo.setBuildLocation("排污口");
                     warningInfoMapper.insert(protWarningInfo);
-                } else if (Double.parseDouble(num5) > Double.parseDouble(protThreshold.getFlow1())) {
+                }
+                if (Double.parseDouble(num5) > Double.parseDouble(protThreshold.getFlow1())) {
                     ProtWarningInfo protWarningInfo = new ProtWarningInfo();
                     protWarningInfo.setWarningContent("排污口累计流量值为" + num5 + "达到橙色预警");
                     protWarningInfo.setWarningType(5);