优化
This commit is contained in:
+1
-2
@@ -134,8 +134,7 @@ public class LoadingModelBridgeService {
|
||||
var preload = repository.preload(tenantId, inboundId);
|
||||
if (preload == null) throw new BizException(ResultCode.NOT_FOUND, "入库单预装计划不存在");
|
||||
boolean running = "LOADING".equals(plan.status());
|
||||
if (!Set.of("PENDING", "CONFIRMED").contains(preload.status())
|
||||
&& !(running && "CONFIRMING".equals(preload.status()))) {
|
||||
if (!Set.of("PENDING", "CONFIRMING", "CONFIRMED").contains(preload.status())) {
|
||||
throw conflict("新增入库单预装状态不允许进入当前柜次");
|
||||
}
|
||||
PreloadLoadingPlanLinkEntity link = new PreloadLoadingPlanLinkEntity();
|
||||
|
||||
@@ -82,8 +82,8 @@ public class SplitPreloadService {
|
||||
}
|
||||
PreloadPlanEntity plan = repository.findPlan(tenantId, inboundId);
|
||||
if (plan != null) {
|
||||
if (!PreloadStatus.PENDING.equals(plan.getStatus())) {
|
||||
throw new BizException(ResultCode.CONFLICT, "预装计划已进入确认流程,不能修改智能装柜分配");
|
||||
if (!reusableForLoadingAllocation(plan.getStatus())) {
|
||||
throw new BizException(ResultCode.CONFLICT, "预装计划当前状态不能修改智能装柜分配");
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -96,17 +96,13 @@ public class SplitPreloadService {
|
||||
repository.createPlan(plan);
|
||||
} catch (DuplicateKeyException exception) {
|
||||
PreloadPlanEntity concurrent = repository.findPlan(tenantId, inboundId);
|
||||
if (concurrent == null || !PreloadStatus.PENDING.equals(concurrent.getStatus())) {
|
||||
if (concurrent == null || !reusableForLoadingAllocation(concurrent.getStatus())) {
|
||||
throw new BizException(ResultCode.CONFLICT, "预装计划已被并发修改,请刷新后重试");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A running PDA task may restore or add an unpicked allocation after the plan-level preload
|
||||
* confirmation. A running PDA task owns the mutation lock, so CONFIRMING and CONFIRMED
|
||||
* lifecycles may be reused while the restored loading item is synchronised atomically.
|
||||
*/
|
||||
/** Reuses the confirmed preload lifecycle while a running PDA task owns the mutation lock. */
|
||||
@Transactional
|
||||
public void ensureForRunningLoadingAllocation(long tenantId, long inboundId, long operatorId,
|
||||
String operatorName) {
|
||||
@@ -126,10 +122,8 @@ public class SplitPreloadService {
|
||||
throw new BizException(ResultCode.CONFLICT, "装柜中的订单缺少既有预装计划,不能新增分配");
|
||||
}
|
||||
if (plan != null) {
|
||||
if (!PreloadStatus.PENDING.equals(plan.getStatus())
|
||||
&& !(running && Set.of(PreloadStatus.CONFIRMING, PreloadStatus.CONFIRMED)
|
||||
.contains(plan.getStatus()))) {
|
||||
throw new BizException(ResultCode.CONFLICT, "预装计划已进入确认流程,不能修改智能装柜分配");
|
||||
if (!reusableForLoadingAllocation(plan.getStatus())) {
|
||||
throw new BizException(ResultCode.CONFLICT, "预装计划当前状态不能修改智能装柜分配");
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -142,12 +136,17 @@ public class SplitPreloadService {
|
||||
repository.createPlan(plan);
|
||||
} catch (DuplicateKeyException exception) {
|
||||
PreloadPlanEntity concurrent = repository.findPlan(tenantId, inboundId);
|
||||
if (concurrent == null || !PreloadStatus.PENDING.equals(concurrent.getStatus())) {
|
||||
if (concurrent == null || !reusableForLoadingAllocation(concurrent.getStatus())) {
|
||||
throw new BizException(ResultCode.CONFLICT, "预装计划已被并发修改,请刷新后重试");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean reusableForLoadingAllocation(String status) {
|
||||
return Set.of(PreloadStatus.PENDING, PreloadStatus.CONFIRMING, PreloadStatus.CONFIRMED)
|
||||
.contains(status);
|
||||
}
|
||||
|
||||
public PreloadPlanResponse detail(long tenantId, long inboundId) {
|
||||
requireInbound(tenantId, inboundId);
|
||||
return response(requirePlan(tenantId, inboundId));
|
||||
|
||||
Reference in New Issue
Block a user