From b0cdfd7afc59ac605320ab0d3cb002fe26ab8d8b Mon Sep 17 00:00:00 2001 From: YunaiV Date: Wed, 20 Jul 2022 00:34:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=B7=A5=E4=BD=9C=E6=B5=81?= =?UTF-8?q?=E7=9A=84=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/mysql/ruoyi-vue-pro.sql | 1 - .../pom.xml | 1 + .../task/BpmProcessInstanceController.java | 1 + .../definition/BpmFormServiceImpl.java | 9 +++---- .../definition/BpmModelServiceImpl.java | 27 ++++++++++--------- .../BpmProcessDefinitionServiceImpl.java | 7 +++-- .../src/views/bpm/processInstance/detail.vue | 27 +------------------ 7 files changed, 24 insertions(+), 49 deletions(-) diff --git a/sql/mysql/ruoyi-vue-pro.sql b/sql/mysql/ruoyi-vue-pro.sql index 12e77d40f5..8601d6df98 100644 --- a/sql/mysql/ruoyi-vue-pro.sql +++ b/sql/mysql/ruoyi-vue-pro.sql @@ -431,7 +431,6 @@ CREATE TABLE `bpm_task_ext` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号', `assignee_user_id` bigint NULL DEFAULT NULL COMMENT '任务的审批人', `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '任务的名字', - `task_def_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '流程任务key', `task_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '任务的编号', `result` tinyint NOT NULL COMMENT '任务的结果', `reason` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '审批建议', diff --git a/yudao-framework/yudao-spring-boot-starter-biz-weixin/pom.xml b/yudao-framework/yudao-spring-boot-starter-biz-weixin/pom.xml index 4c53e29001..9572391db3 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-weixin/pom.xml +++ b/yudao-framework/yudao-spring-boot-starter-biz-weixin/pom.xml @@ -14,6 +14,7 @@ ${project.artifactId} 微信拓展 1. 基于 weixin-java-mp 库,对接微信公众号平台。目前主要解决微信公众号的支付场景。 + 2. 基于 weixin-java-miniapp 库,对接微信小程序。目前主要解决微信小程序的一键登录场景。 https://github.com/YunaiV/ruoyi-vue-pro diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.java index 851a83ce53..31abf7de12 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.java @@ -22,6 +22,7 @@ import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUti @RequestMapping("/bpm/process-instance") @Validated public class BpmProcessInstanceController { + @Resource private BpmProcessInstanceService processInstanceService; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormServiceImpl.java index d64684b829..967ab8f496 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormServiceImpl.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormServiceImpl.java @@ -1,6 +1,8 @@ package cn.iocoder.yudao.module.bpm.service.definition; import cn.hutool.core.lang.Assert; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.json.JsonUtils; import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormCreateReqVO; import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormPageReqVO; @@ -11,9 +13,6 @@ import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmFormMapper; import cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants; import cn.iocoder.yudao.module.bpm.enums.definition.BpmModelFormTypeEnum; import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmFormFieldRespDTO; -import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmModelMetaInfoRespDTO; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; @@ -66,7 +65,7 @@ public class BpmFormServiceImpl implements BpmFormService { private void validateFormExists(Long id) { if (formMapper.selectById(id) == null) { - throw ServiceExceptionUtil.exception(ErrorCodeConstants.FORM_NOT_EXISTS); + throw exception(ErrorCodeConstants.FORM_NOT_EXISTS); } } @@ -129,7 +128,7 @@ public class BpmFormServiceImpl implements BpmFormService { continue; } // 如果存在,则报错 - throw ServiceExceptionUtil.exception(ErrorCodeConstants.FORM_FIELD_REPEAT, oldLabel, fieldDTO.getLabel(), fieldDTO.getVModel()); + throw exception(ErrorCodeConstants.FORM_FIELD_REPEAT, oldLabel, fieldDTO.getLabel(), fieldDTO.getVModel()); } } diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelServiceImpl.java index dcb0b9e473..a4a2d9182c 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelServiceImpl.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelServiceImpl.java @@ -99,7 +99,7 @@ public class BpmModelServiceImpl implements BpmModelService { public String createModel(@Valid BpmModelCreateReqVO createReqVO, String bpmnXml) { checkKeyNCName(createReqVO.getKey()); // 校验流程标识已经存在 - Model keyModel = this.getModelByKey(createReqVO.getKey()); + Model keyModel = getModelByKey(createReqVO.getKey()); if (keyModel != null) { throw exception(MODEL_KEY_EXISTS, createReqVO.getKey()); } @@ -151,42 +151,43 @@ public class BpmModelServiceImpl implements BpmModelService { @Override @Transactional(rollbackFor = Exception.class) // 因为进行多个操作,所以开启事务 public void deployModel(String id) { - // 校验流程模型存在 + // 1.1 校验流程模型存在 Model model = repositoryService.getModel(id); if (ObjectUtils.isEmpty(model)) { throw exception(MODEL_NOT_EXISTS); } - // 校验流程图 + // 1.2 校验流程图 + // TODO 芋艿:校验流程图的有效性;例如说,是否有开始的元素,是否有结束的元素; byte[] bpmnBytes = repositoryService.getModelEditorSource(model.getId()); if (bpmnBytes == null) { throw exception(MODEL_NOT_EXISTS); } - // TODO 芋艿:校验流程图的有效性;例如说,是否有开始的元素,是否有结束的元素; - // 校验表单已配 + // 1.3 校验表单已配 BpmFormDO form = checkFormConfig(model.getMetaInfo()); - //校验任务分配规则已配置 + // 1.4 校验任务分配规则已配置 taskAssignRuleService.checkTaskAssignRuleAllConfig(id); + // 1.5 校验模型是否发生修改。如果未修改,则不允许创建 BpmProcessDefinitionCreateReqDTO definitionCreateReqDTO = BpmModelConvert.INSTANCE.convert2(model, form).setBpmnBytes(bpmnBytes); - //校验模型是否发生修改。如果未修改,则不允许创建 if (processDefinitionService.isProcessDefinitionEquals(definitionCreateReqDTO)) { // 流程定义的信息相等 - ProcessDefinition oldProcessInstance = processDefinitionService.getProcessDefinitionByDeploymentId(model.getDeploymentId()); - if (oldProcessInstance != null && taskAssignRuleService.isTaskAssignRulesEquals(model.getId(), oldProcessInstance.getId())) { + ProcessDefinition oldProcessDefinition = processDefinitionService.getProcessDefinitionByDeploymentId(model.getDeploymentId()); + if (oldProcessDefinition != null && taskAssignRuleService.isTaskAssignRulesEquals(model.getId(), oldProcessDefinition.getId())) { throw exception(MODEL_DEPLOY_FAIL_TASK_INFO_EQUALS); } } - // 创建流程定义 + + // 2.1 创建流程定义 String definitionId = processDefinitionService.createProcessDefinition(definitionCreateReqDTO); - // 将老的流程定义进行挂起。也就是说,只有最新部署的流程定义,才可以发起任务。 + // 2.2 将老的流程定义进行挂起。也就是说,只有最新部署的流程定义,才可以发起任务。 updateProcessDefinitionSuspended(model.getDeploymentId()); - // 更新 model 的 deploymentId,进行关联 + // 2.3 更新 model 的 deploymentId,进行关联 ProcessDefinition definition = processDefinitionService.getProcessDefinition(definitionId); model.setDeploymentId(definition.getDeploymentId()); repositoryService.saveModel(model); - //复制任务分配规则 + // 2.4 复制任务分配规则 taskAssignRuleService.copyTaskAssignRules(id, definition.getId()); } diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionServiceImpl.java index b54e958130..35464ab6a8 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionServiceImpl.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionServiceImpl.java @@ -127,7 +127,8 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ .deploy(); // 设置 ProcessDefinition 的 category 分类 - ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().deploymentId(deploy.getId()).singleResult(); + ProcessDefinition definition = repositoryService.createProcessDefinitionQuery() + .deploymentId(deploy.getId()).singleResult(); repositoryService.setProcessDefinitionCategory(definition.getId(), createReqDTO.getCategory()); // 注意 1,ProcessDefinition 的 key 和 name 是通过 BPMN 中的 的 id 和 name 决定 // 注意 2,目前该项目的设计上,需要保证 Model、Deployment、ProcessDefinition 使用相同的 key,保证关联性。 @@ -198,7 +199,7 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ // 校验 BPMN XML 信息 BpmnModel newModel = buildBpmnModel(createReqDTO.getBpmnBytes()); BpmnModel oldModel = getBpmnModel(oldProcessDefinition.getId()); - //TODO 貌似 flowable 不修改这个也不同。需要看看。 sourceSystemId 不同 + // TODO 貌似 flowable 不修改这个也不同。需要看看。 sourceSystemId 不同 if (FlowableUtils.equals(oldModel, newModel)) { return false; } @@ -218,8 +219,6 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ return converter.convertToBpmnModel(new BytesStreamSource(bpmnBytes), true, true); } - - @Override public BpmProcessDefinitionExtDO getProcessDefinitionExt(String id) { return processDefinitionMapper.selectByProcessDefinitionId(id); diff --git a/yudao-ui-admin/src/views/bpm/processInstance/detail.vue b/yudao-ui-admin/src/views/bpm/processInstance/detail.vue index 5a5459a7a3..e9491c4a62 100644 --- a/yudao-ui-admin/src/views/bpm/processInstance/detail.vue +++ b/yudao-ui-admin/src/views/bpm/processInstance/detail.vue @@ -35,7 +35,7 @@
- +
@@ -290,31 +290,6 @@ export default { // 这里暂时无需加载流程图,因为跳出到另外个 Tab; } }, - /** 提交按钮 */ - submitForm(params) { - if (!params) { - return; - } - // 设置表单禁用 - const conf = params.conf; - conf.disabled = true; // 表单禁用 - conf.formBtns = false; // 按钮隐藏 - - // 提交表单,创建流程 - const variables = params.values; - createProcessInstance({ - processDefinitionId: this.selectProcessInstance.id, - variables: variables - }).then(response => { - this.$modal.msgSuccess("发起流程成功"); - // 关闭当前窗口 - this.$tab.closeOpenPage(); - this.$router.go(-1); - }).catch(() => { - conf.disabled = false; // 表单开启 - conf.formBtns = true; // 按钮展示 - }) - }, getDateStar(ms) { return getDate(ms); },