fix(firstleg): allow confirmed preload reassign during loading

This commit is contained in:
2026-08-24 12:34:34 +08:00
parent 2389a63858
commit 4377a7acd9
4 changed files with 38 additions and 3 deletions
@@ -136,8 +136,13 @@ public class SmartLoadingService {
if (candidate == null) throw conflict("入库货物不存在或尚未完成入库");
requireSameChannel(booking, candidate);
requireSameCustomerScope(booking, candidate);
splitPreloadService.ensurePendingForLoadingAllocation(candidate.accountId(), candidate.inboundId(),
operatorId, operatorName);
if ("LOADING".equals(plan.getPlanStatus())) {
splitPreloadService.ensureForRunningLoadingAllocation(candidate.accountId(), candidate.inboundId(),
operatorId, operatorName);
} else {
splitPreloadService.ensurePendingForLoadingAllocation(candidate.accountId(), candidate.inboundId(),
operatorId, operatorName);
}
OrderCargoClient.CargoBinding cargo = loadCargo(candidate);
LoadingPlanItemEntity existing = repository.activeItem(planId, candidate.accountId(), request.inboundDetailId());
int total = request.packageCount() + (existing == null ? 0 : existing.getPackageCount());
@@ -68,11 +68,27 @@ public class SplitPreloadService {
@Transactional
public void ensurePendingForLoadingAllocation(long tenantId, long inboundId, long operatorId,
String operatorName) {
ensureForLoadingAllocation(tenantId, inboundId, operatorId, operatorName, false);
}
/**
* A running loading task may re-add an inbound whose preload was confirmed by an earlier
* incremental allocation. Draft plans must still use the stricter pending-only entry point.
*/
@Transactional
public void ensureForRunningLoadingAllocation(long tenantId, long inboundId, long operatorId,
String operatorName) {
ensureForLoadingAllocation(tenantId, inboundId, operatorId, operatorName, true);
}
private void ensureForLoadingAllocation(long tenantId, long inboundId, long operatorId,
String operatorName, boolean allowConfirmed) {
InboundSnapshot inbound = requireInbound(tenantId, inboundId);
requireWaitingSplit(inbound, "仅待分柜订单可以建立智能装柜预装计划");
PreloadPlanEntity plan = repository.findPlan(tenantId, inboundId);
if (plan != null) {
if (!PreloadStatus.PENDING.equals(plan.getStatus())) {
if (!PreloadStatus.PENDING.equals(plan.getStatus())
&& !(allowConfirmed && PreloadStatus.CONFIRMED.equals(plan.getStatus()))) {
throw new BizException(ResultCode.CONFLICT, "预装计划已进入确认流程,不能修改智能装柜分配");
}
return;