fix: allow primary task pipeline conversion after rejection

This commit is contained in:
Your Name 2026-03-02 17:31:37 +08:00
parent 4d19e5efe8
commit 26a99e3a34
2 changed files with 12 additions and 10 deletions

View File

@ -201,6 +201,8 @@ public class TaskController {
Task task = objectMapper.treeToValue(jsonNode, Task.class);
taskService.updateTask(id, task, userId);
}
} catch (com.designhub.exception.BusinessException e) {
throw e;
} catch (Exception e) {
log.error("解析任务数据失败: taskId={}, error={}", id, e.getMessage(), e);
throw new com.designhub.exception.BusinessException(com.designhub.common.ResultCode.PARAM_ERROR, "任务数据格式错误: " + e.getMessage());
@ -643,4 +645,3 @@ public class TaskController {
return Result.success(taskService.getTaskFlowStatus(taskNo, keyword));
}
}

View File

@ -1852,21 +1852,22 @@ public class TaskService {
throw new BusinessException(ResultCode.FORBIDDEN, "只有任务发布人、指定的明细完善人或接单部门负责人(待接单任务)可以更新任务");
}
// 允许更新的任务状态:草稿、待审核(需求/接单部门审核)、被驳回、待完善明细
// 不允许更新的状态:进行中(in_progress)、已完成(completed)、已取消(cancelled)
String approvalStatus = existTask.getApprovalStatus();
// 验证任务是否是流水线任务
// 特殊情况:一级需求部门任务在草稿或待完善明细状态下,允许将非流水线任务转换为流水线任务
boolean isPrimaryTaskCanConvert = existTask.getIsPrimaryTask() != null
&& existTask.getIsPrimaryTask() == 1
&& ("pending_detail_completion".equals(existTask.getApprovalStatus())
|| "draft".equals(existTask.getApprovalStatus()));
// 特殊情况:一级需求部门任务在草稿/驳回/待完善明细状态下,允许将非流水线任务转换为流水线任务
boolean isPrimaryTaskCanConvert = existTask.getIsPrimaryTask() != null
&& existTask.getIsPrimaryTask() == 1
&& ("draft".equals(status)
|| "pending_detail_completion".equals(approvalStatus)
|| (approvalStatus != null && approvalStatus.contains("rejected")));
if ((existTask.getIsPipeline() == null || existTask.getIsPipeline() != 1) && !isPrimaryTaskCanConvert) {
throw new BusinessException(ResultCode.PARAM_ERROR, "该任务不是流水线任务");
}
// 允许更新的任务状态:草稿、待审核(需求/接单部门审核)、被驳回、待完善明细
// 不允许更新的状态:进行中(in_progress)、已完成(completed)、已取消(cancelled)
String approvalStatus = existTask.getApprovalStatus();
boolean canUpdate = "draft".equals(status) ||
"pending".equals(status) || // 待接单状态也允许编辑
(approvalStatus != null && (