Ver código fonte

测温代码修改

hanqingsong 4 anos atrás
pai
commit
10e916f192

+ 44 - 46
src/main/java/com/chinaitop/depot/intelligent/pushs/service/impl/GrainPushsServiceImpl.java

@@ -95,7 +95,7 @@ public class GrainPushsServiceImpl implements GrainPushsService {
95
                 }
95
                 }
96
                 String orgId = temperatureRecordService.getOrgId(cDcsCodes.get(0));
96
                 String orgId = temperatureRecordService.getOrgId(cDcsCodes.get(0));
97
                 ts.forEach(obj -> {
97
                 ts.forEach(obj -> {
98
-                    String testdataId = uuidUtils.getCodeId(orgId, "t_testdata");
98
+                    String testdataId = UuidUtils.getCode();
99
                     TTestdata tTestdata = (TTestdata) obj;
99
                     TTestdata tTestdata = (TTestdata) obj;
100
                     String house = tTestdata.getStorehouse();
100
                     String house = tTestdata.getStorehouse();
101
                     Date time = tTestdata.getTime();
101
                     Date time = tTestdata.getTime();
@@ -105,12 +105,14 @@ public class GrainPushsServiceImpl implements GrainPushsService {
105
                     //获取报警阈值信息6972测温 6983温度高限 6982温度底限 6991温度预警
105
                     //获取报警阈值信息6972测温 6983温度高限 6982温度底限 6991温度预警
106
                     TWarningThreshold threshold = null; //温度高限
106
                     TWarningThreshold threshold = null; //温度高限
107
                     TWarningThreshold wLowest = null; //温度底限
107
                     TWarningThreshold wLowest = null; //温度底限
108
-                    TWarningThreshold wWarning = null; //温度预警
108
+                    TWarningThreshold thresholdWarning = null; //低温温度预警
109
+                    TWarningThreshold wLowestWarning = null; //低温温度预警
109
                     String ilqYq = tTestdata.getIlqYq();
110
                     String ilqYq = tTestdata.getIlqYq();
110
                     if (ilqYq.equals("0")) {
111
                     if (ilqYq.equals("0")) {
111
-                        threshold = warningThresholdService.getByCfCodeAndwName(house, 0, "6972", "6983");
112
-                        wLowest = warningThresholdService.getByCfCodeAndwName(house, 0, "6972", "6982");
113
-                        wWarning = warningThresholdService.getByCfCodeAndwName(house, 0, "6972", "6991");
112
+                        threshold = warningThresholdService.getByCfCodeAndwName(house, 0, "6972", "6983");//获取高温报警阀值
113
+                        wLowest = warningThresholdService.getByCfCodeAndwName(house, 0, "6972", "6982");//获取低温报警阀值
114
+                        thresholdWarning = warningThresholdService.getByCfCodeAndwName(house, 0, "6972", "6991");//获取高温预警
115
+                        wLowestWarning = warningThresholdService.getByCfCodeAndwName(house, 0, "6972", "7248");//低温温度预警
114
 
116
 
115
                     }
117
                     }
116
                     BigDecimal wholeSum = ps.stream().filter(TPoints -> !TPoints.getTemp().equals(new BigDecimal("250.0"))).map(TPoints::getTemp).reduce(BigDecimal.ZERO, BigDecimal::add);
118
                     BigDecimal wholeSum = ps.stream().filter(TPoints -> !TPoints.getTemp().equals(new BigDecimal("250.0"))).map(TPoints::getTemp).reduce(BigDecimal.ZERO, BigDecimal::add);
@@ -139,22 +141,21 @@ public class GrainPushsServiceImpl implements GrainPushsService {
139
                         //用于判断是否已经报警
141
                         //用于判断是否已经报警
140
                         boolean temp = false;
142
                         boolean temp = false;
141
                         BigDecimal wh = threshold.getThreshold();
143
                         BigDecimal wh = threshold.getThreshold();
142
-                        //-1 小于 0 等于 1 大于
144
+                        //-1 小于 0 等于 1 大于 高温报警
143
                         if (wholeMax.compareTo(wh) == 1 && !wholeMax.toString().equals("250.0") && ilqYq.equals("0")) {
145
                         if (wholeMax.compareTo(wh) == 1 && !wholeMax.toString().equals("250.0") && ilqYq.equals("0")) {
144
-                            String tid = uuidUtils.getCodeId(orgId, "t_warning_threshold_history");
146
+                            String tid = UuidUtils.getCode();
145
                             String desc = "整仓粮温(" + wholeMax + ")高于阈值(" + wh + ")";
147
                             String desc = "整仓粮温(" + wholeMax + ")高于阈值(" + wh + ")";
146
                             TWarningThresholdHistory tt = warningMessage.saveWThreshold(tid, house, threshold, wholeMax, wh, time, desc, dataSource2, "0", "0");
148
                             TWarningThresholdHistory tt = warningMessage.saveWThreshold(tid, house, threshold, wholeMax, wh, time, desc, dataSource2, "0", "0");
147
                             tWarningThresholdHistorieList.add(tt);
149
                             tWarningThresholdHistorieList.add(tt);
148
                             temp = true;
150
                             temp = true;
149
                         }
151
                         }
150
-                        if (wWarning != null && !temp && !wholeMax.toString().equals("250.0") && ilqYq.equals("0")) {
151
-                            //-1 小于 0 等于 1 大于
152
-                            BigDecimal ww = wWarning.getThreshold();
153
-                            BigDecimal subtract = wh.subtract(ww).setScale(2, RoundingMode.HALF_UP); //高温减去阈值
154
-                            if (wholeMax.compareTo(subtract) == 1 && ilqYq.equals("0")) {
155
-                                String tid = uuidUtils.getCodeId(orgId, "t_warning_threshold_history");
156
-                                String desc = "整仓粮温(" + wholeMax + ")高于阈值(" + subtract + ")";
157
-                                TWarningThresholdHistory tt = warningMessage.saveWThreshold(tid, house, wWarning, wholeMax, subtract, time, desc, dataSource2, "0", "1");
152
+                        if (thresholdWarning != null && !temp && !wholeMax.toString().equals("250.0") && ilqYq.equals("0")) {
153
+                            //-1 小于 0 等于 1 大于 高温预警
154
+                            BigDecimal ww = thresholdWarning.getThreshold();
155
+                            if (wholeMax.compareTo(ww) == 1 && ilqYq.equals("0")) {
156
+                                String tid = UuidUtils.getCode();
157
+                                String desc = "整仓粮温(" + wholeMax + ")高于阈值(" + ww + ")";
158
+                                TWarningThresholdHistory tt = warningMessage.saveWThreshold(tid, house, thresholdWarning, wholeMax, ww, time, desc, dataSource2, "0", "1");
158
                                 tWarningThresholdHistorieList.add(tt);
159
                                 tWarningThresholdHistorieList.add(tt);
159
                             }
160
                             }
160
                         }
161
                         }
@@ -163,22 +164,21 @@ public class GrainPushsServiceImpl implements GrainPushsService {
163
                         //用于判断是否已经报警
164
                         //用于判断是否已经报警
164
                         boolean temp = false;
165
                         boolean temp = false;
165
                         BigDecimal wl = wLowest.getThreshold().setScale(2, RoundingMode.HALF_UP);
166
                         BigDecimal wl = wLowest.getThreshold().setScale(2, RoundingMode.HALF_UP);
166
-                        //-1 小于 0 等于 1 大于
167
+                        //-1 小于 0 等于 1 大于 低温报警
167
                         if (wMin.compareTo(wl) == -1 && !wMin.toString().equals("250.0") && ilqYq.equals("0")) {
168
                         if (wMin.compareTo(wl) == -1 && !wMin.toString().equals("250.0") && ilqYq.equals("0")) {
168
-                            String tid = uuidUtils.getCodeId(orgId, "t_warning_threshold_history");
169
+                            String tid = UuidUtils.getCode();
169
                             String desc = "整仓粮温(" + wMin + ")低于阈值(" + wl + ")";
170
                             String desc = "整仓粮温(" + wMin + ")低于阈值(" + wl + ")";
170
                             TWarningThresholdHistory tt = warningMessage.saveWThreshold(tid, house, wLowest, wMin, wl, time, desc, dataSource2, "0", "0");
171
                             TWarningThresholdHistory tt = warningMessage.saveWThreshold(tid, house, wLowest, wMin, wl, time, desc, dataSource2, "0", "0");
171
                             tWarningThresholdHistorieList.add(tt);
172
                             tWarningThresholdHistorieList.add(tt);
172
                             temp = true;
173
                             temp = true;
173
                         }
174
                         }
174
-                        if (wWarning != null && !temp && !wMin.toString().equals("250.0") && ilqYq.equals("0")) {
175
-                            //-1 小于 0 等于 1 大于
176
-                            BigDecimal ww = wWarning.getThreshold();
177
-                            BigDecimal wadd = wl.add(ww);//高温减去阈值
178
-                            if (wMin.compareTo(wadd) == -1 && ilqYq.equals("0")) {
179
-                                String tid = uuidUtils.getCodeId(orgId, "t_warning_threshold_history");
180
-                                String desc = "整仓粮温(" + wMin + ")低于阈值(" + wadd + ")";
181
-                                TWarningThresholdHistory tt = warningMessage.saveWThreshold(tid, house, wWarning, wMin, wadd, time, desc, dataSource2, "0", "1");
175
+                        if (wLowestWarning != null && !temp && !wMin.toString().equals("250.0") && ilqYq.equals("0")) {
176
+                            //-1 小于 0 等于 1 大于 低温预警
177
+                            BigDecimal ww = wLowestWarning.getThreshold();
178
+                            if (wMin.compareTo(ww) == -1 && ilqYq.equals("0")) {
179
+                                String tid = UuidUtils.getCode();
180
+                                String desc = "整仓粮温(" + wMin + ")低于阈值(" + ww + ")";
181
+                                TWarningThresholdHistory tt = warningMessage.saveWThreshold(tid, house, wLowestWarning, wMin, ww, time, desc, dataSource2, "0", "1");
182
                                 tWarningThresholdHistorieList.add(tt);
182
                                 tWarningThresholdHistorieList.add(tt);
183
                             }
183
                             }
184
                         }
184
                         }
@@ -211,7 +211,7 @@ public class GrainPushsServiceImpl implements GrainPushsService {
211
                         tTestdataLayer.setLmin(lsyerMin);
211
                         tTestdataLayer.setLmin(lsyerMin);
212
                         tTestdataLayer.setLhouse(house);
212
                         tTestdataLayer.setLhouse(house);
213
                         tTestdataLayer.setLtime(time);
213
                         tTestdataLayer.setLtime(time);
214
-                        tTestdataLayer.setId(uuidUtils.getCodeId(orgId, "t_testdata_layer"));
214
+                        tTestdataLayer.setId(UuidUtils.getCode());
215
                         tTestdataLayer.setOrgId(orgId);
215
                         tTestdataLayer.setOrgId(orgId);
216
                         tTestdataLayer.setDataSource(dataSource2);
216
                         tTestdataLayer.setDataSource(dataSource2);
217
                         tTestdataLayer.setLqId(testdataId);
217
                         tTestdataLayer.setLqId(testdataId);
@@ -232,23 +232,22 @@ public class GrainPushsServiceImpl implements GrainPushsService {
232
                                     if (threshold != null && ilqYq.equals("0")) {
232
                                     if (threshold != null && ilqYq.equals("0")) {
233
                                         boolean temp = false;
233
                                         boolean temp = false;
234
                                         BigDecimal threshold1 = threshold.getThreshold().setScale(2, RoundingMode.HALF_UP);
234
                                         BigDecimal threshold1 = threshold.getThreshold().setScale(2, RoundingMode.HALF_UP);
235
-                                        //-1 小于 0 等于 1 大于
235
+                                        //-1 小于 0 等于 1 大于 高温报警
236
                                         if (te.compareTo(threshold1) == 1 && !te.toString().equals("250.0")) {
236
                                         if (te.compareTo(threshold1) == 1 && !te.toString().equals("250.0")) {
237
                                             // tid id,cfCdoe 仓房编码,threshold 报警实体包括orgID,tthreshold 检测值,wThreshold 预警或报警设置值,date 检测时间,desc 描述信息,mode 0测温,1测虫,2测气,warning 0报警,1预警
237
                                             // tid id,cfCdoe 仓房编码,threshold 报警实体包括orgID,tthreshold 检测值,wThreshold 预警或报警设置值,date 检测时间,desc 描述信息,mode 0测温,1测虫,2测气,warning 0报警,1预警
238
-                                            String tid = uuidUtils.getCodeId(orgId, "t_warning_threshold_history");
238
+                                            String tid = UuidUtils.getCode();
239
                                             String desc = "第" + keyL + "层,第" + keyR + "行,第" + keyC + "列粮温(" + te + ")高于阈值(" + threshold1 + ")";
239
                                             String desc = "第" + keyL + "层,第" + keyR + "行,第" + keyC + "列粮温(" + te + ")高于阈值(" + threshold1 + ")";
240
                                             TWarningThresholdHistory tt = warningMessage.saveWThreshold(tid, house, threshold, te, threshold1, time, desc, dataSource2, "0", "0");
240
                                             TWarningThresholdHistory tt = warningMessage.saveWThreshold(tid, house, threshold, te, threshold1, time, desc, dataSource2, "0", "0");
241
                                             tWarningThresholdHistorieList.add(tt);
241
                                             tWarningThresholdHistorieList.add(tt);
242
                                             temp = true;
242
                                             temp = true;
243
                                         }
243
                                         }
244
-                                        if (wWarning != null && !temp && !te.toString().equals("250.0")) {
245
-                                            //-1 小于 0 等于 1 大于
246
-                                            BigDecimal ww = wWarning.getThreshold();
247
-                                            BigDecimal subtract = threshold1.subtract(ww).setScale(2, RoundingMode.HALF_UP); //高温减去阈值
248
-                                            if (te.compareTo(subtract) == 1 && ilqYq.equals("0")) {
249
-                                                String tid = uuidUtils.getCodeId(orgId, "t_warning_threshold_history");
250
-                                                String desc = "第" + keyL + "层,第" + keyR + "行,第" + keyC + "列粮温(" + te + ")高于阈值(" + subtract + ")";
251
-                                                TWarningThresholdHistory tt = warningMessage.saveWThreshold(tid, house, wWarning, te, subtract, time, desc, dataSource2, "0", "1");
244
+                                        if (thresholdWarning != null && !temp && !te.toString().equals("250.0")) {
245
+                                            //-1 小于 0 等于 1 大于 高温预警
246
+                                            BigDecimal ww = thresholdWarning.getThreshold();
247
+                                            if (te.compareTo(ww) == 1 && ilqYq.equals("0")) {
248
+                                                String tid = UuidUtils.getCode();
249
+                                                String desc = "第" + keyL + "层,第" + keyR + "行,第" + keyC + "列粮温(" + te + ")高于阈值(" + ww + ")";
250
+                                                TWarningThresholdHistory tt = warningMessage.saveWThreshold(tid, house, thresholdWarning, te, ww, time, desc, dataSource2, "0", "1");
252
                                                 tWarningThresholdHistorieList.add(tt);
251
                                                 tWarningThresholdHistorieList.add(tt);
253
                                             }
252
                                             }
254
                                         }
253
                                         }
@@ -256,22 +255,21 @@ public class GrainPushsServiceImpl implements GrainPushsService {
256
                                     if (wLowest != null && ilqYq.equals("0")) {
255
                                     if (wLowest != null && ilqYq.equals("0")) {
257
                                         boolean temp = false;
256
                                         boolean temp = false;
258
                                         BigDecimal wl = wLowest.getThreshold().setScale(2, RoundingMode.HALF_UP);
257
                                         BigDecimal wl = wLowest.getThreshold().setScale(2, RoundingMode.HALF_UP);
259
-                                        //-1 小于 0 等于 1 大于
258
+                                        //-1 小于 0 等于 1 大于 低温报警
260
                                         if (te.compareTo(wl) == -1 && !te.toString().equals("250.0")) {
259
                                         if (te.compareTo(wl) == -1 && !te.toString().equals("250.0")) {
261
-                                            String tid = uuidUtils.getCodeId(orgId, "t_warning_threshold_history");
260
+                                            String tid = UuidUtils.getCode();
262
                                             String desc = "第" + keyL + "层,第" + keyR + "行,第" + keyC + "列粮温(" + te + ")低于阈值(" + wl + ")";
261
                                             String desc = "第" + keyL + "层,第" + keyR + "行,第" + keyC + "列粮温(" + te + ")低于阈值(" + wl + ")";
263
                                             TWarningThresholdHistory tt = warningMessage.saveWThreshold(tid, house, wLowest, te, wl, time, desc, dataSource2, "0", "0");
262
                                             TWarningThresholdHistory tt = warningMessage.saveWThreshold(tid, house, wLowest, te, wl, time, desc, dataSource2, "0", "0");
264
                                             tWarningThresholdHistorieList.add(tt);
263
                                             tWarningThresholdHistorieList.add(tt);
265
                                             temp = true;
264
                                             temp = true;
266
                                         }
265
                                         }
267
-                                        if (wWarning != null && !temp && !te.toString().equals("250.0")) {
268
-                                            //-1 小于 0 等于 1 大于
269
-                                            BigDecimal ww = wWarning.getThreshold();
270
-                                            BigDecimal wadd = wl.add(ww).setScale(2, RoundingMode.HALF_UP);//高温减去阈值
271
-                                            if (te.compareTo(wadd) == -1 && ilqYq.equals("0")) {
272
-                                                String tid = uuidUtils.getCodeId(orgId, "t_warning_threshold_history");
273
-                                                String desc = "第" + keyL + "层,第" + keyR + "行,第" + keyC + "列粮温(" + te + ")低于阈值(" + wadd + ")";
274
-                                                TWarningThresholdHistory tt = warningMessage.saveWThreshold(tid, house, wWarning, te, wadd, time, desc, dataSource2, "0", "1");
266
+                                        if (wLowestWarning != null && !temp && !te.toString().equals("250.0")) {
267
+                                            //-1 小于 0 等于 1 大于 低温预警
268
+                                            BigDecimal ww = wLowestWarning.getThreshold();
269
+                                            if (te.compareTo(ww) == -1 && ilqYq.equals("0")) {
270
+                                                String tid = UuidUtils.getCode();
271
+                                                String desc = "第" + keyL + "层,第" + keyR + "行,第" + keyC + "列粮温(" + te + ")低于阈值(" + ww + ")";
272
+                                                TWarningThresholdHistory tt = warningMessage.saveWThreshold(tid, house, wLowestWarning, te, ww, time, desc, dataSource2, "0", "1");
275
                                                 tWarningThresholdHistorieList.add(tt);
273
                                                 tWarningThresholdHistorieList.add(tt);
276
                                             }
274
                                             }
277
                                         }
275
                                         }