fix: preserve hold binding replays
This commit is contained in:
+8
-8
@@ -32,7 +32,6 @@ public class LoadingModelBridgeService {
|
||||
resourceId = "#loadingPlanId", description = "关联入库预装与柜次装柜计划")
|
||||
public Link bind(long tenantId, long inboundId, long loadingPlanId, long operatorId,
|
||||
String operatorName, String idempotencyKey, BindRequest request) {
|
||||
inboundHoldGuard.requireInboundNotHeld(tenantId, inboundId);
|
||||
String key = validateKey(idempotencyKey);
|
||||
String requestHash = hash(tenantId + "|" + inboundId + "|" + loadingPlanId + "|"
|
||||
+ request.expectedPreloadVersion() + "|" + request.expectedLoadingPlanVersion());
|
||||
@@ -44,6 +43,7 @@ public class LoadingModelBridgeService {
|
||||
if (repository.byPair(tenantId, inboundId, loadingPlanId) != null) {
|
||||
return requireLink(tenantId, inboundId, loadingPlanId);
|
||||
}
|
||||
inboundHoldGuard.requireInboundNotHeld(tenantId, inboundId);
|
||||
|
||||
var preload = repository.preload(tenantId, inboundId);
|
||||
if (preload == null) throw new BizException(ResultCode.NOT_FOUND, "入库单预装计划不存在");
|
||||
@@ -80,7 +80,6 @@ public class LoadingModelBridgeService {
|
||||
@Transactional
|
||||
public List<Link> bindAllocatedBeforeLoading(long loadingPlanId, long operatorId,
|
||||
String operatorName, String orchestrationKey) {
|
||||
inboundHoldGuard.requirePlanNotHeld(loadingPlanId);
|
||||
var loadingPlan = repository.loadingPlan(loadingPlanId);
|
||||
if (loadingPlan == null) throw new BizException(ResultCode.NOT_FOUND, "柜次装柜计划不存在");
|
||||
List<AllocationScope> scopes = repository.allocatedScopes(loadingPlanId);
|
||||
@@ -89,14 +88,15 @@ public class LoadingModelBridgeService {
|
||||
&& scopes.stream().anyMatch(scope -> !"WAIT_SPLIT".equals(scope.processStatus()))) {
|
||||
throw conflict("装柜清单仍有订单未完成审核和测量,不能开始PDA作业");
|
||||
}
|
||||
boolean allLinked = scopes.stream().allMatch(scope -> repository.byPair(
|
||||
scope.tenantId(), scope.inboundId(), loadingPlanId) != null);
|
||||
if (Set.of("EDITING", "LOADING", "COMPLETED").contains(loadingPlan.status()) && allLinked) {
|
||||
return repository.byLoadingPlan(loadingPlanId);
|
||||
}
|
||||
if (!"EDITING".equals(loadingPlan.status())) {
|
||||
if (Set.of("LOADING", "COMPLETED").contains(loadingPlan.status())
|
||||
&& scopes.stream().allMatch(scope -> repository.byPair(
|
||||
scope.tenantId(), scope.inboundId(), loadingPlanId) != null)) {
|
||||
return repository.byLoadingPlan(loadingPlanId);
|
||||
}
|
||||
throw conflict("PDA开始前的预装关联不完整,禁止在LOADING后补关联");
|
||||
}
|
||||
inboundHoldGuard.requirePlanNotHeld(loadingPlanId);
|
||||
for (AllocationScope scope : scopes) {
|
||||
// Internal push replay is pair-idempotent: an existing association has
|
||||
// already advanced both versions, so calling public bind again would
|
||||
@@ -121,8 +121,8 @@ public class LoadingModelBridgeService {
|
||||
@Transactional
|
||||
public void bindIncrementalAllocation(long loadingPlanId, long tenantId, long inboundId,
|
||||
long operatorId, String operatorName, String operationId) {
|
||||
inboundHoldGuard.requireInboundNotHeld(tenantId, inboundId);
|
||||
if (repository.byPair(tenantId, inboundId, loadingPlanId) != null) return;
|
||||
inboundHoldGuard.requireInboundNotHeld(tenantId, inboundId);
|
||||
var plan = repository.loadingPlan(loadingPlanId);
|
||||
if (plan == null) throw new BizException(ResultCode.NOT_FOUND, "柜次装柜计划不存在");
|
||||
if (!Set.of("EDITING", "LOADING").contains(plan.status())) {
|
||||
|
||||
Reference in New Issue
Block a user