贴标申请,仓储转运

This commit is contained in:
2026-10-08 15:55:47 +08:00
parent e09f8785e1
commit 16d2d9111a
160 changed files with 5704 additions and 4799 deletions
@@ -108,7 +108,8 @@ public class PdaPalletOperationService {
PalletPhysicalGateway.PalletReference pallet = physical.resolve(carton.getPalletCode());
if (pallet == null || pallet.warehouseId() != identity.overseasWarehouseId())
throw conflict("退货换标来源托盘不属于当前仓库");
long quantity = value(carton.getTotalQuantity());
long quantity = entry.getValue().stream().anyMatch(item -> "RETURN_BULK_SKU_LABEL".equals(item.getOperationType()))
? value(carton.getTotalQuantity()) : 1;
result.add(new PalletOperationResponses.RelabelSource(carton.getId(), 0L,
pallet.palletId(), pallet.palletCode(), null, carton.getSourceBatchNo(), quantity, quantity,
entry.getValue().stream().map(RelabelItem::getCartonMark).filter(Objects::nonNull).toList()));
@@ -159,11 +160,12 @@ public class PdaPalletOperationService {
String fbaValue = destination == null ? pallet.fbaWarehouseCode() : destination;
String fba = HtmlUtils.htmlEscape(fbaValue == null ? "" : fbaValue);
if (fba == null || fba.isBlank()) fba = "待绑定";
String html = "<!doctype html><html><head><meta charset=\"UTF-8\"><title>" + code
+ "</title><style>@page{size:100mm 70mm;margin:4mm}body{font-family:Arial,sans-serif;text-align:center;margin:0}"
+ "h1{font-size:24px;margin:8mm 0 4mm;letter-spacing:0}.code{font-size:18px;font-weight:700;word-break:break-all}"
+ ".ref{font-size:12px;margin-top:6mm}</style></head><body><h1>托盘标签</h1><div class=\"code\">"
+ code + "</div><div class=\"ref\">换标单:" + order + "<br>FBA目的仓:" + fba + "</div></body></html>";
String html = "<!doctype html><html><head><meta charset=\"UTF-8\"><title>托盘标签 " + code
+ "</title><style>@page{size:100mm 70mm;margin:0}*{box-sizing:border-box}body{width:100mm;height:70mm;margin:0;padding:6mm 8mm;display:flex;flex-direction:column;align-items:center;justify-content:center;font-family:Arial,'Microsoft YaHei',sans-serif;text-align:center;color:#111}"
+ ".code{max-width:84mm;font-size:14px;font-weight:700;line-height:1.15;overflow-wrap:anywhere}.ref{max-width:84mm;font-size:9px;line-height:1.35;margin-top:3mm;overflow-wrap:anywhere}</style></head><body><div class=\"code\">"
+ code + "</div><div style=\"width:76mm;margin-top:3mm\">"
+ com.baiyue.lastleg.returnreceipt.service.ReturnCartonBarcode.svg(pallet.palletCode())
+ "</div><div class=\"ref\">" + order + "<br>" + fba + "</div></body></html>";
return new PalletOperationResponses.PrintablePallet(pallet.palletId(), pallet.palletCode(), pallet.version(),
relabelNo, html);
}
@@ -335,7 +337,8 @@ public class PdaPalletOperationService {
String requestHash = hash(request);
PdaPalletOperation operation = begin(identity, "RELABEL_PALLET_DISASSEMBLE", key, requestHash);
if ("COMPLETED".equals(operation.getStatus())) return read(operation).asReplay();
physical.apply(identity.overseasWarehouseId(), target, "OCCUPIED", target.locationId(), key, "退货换标组托");
var transition = physical.apply(identity.overseasWarehouseId(), target, "OCCUPIED", target.locationId(), key, "退货换标组托");
try {
return transaction.execute(status -> {
for (int index = 0; index < cartons.size(); index++) {
RelabelItem item = selected.get(index);
@@ -345,7 +348,8 @@ public class PdaPalletOperationService {
|| !Objects.equals(carton.getRelabelApplicationId(), application.getId())
|| !"RELABEL_PENDING".equals(carton.getStatus()))
throw conflict("退货换标来源库存已变化,请刷新后重试");
long move = value(item.getNotifiedPackageCount());
long move = "RETURN_BULK_SKU_LABEL".equals(item.getOperationType())
? value(item.getNotifiedPackageCount()) : value(carton.getTotalQuantity());
if (move <= 0 || move > value(carton.getTotalQuantity())) throw conflict("来源托盘可拆数量不足");
if (move < value(carton.getTotalQuantity())) {
splitReturnRelabelCarton(application, item, carton, target, move);
@@ -367,6 +371,11 @@ public class PdaPalletOperationService {
operation.setUpdatedAt(result.completedAt()); mapper.updateById(operation);
return result;
});
} catch (RuntimeException failure) {
try { physical.compensate(identity.overseasWarehouseId(), transition); }
catch (RuntimeException compensationFailure) { failure.addSuppressed(compensationFailure); }
throw failure;
}
}
/** Keep the unlabelled remainder on its original pallet; move only the confirmed SKU pieces. */