feat(lastleg): expose inbound PDA work instructions
This commit is contained in:
+9
@@ -26,6 +26,7 @@ public class InboundPalletAssignmentController {
|
||||
@PathVariable String planNo, @PathVariable long planPalletId,
|
||||
@RequestParam(required = false) String customerId,
|
||||
@Valid @RequestBody PdaRequests.Assign request) {
|
||||
requireOperate(user);
|
||||
service.assign(scope(user, customerId), planNo, planPalletId, request);
|
||||
return ApiResponse.success(null);
|
||||
}
|
||||
@@ -40,4 +41,12 @@ public class InboundPalletAssignmentController {
|
||||
}
|
||||
return String.valueOf(user.tenantId());
|
||||
}
|
||||
|
||||
private void requireOperate(AuthenticatedUser user) {
|
||||
if (user == null || user.tenantId() == null) throw new ResponseStatusException(HttpStatus.UNAUTHORIZED);
|
||||
if (user.permissions() == null || !user.permissions().contains(InboundPdaController.OPERATE_PERMISSION)) {
|
||||
throw new ResponseStatusException(HttpStatus.FORBIDDEN,
|
||||
InboundPdaController.OPERATE_PERMISSION + " permission is required");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+13
-1
@@ -10,7 +10,19 @@ public final class PdaResponses {
|
||||
public record Task(long taskId, String taskNo, String planNo, String status,
|
||||
LocalDateTime pushedAt, LocalDateTime startedAt, LocalDateTime completedAt,
|
||||
List<Long> unloadPhotoFileIds, LocalDateTime unloadPhotoUploadedAt,
|
||||
LocalDateTime estimatedEmptyReturnAt) {}
|
||||
LocalDateTime estimatedEmptyReturnAt,
|
||||
List<Pallet> pallets, List<Allocation> allocations) {}
|
||||
|
||||
public record Pallet(long planPalletId, String palletNo, String destinationWarehouseId,
|
||||
String destinationWarehouseCode, String destinationWarehouseName,
|
||||
long warehousePalletId, long warehouseLocationId,
|
||||
String assignmentStatus, int actualPackageCount) {}
|
||||
|
||||
public record Allocation(long allocationId, long lineId, long planPalletId,
|
||||
long orderId, String inboundCode, String fbaWarehouseCode,
|
||||
int requiredPackageCount, int plannedPackageCount,
|
||||
int countedPackageCount, int pickedPackageCount,
|
||||
String status, int version) {}
|
||||
|
||||
public record UnloadPhotoFile(long fileId, String fileName, String contentType, long sizeBytes) {}
|
||||
|
||||
|
||||
+22
-1
@@ -629,9 +629,30 @@ public class InboundPdaWorkflowService {
|
||||
}
|
||||
|
||||
private PdaResponses.Task task(InboundPdaTask task, String planNo) {
|
||||
List<InboundPlanPallet> planPallets = repository.pallets(task.getPlanId());
|
||||
List<InboundPlanPalletAllocation> planAllocations = repository.allocations(task.getPlanId());
|
||||
Map<Long, InboundPlanLine> lines = repository.lines(task.getPlanId()).stream()
|
||||
.collect(java.util.stream.Collectors.toMap(InboundPlanLine::getId, value -> value));
|
||||
List<PdaResponses.Pallet> pallets = planPallets.stream().map(value -> new PdaResponses.Pallet(
|
||||
value.getId(), value.getPalletNo(), value.getDestinationWarehouseId(),
|
||||
value.getDestinationWarehouseCode(), value.getDestinationWarehouseName(),
|
||||
Objects.requireNonNullElse(value.getWarehousePalletId(), 0L),
|
||||
Objects.requireNonNullElse(value.getWarehouseLocationId(), 0L),
|
||||
value.getAssignmentStatus(), InboundPdaWorkflowService.value(value.getActualPackageCount()))).toList();
|
||||
List<PdaResponses.Allocation> allocations = planAllocations.stream().map(value -> {
|
||||
InboundPlanLine line = lines.get(value.getLineId());
|
||||
if (line == null) throw conflict("Inbound allocation line is missing");
|
||||
return new PdaResponses.Allocation(value.getId(), value.getLineId(), value.getPalletId(),
|
||||
line.getOrderId(), line.getInboundCode(), line.getFbaWarehouseCode(),
|
||||
InboundPdaWorkflowService.value(line.getRequiredPackageCount()),
|
||||
InboundPdaWorkflowService.value(value.getPlannedPackageCount()),
|
||||
InboundPdaWorkflowService.value(value.getCountedPackageCount()),
|
||||
InboundPdaWorkflowService.value(value.getPickedPackageCount()), value.getStatus(),
|
||||
InboundPdaWorkflowService.value(value.getVersion()));
|
||||
}).toList();
|
||||
return new PdaResponses.Task(task.getId(), task.getTaskNo(), planNo, task.getStatus(),
|
||||
task.getPushedAt(), task.getStartedAt(), task.getCompletedAt(), unloadPhotoFileIds(task),
|
||||
task.getUnloadPhotoUploadedAt(), task.getEstimatedEmptyReturnAt());
|
||||
task.getUnloadPhotoUploadedAt(), task.getEstimatedEmptyReturnAt(), pallets, allocations);
|
||||
}
|
||||
|
||||
private List<Long> unloadPhotoFileIds(InboundPdaTask task) {
|
||||
|
||||
Reference in New Issue
Block a user