✨ 司机打完末位到货卸货签收节点且回单无需确认时自动完成运单

This commit is contained in:
2026-10-08 09:24:30 +08:00
parent 9f8ea5412d
commit 7c488b6f09
3 changed files with 279 additions and 1 deletions
@@ -360,7 +360,20 @@ public class DriverWaybillServiceImpl implements IDriverWaybillService {
nodePunchMapper.insert(punch);
advanceCurrentProcessNode(waybill, nodeCfg);
return toNodePunchVO(punch);
// 末位打卡节点是到货/卸货/签收、且回单无需确认完成时,本次打卡一并把运单置为完成;
// 判定与找节点共用上面已解析的那份过程配置,不重新解析。
String nodeKey = WaybillProcessSupport.nodeKey(nodeCfg);
String nodeName = WaybillProcessSupport.nodeName(nodeCfg);
boolean completed = false;
if (WaybillProcessSupport.isLastDriverPunchNode(processJson, nodeKey)
&& WaybillProcessSupport.isDeliveryNode(nodeKey, nodeName)
&& WaybillProcessSupport.returnNeedsNoConfirmation(processJson)
&& canAutoCompleteWaybill(waybill)) {
completed = waybillService.completeWithoutDeptCheck(waybill.getId());
}
DriverNodePunchVO vo = toNodePunchVO(punch);
vo.setWaybillCompleted(completed);
return vo;
}
@Override
@@ -1022,6 +1035,20 @@ public class DriverWaybillServiceImpl implements IDriverWaybillService {
return countByType;
}
/**
* 自动完成的前置:与司机端「完成运单」同一套——业务状态允许完成,且没有未了结异常。
* <p>
* 不满足返回 false,由调用方静默跳过,打卡不受影响。
*/
private boolean canAutoCompleteWaybill(Waybill waybill) {
String status = waybill.getBusinessStatus();
boolean statusAllowed = STATUS_RUNNING.equals(status)
|| STATUS_PENDING.equals(status)
|| STATUS_WAITING_DISPATCH.equals(status)
|| STATUS_DISPATCHING.equals(status);
return statusAllowed && unresolvedExceptionNodeCodeList(waybill.getId()).isEmpty();
}
/**
* 断言该运单没有未了结的异常。
* <p>