提交
This commit is contained in:
+6
@@ -451,6 +451,11 @@ public class InboundPdaWorkflowService {
|
||||
InboundPdaOperation replay = replay(customerId, "PARTIAL_COMPLETE", request.idempotencyKey(), request);
|
||||
if (replay != null) return read(replay, PdaResponses.Task.class);
|
||||
InboundPdaTask task = requireActiveTask(customerId, plan);
|
||||
List<Long> unloadPhotoFileIds = unloadPhotoFileIds(task);
|
||||
if (unloadPhotoFileIds.isEmpty() || task.getUnloadPhotoUploadedAt() == null
|
||||
|| task.getEstimatedEmptyReturnAt() == null) {
|
||||
throw conflict("Upload unload photos before partially completing the PDA inbound task");
|
||||
}
|
||||
List<InboundPlanLine> lines = repository.lines(plan.getId());
|
||||
List<InboundPlanPalletAllocation> allocations = repository.allocations(plan.getId());
|
||||
int expected = lines.stream().mapToInt(line -> value(line.getRequiredPackageCount())).sum();
|
||||
@@ -468,6 +473,7 @@ public class InboundPdaWorkflowService {
|
||||
task.setStatus("PARTIAL_INBOUND"); task.setCompletedAt(now); task.setUpdatedAt(now);
|
||||
task.setVersion(value(task.getVersion()) + 1); repository.update(task);
|
||||
plan.setStatus("PARTIAL_INBOUND"); plan.setUpdatedAt(now); repository.update(plan);
|
||||
unloadCompletedOutbox.publish(plan, task, unloadPhotoFileIds);
|
||||
PdaResponses.Task result = taskResponse(task, plan, planNo);
|
||||
saveOperation(customerId, task.getId(), null, "PARTIAL_COMPLETE", request.idempotencyKey(), request, result);
|
||||
return result;
|
||||
|
||||
+13
-10
@@ -72,7 +72,7 @@ public class InboundStockReceiptService {
|
||||
.filter(Objects::nonNull).collect(Collectors.toSet());
|
||||
if (receivedAllocationIds.equals(expectedAllocationIds)) {
|
||||
if (!allowPartial) activateDropship(customerId, task.getId(), orderById, existing);
|
||||
if (!allowPartial) completeOrders(customerId, plan, orderById, receivedAt);
|
||||
completeOrders(customerId, plan, orderById, receivedAt, allowPartial);
|
||||
return;
|
||||
}
|
||||
throw conflict("PDA stock-in receipts are incomplete; repair the task receipts before retrying");
|
||||
@@ -109,29 +109,32 @@ public class InboundStockReceiptService {
|
||||
throw conflict("Inbound SKU package snapshots were not fully received");
|
||||
}
|
||||
}
|
||||
if (!allowPartial) {
|
||||
activateDropship(customerId, task.getId(), orderById, created);
|
||||
completeOrders(customerId, plan, orderById, receivedAt);
|
||||
}
|
||||
if (!allowPartial) activateDropship(customerId, task.getId(), orderById, created);
|
||||
completeOrders(customerId, plan, orderById, receivedAt, allowPartial);
|
||||
}
|
||||
|
||||
private void completeOrders(String customerId, InboundPlan plan, Map<Long, LastlegOrder> orderById,
|
||||
LocalDateTime completedAt) {
|
||||
LocalDateTime completedAt, boolean partial) {
|
||||
String subOrderStatus = partial ? "INBOUND_PLAN:PARTIAL_INBOUND" : "INBOUND_PLAN:COMPLETED";
|
||||
for (LastlegOrder snapshot : orderById.values()) {
|
||||
LastlegOrder order = orders.lockById(customerId, snapshot.getId());
|
||||
if (order == null) throw conflict("Inbound tail-leg order disappeared while completing stock-in");
|
||||
if ("INBOUND_COMPLETED".equals(order.getCurrentStatus())) continue;
|
||||
if ("INBOUND_COMPLETED".equals(order.getCurrentStatus())
|
||||
&& subOrderStatus.equals(order.getSubOrderStatus())) continue;
|
||||
String before = order.getCurrentStatus();
|
||||
order.setCurrentStatus("INBOUND_COMPLETED");
|
||||
order.setSubOrderStatus("INBOUND_PLAN:COMPLETED");
|
||||
order.setSubOrderStatus(subOrderStatus);
|
||||
order.setUpdatedAt(completedAt);
|
||||
orders.updateById(order);
|
||||
LastlegOrderStatusHistory history = new LastlegOrderStatusHistory();
|
||||
history.setOrderId(order.getId());
|
||||
history.setFromStatus(before);
|
||||
history.setToStatus("INBOUND_COMPLETED");
|
||||
history.setEventId("PDA_INBOUND_COMPLETE:" + plan.getPlanNo());
|
||||
history.setRemark("PDA inbound completed and inventory stocked in");
|
||||
history.setEventId((partial ? "PDA_PARTIAL_INBOUND_COMPLETE:" : "PDA_INBOUND_COMPLETE:")
|
||||
+ plan.getPlanNo());
|
||||
history.setRemark(partial
|
||||
? "PDA inbound partially completed and actual inventory stocked in"
|
||||
: "PDA inbound completed and inventory stocked in");
|
||||
history.setCreatedAt(completedAt);
|
||||
orderHistories.insert(history);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user