Explorar el Código

小时数据0点和异常值处理

欧阳劲驰 hace 3 meses
padre
commit
2c6d3f2fca

+ 34 - 21
src/main/java/com/shkpr/service/aimodelpower/bizmgr/KprAimTapWaterBizFun.java

@@ -804,27 +804,27 @@ public class KprAimTapWaterBizFun {
                                     DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
                                     // 解析字符串以创建 LocalDateTime 实例
                                     LocalDateTime dateTime = LocalDateTime.parse(endTime, formatter);
-                                    if (dateTime.getHour()==1&&("SS.SSCOM.F36:2".equals(item.get("collcation_tag").toString()) ||
-                                            "SS.SSCOM.F36:5".equals(item.get("collcation_tag").toString()) ||
-                                            "SS.SSCOM.F36:8".equals(item.get("collcation_tag").toString()))) {
-                                        Integer itemCount = getWaterTapWaterApi().getTabWaterHistoryCount(
-                                                " WHERE TAG_CODE = '" + item.get("collcation_tag") + "' " +
-                                                        " and QCQUISITION_TIME >= to_date('" + startDate + "', 'yyyy-mm-dd hh24:mi:ss')" +
-                                                        " and QCQUISITION_TIME < to_date('" + endDate + "', 'yyyy-mm-dd hh24:mi:ss')");
-                                        if(itemCount!=null&&itemCount>0) {
-                                            List<Map<String, Object>> tapWaterHistoryList = getWaterTapWaterApi().getPageZILAISHUI_HISTORY2(itemCount, 0,
-                                                    " AND TAG_CODE = '" + item.get("collcation_tag") + "' " +
-                                                            " and QCQUISITION_TIME >= to_date('" + startTime + "', 'yyyy-mm-dd hh24:mi:ss')" +
-                                                            " and QCQUISITION_TIME < to_date('" + endTime + "', 'yyyy-mm-dd hh24:mi:ss')" +
-                                                            " order by QCQUISITION_TIME");
-                                            if (!CollectionUtils.isEmpty(tapWaterHistoryList) && tapWaterHistoryList.size() > 1) {
-                                                if (value == null) {
-                                                    value = 0.00;
-                                                }
-                                                value += tapWaterHistoryList.get((tapWaterHistoryList.size() - 1)).get("VAL") != null ? Double.valueOf(tapWaterHistoryList.get((tapWaterHistoryList.size() - 1)).get("val").toString()) : null;
-                                            }
-                                        }
-                                    }else {
+//                                    if (dateTime.getHour()==1&&("SS.SSCOM.F36:2".equals(item.get("collcation_tag").toString()) ||
+//                                            "SS.SSCOM.F36:5".equals(item.get("collcation_tag").toString()) ||
+//                                            "SS.SSCOM.F36:8".equals(item.get("collcation_tag").toString()))) {
+//                                        Integer itemCount = getWaterTapWaterApi().getTabWaterHistoryCount(
+//                                                " WHERE TAG_CODE = '" + item.get("collcation_tag") + "' " +
+//                                                        " and QCQUISITION_TIME >= to_date('" + startDate + "', 'yyyy-mm-dd hh24:mi:ss')" +
+//                                                        " and QCQUISITION_TIME < to_date('" + endDate + "', 'yyyy-mm-dd hh24:mi:ss')");
+//                                        if(itemCount!=null&&itemCount>0) {
+//                                            List<Map<String, Object>> tapWaterHistoryList = getWaterTapWaterApi().getPageZILAISHUI_HISTORY2(itemCount, 0,
+//                                                    " AND TAG_CODE = '" + item.get("collcation_tag") + "' " +
+//                                                            " and QCQUISITION_TIME >= to_date('" + startTime + "', 'yyyy-mm-dd hh24:mi:ss')" +
+//                                                            " and QCQUISITION_TIME < to_date('" + endTime + "', 'yyyy-mm-dd hh24:mi:ss')" +
+//                                                            " order by QCQUISITION_TIME");
+//                                            if (!CollectionUtils.isEmpty(tapWaterHistoryList) && tapWaterHistoryList.size() > 1) {
+//                                                if (value == null) {
+//                                                    value = 0.00;
+//                                                }
+//                                                value += tapWaterHistoryList.get((tapWaterHistoryList.size() - 1)).get("VAL") != null ? Double.valueOf(tapWaterHistoryList.get((tapWaterHistoryList.size() - 1)).get("val").toString()) : null;
+//                                            }
+//                                        }
+//                                    }else {
                                         Integer itemCount = getWaterTapWaterApi().getTabWaterHistoryCount(
                                                 " WHERE TAG_CODE = '" + item.get("collcation_tag") + "' " +
                                                         " and QCQUISITION_TIME >= to_date('" + startDate + "', 'yyyy-mm-dd hh24:mi:ss')" +
@@ -848,8 +848,21 @@ public class KprAimTapWaterBizFun {
                                                 }
                                             }
                                         }
+//                                    }
+                                }
+
+                                //数据异常值判断,如大于3万,使用上一条数据
+                                if (value!=null && value > 30000) {
+                                    Double dbLastValue  = getWaterTapWaterApi().getLastValue(
+                                            (String) recordAllEntity.get("org_name"),
+                                            (String) recordAllEntity.get("time"),
+                                            (String) recordAllEntity.get("value_tag"),
+                                            30000.0,-30000.0);
+                                    if (dbLastValue != null) {
+                                        value = dbLastValue;
                                     }
                                 }
+
                                 recordAllEntity.put("value", value);
                                 List<Map<String, Object>> queryWaterRecord = getWaterTapWaterApi().getWaterCollectionRecordAllList(1, 0,
                                         " WHERE org_name = '" + recordAllEntity.get("org_name")