完善工作流的注释

This commit is contained in:
YunaiV 2022-07-20 00:34:44 +08:00
parent 8dadc51920
commit b0cdfd7afc
7 changed files with 24 additions and 49 deletions

View File

@ -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 '审批建议',

View File

@ -14,6 +14,7 @@
<name>${project.artifactId}</name>
<description>微信拓展
1. 基于 weixin-java-mp 库,对接微信公众号平台。目前主要解决微信公众号的支付场景。
2. 基于 weixin-java-miniapp 库,对接微信小程序。目前主要解决微信小程序的一键登录场景。
</description>
<url>https://github.com/YunaiV/ruoyi-vue-pro</url>

View File

@ -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;

View File

@ -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());
}
}

View File

@ -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());
}

View File

@ -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());
// 注意 1ProcessDefinition key name 是通过 BPMN 中的 <bpmn2:process /> id name 决定
// 注意 2目前该项目的设计上需要保证 ModelDeploymentProcessDefinition 使用相同的 key保证关联性
@ -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);

View File

@ -35,7 +35,7 @@
<el-col v-if="this.processInstance.processDefinition && this.processInstance.processDefinition.formType === 10"
:span="16" :offset="6">
<div >
<parser :key="new Date().getTime()" :form-conf="detailForm" @submit="submitForm" />
<parser :key="new Date().getTime()" :form-conf="detailForm" />
</div>
</el-col>
<div v-if="this.processInstance.processDefinition && this.processInstance.processDefinition.formType === 20">
@ -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);
},