🐛 运次详情也按项目生效配置判接单需求,与列表同口径
详情取数漏跑生效配置解析,子单只带运单快照:同一趟车在列表里是待接单、 在详情里是运输中,卡片点进去没有接单入口;运次接单与拒单的子单集合也来自 详情,会被判成无需确认接单而直接拒绝。现在详情两条分支都跑同一份解析, status / requireAccept / 子单 requireAccept 三处与列表一致,且仍只读—— 生效配置只写回内存里的行,不落库。
This commit is contained in:
+1
-6
@@ -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)
|
||||
|
||||
+3
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+45
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user