🐛 异常上报收紧为仅运输中,与打卡同一状态判据

This commit is contained in:
2026-10-20 23:07:41 +08:00
parent 142eee384b
commit 8dd0fa3260
4 changed files with 93 additions and 0 deletions
@@ -144,6 +144,17 @@ public class ExceptionDisposalServiceImpl
// 整单异常同样受这条约束:没有节点不等于没有上报人。
driverWaybillService.assertCurrentDriverOwnsWaybill(disposal.getWaybillId());
// 上报门禁之零:运单得先在路上,且不能已经结束。
// 判据与司机打卡同一来源;归属校验会顺手把「无需接单」的待执行运单校正为进行中,
// 所以状态要在它之后重新读,不能用 fillFromWaybill 里校正前的那份对象。
Waybill reportWaybill = waybillService.getById(disposal.getWaybillId());
String blockedReason = reportWaybill == null
? null
: WaybillProcessSupport.reportBlockedReason(reportWaybill.getBusinessStatus());
if (blockedReason != null) {
throw new ServiceException(blockedReason);
}
// 节点可以为空:全局入口(首页快捷格、打卡页底部按钮)上报的异常不指定环节,
// 它无从定位阻断区间,由门禁按「阻断该运单全部未打卡节点」处理。
// 节点非空时才要求它确属该运单;节点名取自过程配置而非请求体,避免落进一个该节点并不叫的名字。
@@ -191,6 +191,23 @@ public final class WaybillProcessSupport {
return last != null && last.equals(day);
}
/**
* 上报异常前的运单状态门禁原因;可上报时返回 null。
* <p>
* 与打卡共用「已开始运输」判据,但文案说的是能不能报,不是能不能打。
* 结束优先于未开始:已完成/已取消的运单先说结束,不再提「等你上路」。
*/
public static String reportBlockedReason(String businessStatus) {
String endedReason = punchEndedReason(businessStatus);
if (endedReason != null) {
return endedReason + ",不能上报异常";
}
if (!isTransitPunchStarted(businessStatus)) {
return "运单尚未开始运输,暂不可上报异常";
}
return null;
}
public static boolean isTerminalBusinessStatus(String businessStatus) {
return "draft".equals(businessStatus)
|| "completed".equals(businessStatus)