From 72a7deb95e2e48dade03e54b90a7498f226af1fc Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期四, 09 一月 2025 14:57:34 +0800
Subject: [PATCH] 转办逻辑完善

---
 business/src/main/java/com/ycl/service/impl/ProjectProcessServiceImpl.java |   99 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 98 insertions(+), 1 deletions(-)

diff --git a/business/src/main/java/com/ycl/service/impl/ProjectProcessServiceImpl.java b/business/src/main/java/com/ycl/service/impl/ProjectProcessServiceImpl.java
index 0ba8055..9e7bda4 100644
--- a/business/src/main/java/com/ycl/service/impl/ProjectProcessServiceImpl.java
+++ b/business/src/main/java/com/ycl/service/impl/ProjectProcessServiceImpl.java
@@ -25,6 +25,7 @@
 import com.ycl.domain.form.TaskDelegationForm;
 import com.ycl.domain.json.TaskDelegateData;
 import com.ycl.domain.vo.CustomerTaskVO;
+import com.ycl.domain.vo.IndexCustomerTaskVO;
 import com.ycl.domain.vo.ProjectProcessDetailVO;
 import com.ycl.mapper.ProjectInfoMapper;
 import com.ycl.mapper.ProjectProcessMapper;
@@ -257,6 +258,101 @@
     }
 
     @Override
