This commit is contained in:
2026-10-16 11:41:24 +08:00
parent 4e2ea89403
commit 5855529e97
59 changed files with 1077 additions and 110 deletions
@@ -18,8 +18,6 @@ import org.springframework.transaction.annotation.Transactional;
import jakarta.annotation.Resource;
import java.util.Set;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import org.springframework.util.StringUtils;
@Service
@@ -448,11 +446,7 @@ public class WarehouseResourceService {
}
private static String generatedPalletCode(String warehouseCode, long palletId) {
String compactWarehouseCode = warehouseCode.replaceAll("[^A-Za-z0-9]", "").toUpperCase(java.util.Locale.ROOT);
if (compactWarehouseCode.length() > 9) compactWarehouseCode = compactWarehouseCode.substring(0, 9);
return "PLT-" + compactWarehouseCode + "-"
+ LocalDate.now().format(DateTimeFormatter.ofPattern("yyMMdd")) + "-"
+ Long.toUnsignedString(palletId, 36).toUpperCase(java.util.Locale.ROOT);
return "TP-" + Long.toUnsignedString(palletId, 36).toUpperCase(java.util.Locale.ROOT);
}
private static String defaultLocationCode(String warehouseCode) {
@@ -262,7 +262,7 @@ class WarehouseResourceServiceTest {
ArgumentCaptor<WarehousePalletEntity> captor = ArgumentCaptor.forClass(WarehousePalletEntity.class);
verify(repository).insertPallet(captor.capture());
assertThat(captor.getValue().getPalletCode()).matches("PLT-USLAX01-[0-9]{6}-[0-9A-Z]+");
assertThat(captor.getValue().getPalletCode()).matches("TP-[0-9A-Z]+");
assertThat(captor.getValue().getPalletCode()).hasSizeLessThanOrEqualTo(34);
assertThat(captor.getValue().getLocationId()).isEqualTo(30003L);
assertThat(captor.getValue().getId()).isNotNull();