Browse Source

流程查询添加 发起人 和 流程名称 筛选

huangguoce 1 month ago
parent
commit
403ce7a3a8

+ 5 - 4
jeeplus-modules/jeeplus-flowable/src/main/java/com/jeeplus/flowable/controller/FlowableProcessController.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.jeeplus.aop.demo.annotation.DemoMode;
 import com.jeeplus.extension.domain.FlowCopy;
 import com.jeeplus.extension.service.FlowCopyService;
+import com.jeeplus.flowable.model.FlowDTO;
 import com.jeeplus.flowable.service.FlowProcessService;
 import com.jeeplus.flowable.vo.ProcessStatus;
 import com.jeeplus.flowable.vo.ProcessVo;
@@ -68,8 +69,8 @@ public class FlowableProcessController {
     }
 
     @GetMapping("runningData")
-    public ResponseEntity runningListData(Page <ProcessInstance> page, String title, String procInsId, String procDefKey) throws Exception {
-        Page <ProcessVo> result = flowProcessService.runningList ( page, title, procInsId, procDefKey );
+    public ResponseEntity runningListData(Page <ProcessInstance> page, FlowDTO flowDTO) throws Exception {
+        Page <ProcessVo> result = flowProcessService.runningList ( page, flowDTO );
         return ResponseEntity.ok ( result );
     }
 
@@ -78,8 +79,8 @@ public class FlowableProcessController {
      * 已结束的实例
      */
     @GetMapping("historyListData")
-    public ResponseEntity historyListData(Page <ProcessVo> page, String title, String procInsId, String procDefKey) throws Exception {
-        page = flowProcessService.historyList ( page, title, procInsId, procDefKey );
+    public ResponseEntity historyListData(Page <ProcessVo> page, FlowDTO flowDTO) throws Exception {
+        page = flowProcessService.historyList ( page, flowDTO);
         return ResponseEntity.ok ( page );
     }
 

+ 40 - 0
jeeplus-modules/jeeplus-flowable/src/main/java/com/jeeplus/flowable/model/FlowDTO.java

@@ -0,0 +1,40 @@
+package com.jeeplus.flowable.model;
+
+import cn.hutool.core.util.StrUtil;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.jeeplus.flowable.utils.TimeUtils;
+import com.jeeplus.flowable.utils.Variable;
+import lombok.Data;
+import org.flowable.engine.history.HistoricActivityInstance;
+import org.flowable.engine.history.HistoricProcessInstance;
+import org.flowable.engine.repository.ProcessDefinition;
+import org.flowable.engine.runtime.ProcessInstance;
+import org.flowable.task.api.Task;
+import org.flowable.task.api.history.HistoricTaskInstance;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 工作流模型
+ *
+ * @author liugaofeng
+ * @version 2021-08-01
+ */
+@Data
+public class FlowDTO {
+
+    private static final long serialVersionUID = 1L;
+
+   private String title;
+   private String procInsId;
+    private String procDefKe;
+    private String processDefinitionName;
+    private String userName;
+    private String userId;
+    private String officeName;
+
+}
+
+

+ 43 - 5
jeeplus-modules/jeeplus-flowable/src/main/java/com/jeeplus/flowable/service/FlowProcessService.java

@@ -12,6 +12,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.google.common.collect.Lists;
 import com.jeeplus.common.TokenProvider;
 import com.jeeplus.flowable.constant.FlowableConstant;
+import com.jeeplus.flowable.model.FlowDTO;
 import com.jeeplus.flowable.model.TaskComment;
 import com.jeeplus.flowable.service.converter.json.FlowModelService;
 import com.jeeplus.flowable.utils.StringUtils;
@@ -19,8 +20,10 @@ import com.jeeplus.flowable.vo.ActionType;
 import com.jeeplus.flowable.vo.ProcessStatus;
 import com.jeeplus.flowable.vo.ProcessVo;
 import com.jeeplus.flowable.vo.TaskVo;
+import com.jeeplus.sys.feign.IOfficeApi;
 import com.jeeplus.sys.feign.ITenantApi;
 import com.jeeplus.sys.feign.IUserApi;
+import com.jeeplus.sys.service.dto.OfficeDTO;
 import com.jeeplus.sys.service.dto.UserDTO;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.io.FileUtils;
@@ -190,7 +193,14 @@ public class FlowProcessService {
     /**
      * 运行中的流程
      */
-    public Page <ProcessVo> runningList(Page <ProcessInstance> page, String title, String procInsId, String procDefKey) throws Exception {
+    public Page <ProcessVo> runningList(Page <ProcessInstance> page, FlowDTO flowDTO) throws Exception {
+        String procInsId = flowDTO.getProcInsId();
+        String procDefKey = flowDTO.getProcDefKe();
+        String title = flowDTO.getTitle();
+        String userName = flowDTO.getUserName();
+        String userId = flowDTO.getUserId();
+        String processDefinitionName = flowDTO.getProcessDefinitionName();
+
         List <ProcessVo> result = new ArrayList <ProcessVo> ( );
         Page <ProcessVo> resultPage = new Page <> ( );
         ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery ( ).processInstanceTenantId ( tenantApi.getCurrentTenantId ( ) ).includeProcessVariables ( );
@@ -203,10 +213,22 @@ public class FlowProcessService {
             processInstanceQuery.processDefinitionKey ( procDefKey );
         }
 
+        if ( StrUtil.isNotBlank ( processDefinitionName ) ) {
+            processInstanceQuery.processDefinitionName (  processDefinitionName );
+        }
+
         if ( StrUtil.isNotBlank ( title ) ) {
             processInstanceQuery.variableValueLike ( "title", "%" + title + "%" );
         }
 
+        if ( StrUtil.isNotBlank ( userId ) ) {
+            processInstanceQuery.variableValueEquals ( "applyUserId",  userId );
+        }else{
+            if ( StrUtil.isNotBlank ( userName ) ) {
+                processInstanceQuery.variableValueLike ( "userName", "%" + userName + "%" );
+            }
+        }
+
         page.setTotal ( processInstanceQuery.count ( ) );
         resultPage.setTotal ( processInstanceQuery.count ( ) );
 
@@ -225,7 +247,7 @@ public class FlowProcessService {
             processVo.setProcessDefinitionId ( p.getProcessDefinitionId ( ) );
             processVo.setProcessDefinitionName ( p.getProcessDefinitionName ( ) );
             processVo.setActivityId ( p.getActivityId ( ) );
-            processVo.setVars ( p.getProcessVariables ( ) );
+            processVo.setVars ( p.getProcessVariables() );
             result.add ( processVo );
         }
         resultPage.setRecords ( result );
@@ -236,18 +258,34 @@ public class FlowProcessService {
     /**
      * 已结束的流程
      */
-    public Page <ProcessVo> historyList(Page <ProcessVo> page, String title, String procInsId, String procDefKey) throws Exception {
-
+    public Page <ProcessVo> historyList(Page <ProcessVo> page,  FlowDTO flowDTO) throws Exception {
+        String procInsId = flowDTO.getProcInsId();
+        String procDefKey = flowDTO.getProcDefKe();
+        String title = flowDTO.getTitle();
+        String userId = flowDTO.getUserId();
+        String userName = flowDTO.getUserName();
+        String processDefinitionName = flowDTO.getProcessDefinitionName();
         HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery ( ).processInstanceTenantId ( tenantApi.getCurrentTenantId ( ) ).includeProcessVariables ( ).finished ( )
                 .orderByProcessInstanceEndTime ( ).desc ( );
 
         if ( StrUtil.isNotBlank ( procInsId ) ) {
             query.processInstanceId ( procInsId );
         }
+
+        if ( StrUtil.isNotBlank ( processDefinitionName ) ) {
+            query.processDefinitionName (  processDefinitionName );
+        }
+
         if ( StrUtil.isNotBlank ( title ) ) {
             query.variableValueLike ( "title", "%" + title + "%" );
         }
-
+        if ( StrUtil.isNotBlank ( userId ) ) {
+            query.variableValueEquals ( "applyUserId",  userId );
+        }else{
+            if ( StrUtil.isNotBlank ( userName ) ) {
+                query.variableValueLike ( "userName", "%" + userName + "%" );
+            }
+        }
         if ( StrUtil.isNotBlank ( procDefKey ) ) {
             query.processDefinitionKey ( procDefKey );
         }