fix: 接单部门驳回任务时,如果需求部门没有负责人则退回给发起人
This commit is contained in:
parent
7733070ecd
commit
d15baa97f5
@ -645,17 +645,25 @@ public class TaskApprovalService {
|
||||
Task task = getTaskForApproval(taskId, "pending_receiving_approval");
|
||||
validateApprover(task, approverId, "receiving_leader");
|
||||
|
||||
// 退回给需求部门负责人
|
||||
// 退回给需求部门负责人,如果没有负责人则退回给发起人
|
||||
Department demandDept = departmentMapper.selectById(task.getPublisherDeptId());
|
||||
if (demandDept == null || demandDept.getLeaderId() == null) {
|
||||
throw new BusinessException(ResultCode.PARAM_ERROR, "需求部门负责人不存在");
|
||||
Long targetApproverId = null;
|
||||
String targetApproverRole = "demand_leader";
|
||||
|
||||
if (demandDept != null && demandDept.getLeaderId() != null) {
|
||||
targetApproverId = demandDept.getLeaderId();
|
||||
} else {
|
||||
// 一级需求部门可能没有负责人,退回给发起人
|
||||
targetApproverId = task.getPublisherId();
|
||||
targetApproverRole = "publisher";
|
||||
log.warn("需求部门{}没有负责人,任务退回给发起人{}", task.getPublisherDeptId(), task.getPublisherId());
|
||||
}
|
||||
|
||||
task.setApprovalStatus("rejected_by_receiving");
|
||||
task.setStatus("draft");
|
||||
task.setRejectReason(reason); // 保存驳回原因
|
||||
task.setCurrentApproverId(demandDept.getLeaderId());
|
||||
task.setCurrentApproverRole("demand_leader");
|
||||
task.setCurrentApproverId(targetApproverId);
|
||||
task.setCurrentApproverRole(targetApproverRole);
|
||||
taskMapper.updateById(task);
|
||||
|
||||
logApproval(taskId, approverId, 2, "reject", reason);
|
||||
@ -670,8 +678,8 @@ public class TaskApprovalService {
|
||||
);
|
||||
log.info("已通知任务发起人: publisherId={}", task.getPublisherId());
|
||||
|
||||
// 2. 如果需求部门负责人不是发起人,也通知需求部门负责人
|
||||
if (!demandDept.getLeaderId().equals(task.getPublisherId())) {
|
||||
// 2. 如果需求部门负责人存在且不是发起人,也通知需求部门负责人
|
||||
if (demandDept != null && demandDept.getLeaderId() != null && !demandDept.getLeaderId().equals(task.getPublisherId())) {
|
||||
notificationService.sendNotification(
|
||||
demandDept.getLeaderId(),
|
||||
"任务已被驳回",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user