瀏覽代碼

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

aihua 3 年之前
父節點
當前提交
038d19b90a

+ 58 - 2
depot-intelligent/src/main/java/com/chinaitop/depot/intelligent/utils/LongRangeUtils.java

@@ -1,6 +1,5 @@
1 1
 package com.chinaitop.depot.intelligent.utils;
2 2
 
3
-import com.alibaba.fastjson.JSON;
4 3
 import com.chinaitop.depot.intelligent.basicdata.model.TWarningThreshold;
5 4
 import com.chinaitop.depot.intelligent.basicdata.service.WarningThresholdService;
6 5
 import com.chinaitop.depot.intelligent.grainsituation.mapper.TTestdataLayerMapper;
@@ -14,7 +13,6 @@ import org.slf4j.LoggerFactory;
14 13
 import org.springframework.context.annotation.Configuration;
15 14
 import org.springframework.scheduling.annotation.Async;
16 15
 import org.springframework.transaction.annotation.Transactional;
17
-import org.springframework.web.client.RestTemplate;
18 16
 
19 17
 import javax.annotation.Resource;
20 18
 import java.math.BigDecimal;
@@ -111,12 +109,20 @@ public class LongRangeUtils {
111 109
                 TWarningThreshold threshold = null; //温度高限
112 110
                 TWarningThreshold wLowest = null; //温度底限
113 111
                 TWarningThreshold wWarning = null; //温度预警
112
+
113
+                // 获取报警阈值信息7252 测湿 7253湿度高限 7254湿度低限 7509湿度预警
114
+                TWarningThreshold thresholdHumidity = null; //湿度高限
115
+                TWarningThreshold wLowestHumidity = null; //湿度低限
116
+                TWarningThreshold wWarningHumidity = null; //湿度预警
114 117
                 String ilqYq = tTestdata.getIlqYq();
115 118
                 if (ilqYq.equals(STR_ZERO)) {
116 119
                     threshold = warningThresholdService.getByCfCodeAndwName(house, INT_ZERO, "6972", "6983");
117 120
                     wLowest = warningThresholdService.getByCfCodeAndwName(house, INT_ZERO, "6972", "6982");
118 121
                     wWarning = warningThresholdService.getByCfCodeAndwName(house, INT_ZERO, "6972", "6991");
119 122
 
123
+                    thresholdHumidity = warningThresholdService.getByCfCodeAndwName(house, 0, "7252", "7253");
124
+                    wLowestHumidity = warningThresholdService.getByCfCodeAndwName(house, 0, "7252", "7254");
125
+                    wWarningHumidity = warningThresholdService.getByCfCodeAndwName(house, 0, "7252", "7509");
120 126
                 }
121 127
                 BigDecimal wholeSum = ps.stream().filter(TPoints -> !TPoints.getTemp().toString().equals(new BigDecimal(STR_TEMP).toString())).map(TPoints::getTemp).reduce(BigDecimal.ZERO, BigDecimal::add);
122 128
                 List<BigDecimal> collect = ps.stream().filter(TPoints -> !TPoints.getTemp().toString().equals(new BigDecimal(STR_TEMP).toString())).map(t -> t.getTemp()).collect(Collectors.toList());
@@ -171,6 +177,31 @@ public class LongRangeUtils {
171 177
                         }
172 178
                     }
173 179
                 }
180
+                if (thresholdHumidity != null) {
181
+                    //用于判断是否已经报警
182
+                    boolean temp = false;
183
+                    BigDecimal wh = thresholdHumidity.getThreshold();
184
+                    BigDecimal inh = tTestdata.getInh();
185
+                    //-1 小于 0 等于 1 大于
186
+                    if (inh.compareTo(wh) == 1 && !inh.toString().equals("250.0") && ilqYq.equals("0")) {
187
+                        String tid = UuidUtils.getCode();
188
+                        String desc = "整仓仓湿(" + inh + ")高于阈值(" + wh + ")";
189
+                        TWarningThresholdHistory tt = warningMessage.saveWThreshold(tid, house, thresholdHumidity, inh, wh, time, desc, dataSource2, "0", "0");
190
+                        tWarningThresholdHistorieList.add(tt);
191
+                        temp = true;
192
+                    }
193
+                    if (wWarningHumidity != null && !temp && !inh.toString().equals("250.0") && ilqYq.equals("0")) {
194
+                        //-1 小于 0 等于 1 大于
195
+                        BigDecimal ww = wWarningHumidity.getThreshold();
196
+                        BigDecimal subtract = wh.subtract(ww); //高温减去阈值
197
+                        if (inh.compareTo(subtract) == 1 && ilqYq.equals("0")) {
198
+                            String tid = UuidUtils.getCode();
199
+                            String desc = "整仓仓湿(" + inh + ")高于阈值(" + subtract + ")";
200
+                            TWarningThresholdHistory tt = warningMessage.saveWThreshold(tid, house, wWarningHumidity, inh, subtract, time, desc, dataSource2, "0", "1");
201
+                            tWarningThresholdHistorieList.add(tt);
202
+                        }
203
+                    }
204
+                }
174 205
                 if (wLowest != null) {
175 206
                     //用于判断是否已经报警
176 207
                     boolean temp = false;
@@ -197,6 +228,31 @@ public class LongRangeUtils {
197 228
                         }
198 229
                     }
199 230
                 }
231
+                if (wLowestHumidity != null) {
232
+                    //用于判断是否已经报警
233
+                    boolean temp = false;
234
+                    BigDecimal wl = wLowest.getThreshold();
235
+                    BigDecimal inh = tTestdata.getInh();
236
+                    //-1 小于 0 等于 1 大于
237
+                    if (inh.compareTo(wl) == -1 && !inh.toString().equals("250.0") && ilqYq.equals("0")) {
238
+                        String tid = UuidUtils.getCode();
239
+                        String desc = "整仓仓湿(" + inh + ")低于阈值(" + wl + ")";
240
+                        TWarningThresholdHistory tt = warningMessage.saveWThreshold(tid, house, wLowestHumidity, inh, wl, time, desc, dataSource2, "0", "0");
241
+                        tWarningThresholdHistorieList.add(tt);
242
+                        temp = true;
243
+                    }
244
+                    if (wWarningHumidity != null && !temp && !inh.toString().equals("250.0") && ilqYq.equals("0")) {
245
+                        //-1 小于 0 等于 1 大于
246
+                        BigDecimal ww = wWarningHumidity.getThreshold();
247
+                        BigDecimal wadd = wl.add(ww);//高温减去阈值
248
+                        if (inh.compareTo(wadd) == -1 && ilqYq.equals("0")) {
249
+                            String tid = UuidUtils.getCode();
250
+                            String desc = "整仓仓湿(" + inh + ")低于阈值(" + wadd + ")";
251
+                            TWarningThresholdHistory tt = warningMessage.saveWThreshold(tid, house, wWarningHumidity, inh, wadd, time, desc, dataSource2, "0", "1");
252
+                            tWarningThresholdHistorieList.add(tt);
253
+                        }
254
+                    }
255
+                }
200 256
 
201 257
                 Map<String, List<TPoints>> layerGroupV = ps.stream().collect(Collectors.groupingBy(t -> t.getZ()));
202 258
                 int layerNumber = INT_ZERO;