Преглед изворни кода

移动端相关代码调整

wangqiang пре 1 година
родитељ
комит
3ab2b66efc

+ 14 - 1
jeeplus-modules/jeeplus-flowable/src/main/java/com/jeeplus/extension/controller/FlowCopyController.java

@@ -16,6 +16,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.Iterator;
+
 /**
  * 流程抄送Controller
  *
@@ -37,12 +39,23 @@ public class FlowCopyController {
      * @return
      */
     @GetMapping("list")
-    public ResponseEntity list(FlowCopyDTO flowCopyDTO, Page <FlowCopyDTO> page) throws Exception {
+    public ResponseEntity list(FlowCopyDTO flowCopyDTO, Page <FlowCopyDTO> page, String type,String userName) throws Exception {
         QueryWrapper <FlowCopyDTO> queryWrapper = QueryWrapperGenerator.buildQueryCondition ( flowCopyDTO, FlowCopyDTO.class );
         if (null != flowCopyDTO && null != flowCopyDTO.getCreateBy() && StringUtils.isNotBlank(flowCopyDTO.getCreateBy().getName())){
             queryWrapper.like("createBy.name",flowCopyDTO.getCreateBy().getName());
         }
+
         IPage <FlowCopyDTO> result = flowCopyService.findPage ( page, queryWrapper );
+        if ("ydd".equals(type)) {
+            Iterator<FlowCopyDTO> iterator = result.getRecords().iterator();
+            while (iterator.hasNext()) {
+                FlowCopyDTO record = iterator.next();
+                if (!record.getProcInsName().contains("嘉溢-请假申请")) {
+                    iterator.remove(); // 删除不满足条件的数据
+                }
+            }
+        }
+
         return ResponseEntity.ok ( result );
     }
 

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

@@ -46,11 +46,11 @@ public class FlowableProcessController {
      * 流程定义列表
      */
     @GetMapping("list")
-    public ResponseEntity processListData(Page <Map> page, String category) {
+    public ResponseEntity processListData(Page <Map> page, String category,String type) {
         /*
          * 保存两个对象,一个是ProcessDefinition(流程定义),一个是Deployment(流程部署)
          */
-        page = flowProcessService.processList ( page, category );
+        page = flowProcessService.processList ( page, category, type );
         return ResponseEntity.ok ( page );
     }
 
@@ -253,7 +253,7 @@ public class FlowableProcessController {
         /*
          * 保存两个对象,一个是ProcessDefinition(流程定义),一个是Deployment(流程部署)
          */
-        page = flowProcessService.processList(page, "");
+        page = flowProcessService.processList(page, "","");
         List<Map> records = page.getRecords();
         Map resultMap = new HashMap();
         for (Map map : records) {
@@ -272,7 +272,7 @@ public class FlowableProcessController {
         /*
          * 保存两个对象,一个是ProcessDefinition(流程定义),一个是Deployment(流程部署)
          */
-        page = flowProcessService.processList(page, "");
+        page = flowProcessService.processList(page, "","");
         List<Map> records = page.getRecords();
         Map resultMap = new HashMap();
         for (Map map : records) {

+ 6 - 6
jeeplus-modules/jeeplus-flowable/src/main/java/com/jeeplus/flowable/controller/FlowableTaskController.java

@@ -85,8 +85,8 @@ public class FlowableTaskController {
     private IMailApi mailApi;
 
     @GetMapping("todo")
-    public ResponseEntity todoListData(Page <ProcessVo> page, Flow flow) {
-        page = flowTaskService.todoList ( page, flow );
+    public ResponseEntity todoListData(Page <ProcessVo> page, Flow flow, String type) {
+        page = flowTaskService.todoList ( page, flow, type );
         return ResponseEntity.ok ( page );
     }
 
@@ -96,8 +96,8 @@ public class FlowableTaskController {
      * @return
      */
     @GetMapping("historic")
-    public ResponseEntity historicListData(Page <HisTaskVo> page, Flow flow) {
-        page = flowTaskService.historicList ( page, flow );
+    public ResponseEntity historicListData(Page <HisTaskVo> page, Flow flow, String type) {
+        page = flowTaskService.historicList ( page, flow, type );
         return ResponseEntity.ok ( page );
     }
 
@@ -107,8 +107,8 @@ public class FlowableTaskController {
      * @return
      */
     @GetMapping("myApplyed")
-    public ResponseEntity myApplyedListData(Page <ProcessVo> page, Flow flow) throws Exception {
-        page = flowTaskService.getMyStartedProcIns ( userApi.getByToken ( TokenProvider.getCurrentToken ( ) ), page, flow );
+    public ResponseEntity myApplyedListData(Page <ProcessVo> page, Flow flow, String type) throws Exception {
+        page = flowTaskService.getMyStartedProcIns ( userApi.getByToken ( TokenProvider.getCurrentToken ( ) ), page, flow, type );
         return ResponseEntity.ok ( page );
     }
 

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

@@ -14,6 +14,7 @@ import com.jeeplus.common.TokenProvider;
 import com.jeeplus.flowable.constant.FlowableConstant;
 import com.jeeplus.flowable.model.TaskComment;
 import com.jeeplus.flowable.service.converter.json.FlowModelService;
+import com.jeeplus.flowable.utils.StringUtils;
 import com.jeeplus.flowable.vo.ActionType;
 import com.jeeplus.flowable.vo.ProcessStatus;
 import com.jeeplus.flowable.vo.ProcessVo;
@@ -63,10 +64,7 @@ import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 import java.io.*;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 import java.util.zip.ZipInputStream;
 
@@ -136,7 +134,7 @@ public class FlowProcessService {
      * 流程定义列表
      */
     @InterceptorIgnore(tenantLine = "true")
-    public Page <Map> processList(Page <Map> page, String category) {
+    public Page <Map> processList(Page <Map> page, String category, String type) {
         ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery ( )/*.processDefinitionTenantId ( tenantApi.getCurrentTenantId ( ) )*/.active ( )
                 .latestVersion ( ).orderByProcessDefinitionKey ( ).asc ( );
         if ( StrUtil.isNotEmpty ( category ) ) {
@@ -144,6 +142,27 @@ public class FlowProcessService {
         }
 
         List <ProcessDefinition> processDefinitionList = processDefinitionQuery.list ( );
+
+        if (StringUtils.isNotBlank(type)) {
+            if (type.equals("ydd")) {
+                // 创建一个包含需要保留的流程定义名称的集合
+                List<String> requiredNames = Arrays.asList("物资管理-领用申请", "物资管理-采购申请", "嘉溢-请假申请");
+                /**
+                 * 移动端工作台数据处理
+                 */
+                // 使用流操作筛选出符合条件的流程定义
+                //它首先创建了一个包含需要保留的流程定义名称的集合 requiredNames,
+                // 然后使用 stream() 方法将流程定义列表转换为流,
+                // 接着使用 filter 方法筛选出名称在 requiredNames 中的流程定义,
+                // 最后使用 collect 方法将结果收集到一个新的列表中
+                List<ProcessDefinition> newList = processDefinitionList.stream()
+                        .filter(processDefinition -> requiredNames.contains(processDefinition.getName()))
+                        .collect(Collectors.toList());
+                processDefinitionList.clear();
+                processDefinitionList.addAll(newList);
+            }
+        }
+
         List records = Lists.newArrayList ( );
         for (ProcessDefinition processDefinition : processDefinitionList) {
             if ( this.isAuth ( userApi.getByToken ( TokenProvider.getCurrentToken ( ) ), processDefinition.getId ( ) ) ) {

+ 72 - 31
jeeplus-modules/jeeplus-flowable/src/main/java/com/jeeplus/flowable/service/FlowTaskService.java

@@ -351,7 +351,7 @@ public class FlowTaskService {
      *
      * @return
      */
-    public Page <ProcessVo> todoList(Page <ProcessVo> page, Flow flow) {
+    public Page <ProcessVo> todoList(Page <ProcessVo> page, Flow flow, String type) {
         List <HashMap <String, String>> result = new ArrayList <HashMap <String, String>> ( );
         String userId = userApi.getByToken ( TokenProvider.getCurrentToken ( ) ).getId ( );//ObjectUtils.toString(UserUtils.getUser().getId());
         // =============== 已经签收或者等待签收的任务  ===============
@@ -390,28 +390,45 @@ public class FlowTaskService {
         }
         List records = Lists.newArrayList ( );
         for (Task task : todoList) {
-            Process process = SpringUtil.getBean ( RepositoryService.class ).getBpmnModel ( task.getProcessDefinitionId ( ) ).getMainProcess ( );
-            ProcessVo processVo = new ProcessVo ( );
-            TaskVo taskVo = new TaskVo ( task );
-            taskVo.setProcessDefKey ( process.getId ( ) );
-            processVo.setTask ( taskVo );
-            processVo.setVars ( task.getProcessVariables ( ) );
-            processVo.setProcessDefinitionName ( ProcessDefCache.get ( task.getProcessDefinitionId ( ) ).getName ( ) );
-            processVo.setVersion ( ProcessDefCache.get ( task.getProcessDefinitionId ( ) ).getVersion ( ) );
-            processVo.setStatus ( "todo" );
-            records.add ( processVo );
+
+            String processDefinitionId = task.getProcessDefinitionId();
+            String processName = ProcessDefCache.get(processDefinitionId).getName();
+
+            // 如果类型为 "ydd" 并且流程名称满足条件,或者类型为空
+            if (("ydd".equals(type) && isRequiredProcess(processName)) || StringUtils.isBlank(type)) {
+                Process process = SpringUtil.getBean ( RepositoryService.class ).getBpmnModel ( task.getProcessDefinitionId ( ) ).getMainProcess ( );
+
+                ProcessVo processVo = new ProcessVo();
+                TaskVo taskVo = new TaskVo(task);
+
+                taskVo.setProcessDefKey ( process.getId ( ) );
+                processVo.setTask(taskVo);
+                processVo.setVars(task.getProcessVariables());
+                processVo.setProcessDefinitionName(processName);
+                processVo.setVersion(ProcessDefCache.get(processDefinitionId).getVersion());
+                processVo.setStatus("todo");
+
+                records.add(processVo);
+            }
         }
         page.setRecords ( records );
         return page;
     }
 
+    // 判断流程名称是否满足条件
+    private boolean isRequiredProcess(String processName) {
+        return processName.equals("物资管理-领用申请") ||
+                processName.equals("物资管理-采购申请") ||
+                processName.equals("嘉溢-请假申请");
+    }
+
     /**
      * 获取已办任务列表
      *
      * @param page
      * @return
      */
-    public Page <HisTaskVo> historicList(Page <HisTaskVo> page, Flow act) {
+    public Page <HisTaskVo> historicList(Page <HisTaskVo> page, Flow act, String type) {
         String userId = userApi.getByToken ( TokenProvider.getCurrentToken ( ) ).getId ( );
 
         HistoricTaskInstanceQuery histTaskQuery = historyService.createHistoricTaskInstanceQuery ( ).taskAssignee ( userId ).finished ( )
@@ -447,28 +464,31 @@ public class FlowTaskService {
 
         List records = Lists.newArrayList ( );
         for (HistoricTaskInstance histTask : histList) {
-            HisTaskVo hisTaskVo = new HisTaskVo ( histTask );
-            hisTaskVo.setProcessDefinitionName ( ProcessDefCache.get ( histTask.getProcessDefinitionId ( ) ).getName ( ) );
-            hisTaskVo.setBack ( isBack ( histTask ) );
-            List <Task> currentTaskList = taskService.createTaskQuery ( ).processInstanceId ( histTask.getProcessInstanceId ( ) ).list ( );
-            if ( ((List) currentTaskList).size ( ) > 0 ) {
-                TaskVo currentTaskVo = new TaskVo ( currentTaskList.get ( 0 ) );
-                hisTaskVo.setCurrentTask ( currentTaskVo );
-            }
 
+            String processDefinitionId = histTask.getProcessDefinitionId();
+            String processName = ProcessDefCache.get(processDefinitionId).getName();
+            if (("ydd".equals(type) && isRequiredProcess(processName)) || StringUtils.isBlank(type)){
+                HisTaskVo hisTaskVo = new HisTaskVo ( histTask );
+                hisTaskVo.setProcessDefinitionName ( ProcessDefCache.get ( histTask.getProcessDefinitionId ( ) ).getName ( ) );
+                hisTaskVo.setBack ( isBack ( histTask ) );
+                List <Task> currentTaskList = taskService.createTaskQuery ( ).processInstanceId ( histTask.getProcessInstanceId ( ) ).list ( );
+                if ( ((List) currentTaskList).size ( ) > 0 ) {
+                    TaskVo currentTaskVo = new TaskVo ( currentTaskList.get ( 0 ) );
+                    hisTaskVo.setCurrentTask ( currentTaskVo );
+                }
 
-            // 获取意见评论内容
-
-            List <TaskComment> commentList = this.getTaskComments ( histTask.getId ( ) );
-            if ( commentList.size ( ) > 0 ) {
-                TaskComment comment = commentList.get ( commentList.size ( ) - 1 );
-                hisTaskVo.setComment ( comment.getMessage ( ) );
-                hisTaskVo.setLevel ( comment.getLevel ( ) );
-                hisTaskVo.setType ( comment.getType ( ) );
-                hisTaskVo.setStatus ( comment.getStatus ( ) );
+                // 获取意见评论内容
+                List <TaskComment> commentList = this.getTaskComments ( histTask.getId ( ) );
+                if ( commentList.size ( ) > 0 ) {
+                    TaskComment comment = commentList.get ( commentList.size ( ) - 1 );
+                    hisTaskVo.setComment ( comment.getMessage ( ) );
+                    hisTaskVo.setLevel ( comment.getLevel ( ) );
+                    hisTaskVo.setType ( comment.getType ( ) );
+                    hisTaskVo.setStatus ( comment.getStatus ( ) );
 
+                }
+                records.add ( hisTaskVo );
             }
-            records.add ( hisTaskVo );
         }
         page.setRecords ( records );
         return page;
@@ -566,7 +586,7 @@ public class FlowTaskService {
      * @param user
      * @return
      */
-    public Page <ProcessVo> getMyStartedProcIns(UserDTO user, Page <ProcessVo> page, Flow flow) throws Exception {
+    public Page <ProcessVo> getMyStartedProcIns(UserDTO user, Page <ProcessVo> page, Flow flow, String type) throws Exception {
         HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery ( ).startedBy ( user.getId ( ) ).includeProcessVariables ( ).orderByProcessInstanceStartTime ( ).desc ( );
         if ( flow.getBeginDate ( ) != null ) {
             query.startedAfter ( flow.getBeginDate ( ) );
@@ -587,6 +607,27 @@ public class FlowTaskService {
             int size = (int) (page.getSize ( ));
             histList = query.involvedUser ( user.getId ( ) ).listPage ( start, size );
         }
+
+        if (StringUtils.isNotBlank(type)) {
+            if (type.equals("ydd")) {
+                // 创建一个包含需要保留的流程定义名称的集合
+                List<String> requiredNames = Arrays.asList("物资管理-领用申请", "物资管理-采购申请", "嘉溢-请假申请");
+                /**
+                 * 移动端工作台数据处理
+                 */
+                // 使用流操作筛选出符合条件的流程定义
+                //它首先创建了一个包含需要保留的流程定义名称的集合 requiredNames,
+                // 然后使用 stream() 方法将流程定义列表转换为流,
+                // 接着使用 filter 方法筛选出名称在 requiredNames 中的流程定义,
+                // 最后使用 collect 方法将结果收集到一个新的列表中
+                List<HistoricProcessInstance> newList = histList.stream()
+                        .filter(processDefinition -> requiredNames.contains(processDefinition.getProcessDefinitionName()))
+                        .collect(Collectors.toList());
+                histList.clear();
+                histList.addAll(newList);
+            }
+        }
+
         List records = Lists.newArrayList ( );
         for (HistoricProcessInstance historicProcessInstance : histList) {
             ProcessVo processVo = flowProcessService.queryProcessState ( historicProcessInstance.getProcessDefinitionId ( ), historicProcessInstance.getId ( ) );

+ 1 - 1
jeeplus-modules/jeeplus-flowable/src/main/java/com/jeeplus/flowable/service/MyNoticeService.java

@@ -123,7 +123,7 @@ public class MyNoticeService {
         if (StringUtils.isNotEmpty(taskName)) {
             notice.setTaskName(taskName);
         } else {
-            Page<Map> page = flowProcessService.processList(new Page<Map>(), "");
+            Page<Map> page = flowProcessService.processList(new Page<Map>(), "","");
             List<Map> records = page.getRecords();
             Map resultMap = new HashMap();
             for (Map<String, String> map : records) {

+ 69 - 0
jeeplus-modules/jeeplus-system/src/main/java/com/jeeplus/sys/controller/app/AppUserController.java

@@ -3,22 +3,28 @@
  */
 package com.jeeplus.sys.controller.app;
 
+import cn.hutool.extra.spring.SpringUtil;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
+import com.jeeplus.common.TokenProvider;
 import com.jeeplus.sys.controller.UserController;
 import com.jeeplus.sys.domain.Office;
 import com.jeeplus.sys.domain.User;
+import com.jeeplus.sys.feign.IUserApi;
 import com.jeeplus.sys.service.OfficeService;
 import com.jeeplus.sys.service.UserService;
+import com.jeeplus.sys.service.dto.UserDTO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * 用户Controller
@@ -36,6 +42,69 @@ public class AppUserController extends UserController {
     UserService userService;
 
     /**
+     * 移动端人员单选所需-获取机构JSON数据。
+     *
+     * @return
+     */
+    @GetMapping("treeDataRadio")
+    public ResponseEntity treeDataRadio(String type) {
+        UserDTO userDTO = SpringUtil.getBean(IUserApi.class).getByToken(TokenProvider.getCurrentToken());
+        List<Office> list = new ArrayList<>();
+        if (null != type && type.equals("ydd")) {
+            list = officeService.list().stream()
+                    .filter(office -> office.getTenantId().equals(userDTO.getTenantDTO().getId()))
+                    .collect(Collectors.toList());
+        } else {
+            list = officeService.list ( );
+        }
+
+        List rootTree = getRootTreeRadio ( list, type, userDTO );
+        return ResponseEntity.ok ( rootTree );
+    }
+
+    private List <Map> getRootTreeRadio(List <Office> list, String type, UserDTO userDTO) {
+        List <Map> offices = Lists.newArrayList ( );
+
+        List <Office> rootTrees = new ArrayList<>();
+        if (null != type && type.equals("ydd")){
+            rootTrees = officeService.treeData().stream()
+                    .filter(office -> office.getTenantId().equals(userDTO.getTenantDTO().getId()))
+                    .collect(Collectors.toList());
+        } else {
+            rootTrees = officeService.treeData ( );
+        }
+
+        for (Office root : rootTrees) {
+            offices.add ( getChildOfTreeRadio ( root, list ) );
+        }
+        return offices;
+    }
+
+    private Map getChildOfTreeRadio(Office officeItem, List <Office> officeList) {
+        Map oMap = new HashMap ( );
+        oMap.put ( "id", officeItem.getId ( ) );
+        oMap.put ( "type", "office" );
+        oMap.put ( "label", officeItem.getName ( ) );
+        List children = Lists.newArrayList ( );
+        oMap.put ( "children", children );
+        List <User> list = userService.lambdaQuery ( ).eq ( User::getOfficeId, officeItem.getId ( ) ).list ( );
+        for (int i = 0; i < list.size ( ); i++) {
+            User e = list.get ( i );
+            Map <String, Object> map = Maps.newHashMap ( );
+            map.put ( "id", e.getId ( ) );
+            map.put ( "type", "user" );
+            map.put ( "label", e.getName ( ) );
+            children.add ( map );
+        }
+        for (Office child : officeList) {
+            if ( child.getParentId ( ).equals ( officeItem.getId ( ) ) ) {
+                children.add ( getChildOfTreeRadio ( child, officeList ) );
+            }
+        }
+        return oMap;
+    }
+
+    /**
      * 获取机构JSON数据。
      *
      * @return