package org.springblade.mdm.flow.service.execute; import org.flowable.task.api.Task; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.support.Kv; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.StringUtil; import org.springblade.mdm.flow.constants.FlowVariableConstant; import org.springblade.mdm.flow.service.FlowCommonService; import org.springblade.mdm.flow.service.FlowProgramFileService; import org.springblade.mdm.program.service.NcNodeAutoCreateService; import org.springblade.mdm.program.service.NcNodeService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.Map; /** * 替换流程完成任务的实现 */ @Service("repalceFlowCompleteService") public class ReplaceFlowCompleteService extends AbstractFlowCompleteService { @Autowired private FlowProgramFileService flowProgramFileService; @Autowired private NcNodeService ncNodeService; @Autowired private NcNodeAutoCreateService ncNodeAutoCreateService; @Autowired private FlowCommonService flowCommonService; @Transactional @Override public void completeTask(String taskId, String processInstanceId, String comment, Map variables) { Task task = currentTask(taskId); // 非空判断 if (Func.isEmpty(variables)) { variables = Kv.create(); } String operateResult = this.getApproveResult(variables); if(task.getTaskDefinitionKey().equals("replaceProgrammingTask")) {//编制节点 variables.put(FlowVariableConstant.ACT_PROGRAMMER,Func.toStr(AuthUtil.getUserId())); flowProgramFileService.checkProgramFiles(processInstanceId,"Y".equals(operateResult)); } if (StringUtil.isNoneBlank(processInstanceId, comment)) { taskService.addComment(taskId, processInstanceId, comment); } variables.put(FlowVariableConstant.LAST_STEP_USER_NICKNAME, AuthUtil.getNickName()); if(!variables.containsKey("assignee")) { throw new ServiceException("请指定流程下一步处理人"); } variables.remove(FlowVariableConstant.PROCESS_EDITION);//不要升版了 taskService.complete(taskId, variables); } }