From 0c336d5c5c0596691c9b33c08643c03486d47d5f Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期一, 27 四月 2026 18:56:39 +0800
Subject: [PATCH] refactor: move station buffer capacity to bas station

---
 src/main/java/com/zy/ai/service/impl/AutoTuneApplyServiceImpl.java |   18 ++++--------------
 1 files changed, 4 insertions(+), 14 deletions(-)

diff --git a/src/main/java/com/zy/ai/service/impl/AutoTuneApplyServiceImpl.java b/src/main/java/com/zy/ai/service/impl/AutoTuneApplyServiceImpl.java
index 0adf162..14ce0c9 100644
--- a/src/main/java/com/zy/ai/service/impl/AutoTuneApplyServiceImpl.java
+++ b/src/main/java/com/zy/ai/service/impl/AutoTuneApplyServiceImpl.java
@@ -17,12 +17,10 @@
 import com.zy.asrs.entity.BasCrnp;
 import com.zy.asrs.entity.BasDualCrnp;
 import com.zy.asrs.entity.BasStation;
-import com.zy.asrs.entity.StationFlowCapacity;
 import com.zy.asrs.entity.WrkMast;
 import com.zy.asrs.service.BasCrnpService;
 import com.zy.asrs.service.BasDualCrnpService;
 import com.zy.asrs.service.BasStationService;
-import com.zy.asrs.service.StationFlowCapacityService;
 import com.zy.asrs.service.WrkMastService;
 import com.zy.common.utils.RedisUtil;
 import com.zy.core.enums.RedisKeyType;
@@ -50,7 +48,6 @@
 
     private static final Logger LOGGER = LoggerFactory.getLogger(AutoTuneApplyServiceImpl.class);
     private static final String PROMPT_SCENE_CODE = "auto_tune_apply";
-    private static final String DIRECTION_OUT = "OUT";
     private static final long APPLY_LOCK_SECONDS = 120L;
     private static final String APPLY_LOCK_BUSY_REASON = "鐢宠璋冨弬閿佸け璐ワ紝閿佷笉鍙敤锛屽彲鑳藉凡鏈変换鍔℃垨 Redis 寮傚父";
     private static final List<Long> FINAL_WRK_STS_LIST = Arrays.asList(
@@ -74,8 +71,6 @@
     private BasCrnpService basCrnpService;
     @Autowired
     private BasDualCrnpService basDualCrnpService;
-    @Autowired
-    private StationFlowCapacityService stationFlowCapacityService;
     @Autowired
     private WrkMastService wrkMastService;
     @Autowired
@@ -300,7 +295,7 @@
         Integer maxValue = resolveMaxValue(validatedChange, rule, requestedValue);
         if (maxValue == null) {
             return validatedChange.reject("绔欑偣 " + validatedChange.getTargetId()
-                    + " 缂哄皯 OUT 鏂瑰悜 bufferCapacity锛屾棤娉曡瘉鏄� outTaskLimit 涓婇檺");
+                    + " 缂哄皯 outBufferCapacity锛屾棤娉曡瘉鏄� outTaskLimit 涓婇檺");
         }
         if (requestedValue < rule.getMinValue() || requestedValue > maxValue) {
             return validatedChange.reject(validatedChange.getTargetKey() + " 蹇呴』鍦� "
@@ -388,16 +383,11 @@
             return rule.getMaxValue();
         }
         Integer targetId = parseTargetId(validatedChange.getTargetId(), rule.getTargetType());
-        StationFlowCapacity capacity = stationFlowCapacityService.getOne(
-                new QueryWrapper<StationFlowCapacity>()
-                        .eq("station_id", targetId)
-                        .eq("direction_code", DIRECTION_OUT)
-                        .last("limit 1")
-        );
-        if (capacity == null || capacity.getBufferCapacity() == null) {
+        BasStation station = basStationService.getById(targetId);
+        if (station == null || station.getOutBufferCapacity() == null) {
             return requestedValue == 0 ? 0 : null;
         }
-        return Math.max(0, capacity.getBufferCapacity());
+        return Math.max(0, station.getOutBufferCapacity());
     }
 
     private Date findCooldownExpireTime(ValidatedChange validatedChange, Date now) {

--
Gitblit v1.9.1