优化
This commit is contained in:
+4
-1
@@ -138,7 +138,10 @@ public class DeliveryDocumentService {
|
||||
.eq(LastlegOrder::getCustomerId, delivery.getCustomerId())
|
||||
.eq(LastlegOrder::getDeliveryOrderNo, delivery.getDeliveryNo()));
|
||||
for (LastlegOrder order : completedOrders) {
|
||||
order.setSubOrderStatus("DELIVERY:DELIVERED");
|
||||
// Preserve the outbound leg when receipt completion closes delivery.
|
||||
// Sub-order status is a composite fact; replacing it with DELIVERY alone
|
||||
// makes a successfully departed outbound appear unfinished or disappear.
|
||||
order.setSubOrderStatus("OUTBOUND:OUTBOUNDED;DELIVERY:DELIVERED");
|
||||
order.setUpdatedAt(now);
|
||||
lastlegOrders.updateById(order);
|
||||
}
|
||||
|
||||
+13
@@ -3,6 +3,7 @@ package com.baiyue.lastleg.dispatch.pda.service;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baiyue.lastleg.delivery.entity.OutboundOrder;
|
||||
import com.baiyue.lastleg.delivery.mapper.OutboundOrderMapper;
|
||||
import com.baiyue.lastleg.delivery.mapper.OutboundPalletItemMapper;
|
||||
import com.baiyue.lastleg.dispatch.entity.DispatchItem;
|
||||
import com.baiyue.lastleg.dispatch.entity.DispatchOrder;
|
||||
import com.baiyue.lastleg.dispatch.entity.DispatchPalletLock;
|
||||
@@ -37,6 +38,7 @@ import java.util.stream.Collectors;
|
||||
public class DispatchPdaWorkflowService {
|
||||
@Resource private DispatchOrderMapper orders;
|
||||
@Resource private OutboundOrderMapper outboundOrders;
|
||||
@Resource private OutboundPalletItemMapper outboundPalletItems;
|
||||
@Resource private DispatchItemMapper items;
|
||||
@Resource private DispatchPdaTaskMapper tasks;
|
||||
@Resource private DispatchPdaPickMapper picks;
|
||||
@@ -227,6 +229,17 @@ public class DispatchPdaWorkflowService {
|
||||
long shipped = dispatchPicks.stream().mapToLong(p -> n(p.getPackages())).sum();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
pickAttribution.depart(customerId, outbound.getOutboundNo(), order.getDispatchNo(), dispatchPicks, now);
|
||||
if (outboundPalletItems != null) {
|
||||
for (var outboundItem : outboundPalletItems.findByOutbound(customerId, outbound.getId())) {
|
||||
boolean selected = dispatchItems.stream().anyMatch(item -> Objects.equals(item.getWarehousePalletId(), outboundItem.getWarehousePalletId())
|
||||
&& Objects.equals(item.getInboundCode(), outboundItem.getInboundCode()));
|
||||
if (selected) {
|
||||
outboundItem.setPickedPackageCount(outboundItem.getPackageCount());
|
||||
outboundItem.setStatus("PICKED");
|
||||
outboundPalletItems.updateById(outboundItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (DispatchItem item : dispatchItems) {
|
||||
if (item.getOrderId() != null) warehouseTransfers.markOutboundByOrder(customerId, item.getOrderId(), now);
|
||||
if ("RELABEL_ORDER".equals(item.getSourceBusinessType()) && item.getSourceBusinessNo() != null) {
|
||||
|
||||
+3
@@ -94,6 +94,9 @@ public class DispatchPickOrderAttributionService {
|
||||
if (before == null || orders.transferPickedToShipped(customerId, entry.getKey(), entry.getValue(), outboundNo) != 1) {
|
||||
throw conflict("Tail-leg order picked packages are inconsistent");
|
||||
}
|
||||
if (orders.markDispatchOutbound(customerId, entry.getKey()) != 1) {
|
||||
throw conflict("Tail-leg outbound sub-order status could not be synchronized");
|
||||
}
|
||||
long shipped = value(before.getShippedPackageCount()) + entry.getValue();
|
||||
String to = shipped == value(before.getPackageCount()) ? "COMPLETED" : "PARTIALLY_SHIPPED";
|
||||
LastlegOrderStatusHistory row = new LastlegOrderStatusHistory();
|
||||
|
||||
@@ -230,6 +230,10 @@ public interface LastlegOrderMapper extends BaseMapper<LastlegOrder> {
|
||||
int transferPickedToShipped(@Param("customerId") String customerId, @Param("id") Long id,
|
||||
@Param("packages") long packages, @Param("outboundNo") String outboundNo);
|
||||
|
||||
@Update("UPDATE ll_order SET sub_order_status='OUTBOUND:OUTBOUNDED;DELIVERY:WAIT_DELIVERY',updated_at=NOW() " +
|
||||
"WHERE customer_id=#{customerId} AND id=#{id}")
|
||||
int markDispatchOutbound(@Param("customerId") String customerId, @Param("id") Long id);
|
||||
|
||||
@Update("UPDATE ll_order SET pallet_merge_flag=#{flag}," +
|
||||
"pallet_merge_batch_id=CASE WHEN #{flag} IS NULL THEN NULL ELSE pallet_merge_batch_id END," +
|
||||
"updated_at=#{updatedAt} " +
|
||||
|
||||
+1
-1
@@ -142,7 +142,7 @@ class DeliveryDocumentServiceTest {
|
||||
|
||||
assertThat(order.getStatus()).isEqualTo("DELIVERED");
|
||||
assertThat(order.getSignedAt()).isNotNull();
|
||||
assertThat(related.getSubOrderStatus()).isEqualTo("DELIVERY:DELIVERED");
|
||||
assertThat(related.getSubOrderStatus()).isEqualTo("OUTBOUND:OUTBOUNDED;DELIVERY:DELIVERED");
|
||||
verify(lastlegOrders).updateById(related);
|
||||
verify(deliveryCompletedOutbox).publish(eq(order), eq(List.of(related)), any());
|
||||
verify(customerVisits).ensureForCompletedDelivery(eq(order), any());
|
||||
|
||||
+14
@@ -2,6 +2,8 @@ package com.baiyue.lastleg.dispatch.pda.service;
|
||||
|
||||
import com.baiyue.lastleg.delivery.entity.OutboundOrder;
|
||||
import com.baiyue.lastleg.delivery.mapper.OutboundOrderMapper;
|
||||
import com.baiyue.lastleg.delivery.mapper.OutboundPalletItemMapper;
|
||||
import com.baiyue.lastleg.delivery.entity.OutboundPalletItem;
|
||||
import com.baiyue.lastleg.dispatch.entity.DispatchItem;
|
||||
import com.baiyue.lastleg.dispatch.entity.DispatchOrder;
|
||||
import com.baiyue.lastleg.dispatch.mapper.DispatchItemMapper;
|
||||
@@ -46,6 +48,7 @@ import static org.mockito.Mockito.when;
|
||||
class DispatchPdaWorkflowServiceTest {
|
||||
@Mock DispatchOrderMapper orders;
|
||||
@Mock OutboundOrderMapper outboundOrders;
|
||||
@Mock OutboundPalletItemMapper outboundPalletItems;
|
||||
@Mock DispatchItemMapper items;
|
||||
@Mock DispatchPdaTaskMapper tasks;
|
||||
@Mock DispatchPdaPickMapper picks;
|
||||
@@ -63,6 +66,7 @@ class DispatchPdaWorkflowServiceTest {
|
||||
objectMapper = new ObjectMapper();
|
||||
ReflectionTestUtils.setField(service, "orders", orders);
|
||||
ReflectionTestUtils.setField(service, "outboundOrders", outboundOrders);
|
||||
ReflectionTestUtils.setField(service, "outboundPalletItems", outboundPalletItems);
|
||||
ReflectionTestUtils.setField(service, "items", items);
|
||||
ReflectionTestUtils.setField(service, "tasks", tasks);
|
||||
ReflectionTestUtils.setField(service, "picks", picks);
|
||||
@@ -114,6 +118,7 @@ class DispatchPdaWorkflowServiceTest {
|
||||
order.setVehiclePlate("CA-100");
|
||||
DispatchPdaTask task = task(11L, "100", "WH-1", "COMPLETED");
|
||||
DispatchItem item = item(21L, "100", 6);
|
||||
item.setInboundCode("IN-1");
|
||||
when(orders.findGlobalByDispatchNo("DSP-1")).thenReturn(order);
|
||||
when(tasks.findByDispatch("100", 1L)).thenReturn(task);
|
||||
when(items.findByDispatchOrder("100", 1L)).thenReturn(List.of(item));
|
||||
@@ -233,9 +238,14 @@ class DispatchPdaWorkflowServiceTest {
|
||||
order.setVehiclePlate("CA-100");
|
||||
DispatchPdaTask task = task(11L, "100", "WH-1", "COMPLETED");
|
||||
DispatchItem item = item(21L, "100", 6);
|
||||
item.setInboundCode("IN-1");
|
||||
DispatchPdaPick pick = new DispatchPdaPick(); pick.setPackages(6L);
|
||||
OutboundOrder outbound = new OutboundOrder();
|
||||
outbound.setId(1L);
|
||||
outbound.setOutboundNo("OB-1"); outbound.setStatus("WAIT_OUTBOUND");
|
||||
OutboundPalletItem outboundItem = new OutboundPalletItem();
|
||||
outboundItem.setWarehousePalletId(41L); outboundItem.setInboundCode("IN-1");
|
||||
outboundItem.setPackageCount(6); outboundItem.setPickedPackageCount(0); outboundItem.setStatus("WAIT_PICK");
|
||||
when(orders.findGlobalByDispatchNo("DSP-1")).thenReturn(order);
|
||||
when(orders.lockById("100", 1L)).thenReturn(order);
|
||||
when(outboundOrders.lockByDispatch("100", 1L)).thenReturn(outbound);
|
||||
@@ -243,6 +253,7 @@ class DispatchPdaWorkflowServiceTest {
|
||||
when(items.findByDispatchOrder("100", 1L)).thenReturn(List.of(item));
|
||||
when(picks.totalItem("100", 11L, 21L)).thenReturn(6L);
|
||||
when(picks.listTask("100", 11L)).thenReturn(List.of(pick));
|
||||
when(outboundPalletItems.findByOutbound("100", 1L)).thenReturn(List.of(outboundItem));
|
||||
when(palletLocks.selectList(any())).thenReturn(List.of());
|
||||
|
||||
DispatchPdaResponses.Departed result = service.depart(
|
||||
@@ -254,6 +265,9 @@ class DispatchPdaWorkflowServiceTest {
|
||||
verify(orders).updateById(order);
|
||||
assertEquals("DEPARTED", order.getStatus());
|
||||
assertEquals("OUTBOUNDED", outbound.getStatus());
|
||||
assertEquals(6, outboundItem.getPickedPackageCount());
|
||||
assertEquals("PICKED", outboundItem.getStatus());
|
||||
verify(outboundPalletItems).updateById(outboundItem);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+1
@@ -70,6 +70,7 @@ class DispatchPickOrderAttributionServiceTest {
|
||||
order.setShippedPackageCount(2); order.setCurrentStatus("INBOUND_COMPLETED");
|
||||
when(orders.lockById("t1", 101L)).thenReturn(order);
|
||||
when(orders.transferPickedToShipped("t1", 101L, 4L, "OUT1")).thenReturn(1);
|
||||
when(orders.markDispatchOutbound("t1", 101L)).thenReturn(1);
|
||||
|
||||
List<DispatchPickOrderAttributionService.OrderPackages> result = service.depart(
|
||||
"t1", "OUT1", "D1", List.of(pick), LocalDateTime.of(2026, 8, 17, 15, 0));
|
||||
|
||||
Reference in New Issue
Block a user