fix(lastleg): expose dispatch reviews and filter available capacity offers
This commit is contained in:
+13
-1
@@ -15,10 +15,22 @@ public final class DispatchRequests {
|
||||
}
|
||||
|
||||
public record Query(@Min(1) long page, @Min(1) @Max(200) long size, String dispatchNo,
|
||||
String vehiclePlate, String status, String fbaAppointmentNo) {
|
||||
String vehiclePlate, String status, String fbaAppointmentNo, Stage stage) {
|
||||
public Query { if (page == 0) page = 1; if (size == 0) size = 20; }
|
||||
}
|
||||
|
||||
public enum Stage {
|
||||
BEFORE_LOADING, LOADING, AFTER_LOADING, CANCELLED;
|
||||
public List<String> statuses() {
|
||||
return switch (this) {
|
||||
case BEFORE_LOADING -> List.of("PENDING_DEPARTURE");
|
||||
case LOADING -> List.of("PICKING", "READY_TO_DEPART", "PARTIAL_READY_TO_DEPART");
|
||||
case AFTER_LOADING -> List.of("DEPARTED", "PARTIAL_DEPARTED");
|
||||
case CANCELLED -> List.of("CANCELLED");
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public record PreArrange(@Size(max = 500) List<@NotNull Long> planPalletIds,
|
||||
@Size(max = 64) String fbaAppointmentNo,
|
||||
@Size(max = 32) String fbaAppointmentStatus,
|
||||
|
||||
@@ -12,7 +12,7 @@ public record DispatchResponse(Long id, String dispatchNo, String vehiclePlate,
|
||||
int itemCount, int palletCount, int packageCount, int pickedPackageCount,
|
||||
int shippedPackageCount, int remainingPackageCount, String partialCompletionReason,
|
||||
LocalDateTime createdAt,
|
||||
List<Item> items, List<BolLine> bolLines) {
|
||||
List<Item> items, List<BolLine> bolLines, com.baiyue.lastleg.fleet.trip.FleetDispatchWorkflowQuery.Workflow workflow) {
|
||||
public record Item(Long id, Long planPalletId, Long warehousePalletId, String palletNo,
|
||||
String overseasWarehouseId, String overseasWarehouseName,
|
||||
String orderNo, String orderRefs, String inboundCode, String destinationWarehouseCode,
|
||||
|
||||
+13
-2
@@ -75,6 +75,7 @@ public class DispatchService {
|
||||
@Resource private LastlegOrderMapper tailOrders;
|
||||
@Resource private OutboundOrderMapper outboundOrders;
|
||||
@Resource private FleetDispatchBindingGuard fleetBindings;
|
||||
@Resource private com.baiyue.lastleg.fleet.trip.FleetDispatchWorkflowQuery fleetWorkflow;
|
||||
@Resource private RelabelApplicationMapper relabelApplications;
|
||||
@Resource private com.baiyue.lastleg.relabel.service.RelabelBindingGuard relabelBindingGuard;
|
||||
|
||||
@@ -623,11 +624,16 @@ public class DispatchService {
|
||||
.like(StringUtils.hasText(query.dispatchNo()), DispatchOrder::getDispatchNo, query.dispatchNo())
|
||||
.like(StringUtils.hasText(query.vehiclePlate()), DispatchOrder::getVehiclePlate, query.vehiclePlate())
|
||||
.eq(StringUtils.hasText(query.status()), DispatchOrder::getStatus, query.status())
|
||||
.in(query.stage() != null, DispatchOrder::getStatus,
|
||||
query.stage() == null ? List.of() : query.stage().statuses())
|
||||
.like(StringUtils.hasText(query.fbaAppointmentNo()), DispatchOrder::getFbaAppointmentNo,
|
||||
query.fbaAppointmentNo())
|
||||
.orderByDesc(DispatchOrder::getCreatedAt));
|
||||
var workflows = acrossCustomers ? fleetWorkflow.read(page.getRecords().stream()
|
||||
.map(DispatchOrder::getDispatchNo).toList()) : java.util.Map.<String, com.baiyue.lastleg.fleet.trip.FleetDispatchWorkflowQuery.Workflow>of();
|
||||
List<DispatchResponse> records = page.getRecords().stream()
|
||||
.map(order -> response(order, items.findByDispatchOrder(order.getCustomerId(), order.getId()))).toList();
|
||||
.map(order -> response(order, items.findByDispatchOrder(order.getCustomerId(), order.getId()),
|
||||
List.of(), workflows.get(order.getDispatchNo()))).toList();
|
||||
return new PageResult<>(records, page.getCurrent(), page.getSize(), page.getTotal(), page.getPages());
|
||||
}
|
||||
|
||||
@@ -764,6 +770,11 @@ public class DispatchService {
|
||||
|
||||
private DispatchResponse response(DispatchOrder order, List<DispatchItem> itemList,
|
||||
List<DispatchResponse.BolLine> bolLineList) {
|
||||
return response(order, itemList, bolLineList, null);
|
||||
}
|
||||
|
||||
private DispatchResponse response(DispatchOrder order, List<DispatchItem> itemList,
|
||||
List<DispatchResponse.BolLine> bolLineList, com.baiyue.lastleg.fleet.trip.FleetDispatchWorkflowQuery.Workflow workflow) {
|
||||
String orderNos = itemList.stream().flatMap(item -> splitOrderRefs(item.getOrderRefs(), item.getOrderNo()).stream())
|
||||
.distinct().collect(Collectors.joining(","));
|
||||
return new DispatchResponse(order.getId(), order.getDispatchNo(), order.getVehiclePlate(), order.getDriverName(),
|
||||
@@ -782,7 +793,7 @@ public class DispatchService {
|
||||
item.getDestinationWarehouseCode(), item.getDestinationWarehouseName(), item.getFbaWarehouseCode(),
|
||||
Objects.requireNonNullElse(item.getPackageCount(), 0), item.getGrossWeightKg(),
|
||||
item.getVolumeWeightKg(), item.getVolumeCbm(), item.getSourceStage())).toList(),
|
||||
bolLineList == null ? List.of() : bolLineList);
|
||||
bolLineList == null ? List.of() : bolLineList, workflow);
|
||||
}
|
||||
|
||||
private static String candidateRoute(List<DispatchPalletCandidate> selected) {
|
||||
|
||||
Reference in New Issue
Block a user