From 3acb56f880a8f305461d55956d4a34b868c56263 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 16 Jan 2022 00:36:04 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E6=B5=81=E7=A8=8B=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E5=88=97=E8=A1=A8=EF=BC=8C=E5=A2=9E=E5=8A=A0=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E5=88=86=E9=85=8D=E8=A7=84=E5=88=99=E7=9A=84=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=202.=20=E6=B5=81=E7=A8=8B=E5=AE=9A=E4=B9=89=E5=88=97=E8=A1=A8?= =?UTF-8?q?=EF=BC=8C=E6=8C=89=E7=85=A7=20version=20=E5=80=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../definition/impl/BpmModelServiceImpl.java | 28 +++++++++++-------- .../impl/BpmProcessDefinitionServiceImpl.java | 2 +- .../src/views/bpm/definition/index.vue | 18 +++++++++++- yudao-admin-ui/src/views/bpm/task/done.vue | 2 +- .../taskAssignRule/taskAssignRuleDialog.vue | 5 ++-- 5 files changed, 38 insertions(+), 17 deletions(-) diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmModelServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmModelServiceImpl.java index 01ec8ed68..476dbb7b4 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmModelServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmModelServiceImpl.java @@ -52,6 +52,7 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils. * 主要进行 Activiti {@link Model} 的维护 * * @author yunlongn + * @author 芋道源码 */ @Service @Validated @@ -189,12 +190,7 @@ public class BpmModelServiceImpl implements BpmModelService { String definitionId = processDefinitionService.createProcessDefinition(definitionCreateReqDTO); // 将老的流程定义进行挂起。也就是说,只有最新部署的流程定义,才可以发起任务。 - if (StrUtil.isNotEmpty(model.getDeploymentId())) { - ProcessDefinition oldDefinition = processDefinitionService.getProcessDefinitionByDeploymentId(model.getDeploymentId()); - if (oldDefinition != null) { - processDefinitionService.updateProcessDefinitionState(oldDefinition.getId(), SuspensionState.SUSPENDED.getStateCode()); - } - } + updateProcessDefinitionSuspended(model.getDeploymentId()); // 更新 model 的 deploymentId,进行关联 ProcessDefinition definition = processDefinitionService.getProcessDefinition(definitionId); @@ -226,6 +222,7 @@ public class BpmModelServiceImpl implements BpmModelService { } @Override + @Transactional(rollbackFor = Exception.class) public void deleteModel(String id) { // 校验流程模型存在 Model model = repositoryService.getModel(id); @@ -234,6 +231,19 @@ public class BpmModelServiceImpl implements BpmModelService { } // 执行删除 repositoryService.deleteModel(id); + // 禁用流程实例 + updateProcessDefinitionSuspended(model.getDeploymentId()); + } + + private void updateProcessDefinitionSuspended(String deploymentId) { + if (StrUtil.isEmpty(deploymentId)) { + return; + } + ProcessDefinition oldDefinition = processDefinitionService.getProcessDefinitionByDeploymentId(deploymentId); + if (oldDefinition == null) { + return; + } + processDefinitionService.updateProcessDefinitionState(oldDefinition.getId(), SuspensionState.SUSPENDED.getStateCode()); } @Override @@ -272,10 +282,4 @@ public class BpmModelServiceImpl implements BpmModelService { } } - public static void main(String[] args) { - // 创建转换对象 - BpmnXMLConverter converter = new BpmnXMLConverter(); - BpmnModel bpmnModel = converter.convertToBpmnModel(new StringStreamSource(""), true, true); - } - } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmProcessDefinitionServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmProcessDefinitionServiceImpl.java index a99774bf9..fdb8abb30 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmProcessDefinitionServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmProcessDefinitionServiceImpl.java @@ -67,7 +67,7 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ definitionQuery.processDefinitionKey(pageVO.getKey()); } // 执行查询 - List processDefinitions = definitionQuery.orderByProcessDefinitionId().desc() + List processDefinitions = definitionQuery.orderByProcessDefinitionVersion().desc() .listPage(PageUtils.getStart(pageVO), pageVO.getPageSize()); if (CollUtil.isEmpty(processDefinitions)) { return new PageResult<>(Collections.emptyList(), definitionQuery.count()); diff --git a/yudao-admin-ui/src/views/bpm/definition/index.vue b/yudao-admin-ui/src/views/bpm/definition/index.vue index 2b6554af5..6960c0a01 100644 --- a/yudao-admin-ui/src/views/bpm/definition/index.vue +++ b/yudao-admin-ui/src/views/bpm/definition/index.vue @@ -41,6 +41,13 @@ + + + @@ -56,6 +63,9 @@ + + + @@ -65,11 +75,13 @@ import {DICT_TYPE, getDictDatas} from "@/utils/dict"; import {getForm} from "@/api/bpm/form"; import {decodeFields} from "@/utils/formGenerator"; import Parser from '@/components/parser/Parser' +import taskAssignRuleDialog from "../taskAssignRule/taskAssignRuleDialog"; export default { name: "processDefinition", components: { - Parser + Parser, + taskAssignRuleDialog }, data() { return { @@ -141,6 +153,10 @@ export default { this.showBpmnOpen = true }) }, + /** 处理任务分配规则列表的按钮操作 */ + handleAssignRule(row) { + this.$refs['taskAssignRuleDialog'].initProcessDefinition(row.id); + }, } }; diff --git a/yudao-admin-ui/src/views/bpm/task/done.vue b/yudao-admin-ui/src/views/bpm/task/done.vue index 9d63a2f7e..c738d2211 100644 --- a/yudao-admin-ui/src/views/bpm/task/done.vue +++ b/yudao-admin-ui/src/views/bpm/task/done.vue @@ -87,7 +87,7 @@ export default { showSearch: true, // 总条数 total: 0, - // 待办任务列表 + // 已办任务列表 list: [], // 查询参数 dateRangeCreateTime: [], diff --git a/yudao-admin-ui/src/views/bpm/taskAssignRule/taskAssignRuleDialog.vue b/yudao-admin-ui/src/views/bpm/taskAssignRule/taskAssignRuleDialog.vue index 654a2390e..093508599 100644 --- a/yudao-admin-ui/src/views/bpm/taskAssignRule/taskAssignRuleDialog.vue +++ b/yudao-admin-ui/src/views/bpm/taskAssignRule/taskAssignRuleDialog.vue @@ -10,14 +10,14 @@ {{ getDictDataLabel(DICT_TYPE.BPM_TASK_ASSIGN_RULE_TYPE, scope.row.type) }} - + - +