优化
This commit is contained in:
@@ -19,6 +19,6 @@ public interface IamCustomerSnapshotClient {
|
||||
@RequestParam(value = "status", required = false) String status,
|
||||
@RequestParam(value = "customerId", required = false) Long customerId);
|
||||
|
||||
record Customer(long id, String tenantCode, String tenantName, String status,
|
||||
record Customer(long id, String tenantCode, String tenantName, String customerNickname, String status,
|
||||
String contactName, String contactPhone) {}
|
||||
}
|
||||
|
||||
@@ -54,11 +54,16 @@ public interface PrintPdfClient {
|
||||
record DropshipPalletA4PdfRequest(String templateCode, PageSpec pageSpec,
|
||||
String downloadFileName, List<DropshipPalletDocument> documents) {}
|
||||
|
||||
record DropshipPalletDocument(String palletNo, String inboundCodes, int cartonCount,
|
||||
int skuCount, BigDecimal weightKg, BigDecimal volumeCbm,
|
||||
String barcodeContent, List<DropshipPalletSkuRow> skuRows) {}
|
||||
record DropshipPalletDocument(String palletNo, String destinationWarehouse,
|
||||
int palletSequence, int totalPallets,
|
||||
String barcodeContent,
|
||||
List<DropshipPalletInboundRow> inboundRows,
|
||||
List<DropshipPalletSkuRow> skuRows) {}
|
||||
|
||||
record DropshipPalletSkuRow(String inboundCode, String skuCode, String cargoName,
|
||||
int cartonCount, int skuQuantity) {}
|
||||
record DropshipPalletInboundRow(String inboundCode, String customerNickname,
|
||||
int cartonCount, int itemQuantity) {}
|
||||
|
||||
record DropshipPalletSkuRow(String skuCode, int cartonCount,
|
||||
int itemQuantity, String unitsPerCarton) {}
|
||||
|
||||
}
|
||||
|
||||
@@ -203,6 +203,58 @@ public interface DropshipPalletizationMapper {
|
||||
JOIN fl_inbound_order o ON o.id=c.inbound_id AND o.tenant_id=c.tenant_id
|
||||
WHERE c.pallet_id=#{palletId}""")
|
||||
PalletMetrics metrics(@Param("palletId") long palletId);
|
||||
|
||||
@Select("""
|
||||
SELECT c.tenant_id,c.inbound_id,o.inbound_code,
|
||||
COALESCE(NULLIF(o.destination_name,''),NULLIF(o.destination_code,''),'—') destination_warehouse,
|
||||
COUNT(DISTINCT c.id) carton_count,
|
||||
SUM(COALESCE(q.item_quantity,c.actual_sku_quantity,0)) item_quantity
|
||||
FROM fl_dropship_pallet_carton c
|
||||
JOIN fl_inbound_order o ON o.id=c.inbound_id AND o.tenant_id=c.tenant_id
|
||||
LEFT JOIN (SELECT carton_id,SUM(actual_quantity) item_quantity
|
||||
FROM fl_dropship_pallet_carton_sku GROUP BY carton_id) q ON q.carton_id=c.id
|
||||
WHERE c.pallet_id=#{palletId}
|
||||
GROUP BY c.tenant_id,c.inbound_id,o.inbound_code,o.destination_name,o.destination_code
|
||||
UNION ALL
|
||||
SELECT p.tenant_id,p.inbound_id,o.inbound_code,
|
||||
COALESCE(NULLIF(o.destination_name,''),NULLIF(o.destination_code,''),'—') destination_warehouse,
|
||||
0 carton_count,0 item_quantity
|
||||
FROM fl_dropship_pallet p
|
||||
JOIN fl_inbound_order o ON o.id=p.inbound_id AND o.tenant_id=p.tenant_id
|
||||
WHERE p.id=#{palletId}
|
||||
AND NOT EXISTS(SELECT 1 FROM fl_dropship_pallet_carton c WHERE c.pallet_id=p.id)
|
||||
ORDER BY inbound_code
|
||||
""")
|
||||
List<PrintInboundRow> printInboundRows(@Param("palletId") long palletId);
|
||||
|
||||
@Select("""
|
||||
SELECT sku_code,COUNT(DISTINCT carton_id) carton_count,SUM(item_quantity) item_quantity,
|
||||
MIN(item_quantity) min_units_per_carton,MAX(item_quantity) max_units_per_carton
|
||||
FROM (
|
||||
SELECT c.id carton_id,s.sku_code,SUM(s.actual_quantity) item_quantity
|
||||
FROM fl_dropship_pallet_carton c
|
||||
JOIN fl_dropship_pallet_carton_sku s ON s.carton_id=c.id
|
||||
WHERE c.pallet_id=#{palletId}
|
||||
GROUP BY c.id,s.sku_code
|
||||
UNION ALL
|
||||
SELECT c.id carton_id,c.sku_code,c.actual_sku_quantity item_quantity
|
||||
FROM fl_dropship_pallet_carton c
|
||||
WHERE c.pallet_id=#{palletId}
|
||||
AND NOT EXISTS(SELECT 1 FROM fl_dropship_pallet_carton_sku s WHERE s.carton_id=c.id)
|
||||
) pallet_sku
|
||||
GROUP BY sku_code ORDER BY sku_code
|
||||
""")
|
||||
List<PrintSkuRow> printSkuRows(@Param("palletId") long palletId);
|
||||
|
||||
@Select("""
|
||||
SELECT (SELECT COUNT(*) FROM fl_dropship_pallet listed
|
||||
WHERE listed.task_id=target.task_id AND listed.id<=target.id) sequence_no,
|
||||
(SELECT COUNT(*) FROM fl_dropship_pallet listed
|
||||
WHERE listed.task_id=target.task_id) total
|
||||
FROM fl_dropship_pallet target
|
||||
WHERE target.id=#{palletId}
|
||||
""")
|
||||
PalletPosition palletPosition(@Param("palletId") long palletId);
|
||||
@Select("""
|
||||
SELECT p.id pallet_id,p.pallet_no,'SEALED_PALLET' unit_type,TRUE indivisible,COUNT(DISTINCT c.id) carton_count,
|
||||
(SELECT COUNT(DISTINCT sku.sku_code) FROM fl_dropship_pallet_carton pc
|
||||
@@ -244,5 +296,8 @@ public interface DropshipPalletizationMapper {
|
||||
@Getter @Setter class CartonRow { private Long id,taskId,palletId,inboundId,inboundDetailId; private String palletNo,inboundCode,skuCode,cargoName,boxCode,discrepancyStatus,discrepancyRemark; private Integer expectedSkuQuantity,actualSkuQuantity; }
|
||||
@Getter @Setter class CartonSkuRow { private Long inboundDetailId; private String skuCode,cargoName,discrepancyStatus,discrepancyRemark; private Integer expectedQuantity,actualQuantity,lineNo; }
|
||||
record PalletMetrics(BigDecimal weightKg,BigDecimal volumeCbm) {}
|
||||
@Getter @Setter class PrintInboundRow { private Long tenantId,inboundId; private String inboundCode,destinationWarehouse; private Integer cartonCount,itemQuantity; }
|
||||
@Getter @Setter class PrintSkuRow { private String skuCode; private Integer cartonCount,itemQuantity,minUnitsPerCarton,maxUnitsPerCarton; }
|
||||
record PalletPosition(int sequenceNo,int total) {}
|
||||
@Getter @Setter class PalletLine { private Long palletId,tenantId,accountId,inboundId,orderId,warehouseId,destinationWarehouseId,inboundDetailId; private String palletNo,palletStatus,orderNo,inboundCode,channelCode,channelName,destinationWarehouseCode,destinationWarehouseName,customerName,skuCode,cargoName; private Integer cartonCount,actualSkuQuantity; private BigDecimal unitGrossWeightKg,unitNetWeightKg,unitVolumeCbm; }
|
||||
}
|
||||
|
||||
@@ -35,4 +35,21 @@ public class IamCustomerSnapshotService {
|
||||
throw new BizException(ResultCode.SERVICE_UNAVAILABLE, "客户主数据服务暂不可用");
|
||||
}
|
||||
}
|
||||
|
||||
public String customerNickname(long customerId) {
|
||||
try {
|
||||
var response = client.page(internalToken, 1, 2, null, null, customerId);
|
||||
if (response == null || !response.successful() || response.data() == null
|
||||
|| response.data().records() == null || response.data().records().size() != 1) {
|
||||
throw new BizException(ResultCode.CONFLICT, "客户昵称不存在,请先完善客户资料");
|
||||
}
|
||||
var customer = response.data().records().get(0);
|
||||
if (customer.id() != customerId || !StringUtils.hasText(customer.customerNickname())) {
|
||||
throw new BizException(ResultCode.CONFLICT, "客户昵称不存在,请先完善客户资料");
|
||||
}
|
||||
return customer.customerNickname().trim();
|
||||
} catch (FeignException exception) {
|
||||
throw new BizException(ResultCode.SERVICE_UNAVAILABLE, "客户主数据服务暂不可用");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+43
-13
@@ -5,9 +5,11 @@ import com.baiyue.common.core.api.ResultCode;
|
||||
import com.baiyue.common.core.exception.BizException;
|
||||
import com.baiyue.firstleg.client.PrintPdfClient;
|
||||
import com.baiyue.firstleg.dto.InboundCartonLabels;
|
||||
import com.baiyue.firstleg.mapper.DropshipPalletizationMapper;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import feign.FeignException;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.client.circuitbreaker.NoFallbackAvailableException;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
@@ -19,6 +21,9 @@ import org.springframework.util.StringUtils;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import com.baiyue.firstleg.dto.DropshipPalletizationDtos.Pallet;
|
||||
|
||||
/** Allocates stable carton codes and forwards immutable label facts to Print. */
|
||||
@@ -34,6 +39,8 @@ public class InboundCartonLabelPrintService {
|
||||
private final InboundCartonLabelService labelService;
|
||||
private final PrintPdfClient printClient;
|
||||
private final ObjectMapper objectMapper;
|
||||
@Resource private DropshipPalletizationMapper palletizationMapper;
|
||||
@Resource private IamCustomerSnapshotService customerSnapshots;
|
||||
|
||||
@Value("${baiyue.security.internal-service-token}")
|
||||
private String internalToken;
|
||||
@@ -115,7 +122,7 @@ public class InboundCartonLabelPrintService {
|
||||
return ResponseEntity.status(response.getStatusCode()).headers(headers).body(response.getBody());
|
||||
}
|
||||
|
||||
/** 一件代发 A4 托盘信息单:托盘号、Code 128 一维码和 SKU 归托明细。 */
|
||||
/** 一件代发 A4 托盘信息单:托盘、目的仓、入仓码和 SKU 汇总。 */
|
||||
public ResponseEntity<byte[]> generateDropshipPallet(Pallet pallet, String inboundCode, String requestId) {
|
||||
return generateDropshipPallets(List.of(pallet), inboundCode, requestId);
|
||||
}
|
||||
@@ -125,13 +132,14 @@ public class InboundCartonLabelPrintService {
|
||||
if (pallets == null || pallets.isEmpty()) {
|
||||
throw new BizException(ResultCode.CONFLICT, "托盘码尚未生成,不能打印");
|
||||
}
|
||||
Map<Long, String> customerNicknameCache = new HashMap<>();
|
||||
List<PrintPdfClient.DropshipPalletDocument> documents = pallets.stream()
|
||||
.map(pallet -> dropshipPalletDocument(pallet, inboundCode)).toList();
|
||||
.map(pallet -> dropshipPalletDocument(pallet, customerNicknameCache)).toList();
|
||||
String fileName = pallets.size() == 1
|
||||
? pallets.get(0).palletNo() + "-A4托盘信息单.pdf"
|
||||
: inboundCode + "-" + pallets.size() + "托-A4托盘信息单.pdf";
|
||||
PrintPdfClient.DropshipPalletA4PdfRequest request = new PrintPdfClient.DropshipPalletA4PdfRequest(
|
||||
"DROPSHIP_PALLET_A4_V1", new PrintPdfClient.PageSpec(A4_WIDTH_MM, A4_HEIGHT_MM),
|
||||
"DROPSHIP_PALLET_A4_V2", new PrintPdfClient.PageSpec(A4_WIDTH_MM, A4_HEIGHT_MM),
|
||||
fileName, documents);
|
||||
try {
|
||||
return requirePdf(printClient.generateDropshipPalletA4Documents(internalToken, requestId, request));
|
||||
@@ -140,20 +148,42 @@ public class InboundCartonLabelPrintService {
|
||||
}
|
||||
}
|
||||
|
||||
private PrintPdfClient.DropshipPalletDocument dropshipPalletDocument(Pallet pallet, String inboundCode) {
|
||||
if (pallet == null || !StringUtils.hasText(pallet.palletNo())) {
|
||||
private PrintPdfClient.DropshipPalletDocument dropshipPalletDocument(
|
||||
Pallet pallet, Map<Long, String> customerNicknameCache) {
|
||||
if (pallet == null || pallet.palletId() == null || !StringUtils.hasText(pallet.palletNo())) {
|
||||
throw new BizException(ResultCode.CONFLICT, "托盘码尚未生成,不能打印");
|
||||
}
|
||||
String inboundCodes = pallet.items().stream().map(item -> item.inboundCode())
|
||||
.filter(StringUtils::hasText).distinct().collect(java.util.stream.Collectors.joining("/"));
|
||||
if (!StringUtils.hasText(inboundCodes)) inboundCodes = inboundCode;
|
||||
List<PrintPdfClient.DropshipPalletSkuRow> skuRows = pallet.items().stream()
|
||||
.map(item -> new PrintPdfClient.DropshipPalletSkuRow(item.inboundCode(), item.skuCode(),
|
||||
item.cargoName(), number(item.cartonCount()), number(item.skuQuantity())))
|
||||
List<DropshipPalletizationMapper.PrintInboundRow> inboundFacts =
|
||||
palletizationMapper.printInboundRows(pallet.palletId());
|
||||
if (inboundFacts == null || inboundFacts.isEmpty()) {
|
||||
throw new BizException(ResultCode.CONFLICT, "托盘未关联入仓单,不能打印");
|
||||
}
|
||||
List<PrintPdfClient.DropshipPalletInboundRow> inboundRows = inboundFacts.stream()
|
||||
.map(row -> new PrintPdfClient.DropshipPalletInboundRow(
|
||||
row.getInboundCode(),
|
||||
customerNicknameCache.computeIfAbsent(row.getTenantId(), customerSnapshots::customerNickname),
|
||||
number(row.getCartonCount()), number(row.getItemQuantity())))
|
||||
.toList();
|
||||
String destinationWarehouse = inboundFacts.stream()
|
||||
.map(DropshipPalletizationMapper.PrintInboundRow::getDestinationWarehouse)
|
||||
.filter(StringUtils::hasText).distinct().collect(Collectors.joining(" / "));
|
||||
if (!StringUtils.hasText(destinationWarehouse)) destinationWarehouse = "—";
|
||||
List<PrintPdfClient.DropshipPalletSkuRow> skuRows = palletizationMapper.printSkuRows(pallet.palletId())
|
||||
.stream().map(row -> new PrintPdfClient.DropshipPalletSkuRow(
|
||||
row.getSkuCode(), number(row.getCartonCount()), number(row.getItemQuantity()),
|
||||
unitsPerCarton(row))).toList();
|
||||
DropshipPalletizationMapper.PalletPosition position =
|
||||
palletizationMapper.palletPosition(pallet.palletId());
|
||||
return new PrintPdfClient.DropshipPalletDocument(
|
||||
pallet.palletNo(), inboundCodes, number(pallet.cartonCount()), number(pallet.skuCount()),
|
||||
pallet.weightKg(), pallet.volumeCbm(), pallet.palletNo(), skuRows);
|
||||
pallet.palletNo(), destinationWarehouse,
|
||||
position == null ? 1 : position.sequenceNo(), position == null ? 1 : position.total(),
|
||||
pallet.palletNo(), inboundRows, skuRows);
|
||||
}
|
||||
|
||||
private String unitsPerCarton(DropshipPalletizationMapper.PrintSkuRow row) {
|
||||
int min = number(row.getMinUnitsPerCarton());
|
||||
int max = number(row.getMaxUnitsPerCarton());
|
||||
return min == max ? Integer.toString(min) : min + "-" + max;
|
||||
}
|
||||
|
||||
private int number(Integer value) {
|
||||
|
||||
@@ -68,7 +68,7 @@ paths:
|
||||
/api/platform/v1/first-leg/pda-dropship/tasks/{taskId}/pallets/{palletId}/print:
|
||||
get:
|
||||
summary: PDA 获取预生成托盘码的 A4 托盘信息单
|
||||
description: 测量审核通过并生成托盘码后即可获取;每个托盘固定一页 A4,包含托盘号及其 Code 128 一维码、入仓码、箱数以及已归托 SKU、商品名称和实点数量,不展示作业状态。空托显示暂无已归托 SKU。仅当前仓库、当前操作员可访问。
|
||||
description: 测量审核通过并生成托盘码后即可获取;每个托盘固定一页 A4,包含托盘号及其 Code 128 一维码、目的仓、托盘序号、入仓码/客户昵称/箱数/件数汇总以及 SKU/箱数/件数/每箱件数汇总,不展示作业状态、重量或体积。空托显示暂无已归托 SKU。仅当前仓库、当前操作员可访问。
|
||||
x-required-authority: platform:firstleg:pda:view
|
||||
parameters:
|
||||
- {$ref: '#/components/parameters/TaskId'}
|
||||
@@ -91,7 +91,7 @@ paths:
|
||||
responses: {'200': {description: OK}}
|
||||
/api/platform/v1/first-leg/pda-dropship/inbound-orders/{inboundId}/pallets/{palletId}/print:
|
||||
get:
|
||||
summary: 获取包含托盘码、入仓码和 SKU 实收汇总的 A4 托盘信息单
|
||||
summary: 获取包含托盘码、目的仓、入仓码和 SKU 汇总的 A4 托盘信息单
|
||||
x-required-authority: platform:firstleg:inbound:list
|
||||
responses: {'200': {description: PDF}}
|
||||
components:
|
||||
|
||||
+12
-2
@@ -32,7 +32,7 @@ class IamCustomerSnapshotServiceTest {
|
||||
@Test
|
||||
void resolvesExactlyOneActiveCustomerAndUsesServerName() {
|
||||
var customer = new IamCustomerSnapshotClient.Customer(
|
||||
7L, "C-7", "Canonical Customer", "ACTIVE", null, null);
|
||||
7L, "C-7", "Canonical Customer", "Short Name", "ACTIVE", null, null);
|
||||
when(client.page("internal-token", 1, 2, null, "ACTIVE", 7L))
|
||||
.thenReturn(ApiResponse.success(new PageResult<>(List.of(customer), 1, 2, 1, 1)));
|
||||
|
||||
@@ -50,10 +50,20 @@ class IamCustomerSnapshotServiceTest {
|
||||
.isInstanceOf(BizException.class).hasMessageContaining("不存在或未启用");
|
||||
|
||||
var customer = new IamCustomerSnapshotClient.Customer(
|
||||
7L, "C-7", "Canonical Customer", "ACTIVE", null, null);
|
||||
7L, "C-7", "Canonical Customer", "Short Name", "ACTIVE", null, null);
|
||||
when(client.page("internal-token", 1, 2, null, "ACTIVE", 7L))
|
||||
.thenReturn(ApiResponse.success(new PageResult<>(List.of(customer), 1, 2, 1, 1)));
|
||||
assertThatThrownBy(() -> service.active(7L, "Forged Customer"))
|
||||
.isInstanceOf(BizException.class).hasMessageContaining("不一致");
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolvesCustomerNicknameForPalletDocument() {
|
||||
var customer = new IamCustomerSnapshotClient.Customer(
|
||||
7L, "C-7", "Canonical Customer", " Short Name ", "ACTIVE", null, null);
|
||||
when(client.page("internal-token", 1, 2, null, null, 7L))
|
||||
.thenReturn(ApiResponse.success(new PageResult<>(List.of(customer), 1, 2, 1, 1)));
|
||||
|
||||
assertThat(service.customerNickname(7L)).isEqualTo("Short Name");
|
||||
}
|
||||
}
|
||||
|
||||
+43
-4
@@ -6,6 +6,7 @@ import com.baiyue.firstleg.client.PrintPdfClient;
|
||||
import com.baiyue.firstleg.dto.InboundCartonLabels;
|
||||
import com.baiyue.firstleg.dto.DropshipPalletizationDtos.Pallet;
|
||||
import com.baiyue.firstleg.dto.DropshipPalletizationDtos.SkuItem;
|
||||
import com.baiyue.firstleg.mapper.DropshipPalletizationMapper;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -29,17 +30,22 @@ import static org.mockito.Mockito.when;
|
||||
class InboundCartonLabelPrintServiceTest {
|
||||
private final InboundCartonLabelService labels = mock(InboundCartonLabelService.class);
|
||||
private final PrintPdfClient print = mock(PrintPdfClient.class);
|
||||
private final DropshipPalletizationMapper palletization = mock(DropshipPalletizationMapper.class);
|
||||
private final IamCustomerSnapshotService customerSnapshots = mock(IamCustomerSnapshotService.class);
|
||||
private InboundCartonLabelPrintService service;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
service = new InboundCartonLabelPrintService(labels, print, new ObjectMapper());
|
||||
ReflectionTestUtils.setField(service, "internalToken", "internal-token");
|
||||
ReflectionTestUtils.setField(service, "palletizationMapper", palletization);
|
||||
ReflectionTestUtils.setField(service, "customerSnapshots", customerSnapshots);
|
||||
}
|
||||
|
||||
@Test
|
||||
void dropshipPalletLabelIsAvailableBeforeSeal() {
|
||||
Pallet open = dropshipPallet("OPEN");
|
||||
stubPalletFacts(90001L, 1, 2);
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_PDF);
|
||||
when(print.generateDropshipPalletA4Documents(org.mockito.ArgumentMatchers.anyString(),
|
||||
@@ -54,17 +60,25 @@ class InboundCartonLabelPrintServiceTest {
|
||||
ArgumentCaptor.forClass(PrintPdfClient.DropshipPalletA4PdfRequest.class);
|
||||
verify(print).generateDropshipPalletA4Documents(org.mockito.ArgumentMatchers.eq("internal-token"),
|
||||
org.mockito.ArgumentMatchers.eq("request-open"), request.capture());
|
||||
assertThat(request.getValue().templateCode()).isEqualTo("DROPSHIP_PALLET_A4_V1");
|
||||
assertThat(request.getValue().templateCode()).isEqualTo("DROPSHIP_PALLET_A4_V2");
|
||||
assertThat(request.getValue().pageSpec().widthMm()).isEqualByComparingTo("210");
|
||||
assertThat(request.getValue().pageSpec().heightMm()).isEqualByComparingTo("297");
|
||||
assertThat(request.getValue().documents()).singleElement().satisfies(document -> {
|
||||
assertThat(document.palletNo()).isEqualTo("DP-260911-0001");
|
||||
assertThat(document.inboundCodes()).isEqualTo("PCHK2608040174");
|
||||
assertThat(document.destinationWarehouse()).isEqualTo("纽约 N.JDF");
|
||||
assertThat(document.palletSequence()).isEqualTo(1);
|
||||
assertThat(document.totalPallets()).isEqualTo(2);
|
||||
assertThat(document.inboundRows()).singleElement().satisfies(row -> {
|
||||
assertThat(row.inboundCode()).isEqualTo("PCHK2608040174");
|
||||
assertThat(row.customerNickname()).isEqualTo("小虫科技");
|
||||
assertThat(row.cartonCount()).isEqualTo(1);
|
||||
assertThat(row.itemQuantity()).isEqualTo(19);
|
||||
});
|
||||
assertThat(document.skuRows()).singleElement().satisfies(row -> {
|
||||
assertThat(row.skuCode()).isEqualTo("SKU-1");
|
||||
assertThat(row.cargoName()).isEqualTo("音箱");
|
||||
assertThat(row.cartonCount()).isEqualTo(1);
|
||||
assertThat(row.skuQuantity()).isEqualTo(19);
|
||||
assertThat(row.itemQuantity()).isEqualTo(19);
|
||||
assertThat(row.unitsPerCarton()).isEqualTo("19");
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -74,6 +88,8 @@ class InboundCartonLabelPrintServiceTest {
|
||||
Pallet first = dropshipPallet("OPEN");
|
||||
Pallet second = new Pallet(90002L, "DP-260911-0002", "OPEN", 0, 0, 0,
|
||||
BigDecimal.ZERO, BigDecimal.ZERO, 1, List.of(), List.of(), null);
|
||||
stubPalletFacts(90001L, 1, 2);
|
||||
stubPalletFacts(90002L, 2, 2);
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_PDF);
|
||||
when(print.generateDropshipPalletA4Documents(org.mockito.ArgumentMatchers.anyString(),
|
||||
@@ -225,4 +241,27 @@ class InboundCartonLabelPrintServiceTest {
|
||||
return new Pallet(90001L, "DP-260911-0001", status, 1, 1, 0,
|
||||
BigDecimal.ONE, BigDecimal.ONE, 1, List.of(item), List.of(), null);
|
||||
}
|
||||
|
||||
private void stubPalletFacts(long palletId, int sequence, int total) {
|
||||
DropshipPalletizationMapper.PrintInboundRow inbound =
|
||||
new DropshipPalletizationMapper.PrintInboundRow();
|
||||
inbound.setTenantId(10001L);
|
||||
inbound.setInboundId(70001L);
|
||||
inbound.setInboundCode("PCHK2608040174");
|
||||
inbound.setDestinationWarehouse("纽约 N.JDF");
|
||||
inbound.setCartonCount(palletId == 90001L ? 1 : 0);
|
||||
inbound.setItemQuantity(palletId == 90001L ? 19 : 0);
|
||||
when(palletization.printInboundRows(palletId)).thenReturn(List.of(inbound));
|
||||
DropshipPalletizationMapper.PrintSkuRow sku = new DropshipPalletizationMapper.PrintSkuRow();
|
||||
sku.setSkuCode("SKU-1");
|
||||
sku.setCartonCount(1);
|
||||
sku.setItemQuantity(19);
|
||||
sku.setMinUnitsPerCarton(19);
|
||||
sku.setMaxUnitsPerCarton(19);
|
||||
when(palletization.printSkuRows(palletId))
|
||||
.thenReturn(palletId == 90001L ? List.of(sku) : List.of());
|
||||
when(palletization.palletPosition(palletId))
|
||||
.thenReturn(new DropshipPalletizationMapper.PalletPosition(sequence, total));
|
||||
when(customerSnapshots.customerNickname(10001L)).thenReturn("小虫科技");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user