mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-29 18:51:53 +08:00
将 Model exportBpmnXml 去除,替换成 getModel 接口
This commit is contained in:
parent
e47d5afcfa
commit
df91c3ceff
@ -1,21 +1,19 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.model;
|
||||
|
||||
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.ModelPageReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.model.BpmModelService;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@ -31,11 +29,20 @@ public class BpmModelController {
|
||||
// TODO @芋艿:权限
|
||||
|
||||
@GetMapping ("/page")
|
||||
@ApiOperation(value = "分页数据")
|
||||
public CommonResult<PageResult<BpmModelRespVO>> getModelPage(ModelPageReqVO pageVO) {
|
||||
@ApiOperation(value = "获得模型分页")
|
||||
public CommonResult<PageResult<BpmModelPageItemRespVO>> getModelPage(ModelPageReqVO pageVO) {
|
||||
return success(bpmModelService.getModelPage(pageVO));
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得模型")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = String.class)
|
||||
// @PreAuthorize("@ss.hasPermission('bpm:form:query')")
|
||||
public CommonResult<BpmModelRespVO> getModel(@RequestParam("id") String id) {
|
||||
BpmModelRespVO model = bpmModelService.getModel(id);
|
||||
return success(model);
|
||||
}
|
||||
|
||||
@PostMapping("/create")
|
||||
@ApiOperation(value = "新建模型")
|
||||
public CommonResult<String> createModel(@RequestBody BpmModelCreateReqVO createRetVO) {
|
||||
@ -60,11 +67,4 @@ public class BpmModelController {
|
||||
return bpmModelService.deploy(modelId);
|
||||
}
|
||||
|
||||
@GetMapping("/exportBpmnXml")
|
||||
@ApiOperation(value = "导出模型Xml")
|
||||
public void export(@RequestParam String modelId, HttpServletResponse response) throws IOException {
|
||||
FileResp fileResp = bpmModelService.exportBpmnXml(modelId);
|
||||
ServletUtils.writeAttachment(response, fileResp.getFileName(), fileResp.getFileByte());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,43 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ApiModel("流程模型的分页的每一项 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class BpmModelPageItemRespVO extends BpmModelBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "编号", required = true, example = "1024")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "表单名字", example = "请假表单")
|
||||
private String formName;
|
||||
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 最新部署的流程定义
|
||||
*/
|
||||
private ProcessDefinition processDefinition;
|
||||
|
||||
@ApiModel("流程定义")
|
||||
@Data
|
||||
public static class ProcessDefinition {
|
||||
|
||||
@ApiModelProperty(value = "编号", required = true, example = "1024")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "版本", required = true, example = "1")
|
||||
private Integer version;
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -6,38 +6,15 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Date;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
@ApiModel("流程模型 Response VO")
|
||||
@ApiModel("流程模型的创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class BpmModelRespVO extends BpmModelBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "编号", required = true, example = "1024")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "表单名字", example = "请假表单")
|
||||
private String formName;
|
||||
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 最新部署的流程定义
|
||||
*/
|
||||
private ProcessDefinition processDefinition;
|
||||
|
||||
@ApiModel("流程定义")
|
||||
@Data
|
||||
public static class ProcessDefinition {
|
||||
|
||||
@ApiModelProperty(value = "编号", required = true, example = "1024")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "版本", required = true, example = "1")
|
||||
private Integer version;
|
||||
|
||||
}
|
||||
@ApiModelProperty(value = "BPMN XML", required = true)
|
||||
private String bpmnXml;
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.convert.model;
|
||||
|
||||
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.dal.dataobject.form.BpmFormDO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.model.dto.BpmModelMetaInfoRespDTO;
|
||||
@ -25,7 +26,7 @@ public interface ModelConvert {
|
||||
|
||||
ModelConvert INSTANCE = Mappers.getMapper(ModelConvert.class);
|
||||
|
||||
default List<BpmModelRespVO> convertList(List<Model> list, Map<Long, BpmFormDO> formMap,
|
||||
default List<BpmModelPageItemRespVO> convertList(List<Model> list, Map<Long, BpmFormDO> formMap,
|
||||
Map<String, ProcessDefinition> processDefinitionMap) {
|
||||
return CollectionUtils.convertList(list, model -> {
|
||||
BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class);
|
||||
@ -35,8 +36,8 @@ public interface ModelConvert {
|
||||
});
|
||||
}
|
||||
|
||||
default BpmModelRespVO convert(Model model, BpmFormDO form, ProcessDefinition processDefinition) {
|
||||
BpmModelRespVO modelRespVO = new BpmModelRespVO();
|
||||
default BpmModelPageItemRespVO convert(Model model, BpmFormDO form, ProcessDefinition processDefinition) {
|
||||
BpmModelPageItemRespVO modelRespVO = new BpmModelPageItemRespVO();
|
||||
modelRespVO.setId(model.getId());
|
||||
modelRespVO.setName(model.getName());
|
||||
modelRespVO.setKey(model.getKey());
|
||||
@ -54,6 +55,8 @@ public interface ModelConvert {
|
||||
return modelRespVO;
|
||||
}
|
||||
|
||||
BpmModelRespVO convert(Model model);
|
||||
|
||||
default void copy(Model model, BpmModelCreateReqVO bean) {
|
||||
model.setName(bean.getName());
|
||||
model.setKey(bean.getKey());
|
||||
@ -68,6 +71,6 @@ public interface ModelConvert {
|
||||
return metaInfo;
|
||||
}
|
||||
|
||||
BpmModelRespVO.ProcessDefinition convert(ProcessDefinition bean);
|
||||
BpmModelPageItemRespVO.ProcessDefinition convert(ProcessDefinition bean);
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.service.model;
|
||||
|
||||
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.ModelPageReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
@ -20,7 +20,15 @@ public interface BpmModelService {
|
||||
* @param pageVO 分页查询
|
||||
* @return 流程模型分页
|
||||
*/
|
||||
PageResult<BpmModelRespVO> getModelPage(ModelPageReqVO pageVO);
|
||||
PageResult<BpmModelPageItemRespVO> getModelPage(ModelPageReqVO pageVO);
|
||||
|
||||
/**
|
||||
* 获得流程模块
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 流程模型
|
||||
*/
|
||||
BpmModelRespVO getModel(String id);
|
||||
|
||||
// TODO @Li:不用返回 CommonResult
|
||||
// TODO @Li:createBpmModal。
|
||||
@ -46,17 +54,11 @@ public interface BpmModelService {
|
||||
*/
|
||||
CommonResult<String> deploy(String modelId);
|
||||
|
||||
/**
|
||||
* 导出模型
|
||||
* @param modelId 模型Id
|
||||
* @return {@link FileResp} 返回文件
|
||||
*/
|
||||
FileResp exportBpmnXml(String modelId);
|
||||
|
||||
/**
|
||||
* 删除模型
|
||||
* @param modelId 模型Id
|
||||
* @return 返回成功
|
||||
*/
|
||||
CommonResult<String> deleteModel(String modelId);
|
||||
|
||||
}
|
||||
|
@ -1,10 +1,11 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.service.model.impl;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
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.BpmModelPageItemRespVO;
|
||||
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.workflow.vo.FileResp;
|
||||
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.enums.BpmErrorCodeConstants;
|
||||
@ -37,7 +38,10 @@ import javax.xml.stream.XMLStreamReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStreamReader;
|
||||
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.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
@ -64,7 +68,7 @@ public class BpmModelServiceImpl implements BpmModelService {
|
||||
private BpmDefinitionService bpmDefinitionService;
|
||||
|
||||
@Override
|
||||
public PageResult<BpmModelRespVO> getModelPage(ModelPageReqVO pageVO) {
|
||||
public PageResult<BpmModelPageItemRespVO> getModelPage(ModelPageReqVO pageVO) {
|
||||
ModelQuery modelQuery = repositoryService.createModelQuery();
|
||||
if (StrUtil.isNotBlank(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);
|
||||
}
|
||||
|
||||
@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
|
||||
@Transactional(rollbackFor = Exception.class) // 因为进行多个 activiti 操作,所以开启事务
|
||||
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
|
||||
public CommonResult<String> deleteModel(String modelId) {
|
||||
// TODO @Li:activitie 是逻辑删除么?
|
||||
|
@ -8,11 +8,10 @@ export function page(query) {
|
||||
})
|
||||
}
|
||||
|
||||
export function exportBpmnXml(query) {
|
||||
export function getModel(id) {
|
||||
return request({
|
||||
url: '/bpm/model/exportBpmnXml',
|
||||
method: 'get',
|
||||
params: query
|
||||
url: '/bpm/model/get?id=' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -47,14 +47,17 @@
|
||||
|
||||
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"/>
|
||||
|
||||
|
||||
<el-dialog class="bpmnclass dialogClass" :visible.sync="showBpmnBool" :before-close="close" :fullscreen="true">
|
||||
<vue-bpmn v-if="showBpmnBool" product="activiti" @processSave="processSave" :bpmnXml="bpmnXML" :bpmnData="bpmnData" @beforeClose="close"></vue-bpmn>
|
||||
<vue-bpmn v-if="showBpmnBool" product="activiti" @processSave="processSave"
|
||||
:bpmnXml="bpmnXML" :bpmnData="bpmnData" @beforeClose="close" />
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {exportBpmnXml, modelDelete, modelDeploy, modelSave, modelUpdate, page} from "@/api/bpm/model";
|
||||
import {modelDelete, modelDeploy, modelSave, modelUpdate, page, getModel} from "@/api/bpm/model";
|
||||
import VueBpmn from "@/components/bpmn/VueBpmn";
|
||||
|
||||
export default {
|
||||
@ -70,13 +73,14 @@ export default {
|
||||
total: 0,
|
||||
// 表格数据
|
||||
list: [],
|
||||
bpmnXML: null,
|
||||
bpmnData: {},
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNo: 1,
|
||||
pageSize: 10
|
||||
}
|
||||
},
|
||||
// BPMN 数据
|
||||
bpmnXML: null,
|
||||
bpmnData: {},
|
||||
};
|
||||
},
|
||||
components: {VueBpmn},
|
||||
@ -144,15 +148,15 @@ export default {
|
||||
this.getList();
|
||||
},
|
||||
change(row) {
|
||||
const that = this;
|
||||
// 重置 Model 信息
|
||||
this.bpmnXML = ""
|
||||
this.bpmnData = {}
|
||||
exportBpmnXml({
|
||||
modelId: row.id
|
||||
}).then(response => {
|
||||
that.bpmnXML = response
|
||||
that.bpmnData = row
|
||||
that.showBpmnBool = true
|
||||
// 获得 Model 信息
|
||||
getModel(row.id).then(response => {
|
||||
this.bpmnXML = response.data.bpmnXml
|
||||
this.bpmnData = response.data
|
||||
// 打开弹窗
|
||||
this.showBpmnBool = true
|
||||
})
|
||||
},
|
||||
modelDelete(row) {
|
||||
|
@ -142,13 +142,7 @@ export default {
|
||||
const that = this;
|
||||
this.bpmnXML = ""
|
||||
this.bpmnData = {}
|
||||
exportBpmnXml({
|
||||
modelId: row.id
|
||||
}).then(response => {
|
||||
that.bpmnXML = response
|
||||
that.bpmnData = row
|
||||
that.showBpmnBool = true
|
||||
})
|
||||
// TODO @芋艿:修改成 getModel
|
||||
},
|
||||
modelDelete(row) {
|
||||
const that = this;
|
||||
|
Loading…
Reference in New Issue
Block a user