From 49e63eca9f064ef9daac1045239e543a27086c73 Mon Sep 17 00:00:00 2001 From: ouyangxq <775153912@qq.com> Date: Thu, 24 Sep 2026 08:54:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/sql/海外区域统一增量-MySQL8.sql | 9 +++++++-- .../phase4-overseas-warehouse-contract.test.mjs | 2 +- .../phase4-overseas-warehouse.mjs | 4 ++-- .../com/baiyue/warehouse/dto/LocationRequests.java | 2 -- .../warehouse/entity/WarehouseLocationEntity.java | 1 - .../warehouse/mapper/WarehouseLocationMapper.java | 4 ++-- .../repository/WarehouseResourceRepository.java | 4 +--- .../warehouse/service/WarehouseResourceService.java | 3 --- .../src/main/resources/db/warehouse.sql | 12 +++++++++--- .../service/WarehouseResourceServiceTest.java | 2 +- 10 files changed, 23 insertions(+), 20 deletions(-) diff --git a/deploy/sql/海外区域统一增量-MySQL8.sql b/deploy/sql/海外区域统一增量-MySQL8.sql index 5f3e46564..f84fba221 100644 --- a/deploy/sql/海外区域统一增量-MySQL8.sql +++ b/deploy/sql/海外区域统一增量-MySQL8.sql @@ -2917,7 +2917,6 @@ CREATE TABLE wh_location ( id bigint unsigned NOT NULL COMMENT '库位ID(雪花ID)', customer_id bigint unsigned NOT NULL COMMENT '数据所属租户ID', warehouse_id bigint unsigned NOT NULL COMMENT '所属仓库ID', - zone_code varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '仓库分区编码', location_code varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '仓库内唯一库位编码', location_type varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '库位类型', shared_overflow tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否系统共享溢出库位(A0)', @@ -2932,9 +2931,15 @@ CREATE TABLE wh_location ( version int NOT NULL DEFAULT '0' COMMENT '乐观锁版本号', PRIMARY KEY (id), UNIQUE KEY uk_location_code (customer_id,warehouse_id,location_code,deleted), - KEY idx_location_query (customer_id,warehouse_id,zone_code,status,deleted) + KEY idx_location_query (customer_id,warehouse_id,status,deleted) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='仓库库位表:按租户和仓库维护库位及承重信息'; +SET @ddl = (SELECT IF(EXISTS (SELECT 1 FROM information_schema.statistics WHERE table_schema=DATABASE() AND table_name='wh_location' AND index_name='idx_location_query'), 'ALTER TABLE wh_location DROP INDEX idx_location_query', 'SELECT 1')); +PREPARE location_zone_index_stmt FROM @ddl; EXECUTE location_zone_index_stmt; DEALLOCATE PREPARE location_zone_index_stmt; +SET @ddl = (SELECT IF(EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema=DATABASE() AND table_name='wh_location' AND column_name='zone_code'), 'ALTER TABLE wh_location DROP COLUMN zone_code', 'SELECT 1')); +PREPARE location_zone_column_stmt FROM @ddl; EXECUTE location_zone_column_stmt; DEALLOCATE PREPARE location_zone_column_stmt; + + CREATE TABLE wh_pallet ( id bigint unsigned NOT NULL COMMENT '托盘ID(雪花ID)', customer_id bigint unsigned NOT NULL COMMENT '数据所属租户ID', diff --git a/scripts/admin-test-env-modules/phase4-overseas-warehouse-contract.test.mjs b/scripts/admin-test-env-modules/phase4-overseas-warehouse-contract.test.mjs index 600eb6c4c..8b889591a 100644 --- a/scripts/admin-test-env-modules/phase4-overseas-warehouse-contract.test.mjs +++ b/scripts/admin-test-env-modules/phase4-overseas-warehouse-contract.test.mjs @@ -45,7 +45,7 @@ function contextFixture({ tenants = [{ id: '10001', status: 'ACTIVE' }], warehou if (requestPath.includes('/inventory/balances?')) return response(page([{ id: '60001', customerId: '10001', skuCode: 'SKU-1', totalPackages: 10, availablePackages: 10, updatedAt: '2026-08-21T10:00:00' }])) if (requestPath.includes('/inventory/balances/60001/positions?')) return response([{ id: '61001', balanceId: '60001', totalPackages: 10 }]) if (requestPath.includes('/inventory/ledger?')) return response(page([{ id: '62001', customerId: '10001', businessType: 'STOCK_IN', beforePackages: 0, deltaPackages: 10, afterPackages: 10, occurredAt: '2026-08-21T10:00:00' }])) - if (requestPath.endsWith('/warehouse-admin/20001/locations?page=1&size=20')) return response(page([{ id: '72001', customerId: '0', warehouseId: '20001', zoneCode: 'A', locationCode: 'A-01', locationType: 'STORAGE', maxLoadKg: 1000, status: 'ACTIVE' }])) + if (requestPath.endsWith('/warehouse-admin/20001/locations?page=1&size=20')) return response(page([{ id: '72001', customerId: '0', warehouseId: '20001', locationCode: 'A-01', locationType: 'STORAGE', maxLoadKg: 1000, status: 'ACTIVE' }])) if (requestPath.endsWith('/warehouse-admin/20001/locations/72001')) return response({ id: '72001', customerId: '0', warehouseId: '20001', locationCode: 'A-01', status: 'ACTIVE' }) if (requestPath.endsWith('/warehouse-admin/20001/locations/72002')) return createdLocation == null ? response(undefined, 'A0404') : response(createdLocation) diff --git a/scripts/admin-test-env-modules/phase4-overseas-warehouse.mjs b/scripts/admin-test-env-modules/phase4-overseas-warehouse.mjs index bd11e6a32..7328e5768 100644 --- a/scripts/admin-test-env-modules/phase4-overseas-warehouse.mjs +++ b/scripts/admin-test-env-modules/phase4-overseas-warehouse.mjs @@ -210,7 +210,7 @@ async function verifyLocationLifecycle(context, warehouseId) { try { const created = await overseasMutation(context, 'POST', '创建本轮公共库位', `/api/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}/locations`, { - zoneCode: 'ACC', locationCode, locationType: 'STORAGE', maxLoadKg: 1000, + locationCode, locationType: 'STORAGE', maxLoadKg: 1000, status: 'ACTIVE', remark: context.marker, }) locationId = id(created.data) @@ -225,7 +225,7 @@ async function verifyLocationLifecycle(context, warehouseId) { && detail.data?.locationCode === locationCode && detail.data?.remark === context.marker, `locationId=${id(detail.data?.id) || 'missing'}, code=${detail.data?.locationCode || 'missing'}; ${trace(detail.response)}`, OPTIONS) const updated = await overseasMutation(context, 'PUT', '编辑本轮公共库位', detailPath, { - zoneCode: 'ACC', locationCode, locationType: 'STORAGE', maxLoadKg: 1200, + locationCode, locationType: 'STORAGE', maxLoadKg: 1200, status: 'ACTIVE', remark: `${context.marker}-edited`, }) context.assert(MODULE, '公共库位编辑成功', updated.response, voidMutationSucceeded(updated), diff --git a/warehouse-overseas-service/src/main/java/com/baiyue/warehouse/dto/LocationRequests.java b/warehouse-overseas-service/src/main/java/com/baiyue/warehouse/dto/LocationRequests.java index 2013ef02a..842a29aed 100644 --- a/warehouse-overseas-service/src/main/java/com/baiyue/warehouse/dto/LocationRequests.java +++ b/warehouse-overseas-service/src/main/java/com/baiyue/warehouse/dto/LocationRequests.java @@ -14,7 +14,6 @@ public final class LocationRequests { } public record SaveRequest( - @NotBlank @Size(max = 50) String zoneCode, @NotBlank @Size(max = 64) String locationCode, @NotBlank @Size(max = 32) String locationType, @NotNull @DecimalMin(value = "0.000", inclusive = false) BigDecimal maxLoadKg, @@ -26,7 +25,6 @@ public final class LocationRequests { public record QueryRequest( @Min(1) long page, @Min(1) @Max(200) long size, - String zoneCode, String locationType, String status, String keyword diff --git a/warehouse-overseas-service/src/main/java/com/baiyue/warehouse/entity/WarehouseLocationEntity.java b/warehouse-overseas-service/src/main/java/com/baiyue/warehouse/entity/WarehouseLocationEntity.java index 97ab5671a..8b82e7694 100644 --- a/warehouse-overseas-service/src/main/java/com/baiyue/warehouse/entity/WarehouseLocationEntity.java +++ b/warehouse-overseas-service/src/main/java/com/baiyue/warehouse/entity/WarehouseLocationEntity.java @@ -17,7 +17,6 @@ public class WarehouseLocationEntity extends BaseEntity { private Long id; private Long customerId; private Long warehouseId; - private String zoneCode; private String locationCode; private String locationType; /** A0 is a system-managed shared overflow location; normal locations are exclusive. */ diff --git a/warehouse-overseas-service/src/main/java/com/baiyue/warehouse/mapper/WarehouseLocationMapper.java b/warehouse-overseas-service/src/main/java/com/baiyue/warehouse/mapper/WarehouseLocationMapper.java index 55213ec04..49c397c88 100644 --- a/warehouse-overseas-service/src/main/java/com/baiyue/warehouse/mapper/WarehouseLocationMapper.java +++ b/warehouse-overseas-service/src/main/java/com/baiyue/warehouse/mapper/WarehouseLocationMapper.java @@ -14,10 +14,10 @@ public interface WarehouseLocationMapper extends BaseMapper() .eq(WarehouseLocationEntity::getCustomerId, customerId) .eq(WarehouseLocationEntity::getWarehouseId, warehouseId) - .eq(StringUtils.hasText(query.zoneCode()), WarehouseLocationEntity::getZoneCode, query.zoneCode()) .eq(StringUtils.hasText(query.locationType()), WarehouseLocationEntity::getLocationType, query.locationType()) .eq(StringUtils.hasText(query.status()), WarehouseLocationEntity::getStatus, query.status()) .and(StringUtils.hasText(query.keyword()), q -> q .like(WarehouseLocationEntity::getLocationCode, query.keyword()) - .or().like(WarehouseLocationEntity::getZoneCode, query.keyword())) - .orderByAsc(WarehouseLocationEntity::getZoneCode) + ) .orderByAsc(WarehouseLocationEntity::getLocationCode); return PageResult.from(locations.selectPage(new Page<>(query.page(), query.size()), wrapper)); } diff --git a/warehouse-overseas-service/src/main/java/com/baiyue/warehouse/service/WarehouseResourceService.java b/warehouse-overseas-service/src/main/java/com/baiyue/warehouse/service/WarehouseResourceService.java index 1036dbdb2..024636e81 100644 --- a/warehouse-overseas-service/src/main/java/com/baiyue/warehouse/service/WarehouseResourceService.java +++ b/warehouse-overseas-service/src/main/java/com/baiyue/warehouse/service/WarehouseResourceService.java @@ -185,7 +185,6 @@ public class WarehouseResourceService { location.setId(IdWorker.getId()); location.setCustomerId(customerId); location.setWarehouseId(warehouseId); - location.setZoneCode("DEFAULT"); location.setLocationCode(locationCode); location.setLocationType("VIRTUAL"); location.setMaxLoadKg(new java.math.BigDecimal("999999999.000")); @@ -214,7 +213,6 @@ public class WarehouseResourceService { location.setId(IdWorker.getId()); location.setCustomerId(PUBLIC_RESOURCE_SCOPE); location.setWarehouseId(warehouseId); - location.setZoneCode("OVERFLOW"); location.setLocationCode(SHARED_OVERFLOW_LOCATION_CODE); location.setLocationType("SHARED_OVERFLOW"); location.setSharedOverflow(true); @@ -424,7 +422,6 @@ public class WarehouseResourceService { WarehouseLocationEntity entity = new WarehouseLocationEntity(); entity.setCustomerId(customerId); entity.setWarehouseId(warehouseId); - entity.setZoneCode(request.zoneCode()); entity.setLocationCode(request.locationCode()); entity.setLocationType(request.locationType()); entity.setMaxLoadKg(request.maxLoadKg()); diff --git a/warehouse-overseas-service/src/main/resources/db/warehouse.sql b/warehouse-overseas-service/src/main/resources/db/warehouse.sql index 874e1a9c9..f406d6f29 100644 --- a/warehouse-overseas-service/src/main/resources/db/warehouse.sql +++ b/warehouse-overseas-service/src/main/resources/db/warehouse.sql @@ -9,7 +9,6 @@ CREATE TABLE IF NOT EXISTS wh_location ( id BIGINT UNSIGNED NOT NULL COMMENT '库位ID(雪花ID)', customer_id BIGINT UNSIGNED NOT NULL COMMENT '数据所属租户ID', warehouse_id BIGINT UNSIGNED NOT NULL COMMENT '所属仓库ID', - zone_code VARCHAR(50) NOT NULL COMMENT '仓库分区编码', location_code VARCHAR(64) NOT NULL COMMENT '仓库内唯一库位编码', location_type VARCHAR(32) NOT NULL COMMENT '库位类型', shared_overflow TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否系统共享溢出库位(A0)', @@ -24,9 +23,17 @@ CREATE TABLE IF NOT EXISTS wh_location ( version INT NOT NULL DEFAULT 0 COMMENT '乐观锁版本号', PRIMARY KEY (id), UNIQUE KEY uk_location_code (customer_id, warehouse_id, location_code, deleted), - KEY idx_location_query (customer_id, warehouse_id, zone_code, status, deleted) + KEY idx_location_query (customer_id, warehouse_id, status, deleted) ) ENGINE=InnoDB COMMENT='仓库库位表:按租户和仓库维护库位及承重信息'; +-- Remove the retired zone concept from installations created by the previous schema. +SET @ddl = (SELECT IF(EXISTS (SELECT 1 FROM information_schema.statistics WHERE table_schema=DATABASE() AND table_name='wh_location' AND index_name='idx_location_query'), 'ALTER TABLE wh_location DROP INDEX idx_location_query', 'SELECT 1')); +PREPARE location_zone_index_stmt FROM @ddl; EXECUTE location_zone_index_stmt; DEALLOCATE PREPARE location_zone_index_stmt; +SET @ddl = (SELECT IF(EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema=DATABASE() AND table_name='wh_location' AND column_name='zone_code'), 'ALTER TABLE wh_location DROP COLUMN zone_code', 'SELECT 1')); +PREPARE location_zone_column_stmt FROM @ddl; EXECUTE location_zone_column_stmt; DEALLOCATE PREPARE location_zone_column_stmt; + + + CREATE TABLE IF NOT EXISTS wh_pallet ( id BIGINT UNSIGNED NOT NULL COMMENT '托盘ID(雪花ID)', customer_id BIGINT UNSIGNED NOT NULL COMMENT '数据所属租户ID', @@ -97,7 +104,6 @@ ALTER TABLE wh_location MODIFY COLUMN id BIGINT UNSIGNED NOT NULL COMMENT '库位ID(雪花ID)', MODIFY COLUMN customer_id BIGINT UNSIGNED NOT NULL COMMENT '数据所属租户ID', MODIFY COLUMN warehouse_id BIGINT UNSIGNED NOT NULL COMMENT '所属仓库ID', - MODIFY COLUMN zone_code VARCHAR(50) NOT NULL COMMENT '仓库分区编码', MODIFY COLUMN location_code VARCHAR(64) NOT NULL COMMENT '仓库内唯一库位编码', MODIFY COLUMN location_type VARCHAR(32) NOT NULL COMMENT '库位类型', MODIFY COLUMN shared_overflow TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否系统共享溢出库位(A0)', diff --git a/warehouse-overseas-service/src/test/java/com/baiyue/warehouse/service/WarehouseResourceServiceTest.java b/warehouse-overseas-service/src/test/java/com/baiyue/warehouse/service/WarehouseResourceServiceTest.java index d89161f7c..fa6f46a7b 100644 --- a/warehouse-overseas-service/src/test/java/com/baiyue/warehouse/service/WarehouseResourceServiceTest.java +++ b/warehouse-overseas-service/src/test/java/com/baiyue/warehouse/service/WarehouseResourceServiceTest.java @@ -243,7 +243,7 @@ class WarehouseResourceServiceTest { } private static LocationRequests.SaveRequest locationRequest(String code) { - return new LocationRequests.SaveRequest("A", code, "STORAGE", + return new LocationRequests.SaveRequest(code, "STORAGE", new BigDecimal("1000.000"), "ACTIVE", null); }