云
2 天以前 657698fd2fb32794932474648dbaee9e284e38c8
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pd/project/MesPdProjectServiceImpl.java
@@ -219,6 +219,18 @@
            throw exception(PD_PROJECT_AUDIT_NOT_FINISHED);
        }
        // 3. 创建 BPM 流程实例
        // 全局免审批:业务校验通过后直接执行审批通过逻辑,无需流程模型。
        if (processInstanceApi.isGlobalAutoApprove()) {
            projectMapper.updateById(MesPdProjectDO.builder()
                    .id(id)
                    .status(MesPdProjectStatusEnum.APPROVING.getStatus())
                    .processInstanceId("")
                    .processDefinitionKey("")
                    .build());
            updateProjectAuditStatus(id, cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceStatusEnum.APPROVE.getStatus());
            return;
        }
        String processInstanceId = processInstanceApi.createProcessInstance(getLoginUserId(),
                new BpmProcessInstanceCreateReqDTO()
                        .setProcessDefinitionKey(processDefinitionKey)
@@ -306,6 +318,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. 批量查出所有待审核记录(auditStatus=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);