Przeglądaj źródła

超短池历史趋势字段补全逻辑修改

Zhangbw 1 miesiąc temu
rodzic
commit
22c7160194

+ 2 - 1
.claude/settings.local.json

@@ -2,7 +2,8 @@
   "permissions": {
     "allow": [
       "Bash(mvn clean)",
-      "Bash(mvn compile -pl ruoyi-modules/yp-stock -am -DskipTests)"
+      "Bash(mvn compile -pl ruoyi-modules/yp-stock -am -DskipTests)",
+      "Bash(xargs grep -l \"history\")"
     ]
   }
 }

+ 12 - 8
ruoyi-modules/yp-stock/src/main/java/com/yingpai/stock/service/impl/StockPoolServiceImpl.java

@@ -356,23 +356,27 @@ public class StockPoolServiceImpl implements IStockPoolService {
             log.warn("[补全历史数据] 未找到最近7天内的交易数据");
         }
 
-        // 查询当天的超短池数据
-        List<StockPool> currentDayData = baseMapper.selectByDateAndType(importDate, 1);
-        if (currentDayData.isEmpty()) {
-            String message = "当天(" + importDate + ")没有超短池数据,无法补全";
-            log.warn("[补全历史数据] {}", message);
-            return message;
-        }
-
         // 查询当天的历史数据(从stock_pool_history表)
         LambdaQueryWrapper<StockPoolHistory> historyWrapper = Wrappers.lambdaQuery();
         historyWrapper.eq(StockPoolHistory::getRecordDate, importDate);
         List<StockPoolHistory> historyData = stockPoolHistoryMapper.selectList(historyWrapper);
 
+        if (historyData == null || historyData.isEmpty()) {
+            String message = "当天(" + importDate + ")没有历史数据(stock_pool_history),无法补全";
+            log.warn("[补全历史数据] {}", message);
+            return message;
+        }
+
         // 将历史数据转换为Map,key为股票代码
         Map<String, StockPoolHistory> historyMap = historyData.stream()
             .collect(Collectors.toMap(StockPoolHistory::getStockCode, h -> h));
 
+        // 查询当天的超短池数据(用于补全当天收盘价;即使为空也不应阻断前一天隔日补全)
+        List<StockPool> currentDayData = baseMapper.selectByDateAndType(importDate, 1);
+        if (currentDayData.isEmpty()) {
+            log.warn("[补全历史数据] 当天({})没有超短池数据(stock_pool),将跳过当天收盘价补全,但仍会尝试补全前一天隔日数据", importDate);
+        }
+
         int currentDayUpdated = 0;
         int previousDayUpdated = 0;