贴标申请,仓储转运

This commit is contained in:
2026-10-12 18:01:16 +08:00
parent c06e788b0f
commit 46507e41c6
17 changed files with 214 additions and 16 deletions
@@ -25,7 +25,14 @@ public final class PalletOperationResponses {
String palletCode, String status, int palletVersion,
@JsonSerialize(using = ToStringSerializer.class) Long locationId,
String locationCode, String destinationWarehouseCode,
long totalPackages, List<InventoryLine> inventory) { }
long totalPackages, List<InventoryLine> inventory,
java.math.BigDecimal grossWeightKg, java.math.BigDecimal volumeCbm) {
public PalletContent(long palletId, String palletCode, String status, int palletVersion, Long locationId,
String locationCode, String destinationWarehouseCode, long totalPackages, List<InventoryLine> inventory) {
this(palletId, palletCode, status, palletVersion, locationId, locationCode, destinationWarehouseCode,
totalPackages, inventory, null, null);
}
}
public record PrintablePallet(@JsonSerialize(using = ToStringSerializer.class) long palletId,
String palletCode, int palletVersion,
String relabelNo, String printableHtml) { }
@@ -316,7 +316,8 @@ public class PdaPalletOperationService {
PalletOperationRequests.RelabelDisassemble request) {
requireRelabelDestination(identity.overseasWarehouseId(), selected, target);
Set<String> alreadyBound = boundRelabelMarks(application);
if (selected.stream().map(RelabelItem::getCartonMark).anyMatch(alreadyBound::contains))
boolean rebind = request.actualSource() == null && selected.stream().allMatch(item -> alreadyBound.contains(item.getCartonMark()));
if (!rebind && selected.stream().map(RelabelItem::getCartonMark).anyMatch(alreadyBound::contains))
throw conflict("退货换标箱已在本轮完成组托,请刷新后重试");
long quantity = 0;
List<ReturnInventoryCarton> cartons = new ArrayList<>();
@@ -330,8 +331,8 @@ public class PdaPalletOperationService {
quantity += value(item.getNotifiedPackageCount());
cartons.add(carton);
}
if (request.actualSource() == null || request.actualSource().positionId() != cartons.get(0).getId()
|| request.actualSource().packages() != quantity)
if (!rebind && (request.actualSource() == null || request.actualSource().positionId() != cartons.get(0).getId()
|| request.actualSource().packages() != quantity))
throw conflict("退货换标拆出数量必须等于本批已完成贴标数量");
String key = required(request.idempotencyKey(), "幂等键不能为空");
String requestHash = hash(request);
@@ -836,6 +837,8 @@ public class PdaPalletOperationService {
Set<String> destinations = new HashSet<>();
selected.forEach(item -> destinations.add(text(item.getDestinationFbaWarehouseCode())));
if (destinations.size() != 1 || destinations.contains("")) throw conflict("请按已维护的新目的仓分批组托");
returnCartons.palletCartons(String.valueOf(warehouseId), target.palletCode())
.forEach(carton -> destinations.add(text(carton.getDestinationWarehouseCode())));
for (PalletInventoryRow row : mapper.content(String.valueOf(warehouseId), target.palletId())) {
var bound = relabelItems.selectList(new com.baomidou.mybatisplus.core.conditions.query.QueryWrapper<RelabelItem>()
.eq("customer_id", row.getCustomerId()).eq("source_inventory_position_id", row.getPositionId()));
@@ -898,10 +901,22 @@ public class PdaPalletOperationService {
value(row.getReceivingPackages()), value(row.getVersion()));
}).toList();
long total = rows.stream().mapToLong(PdaPalletOperationService::rowPackages).sum();
var boxes = returnCartons.palletCartons(String.valueOf(warehouseId), pallet.palletCode());
boxes.forEach(box -> destinations.add(text(box.getDestinationWarehouseCode())));
total += boxes.size();
// Derive totals from current physical bindings, so retries and rebinds cannot double count.
java.math.BigDecimal weight = rows.isEmpty() ? java.math.BigDecimal.ZERO : null;
java.math.BigDecimal volume = rows.isEmpty() ? java.math.BigDecimal.ZERO : null;
for (var box : boxes) {
if (weight != null) weight = box.getWeight() == null || box.getWeight().signum() <= 0 ? null : weight.add(box.getWeight());
if (volume != null) volume = box.getLength() == null || box.getWidth() == null || box.getHeight() == null
|| box.getLength().signum() <= 0 || box.getWidth().signum() <= 0 || box.getHeight().signum() <= 0 ? null
: volume.add(box.getLength().multiply(box.getWidth()).multiply(box.getHeight()).movePointLeft(6));
}
String locationCode = locationCode(warehouseId, pallet.locationId());
return new PalletOperationResponses.PalletContent(pallet.palletId(), pallet.palletCode(), pallet.status(),
pallet.version(), pallet.locationId(), locationCode, destinations.size() == 1 ? destinations.iterator().next() : null,
total, inventory);
total, inventory, weight, volume);
}
private PdaPalletOperation begin(PdaWarehouseIdentity identity, String type, String key, String requestHash) {