From 5de51c107d3dd967289bec6ea129fd1834494198 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Fri, 22 Nov 2024 17:42:17 +0800 Subject: [PATCH] =?UTF-8?q?feat:=201.=20=E5=90=88=E8=A7=84=E6=80=A7?= =?UTF-8?q?=E5=AE=A1=E6=9F=A5=E9=80=9A=E8=BF=87=E4=BF=AE=E6=94=B9=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manage/DeclaredProjectManage.java | 28 +++++++++++----------- .../manage/ProjectReviewManage.java | 2 ++ .../service/IProjectStatusChangeService.java | 15 ++++++++---- 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/DeclaredProjectManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/DeclaredProjectManage.java index cb6c838..3b28581 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/DeclaredProjectManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/DeclaredProjectManage.java @@ -42,6 +42,7 @@ import com.hz.pm.api.projectlib.model.enumeration.status.ProjectStatus; import com.hz.pm.api.projectlib.model.req.ProjectListReq; import com.hz.pm.api.projectlib.model.vo.ProjectLibListItemVO; import com.hz.pm.api.projectlib.service.IProjectService; +import com.hz.pm.api.projectlib.service.IProjectStatusChangeService; import com.hz.pm.api.staging.enums.MsgTypeEnum; import com.hz.pm.api.sys.manage.NoticeManage; import com.hz.pm.api.sys.manage.ProcessModelManage; @@ -74,6 +75,8 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.function.BiConsumer; import java.util.stream.Collectors; +import static com.hz.pm.api.common.statemachine.event.ProjectStateChangeEvent.COMPLIANCE_REVIEW_PASS; + /** *

* DeclaredProjectManage @@ -96,6 +99,7 @@ public class DeclaredProjectManage { private final NoticeManage noticeManage; private final UserInfoHelper userInfoHelper; private final MhUnitCache mhUnitCache; + private final IProjectStatusChangeService projectStatusChangeService; /** * 新项目 启动实例 @@ -374,23 +378,19 @@ public class DeclaredProjectManage { query.ne(Project::getStage, ProjectStatus.STOPPED.getCode()) .ne(Project::getStatus, ProjectStatus.CHANGE_APPLY_PASSED.getCode()) .eq(Project::getNewest, Boolean.TRUE) - .select(Project::getStatus, Project::getId); + .select(Project::getStatus, Project::getProjectCode, Project::getStage); List projects = projectService.list(query); - Map countMap = CollUtils.groupCount(projects, w -> { - if (!ProjectStatus.TO_BE_DECLARED.eq(w.getStatus()) - && !ProjectStatus.COMPLIANCE_REVIEW_FAILED.eq(w.getStatus()) - && !ProjectStatus.ON_COMPLIANCE_REVIEW.eq(w.getStatus()) - && !ProjectStatus.CHANGE.eq(w.getStage())) { - return ProjectStatus.COMPLIANCE_REVIEW_PASSED; - } - return ProjectStatus.getNoNull(w.getStatus()); - }); + Map countMap = CollUtils.groupCount(projects, + w -> ProjectStatus.getNoNull(w.getStatus())); DeclaredProgressStatisticsVO stat = new DeclaredProgressStatisticsVO(); stat.setTotalCount(projects.size()); stat.setTodoCount(countMap.getOrDefault(ProjectStatus.TO_BE_DECLARED, 0L)); stat.setAuditCount(countMap.getOrDefault(ProjectStatus.ON_COMPLIANCE_REVIEW, 0L)); stat.setFailedCount(countMap.getOrDefault(ProjectStatus.COMPLIANCE_REVIEW_FAILED, 0L)); - stat.setPassedCount(countMap.getOrDefault(ProjectStatus.COMPLIANCE_REVIEW_PASSED, 0L)); + if (!projects.isEmpty()) { + List projectCodes = CollUtils.fieldList(projects, Project::getProjectCode); + stat.setPassedCount(projectStatusChangeService.count(projectCodes, COMPLIANCE_REVIEW_PASS)); + } return stat; } @@ -413,7 +413,7 @@ public class DeclaredProjectManage { if (status != null) { if (ProjectStatus.COMPLIANCE_REVIEW_PASSED.eq(status)) { query.exists(ExistsSqlConst.PROJECT_EXISTS_STATUS_CHANGE + - " and npsc.event = {0}", ProjectStateChangeEvent.COMPLIANCE_REVIEW_PASS); + " and npsc.event = {0}", COMPLIANCE_REVIEW_PASS); } else { query.eq(Project::getStatus, status); } @@ -429,8 +429,8 @@ public class DeclaredProjectManage { ProjectLibListItemVO item = BeanUtil.copyProperties(w, ProjectLibListItemVO.class); item.setDeclaredAmount(w.getDeclareAmount()); if (!ProjectStatus.TO_BE_DECLARED.eq(w.getStatus()) - && ProjectStatus.COMPLIANCE_REVIEW_FAILED.eq(w.getStatus()) - && ProjectStatus.ON_COMPLIANCE_REVIEW.eq(w.getStatus()) + && !ProjectStatus.COMPLIANCE_REVIEW_FAILED.eq(w.getStatus()) + && !ProjectStatus.ON_COMPLIANCE_REVIEW.eq(w.getStatus()) && !ProjectStatus.CHANGE.eq(w.getStage())) { item.setStatus(ProjectStatus.COMPLIANCE_REVIEW_PASSED.getCode()); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ProjectReviewManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ProjectReviewManage.java index 905d814..e5ac1fb 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ProjectReviewManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ProjectReviewManage.java @@ -287,6 +287,8 @@ public class ProjectReviewManage { } else if (ProjectStatus.EXPERT_REVIEW_FAILED.eq(status)) { query.in(Project::getStatus, ProjectStatus.EXPERT_REVIEW_FAILED.getCode(), ProjectStatus.EXPERT_REVIEW_AFTER_MODIFY.getCode()); + } else { + query.eq(Project::getStatus, status); } } else { query.exists(ExistsSqlConst.PROJECT_EXISTS_STATUS_CHANGE + diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/service/IProjectStatusChangeService.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/service/IProjectStatusChangeService.java index 8467ed9..5d13565 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/service/IProjectStatusChangeService.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/service/IProjectStatusChangeService.java @@ -1,7 +1,9 @@ package com.hz.pm.api.projectlib.service; +import cn.hutool.core.map.MapUtil; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.IService; import com.hz.pm.api.common.model.constant.BizConst; @@ -10,10 +12,7 @@ import com.hz.pm.api.common.util.BizUtils; import com.hz.pm.api.projectlib.model.entity.ProjectStatusChange; import com.ningdatech.basic.util.CollUtils; -import java.util.Collection; -import java.util.Comparator; -import java.util.List; -import java.util.Map; +import java.util.*; /** *

@@ -89,4 +88,12 @@ public interface IProjectStatusChangeService extends IService projectCodes, ProjectStateChangeEvent event) { + QueryWrapper query = Wrappers.query(); + query.select("count(distinct project_code) cnt") + .in("project_code", projectCodes) + .eq("event", event); + return MapUtil.getLong(getMap(query), "cnt"); + } + }