|
@@ -11,6 +11,7 @@ import com.google.common.collect.Lists;
|
|
|
import com.google.common.collect.Maps;
|
|
|
import com.jeeplus.common.utils.Collections3;
|
|
|
import com.jeeplus.flowable.constant.FlowableConstant;
|
|
|
+import com.jeeplus.flowable.model.ActHiIdentitylink;
|
|
|
import com.jeeplus.flowable.vo.*;
|
|
|
import com.jeeplus.flowable.common.cmd.BackUserTaskCmd;
|
|
|
import com.jeeplus.flowable.model.Flow;
|
|
@@ -24,16 +25,22 @@ import com.jeeplus.sys.utils.StringUtils;
|
|
|
import com.jeeplus.sys.utils.UserUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.flowable.bpmn.constants.BpmnXMLConstants;
|
|
|
-import org.flowable.bpmn.model.BpmnModel;
|
|
|
-import org.flowable.bpmn.model.FlowNode;
|
|
|
+import org.flowable.bpmn.model.*;
|
|
|
import org.flowable.bpmn.model.Process;
|
|
|
+import org.flowable.common.engine.impl.de.odysseus.el.ExpressionFactoryImpl;
|
|
|
+import org.flowable.common.engine.impl.de.odysseus.el.util.SimpleContext;
|
|
|
+import org.flowable.common.engine.impl.javax.el.ExpressionFactory;
|
|
|
+import org.flowable.common.engine.impl.javax.el.ValueExpression;
|
|
|
import org.flowable.editor.language.json.converter.util.CollectionUtils;
|
|
|
import org.flowable.engine.*;
|
|
|
import org.flowable.engine.history.HistoricActivityInstance;
|
|
|
import org.flowable.engine.history.HistoricProcessInstance;
|
|
|
import org.flowable.engine.history.HistoricProcessInstanceQuery;
|
|
|
+import org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl;
|
|
|
+import org.flowable.engine.impl.util.CommandContextUtil;
|
|
|
import org.flowable.engine.runtime.ActivityInstance;
|
|
|
import org.flowable.engine.runtime.ProcessInstance;
|
|
|
+import org.flowable.identitylink.service.impl.persistence.entity.IdentityLinkEntity;
|
|
|
import org.flowable.task.api.DelegationState;
|
|
|
import org.flowable.task.api.Task;
|
|
|
import org.flowable.task.api.TaskQuery;
|
|
@@ -392,6 +399,10 @@ public class FlowTaskService {
|
|
|
// 启动流程
|
|
|
ProcessInstance procIns = runtimeService.startProcessInstanceByKey (procDefKey, businessTable + ":" + businessId, vars);
|
|
|
|
|
|
+ //FlowNode currentTask = this.getNextTask(procIns.getProcessInstanceId());
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
// 更新业务表流程实例ID
|
|
|
Flow act = new Flow ();
|
|
|
act.setBusinessTable (businessTable);// 业务表名
|
|
@@ -405,6 +416,118 @@ public class FlowTaskService {
|
|
|
|
|
|
|
|
|
/**
|
|
|
+ * 获取当前节点信息
|
|
|
+ * @param processInstanceId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private FlowNode getCurrentTask(String processInstanceId){
|
|
|
+ //当前任务信息
|
|
|
+ Task task =taskService.createTaskQuery().processInstanceId(processInstanceId).active().singleResult();
|
|
|
+
|
|
|
+ if(task!=null) {
|
|
|
+ //获取流程发布Id信息
|
|
|
+ String definitionId = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult().getProcessDefinitionId();
|
|
|
+ //获取bpm对象
|
|
|
+ BpmnModel bpmnModel = SpringUtil.getBean (RepositoryService.class).getBpmnModel(definitionId);
|
|
|
+ //传节点定义key 获取当前节点
|
|
|
+ FlowNode flowNode = (FlowNode) bpmnModel.getFlowElement(task.getTaskDefinitionKey());
|
|
|
+ return flowNode;
|
|
|
+ }else{
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取流程实例的下一个节点的信息 BPMN
|
|
|
+ * 流程实例id
|
|
|
+ * 在遇到网关、分支的时候可能出现问题
|
|
|
+ */
|
|
|
+ @Deprecated
|
|
|
+ private UserTask getNextTask(String processInstanceId) {
|
|
|
+ UserTask userTask=null;
|
|
|
+ //当前任务信息
|
|
|
+ Task task =taskService.createTaskQuery().processInstanceId(processInstanceId).active().singleResult();
|
|
|
+
|
|
|
+ if(task!=null) {
|
|
|
+ //获取流程发布Id信息
|
|
|
+ String definitionId = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult().getProcessDefinitionId();
|
|
|
+ //获取bpm对象
|
|
|
+ BpmnModel bpmnModel = SpringUtil.getBean (RepositoryService.class).getBpmnModel(definitionId);
|
|
|
+ //传节点定义key 获取当前节点
|
|
|
+ FlowNode flowNode = (FlowNode) bpmnModel.getFlowElement(task.getTaskDefinitionKey());
|
|
|
+ //输出连线
|
|
|
+ List<SequenceFlow> outgoingFlows = flowNode.getOutgoingFlows();
|
|
|
+ //遍历返回下一个节点信息
|
|
|
+ for (SequenceFlow outgoingFlow : outgoingFlows) {
|
|
|
+ //类型自己判断
|
|
|
+ FlowElement targetFlowElement = outgoingFlow.getTargetFlowElement();
|
|
|
+ //用户任务
|
|
|
+ if (targetFlowElement instanceof UserTask) {
|
|
|
+ userTask = (UserTask) targetFlowElement;
|
|
|
+ break;
|
|
|
+ }else if (targetFlowElement instanceof EndEvent) {
|
|
|
+ return null;
|
|
|
+ }else{
|
|
|
+ Map proInsMap=runtimeService.getVariables(processInstanceId);
|
|
|
+ return setExclusiveGateway(targetFlowElement,proInsMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return userTask;
|
|
|
+ }else{
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private UserTask setExclusiveGateway(FlowElement targetFlow, Map proInsMap) {
|
|
|
+
|
|
|
+ List<SequenceFlow> targetFlows = ((Gateway) targetFlow).getOutgoingFlows();
|
|
|
+ for (SequenceFlow sequenceFlow : targetFlows) {
|
|
|
+ try {
|
|
|
+ if(checkFormDataByRuleEl(sequenceFlow.getConditionExpression(),proInsMap)) {
|
|
|
+ //目标节点信息
|
|
|
+ FlowElement targetFlowElement = sequenceFlow.getTargetFlowElement();
|
|
|
+
|
|
|
+ if (targetFlowElement instanceof UserTask) {
|
|
|
+ return (UserTask) targetFlowElement;
|
|
|
+ } else if (targetFlowElement instanceof EndEvent) {
|
|
|
+ return null;
|
|
|
+ } else if (targetFlowElement instanceof ServiceTask) {
|
|
|
+ return (UserTask) targetFlowElement;//不一定对 按照UserTask 来
|
|
|
+ } else if (targetFlowElement instanceof Gateway) {
|
|
|
+ //递归寻找
|
|
|
+ setExclusiveGateway(targetFlowElement,proInsMap);
|
|
|
+ } else if (targetFlowElement instanceof SubProcess) {
|
|
|
+ return null;//目前不管
|
|
|
+ } else {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ private Boolean checkFormDataByRuleEl(String el, Map<String, Object> formData) throws Exception {
|
|
|
+
|
|
|
+ ExpressionFactory factory = new ExpressionFactoryImpl();
|
|
|
+ SimpleContext context = new SimpleContext();
|
|
|
+ for (Object k : formData.keySet()) {
|
|
|
+ if (formData.get(k) != null) {
|
|
|
+ context.setVariable(k.toString(), factory.createValueExpression(formData.get(k), formData.get(k).getClass()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ValueExpression e = factory.createValueExpression(context, el, Boolean.class);
|
|
|
+ return (Boolean) e.getValue(context);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
* 删除任务
|
|
|
*
|
|
|
* @param taskId 任务ID
|