+    public void getIndexTodoTask(String taskName, int pageSize, int pageNum, Result result) {
+        TaskQuery taskQuery = taskService.createTaskQuery()
+                .active()
+                .includeProcessVariables()
+                .includeIdentityLinks()
+                .orderByTaskCreateTime().desc();
+
+        if (StringUtils.isNotBlank(taskName)) {
+            taskQuery.processDefinitionNameLike(taskName);
+        }
+        result.total(taskQuery.count());
+        List<Task> taskList = taskQuery.listPage(pageSize * (pageNum - 1), pageSize);
+        List<IndexCustomerTaskVO> vos = new ArrayList<>();
+        for (Task task : taskList) {
+            IndexCustomerTaskVO taskVO = new IndexCustomerTaskVO();
+            // 褰撳墠娴佺▼淇℃伅
+            taskVO.setTaskId(task.getId());
+            taskVO.setCreateTime(task.getCreateTime());
+            taskVO.setProcessDefId(task.getProcessDefinitionId());
+            taskVO.setExecutionId(task.getExecutionId());
+            taskVO.setTaskName(task.getName());
+            taskVO.setTaskStatus(TaskStatusEnum.TODO);
+            // 娴佺▼瀹氫箟淇℃伅
+            ProcessDefinition pd = repositoryService.createProcessDefinitionQuery()
+                    .processDefinitionId(task.getProcessDefinitionId())
+                    .singleResult();
+            taskVO.setDeployId(pd.getDeploymentId());
+            taskVO.setProcessName(pd.getName());
+            taskVO.setProcessInsId(task.getProcessInstanceId());
+            taskVO.setTaskDefinitionKey(task.getTaskDefinitionKey());
+
+            // 娴佺▼椤圭洰淇℃伅
+            ProjectInfo project = baseMapper.getProjectInfo(task.getProcessInstanceId());
+            if (Objects.nonNull(project)) {
+                taskVO.setProjectId(project.getId());
+                taskVO.setProjectName(project.getProjectName());
+            }
+
+            // 娴佺▼鍙戣捣浜轰俊鎭�
+            this.setPromoterInfo(taskVO);
+
+            // 涓�涓换鍔″彲鑳芥湁澶氫釜鍊欓�変汉/缁勶紝鎵�浠ラ渶瑕佷娇鐢╨ist
+            List<Long> handlerIds = new ArrayList<>(2);
+            List<String> handlerNames = new ArrayList<>(2);
+            List<Long> handlerUnitIds = new ArrayList<>(2);
+            List<String> handlerUnitNames = new ArrayList<>(2);
+
+            // 娴佺▼澶勭悊浜轰俊鎭�
+            List<? extends IdentityLinkInfo> identityLinks = task.getIdentityLinks();
+            for (IdentityLinkInfo identityLink : identityLinks) {
+                // 缁戝畾鐨勬槸鐢ㄦ埛锛屾煡鍑虹敤鎴峰鍚嶃�侀儴闂�
+                if (StringUtils.isNotBlank(identityLink.getUserId())) {
+                    taskVO.setHandlerType(HandlerTypeEnum.USER);
+                    SysUser sysUser = sysUserService.selectUserById(Long.parseLong(identityLink.getUserId()));
+                    if (Objects.nonNull(sysUser)) {
+                        handlerIds.add(sysUser.getUserId());
+                        handlerNames.add(sysUser.getNickName());
+                        if (Objects.nonNull(sysUser.getDept())) {
+                            handlerUnitIds.add(sysUser.getDept().getDeptId());
+                            handlerUnitNames.add(sysUser.getDept().getDeptName());
+                        }
+                    }
+                    // 缁戝畾鐨勬槸瑙掕壊鎴栬�呴儴闂�
+                } else if (StringUtils.isNotBlank(identityLink.getGroupId())) {
+                    if (identityLink.getGroupId().startsWith("dept")) {   // 閮ㄩ棬鐨刬d鏄姞浜嗗墠缂�鐨勫锛歞ept:1
+                        taskVO.setHandlerType(HandlerTypeEnum.DEPT);
+                        String[] split = identityLink.getGroupId().split(":");
+                        if (split.length > 1) {
+                            // 閮ㄩ棬
+                            SysDept dept = sysDeptService.selectDeptById(Long.parseLong(split[1]));
+                            if (Objects.nonNull(dept)) {
+                                handlerUnitIds.add(dept.getDeptId());
+                                handlerUnitNames.add(dept.getDeptName());
+                            }
+                        }
+                    } else {
+                        taskVO.setHandlerType(HandlerTypeEnum.ROLE);
+                        SysRole role = sysRoleService.selectRoleById(Long.parseLong(identityLink.getGroupId()));
+                        if (Objects.nonNull(role)) {
+                            handlerUnitIds.add(role.getRoleId());
+                            handlerUnitNames.add(role.getRoleName());
+                        }
+                    }
+                }
+            }
+            taskVO.setHandlerId(handlerIds);
+            taskVO.setHandlerName(handlerNames);
+            taskVO.setHandlerUnitId(handlerUnitIds);
+            taskVO.setHandlerUnitName(handlerUnitNames);
+            vos.add(taskVO);
+        }
+        result.put("taskList", vos);
+    }
+
+    @Override
     public void getAllTodoTask(String taskName, int pageSize, int pageNum, Result result) {
         TaskQuery taskQuery = taskService.createTaskQuery()
                 .active()
@@ -442,7 +538,7 @@
         jsonData.setAfterHandlerIds(afterHandlerIds);
         jsonData.setAfterHandlerType(form.getPeopleType());
         // 娣诲姞鏃ュ織
-        flowLogService.add(task.getId(), form.getProcessInsId(), FlowLogEventTypeEnum.DELEGATE, form.getProjectId(), JSON.toJSONString(jsonData));
+        flowLogService.add(task.getId(), task.getProcessInstanceId(), FlowLogEventTypeEnum.DELEGATE, form.getProjectId(), JSON.toJSONString(jsonData));
 
         return Result.ok("杞姙鎴愬姛");
     }
@@ -529,6 +625,7 @@
                         SysRole role = sysRoleService.selectRoleById(Long.parseLong(identityLink.getGroupId()));
                         if (Objects.nonNull(role)) {
                             handlerUnitIds.add(Long.parseLong(identityLink.getGroupId()));
+                            handlerUnitNames.add(role.getRoleName());
                         }
                     }
                 }

--
Gitblit v1.8.0