BPM: 新增通过流程标识获取流程图

This commit is contained in:
puhui999 2024-01-28 16:34:39 +08:00
parent 1cab3c009c
commit ea6752f15e
5 changed files with 45 additions and 11 deletions

View File

@ -6,16 +6,15 @@ import cn.iocoder.yudao.framework.common.util.io.IoUtils;
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.*; import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.*;
import cn.iocoder.yudao.module.bpm.convert.definition.BpmModelConvert; import cn.iocoder.yudao.module.bpm.convert.definition.BpmModelConvert;
import cn.iocoder.yudao.module.bpm.service.definition.BpmModelService; import cn.iocoder.yudao.module.bpm.service.definition.BpmModelService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import java.io.IOException; import java.io.IOException;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@ -44,6 +43,15 @@ public class BpmModelController {
return success(model); return success(model);
} }
@GetMapping("/get-by-key")
@Operation(summary = "获得模型")
@Parameter(name = "key", description = "流程标识", required = true, example = "oa_leave")
@PreAuthorize("@ss.hasPermission('bpm:model:query')")
public CommonResult<BpmModelRespVO> getModelByKey(@RequestParam("key") String key) {
BpmModelRespVO model = modelService.getBpmnModelByKey(key);
return success(model);
}
@PostMapping("/create") @PostMapping("/create")
@Operation(summary = "新建模型") @Operation(summary = "新建模型")
@PreAuthorize("@ss.hasPermission('bpm:model:create')") @PreAuthorize("@ss.hasPermission('bpm:model:create')")

View File

@ -2,9 +2,8 @@ package cn.iocoder.yudao.module.bpm.service.definition;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.*; import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.*;
import org.flowable.bpmn.model.BpmnModel;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.flowable.bpmn.model.BpmnModel;
/** /**
* Flowable流程模型接口 * Flowable流程模型接口
@ -38,6 +37,14 @@ public interface BpmModelService {
*/ */
BpmModelRespVO getModel(String id); BpmModelRespVO getModel(String id);
/**
* 获得流程模块
*
* @param key 流程标识
* @return 流程模型
*/
BpmModelRespVO getBpmnModelByKey(String key);
/** /**
* 修改流程模型 * 修改流程模型
* *
@ -62,7 +69,7 @@ public interface BpmModelService {
/** /**
* 修改模型的状态实际更新的部署的流程定义的状态 * 修改模型的状态实际更新的部署的流程定义的状态
* *
* @param id 编号 * @param id 编号
* @param state 状态 * @param state 状态
*/ */
void updateModelState(String id, Integer state); void updateModelState(String id, Integer state);

View File

@ -14,6 +14,8 @@ 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.service.definition.dto.BpmModelMetaInfoRespDTO; import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmModelMetaInfoRespDTO;
import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmProcessDefinitionCreateReqDTO; import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmProcessDefinitionCreateReqDTO;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.flowable.bpmn.converter.BpmnXMLConverter; import org.flowable.bpmn.converter.BpmnXMLConverter;
import org.flowable.bpmn.model.BpmnModel; import org.flowable.bpmn.model.BpmnModel;
@ -29,8 +31,6 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import jakarta.annotation.Resource;
import jakarta.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;
@ -134,6 +134,19 @@ public class BpmModelServiceImpl implements BpmModelService {
return modelRespVO; return modelRespVO;
} }
@Override
public BpmModelRespVO getBpmnModelByKey(String key) {
Model model = getModelByKey(key);
if (model == null) {
return null;
}
BpmModelRespVO modelRespVO = BpmModelConvert.INSTANCE.convert(model);
// 拼接 bpmn XML
byte[] bpmnBytes = repositoryService.getModelEditorSource(model.getId());
modelRespVO.setBpmnXml(StrUtil.utf8Str(bpmnBytes));
return modelRespVO;
}
@Override @Override
@Transactional(rollbackFor = Exception.class) // 因为进行多个操作所以开启事务 @Transactional(rollbackFor = Exception.class) // 因为进行多个操作所以开启事务
public void updateModel(@Valid BpmModelUpdateReqVO updateReqVO) { public void updateModel(@Valid BpmModelUpdateReqVO updateReqVO) {

View File

@ -12,6 +12,7 @@ import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractTrans
import cn.iocoder.yudao.module.crm.convert.contract.CrmContractConvert; import cn.iocoder.yudao.module.crm.convert.contract.CrmContractConvert;
import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;
import cn.iocoder.yudao.module.crm.dal.mysql.contract.CrmContractMapper; import cn.iocoder.yudao.module.crm.dal.mysql.contract.CrmContractMapper;
import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum;
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission;
@ -156,7 +157,8 @@ public class CrmContractServiceImpl implements CrmContractService {
.setProcessDefinitionKey(CONTRACT_APPROVE).setBusinessKey(String.valueOf(id))); .setProcessDefinitionKey(CONTRACT_APPROVE).setBusinessKey(String.valueOf(id)));
// 更新合同工作流编号 // 更新合同工作流编号
contractMapper.updateById(new CrmContractDO().setId(id).setProcessInstanceId(processInstanceId)); contractMapper.updateById(new CrmContractDO().setId(id).setProcessInstanceId(processInstanceId)
.setAuditStatus(CrmAuditStatusEnum.PROCESS.getStatus()));
} }
//======================= 查询相关 ======================= //======================= 查询相关 =======================

View File

@ -0,0 +1,4 @@
package cn.iocoder.yudao.module.crm.service.contract.listener;
public class CrmContractResultListener {
}