|
|
|
@ -1,10 +1,11 @@
|
|
|
|
package cn.iocoder.yudao.adminserver.modules.bpm.service.model.impl;
|
|
|
|
package cn.iocoder.yudao.adminserver.modules.bpm.service.model.impl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ArrayUtil;
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelCreateReqVO;
|
|
|
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelCreateReqVO;
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelPageItemRespVO;
|
|
|
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelRespVO;
|
|
|
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelRespVO;
|
|
|
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.ModelPageReqVO;
|
|
|
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.ModelPageReqVO;
|
|
|
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp;
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.adminserver.modules.bpm.convert.model.ModelConvert;
|
|
|
|
import cn.iocoder.yudao.adminserver.modules.bpm.convert.model.ModelConvert;
|
|
|
|
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO;
|
|
|
|
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO;
|
|
|
|
import cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants;
|
|
|
|
import cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants;
|
|
|
|
@ -37,7 +38,10 @@ import javax.xml.stream.XMLStreamReader;
|
|
|
|
import java.io.ByteArrayInputStream;
|
|
|
|
import java.io.ByteArrayInputStream;
|
|
|
|
import java.io.InputStreamReader;
|
|
|
|
import java.io.InputStreamReader;
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.HashSet;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
|
|
|
|
import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.BPM_MODEL_KEY_EXISTS;
|
|
|
|
import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.BPM_MODEL_KEY_EXISTS;
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
|
@ -64,7 +68,7 @@ public class BpmModelServiceImpl implements BpmModelService {
|
|
|
|
private BpmDefinitionService bpmDefinitionService;
|
|
|
|
private BpmDefinitionService bpmDefinitionService;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public PageResult<BpmModelRespVO> getModelPage(ModelPageReqVO pageVO) {
|
|
|
|
public PageResult<BpmModelPageItemRespVO> getModelPage(ModelPageReqVO pageVO) {
|
|
|
|
ModelQuery modelQuery = repositoryService.createModelQuery();
|
|
|
|
ModelQuery modelQuery = repositoryService.createModelQuery();
|
|
|
|
if (StrUtil.isNotBlank(pageVO.getName())) {
|
|
|
|
if (StrUtil.isNotBlank(pageVO.getName())) {
|
|
|
|
modelQuery.modelNameLike("%" + pageVO.getName() + "%"); // 模糊匹配
|
|
|
|
modelQuery.modelNameLike("%" + pageVO.getName() + "%"); // 模糊匹配
|
|
|
|
@ -91,6 +95,18 @@ public class BpmModelServiceImpl implements BpmModelService {
|
|
|
|
return new PageResult<>(ModelConvert.INSTANCE.convertList(models, formMap, processDefinitionMap), modelCount);
|
|
|
|
return new PageResult<>(ModelConvert.INSTANCE.convertList(models, formMap, processDefinitionMap), modelCount);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public BpmModelRespVO getModel(String id) {
|
|
|
|
|
|
|
|
Model model = repositoryService.getModel(id);
|
|
|
|
|
|
|
|
BpmModelRespVO modelRespVO = ModelConvert.INSTANCE.convert(model);
|
|
|
|
|
|
|
|
// 拼接 bpmn XML
|
|
|
|
|
|
|
|
byte[] bpmnBytes = repositoryService.getModelEditorSource(id);
|
|
|
|
|
|
|
|
if (ArrayUtil.isNotEmpty(bpmnBytes)) {
|
|
|
|
|
|
|
|
modelRespVO.setBpmnXml(StrUtil.utf8Str(bpmnBytes));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return modelRespVO;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@Transactional(rollbackFor = Exception.class) // 因为进行多个 activiti 操作,所以开启事务
|
|
|
|
@Transactional(rollbackFor = Exception.class) // 因为进行多个 activiti 操作,所以开启事务
|
|
|
|
public String createModel(BpmModelCreateReqVO createReqVO) {
|
|
|
|
public String createModel(BpmModelCreateReqVO createReqVO) {
|
|
|
|
@ -209,24 +225,6 @@ public class BpmModelServiceImpl implements BpmModelService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public FileResp exportBpmnXml(String modelId) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Model modelData = repositoryService.getModel(modelId);
|
|
|
|
|
|
|
|
if (ObjectUtils.isEmpty(modelData)) {
|
|
|
|
|
|
|
|
throw exception(BpmErrorCodeConstants.BPMN_MODEL_EDITOR_SOURCE_NOT_EXISTS);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
byte[] bytes = repositoryService.getModelEditorSource(modelData.getId());
|
|
|
|
|
|
|
|
FileResp fileResp = new FileResp();
|
|
|
|
|
|
|
|
fileResp.setFileName(String.format("%s.bpmn", Optional.ofNullable(modelData.getName()).orElse("流程图")));
|
|
|
|
|
|
|
|
fileResp.setFileByte(bytes);
|
|
|
|
|
|
|
|
return fileResp;
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
log.info("模型部署失败!modelId = {} e = {} ", modelId, ExceptionUtils.getStackTrace(e));
|
|
|
|
|
|
|
|
throw exception(BpmErrorCodeConstants.BPMN_MODEL_ERROR);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public CommonResult<String> deleteModel(String modelId) {
|
|
|
|
public CommonResult<String> deleteModel(String modelId) {
|
|
|
|
// TODO @Li:activitie 是逻辑删除么?
|
|
|
|
// TODO @Li:activitie 是逻辑删除么?
|
|
|
|
|