| | |
| | | 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.flowable.task.service.impl.persistence.entity.TaskEntity; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.Map; |
| | | import java.util.Date; |
| | | import java.util.UUID; |
| | | |
| | | @AllArgsConstructor |
| | | @Service |
| | | public class FlowTransferService { |
| | | |
| | | private final TaskService taskService; |
| | | |
| | | private final ApproveRecordService approveRecordService; |
| | | |
| | | /** |
| | | * 转派,并记录自己的备注信息 |
| | |
| | | @Transactional |
| | | public void transferTask(String taskId, String newAssigneeId,String comment) { |
| | | |
| | | Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); |
| | | // 增加评论 |
| | | Task currTask = taskService.createTaskQuery().taskId(taskId).singleResult(); |
| | | |
| | | taskService.addComment(taskId, task.getProcessInstanceId(), comment); |
| | | //if (currTask != null) { |
| | | //1.生成历史记录 |
| | | TaskEntity subtask = this.createSubTask(currTask, currTask.getAssignee()); |
| | | //2.添加审批意见 |
| | | //this.addComment(subtask.getId(), turnTaskVo.getUserCode(), turnTaskVo.getProcessInstanceId(), CommentTypeEnum.ZB.toString(), turnTaskVo.getMessage()); |
| | | taskService.addComment(subtask.getId(), currTask.getProcessInstanceId(), comment); |
| | | taskService.complete(subtask.getId()); |
| | | //3.转办 |
| | | //taskService.setAssignee(turnTaskVo.getTaskId(), turnTaskVo.getTurnToUserId()); |
| | | taskService.setAssignee(taskId, newAssigneeId); |
| | | //taskService.setOwner(taskId, currTask.getAssignee()); |
| | | taskService.setOwner(taskId, newAssigneeId); |
| | | //returnVo = new ReturnVo<>(ReturnCode.SUCCESS, "转办成功"); |
| | | //} |
| | | |
| | | // 增加评论 |
| | | //taskService.addComment(taskId, currTask.getProcessInstanceId(), comment); |
| | | // 完成任务 |
| | | taskService.setAssignee(taskId, newAssigneeId); |
| | | //taskService.setAssignee(taskId, newAssigneeId); |
| | | |
| | | //自荐表增加评论数据 |
| | | approveRecordService.saveApproveRecords(task,"Y",comment); |
| | | //approveRecordService.saveApproveRecords(currTask,"Y",comment); |
| | | } |
| | | |
| | | TaskEntity createSubTask(Task ptask, String assignee) { |
| | | TaskEntity task = null; |
| | | if (ptask != null) { |
| | | //1.生成子任务 |
| | | UUID uuid = UUID.randomUUID(); |
| | | task = (TaskEntity) taskService.newTask(uuid.toString()); |
| | | task.setCategory(ptask.getCategory()); |
| | | task.setDescription(ptask.getDescription()); |
| | | task.setTenantId(ptask.getTenantId()); |
| | | task.setAssignee(assignee); |
| | | task.setName(ptask.getName()); |
| | | task.setParentTaskId(ptask.getId()); |
| | | task.setProcessDefinitionId(ptask.getProcessDefinitionId()); |
| | | task.setProcessInstanceId(ptask.getProcessInstanceId()); |
| | | task.setTaskDefinitionKey(ptask.getTaskDefinitionKey()); |
| | | task.setTaskDefinitionId(ptask.getTaskDefinitionId()); |
| | | task.setPriority(ptask.getPriority()); |
| | | task.setCreateTime(new Date()); |
| | | taskService.saveTask(task); |
| | | } |
| | | return task; |
| | | } |
| | | } |
| | | |