From 1f7c36424e8f48a5917ac6c77e2e47979c469a28 Mon Sep 17 00:00:00 2001
From: liu <2021943741@qq.com>
Date: 星期三, 26 八月 2026 09:00:14 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_business' into dev_business

---
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pd/project/MesPdProjectServiceImpl.java |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pd/project/MesPdProjectServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pd/project/MesPdProjectServiceImpl.java
index 2eacc3f..bb57d2b 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pd/project/MesPdProjectServiceImpl.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pd/project/MesPdProjectServiceImpl.java
@@ -306,6 +306,32 @@
         return projectMapper.selectList(new QueryWrapper<MesPdProjectDO>().lambda().eq(MesPdProjectDO::getProductCode,productCode).eq(MesPdProjectDO::getStatus, MesPdProjectStatusEnum.ARCHIVE.getStatus()));
     }
 
+    @Override
+    public Map<Long, Integer> getPendingAuditCountMap(Collection<Long> projectIds) {
+        if (CollUtil.isEmpty(projectIds)) {
+            return Collections.emptyMap();
+        }
+        // 1. 鎵归噺鏌ュ嚭杩欎簺椤圭洰涓嬬殑鎵�鏈夎祫鏂�
+        List<MesPdDocumentDO> documents = documentService.getDocumentListByProjectIds(projectIds);
+        if (CollUtil.isEmpty(documents)) {
+            return Collections.emptyMap();
+        }
+        // 2. 璧勬枡ID -> 椤圭洰ID
+        Map<Long, Long> documentProjectIdMap = convertMap(documents, MesPdDocumentDO::getId, MesPdDocumentDO::getProjectId);
+        // 3. 鎵归噺鏌ュ嚭鎵�鏈夊緟瀹℃牳璁板綍锛坅uditStatus=0锛�
+        List<MesPdDocumentAuditDO> pendingAudits =
+                documentAuditMapper.selectPendingAuditListByDocumentIds(documentProjectIdMap.keySet());
+        // 4. 鎸夐」鐩粺璁″緟瀹℃牳鏂囦欢鏁�
+        Map<Long, Integer> result = new HashMap<>();
+        for (MesPdDocumentAuditDO audit : pendingAudits) {
+            Long projectId = documentProjectIdMap.get(audit.getDocumentId());
+            if (projectId != null) {
+                result.merge(projectId, 1, Integer::sum);
+            }
+        }
+        return result;
+    }
+
     private void validateProjectInitiate(MesPdProjectDO project) {
         if (!MesPdProjectStatusEnum.INITIATE.getStatus().equals(project.getStatus())) {
             throw exception(PD_PROJECT_NOT_INITIATE);

--
Gitblit v1.9.3