From 8a5c8eda00e462d126617d091e25c26d717465c7 Mon Sep 17 00:00:00 2001 From: CMM <2198256324@qq.com> Date: Wed, 12 Apr 2023 17:53:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=BE=85=E6=88=91=E5=A4=84?= =?UTF-8?q?=E7=90=86=E6=95=B0=E9=87=8F=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/TodoCenterController.java | 7 +++ .../pmapi/todocenter/manage/TodoCenterManage.java | 71 +++++++++++++++++++++- .../pmapi/todocenter/model/vo/TodoNumVO.java | 28 +++++++++ 3 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/vo/TodoNumVO.java diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/controller/TodoCenterController.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/controller/TodoCenterController.java index 50fc956..e151536 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/controller/TodoCenterController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/controller/TodoCenterController.java @@ -4,6 +4,7 @@ package com.ningdatech.pmapi.todocenter.controller; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; +import com.ningdatech.pmapi.todocenter.model.vo.TodoNumVO; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -180,4 +181,10 @@ public class TodoCenterController { public Long getSealedPdf(@Valid @RequestBody SealInfoDTO req){ return todoCenterManage.getSealedPdf(req); } + + @ApiOperation("待办中心待我处理数量统计") + @GetMapping("/getTodoNums") + public TodoNumVO getTodoNums(@Valid @ModelAttribute ToBeProcessedReq param){ + return todoCenterManage.getTodoNums(param); + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java index 98d3901..b39f9d4 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java @@ -12,6 +12,7 @@ import javax.servlet.http.HttpServletResponse; import com.ningdatech.pmapi.projectdeclared.manage.DeclaredProjectManage; import com.ningdatech.pmapi.todocenter.handle.WithDrawHandle; +import com.ningdatech.pmapi.todocenter.model.vo.TodoNumVO; import com.wflow.workflow.enums.ProcessHandlerEnum; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; @@ -218,7 +219,7 @@ public class TodoCenterManage { res.setProcessDefName(d.getProcessDefName()); return res; }).collect(Collectors.toList()); - return PageVo.of(resVos, todoList.size()); + return PageVo.of(resVos, list.size()); } /** @@ -1105,4 +1106,72 @@ public class TodoCenterManage { return statisticsVO; } + + public TodoNumVO getTodoNums(ToBeProcessedReq param) { + // 获取登录用户ID + Long userId = LoginUserUtil.getUserId(); + // 获取登录用户全量信息 + UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId); + // 获取员工浙政钉code + String employeeCode = userFullInfo.getEmployeeCode(); + TodoNumVO todoNumVo = new TodoNumVO(); + // 查出项目库项目 + ProjectListReq projectListReq = new ProjectListReq(); + BeanUtils.copyProperties(param, projectListReq); + List projects = projectLibManage.projectList(projectListReq); + if(CollUtil.isEmpty(projects)){ + return todoNumVo; + } + // 再查出项目关联的流程实例ID + List projectIdList = projects.stream().map(Project::getId).collect(Collectors.toList()); + + List projectInstList = projectInstService.list(Wrappers.lambdaQuery(ProjectInst.class) + .in(ProjectInst::getProjectId, projectIdList) + .orderByDesc(ProjectInst::getProjectId)); + List instCodes = projectInstList.stream().map(ProjectInst::getInstCode).collect(Collectors.toList()); + // 查出用户工作流 + TodoCenterListReqDTO req = new TodoCenterListReqDTO(); + req.setInstCodes(instCodes); + req.setProcessDefId(param.getProcessDefId()); + req.setUserId(String.valueOf(userId)); + req.setEmployeeCode(employeeCode); + //有待办节点的(不包含退回) + List todoList = processTaskService.getUserTodoList(req); + //有退回待办的 + List backList = processTaskService.getBackTodoList(req); + //合并 并且排序 + List list = Stream.concat(todoList.stream(),backList.stream()) + .filter(Objects::nonNull) + .sorted(Comparator.comparing(ProcessTaskVo::getTaskCreateTime) + .reversed()) + .collect(Collectors.toList()); + if (CollUtil.isEmpty(list)){ + return todoNumVo; + } + + Map projectsMap = projects.stream().collect(Collectors.toMap(Project::getId, v -> v)); + Map projectInfoMap = projectInstList.stream() + .collect(Collectors.toMap(ProjectInst::getInstCode, p-> projectsMap.get(p.getProjectId()))); + // 关联项目信息 + List projectList = list.stream() + .map(d -> projectInfoMap.get(d.getInstanceId())) + .collect(Collectors.toList()); + if (CollUtil.isNotEmpty(projectList)) { + todoNumVo.setTotalNum(projectList.size()); + } + // 筛选出增补项目和非增补项目 + List appendProjects = projectList.stream() + .filter(p -> IsAppendProjectEnum.APPEND_PROJECT.getCode().equals(p.getIsTemporaryAugment())) + .collect(Collectors.toList()); + if (CollUtil.isNotEmpty(appendProjects)){ + todoNumVo.setAppendNum(appendProjects.size()); + } + List notAppendProjects = projectList.stream() + .filter(p -> IsAppendProjectEnum.NOT_APPEND_PROJECT.getCode().equals(p.getIsTemporaryAugment())) + .collect(Collectors.toList()); + if (CollUtil.isNotEmpty(notAppendProjects)){ + todoNumVo.setNotAppendNum(notAppendProjects.size()); + } + return todoNumVo; + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/vo/TodoNumVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/vo/TodoNumVO.java new file mode 100644 index 0000000..d1ab1c3 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/vo/TodoNumVO.java @@ -0,0 +1,28 @@ +package com.ningdatech.pmapi.todocenter.model.vo; + +import io.swagger.annotations.ApiModelProperty; +import io.swagger.models.auth.In; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 待办中心待我处理数量统计 + * + * @author CMM + * @since 2023/04/12 16:51 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class TodoNumVO { + + @ApiModelProperty("待我处理总数量") + private Integer totalNum; + + @ApiModelProperty("待我处理非增补项目总数量") + private Integer notAppendNum; + + @ApiModelProperty("待我处理非增补项目总数量") + private Integer appendNum; +}