mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-14 19:15:06 +08:00
BPM: 新增通过流程标识获取流程图
This commit is contained in:
@ -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.convert.definition.BpmModelConvert;
|
||||
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.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.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
@ -44,6 +43,15 @@ public class BpmModelController {
|
||||
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")
|
||||
@Operation(summary = "新建模型")
|
||||
@PreAuthorize("@ss.hasPermission('bpm:model:create')")
|
||||
|
@ -2,9 +2,8 @@ package cn.iocoder.yudao.module.bpm.service.definition;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.*;
|
||||
import org.flowable.bpmn.model.BpmnModel;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import org.flowable.bpmn.model.BpmnModel;
|
||||
|
||||
/**
|
||||
* Flowable流程模型接口
|
||||
@ -38,6 +37,14 @@ public interface BpmModelService {
|
||||
*/
|
||||
BpmModelRespVO getModel(String id);
|
||||
|
||||
/**
|
||||
* 获得流程模块
|
||||
*
|
||||
* @param key 流程标识
|
||||
* @return 流程模型
|
||||
*/
|
||||
BpmModelRespVO getBpmnModelByKey(String key);
|
||||
|
||||
/**
|
||||
* 修改流程模型
|
||||
*
|
||||
@ -62,7 +69,7 @@ public interface BpmModelService {
|
||||
/**
|
||||
* 修改模型的状态,实际更新的部署的流程定义的状态
|
||||
*
|
||||
* @param id 编号
|
||||
* @param id 编号
|
||||
* @param state 状态
|
||||
*/
|
||||
void updateModelState(String id, Integer state);
|
||||
|
@ -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.service.definition.dto.BpmModelMetaInfoRespDTO;
|
||||
import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmProcessDefinitionCreateReqDTO;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.bpmn.converter.BpmnXMLConverter;
|
||||
import org.flowable.bpmn.model.BpmnModel;
|
||||
@ -29,8 +31,6 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.*;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
@ -134,6 +134,19 @@ public class BpmModelServiceImpl implements BpmModelService {
|
||||
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
|
||||
@Transactional(rollbackFor = Exception.class) // 因为进行多个操作,所以开启事务
|
||||
public void updateModel(@Valid BpmModelUpdateReqVO updateReqVO) {
|
||||
|
Reference in New Issue
Block a user