赞
踩
正常工作流,需要经过 node1、node2 才能结束。
现在要求已经开启的流程,目前停留在 node1,可以提前终止。
一般根据实际需要,可以有几种做法:
下面分析一下这些方式的应用场景及优缺点。
UPDATE ACT_GE_BYTEARRAY SET BYTES_ = '新流程的对应值' WHERE _ID = xxx AND NAME_ = 'xxxxx.bpmn';
## 以下根据情况可选,在使用 activiti5 时有碰到
UPDATE ACT_GE_BYTEARRAY SET BYTES_ = '新流程的对应值' WHERE _ID = xxx AND NAME_ = 'xxx.png';
UPDATE ACT_GE_BYTEARRAY SET BYTES_ = '新流程的对应值' WHERE _ID = xxx AND NAME_ = 'source';
UPDATE ACT_GE_BYTEARRAY SET BYTES_ = '新流程的对应值' WHERE _ID = xxx AND NAME_ = 'source-extra';
后续根据条件,正确提交即可,可以正常流转。
改动是全局的;
工作流模型改动有良好的版本管理和上线流程;
流程图需要体现这个分支流程(是正常业务应该关心的流转)
DELETE FROM act_ru_task WHERE ID_ = 'xxxx';
DELETE FROM act_ru_variable WHERE PROC_INST_ID_ = 'xxxx';
DELETE FROM act_ru_execution WHERE ID_ = 'xxxx';
UPDATE act_hi_taskinst SET END_TIME_ = '2023-02-20 21:57:47.033000', DURATION_= 4180506 WHERE ID_ = 'xxxx';
UPDATE act_hi_procinstSET END_TIME_ = '2023-02-20 21:57:47.033000', DURATION_= 4180506, END_ACT_ID_ = 'endevent_oc' WHERE PROC_INST_ID_ = 'xxxx';
一次性流程关闭,无业务数据修复
/** * 提前终止业务流程实例,适用场景:当前任务节点没有对应的流程结束节点(业务变更导致需要终止流程) */ public void terminateProcessByBusinessKey(String businessKey) { taskService.createTaskQuery() .processInstanceBusinessKey(businessKey) .list() .forEach(task -> terminateProcessByTask(task.getId(), task)); } private void terminateProcessByTask(String taskId, Task task) { if (Objects.isNull(task)) { log.warn("流程任务实例不存在. taskId: {}", taskId); return; } BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId()); EndEvent endEvent = bpmnModel.getMainProcess().findFlowElementsOfType(EndEvent.class).get(0); FlowNode currentNode = (FlowNode) bpmnModel.getMainProcess().getFlowElement(task.getTaskDefinitionKey()); List<SequenceFlow> orignOutgoingFlows = currentNode.getOutgoingFlows(); SequenceFlow endFlow = new SequenceFlow(); endFlow.setId("flow_to_temp_end"); endFlow.setSourceFlowElement(currentNode); endFlow.setTargetFlowElement(endEvent); // 将当前节点的出向分支替换为流向 flow_to_temp_end currentNode.setOutgoingFlows(Lists.newArrayList(endFlow)); taskService.complete(taskId); // 流转完恢复 currentNode.setOutgoingFlows(orignOutgoingFlows); log.info("非正常方式完成流程. taskId: {},procDefKey: {},caseNo:{}", taskId, bpmnModel.getMainProcess().getId(), task.getBusinessKey()); }
图例:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。