Эх сурвалжийг харах

[101903] 修复全分支审查建议: 时点解析逐条容错, type 校验防孤儿批次行

taosj 2 долоо хоног өмнө
parent
commit
98edc9a5aa

+ 19 - 1
forecast-backend-server/src/main/java/com/ufo/project/forecast/fileupload/task/DataPowerForecastReportBatchTask.java

@@ -138,6 +138,13 @@ public class DataPowerForecastReportBatchTask
             log.warn("[PowerForecastReportBatch] period 非 daily, 跳过, stationCode={}", config.getStationCode());
             return;
         }
+        if (!DataPowerForecastReportBatch.TYPE_SHORT.equals(config.getType())
+                && !DataPowerForecastReportBatch.TYPE_ULTRA.equals(config.getType()))
+        {
+            log.warn("[PowerForecastReportBatch] type 未知, 跳过, stationCode={}, type={}",
+                    config.getStationCode(), config.getType());
+            return;
+        }
         ConfigStation q = new ConfigStation();
         q.setStationCode(config.getStationCode());
         List<ConfigStation> stations = configStationService.selectConfigStationList(q);
@@ -156,9 +163,20 @@ public class DataPowerForecastReportBatchTask
         times.sort(Comparator.naturalOrder());
         for (String t : times)
         {
+            LocalTime slotTime;
+            try
+            {
+                slotTime = LocalTime.parse(t);
+            }
+            catch (Exception e)
+            {
+                log.warn("[PowerForecastReportBatch] 时点格式非法, 跳过, stationCode={}, time={}",
+                        config.getStationCode(), t);
+                continue;
+            }
             LocalDateTime now = LocalDateTime.now(ZONE_SH);
             LocalDate today = LocalDate.now(ZONE_SH);
-            LocalDateTime slot = today.atTime(LocalTime.parse(t));
+            LocalDateTime slot = today.atTime(slotTime);
             // 已过时点, 跳过后续更远的时点
             if (now.isAfter(slot))
             {