✨ 新增异常拒绝与撤销接口

This commit is contained in:
2026-10-23 00:37:59 +08:00
parent cb83f5bffd
commit 7f4dc94934
5 changed files with 460 additions and 1 deletions
@@ -33,6 +33,7 @@ import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.annotation.PreAuth;
import org.springblade.core.tool.api.R;
import org.springblade.transport.pojo.dto.ExceptionDisposalFollowRequest;
import org.springblade.transport.pojo.dto.ExceptionDisposalRejectRequest;
import org.springblade.transport.pojo.dto.ExceptionDisposalUpdateRequest;
import org.springblade.transport.pojo.entity.ExceptionDisposal;
import org.springblade.transport.pojo.vo.ExceptionDisposalVO;
@@ -50,7 +51,7 @@ import org.springframework.web.bind.annotation.RestController;
* <p>
* 对外路径:{@code /api/blade-transport/exception-disposal/**}
* 同时兼容未去前缀直连 {@code /blade-transport/exception-disposal/**}。
* 列表 / 详情 / 上报 / 跟进 / 完成均仅需登录态(小程序调度端与司机端共用)。
* 列表 / 详情 / 上报 / 跟进 / 完成 / 拒绝 / 撤销均仅需登录态(小程序调度端与司机端共用)。
*/
@RestController
@AllArgsConstructor
@@ -114,4 +115,20 @@ public class ExceptionDisposalController extends BladeController {
return R.success("编辑成功");
}
@PostMapping("/reject")
@ApiOperationSupport(order = 8)
@Operation(summary = "拒绝异常", description = "调度端拒绝上报:先写一条拒绝原因的跟进记录,再了结;仅需登录态")
public R reject(@RequestBody ExceptionDisposalRejectRequest request) {
exceptionDisposalService.reject(request);
return R.success("已拒绝");
}
@PostMapping("/revoke")
@ApiOperationSupport(order = 9)
@Operation(summary = "撤销异常上报", description = "上报人撤销自己未了结的上报,不写跟进记录;仅需登录态")
public R revoke(@RequestBody ExceptionDisposalFollowRequest request) {
exceptionDisposalService.revoke(request.getId());
return R.success("已撤销");
}
}
@@ -25,6 +25,7 @@ package org.springblade.transport.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseService;
import org.springblade.transport.pojo.dto.ExceptionDisposalFollowRequest;
import org.springblade.transport.pojo.dto.ExceptionDisposalRejectRequest;
import org.springblade.transport.pojo.dto.ExceptionDisposalUpdateRequest;
import org.springblade.transport.pojo.entity.ExceptionDisposal;
import org.springblade.transport.pojo.vo.ExceptionDisposalVO;
@@ -56,4 +57,15 @@ public interface IExceptionDisposalService extends BaseService<ExceptionDisposal
void batchComplete(String ids);
/**
* 拒绝异常:先写一条「拒绝:原因」的跟进记录,再了结。
* 拒绝了结复用已完成终态,不新增状态值。
*/
void reject(ExceptionDisposalRejectRequest request);
/**
* 撤销异常上报:仅限上报人本人、仅限未了结,置为已撤销,不留跟进记录
*/
void revoke(Long id);
}
@@ -35,6 +35,7 @@ import org.springblade.system.cache.UserDisplayCache;
import org.springblade.transport.mapper.ExceptionDisposalFollowRecordMapper;
import org.springblade.transport.mapper.ExceptionDisposalMapper;
import org.springblade.transport.pojo.dto.ExceptionDisposalFollowRequest;
import org.springblade.transport.pojo.dto.ExceptionDisposalRejectRequest;
import org.springblade.transport.pojo.dto.ExceptionDisposalUpdateRequest;
import org.springblade.transport.pojo.entity.ExceptionDisposal;
import org.springblade.transport.pojo.entity.ExceptionDisposalFollowRecord;
@@ -72,10 +73,14 @@ public class ExceptionDisposalServiceImpl
private static final String STATUS_PENDING = "pending";
private static final String STATUS_PROCESSING = "processing";
private static final String STATUS_COMPLETED = "completed";
private static final String STATUS_REVOKED = "revoked";
/** latest_follow_content 与 follow_content 两列均为 varchar(500) */
private static final int FOLLOW_CONTENT_MAX_LENGTH = 500;
/** 拒绝原因长度上限,与上报说明、异常原因同量级,且远小于跟进记录列宽 */
private static final int REJECT_REASON_MAX_LENGTH = 200;
private final ExceptionDisposalFollowRecordMapper followRecordMapper;
private final IWaybillService waybillService;
private final IDriverWaybillService driverWaybillService;
@@ -394,6 +399,58 @@ public class ExceptionDisposalServiceImpl
updateBatchById(disposals);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void reject(ExceptionDisposalRejectRequest request) {
if (request == null || request.getId() == null) {
throw new ServiceException("请选择需要拒绝的异常");
}
ExceptionDisposal disposal = getExisting(request.getId());
// 已完成、已撤销都算已了结:再拒绝一次会覆盖最新处置结论,并往处置记录里多添一条
if (WaybillProcessSupport.SETTLED_DISPOSAL_STATUSES.contains(disposal.getDisposalStatus())) {
throw new ServiceException("该异常已处理");
}
String rejectReason = Func.toStr(request.getRejectReason(), "").trim();
if (Func.isBlank(rejectReason)) {
throw new ServiceException("请填写拒绝原因");
}
if (rejectReason.length() > REJECT_REASON_MAX_LENGTH) {
throw new ServiceException("拒绝原因不能超过200字");
}
String rejectContent = "拒绝:" + rejectReason;
ExceptionDisposalFollowRecord record = new ExceptionDisposalFollowRecord();
record.setDisposalId(disposal.getId());
record.setFollowContent(rejectContent);
// 拒绝弹窗只有原因、没有附件,attachments_json 不写
record.setFollowUser(AuthUtil.getUserId());
record.setFollowUserName(UserDisplayCache.getUserRealName(AuthUtil.getUserId()));
record.setFollowTime(LocalDateTime.now());
followRecordMapper.insert(record);
// 记录先于状态落库,且同在一个事务里:结案了却没有拒绝记录,事后无从知道是谁以什么理由拒绝的
disposal.setDisposalStatus(STATUS_COMPLETED);
disposal.setLatestFollowContent(rejectContent);
updateById(disposal);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void revoke(Long id) {
ExceptionDisposal disposal = getExisting(id);
Long currentUserId = AuthUtil.getUserId();
// 撤销是上报人收回自己的上报,不是一次处置:别的账号(包括调度员)要推翻上报只能走拒绝
if (currentUserId == null || !Objects.equals(disposal.getReporterId(), currentUserId)) {
throw new ServiceException("只能撤销本人上报的异常");
}
if (WaybillProcessSupport.SETTLED_DISPOSAL_STATUSES.contains(disposal.getDisposalStatus())) {
throw new ServiceException("该异常已处理");
}
// 不写跟进记录,也不动 latest_follow_content:处置时间线里不该出现一条由上报人「处置」的记录
disposal.setDisposalStatus(STATUS_REVOKED);
updateById(disposal);
}
private LambdaQueryWrapper<ExceptionDisposal> buildQuery(ExceptionDisposalVO query) {
LambdaQueryWrapper<ExceptionDisposal> wrapper = Wrappers.<ExceptionDisposal>lambdaQuery()
.eq(ExceptionDisposal::getIsDeleted, 0)
@@ -488,6 +545,7 @@ public class ExceptionDisposalServiceImpl
case STATUS_PENDING -> "待处理";
case STATUS_PROCESSING -> "处理中";
case STATUS_COMPLETED -> "已完成";
case STATUS_REVOKED -> "已撤销";
default -> "";
};
}