fix: 自定义查询流程定义列表

approve-sys
tony 3 years ago
parent aef8335b6e
commit 0410ab897f

@ -3,7 +3,7 @@ package com.ruoyi.flowable.controller;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.flowable.domain.dto.FlowProcDefDto;
import com.ruoyi.system.domain.FlowProcDefDto;
import com.ruoyi.flowable.domain.dto.FlowSaveXmlVo;
import com.ruoyi.flowable.service.IFlowDefinitionService;
import com.ruoyi.system.service.ISysRoleService;
@ -55,8 +55,9 @@ public class FlowDefinitionController {
@GetMapping(value = "/list")
@ApiOperation(value = "流程定义列表", response = FlowProcDefDto.class)
public AjaxResult list(@ApiParam(value = "当前页码", required = true) @RequestParam Integer pageNum,
@ApiParam(value = "每页条数", required = true) @RequestParam Integer pageSize) {
return AjaxResult.success(flowDefinitionService.list(pageNum, pageSize));
@ApiParam(value = "每页条数", required = true) @RequestParam Integer pageSize,
@ApiParam(value = "流程名称", required = false) @RequestParam(required = false) String name) {
return AjaxResult.success(flowDefinitionService.list(name,pageNum, pageSize));
}

@ -2,7 +2,7 @@ package com.ruoyi.flowable.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.flowable.domain.dto.FlowProcDefDto;
import com.ruoyi.system.domain.FlowProcDefDto;
import java.io.IOException;
import java.io.InputStream;
@ -24,7 +24,7 @@ public interface IFlowDefinitionService {
* @param pageSize
* @return
*/
Page<FlowProcDefDto> list(Integer pageNum, Integer pageSize);
Page<FlowProcDefDto> list(String name,Integer pageNum, Integer pageSize);
/**
*

@ -1,21 +1,25 @@
package com.ruoyi.flowable.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ruoyi.flowable.common.constant.ProcessConstants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.flowable.common.enums.FlowComment;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.flowable.domain.dto.FlowProcDefDto;
import com.ruoyi.system.domain.FlowProcDefDto;
import com.ruoyi.flowable.factory.FlowServiceFactory;
import com.ruoyi.flowable.service.IFlowDefinitionService;
import com.ruoyi.flowable.service.ISysDeployFormService;
import com.ruoyi.system.domain.SysForm;
import com.ruoyi.system.mapper.FlowDeployMapper;
import com.ruoyi.system.service.ISysDeptService;
import com.ruoyi.system.service.ISysPostService;
import com.ruoyi.system.service.ISysUserService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.flowable.bpmn.model.BpmnModel;
import org.flowable.engine.repository.Deployment;
import org.flowable.engine.repository.ProcessDefinition;
@ -54,6 +58,9 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl
@Resource
private ISysPostService postService;
@Resource
private FlowDeployMapper flowDeployMapper;
private static final String BPMN_FILE_SUFFIX = ".bpmn";
@Override
@ -73,30 +80,43 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl
* @return
*/
@Override
public Page<FlowProcDefDto> list(Integer pageNum, Integer pageSize) {
public Page<FlowProcDefDto> list(String name, Integer pageNum, Integer pageSize) {
Page<FlowProcDefDto> page = new Page<>();
// 流程定义列表数据查询
ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery()
// .latestVersion()
.orderByProcessDefinitionKey().asc();
page.setTotal(processDefinitionQuery.count());
List<ProcessDefinition> processDefinitionList = processDefinitionQuery.listPage(pageSize * (pageNum - 1), pageSize);
List<FlowProcDefDto> dataList = new ArrayList<>();
for (ProcessDefinition processDefinition : processDefinitionList) {
String deploymentId = processDefinition.getDeploymentId();
Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();
FlowProcDefDto reProcDef = new FlowProcDefDto();
BeanUtils.copyProperties(processDefinition, reProcDef);
SysForm sysForm = sysDeployFormService.selectSysDeployFormByDeployId(deploymentId);
// // 流程定义列表数据查询
// final ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery();
// if (StringUtils.isNotEmpty(name)) {
// processDefinitionQuery.processDefinitionNameLike(name);
// }
//// processDefinitionQuery.orderByProcessDefinitionKey().asc();
// page.setTotal(processDefinitionQuery.count());
// List<ProcessDefinition> processDefinitionList = processDefinitionQuery.listPage(pageSize * (pageNum - 1), pageSize);
//
// List<FlowProcDefDto> dataList = new ArrayList<>();
// for (ProcessDefinition processDefinition : processDefinitionList) {
// String deploymentId = processDefinition.getDeploymentId();
// Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();
// FlowProcDefDto reProcDef = new FlowProcDefDto();
// BeanUtils.copyProperties(processDefinition, reProcDef);
// SysForm sysForm = sysDeployFormService.selectSysDeployFormByDeployId(deploymentId);
// if (Objects.nonNull(sysForm)) {
// reProcDef.setFormName(sysForm.getFormName());
// reProcDef.setFormId(sysForm.getFormId());
// }
// // 流程定义时间
// reProcDef.setDeploymentTime(deployment.getDeploymentTime());
// dataList.add(reProcDef);
// }
PageHelper.startPage(pageNum, pageSize);
final List<FlowProcDefDto> dataList = flowDeployMapper.selectDeployList(name);
for (FlowProcDefDto procDef : dataList) {
SysForm sysForm = sysDeployFormService.selectSysDeployFormByDeployId(procDef.getId());
if (Objects.nonNull(sysForm)) {
reProcDef.setFormName(sysForm.getFormName());
reProcDef.setFormId(sysForm.getFormId());
procDef.setFormName(sysForm.getFormName());
procDef.setFormId(sysForm.getFormId());
}
// 流程定义时间
reProcDef.setDeploymentTime(deployment.getDeploymentTime());
dataList.add(reProcDef);
}
page.setTotal(new PageInfo(dataList).getTotal());
page.setRecords(dataList);
return page;
}

@ -22,6 +22,25 @@
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
</dependency>
<!-- swagger-bootstrap-ui -->
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>swagger-bootstrap-ui</artifactId>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>

@ -1,4 +1,4 @@
package com.ruoyi.flowable.domain.dto;
package com.ruoyi.system.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ -28,7 +28,7 @@ public class FlowProcDefDto implements Serializable {
private String name;
@ApiModelProperty("流程key")
private String key;
private String flowKey;
@ApiModelProperty("流程分类")
private String category;

@ -0,0 +1,22 @@
package com.ruoyi.system.mapper;
import com.ruoyi.system.domain.FlowProcDefDto;
import java.util.List;
/**
*
*
* @author Xuan Xuan
* @email
* @date 2022/1/29 5:44
**/
public interface FlowDeployMapper {
/**
*
* @param name
* @return
*/
List<FlowProcDefDto> selectDeployList(String name);
}

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.FlowDeployMapper">
<select id="selectDeployList" resultType="com.ruoyi.system.domain.FlowProcDefDto">
SELECT
rd.id_ as deploymentId,
rd.name_ as name,
rd.category_ as category,
rp.key_ as flowKey,
rp.version_ as version,
rp.suspension_state_ as suspensionState,
rd.deploy_time_ as deploymentTime
FROM
ACT_RE_PROCDEF rp
LEFT JOIN ACT_RE_DEPLOYMENT rd ON rp.deployment_id_ = rd.id_
<where>
<if test="name != null and name != ''">
and rd.name_ like concat('%', #{name}, '%')
</if>
</where>
order by rd.deploy_time_ desc
</select>
</mapper>

@ -25,6 +25,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="formName != null and formName != ''"> and form_name like concat('%', #{formName}, '%')</if>
<if test="formContent != null and formContent != ''"> and form_content = #{formContent}</if>
</where>
order by create_time desc
</select>
<select id="selectSysFormById" parameterType="Long" resultMap="SysFormResult">

Loading…
Cancel
Save