yangys
2025-08-07 c903c1606a9c9e58d2b12adea1d7f5c775cca041
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package org.springblade.mdm.flow.service;
 
import lombok.AllArgsConstructor;
import org.flowable.engine.HistoryService;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService;
import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.task.api.Task;
import org.springblade.mdm.flow.constants.FlowContants;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.Map;
 
@AllArgsConstructor
@Service
public class FlowTransferService {
 
    private final TaskService taskService;
 
    private final ApproveRecordService approveRecordService;
 
    /**
     * 转派,并记录自己的备注信息
     * @param taskId 任务id
     * @param newAssigneeId 转派给
     * @param comment 评论信息
     */
    @Transactional
    public void transferTask(String taskId, String newAssigneeId,String comment) {
 
        Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
        // 增加评论
 
        taskService.addComment(taskId, task.getProcessInstanceId(), comment);
        // 完成任务
        taskService.setAssignee(taskId, newAssigneeId);
 
        //自荐表增加评论数据
        approveRecordService.saveApproveRecords(task,"Y",comment);
    }
}