✨ 确认回单改看运单状态并支持取消打卡回退
This commit is contained in:
+29
-9
@@ -538,9 +538,26 @@ public class WaybillServiceImpl extends BaseServiceImpl<WaybillMapper, Waybill>
|
||||
throw new ServiceException("运单待业务员确认回单,不能补录打卡");
|
||||
}
|
||||
if (ENROUTE_PUNCH_TYPE.equalsIgnoreCase(TransportBusinessSupport.trimToEmpty(request.getType()))) {
|
||||
return saveEnroutePunchRecord(waybill, request, punched);
|
||||
return revertIfReturnConfirmPreconditionLost(waybill, punched,
|
||||
saveEnroutePunchRecord(waybill, request, punched));
|
||||
}
|
||||
return saveNodePunchRecord(waybill, request, punched);
|
||||
return revertIfReturnConfirmPreconditionLost(waybill, punched,
|
||||
saveNodePunchRecord(waybill, request, punched));
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消打卡撤掉了「司机已无待打卡节点」这个前提,停在待回单确认的运单退回进行中。
|
||||
* <p>
|
||||
* 只认取消打卡后的待回单确认,其它状态一律不动。
|
||||
*/
|
||||
private boolean revertIfReturnConfirmPreconditionLost(Waybill waybill, boolean punched, boolean saved) {
|
||||
if (!saved || punched
|
||||
|| !WaybillProcessSupport.STATUS_PENDING_RETURN_CONFIRM
|
||||
.equalsIgnoreCase(waybill.getBusinessStatus())) {
|
||||
return saved;
|
||||
}
|
||||
waybill.setBusinessStatus(WaybillProcessSupport.STATUS_RUNNING);
|
||||
return updateById(waybill);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -968,13 +985,16 @@ public class WaybillServiceImpl extends BaseServiceImpl<WaybillMapper, Waybill>
|
||||
/**
|
||||
* 运单是否已越过接单阶段。
|
||||
* <p>
|
||||
* 正向列举进行中/已完成/已取消,不能用「不是终态」取反:终态里还包含草稿、待调度、
|
||||
* 正向列举进行中/已完成/已取消/待回单确认,不能用「不是终态」取反:终态里还包含草稿、待调度、
|
||||
* 调度中这些并未越过接单的阶段,取反会把它们判成已接单。
|
||||
* <p>
|
||||
* 待回单确认下司机已打完末位卡,无需接单配置时接单节点不该再显示未打卡。
|
||||
*/
|
||||
private static boolean passedAcceptStage(String businessStatus) {
|
||||
return "running".equals(businessStatus)
|
||||
|| "completed".equals(businessStatus)
|
||||
|| "cancelled".equals(businessStatus);
|
||||
|| "cancelled".equals(businessStatus)
|
||||
|| WaybillProcessSupport.STATUS_PENDING_RETURN_CONFIRM.equals(businessStatus);
|
||||
}
|
||||
|
||||
private String formatPunchTime(Date time) {
|
||||
@@ -1525,14 +1545,14 @@ public class WaybillServiceImpl extends BaseServiceImpl<WaybillMapper, Waybill>
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean confirmReturnReceipt(Long id) {
|
||||
Waybill waybill = loadEditable(id, true);
|
||||
// 判据只看运单当前状态,不看回单配置当前值:配置改回「无需确认」后,
|
||||
// 已停在待回单确认的运单仍要能确认回单
|
||||
if (!WaybillProcessSupport.STATUS_PENDING_RETURN_CONFIRM.equalsIgnoreCase(waybill.getBusinessStatus())) {
|
||||
throw new ServiceException("当前状态不允许确认回单");
|
||||
}
|
||||
String processJson = LiveProcessConfigSupport.resolve(
|
||||
LiveProcessConfigSupport.byProject(processConfigService, waybill.getProjectId()),
|
||||
waybill.getProcessJson());
|
||||
if (WaybillProcessSupport.returnNeedsNoConfirmation(processJson)) {
|
||||
// 不要求确认时司机打完末位卡就已经完成了,运单不会停在进行中等确认;配置对不上要说清,
|
||||
// 否则用户会以为是确认没生效
|
||||
throw new ServiceException("该运单的回单不需要业务员确认");
|
||||
}
|
||||
assertPunchNodesFinished(waybill.getId(), processJson);
|
||||
assertNoUnresolvedException(waybill.getId());
|
||||
return doComplete(waybill);
|
||||
|
||||
Reference in New Issue
Block a user