feat: 支持按箱号展开可用库存子卷

This commit is contained in:
zhouz
2026-07-22 14:36:21 +08:00
parent eb35c99966
commit 1fcc152dca
9 changed files with 246 additions and 8 deletions

View File

@@ -1,17 +1,22 @@
package cn.code.nl.module.wms.service.iostorinv;
import cn.code.nl.module.wms.controller.admin.iostorinv.vo.IostorInvCreateReqVO;
import cn.code.nl.module.wms.controller.admin.iostorinv.vo.AvailableInventoryRespVO;
import cn.code.nl.module.wms.controller.admin.iostorinv.vo.ExpandAvailableInventoryReqVO;
import jakarta.annotation.Resource;
import jakarta.validation.ConstraintViolationException;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Disabled;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
@SpringBootTest
@ActiveProfiles("local")
@@ -34,4 +39,23 @@ class IostorInvServiceLocalSpringTest {
assertTrue(exception.getConstraintViolations().stream()
.anyMatch(violation -> violation.getPropertyPath().toString().contains("details")));
}
/**
* 本地库数据前置:仓库 stor-1 的 BOX-001 有两个可用子卷,另一仓库也存在 BOX-001。
* 当前仓库没有可移植的 WMS 本地测试数据集,避免向开发库写入固定业务数据,准备好上述数据后可手动启用。
*/
@Test
@Disabled("需要 local 数据库预置跨仓库 BOX-001 测试数据")
void expandAvailableInventoryShouldReturnAllChildrenOnceAndOnlyFromRequestedWarehouse() {
ExpandAvailableInventoryReqVO reqVO = new ExpandAvailableInventoryReqVO();
reqVO.setStorId("stor-1");
reqVO.setVehicleCodes(List.of("BOX-001", "BOX-001"));
List<AvailableInventoryRespVO> result = iostorInvService.expandAvailableInventory(reqVO);
assertEquals(2, result.size());
assertTrue(result.stream().allMatch(item -> "BOX-001".equals(item.getVehicleCode())));
assertTrue(result.stream().allMatch(item -> "stor-1".equals(item.getStorId())));
assertEquals(2, result.stream().map(AvailableInventoryRespVO::getPcsn).distinct().count());
}
}