diff --git a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/controller/FlowDefinitionController.java b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/controller/FlowDefinitionController.java index 8c5111c..ece435a 100644 --- a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/controller/FlowDefinitionController.java +++ b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/controller/FlowDefinitionController.java @@ -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)); } diff --git a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/IFlowDefinitionService.java b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/IFlowDefinitionService.java index 51c74f9..391cc53 100644 --- a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/IFlowDefinitionService.java +++ b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/IFlowDefinitionService.java @@ -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 list(Integer pageNum, Integer pageSize); + Page list(String name,Integer pageNum, Integer pageSize); /** * 导入流程文件 diff --git a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/impl/FlowDefinitionServiceImpl.java b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/impl/FlowDefinitionServiceImpl.java index 1a7680e..ac37d60 100644 --- a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/impl/FlowDefinitionServiceImpl.java +++ b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/impl/FlowDefinitionServiceImpl.java @@ -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 list(Integer pageNum, Integer pageSize) { + public Page list(String name, Integer pageNum, Integer pageSize) { Page page = new Page<>(); - // 流程定义列表数据查询 - ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery() -// .latestVersion() - .orderByProcessDefinitionKey().asc(); - page.setTotal(processDefinitionQuery.count()); - List processDefinitionList = processDefinitionQuery.listPage(pageSize * (pageNum - 1), pageSize); - - List 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 processDefinitionList = processDefinitionQuery.listPage(pageSize * (pageNum - 1), pageSize); +// +// List 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 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; } diff --git a/ruoyi-system/pom.xml b/ruoyi-system/pom.xml index 5bac2b4..302c9d1 100644 --- a/ruoyi-system/pom.xml +++ b/ruoyi-system/pom.xml @@ -22,6 +22,25 @@ com.ruoyi ruoyi-common + + org.projectlombok + lombok + true + + + io.springfox + springfox-swagger2 + + + + com.github.xiaoymin + swagger-bootstrap-ui + + + io.swagger + swagger-annotations + compile + diff --git a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/domain/dto/FlowProcDefDto.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/FlowProcDefDto.java similarity index 94% rename from ruoyi-flowable/src/main/java/com/ruoyi/flowable/domain/dto/FlowProcDefDto.java rename to ruoyi-system/src/main/java/com/ruoyi/system/domain/FlowProcDefDto.java index 9d68829..44f5cc3 100644 --- a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/domain/dto/FlowProcDefDto.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/FlowProcDefDto.java @@ -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; diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/FlowDeployMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/FlowDeployMapper.java new file mode 100644 index 0000000..2cfd0ac --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/FlowDeployMapper.java @@ -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 selectDeployList(String name); +} diff --git a/ruoyi-system/src/main/resources/mapper/FlowDeployMapper.xml b/ruoyi-system/src/main/resources/mapper/FlowDeployMapper.xml new file mode 100644 index 0000000..65fabfc --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/FlowDeployMapper.xml @@ -0,0 +1,30 @@ + + + + + + + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/system/SysFormMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysFormMapper.xml index 2018cf9..b4ad545 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysFormMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysFormMapper.xml @@ -25,6 +25,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and form_name like concat('%', #{formName}, '%') and form_content = #{formContent} + order by create_time desc