贴标申请,仓储转运
This commit is contained in:
-12
@@ -58,18 +58,6 @@ class ReturnOutboundPdaPersistenceTest {
|
||||
for (Class<?> mapper : List.of(OutboundOrderMapper.class, OutboundPalletItemMapper.class,
|
||||
OutboundPdaTaskMapper.class, OutboundPdaPickMapper.class, DeliveryOrderMapper.class, ReturnInventoryCartonMapper.class,
|
||||
ReturnInventoryCartonItemMapper.class, ReturnInventoryBalanceMapper.class, ReturnInventoryMovementMapper.class)) configuration.addMapper(mapper);
|
||||
// H2 does not implement MySQL charset/collation expressions. Preserve the real
|
||||
// movement query and bindings, removing only those expressions in this H2 fixture.
|
||||
for (String method : List.of("platformCount", "platformPage")) {
|
||||
var statement = configuration.getMappedStatement(ReturnInventoryMovementMapper.class.getName() + "." + method);
|
||||
var mysqlSource = statement.getSqlSource();
|
||||
org.apache.ibatis.mapping.SqlSource h2Source = params -> {
|
||||
var bound = mysqlSource.getBoundSql(params);
|
||||
String sql = bound.getSql().replaceAll("CONVERT\\(([^()]+) USING utf8mb4\\) COLLATE utf8mb4_unicode_ci", "$1");
|
||||
return new org.apache.ibatis.mapping.BoundSql(configuration, sql, bound.getParameterMappings(), params);
|
||||
};
|
||||
ReflectionTestUtils.setField(statement, "sqlSource", h2Source);
|
||||
}
|
||||
var factory = new MybatisSqlSessionFactoryBean(); factory.setDataSource(ds); factory.setConfiguration(configuration);
|
||||
var session = new SqlSessionTemplate(factory.getObject());
|
||||
movementMapper = session.getMapper(ReturnInventoryMovementMapper.class);
|
||||
|
||||
+32
-9
@@ -6,24 +6,46 @@ import org.apache.ibatis.session.Configuration;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Map;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
class ReturnInventoryMovementSqlTest {
|
||||
@Test
|
||||
void everyUnionBranchNormalizesAllSixTextColumns() {
|
||||
String[] branches = ReturnInventoryMovementMapper.MOVEMENTS.split("UNION ALL");
|
||||
assertEquals(7, branches.length);
|
||||
for (String branch : branches) {
|
||||
String projection = branch.substring(0, branch.indexOf("FROM"));
|
||||
assertEquals(6, projection.split("COLLATE utf8mb4_unicode_ci", -1).length - 1, branch);
|
||||
assertEquals(6, projection.split("USING utf8mb4", -1).length - 1, branch);
|
||||
void unionSourceColumnsHaveExplicitMatchingCollationsInBothBaselinesAndMigration() throws Exception {
|
||||
Map<String, List<String>> fields = Map.of(
|
||||
"ll_return_order", List.of("customer_id", "overseas_warehouse_id"),
|
||||
"ll_return_order_item", List.of("sku_code", "product_name_zh"),
|
||||
"ll_return_receipt", List.of("receipt_no"),
|
||||
"ll_return_receipt_item", List.of("sku_code"),
|
||||
"ll_return_inventory_carton", List.of("customer_id", "overseas_warehouse_id", "carton_mark"),
|
||||
"ll_return_inventory_carton_item", List.of("sku_code", "product_name_zh"),
|
||||
"ll_return_inventory_outbound_movement", List.of("customer_id", "overseas_warehouse_id", "sku_code", "product_name_zh", "outbound_no"),
|
||||
"ll_return_sku_conversion", List.of("customer_id", "overseas_warehouse_id", "old_sku_code", "new_sku_code", "product_name_zh", "relabel_no"));
|
||||
for (Path file : List.of(Path.of("src/main/resources/db/lastleg.sql"),
|
||||
Path.of("../deploy/sql/海外区域统一增量-MySQL8.sql"),
|
||||
Path.of("../deploy/sql/migrations/overseas/baiyue_lastleg/V23__align_return_movement_collation.sql"))) {
|
||||
String sql = Files.readString(file);
|
||||
for (var entry : fields.entrySet()) {
|
||||
var block = Pattern.compile("(?s)(?:CREATE TABLE (?:IF NOT EXISTS )?|ALTER TABLE )" + entry.getKey() + "\\b.*?;").matcher(sql);
|
||||
assertTrue(block.find(), file + ": " + entry.getKey());
|
||||
for (String column : entry.getValue()) {
|
||||
assertTrue(Pattern.compile("(?i)\\b" + column + "\\s+varchar\\(\\d+\\) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci").matcher(block.group()).find(),
|
||||
file + ": " + entry.getKey() + "." + column);
|
||||
}
|
||||
}
|
||||
}
|
||||
String standalone = Files.readString(Path.of("src/main/resources/db/return-sku-conversion.sql"));
|
||||
for (String column : fields.get("ll_return_sku_conversion"))
|
||||
assertTrue(Pattern.compile("\\b" + column + "\\s+VARCHAR\\(\\d+\\) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci").matcher(standalone).find());
|
||||
}
|
||||
|
||||
@Test
|
||||
void countAndPageShareNormalizedProjectionAndKeepScopeFilters() {
|
||||
void countAndPageKeepOriginalProjectionAndScopeFilters() {
|
||||
Configuration configuration = new Configuration();
|
||||
new MapperAnnotationBuilder(configuration, ReturnInventoryMovementMapper.class).parse();
|
||||
Map<String, Object> params = Map.of("customerId", "CUSTOMER", "warehouseId", "WAREHOUSE",
|
||||
@@ -32,7 +54,8 @@ class ReturnInventoryMovementSqlTest {
|
||||
var boundSql = configuration.getMappedStatement(ReturnInventoryMovementMapper.class.getName() + "." + method)
|
||||
.getBoundSql(params);
|
||||
String sql = boundSql.getSql();
|
||||
assertEquals(42, sql.split("COLLATE utf8mb4_unicode_ci", -1).length - 1);
|
||||
assertEquals(7, sql.split("UNION ALL", -1).length);
|
||||
assertTrue(!sql.contains("CONVERT("));
|
||||
assertTrue(sql.contains("m.customerId=?"));
|
||||
assertTrue(sql.contains("m.overseasWarehouseId=?"));
|
||||
assertTrue(sql.contains("m.skuCode LIKE CONCAT('%',?,'%')"));
|
||||
|
||||
Reference in New Issue
Block a user