修复:1.一级需求任务明细完善后子任务状态更新为pending_approval 2.我发起的任务页面也显示明细完善人的任务

This commit is contained in:
Your Name 2026-01-23 11:43:48 +08:00
parent a615aa3d44
commit e84f98933e
2 changed files with 34 additions and 2 deletions

View File

@ -185,6 +185,7 @@ public interface TaskMapper extends BaseMapper<Task> {
/**
* 查询我发布的任务
* 包括:作为发布人的任务 或 作为一级需求任务明细完善人的任务
*/
@Select("<script>" +
"SELECT t.*, " +
@ -205,9 +206,9 @@ public interface TaskMapper extends BaseMapper<Task> {
"LEFT JOIN sys_user approver ON t.current_approver_id = approver.id " +
"LEFT JOIN sys_user primary_user ON t.primary_publisher_id = primary_user.id " +
"LEFT JOIN sys_dept primary_dept ON t.primary_publisher_dept_id = primary_dept.id " +
"WHERE t.publisher_id = #{userId} AND t.deleted = 0 " +
"WHERE (t.publisher_id = #{userId} OR t.detail_completer_id = #{userId}) AND t.deleted = 0 " +
"<if test='status != null'> AND t.status = #{status}</if> " +
"ORDER BY t.create_time DESC" +
"ORDER BY t.update_time DESC" +
"</script>")
IPage<Task> selectMyPublishedTasks(Page<Task> page,
@Param("userId") Long userId,

View File

@ -3616,6 +3616,37 @@ public class TaskService {
task.setCurrentApproverId(receivingLeaderId);
task.setCurrentApproverRole("receiving_leader");
log.info("一级需求任务明细完善后,等待接单部门负责人审核:leaderId={}", receivingLeaderId);
// 🔥 更新子任务状态为 pending_approval,以便接单部门负责人审核
// 顺序模式:只更新第一个部门的子任务
// 并行模式:更新所有子任务
List<TaskItem> taskItems;
if ("sequential".equals(task.getPipelineMode())) {
// 顺序模式:只更新第一个部门的子任务(item_no 中部门序号为 01)
taskItems = taskItemMapper.selectList(
new LambdaQueryWrapper<TaskItem>()
.eq(TaskItem::getTaskId, task.getId())
.eq(TaskItem::getStatus, "pending")
.eq(TaskItem::getIsLocked, 0)
);
log.info("一级需求任务 {} 顺序模式,共 {} 个子任务待更新状态", task.getId(), taskItems.size());
} else {
// 并行模式:更新所有子任务
taskItems = taskItemMapper.selectList(
new LambdaQueryWrapper<TaskItem>()
.eq(TaskItem::getTaskId, task.getId())
.eq(TaskItem::getStatus, "pending")
.eq(TaskItem::getIsLocked, 0)
);
log.info("一级需求任务 {} 并行模式,共 {} 个子任务待更新状态", task.getId(), taskItems.size());
}
for (TaskItem item : taskItems) {
item.setStatus("pending_approval");
item.setUpdateTime(LocalDateTime.now());
taskItemMapper.updateById(item);
log.info("一级需求任务子任务 {} 状态已更新为 pending_approval", item.getItemNo());
}
} else {
// 如果无法确定接单部门负责人,直接发布到任务大厅
log.warn("无法确定接单部门负责人,任务将直接发布到任务大厅");