fix(workreport): 解决工作报表状态操作错误信息显示内部代码问题

- 引入 StatusActionTextResolver 服务用于解析状态动作名称
- 注入 statusActionTextResolver 依赖实例
- 修改异常抛出逻辑,将内部ActionCode转换为用户友好的中文提示
- 更新工作报表状态转换验证中的错误信息显示方式
- 修复拒绝状态下重新提交操作的错误信息国际化问题
This commit is contained in:
2026-06-11 17:32:57 +08:00
parent 287d0f678a
commit 54bcf7d8ae

View File

@@ -47,6 +47,7 @@ import com.njcn.rdms.module.project.dal.mysql.workreport.weekly.WeeklyReportAppr
import com.njcn.rdms.module.project.dal.mysql.workreport.weekly.WeeklyReportMapper;
import com.njcn.rdms.module.project.dal.mysql.workreport.weekly.WeeklyReportTravelSegmentMapper;
import com.njcn.rdms.module.project.enums.ErrorCodeConstants;
import com.njcn.rdms.module.project.service.status.StatusActionTextResolver;
import com.njcn.rdms.module.system.api.dept.DeptApi;
import com.njcn.rdms.module.system.api.dept.PostApi;
import com.njcn.rdms.module.system.api.dept.dto.DeptRespDTO;
@@ -106,6 +107,8 @@ public class WorkReportCommonService {
@Resource
private ObjectStatusTransitionMapper objectStatusTransitionMapper;
@Resource
private StatusActionTextResolver statusActionTextResolver;
@Resource
private AdminUserApi adminUserApi;
@Resource
private DeptApi deptApi;
@@ -730,10 +733,13 @@ public class WorkReportCommonService {
ObjectStatusTransitionDO transition = objectStatusTransitionMapper
.selectByObjectTypeAndFromStatusAndAction(WorkReportConstants.STATUS_OBJECT_TYPE, fromStatus, actionCode);
if (transition == null) {
throw exception(ErrorCodeConstants.WORK_REPORT_STATUS_ACTION_NOT_ALLOWED, actionCode);
// TD-012用户可见文案不外泄内部 code翻成状态机中文动作名见 docs/architecture/用户可见错误文案规范.html
throw exception(ErrorCodeConstants.WORK_REPORT_STATUS_ACTION_NOT_ALLOWED,
statusActionTextResolver.actionName(WorkReportConstants.STATUS_OBJECT_TYPE, actionCode));
}
if (Boolean.TRUE.equals(transition.getNeedReason()) && !StringUtils.hasText(reason)) {
throw exception(ErrorCodeConstants.WORK_REPORT_STATUS_ACTION_REASON_REQUIRED, actionCode);
throw exception(ErrorCodeConstants.WORK_REPORT_STATUS_ACTION_REASON_REQUIRED,
statusActionTextResolver.actionName(WorkReportConstants.STATUS_OBJECT_TYPE, actionCode));
}
getStatusModel(transition.getToStatusCode());
return transition;
@@ -775,7 +781,8 @@ public class WorkReportCommonService {
if (WorkReportConstants.STATUS_REJECTED.equals(statusCode)) {
return WorkReportConstants.ACTION_RESUBMIT;
}
throw exception(ErrorCodeConstants.WORK_REPORT_STATUS_ACTION_NOT_ALLOWED, WorkReportConstants.ACTION_SUBMIT);
throw exception(ErrorCodeConstants.WORK_REPORT_STATUS_ACTION_NOT_ALLOWED,
statusActionTextResolver.actionName(WorkReportConstants.STATUS_OBJECT_TYPE, WorkReportConstants.ACTION_SUBMIT));
}
private void validateWeeklyDuplicate(Long reporterId, String periodKey, Long excludeId) {