From 6d273236e06346ba3d86344c9bc15d118ea7ffd5 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Sat, 6 May 2023 11:21:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E5=8F=B0debug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manage/DefaultDeclaredProjectManage.java | 7 ++- .../controller/ProjectLibController.java | 8 ++- .../pmapi/projectlib/manage/ProjectLibManage.java | 14 ++--- .../pmapi/todocenter/manage/TodoCenterManage.java | 28 ++++------ .../todocenter/model/req/ToBeProcessedReq.java | 3 ++ .../service/impl/StatisticsServiceImpl.java | 23 +++++--- .../pmapi/workbench/manage/WorkbenchManage.java | 61 ++++++++++++---------- 7 files changed, 77 insertions(+), 67 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DefaultDeclaredProjectManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DefaultDeclaredProjectManage.java index 0ce5555..87eba24 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DefaultDeclaredProjectManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DefaultDeclaredProjectManage.java @@ -17,6 +17,7 @@ import com.ningdatech.pmapi.projectlib.model.dto.ProjectDTO; import com.ningdatech.pmapi.projectlib.model.entity.Project; import com.ningdatech.pmapi.projectlib.service.IProjectService; import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; +import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; import com.ningdatech.pmapi.user.util.LoginUserUtil; import com.wflow.bean.entity.WflowModels; import com.wflow.bean.entity.WflowOrgModels; @@ -216,15 +217,13 @@ public class DefaultDeclaredProjectManage { } //根据提交者的单位 - public DeclaredProjectStatisticsPO declaredProjectOrgStatistics(Integer year){ - UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); + public DeclaredProjectStatisticsPO declaredProjectOrgStatistics(Integer year, UserFullInfoDTO user){ //查此人建设单位的项目 return statisticsService.getOrgStatistics(user.getEmpPosUnitCode(),year); } //根据提交者的区域 他是区管或者超管 - public DeclaredProjectStatisticsPO declaredProjectRegionStatistics(Integer year){ - UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); + public DeclaredProjectStatisticsPO declaredProjectRegionStatistics(Integer year, UserFullInfoDTO user){ //查此人建设单位的项目 return statisticsService.getRegionStatistics(user.getRegionCode(),year); } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/controller/ProjectLibController.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/controller/ProjectLibController.java index 7e0b694..fa5b865 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/controller/ProjectLibController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/controller/ProjectLibController.java @@ -1,10 +1,13 @@ package com.ningdatech.pmapi.projectlib.controller; import com.ningdatech.basic.model.PageVo; +import com.ningdatech.pmapi.common.helper.UserInfoHelper; import com.ningdatech.pmapi.projectlib.manage.ProjectLibManage; import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; import com.ningdatech.pmapi.projectlib.model.vo.ProjectDetailVO; import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO; +import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; +import com.ningdatech.pmapi.user.util.LoginUserUtil; import com.wflow.workflow.bean.vo.ProcessDetailVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -31,10 +34,13 @@ public class ProjectLibController { private final ProjectLibManage projectLibManage; + private final UserInfoHelper userInfoHelper; + @GetMapping("/list") @ApiOperation("项目库列表") public PageVo projectLibList(ProjectListReq req) { - return projectLibManage.projectLibListWithPermission(req); + UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); + return projectLibManage.projectLibListWithPermission(req,user); } @GetMapping("/{id}") diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java index 5277eff..d18fdc0 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java @@ -108,9 +108,9 @@ public class ProjectLibManage { return PageVo.of(records, total); } - public PageVo projectLibListWithPermission(ProjectListReq req) { + public PageVo projectLibListWithPermission(ProjectListReq req,UserFullInfoDTO user) { LambdaQueryWrapper query = ProjectHelper.projectQuery(req); - UserFullInfoDTO user = buildProjectLibPermission(query); + user = buildProjectLibPermission(query,user); //项目查最新 query.eq(Project::getNewest,Boolean.TRUE); Page page = projectService.page(req.page(), query); @@ -118,6 +118,7 @@ public class ProjectLibManage { if ((total = page.getTotal()) == 0) { return PageVo.empty(); } + UserFullInfoDTO finalUser = user; List records = CollUtils.convert(page.getRecords(), w -> { ProjectLibListItemVO item = new ProjectLibListItemVO(); item.setId(w.getId()); @@ -133,10 +134,10 @@ public class ProjectLibManage { item.setProcessStatus(w.getProcessStatus()); item.setInstCode(w.getInstCode()); item.setIsHigherSuperOrg(w.getIsHigherSuperOrg()); - if (user.getIsOrgAdmin() && + if (finalUser.getIsOrgAdmin() && ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode().equals(item.getStatus()) - && StringUtils.isNotBlank(w.getSuperOrgCode()) && StringUtils.isNotBlank(user.getEmpPosUnitCode()) - && w.getSuperOrgCode().equals(user.getEmpPosUnitCode())) { + && StringUtils.isNotBlank(w.getSuperOrgCode()) && StringUtils.isNotBlank(finalUser.getEmpPosUnitCode()) + && w.getSuperOrgCode().equals(finalUser.getEmpPosUnitCode())) { item.setCanPreDeclared(Boolean.TRUE); } return item; @@ -522,8 +523,7 @@ public class ProjectLibManage { * * @param query */ - public UserFullInfoDTO buildProjectLibPermission(LambdaQueryWrapper query) { - UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); + public UserFullInfoDTO buildProjectLibPermission(LambdaQueryWrapper query,UserFullInfoDTO user) { Optional currentUserDataScope = DataScopeUtil.getCurrentUserDataScope(user); if (!currentUserDataScope.isPresent()) { log.warn("没有取到权限信息 当前查询 没有权限条件"); 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 fce580b..b3708f3 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 @@ -122,11 +122,7 @@ public class TodoCenterManage { private final RuntimeService runtimeService; private final IProjectService projectService; private final ProjectLibManage projectLibManage; - private final StateMachineUtils stateMachineUtils; - private final IDingEmployeeInfoService dingEmployeeInfoService; - private final IDingOrganizationService dingOrganizationService; private final ProcessInstanceService processInstanceService; - private final INdWorkNoticeStagingService workNoticeStagingService; private final DefaultDeclaredProjectManage defaultDeclaredProjectManage; private final IProjectApplicationService projectApplicationService; private final UserInfoHelper userInfoHelper; @@ -152,12 +148,15 @@ public class TodoCenterManage { * @since 2023/02/18 */ public PageVo todoProjectList(ToBeProcessedReq param) { - // 获取登录用户ID - Long userId = LoginUserUtil.getUserId(); - // 获取登录用户全量信息 - UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId); - // 获取员工浙政钉code - String employeeCode = userFullInfo.getEmployeeCode(); + String employeeCode = param.getEmployeeCode(); + if(StringUtils.isBlank(employeeCode)){ + // 获取登录用户ID + Long userId = LoginUserUtil.getUserId(); + // 获取登录用户全量信息 + UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId); + // 获取员工浙政钉code + employeeCode = userFullInfo.getEmployeeCode(); + } // 查出项目库项目 ProjectListReq projectListReq = new ProjectListReq(); @@ -184,7 +183,6 @@ public class TodoCenterManage { Integer pageNumber = param.getPageNumber(); Integer pageSize = param.getPageSize(); req.setProcessDefId(param.getProcessDefId()); - req.setUserId(String.valueOf(userId)); req.setEmployeeCode(employeeCode); //有待办节点的(不包含退回) List todoList = processTaskService.getUserTodoList(req); @@ -1136,13 +1134,7 @@ public class TodoCenterManage { } //获取当前登录人的 待办中心统计数据 - public TodoCenterStatisticsVO todoCenterStatistics(){ - Long userId = LoginUserUtil.getUserId(); - // 获取登录用户全量信息 - UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId); - // 获取登录用户浙政钉code - String employeeCode = userFullInfo.getEmployeeCode(); - + public TodoCenterStatisticsVO todoCenterStatistics(String employeeCode){ //为了查询效率 还是自己去写统计接口 TodoCenterStatisticsPO statistics = statisticsService.getStatistics(employeeCode); TodoCenterStatisticsVO statisticsVO = BeanUtil.copyProperties(statistics,TodoCenterStatisticsVO.class); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/req/ToBeProcessedReq.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/req/ToBeProcessedReq.java index cb9a254..b0927a9 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/req/ToBeProcessedReq.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/req/ToBeProcessedReq.java @@ -45,4 +45,7 @@ public class ToBeProcessedReq extends PagePo implements Serializable { @ApiModelProperty("流程配置ID") private String processDefId; + + @ApiModelProperty("登录人员工号") + private String employeeCode; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/service/impl/StatisticsServiceImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/service/impl/StatisticsServiceImpl.java index 2bfb695..e2ce259 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/service/impl/StatisticsServiceImpl.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/service/impl/StatisticsServiceImpl.java @@ -3,7 +3,10 @@ package com.ningdatech.pmapi.todocenter.service.impl; import com.ningdatech.pmapi.todocenter.mapper.StatisticsMapper; import com.ningdatech.pmapi.todocenter.model.po.TodoCenterStatisticsPO; import com.ningdatech.pmapi.todocenter.service.StatisticsService; +import com.wflow.workflow.bean.dto.TodoCenterListReqDTO; +import com.wflow.workflow.service.ProcessTaskService; import lombok.AllArgsConstructor; +import org.flowable.engine.TaskService; import org.springframework.stereotype.Service; import java.util.Objects; @@ -20,18 +23,22 @@ public class StatisticsServiceImpl implements StatisticsService { private final StatisticsMapper mapper; + private final ProcessTaskService processTaskService; + + private final TaskService taskService; + @Override public TodoCenterStatisticsPO getStatistics(String employeeCode) { TodoCenterStatisticsPO res = new TodoCenterStatisticsPO(); - TodoCenterStatisticsPO todo = mapper.getTodoOrIdo(employeeCode); - if(Objects.nonNull(todo)){ - res.setTodoNum(todo.getTodoNum()); - } - TodoCenterStatisticsPO ido = mapper.getIdo(employeeCode); - if(Objects.nonNull(ido)){ - res.setIdoNum(ido.getIdoNum()); - } + TodoCenterListReqDTO req = new TodoCenterListReqDTO(); + req.setEmployeeCode(employeeCode); + Integer todoCount = processTaskService.getTodoCount(req); + res.setTodoNum(todoCount); + + Integer idoCount = processTaskService.getUserIdoCount(req); + res.setIdoNum(idoCount); + TodoCenterStatisticsPO submit = mapper.mysubmitNum(employeeCode); if(Objects.nonNull(submit)){ res.setMysubmitNum(submit.getMysubmitNum()); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/workbench/manage/WorkbenchManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/workbench/manage/WorkbenchManage.java index 369349d..83172a6 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/workbench/manage/WorkbenchManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/workbench/manage/WorkbenchManage.java @@ -1,22 +1,15 @@ package com.ningdatech.pmapi.workbench.manage; -import cn.hutool.core.bean.BeanUtil; -import com.ningdatech.basic.model.PageVo; import com.ningdatech.pmapi.common.helper.UserInfoHelper; import com.ningdatech.pmapi.projectdeclared.manage.DeclaredProjectManage; import com.ningdatech.pmapi.projectdeclared.manage.DefaultDeclaredProjectManage; -import com.ningdatech.pmapi.projectdeclared.model.po.DeclaredProjectStatisticsPO; import com.ningdatech.pmapi.projectlib.manage.ProjectLibManage; import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; -import com.ningdatech.pmapi.sys.enumeration.NoticeTypeEnum; import com.ningdatech.pmapi.sys.manage.NoticeManage; import com.ningdatech.pmapi.sys.model.req.NoticeListReq; -import com.ningdatech.pmapi.sys.model.vo.NoticeListItemVO; import com.ningdatech.pmapi.todocenter.manage.TodoCenterManage; import com.ningdatech.pmapi.todocenter.model.req.ToBeProcessedReq; -import com.ningdatech.pmapi.todocenter.model.vo.ResToBeProcessedVO; import com.ningdatech.pmapi.todocenter.model.vo.TodoCenterStatisticsVO; -import com.ningdatech.pmapi.todocenter.model.vo.TodoVO; import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; import com.ningdatech.pmapi.user.util.LoginUserUtil; @@ -24,7 +17,8 @@ import com.ningdatech.pmapi.workbench.converter.WorkbenchConverter; import com.ningdatech.pmapi.workbench.model.vo.WorkbenchVO; import lombok.AllArgsConstructor; import org.springframework.stereotype.Component; - +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ForkJoinPool; import java.util.stream.Collectors; /** @@ -51,34 +45,43 @@ public class WorkbenchManage { public WorkbenchVO getWorkbenchData(Integer year){ WorkbenchVO res = new WorkbenchVO(); - UserInfoDetails user = LoginUserUtil.loginUserDetail(); + UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); - //1.待办中心数据 - TodoCenterStatisticsVO statisticsVO = todoCenterManage.todoCenterStatistics(); - ToBeProcessedReq toBeProcessedReq = new ToBeProcessedReq(); - toBeProcessedReq.setPageNumber(1); - toBeProcessedReq.setPageSize(5); - statisticsVO.setTodoList(todoCenterManage.todoProjectList(toBeProcessedReq).getRecords() - .stream().map(v -> WorkbenchConverter.convert(v)).collect(Collectors.toList())); - res.setTodoCerter(statisticsVO); + CompletableFuture.allOf( + CompletableFuture.runAsync(()-> { + //1.待办中心数据 + TodoCenterStatisticsVO statisticsVO = todoCenterManage.todoCenterStatistics(user.getEmployeeCode()); + ToBeProcessedReq toBeProcessedReq = new ToBeProcessedReq(); + toBeProcessedReq.setPageNumber(1); + toBeProcessedReq.setPageSize(5); + toBeProcessedReq.setEmployeeCode(user.getEmployeeCode()); + statisticsVO.setTodoList(todoCenterManage.todoProjectList(toBeProcessedReq).getRecords() + .stream().map(v -> WorkbenchConverter.convert(v)).collect(Collectors.toList())); + res.setTodoCerter(statisticsVO); + }, ForkJoinPool.commonPool()), + CompletableFuture.runAsync(()-> { + //2.项目统计数据 + res.setOrgDeclared(WorkbenchConverter.convert(defaultDeclaredProjectManage.declaredProjectOrgStatistics(year,user))); + if(userInfoHelper.isSuperOrRegionAdmin(user.getUserId())){ + res.setRegionDeclared(WorkbenchConverter.convert(defaultDeclaredProjectManage.declaredProjectRegionStatistics(year,user))); + } + }, ForkJoinPool.commonPool()), + CompletableFuture.runAsync(()-> { + //3.所有公告按类型分 + NoticeListReq noticeListReq = new NoticeListReq(); + noticeListReq.setPageNumber(1); + noticeListReq.setPageSize(1000); + res.setNoticeList(noticeManage.listToMapByManager(noticeListReq)); + }, ForkJoinPool.commonPool()) + ).join(); - //2.项目统计数据 - res.setOrgDeclared(WorkbenchConverter.convert(defaultDeclaredProjectManage.declaredProjectOrgStatistics(year))); - if(userInfoHelper.isSuperOrRegionAdmin(LoginUserUtil.getUserId())){ - res.setRegionDeclared(WorkbenchConverter.convert(defaultDeclaredProjectManage.declaredProjectRegionStatistics(year))); - } + //这个不能放入子线程 ProjectListReq projectListReq = new ProjectListReq(); projectListReq.setPageNumber(1); projectListReq.setPageSize(5); projectListReq.setProjectYear(year); projectListReq.setBuildOrgCode(user.getEmpPosUnitCode()); - res.setProjects(projectLibManage.projectLibListWithPermission(projectListReq).getRecords().stream().collect(Collectors.toList())); - - //3.所有公告按类型分 - NoticeListReq noticeListReq = new NoticeListReq(); - noticeListReq.setPageNumber(1); - noticeListReq.setPageSize(1000); - res.setNoticeList(noticeManage.listToMapByManager(noticeListReq)); + res.setProjects(projectLibManage.projectLibListWithPermission(projectListReq,user).getRecords().stream().collect(Collectors.toList())); return res; }