From b1da9ae6e2d5f9ea119bd5fc8ef87ccd5b6d58ae Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Tue, 21 Nov 2023 18:05:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E5=8F=B0=20=E9=A2=84?= =?UTF-8?q?=E8=AD=A6=20=E5=82=AC=E5=8A=9E=20=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pmapi/sys/model/vo/ProjectEarlyWarningVO.java | 3 ++ .../user/security/auth/model/UserFullInfoDTO.java | 7 ++++ .../pmapi/workbench/manage/WorkbenchManage.java | 39 ++++++++++++++++++---- 3 files changed, 42 insertions(+), 7 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/vo/ProjectEarlyWarningVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/vo/ProjectEarlyWarningVO.java index 1300f44..55aa5d1 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/vo/ProjectEarlyWarningVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/vo/ProjectEarlyWarningVO.java @@ -34,6 +34,9 @@ public class ProjectEarlyWarningVO implements Serializable { @ApiModelProperty(value = "项目编码") private String projectCode; + @ApiModelProperty(value = "项目名称") + private String projectName; + @ApiModelProperty(value = "区域") private String areaCode; diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/model/UserFullInfoDTO.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/model/UserFullInfoDTO.java index 8625d21..e240077 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/model/UserFullInfoDTO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/model/UserFullInfoDTO.java @@ -128,4 +128,11 @@ public class UserFullInfoDTO { } return Boolean.FALSE; } + + public Boolean notAdmin() { + if(!getSuperAdmin() && !getRegionAdmin() && !getIsOrgAdmin()){ + return Boolean.TRUE; + } + return Boolean.FALSE; + } } 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 d5783a3..9da1750 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 @@ -108,7 +108,7 @@ public class WorkbenchManage { }, ForkJoinPool.commonPool()), CompletableFuture.runAsync(() -> { //4.项目预警记录 - res.setProjectEarlyWarning(getProjectEarlyWarning()); + res.setProjectEarlyWarning(getProjectEarlyWarning(user)); }, ForkJoinPool.commonPool()) ).join(); @@ -122,17 +122,31 @@ public class WorkbenchManage { return res; } - private WorkbenchVO.ProjectEarlyWarning getProjectEarlyWarning() { + private WorkbenchVO.ProjectEarlyWarning getProjectEarlyWarning(UserFullInfoDTO user) { WorkbenchVO.ProjectEarlyWarning projectEarlyWarning = new WorkbenchVO.ProjectEarlyWarning(); + + List projects = projectService.list(Wrappers.lambdaQuery(Project.class) + .eq(Project::getNewest, Boolean.TRUE) + .eq(user.getRegionAdmin(),Project::getAreaCode,user.getRegionCode()) + .eq(user.getIsOrgAdmin() || user.notAdmin(),Project::getBuildOrgCode,user.getEmpPosUnitCode())); + Set projectCodeS = Sets.newHashSet(); + Map projectNameMap = projects.stream() + .filter(p -> projectCodeS.add(p.getProjectCode())) + .collect(Collectors.toMap(Project::getProjectCode,Project::getProjectName)); + //4.1 //累积预警统计 WorkbenchVO.WarningStatistics accumulate = new WorkbenchVO.WarningStatistics(); Long overCount = earlyWarningRecordsService.count(Wrappers.lambdaQuery(WflowEarlyWarningRecords.class) .eq(WflowEarlyWarningRecords::getNoticeType, WarningNoticeTypeEnum.OVER.getCode()) - .or(q2 -> q2.isNull(WflowEarlyWarningRecords::getNoticeType))); + .or(q2 -> q2.isNull(WflowEarlyWarningRecords::getNoticeType)) + .eq(user.getRegionAdmin(),WflowEarlyWarningRecords::getAreaCode,user.getRegionCode()) + .eq(user.getIsOrgAdmin() || user.notAdmin(),WflowEarlyWarningRecords::getBuildOrgCode,user.getEmpPosUnitCode())); accumulate.setOver(overCount.intValue()); Long adventCount = earlyWarningRecordsService.count(Wrappers.lambdaQuery(WflowEarlyWarningRecords.class) - .eq(WflowEarlyWarningRecords::getNoticeType, WarningNoticeTypeEnum.ADVENT.getCode())); + .eq(WflowEarlyWarningRecords::getNoticeType, WarningNoticeTypeEnum.ADVENT.getCode()) + .eq(user.getRegionAdmin(),WflowEarlyWarningRecords::getAreaCode,user.getRegionCode()) + .eq(user.getIsOrgAdmin() || user.notAdmin(),WflowEarlyWarningRecords::getBuildOrgCode,user.getEmpPosUnitCode())); accumulate.setAdvent(adventCount.intValue()); projectEarlyWarning.setAccumulate(accumulate); @@ -143,13 +157,19 @@ public class WorkbenchManage { Page adventPage = Page.of(1,1000); Page normalPage = Page.of(1,1000); LambdaQueryWrapper overWrapper = Wrappers.lambdaQuery(ProjectEarlyWarning.class) - .eq(ProjectEarlyWarning::getStatus, ProjectEarlyWarningStatusEnum.OVER_TIME.name()); + .eq(ProjectEarlyWarning::getStatus, ProjectEarlyWarningStatusEnum.OVER_TIME.name()) + .eq(user.getRegionAdmin(),ProjectEarlyWarning::getAreaCode,user.getRegionCode()) + .eq(user.getIsOrgAdmin() || user.notAdmin(),ProjectEarlyWarning::getBuildOrgCode,user.getEmpPosUnitCode()); projectEarlyWarningService.page(overPage,overWrapper); LambdaQueryWrapper adventWrapper = Wrappers.lambdaQuery(ProjectEarlyWarning.class) - .eq(ProjectEarlyWarning::getStatus, ProjectEarlyWarningStatusEnum.ADVENT_TIME.name()); + .eq(ProjectEarlyWarning::getStatus, ProjectEarlyWarningStatusEnum.ADVENT_TIME.name()) + .eq(user.getRegionAdmin(),ProjectEarlyWarning::getAreaCode,user.getRegionCode()) + .eq(user.getIsOrgAdmin() || user.notAdmin(),ProjectEarlyWarning::getBuildOrgCode,user.getEmpPosUnitCode()); projectEarlyWarningService.page(adventPage,adventWrapper); LambdaQueryWrapper normalWrapper = Wrappers.lambdaQuery(ProjectEarlyWarning.class) - .eq(ProjectEarlyWarning::getStatus, ProjectEarlyWarningStatusEnum.NORMAL.name()); + .eq(ProjectEarlyWarning::getStatus, ProjectEarlyWarningStatusEnum.NORMAL.name()) + .eq(user.getRegionAdmin(),ProjectEarlyWarning::getAreaCode,user.getRegionCode()) + .eq(user.getIsOrgAdmin() || user.notAdmin(),ProjectEarlyWarning::getBuildOrgCode,user.getEmpPosUnitCode()); projectEarlyWarningService.page(normalPage,normalWrapper); WorkbenchVO.WarningStatistics cuurent = new WorkbenchVO.WarningStatistics(); @@ -162,6 +182,8 @@ public class WorkbenchManage { projectEarlyWarning.setCurrent(cuurent); List warningRecords = earlyWarningRecordsService.list(Wrappers.lambdaQuery(WflowEarlyWarningRecords.class) + .eq(user.getRegionAdmin(),WflowEarlyWarningRecords::getAreaCode,user.getRegionCode()) + .eq(user.getIsOrgAdmin() || user.notAdmin(),WflowEarlyWarningRecords::getBuildOrgCode,user.getEmpPosUnitCode()) .orderByDesc(WflowEarlyWarningRecords::getWarningTime)); Set projectCodeSet = Sets.newHashSet(); Map warningMap = warningRecords.stream() @@ -183,6 +205,7 @@ public class WorkbenchManage { vo.setBatchEmployees(record.getBatchEmployees()); vo.setRecordId(record.getId()); } + vo.setProjectName(projectNameMap.get(o.getProjectCode())); return vo; }).collect(Collectors.toList()); projectEarlyWarning.setOvers(PageVo.of(overVos,overPage.getTotal())); @@ -205,6 +228,7 @@ public class WorkbenchManage { vo.setBatchEmployees(record.getBatchEmployees()); vo.setRecordId(record.getId()); } + vo.setProjectName(projectNameMap.get(o.getProjectCode())); return vo; }).collect(Collectors.toList()); projectEarlyWarning.setAdvents(PageVo.of(adventVos,adventPage.getTotal())); @@ -227,6 +251,7 @@ public class WorkbenchManage { vo.setBatchEmployees(record.getBatchEmployees()); vo.setRecordId(record.getId()); } + vo.setProjectName(projectNameMap.get(o.getProjectCode())); return vo; }).collect(Collectors.toList()); projectEarlyWarning.setNormals(PageVo.of(normalVos,normalPage.getTotal()));