feat(warehouse-overseas): reserve inbound pallet batches

This commit is contained in:
2026-09-08 23:52:36 +08:00
parent 4c1e9aa714
commit a88a04fd24
22 changed files with 1227 additions and 6 deletions
@@ -29,7 +29,7 @@ class SchemaChineseCommentContractTest {
Path.of("..", "scripts", "db", "incremental.sql"), StandardCharsets.UTF_8);
List<TableDefinition> tables = parseAndAssert(baseline, "仓储基线 SQL");
assertEquals(5, tables.size(), "海外仓资源表数量变化时必须同步表索引和备注迁移");
assertEquals(7, tables.size(), "海外仓资源表数量变化时必须同步表索引和备注迁移");
assertFalse(baseline.contains("CREATE TABLE IF NOT EXISTS wh_warehouse ("));
assertFalse(baseline.contains("CREATE TABLE IF NOT EXISTS wh_warehouse_address ("));
assertFalse(baseline.contains("CREATE TABLE IF NOT EXISTS wh_service_capability ("));
@@ -39,6 +39,10 @@ class SchemaChineseCommentContractTest {
assertTrue(marker >= 0, "统一增量 SQL 缺少 025 中文备注迁移");
String migration = incremental.substring(marker);
for (TableDefinition table : tables) {
if (Pattern.compile("(?is)CREATE\\s+TABLE\\s+IF\\s+NOT\\s+EXISTS\\s+" + table.name() + "\\b")
.matcher(migration).find()) {
continue;
}
assertTrue(migration.contains("table_name='" + table.name() + "'"),
"025 备注迁移缺少表: " + table.name());
for (String column : table.columns()) {
@@ -0,0 +1,44 @@
package com.baiyue.warehouse.schema;
import org.junit.jupiter.api.Test;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import static org.assertj.core.api.Assertions.assertThat;
class WarehousePalletBatchContractTest {
@Test
void baselineAndUnifiedIncrementalContainBatchTablesAndCommandHashes() throws Exception {
String baseline = read(Path.of("src", "main", "resources", "db", "warehouse.sql"));
String incremental = read(Path.of("..", "scripts", "db", "incremental.sql"));
String unified = read(Path.of("..", "deploy", "sql", "海外区域统一增量-MySQL8.sql"));
for (String sql : new String[] {baseline, incremental, unified}) {
assertThat(sql).contains("CREATE TABLE IF NOT EXISTS wh_pallet_batch (")
.contains("CREATE TABLE IF NOT EXISTS wh_pallet_batch_item (")
.contains("confirm_command_hash CHAR(64)")
.contains("compensate_command_hash CHAR(64)")
.contains("business_key VARCHAR(100)")
.contains("pallet_code VARCHAR(64)");
}
}
@Test
void internalOpenApiFreezesEnvelopeAndLengthContract() throws Exception {
String yaml = read(Path.of("src", "main", "resources", "openapi",
"warehouse-pallet-batch-internal-v1.yaml"));
assertThat(yaml).contains("/internal/v1/warehouse-pallet-batches/ensure-reserved:")
.contains("/internal/v1/warehouse-pallet-batches/confirm:")
.contains("/internal/v1/warehouse-pallet-batches/compensate:")
.contains("业务冲突仍为HTTP 200且响应体code=A0409")
.contains("businessKey: { type: string, minLength: 1, maxLength: 100 }")
.contains("palletCode: { type: string, maxLength: 64 }")
.doesNotContain("'409':");
}
private static String read(Path path) throws Exception {
return Files.readString(path, StandardCharsets.UTF_8);
}
}