优化流程定义的分页接口
This commit is contained in:
parent
7833aa5d0e
commit
513c23efbb
|
@ -1,15 +1,15 @@
|
|||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow;
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.definition;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionPageItemRespVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionPageReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionPageReqVo;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionRespVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmDefinitionService;
|
||||
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.ApiOperation;
|
||||
import org.activiti.api.process.runtime.ProcessRuntime;
|
||||
import org.activiti.engine.RepositoryService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
@ -19,39 +19,38 @@ import javax.annotation.Resource;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
// TODO @json:swagger 和 validation 的注解,后续要补全下哈。可以等 workflow 基本写的差不多之后
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Api(tags = "流程定义")
|
||||
@RestController
|
||||
@RequestMapping("/workflow/process/definition")
|
||||
@RequestMapping("/bpm/definition")
|
||||
@Validated
|
||||
public class ProcessDefinitionController {
|
||||
|
||||
@Resource
|
||||
private RepositoryService repositoryService;
|
||||
private BpmDefinitionService bpmDefinitionService;
|
||||
|
||||
@Resource
|
||||
private ProcessRuntime processRuntime;
|
||||
@Resource
|
||||
private BpmDefinitionService bpmProcessDefinitionService;
|
||||
// TODO 芋艿:权限
|
||||
|
||||
@GetMapping ("/page")
|
||||
@ApiOperation(value = "获得流程定义分页")
|
||||
public CommonResult<PageResult<BpmProcessDefinitionPageItemRespVO>> getDefinitionPage(BpmProcessDefinitionPageReqVO pageReqVO) {
|
||||
return success(bpmDefinitionService.getDefinitionPage(pageReqVO));
|
||||
}
|
||||
|
||||
@GetMapping(value = "/getStartForm")
|
||||
public CommonResult<String> getStartForm(@RequestParam("processKey") String processKey){
|
||||
// final ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().
|
||||
// processDefinitionKey(processKey).latestVersion().singleResult();
|
||||
// processRuntime.processDefinition(processDefinition.getId()).getFormKey();
|
||||
//这样查似乎有问题??, 暂时写死
|
||||
return CommonResult.success("/flow/leave/apply");
|
||||
}
|
||||
|
||||
@GetMapping ("/page")
|
||||
@ApiOperation(value = "流程定义分页数据")
|
||||
public CommonResult<PageResult<ProcessDefinitionRespVO>> pageList(ProcessDefinitionPageReqVo processDefinitionPageReqVo) {
|
||||
return CommonResult.success(bpmProcessDefinitionService.pageList(processDefinitionPageReqVo));
|
||||
// TODO 这样查似乎有问题??, 暂时写死
|
||||
return success("/flow/leave/apply");
|
||||
}
|
||||
|
||||
@GetMapping ("/export")
|
||||
@ApiOperation(value = "流程定义的bpmnXml导出")
|
||||
public void pageList(@RequestParam String processDefinitionId, HttpServletResponse response) throws IOException {
|
||||
FileResp fileResp = bpmProcessDefinitionService.export(processDefinitionId);
|
||||
public void getDefinitionPage(@RequestParam String processDefinitionId, HttpServletResponse response) throws IOException {
|
||||
FileResp fileResp = bpmDefinitionService.export(processDefinitionId);
|
||||
ServletUtils.writeAttachment(response, fileResp.getFileName(), fileResp.getFileByte());
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.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 BpmProcessDefinitionPageItemRespVO extends ProcessDefinitionRespVO {
|
||||
|
||||
@ApiModelProperty(value = "表单名字", example = "请假表单")
|
||||
private String formName;
|
||||
|
||||
@ApiModelProperty(value = "部署时间", required = true)
|
||||
private Date deploymentTime;
|
||||
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition;
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
|
@ -7,14 +7,13 @@ import lombok.Data;
|
|||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* @author yunlong.li
|
||||
*/
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel("流程定义分页 Request VO")
|
||||
public class ProcessDefinitionPageReqVo extends PageParam {
|
||||
@ApiModelProperty("流程名字")
|
||||
private String name;
|
||||
public class BpmProcessDefinitionPageReqVO extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "标识", example = "process1641042089407", notes = "精准匹配")
|
||||
private String key;
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
@ApiModel("流程定义 Response VO")
|
||||
@Data
|
||||
public class ProcessDefinitionRespVO {
|
||||
|
||||
@ApiModelProperty(value = "编号", required = true, example = "1024")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "版本", required = true, example = "1")
|
||||
private Integer version;
|
||||
|
||||
@ApiModelProperty(value = "流程名称", required = true, example = "芋道")
|
||||
@NotEmpty(message = "流程名称不能为空")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "流程描述", example = "我是描述")
|
||||
private String description;
|
||||
|
||||
@ApiModelProperty(value = "流程分类", notes = "参见 bpm_model_category 数据字典", example = "1")
|
||||
@NotEmpty(message = "流程分类不能为空")
|
||||
private String category;
|
||||
|
||||
@ApiModelProperty(value = "表单编号", example = "1024")
|
||||
private Long formId;
|
||||
|
||||
@ApiModelProperty(value = "中断状态", required = true, example = "1", notes = "参见 SuspensionState 枚举")
|
||||
private Integer suspensionState;
|
||||
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author yunlong.li
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("流程定义数据返回 Request VO")
|
||||
public class ProcessDefinitionRespVO {
|
||||
|
||||
private String formKey;
|
||||
private String id;
|
||||
private String key;
|
||||
private String name;
|
||||
private Integer version;
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package cn.iocoder.yudao.adminserver.modules.bpm.convert.definition;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionPageItemRespVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmProcessDefinitionDO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefinitionCreateReqDTO;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import org.activiti.engine.repository.Deployment;
|
||||
import org.activiti.engine.repository.ProcessDefinition;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Bpm 流程定义的 Convert
|
||||
*
|
||||
* @author yunlong.li
|
||||
*/
|
||||
@Mapper
|
||||
public interface BpmDefinitionConvert {
|
||||
|
||||
BpmDefinitionConvert INSTANCE = Mappers.getMapper(BpmDefinitionConvert.class);
|
||||
|
||||
default List<BpmProcessDefinitionPageItemRespVO> convertList(List<ProcessDefinition> list, Map<String, Deployment> deploymentMap,
|
||||
Map<String, BpmProcessDefinitionDO> processDefinitionDOMap, Map<Long, BpmFormDO> formMap) {
|
||||
return CollectionUtils.convertList(list, definition -> {
|
||||
Deployment deployment = definition.getDeploymentId() != null ? deploymentMap.get(definition.getDeploymentId()) : null;
|
||||
BpmProcessDefinitionDO definitionDO = processDefinitionDOMap.get(definition.getId());
|
||||
BpmFormDO form = definitionDO != null ? formMap.get(definitionDO.getFormId()) : null;
|
||||
return convert(definition, deployment, definitionDO, form);
|
||||
});
|
||||
}
|
||||
|
||||
default BpmProcessDefinitionPageItemRespVO convert(ProcessDefinition bean, Deployment deployment,
|
||||
BpmProcessDefinitionDO processDefinitionDO, BpmFormDO form) {
|
||||
BpmProcessDefinitionPageItemRespVO respVO = convert(bean);
|
||||
if (deployment != null) {
|
||||
respVO.setDeploymentTime(deployment.getDeploymentTime());
|
||||
}
|
||||
if (form != null) {
|
||||
respVO.setFormId(form.getId());
|
||||
respVO.setFormName(form.getName());
|
||||
}
|
||||
if (processDefinitionDO != null) {
|
||||
respVO.setDescription(processDefinitionDO.getDescription());
|
||||
}
|
||||
return respVO;
|
||||
}
|
||||
|
||||
BpmProcessDefinitionPageItemRespVO convert(ProcessDefinition bean);
|
||||
|
||||
BpmProcessDefinitionDO convert2(BpmDefinitionCreateReqDTO bean);
|
||||
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
package cn.iocoder.yudao.adminserver.modules.bpm.convert.workflow;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionRespVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmProcessDefinitionDO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefinitionCreateReqDTO;
|
||||
import org.activiti.engine.repository.ProcessDefinition;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* Bpm 流程定义的 Convert
|
||||
*
|
||||
* @author yunlong.li
|
||||
*/
|
||||
@Mapper
|
||||
public interface BpmDefinitionConvert {
|
||||
|
||||
BpmDefinitionConvert INSTANCE = Mappers.getMapper(BpmDefinitionConvert.class);
|
||||
|
||||
ProcessDefinitionRespVO convert(ProcessDefinition processDefinition);
|
||||
|
||||
BpmProcessDefinitionDO convert(BpmDefinitionCreateReqDTO bean);
|
||||
|
||||
}
|
|
@ -1,9 +1,18 @@
|
|||
package cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.definition;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmProcessDefinitionDO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface BpmProcessDefinitionMapper extends BaseMapper<BpmProcessDefinitionDO> {
|
||||
|
||||
default List<BpmProcessDefinitionDO> selectListByProcessDefinitionIds(Collection<String> processDefinitionIds) {
|
||||
return selectList(new QueryWrapper<BpmProcessDefinitionDO>().in("process_definition_id", processDefinitionIds));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package cn.iocoder.yudao.adminserver.modules.bpm.service.definition;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionPageItemRespVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionPageReqVo;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionRespVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionPageReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefinitionCreateReqDTO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
|
@ -18,21 +18,24 @@ import java.util.Set;
|
|||
* 流程定义接口
|
||||
*
|
||||
* @author yunlong.li
|
||||
* @author ZJQ
|
||||
*/
|
||||
public interface BpmDefinitionService {
|
||||
|
||||
/**
|
||||
* 流程定义分页
|
||||
* @param processDefinitionPageReqVo 分页入参
|
||||
* @return 分页model
|
||||
* 获得流程定义分页
|
||||
*
|
||||
* @param pageReqVO 分页入参
|
||||
* @return 流程定义 Page
|
||||
*/
|
||||
PageResult<ProcessDefinitionRespVO> pageList(ProcessDefinitionPageReqVo processDefinitionPageReqVo);
|
||||
PageResult<BpmProcessDefinitionPageItemRespVO> getDefinitionPage(BpmProcessDefinitionPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 导出流程 bpmn 模型
|
||||
* @param processDefinitionId 分页入参
|
||||
* @return 分页model
|
||||
*/
|
||||
// TODO 芋艿:考虑下重写
|
||||
FileResp export(String processDefinitionId);
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package cn.iocoder.yudao.adminserver.modules.bpm.service.definition;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.ProcessService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.activiti.engine.RepositoryService;
|
||||
import org.activiti.engine.repository.Deployment;
|
||||
|
@ -14,6 +13,7 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
import static cn.iocoder.yudao.adminserver.modules.system.enums.SysErrorCodeConstants.FILE_UPLOAD_FAILED;
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
|
|
|
@ -2,16 +2,19 @@ package cn.iocoder.yudao.adminserver.modules.bpm.service.definition.impl;
|
|||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionPageItemRespVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionPageReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionPageReqVo;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionRespVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.convert.workflow.BpmDefinitionConvert;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.convert.definition.BpmDefinitionConvert;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmProcessDefinitionDO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.definition.BpmProcessDefinitionMapper;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmDefinitionService;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefinitionCreateReqDTO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.form.BpmFormService;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.object.PageUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.activiti.bpmn.converter.BpmnXMLConverter;
|
||||
import org.activiti.bpmn.model.BpmnModel;
|
||||
|
@ -24,17 +27,16 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.*;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||
|
||||
/**
|
||||
* 流程定义实现
|
||||
* 主要进行 Activiti {@link ProcessDefinition} 和 {@link Deployment} 的维护
|
||||
*
|
||||
* @author yunlongn
|
||||
* @author ZJQ
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
|
@ -45,28 +47,51 @@ public class BpmDefinitionServiceImpl implements BpmDefinitionService {
|
|||
|
||||
@Resource
|
||||
private RepositoryService repositoryService;
|
||||
@Resource
|
||||
private BpmFormService bpmFormService;
|
||||
|
||||
@Resource
|
||||
private BpmProcessDefinitionMapper processDefinitionMapper;
|
||||
|
||||
@Override
|
||||
public PageResult<ProcessDefinitionRespVO> pageList(ProcessDefinitionPageReqVo processDefinitionPageReqVo) {
|
||||
ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery();
|
||||
String likeName = processDefinitionPageReqVo.getName();
|
||||
if (StrUtil.isNotBlank(likeName)){
|
||||
processDefinitionQuery.processDefinitionNameLike("%"+likeName+"%");
|
||||
public PageResult<BpmProcessDefinitionPageItemRespVO> getDefinitionPage(BpmProcessDefinitionPageReqVO pageVO) {
|
||||
ProcessDefinitionQuery definitionQuery = repositoryService.createProcessDefinitionQuery();
|
||||
if (StrUtil.isNotBlank(pageVO.getKey())) {
|
||||
definitionQuery.processDefinitionKey(pageVO.getKey());
|
||||
}
|
||||
List<ProcessDefinition> processDefinitions = processDefinitionQuery.orderByProcessDefinitionId().desc()
|
||||
.listPage((processDefinitionPageReqVo.getPageNo() - 1) * processDefinitionPageReqVo.getPageSize(),
|
||||
processDefinitionPageReqVo.getPageSize());
|
||||
final List<ProcessDefinitionRespVO> respVOList = processDefinitions.stream()
|
||||
.map(BpmDefinitionConvert.INSTANCE::convert).collect(Collectors.toList());
|
||||
return new PageResult<>(respVOList, processDefinitionQuery.count());
|
||||
// 执行查询
|
||||
List<ProcessDefinition> processDefinitions = definitionQuery.orderByProcessDefinitionId().desc()
|
||||
.listPage(PageUtils.getStart(pageVO), pageVO.getPageSize());
|
||||
if (CollUtil.isEmpty(processDefinitions)) {
|
||||
return new PageResult<>(Collections.emptyList(), definitionQuery.count());
|
||||
}
|
||||
|
||||
// 获得 Deployment Map
|
||||
Set<String> deploymentIds = new HashSet<>();
|
||||
processDefinitions.forEach(definition -> CollectionUtils.addIfNotNull(deploymentIds, definition.getDeploymentId()));
|
||||
Map<String, Deployment> deploymentMap = getDeploymentMap(deploymentIds);
|
||||
|
||||
// 获得 BpmProcessDefinitionDO Map
|
||||
List<BpmProcessDefinitionDO> processDefinitionDOs = Collections.emptyList();
|
||||
processDefinitionDOs = processDefinitionMapper.selectListByProcessDefinitionIds(
|
||||
convertList(processDefinitions, ProcessDefinition::getId));
|
||||
Map<String, BpmProcessDefinitionDO> processDefinitionDOMap = CollectionUtils.convertMap(processDefinitionDOs,
|
||||
BpmProcessDefinitionDO::getProcessDefinitionId);
|
||||
|
||||
// 获得 Form Map
|
||||
Set<Long> formIds = CollectionUtils.convertSet(processDefinitionDOs, BpmProcessDefinitionDO::getFormId);
|
||||
Map<Long, BpmFormDO> formMap = bpmFormService.getFormMap(formIds);
|
||||
|
||||
// 拼接结果
|
||||
long definitionCount = definitionQuery.count();
|
||||
return new PageResult<>(BpmDefinitionConvert.INSTANCE.convertList(processDefinitions, deploymentMap,
|
||||
processDefinitionDOMap, formMap), definitionCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileResp export(String processDefinitionId) {
|
||||
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId);
|
||||
|
||||
byte[] bpmnBytes = new BpmnXMLConverter().convertToXML(bpmnModel);
|
||||
FileResp fileResp = new FileResp();
|
||||
fileResp.setFileName( "export");
|
||||
|
@ -121,7 +146,7 @@ public class BpmDefinitionServiceImpl implements BpmDefinitionService {
|
|||
repositoryService.setProcessDefinitionCategory(definition.getId(), createReqDTO.getCategory());
|
||||
|
||||
// 插入拓展表
|
||||
BpmProcessDefinitionDO definitionDO = BpmDefinitionConvert.INSTANCE.convert(createReqDTO)
|
||||
BpmProcessDefinitionDO definitionDO = BpmDefinitionConvert.INSTANCE.convert2(createReqDTO)
|
||||
.setProcessDefinitionId(definition.getId());
|
||||
processDefinitionMapper.insert(definitionDO);
|
||||
return definition.getId();
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import request from '@/utils/request'
|
||||
|
||||
|
||||
export function page(query) {
|
||||
export function getDefinitionPage(query) {
|
||||
return request({
|
||||
url: '/workflow/process/definition/page',
|
||||
url: '/bpm/definition/page',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
|
@ -179,13 +179,13 @@ export const constantRoutes = [
|
|||
{
|
||||
path: '/bpm',
|
||||
component: Layout,
|
||||
hidden: true, // TODO 芋艿:未来可删除,暂时作为一个测试页
|
||||
hidden: true,
|
||||
children: [
|
||||
{
|
||||
path: 'manager/model/view',
|
||||
component: (resolve) => require(['@/views/bpm/model/modelViewer'], resolve),
|
||||
name: '流程模型-浏览',
|
||||
meta: { title: '流程模型-浏览' }
|
||||
path: 'manager/definition',
|
||||
component: (resolve) => require(['@/views/bpm/definition/index'], resolve),
|
||||
name: '流程定义',
|
||||
meta: { title: '流程定义' }
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
<template>
|
||||
<div class="app-container">
|
||||
<!-- 列表 -->
|
||||
<el-table v-loading="loading" :data="list">
|
||||
<el-table-column label="ID" align="center" prop="id" />
|
||||
<el-table-column label="流程名字" align="center" prop="name" />
|
||||
</el-table>
|
||||
|
||||
<!-- 分页组件 -->
|
||||
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {getDefinitionPage} from "@/api/bpm/definition";
|
||||
|
||||
export default {
|
||||
name: "processDefinition",
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 表格数据
|
||||
list: [],
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNo: 1,
|
||||
pageSize: 10
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
const key = this.$route.query && this.$route.query.key
|
||||
if (key) {
|
||||
this.queryParams['key'] = key
|
||||
}
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 查询流程定义列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
getDefinitionPage(this.queryParams).then(response => {
|
||||
this.list = response.data.list;
|
||||
this.total = response.data.total;
|
||||
this.loading = false;
|
||||
}
|
||||
);
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
@ -68,8 +68,6 @@
|
|||
</el-table-column>
|
||||
<el-table-column label="激活状态" align="center" prop="processDefinition.version" width="80">
|
||||
<template slot-scope="scope">
|
||||
<!-- <el-tag type="success" v-if="scope.row.processDefinition && scope.row.processDefinition.suspensionState === 1">激活</el-tag>-->
|
||||
<!-- <el-tag type="warning" v-if="scope.row.processDefinition && scope.row.processDefinition.suspensionState === 2">挂起</el-tag>-->
|
||||
<el-switch v-if="scope.row.processDefinition" v-model="scope.row.processDefinition.suspensionState"
|
||||
:active-value="1" :inactive-value="2" @change="handleStatusChange(scope.row)" />
|
||||
</template>
|
||||
|
@ -84,7 +82,7 @@
|
|||
<template slot-scope="scope">
|
||||
<el-button size="mini" type="text" icon="el-icon-setting" @click="handleUpdate(scope.row)">设计流程</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-thumb" @click="handleDeploy(scope.row)">发布流程</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-ice-cream-round" @click="handleDeploy(scope.row)">流程定义</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-ice-cream-round" @click="handleDefinitionList(scope.row)">流程定义</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
@ -244,6 +242,15 @@ export default {
|
|||
this.showBpmnOpen = true
|
||||
})
|
||||
},
|
||||
/** 跳转流程定义的列表 */
|
||||
handleDefinitionList(row) {
|
||||
this.$router.push({
|
||||
path:"/bpm/manager/definition",
|
||||
query:{
|
||||
key: row.key
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
<template>
|
||||
<div class="app-container">
|
||||
|
||||
<!-- 流程设计器,负责绘制流程等 -->
|
||||
<my-process-viewer key="designer" v-model="xmlString" v-bind="controlForm" keyboard ref="processDesigner" />
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {getModel} from "@/api/bpm/model";
|
||||
export default {
|
||||
name: "App",
|
||||
components: { },
|
||||
data() {
|
||||
return {
|
||||
xmlString: "", // BPMN XML
|
||||
controlForm: {
|
||||
prefix: "activiti"
|
||||
},
|
||||
};
|
||||
},
|
||||
created() {
|
||||
// 如果 modelId 非空,说明是修改流程模型
|
||||
const modelId = this.$route.query && this.$route.query.modelId
|
||||
if (modelId) {
|
||||
getModel(modelId).then(response => {
|
||||
this.xmlString = response.data.bpmnXml
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
.my-process-designer {
|
||||
height: calc(100vh - 84px);
|
||||
}
|
||||
|
||||
</style>
|
|
@ -1,192 +0,0 @@
|
|||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="模型名字" prop="name">
|
||||
<el-input v-model="queryParams.name" placeholder="请输入模型名字" clearable style="width: 240px;" size="small"
|
||||
@keyup.enter.native="handleQuery"/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
@click="openBpmn"
|
||||
v-hasPermi="['infra:config:create']"
|
||||
>新建流程</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
<el-table v-loading="loading" :data="list">
|
||||
<el-table-column label="ID" align="center" prop="id" />
|
||||
<el-table-column label="流程名字" align="center" prop="name" />
|
||||
<!-- <el-table-column label="创建时间" align="center" prop="createTime" >-->
|
||||
<!-- <template slot-scope="scope">-->
|
||||
<!-- <span>{{ parseTime(scope.row.createTime) }}</span>-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-table-column>-->
|
||||
<el-table-column label="操作" align="center" >
|
||||
<template slot-scope="scope">
|
||||
<!-- <el-button size="mini" type="text" icon="el-icon-setting" @click="change(scope.row)">设计流程</el-button>-->
|
||||
<!-- <el-button size="mini" type="text" icon="el-icon-delete" @click="deleteModel(scope.row)">删除</el-button>-->
|
||||
<!-- <el-button size="mini" type="text" icon="el-icon-thumb" @click="deployModel(scope.row)">发布</el-button>-->
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"/>
|
||||
<el-dialog :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>-->
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {page} from "@/api/bpm/processDefinition";
|
||||
// import VueBpmn from "@/components/bpmn/VueBpmn";
|
||||
|
||||
export default {
|
||||
name: "processDefinition",
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
showBpmnBool: false,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 表格数据
|
||||
list: [],
|
||||
bpmnXML: null,
|
||||
bpmnData: {},
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNo: 1,
|
||||
pageSize: 10
|
||||
}
|
||||
};
|
||||
},
|
||||
// components: {VueBpmn},
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 查询登录日志列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
page(this.queryParams).then(response => {
|
||||
this.list = response.data.list;
|
||||
this.total = response.data.total;
|
||||
this.loading = false;
|
||||
}
|
||||
);
|
||||
|
||||
},
|
||||
// 登录状态字典翻译
|
||||
statusFormat(row, column) {
|
||||
return this.selectDictLabel(this.statusOptions, row.status);
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNo = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.dateRange = [];
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
processSave(data) {
|
||||
const that = this;
|
||||
// 如果存在id 说明是修改
|
||||
if (data.id) {
|
||||
let postData = JSON.parse(data.metaInfo)
|
||||
postData.bpmnXml = data.bpmnXml
|
||||
postData.id = data.id
|
||||
postData.name = data.name
|
||||
postData.key = data.key
|
||||
postData.description = data.description
|
||||
updateModel(postData).then(response => {
|
||||
this.msgSuccess("保存成功");
|
||||
})
|
||||
this.showBpmnBool = false
|
||||
this.getList();
|
||||
return
|
||||
}
|
||||
createModel(data).then(response => {
|
||||
that.bpmnData.id = response.data
|
||||
this.msgSuccess("保存成功");
|
||||
})
|
||||
|
||||
this.showBpmnBool = false
|
||||
this.getList();
|
||||
},
|
||||
openBpmn() {
|
||||
this.bpmnData = {}
|
||||
this.bpmnXML = ""
|
||||
this.showBpmnBool = true
|
||||
},
|
||||
close() {
|
||||
this.showBpmnBool = false
|
||||
this.getList();
|
||||
},
|
||||
change(row) {
|
||||
const that = this;
|
||||
this.bpmnXML = ""
|
||||
this.bpmnData = {}
|
||||
// TODO @芋艿:修改成 getModel
|
||||
},
|
||||
modelDelete(row) {
|
||||
const that = this;
|
||||
this.$confirm('是否删除该流程!!', "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}).then(function() {
|
||||
deleteModel({
|
||||
modelId: row.id
|
||||
}).then(response => {
|
||||
that.getList();
|
||||
that.msgSuccess("删除成功");
|
||||
})
|
||||
})
|
||||
},
|
||||
modelDeploy(row) {
|
||||
const that = this;
|
||||
this.$confirm('是否部署该流程!!', "提示", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "success"
|
||||
}).then(function() {
|
||||
deployModel({
|
||||
modelId: row.id
|
||||
}).then(response => {
|
||||
that.getList();
|
||||
that.msgSuccess("部署成功");
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style>
|
||||
.el-dialog > .el-dialog__body{
|
||||
margin: 0;
|
||||
border: 0;
|
||||
}
|
||||
.bpmn-viewer-header{
|
||||
background: white;
|
||||
}
|
||||
.v-modal{
|
||||
z-index: 2000!important;
|
||||
}
|
||||
</style>
|
||||
|
Loading…
Reference in New Issue