diff --git a/blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/ManageWaybillServiceImpl.java b/blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/ManageWaybillServiceImpl.java index f6ef9920..e47b6357 100644 --- a/blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/ManageWaybillServiceImpl.java +++ b/blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/ManageWaybillServiceImpl.java @@ -124,11 +124,6 @@ public class ManageWaybillServiceImpl implements IManageWaybillService { private static final String SQL_MAX_REJECT_TIME = "MAX(driver_reject_time)"; /** 待重新派单的排序键:运次内子单创建时刻取最大值(与运次列表同一排序口径) */ private static final String SQL_MAX_CREATE_TIME = "MAX(create_time)"; - /** 关键字在子单上匹配的字段:与运次读服务同一份口径,待重新派单列表按它筛 */ - private static final String[] REASSIGN_REASSIGN_KEYWORD_COLUMNS = { - "waybill_no", "loading_no", "departure_name", "arrival_name", - "departure_address", "arrival_address", "vehicle_no" - }; private static final DateTimeFormatter DATE_MD = DateTimeFormatter.ofPattern("MM-dd"); private static final DateTimeFormatter DATE_YMD = DateTimeFormatter.ofPattern("yyyy-MM-dd"); @@ -336,7 +331,7 @@ public class ManageWaybillServiceImpl implements IManageWaybillService { if (Func.isEmpty(tripIds)) { return Set.of(); } - // 被拒子单只有几十行量级:一次取回后在服务层换算运次键,比在库层按分组键表达式反查更省事 + // 被拒子单一次取回后在服务层换算运次键 return waybillService.list(pendingReassignQuery().select(Waybill::getId, Waybill::getLoadingNo)) .stream() .map(this::tripKeyOf) diff --git a/blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/TripQueryServiceImpl.java b/blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/TripQueryServiceImpl.java index 82ec9c4a..9e8dd2ff 100644 --- a/blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/TripQueryServiceImpl.java +++ b/blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/TripQueryServiceImpl.java @@ -162,12 +162,15 @@ public class TripQueryServiceImpl implements ITripQueryService { // 子单全部被拒单(或已释放)的配载运次对司机不可见,与列表口径一致 throw new ServiceException("运次不存在或无权操作"); } + // 详情与列表同一份分档口径:接单需求也按项目生效中的配置判,否则列表说待接单、详情与接收入口说无需接单 + applyLiveProcessConfig(children); return loadingTrip(loading, children, true); } Waybill waybill = visibleWaybill(id, condition); if (waybill == null) { throw new ServiceException("运次不存在或无权操作"); } + applyLiveProcessConfig(List.of(waybill)); return waybillTrip(waybill, true); } diff --git a/blade-service/blade-transport/src/test/java/org/springblade/transport/service/impl/TripQueryServiceImplTest.java b/blade-service/blade-transport/src/test/java/org/springblade/transport/service/impl/TripQueryServiceImplTest.java index 326fc5c2..639b5ab6 100644 --- a/blade-service/blade-transport/src/test/java/org/springblade/transport/service/impl/TripQueryServiceImplTest.java +++ b/blade-service/blade-transport/src/test/java/org/springblade/transport/service/impl/TripQueryServiceImplTest.java @@ -433,6 +433,42 @@ class TripQueryServiceImplTest { assertEquals(0, service.page(outside).getTotal(), "排序键 2000 不在区间内 → 这趟车不在范围内"); } + @Test + @DisplayName("详情与列表同口径:子单快照没有接单节点、项目生效配置要求接单时,详情也算待接单") + void detailUsesLiveProcessConfig() { + when(loadingManageService.getById(LOADING_ID)).thenReturn(loading(PHONE)); + Waybill child = waybill(2092186187239780353L, "YD-20260915-0001", LOADING_NO, "running", "pending", + at(2000L), ACCEPT_NO); + child.setProjectId(7001L); + when(waybillService.list(anyWaybillWrapper())).thenReturn(List.of(child)); + when(processConfigService.list(anyConfigWrapper())).thenReturn(List.of(processConfig(7001L, ACCEPT_YES))); + + TripVO trip = service.detail(tripQuery(String.valueOf(LOADING_ID))); + + assertEquals(0, trip.getStatus(), "生效配置要求接单且未接 → 待接单档,与列表一致"); + assertEquals(Boolean.TRUE, trip.getRequireAccept(), "接单需求按生效配置判,不看快照"); + assertEquals(Boolean.TRUE, trip.getWaybills().get(0).getRequireAccept()); + assertEquals("pending", trip.getAcceptStatus()); + } + + @Test + @DisplayName("详情仍是只读取数:生效配置只写回内存里的行,不落库") + void detailStaysReadOnly() { + when(loadingManageService.getById(LOADING_ID)).thenReturn(loading(PHONE)); + Waybill child = waybill(2092186187239780353L, "YD-20260915-0001", LOADING_NO, "running", "pending", + at(2000L), ACCEPT_NO); + child.setProjectId(7001L); + when(waybillService.list(anyWaybillWrapper())).thenReturn(List.of(child)); + when(processConfigService.list(anyConfigWrapper())).thenReturn(List.of(processConfig(7001L, ACCEPT_YES))); + + service.detail(tripQuery(String.valueOf(LOADING_ID))); + + verify(waybillService, never()).updateById(any()); + verify(waybillService, never()).update(any(), any()); + verify(waybillService, never()).syncDriverAcceptState(any()); + assertEquals(ACCEPT_YES, child.getProcessJson(), "生效配置只写回内存里的行,库里的快照列不动"); + } + @Test @DisplayName("详情:未配载按运单主键取,配载按配载单主键取") void detailResolvesBothTripKinds() { @@ -533,6 +569,15 @@ class TripQueryServiceImplTest { waybill(2092186187470467073L, "YD-20260825-0007", LOADING_NO, "running", "pending", at(1000L), ACCEPT_NO))); } + private ProcessConfig processConfig(Long projectId, String nodeConfigJson) { + ProcessConfig config = new ProcessConfig(); + config.setProjectIds(String.valueOf(projectId)); + config.setNodeConfigJson(nodeConfigJson); + config.setStatus(1); + config.setIsDeleted(0); + return config; + } + private TripQueryVO tripQuery(String tripId) { TripQueryVO query = TripQueryVO.forDriver(PHONE); query.setTripId(tripId);