Selaa lähdekoodia

feat:新增湿度报警数据入库

aihua 3 vuotta sitten
vanhempi
commit
36bc342dd6

+ 59 - 1
src/main/java/com/chinaitop/depot/intelligent/pushs/service/impl/GrainPushsServiceImpl.java

@@ -74,7 +74,7 @@ public class GrainPushsServiceImpl implements GrainPushsService {
74 74
                 ArrayList<TTestdata> tTestdataList = Lists.newArrayList();
75 75
                 //粮温每层数据
76 76
                 ArrayList<TTestdataLayer> tTestdataLayerArrayList = Lists.newArrayList();
77
-                //报警数据
77
+                // 温度报警数据 和 湿度报警数据
78 78
                 ArrayList<TWarningThresholdHistory> tWarningThresholdHistorieList = Lists.newArrayList();
79 79
 
80 80
                 String replace = grainTemperatureData.replace("\"Y\"", "\"y\"").replace("\"X\"", "\"x\"").replace("\"Z\"", "\"z\"");
@@ -105,12 +105,20 @@ public class GrainPushsServiceImpl implements GrainPushsService {
105 105
                     TWarningThreshold threshold = null; //温度高限
106 106
                     TWarningThreshold wLowest = null; //温度底限
107 107
                     TWarningThreshold wWarning = null; //温度预警
108
+
109
+                    // 获取报警阈值信息7252 测湿 7253湿度高限 7254湿度低限 7509湿度预警
110
+                    TWarningThreshold thresholdHumidity = null; //湿度高限
111
+                    TWarningThreshold wLowestHumidity = null; //湿度底限
112
+                    TWarningThreshold wWarningHumidity = null; //湿度预警
108 113
                     String ilqYq = tTestdata.getIlqYq();
109 114
                     if (ilqYq.equals("0")) {
110 115
                         threshold = warningThresholdService.getByCfCodeAndwName(house, 0, "6972", "6983");
111 116
                         wLowest = warningThresholdService.getByCfCodeAndwName(house, 0, "6972", "6982");
112 117
                         wWarning = warningThresholdService.getByCfCodeAndwName(house, 0, "6972", "6991");
113 118
 
119
+                        thresholdHumidity = warningThresholdService.getByCfCodeAndwName(house, 0, "7252", "7253");
120
+                        wLowestHumidity = warningThresholdService.getByCfCodeAndwName(house, 0, "7252", "7254");
121
+                        wWarningHumidity = warningThresholdService.getByCfCodeAndwName(house, 0, "7252", "7509");
114 122
                     }
115 123
                     BigDecimal wholeSum = ps.stream().filter(TPoints -> !TPoints.getTemp().equals(new BigDecimal("250.0"))).map(TPoints::getTemp).reduce(BigDecimal.ZERO, BigDecimal::add);
116 124
                     List<BigDecimal> collect = ps.stream().filter(TPoints -> !TPoints.getTemp().equals(new BigDecimal("250.0"))).map(t -> t.getTemp()).collect(Collectors.toList());
@@ -158,6 +166,31 @@ public class GrainPushsServiceImpl implements GrainPushsService {
158 166
                             }
159 167
                         }
160 168
                     }
169
+                    if (thresholdHumidity != null) {
170
+                        //用于判断是否已经报警
171
+                        boolean temp = false;
172
+                        BigDecimal wh = thresholdHumidity.getThreshold();
173
+                        BigDecimal inh = tTestdata.getInh();
174
+                        //-1 小于 0 等于 1 大于
175
+                        if (inh.compareTo(wh) == 1 && !inh.toString().equals("250.0") && ilqYq.equals("0")) {
176
+                            String tid = uuidUtils.getCodeId(orgId, "t_warning_threshold_history");
177
+                            String desc = "整仓仓湿(" + inh + ")高于阈值(" + wh + ")";
178
+                            TWarningThresholdHistory tt = warningMessage.saveWThreshold(tid, house, thresholdHumidity, inh, wh, time, desc, dataSource2, "0", "0");
179
+                            tWarningThresholdHistorieList.add(tt);
180
+                            temp = true;
181
+                        }
182
+                        if (wWarningHumidity != null && !temp && !inh.toString().equals("250.0") && ilqYq.equals("0")) {
183
+                            //-1 小于 0 等于 1 大于
184
+                            BigDecimal ww = wWarningHumidity.getThreshold();
185
+                            BigDecimal subtract = wh.subtract(ww); //高温减去阈值
186
+                            if (inh.compareTo(subtract) == 1 && ilqYq.equals("0")) {
187
+                                String tid = uuidUtils.getCodeId(orgId, "t_warning_threshold_history");
188
+                                String desc = "整仓仓湿(" + inh + ")高于阈值(" + subtract + ")";
189
+                                TWarningThresholdHistory tt = warningMessage.saveWThreshold(tid, house, wWarningHumidity, inh, subtract, time, desc, dataSource2, "0", "1");
190
+                                tWarningThresholdHistorieList.add(tt);
191
+                            }
192
+                        }
193
+                    }
161 194
                     if (wLowest != null) {
162 195
                         //用于判断是否已经报警
163 196
                         boolean temp = false;
@@ -182,6 +215,31 @@ public class GrainPushsServiceImpl implements GrainPushsService {
182 215
                             }
183 216
                         }
184 217
                     }
218
+                    if (wLowestHumidity != null) {
219
+                        //用于判断是否已经报警
220
+                        boolean temp = false;
221
+                        BigDecimal wl = wLowest.getThreshold();
222
+                        BigDecimal inh = tTestdata.getInh();
223
+                        //-1 小于 0 等于 1 大于
224
+                        if (inh.compareTo(wl) == -1 && !inh.toString().equals("250.0") && ilqYq.equals("0")) {
225
+                            String tid = uuidUtils.getCodeId(orgId, "t_warning_threshold_history");
226
+                            String desc = "整仓仓湿(" + inh + ")低于阈值(" + wl + ")";
227
+                            TWarningThresholdHistory tt = warningMessage.saveWThreshold(tid, house, wLowestHumidity, inh, wl, time, desc, dataSource2, "0", "0");
228
+                            tWarningThresholdHistorieList.add(tt);
229
+                            temp = true;
230
+                        }
231
+                        if (wWarningHumidity != null && !temp && !inh.toString().equals("250.0") && ilqYq.equals("0")) {
232
+                            //-1 小于 0 等于 1 大于
233
+                            BigDecimal ww = wWarningHumidity.getThreshold();
234
+                            BigDecimal wadd = wl.add(ww);//高温减去阈值
235
+                            if (inh.compareTo(wadd) == -1 && ilqYq.equals("0")) {
236
+                                String tid = uuidUtils.getCodeId(orgId, "t_warning_threshold_history");
237
+                                String desc = "整仓仓湿(" + inh + ")低于阈值(" + wadd + ")";
238
+                                TWarningThresholdHistory tt = warningMessage.saveWThreshold(tid, house, wWarningHumidity, inh, wadd, time, desc, dataSource2, "0", "1");
239
+                                tWarningThresholdHistorieList.add(tt);
240
+                            }
241
+                        }
242
+                    }
185 243
 
186 244
                     Map<String, List<TPoints>> layerGroupV = ps.stream().collect(Collectors.groupingBy(t -> t.getZ()));
187 245
                     int layerNumber = 0;