fix(inbound): expose original command for resource confirmation recovery
This commit is contained in:
+1
-1
@@ -86,7 +86,7 @@ public class InboundPlanController {
|
||||
if (user == null || user.tenantId() == null || user.tenantId() != 0L || !"PLATFORM".equals(user.appCode())) {
|
||||
throw new ResponseStatusException(HttpStatus.FORBIDDEN, "仅平台账号可预览整柜入库计划");
|
||||
}
|
||||
return ApiResponse.success(service.previewContainer(sourceContainerBookingId));
|
||||
return ApiResponse.success(containerConversion.preview(sourceContainerBookingId));
|
||||
}
|
||||
|
||||
@GetMapping("/{planNo}")
|
||||
|
||||
+13
-1
@@ -23,8 +23,20 @@ public record ContainerInboundPlanPreviewResponse(
|
||||
int totalSuggestedPalletCount,
|
||||
int totalPlannedPalletCount,
|
||||
boolean ready,
|
||||
List<Group> groups
|
||||
List<Group> groups,
|
||||
ResourceRetry resourceRetry
|
||||
) {
|
||||
/** Original persisted command; distinct from the current display snapshot. */
|
||||
public record ResourceRetry(String idempotencyKey, long snapshotVersion, String snapshotHash) { }
|
||||
|
||||
public ContainerInboundPlanPreviewResponse withResourceRetry(ResourceRetry retry) {
|
||||
return new ContainerInboundPlanPreviewResponse(sourceContainerBookingId, containerNo,
|
||||
overseasWarehouseId, overseasWarehouseCode, overseasWarehouseName, snapshotVersion, snapshotHash,
|
||||
totalOrderCount, readyOrderCount, blockedOrderCount, pendingOrderCount, pendingPalletCount,
|
||||
sourcePalletCount, supplementPalletCount, existingPlannedPalletCount, totalSuggestedPalletCount,
|
||||
totalPlannedPalletCount, ready, groups, retry);
|
||||
}
|
||||
|
||||
public record Group(
|
||||
String destinationType,
|
||||
String destinationWarehouseId,
|
||||
|
||||
+14
@@ -47,6 +47,20 @@ public class ContainerInboundPlanConversionCoordinator {
|
||||
@Resource private ObjectMapper objectMapper;
|
||||
@Resource private PlatformTransactionManager transactionManager;
|
||||
|
||||
@org.springframework.transaction.annotation.Transactional(readOnly = true)
|
||||
public ContainerInboundPlanPreviewResponse preview(String sourceContainerBookingId) {
|
||||
ContainerInboundPlanPreviewResponse current = plans.previewContainer(sourceContainerBookingId);
|
||||
ContainerPlanConversionCommand command = commands.findByBooking(current.sourceContainerBookingId());
|
||||
if (command == null || !"LOCAL_COMMITTED".equals(command.getStatus())) return current;
|
||||
if (trimToNull(command.getIdempotencyKey()) == null || command.getSnapshotVersion() == null
|
||||
|| command.getSnapshotVersion() < 0 || command.getSnapshotHash() == null
|
||||
|| !command.getSnapshotHash().matches("[a-f0-9]{64}")) {
|
||||
throw new ResponseStatusException(HttpStatus.CONFLICT, "原柜级转换命令缺少重试依据,请联系管理员核查");
|
||||
}
|
||||
return current.withResourceRetry(new ContainerInboundPlanPreviewResponse.ResourceRetry(
|
||||
command.getIdempotencyKey(), command.getSnapshotVersion(), command.getSnapshotHash()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves one manually adjusted plan, then materializes every plan in the container as soon as
|
||||
* the last logical plan is complete. The manual endpoint is therefore never a separate pallet
|
||||
|
||||
+1
-1
@@ -270,7 +270,7 @@ public class InboundPlanService {
|
||||
orders.stream().map(ContainerInboundPlanPreviewResponse.Order::suggestedPalletCount)
|
||||
.filter(Objects::nonNull).mapToInt(Integer::intValue).sum(),
|
||||
orders.stream().map(ContainerInboundPlanPreviewResponse.Order::plannedPalletCount)
|
||||
.filter(Objects::nonNull).mapToInt(Integer::intValue).sum(), blocked == 0, groups);
|
||||
.filter(Objects::nonNull).mapToInt(Integer::intValue).sum(), blocked == 0, groups, null);
|
||||
}
|
||||
|
||||
private ContainerInboundPlanPreviewResponse.Order previewOrder(
|
||||
|
||||
@@ -3417,6 +3417,15 @@ components:
|
||||
snapshotVersion: { type: integer, format: int64, minimum: 0 }
|
||||
snapshotHash: { type: string, pattern: '^[0-9a-f]{64}$' }
|
||||
totalOrderCount: { type: integer }
|
||||
resourceRetry:
|
||||
type: object
|
||||
nullable: true
|
||||
description: 仅本地计划已提交而资源确认未完成时返回原命令。重试必须使用此键和快照,当前外层快照仍用于展示;不得重新生成命令或预留第二批资源。
|
||||
required: [idempotencyKey, snapshotVersion, snapshotHash]
|
||||
properties:
|
||||
idempotencyKey: { type: string, minLength: 1, maxLength: 128 }
|
||||
snapshotVersion: { type: integer, format: int64, minimum: 0 }
|
||||
snapshotHash: { type: string, pattern: '^[0-9a-f]{64}$' }
|
||||
readyOrderCount: { type: integer }
|
||||
blockedOrderCount: { type: integer }
|
||||
pendingOrderCount: { type: integer, description: 本次确认将新建计划的 READY 订单数 }
|
||||
|
||||
Reference in New Issue
Block a user