Merge branch 'master-jdk17' of https://gitee.com/zhijiantianya/ruoyi-vue-pro
# Conflicts: # yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelSaveReqVO.java # yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java
This commit is contained in:
commit
d676dcc525
|
@ -99,7 +99,8 @@ public class BpmModelController {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
byte[] bpmnBytes = modelService.getModelBpmnXML(id);
|
byte[] bpmnBytes = modelService.getModelBpmnXML(id);
|
||||||
return success(BpmModelConvert.INSTANCE.buildModel(model, bpmnBytes));
|
BpmSimpleModelNodeVO simpleModel = modelService.getSimpleModel(id);
|
||||||
|
return success(BpmModelConvert.INSTANCE.buildModel(model, bpmnBytes, simpleModel));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
|
@ -109,7 +110,6 @@ public class BpmModelController {
|
||||||
return success(modelService.createModel(createRetVO));
|
return success(modelService.createModel(createRetVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@PutMapping("/update")
|
@PutMapping("/update")
|
||||||
@Operation(summary = "修改模型")
|
@Operation(summary = "修改模型")
|
||||||
@PreAuthorize("@ss.hasPermission('bpm:model:update')")
|
@PreAuthorize("@ss.hasPermission('bpm:model:update')")
|
||||||
|
@ -143,6 +143,7 @@ public class BpmModelController {
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
@PutMapping("/update-bpmn")
|
@PutMapping("/update-bpmn")
|
||||||
@Operation(summary = "修改模型的 BPMN")
|
@Operation(summary = "修改模型的 BPMN")
|
||||||
@PreAuthorize("@ss.hasPermission('bpm:model:update')")
|
@PreAuthorize("@ss.hasPermission('bpm:model:update')")
|
||||||
|
@ -169,6 +170,7 @@ public class BpmModelController {
|
||||||
return success(modelService.getSimpleModel(modelId));
|
return success(modelService.getSimpleModel(modelId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
@PostMapping("/simple/update")
|
@PostMapping("/simple/update")
|
||||||
@Operation(summary = "保存仿钉钉流程设计模型")
|
@Operation(summary = "保存仿钉钉流程设计模型")
|
||||||
@PreAuthorize("@ss.hasPermission('bpm:model:update')")
|
@PreAuthorize("@ss.hasPermission('bpm:model:update')")
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model;
|
package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model;
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.bpm.controller.admin.base.user.UserSimpleBaseVO;
|
import cn.iocoder.yudao.module.bpm.controller.admin.base.user.UserSimpleBaseVO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelNodeVO;
|
||||||
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionRespVO;
|
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionRespVO;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
@ -35,12 +36,15 @@ public class BpmModelRespVO extends BpmModelMetaInfoVO {
|
||||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
@Schema(description = "BPMN XML", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
||||||
private String bpmnXml;
|
|
||||||
|
|
||||||
@Schema(description = "可发起的用户数组")
|
@Schema(description = "可发起的用户数组")
|
||||||
private List<UserSimpleBaseVO> startUsers;
|
private List<UserSimpleBaseVO> startUsers;
|
||||||
|
|
||||||
|
@Schema(description = "BPMN XML")
|
||||||
|
private String bpmnXml;
|
||||||
|
|
||||||
|
@Schema(description = "仿钉钉流程设计模型对象")
|
||||||
|
private BpmSimpleModelNodeVO simpleModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 最新部署的流程定义
|
* 最新部署的流程定义
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model;
|
package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelNodeVO;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import javax.validation.constraints.NotEmpty;
|
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 流程模型的保存 Request VO")
|
@Schema(description = "管理后台 - 流程模型的保存 Request VO")
|
||||||
@Data
|
@Data
|
||||||
public class BpmModelSaveReqVO extends BpmModelMetaInfoVO {
|
public class BpmModelSaveReqVO extends BpmModelMetaInfoVO {
|
||||||
|
@ -23,4 +24,11 @@ public class BpmModelSaveReqVO extends BpmModelMetaInfoVO {
|
||||||
@Schema(description = "流程分类", example = "1")
|
@Schema(description = "流程分类", example = "1")
|
||||||
private String category;
|
private String category;
|
||||||
|
|
||||||
|
@Schema(description = "BPMN XML")
|
||||||
|
private String bpmnXml;
|
||||||
|
|
||||||
|
@Schema(description = "仿钉钉流程设计模型对象")
|
||||||
|
@Valid
|
||||||
|
private BpmSimpleModelNodeVO simpleModel;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.bpm.controller.admin.base.user.UserSimpleBaseVO;
|
||||||
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelMetaInfoVO;
|
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelMetaInfoVO;
|
||||||
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelRespVO;
|
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelRespVO;
|
||||||
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelSaveReqVO;
|
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelSaveReqVO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelNodeVO;
|
||||||
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionRespVO;
|
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionRespVO;
|
||||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmCategoryDO;
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmCategoryDO;
|
||||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO;
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO;
|
||||||
|
@ -58,12 +59,13 @@ public interface BpmModelConvert {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
default BpmModelRespVO buildModel(Model model, byte[] bpmnBytes) {
|
default BpmModelRespVO buildModel(Model model, byte[] bpmnBytes, BpmSimpleModelNodeVO simpleModel) {
|
||||||
BpmModelMetaInfoVO metaInfo = parseMetaInfo(model);
|
BpmModelMetaInfoVO metaInfo = parseMetaInfo(model);
|
||||||
BpmModelRespVO modelVO = buildModel0(model, metaInfo, null, null, null, null, null);
|
BpmModelRespVO modelVO = buildModel0(model, metaInfo, null, null, null, null, null);
|
||||||
if (ArrayUtil.isNotEmpty(bpmnBytes)) {
|
if (ArrayUtil.isNotEmpty(bpmnBytes)) {
|
||||||
modelVO.setBpmnXml(BpmnModelUtils.getBpmnXml(bpmnBytes));
|
modelVO.setBpmnXml(BpmnModelUtils.getBpmnXml(bpmnBytes));
|
||||||
}
|
}
|
||||||
|
modelVO.setSimpleModel(simpleModel);
|
||||||
return modelVO;
|
return modelVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.bpm.service.definition;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
|
import cn.hutool.core.util.ObjUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils;
|
import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils;
|
||||||
|
@ -12,6 +13,7 @@ import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.B
|
||||||
import cn.iocoder.yudao.module.bpm.convert.definition.BpmModelConvert;
|
import cn.iocoder.yudao.module.bpm.convert.definition.BpmModelConvert;
|
||||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO;
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO;
|
||||||
import cn.iocoder.yudao.module.bpm.enums.definition.BpmModelFormTypeEnum;
|
import cn.iocoder.yudao.module.bpm.enums.definition.BpmModelFormTypeEnum;
|
||||||
|
import cn.iocoder.yudao.module.bpm.enums.definition.BpmModelTypeEnum;
|
||||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateInvoker;
|
import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateInvoker;
|
||||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils;
|
import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils;
|
||||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils;
|
import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils;
|
||||||
|
@ -82,26 +84,54 @@ public class BpmModelServiceImpl implements BpmModelService {
|
||||||
throw exception(MODEL_KEY_EXISTS, createReqVO.getKey());
|
throw exception(MODEL_KEY_EXISTS, createReqVO.getKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2.1 创建流程定义
|
// 2. 创建 Model 对象
|
||||||
createReqVO.setSort(System.currentTimeMillis()); // 使用当前时间,作为排序
|
createReqVO.setSort(System.currentTimeMillis()); // 使用当前时间,作为排序
|
||||||
Model model = repositoryService.newModel();
|
Model model = repositoryService.newModel();
|
||||||
BpmModelConvert.INSTANCE.copyToModel(model, createReqVO);
|
BpmModelConvert.INSTANCE.copyToModel(model, createReqVO);
|
||||||
model.setTenantId(FlowableUtils.getTenantId());
|
model.setTenantId(FlowableUtils.getTenantId());
|
||||||
// 2.2 保存流程定义
|
|
||||||
repositoryService.saveModel(model);
|
// 3. 保存模型
|
||||||
|
saveModel(model, createReqVO);
|
||||||
return model.getId();
|
return model.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class) // 因为进行多个操作,所以开启事务
|
@Transactional(rollbackFor = Exception.class) // 因为进行多个操作,所以开启事务
|
||||||
public void updateModel(Long userId, @Valid BpmModelSaveReqVO updateReqVO) {
|
public void updateModel(Long userId, BpmModelSaveReqVO updateReqVO) {
|
||||||
// 1. 校验流程模型存在
|
// 1. 校验流程模型存在
|
||||||
Model model = validateModelManager(updateReqVO.getId(), userId);
|
Model model = validateModelManager(updateReqVO.getId(), userId);
|
||||||
|
|
||||||
// 修改流程定义
|
// 2. 填充 Model 信息
|
||||||
BpmModelConvert.INSTANCE.copyToModel(model, updateReqVO);
|
BpmModelConvert.INSTANCE.copyToModel(model, updateReqVO);
|
||||||
// 更新模型
|
|
||||||
|
// 3. 保存模型
|
||||||
|
saveModel(model, updateReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存模型的基本信息、流程图
|
||||||
|
*
|
||||||
|
* @param model 模型
|
||||||
|
* @param saveReqVO 保存信息
|
||||||
|
*/
|
||||||
|
private void saveModel(Model model, BpmModelSaveReqVO saveReqVO) {
|
||||||
|
// 1. 保存模型的基础信息
|
||||||
repositoryService.saveModel(model);
|
repositoryService.saveModel(model);
|
||||||
|
|
||||||
|
// 2. 保存流程图
|
||||||
|
if (ObjUtil.equals(BpmModelTypeEnum.BPMN.getType(), saveReqVO.getType())
|
||||||
|
&& StrUtil.isNotEmpty(saveReqVO.getBpmnXml())) {
|
||||||
|
updateModelBpmnXml(model.getId(), saveReqVO.getBpmnXml());
|
||||||
|
} else if (ObjUtil.equals(BpmModelTypeEnum.SIMPLE.getType(), saveReqVO.getType())
|
||||||
|
&& saveReqVO.getSimpleModel() != null) {
|
||||||
|
// JSON 转换成 bpmnModel
|
||||||
|
BpmnModel bpmnModel = SimpleModelUtils.buildBpmnModel(model.getKey(), model.getName(),
|
||||||
|
saveReqVO.getSimpleModel());
|
||||||
|
// 保存 Bpmn XML
|
||||||
|
updateModelBpmnXml(model.getId(), BpmnModelUtils.getBpmnXml(bpmnModel));
|
||||||
|
// 保存 JSON 数据
|
||||||
|
updateModelSimpleJson(model.getId(), saveReqVO.getSimpleModel());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -173,7 +203,8 @@ public class BpmModelServiceImpl implements BpmModelService {
|
||||||
String simpleJson = getModelSimpleJson(model.getId());
|
String simpleJson = getModelSimpleJson(model.getId());
|
||||||
|
|
||||||
// 2.1 创建流程定义
|
// 2.1 创建流程定义
|
||||||
String definitionId = processDefinitionService.createProcessDefinition(model, metaInfo, bpmnBytes, simpleJson, form);
|
String definitionId = processDefinitionService.createProcessDefinition(model, metaInfo, bpmnBytes, simpleJson,
|
||||||
|
form);
|
||||||
|
|
||||||
// 2.2 将老的流程定义进行挂起。也就是说,只有最新部署的流程定义,才可以发起任务。
|
// 2.2 将老的流程定义进行挂起。也就是说,只有最新部署的流程定义,才可以发起任务。
|
||||||
updateProcessDefinitionSuspended(model.getDeploymentId());
|
updateProcessDefinitionSuspended(model.getDeploymentId());
|
||||||
|
@ -220,7 +251,8 @@ public class BpmModelServiceImpl implements BpmModelService {
|
||||||
// 1.1 校验流程模型存在
|
// 1.1 校验流程模型存在
|
||||||
Model model = validateModelManager(id, userId);
|
Model model = validateModelManager(id, userId);
|
||||||
// 1.2 校验流程定义存在
|
// 1.2 校验流程定义存在
|
||||||
ProcessDefinition definition = processDefinitionService.getProcessDefinitionByDeploymentId(model.getDeploymentId());
|
ProcessDefinition definition = processDefinitionService
|
||||||
|
.getProcessDefinitionByDeploymentId(model.getDeploymentId());
|
||||||
if (definition == null) {
|
if (definition == null) {
|
||||||
throw exception(PROCESS_DEFINITION_NOT_EXISTS);
|
throw exception(PROCESS_DEFINITION_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
|
@ -276,7 +308,8 @@ public class BpmModelServiceImpl implements BpmModelService {
|
||||||
}
|
}
|
||||||
return form;
|
return form;
|
||||||
} else {
|
} else {
|
||||||
if (StrUtil.isEmpty(metaInfo.getFormCustomCreatePath()) || StrUtil.isEmpty(metaInfo.getFormCustomViewPath())) {
|
if (StrUtil.isEmpty(metaInfo.getFormCustomCreatePath())
|
||||||
|
|| StrUtil.isEmpty(metaInfo.getFormCustomViewPath())) {
|
||||||
throw exception(MODEL_DEPLOY_FAIL_FORM_NOT_CONFIG);
|
throw exception(MODEL_DEPLOY_FAIL_FORM_NOT_CONFIG);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -323,7 +356,8 @@ public class BpmModelServiceImpl implements BpmModelService {
|
||||||
if (oldDefinition == null) {
|
if (oldDefinition == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
processDefinitionService.updateProcessDefinitionState(oldDefinition.getId(), SuspensionState.SUSPENDED.getStateCode());
|
processDefinitionService.updateProcessDefinitionState(oldDefinition.getId(),
|
||||||
|
SuspensionState.SUSPENDED.getStateCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Model getModelByKey(String key) {
|
private Model getModelByKey(String key) {
|
||||||
|
|
|
@ -38,6 +38,8 @@ import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
||||||
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
||||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.flowable.bpmn.constants.BpmnXMLConstants;
|
import org.flowable.bpmn.constants.BpmnXMLConstants;
|
||||||
import org.flowable.bpmn.model.*;
|
import org.flowable.bpmn.model.*;
|
||||||
|
@ -54,8 +56,6 @@ import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import javax.validation.Valid;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
@ -264,8 +264,10 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
|
||||||
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(userIds);
|
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(userIds);
|
||||||
Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId));
|
Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId));
|
||||||
|
|
||||||
|
|
||||||
// 2. 表单权限
|
// 2. 表单权限
|
||||||
Map<String, String> formFieldsPermission = getFormFieldsPermission(bpmnModel, reqVO.getActivityId(), reqVO.getTaskId());
|
String taskId = reqVO.getTaskId() == null && todoTask != null ? todoTask.getId() : reqVO.getTaskId();
|
||||||
|
Map<String, String> formFieldsPermission = getFormFieldsPermission(bpmnModel, reqVO.getActivityId(), taskId);
|
||||||
|
|
||||||
// 3. 拼接数据
|
// 3. 拼接数据
|
||||||
return BpmProcessInstanceConvert.INSTANCE.buildApprovalDetail(bpmnModel, processDefinition, processDefinitionInfo, processInstance,
|
return BpmProcessInstanceConvert.INSTANCE.buildApprovalDetail(bpmnModel, processDefinition, processDefinitionInfo, processInstance,
|
||||||
|
|
|
@ -121,7 +121,7 @@ public class CartServiceImpl implements CartService {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 批量标记删除
|
// 批量标记删除
|
||||||
cartMapper.deleteBatchIds(ids);
|
cartMapper.deleteByIds(convertSet(carts, CartDO::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue