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 |   69 ++++++++++++++--------------------
 1 files changed, 29 insertions(+), 40 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 6648c60..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
@@ -7,8 +7,7 @@
 import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmCategoryDO;
 import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionInfoDO;
 import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskStatusEnum;
-import cn.iocoder.yudao.module.bpm.service.definition.BpmCategoryService;
-import cn.iocoder.yudao.module.bpm.service.definition.BpmProcessDefinitionService;
+import cn.iocoder.yudao.module.mes.service.common.bpm.MesBpmProcessService;
 import cn.iocoder.yudao.module.mes.controller.admin.pd.project.vo.MesPdProjectPageReqVO;
 import cn.iocoder.yudao.module.mes.controller.admin.pd.project.vo.MesPdProjectSaveReqVO;
 import cn.iocoder.yudao.module.mes.dal.dataobject.pd.document.MesPdDocumentDO;
@@ -80,10 +79,7 @@
     private BpmProcessInstanceApi processInstanceApi;
 
     @Resource
-    private BpmCategoryService bpmCategoryService;
-
-    @Resource
-    private BpmProcessDefinitionService bpmProcessDefinitionService;
+    private MesBpmProcessService mesBpmProcessService;
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -238,40 +234,7 @@
 
     @Override
     public List<Map<String, Object>> getProjectApproveProcessDefinitionList() {
-        // 1. 鏍¢獙鍒嗙被鏄惁瀛樺湪
-        List<BpmCategoryDO> categories = bpmCategoryService.getCategoryListByCode(
-                Collections.singletonList(BPM_PROCESS_DEFINITION_CATEGORY_CODE));
-        if (CollUtil.isEmpty(categories)) {
-            throw exception(PD_PROJECT_BPM_CATEGORY_NOT_EXISTS);
-        }
-        // 2. 鑾峰彇鍒嗙被涓嬬殑娴佺▼瀹氫箟淇℃伅
-        List<BpmProcessDefinitionInfoDO> definitionInfoList = bpmProcessDefinitionService
-                .getProcessDefinitionInfoListByCategory(BPM_PROCESS_DEFINITION_CATEGORY_CODE);
-        if (CollUtil.isEmpty(definitionInfoList)) {
-            return Collections.emptyList();
-        }
-        // 3. 杩囨护婵�娲荤姸鎬侊紝淇濈暀鏈�鏂扮増鏈�
-        Map<String, ProcessDefinition> latestVersionMap = new HashMap<>();
-        for (BpmProcessDefinitionInfoDO info : definitionInfoList) {
-            ProcessDefinition pd = bpmProcessDefinitionService.getProcessDefinition(info.getProcessDefinitionId());
-            if (pd == null || pd.isSuspended()) {
-                continue;
-            }
-            ProcessDefinition existing = latestVersionMap.get(pd.getKey());
-            if (existing == null || pd.getVersion() > existing.getVersion()) {
-                latestVersionMap.put(pd.getKey(), pd);
-            }
-        }
-        // 4. 杩斿洖娴佺▼瀹氫箟鍒楄〃
-        List<Map<String, Object>> result = new ArrayList<>();
-        for (ProcessDefinition pd : latestVersionMap.values()) {
-            Map<String, Object> item = new HashMap<>();
-            item.put("id", pd.getId());
-            item.put("key", pd.getKey());
-            item.put("name", pd.getName());
-            result.add(item);
-        }
-        return result;
+        return mesBpmProcessService.getApproveProcessDefinitionList(BPM_PROCESS_DEFINITION_CATEGORY_CODE);
     }
 
     @Override
@@ -343,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