Commit b0cdfd7afc59ac605320ab0d3cb002fe26ab8d8b
1 parent
8dadc519
完善工作流的注释
Showing
7 changed files
with
24 additions
and
49 deletions
sql/mysql/ruoyi-vue-pro.sql
| ... | ... | @@ -431,7 +431,6 @@ CREATE TABLE `bpm_task_ext` ( |
| 431 | 431 | `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号', |
| 432 | 432 | `assignee_user_id` bigint NULL DEFAULT NULL COMMENT '任务的审批人', |
| 433 | 433 | `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '任务的名字', |
| 434 | - `task_def_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '流程任务key', | |
| 435 | 434 | `task_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '任务的编号', |
| 436 | 435 | `result` tinyint NOT NULL COMMENT '任务的结果', |
| 437 | 436 | `reason` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '审批建议', | ... | ... |
yudao-framework/yudao-spring-boot-starter-biz-weixin/pom.xml
| ... | ... | @@ -14,6 +14,7 @@ |
| 14 | 14 | <name>${project.artifactId}</name> |
| 15 | 15 | <description>微信拓展 |
| 16 | 16 | 1. 基于 weixin-java-mp 库,对接微信公众号平台。目前主要解决微信公众号的支付场景。 |
| 17 | + 2. 基于 weixin-java-miniapp 库,对接微信小程序。目前主要解决微信小程序的一键登录场景。 | |
| 17 | 18 | </description> |
| 18 | 19 | <url>https://github.com/YunaiV/ruoyi-vue-pro</url> |
| 19 | 20 | ... | ... |
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 |
| 22 | 22 | @RequestMapping("/bpm/process-instance") |
| 23 | 23 | @Validated |
| 24 | 24 | public class BpmProcessInstanceController { |
| 25 | + | |
| 25 | 26 | @Resource |
| 26 | 27 | private BpmProcessInstanceService processInstanceService; |
| 27 | 28 | ... | ... |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.bpm.service.definition; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.lang.Assert; |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 5 | +import cn.iocoder.yudao.framework.common.util.json.JsonUtils; | |
| 4 | 6 | import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; |
| 5 | 7 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormCreateReqVO; |
| 6 | 8 | 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; |
| 11 | 13 | import cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants; |
| 12 | 14 | import cn.iocoder.yudao.module.bpm.enums.definition.BpmModelFormTypeEnum; |
| 13 | 15 | import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmFormFieldRespDTO; |
| 14 | -import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; | |
| 15 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 16 | -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; | |
| 17 | 16 | import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmModelMetaInfoRespDTO; |
| 18 | 17 | import org.springframework.stereotype.Service; |
| 19 | 18 | import org.springframework.validation.annotation.Validated; |
| ... | ... | @@ -66,7 +65,7 @@ public class BpmFormServiceImpl implements BpmFormService { |
| 66 | 65 | |
| 67 | 66 | private void validateFormExists(Long id) { |
| 68 | 67 | if (formMapper.selectById(id) == null) { |
| 69 | - throw ServiceExceptionUtil.exception(ErrorCodeConstants.FORM_NOT_EXISTS); | |
| 68 | + throw exception(ErrorCodeConstants.FORM_NOT_EXISTS); | |
| 70 | 69 | } |
| 71 | 70 | } |
| 72 | 71 | |
| ... | ... | @@ -129,7 +128,7 @@ public class BpmFormServiceImpl implements BpmFormService { |
| 129 | 128 | continue; |
| 130 | 129 | } |
| 131 | 130 | // 如果存在,则报错 |
| 132 | - throw ServiceExceptionUtil.exception(ErrorCodeConstants.FORM_FIELD_REPEAT, oldLabel, fieldDTO.getLabel(), fieldDTO.getVModel()); | |
| 131 | + throw exception(ErrorCodeConstants.FORM_FIELD_REPEAT, oldLabel, fieldDTO.getLabel(), fieldDTO.getVModel()); | |
| 133 | 132 | } |
| 134 | 133 | } |
| 135 | 134 | ... | ... |
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 { |
| 99 | 99 | public String createModel(@Valid BpmModelCreateReqVO createReqVO, String bpmnXml) { |
| 100 | 100 | checkKeyNCName(createReqVO.getKey()); |
| 101 | 101 | // 校验流程标识已经存在 |
| 102 | - Model keyModel = this.getModelByKey(createReqVO.getKey()); | |
| 102 | + Model keyModel = getModelByKey(createReqVO.getKey()); | |
| 103 | 103 | if (keyModel != null) { |
| 104 | 104 | throw exception(MODEL_KEY_EXISTS, createReqVO.getKey()); |
| 105 | 105 | } |
| ... | ... | @@ -151,42 +151,43 @@ public class BpmModelServiceImpl implements BpmModelService { |
| 151 | 151 | @Override |
| 152 | 152 | @Transactional(rollbackFor = Exception.class) // 因为进行多个操作,所以开启事务 |
| 153 | 153 | public void deployModel(String id) { |
| 154 | - // 校验流程模型存在 | |
| 154 | + // 1.1 校验流程模型存在 | |
| 155 | 155 | Model model = repositoryService.getModel(id); |
| 156 | 156 | if (ObjectUtils.isEmpty(model)) { |
| 157 | 157 | throw exception(MODEL_NOT_EXISTS); |
| 158 | 158 | } |
| 159 | - // 校验流程图 | |
| 159 | + // 1.2 校验流程图 | |
| 160 | + // TODO 芋艿:校验流程图的有效性;例如说,是否有开始的元素,是否有结束的元素; | |
| 160 | 161 | byte[] bpmnBytes = repositoryService.getModelEditorSource(model.getId()); |
| 161 | 162 | if (bpmnBytes == null) { |
| 162 | 163 | throw exception(MODEL_NOT_EXISTS); |
| 163 | 164 | } |
| 164 | - // TODO 芋艿:校验流程图的有效性;例如说,是否有开始的元素,是否有结束的元素; | |
| 165 | - // 校验表单已配 | |
| 165 | + // 1.3 校验表单已配 | |
| 166 | 166 | BpmFormDO form = checkFormConfig(model.getMetaInfo()); |
| 167 | - //校验任务分配规则已配置 | |
| 167 | + // 1.4 校验任务分配规则已配置 | |
| 168 | 168 | taskAssignRuleService.checkTaskAssignRuleAllConfig(id); |
| 169 | 169 | |
| 170 | + // 1.5 校验模型是否发生修改。如果未修改,则不允许创建 | |
| 170 | 171 | BpmProcessDefinitionCreateReqDTO definitionCreateReqDTO = BpmModelConvert.INSTANCE.convert2(model, form).setBpmnBytes(bpmnBytes); |
| 171 | - //校验模型是否发生修改。如果未修改,则不允许创建 | |
| 172 | 172 | if (processDefinitionService.isProcessDefinitionEquals(definitionCreateReqDTO)) { // 流程定义的信息相等 |
| 173 | - ProcessDefinition oldProcessInstance = processDefinitionService.getProcessDefinitionByDeploymentId(model.getDeploymentId()); | |
| 174 | - if (oldProcessInstance != null && taskAssignRuleService.isTaskAssignRulesEquals(model.getId(), oldProcessInstance.getId())) { | |
| 173 | + ProcessDefinition oldProcessDefinition = processDefinitionService.getProcessDefinitionByDeploymentId(model.getDeploymentId()); | |
| 174 | + if (oldProcessDefinition != null && taskAssignRuleService.isTaskAssignRulesEquals(model.getId(), oldProcessDefinition.getId())) { | |
| 175 | 175 | throw exception(MODEL_DEPLOY_FAIL_TASK_INFO_EQUALS); |
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | - // 创建流程定义 | |
| 178 | + | |
| 179 | + // 2.1 创建流程定义 | |
| 179 | 180 | String definitionId = processDefinitionService.createProcessDefinition(definitionCreateReqDTO); |
| 180 | 181 | |
| 181 | - // 将老的流程定义进行挂起。也就是说,只有最新部署的流程定义,才可以发起任务。 | |
| 182 | + // 2.2 将老的流程定义进行挂起。也就是说,只有最新部署的流程定义,才可以发起任务。 | |
| 182 | 183 | updateProcessDefinitionSuspended(model.getDeploymentId()); |
| 183 | 184 | |
| 184 | - // 更新 model 的 deploymentId,进行关联 | |
| 185 | + // 2.3 更新 model 的 deploymentId,进行关联 | |
| 185 | 186 | ProcessDefinition definition = processDefinitionService.getProcessDefinition(definitionId); |
| 186 | 187 | model.setDeploymentId(definition.getDeploymentId()); |
| 187 | 188 | repositoryService.saveModel(model); |
| 188 | 189 | |
| 189 | - //复制任务分配规则 | |
| 190 | + // 2.4 复制任务分配规则 | |
| 190 | 191 | taskAssignRuleService.copyTaskAssignRules(id, definition.getId()); |
| 191 | 192 | } |
| 192 | 193 | ... | ... |
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 |
| 127 | 127 | .deploy(); |
| 128 | 128 | |
| 129 | 129 | // 设置 ProcessDefinition 的 category 分类 |
| 130 | - ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().deploymentId(deploy.getId()).singleResult(); | |
| 130 | + ProcessDefinition definition = repositoryService.createProcessDefinitionQuery() | |
| 131 | + .deploymentId(deploy.getId()).singleResult(); | |
| 131 | 132 | repositoryService.setProcessDefinitionCategory(definition.getId(), createReqDTO.getCategory()); |
| 132 | 133 | // 注意 1,ProcessDefinition 的 key 和 name 是通过 BPMN 中的 <bpmn2:process /> 的 id 和 name 决定 |
| 133 | 134 | // 注意 2,目前该项目的设计上,需要保证 Model、Deployment、ProcessDefinition 使用相同的 key,保证关联性。 |
| ... | ... | @@ -198,7 +199,7 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ |
| 198 | 199 | // 校验 BPMN XML 信息 |
| 199 | 200 | BpmnModel newModel = buildBpmnModel(createReqDTO.getBpmnBytes()); |
| 200 | 201 | BpmnModel oldModel = getBpmnModel(oldProcessDefinition.getId()); |
| 201 | - //TODO 貌似 flowable 不修改这个也不同。需要看看。 sourceSystemId 不同 | |
| 202 | + // TODO 貌似 flowable 不修改这个也不同。需要看看。 sourceSystemId 不同 | |
| 202 | 203 | if (FlowableUtils.equals(oldModel, newModel)) { |
| 203 | 204 | return false; |
| 204 | 205 | } |
| ... | ... | @@ -218,8 +219,6 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ |
| 218 | 219 | return converter.convertToBpmnModel(new BytesStreamSource(bpmnBytes), true, true); |
| 219 | 220 | } |
| 220 | 221 | |
| 221 | - | |
| 222 | - | |
| 223 | 222 | @Override |
| 224 | 223 | public BpmProcessDefinitionExtDO getProcessDefinitionExt(String id) { |
| 225 | 224 | return processDefinitionMapper.selectByProcessDefinitionId(id); | ... | ... |
yudao-ui-admin/src/views/bpm/processInstance/detail.vue
| ... | ... | @@ -35,7 +35,7 @@ |
| 35 | 35 | <el-col v-if="this.processInstance.processDefinition && this.processInstance.processDefinition.formType === 10" |
| 36 | 36 | :span="16" :offset="6"> |
| 37 | 37 | <div > |
| 38 | - <parser :key="new Date().getTime()" :form-conf="detailForm" @submit="submitForm" /> | |
| 38 | + <parser :key="new Date().getTime()" :form-conf="detailForm" /> | |
| 39 | 39 | </div> |
| 40 | 40 | </el-col> |
| 41 | 41 | <div v-if="this.processInstance.processDefinition && this.processInstance.processDefinition.formType === 20"> |
| ... | ... | @@ -290,31 +290,6 @@ export default { |
| 290 | 290 | // 这里暂时无需加载流程图,因为跳出到另外个 Tab; |
| 291 | 291 | } |
| 292 | 292 | }, |
| 293 | - /** 提交按钮 */ | |
| 294 | - submitForm(params) { | |
| 295 | - if (!params) { | |
| 296 | - return; | |
| 297 | - } | |
| 298 | - // 设置表单禁用 | |
| 299 | - const conf = params.conf; | |
| 300 | - conf.disabled = true; // 表单禁用 | |
| 301 | - conf.formBtns = false; // 按钮隐藏 | |
| 302 | - | |
| 303 | - // 提交表单,创建流程 | |
| 304 | - const variables = params.values; | |
| 305 | - createProcessInstance({ | |
| 306 | - processDefinitionId: this.selectProcessInstance.id, | |
| 307 | - variables: variables | |
| 308 | - }).then(response => { | |
| 309 | - this.$modal.msgSuccess("发起流程成功"); | |
| 310 | - // 关闭当前窗口 | |
| 311 | - this.$tab.closeOpenPage(); | |
| 312 | - this.$router.go(-1); | |
| 313 | - }).catch(() => { | |
| 314 | - conf.disabled = false; // 表单开启 | |
| 315 | - conf.formBtns = true; // 按钮展示 | |
| 316 | - }) | |
| 317 | - }, | |
| 318 | 293 | getDateStar(ms) { |
| 319 | 294 | return getDate(ms); |
| 320 | 295 | }, | ... | ... |