fix(firstleg): finalize loading before customs acceptance

This commit is contained in:
2026-08-24 12:52:23 +08:00
parent 4377a7acd9
commit 92dbeb1676
7 changed files with 41 additions and 10 deletions
@@ -298,6 +298,12 @@ public class SmartLoadingService {
LoadingPlanItemEntity item = repository.item(planId, itemId);
if (item == null) throw new BizException(ResultCode.NOT_FOUND, "装柜明细不存在");
if (!Objects.equals(item.getVersion(), request.expectedItemVersion())) throw conflict("装柜明细版本冲突");
LoadingPickService.MutationSnapshot pickSnapshot = loadingPickService.mutationSnapshot(planId);
int pickedPackageCount = pickSnapshot == null ? 0
: pickSnapshot.pickedByPlanItem().getOrDefault(itemId, 0);
if (request.packageCount() < pickedPackageCount) {
throw conflict("计划箱数不能低于已拣货箱数");
}
ContainerBookingEntity booking = requireBooking(plan.getContainerBookingId());
Candidate candidate = repository.candidate(booking.getWarehouseId(), item.getInboundId(), item.getInboundDetailId());
if (candidate == null || request.packageCount() > candidate.availablePackageCount() + item.getPackageCount()) throw validation("调整箱数超过可用箱数");