更多nbcio-boot功能请看演示系统
gitee源代码地址
后端代码: https://gitee.com/nbacheng/nbcio-boot
前端代码:https://gitee.com/nbacheng/nbcio-vue.git
在线演示(包括H5) : http://122.227.135.243:9888
之前流程模型查询一直比较混乱,不是按照时间来排序,因为本身flowable不支持这种排序,原因是他的定义里就没有这个时间。
所以只能用其它方法了。
java实现方法如下:
/*** 流程定义列表** @param pageNum 当前页码* @param pageSize 每页条数* @param flowProcDefDto* modify by nbacheng* @return 流程定义分页列表数据*/@Overridepublic Page<FlowProcDefDto> list(Integer pageNum, Integer pageSize, FlowProcDefDto flowProcDefDto) {Page<FlowProcDefDto> page = new Page<>();// 流程定义列表数据查询ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery();processDefinitionQuery.latestVersion() //获取最新的一个版本.orderByProcessDefinitionName().asc();/*=====参数=====*/if (StrUtil.isNotBlank(flowProcDefDto.getName())){processDefinitionQuery.processDefinitionNameLike("%"+flowProcDefDto.getName()+"%");}if (StrUtil.isNotBlank(flowProcDefDto.getCategory())){processDefinitionQuery.processDefinitionCategory(flowProcDefDto.getCategory());}if (flowProcDefDto.getSuspensionState() == 1){processDefinitionQuery.active();}/*============*/page.setTotal(processDefinitionQuery.count());//获取所有数据List<ProcessDefinition> processDefinitionList = processDefinitionQuery.list();List<FlowProcDefDto> totalDataList = 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);// 流程定义时间reProcDef.setDeploymentTime(deployment.getDeploymentTime());SysForm sysForm = sysDeployFormService.selectSysDeployFormByDeployId(reProcDef.getDeploymentId());if (Objects.nonNull(sysForm)) {reProcDef.setFormName(sysForm.getFormName());reProcDef.setFormId(sysForm.getId());}FlowDeployOnline flowDeployOnline = iFlowDeployOnlineService.selectFlowDeployOnlineByDeployId(reProcDef.getDeploymentId());if (Objects.nonNull(flowDeployOnline)) {reProcDef.setFormName(flowDeployOnline.getTableName());reProcDef.setFormId(flowDeployOnline.getId());}SysCustomForm sysCustomForm = sysDeployFormService.selectSysCustomFormByDeployId(reProcDef.getDeploymentId());if (Objects.nonNull(sysCustomForm)) {reProcDef.setFormName(sysCustomForm.getBusinessName());reProcDef.setFormId(sysCustomForm.getId());}totalDataList.add(reProcDef);}List<FlowProcDefDto> dataList = new ArrayList<>();//按发布时间进行倒序重新排列,以便用户方便查询if(ObjectUtils.isNotEmpty(totalDataList)) {totalDataList.sort(Comparator.comparing(FlowProcDefDto::getDeploymentTime).reversed());dataList = partition(totalDataList,pageSize,pageNum);}page.setRecords(dataList);return page;}/**@Description: 使用 Lists 工具类的 partition 分页* <br> 1. 页码边界值处理:小于等于0,情况处理; 页码大于 (总页数-1) 情况处理* <br> 2. 总页数-1 ,原因是:list集合索引是从0开始的。* @param pageSize 每页显示的数量* @param pageNum 当前页码* @see com.google.common.collect.Lists#partition(java.util.List, int)*/private List<FlowProcDefDto> partition(List<FlowProcDefDto> totalDataList, int pageSize, int pageNum) {// 将 List 按照 PageSzie 拆分成多个ListList<? extends List<?>> partition = Lists.partition(totalDataList, pageSize);// 总页数int pages = partition.size();pageNum = pageNum <= 0 ? 0 : (pageNum <= (pages - 1) ? pageNum : (pages - 1));return (List<FlowProcDefDto>) partition.get(pageNum);}
效果如下: