| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.vci.ubcs.flow.core.constant.ProcessConstant; |
| | | import com.vci.ubcs.flow.core.dto.FlowTaskDTO; |
| | | import com.vci.ubcs.flow.core.dto.ProcessStageAttrDTO; |
| | | import com.vci.ubcs.flow.core.entity.BladeFlow; |
| | | import com.vci.ubcs.flow.core.entity.FlowTaskUser; |
| | | import com.vci.ubcs.flow.core.entity.ProcessStageAttr; |
| | | import com.vci.ubcs.flow.core.utils.TaskUtil; |
| | | import com.vci.ubcs.flow.engine.entity.*; |
| | | import com.vci.ubcs.flow.engine.service.FlowEngineService; |
| | | import com.vci.ubcs.flow.engine.service.FlowTaskUserService; |
| | | import com.vci.ubcs.flow.engine.service.ProcessStageAttrService; |
| | | import com.vci.ubcs.flow.engine.service.VICFlowService; |
| | | import com.vci.ubcs.starter.web.util.BeanUtil; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | |
| | | import org.flowable.engine.repository.ProcessDefinition; |
| | | import org.flowable.engine.runtime.ProcessInstance; |
| | | import org.flowable.task.api.Task; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.api.R; |
| | |
| | | |
| | | private static String MODELKEY = "modelKey";//前端传过来的模型key |
| | | private static String TASKID = "taskId";//前端传过来的模型key |
| | | private static String PROCESSINSTANCEID = "processInstanceId";//前端传过来的模型key |
| | | @Override |
| | | public R<BladeFlow> startProcess(FlowTaskDTO flowTaskUserC){ |
| | | Map<String, Object> kvv = flowTaskUserC.getVariables(); |
| | |
| | | |
| | | String modelKey = processInstance.getProcessDefinitionKey(); |
| | | List<FlowTaskDTO> mis = flowEngineService.getNodeByFlowableKey(modelKey); |
| | | Map<String,String> taskMap = new HashMap<>(); |
| | | mis.stream().forEach(e->{ |
| | | String taskId = e.getTaskId(); |
| | | String taskName = e.getTaskName(); |
| | | taskMap.put(taskId,taskName); |
| | | }); |
| | | |
| | | // 输出连线 |
| | | List<SequenceFlow> outFlows = flowNode.getOutgoingFlows(); |
| | | for (SequenceFlow sequenceFlow : outFlows) { |
| | | String toname = sequenceFlow.getName()==null?"同意":sequenceFlow.getName(); |
| | | //当前审批节点 |
| | | if (NODE_NOW.equals(node)) { |
| | | FlowElement sourceFlowElement = sequenceFlow.getSourceFlowElement(); |
| | |
| | | FlowTaskDTO flowTaskUserCi = new FlowTaskDTO(); |
| | | //flowTaskUserCi.setConditionKey(null); |
| | | //flowTaskUserCi.setConditionValue(null); |
| | | flowTaskUserCi.setToName("同意"); |
| | | flowTaskUserCi.setToName(toname); |
| | | flowTaskUserCi.setToTaskId(targetFlow.getId()); |
| | | flowTaskUserCi.setToTaskName(targetFlow.getName()); |
| | | String taskName = taskMap.get(targetFlow.getId()); |
| | | flowTaskUserCi.setToTaskName(taskName); |
| | | flowTaskUserCi.setTaskName(taskName); |
| | | taskList.add(flowTaskUserCi); |
| | | } |
| | | |
| | |
| | | flowTaskUserCi.setToTaskName(targetFlow.getName()); |
| | | taskList.add(flowTaskUserCi); |
| | | } |
| | | // 如果下个审批节点为排他网关 |
| | | if (targetFlow instanceof ExclusiveGateway) { |
| | | // 如果下个审批节点为网关 |
| | | if (targetFlow instanceof Gateway) { |
| | | |
| | | ExclusiveGateway exclusiveGateway = (ExclusiveGateway) targetFlow; |
| | | List<SequenceFlow> exclusiveGatewayOutgoingFlows = exclusiveGateway.getOutgoingFlows(); |
| | | for (SequenceFlow nexti:exclusiveGatewayOutgoingFlows){ |
| | | String conditionExpression = nexti.getConditionExpression();//condition |
| | | |
| | | String taskId = nexti.getTargetRef();//taskId |
| | | String name = nexti.getName();//toName,驳回、同意 |
| | | |
| | | String taskName = taskMap.get(taskId); |
| | | //ExclusiveGateway |
| | | if(StringUtils.isEmpty(conditionExpression)){//此时排他网关没有配置流转条件 |
| | | continue; |
| | | } |
| | | for (FlowTaskDTO flowTaskUserCi:mis){ |
| | | if(taskId.equals(flowTaskUserCi.getTaskId())){ |
| | | flowTaskUserCi.setCondition(conditionExpression); |
| | |
| | | } |
| | | flowTaskUserCi.setToName(name); |
| | | flowTaskUserCi.setToTaskId(taskId); |
| | | flowTaskUserCi.setToTaskName(flowTaskUserCi.getTaskName()); |
| | | flowTaskUserCi.setToTaskName(taskName); |
| | | flowTaskUserCi.setTaskName(taskName); |
| | | taskList.add(flowTaskUserCi); |
| | | } |
| | | } |
| | |
| | | flowTaskDTO.setVariables(variables); |
| | | } |
| | | |
| | | //流程阶段 |
| | | Map<String, Object> m = new HashMap<>(); |
| | | String templateId = variables.get("templateId").toString(); |
| | | m.put("template_id", templateId); |
| | | m.put("task_id", crruentActivityId); |
| | | m.put("model_key", modelKey); |
| | | QueryWrapper q = Condition.getQueryWrapper(m, ProcessStageAttr.class) |
| | | .select("attr_id attrId,attr_name attrName,attr_group attrGroup"); |
| | | List<ProcessStageAttr> stageAttrs = processStageAttrService.list(q); |
| | | List<ProcessStageAttrDTO> stageAttrsDto = new ArrayList<>(); |
| | | stageAttrs.stream().forEach(e->{ |
| | | ProcessStageAttrDTO dto = new ProcessStageAttrDTO(); |
| | | BeanUtil.convert(e,dto); |
| | | stageAttrsDto.add(dto); |
| | | }); |
| | | flowTaskDTO.setStageAttrs(stageAttrsDto); |
| | | |
| | | //放入流程阶段、流程modelkey |
| | | variables.put(TASKID,crruentActivityId); |
| | | flowTaskDTO.setProcessInstanceId(processInstanceId); |
| | | variables.put(PROCESSINSTANCEID,processInstanceId); |
| | | return flowTaskDTO; |
| | | } |
| | | } |