diff --git a/blade-service-api/blade-dict-api/src/main/java/org/springblade/system/utils/DictUtil.java b/blade-service-api/blade-dict-api/src/main/java/org/springblade/system/utils/DictUtil.java index bb270a81..8d079a2b 100644 --- a/blade-service-api/blade-dict-api/src/main/java/org/springblade/system/utils/DictUtil.java +++ b/blade-service-api/blade-dict-api/src/main/java/org/springblade/system/utils/DictUtil.java @@ -29,7 +29,7 @@ public class DictUtil { */ public static String getValue(String code, Integer dictKey) { String dictValue = CacheUtil.get(CacheConstant.DICT_VALUE, code + StringPool.UNDERSCORE + dictKey, String.class); - if (Func.isEmpty(dictKey)) { + if (Func.isEmpty(dictValue)) { R result = dictClient.getValue(code, dictKey); if (result.isSuccess()) { CacheUtil.put(CacheConstant.DICT_VALUE, code + StringPool.UNDERSCORE + dictKey, result.getData()); diff --git a/blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/controller/FlowManagerController.java b/blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/controller/FlowManagerController.java index c2d4b951..fe5a82c9 100644 --- a/blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/controller/FlowManagerController.java +++ b/blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/controller/FlowManagerController.java @@ -16,7 +16,16 @@ */ package org.springblade.flowable.engine.controller; +import com.baomidou.mybatisplus.core.metadata.IPage; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; import lombok.AllArgsConstructor; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springblade.flowable.engine.entity.FlowProcess; +import org.springblade.flowable.engine.service.FlowService; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -30,5 +39,16 @@ import org.springframework.web.bind.annotation.RestController; @AllArgsConstructor public class FlowManagerController { + private FlowService flowService; + + /** + * 分页 + */ + @GetMapping("/list") + @ApiOperation(value = "分页", notes = "传入notice", position = 1) + public R> list(@ApiParam("流程类型") String category, Query query) { + IPage pages = flowService.selectManagerPage(Condition.getPage(query), category); + return R.data(pages); + } } diff --git a/blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/entity/ProcessDefinition.java b/blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/entity/FlowProcess.java similarity index 93% rename from blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/entity/ProcessDefinition.java rename to blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/entity/FlowProcess.java index 50de82a7..103f0da8 100644 --- a/blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/entity/ProcessDefinition.java +++ b/blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/entity/FlowProcess.java @@ -26,12 +26,12 @@ import java.io.Serializable; import java.util.Date; /** - * ProcessDefinition + * FlowProcess * * @author Chill */ @Data -public class ProcessDefinition implements Serializable { +public class FlowProcess implements Serializable { private String id; private String name; @@ -45,7 +45,7 @@ public class ProcessDefinition implements Serializable { private Integer suspensionState; private Date deploymentTime; - public ProcessDefinition(ProcessDefinitionEntityImpl entity) { + public FlowProcess(ProcessDefinitionEntityImpl entity) { this.id = entity.getId(); this.name = entity.getName(); this.key = entity.getKey(); diff --git a/blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/service/FlowService.java b/blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/service/FlowService.java index c750608a..1f700db1 100644 --- a/blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/service/FlowService.java +++ b/blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/service/FlowService.java @@ -19,6 +19,7 @@ package org.springblade.flowable.engine.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import org.springblade.flowable.engine.entity.FlowModel; +import org.springblade.flowable.engine.entity.FlowProcess; /** * FlowService @@ -36,6 +37,15 @@ public interface FlowService extends IService { */ IPage selectFlowPage(IPage page, FlowModel flowModel); + /** + * 流程管理列表 + * + * @param page 分页工具 + * @param category 分类 + * @return + */ + IPage selectManagerPage(IPage page, String category); + /** * 部署流程 * diff --git a/blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/service/impl/FlowServiceImpl.java b/blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/service/impl/FlowServiceImpl.java index 681cfbfe..2325956a 100644 --- a/blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/service/impl/FlowServiceImpl.java +++ b/blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/service/impl/FlowServiceImpl.java @@ -28,12 +28,16 @@ import org.flowable.bpmn.model.BpmnModel; import org.flowable.bpmn.model.Process; import org.flowable.editor.language.json.converter.BpmnJsonConverter; import org.flowable.engine.RepositoryService; +import org.flowable.engine.impl.persistence.entity.ProcessDefinitionEntityImpl; import org.flowable.engine.repository.Deployment; import org.flowable.engine.repository.ProcessDefinition; +import org.flowable.engine.repository.ProcessDefinitionQuery; import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.StringUtil; import org.springblade.flowable.engine.constant.FlowableConstant; import org.springblade.flowable.engine.entity.FlowModel; +import org.springblade.flowable.engine.entity.FlowProcess; import org.springblade.flowable.engine.mapper.FlowMapper; import org.springblade.flowable.engine.service.FlowService; import org.springframework.stereotype.Service; @@ -63,6 +67,31 @@ public class FlowServiceImpl extends ServiceImpl implemen return page.setRecords(baseMapper.selectFlowPage(page, flowModel)); } + @Override + public IPage selectManagerPage(IPage page, String category) { + + ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery().latestVersion().orderByProcessDefinitionKey().asc(); + + if (StringUtils.isNotEmpty(category)){ + processDefinitionQuery.processDefinitionCategory(category); + } + + page.setTotal(processDefinitionQuery.count()); + List processDefinitionList = processDefinitionQuery.listPage(Func.toInt(page.getCurrent() - 1), Func.toInt(page.getSize())); + + List flowProcessList = new ArrayList<>(); + for (ProcessDefinition processDefinition : processDefinitionList) { + String deploymentId = processDefinition.getDeploymentId(); + Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult(); + + FlowProcess flowProcess = new FlowProcess((ProcessDefinitionEntityImpl) processDefinition); + flowProcess.setDeploymentTime(deployment.getDeploymentTime()); + flowProcessList.add(flowProcess); + } + page.setRecords(flowProcessList); + return page; + } + @Override public boolean deploy(String modelId, String category) {