Browse Source

多线程优化,小时均值修改

zjs 2 days ago
parent
commit
124794c68e

+ 1 - 1
src/main/java/com/cn/esermis/dpld/business/MonitorBusiness.java

@@ -79,7 +79,7 @@ public class MonitorBusiness {
79
         List<CP> cp = factorModel.getCP();
79
         List<CP> cp = factorModel.getCP();
80
         log.info("入库数据:{}", msg);
80
         log.info("入库数据:{}", msg);
81
         try {
81
         try {
82
-            if (factorModel.getST().equals(Constant.ST_AIR)) {
82
+            if (!cp.isEmpty() && factorModel.getST().equals(Constant.ST_AIR)) {
83
                 // 气体检测
83
                 // 气体检测
84
                 if (factorModel.getCN().equals(Constant.MINUTE)) {
84
                 if (factorModel.getCN().equals(Constant.MINUTE)) {
85
                     // 分钟数据入库
85
                     // 分钟数据入库

+ 20 - 20
src/main/java/com/cn/esermis/server/Consumer.java

@@ -59,26 +59,26 @@ public class Consumer {
59
             } else {
59
             } else {
60
                 tolot++;
60
                 tolot++;
61
                 int finalTolot = tolot;
61
                 int finalTolot = tolot;
62
-                Object mge = redisQueueService.receiveMessage(Constant.SERVER);
63
-                try {
64
-                    System.out.println("消费消息------------:第(" + finalTolot + ")条");
65
-                    JSONObject jsonObject = (JSONObject) JSON.toJSON(mge);
66
-                    monitorBusiness.inboundOperations(jsonObject);
67
-                } catch (Exception e) {
68
-                    redisQueueService.sendMessage(Constant.RECEIVEREPEAT, mge);
69
-                    Thread.currentThread().interrupt();
70
-                }
71
-//                executor.submit(() -> {
72
-//                    Object mge = redisQueueService.receiveMessage(Constant.SERVER);
73
-//                    try {
74
-//                        System.out.println("消费消息------------:第(" + finalTolot + ")条");
75
-//                        JSONObject jsonObject = (JSONObject) JSON.toJSON(mge);
76
-//                        monitorBusiness.inboundOperations(jsonObject);
77
-//                    } catch (Exception e) {
78
-//                        redisQueueService.sendMessage(Constant.RECEIVEREPEAT, mge);
79
-//                        Thread.currentThread().interrupt();
80
-//                    }
81
-//                });
62
+//                Object mge = redisQueueService.receiveMessage(Constant.SERVER);
63
+//                try {
64
+//                    System.out.println("消费消息------------:第(" + finalTolot + ")条");
65
+//                    JSONObject jsonObject = (JSONObject) JSON.toJSON(mge);
66
+//                    monitorBusiness.inboundOperations(jsonObject);
67
+//                } catch (Exception e) {
68
+//                    redisQueueService.sendMessage(Constant.RECEIVEREPEAT, mge);
69
+//                    Thread.currentThread().interrupt();
70
+//                }
71
+                executor.submit(() -> {
72
+                    Object mge = redisQueueService.receiveMessage(Constant.SERVER);
73
+                    try {
74
+                        System.out.println("消费消息------------:第(" + finalTolot + ")条");
75
+                        JSONObject jsonObject = (JSONObject) JSON.toJSON(mge);
76
+                        monitorBusiness.inboundOperations(jsonObject);
77
+                    } catch (Exception e) {
78
+                        redisQueueService.sendMessage(Constant.RECEIVEREPEAT, mge);
79
+                        Thread.currentThread().interrupt();
80
+                    }
81
+                });
82
             }
82
             }
83
         }
83
         }
84
 
84
 

+ 1 - 1
src/main/resources/static/mybatis/DataAcquisitionInstrumentMapper.xml

@@ -9,7 +9,7 @@
9
                a.outlet_code outletCode,
9
                a.outlet_code outletCode,
10
                c.factor `factor`,
10
                c.factor `factor`,
11
                a.mn_code `mnCode`,
11
                a.mn_code `mnCode`,
12
-               c.range_str `range`,
12
+               c.hours_avg `range`,
13
                a.company_code `companyCode`,
13
                a.company_code `companyCode`,
14
                a.department_code `departmentCode`
14
                a.department_code `departmentCode`
15
         from data_acquisition_instrument a
15
         from data_acquisition_instrument a