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/test/java/com/zy/ai/service/AutoTuneApplyServiceImplTest.java | 43 ++++++++++++++++++++-----------------------
1 files changed, 20 insertions(+), 23 deletions(-)
diff --git a/src/test/java/com/zy/ai/service/AutoTuneApplyServiceImplTest.java b/src/test/java/com/zy/ai/service/AutoTuneApplyServiceImplTest.java
index 864c535..bcfe4cd 100644
--- a/src/test/java/com/zy/ai/service/AutoTuneApplyServiceImplTest.java
+++ b/src/test/java/com/zy/ai/service/AutoTuneApplyServiceImplTest.java
@@ -10,12 +10,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;
@@ -79,8 +77,6 @@
@Mock
private BasDualCrnpService basDualCrnpService;
@Mock
- private StationFlowCapacityService stationFlowCapacityService;
- @Mock
private WrkMastService wrkMastService;
@Mock
private RedisUtil redisUtil;
@@ -96,7 +92,6 @@
ReflectionTestUtils.setField(service, "basStationService", basStationService);
ReflectionTestUtils.setField(service, "basCrnpService", basCrnpService);
ReflectionTestUtils.setField(service, "basDualCrnpService", basDualCrnpService);
- ReflectionTestUtils.setField(service, "stationFlowCapacityService", stationFlowCapacityService);
ReflectionTestUtils.setField(service, "wrkMastService", wrkMastService);
ReflectionTestUtils.setField(service, "transactionManager", transactionManager);
ReflectionTestUtils.setField(service, "redisUtil", redisUtil);
@@ -201,8 +196,7 @@
@Test
void rejectStationOutTaskLimitAboveDirectionalBufferCapacity() {
- when(basStationService.getById(101)).thenReturn(station(101, 1));
- when(stationFlowCapacityService.getOne(any(Wrapper.class))).thenReturn(capacity(101, "OUT", 2));
+ when(basStationService.getById(101)).thenReturn(station(101, 1, 2));
service.apply(request(true, command("station", "101", "outTaskLimit", "3")));
@@ -220,7 +214,6 @@
List<AiAutoTuneChange> changes = savedChanges();
assertEquals("rejected", changes.get(0).getResultStatus());
assertTrue(changes.get(0).getRejectReason().contains("闇�瑕佷汉宸ュ厛鍒濆鍖栦负鏈夐檺鍊�"));
- verify(stationFlowCapacityService, never()).getOne(any(Wrapper.class));
}
@Test
@@ -232,13 +225,11 @@
List<AiAutoTuneChange> changes = savedChanges();
assertEquals("rejected", changes.get(0).getResultStatus());
assertTrue(changes.get(0).getRejectReason().contains("闇�瑕佷汉宸ュ厛鍒濆鍖栦负鏈夐檺鍊�"));
- verify(stationFlowCapacityService, never()).getOne(any(Wrapper.class));
}
@Test
void allowStationOutTaskLimitZeroToOneAsFiniteStep() {
- when(basStationService.getById(101)).thenReturn(station(101, 0));
- when(stationFlowCapacityService.getOne(any(Wrapper.class))).thenReturn(capacity(101, "OUT", 1));
+ when(basStationService.getById(101)).thenReturn(station(101, 0, 1));
AutoTuneApplyResult result = service.apply(request(true, command("station", "101", "outTaskLimit", "1")));
@@ -247,6 +238,17 @@
assertEquals("dry_run", changes.get(0).getResultStatus());
assertEquals("0", changes.get(0).getOldValue());
assertEquals("1", changes.get(0).getRequestedValue());
+ }
+
+ @Test
+ void rejectStationOutTaskLimitWithoutOutBufferCapacity() {
+ when(basStationService.getById(101)).thenReturn(station(101, 0));
+
+ service.apply(request(true, command("station", "101", "outTaskLimit", "1")));
+
+ List<AiAutoTuneChange> changes = savedChanges();
+ assertEquals("rejected", changes.get(0).getResultStatus());
+ assertTrue(changes.get(0).getRejectReason().contains("缂哄皯 outBufferCapacity"));
}
@Test
@@ -267,8 +269,7 @@
@Test
void realMixedValidAndInvalidBatchRejectsAndDoesNotWriteTargets() {
when(configService.getOne(any(Wrapper.class))).thenReturn(config("conveyorStationTaskLimit", "10"));
- when(basStationService.getById(101)).thenReturn(station(101, 1));
- when(stationFlowCapacityService.getOne(any(Wrapper.class))).thenReturn(capacity(101, "OUT", 2));
+ when(basStationService.getById(101)).thenReturn(station(101, 1, 2));
AutoTuneApplyResult result = service.apply(request(false,
command("sys_config", null, "conveyorStationTaskLimit", "15"),
@@ -376,8 +377,7 @@
@Test
void applyMixedBatchSuccessfully() {
when(configService.getOne(any(Wrapper.class))).thenReturn(config("conveyorStationTaskLimit", "10"));
- when(basStationService.getById(101)).thenReturn(station(101, 1));
- when(stationFlowCapacityService.getOne(any(Wrapper.class))).thenReturn(capacity(101, "OUT", 2));
+ when(basStationService.getById(101)).thenReturn(station(101, 1, 2));
when(basCrnpService.getById(1)).thenReturn(crn(1, 1, 1));
when(basDualCrnpService.getById(2)).thenReturn(dualCrn(2, 1, 1));
@@ -789,9 +789,14 @@
}
private BasStation station(Integer stationId, Integer outTaskLimit) {
+ return station(stationId, outTaskLimit, null);
+ }
+
+ private BasStation station(Integer stationId, Integer outTaskLimit, Integer outBufferCapacity) {
BasStation station = new BasStation();
station.setStationId(stationId);
station.setOutTaskLimit(outTaskLimit);
+ station.setOutBufferCapacity(outBufferCapacity);
return station;
}
@@ -809,14 +814,6 @@
dualCrnp.setMaxOutTask(maxOutTask);
dualCrnp.setMaxInTask(maxInTask);
return dualCrnp;
- }
-
- private StationFlowCapacity capacity(Integer stationId, String directionCode, Integer bufferCapacity) {
- StationFlowCapacity capacity = new StationFlowCapacity();
- capacity.setStationId(stationId);
- capacity.setDirectionCode(directionCode);
- capacity.setBufferCapacity(bufferCapacity);
- return capacity;
}
private AiAutoTuneChange successChange(Long jobId,
--
Gitblit v1.9.1