From f87ce86307056f63f79312178037cc8714eb2b13 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期二, 29 九月 2026 14:17:52 +0800
Subject: [PATCH] feat(docs): 添加档案管理模块业务流程文档

---
 yudao-module-research/src/main/java/cn/iocoder/yudao/module/research/service/application/ResearchApplicationServiceImpl.java |   60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 60 insertions(+), 0 deletions(-)

diff --git a/yudao-module-research/src/main/java/cn/iocoder/yudao/module/research/service/application/ResearchApplicationServiceImpl.java b/yudao-module-research/src/main/java/cn/iocoder/yudao/module/research/service/application/ResearchApplicationServiceImpl.java
index 655f24a..827d337 100644
--- a/yudao-module-research/src/main/java/cn/iocoder/yudao/module/research/service/application/ResearchApplicationServiceImpl.java
+++ b/yudao-module-research/src/main/java/cn/iocoder/yudao/module/research/service/application/ResearchApplicationServiceImpl.java
@@ -7,6 +7,9 @@
 import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+import cn.iocoder.yudao.module.archive.api.document.ArchiveDocumentApi;
+import cn.iocoder.yudao.module.archive.api.document.dto.ArchiveDocumentCreateReqDTO;
+import cn.iocoder.yudao.module.archive.api.document.dto.ArchiveDocumentRespDTO;
 import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi;
 import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO;
 import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmCategoryDO;
@@ -24,6 +27,7 @@
 import cn.iocoder.yudao.module.research.enums.ResearchGuidelineStatusEnum;
 import cn.iocoder.yudao.module.research.service.guideline.ResearchGuidelineService;
 import cn.iocoder.yudao.module.system.api.storage.StorageAttachmentApi;
+import cn.iocoder.yudao.module.system.api.storage.dto.StorageBlobRespDTO;
 import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticeSaveReqVO;
 import cn.iocoder.yudao.module.system.dal.dataobject.notice.NoticeDO;
 import cn.iocoder.yudao.module.system.service.notice.NoticeService;
@@ -40,6 +44,7 @@
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
+import java.util.stream.Collectors;
 
 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
 import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@@ -54,6 +59,15 @@
     private static final String APPLICATION_APPROVE_CATEGORY_CODE = "research_topic_approve";
     public static final String APPLICATION_RECORD_TYPE = "research_application";
 
+    /** 褰掓。鏉ユ簮绫诲瀷锛�2-璇鹃锛堝搴� archive 妯″潡 source_type锛� */
+    private static final Integer ARCHIVE_SOURCE_TYPE_RESEARCH = 2;
+
+    /** 褰掓。瀵嗙骇锛�2-鍐呴儴 */
+    private static final Integer ARCHIVE_SECRET_LEVEL_INTERNAL = 2;
+
+    /** 璇鹃妗f鍒嗙被缂栫爜锛堝搴� archive_category.code锛� */
+    private static final String ARCHIVE_CATEGORY_CODE_RESEARCH = "research";
+
     /** 绔嬮」閫氱煡浣跨敤銆屽叕鍛娿�嶇被鍨嬶紙system_notice_type: 1-閫氱煡 2-鍏憡锛� */
     private static final Integer NOTICE_TYPE_ANNOUNCEMENT = 2;
 
@@ -62,6 +76,9 @@
 
     @Resource
     private ResearchApplicationMapper applicationMapper;
+
+    @Resource
+    private ArchiveDocumentApi archiveDocumentApi;
 
     @Resource
     private ResearchNoRedisDAO noRedisDAO;
@@ -275,6 +292,42 @@
 
     @Override
     @Transactional(rollbackFor = Exception.class)
+    public String archiveApplication(Long id) {
+        // 1.1 鏍¢獙瀛樺湪
+        ResearchApplicationDO application = validateApplicationExists(id);
+        // 1.2 鍙湁銆屽凡绔嬮」銆嶇殑璇鹃鎵嶈兘褰掓。
+        if (!ResearchApplicationStatusEnum.APPROVED.getStatus().equals(application.getStatus())) {
+            throw exception(APPLICATION_ARCHIVE_FAIL_STATUS,
+                    application.getNo(), ResearchApplicationStatusEnum.nameOf(application.getStatus()));
+        }
+        // 1.3 閲嶅褰掓。鏍¢獙
+        if (application.getArchiveDocumentId() != null) {
+            throw exception(APPLICATION_ALREADY_ARCHIVED, application.getNo(),
+                    StrUtil.blankToDefault(archiveNo(id), "鏈煡"));
+        }
+
+        // 2. 甯﹀叆鐢虫姤涔﹂檮浠讹紝鎸夋潵婧愬崟鎹綊妗o紙鏉ユ簮鍗曞彿鍙栫珛椤圭紪鍙凤紝鏈敓鎴愭椂鍥為��鐢虫姤缂栧彿锛�
+        String sourceNo = StrUtil.blankToDefault(application.getResearchNo(), application.getNo());
+        List<Long> blobIds = storageAttachmentApi.listAttachments(APPLICATION_RECORD_TYPE, id).stream()
+                .map(StorageBlobRespDTO::getId).collect(Collectors.toList());
+        Long archiveDocumentId = archiveDocumentApi.archiveBySource(new ArchiveDocumentCreateReqDTO()
+                .setSourceType(ARCHIVE_SOURCE_TYPE_RESEARCH)
+                .setSourceId(id)
+                .setSourceNo(sourceNo)
+                .setSourceTitle(application.getTitle())
+                .setCategoryCode(ARCHIVE_CATEGORY_CODE_RESEARCH)
+                .setSecretLevel(ARCHIVE_SECRET_LEVEL_INTERNAL)
+                .setSummary("璇鹃鐢虫姤涔﹀綊妗�")
+                .setBlobIds(blobIds)).getCheckedData();
+
+        // 3. 鍥炲啓褰掓。妗f ID锛堜綔涓哄凡褰掓。纭爣璁帮級
+        applicationMapper.updateById(new ResearchApplicationDO()
+                .setId(id).setArchiveDocumentId(archiveDocumentId));
+        return StrUtil.blankToDefault(archiveNo(id), "鏈煡");
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
     public void updateReviewSummary(Long id, BigDecimal reviewAvgScore, Integer reviewPass) {
         // 鐢� UpdateWrapper 鏄惧紡 set锛屼繚璇併�岃瘎瀹℃槑缁嗚鍒犵┖銆嶆椂鑳芥妸姹囨�诲�兼竻鎴� null
         applicationMapper.update(null, new LambdaUpdateWrapper<ResearchApplicationDO>()
@@ -293,6 +346,13 @@
         return application;
     }
 
+    /** 鏌ヨ鏉ユ簮鍗曟嵁宸茬敓鎴愮殑妗f缂栧彿锛堟湭褰掓。鏃惰繑鍥� null锛� */
+    private String archiveNo(Long applicationId) {
+        ArchiveDocumentRespDTO archive = archiveDocumentApi
+                .getBySource(ARCHIVE_SOURCE_TYPE_RESEARCH, applicationId).getCheckedData();
+        return archive != null ? archive.getNo() : null;
+    }
+
     /** 淇濆瓨锛堣崏绋匡級闃舵鏍¢獙鎸囧崡锛氬繀椤诲瓨鍦ㄤ笖宸插彂甯� */
     private ResearchGuidelineDO validateGuidelineForSave(Long guidelineId) {
         ResearchGuidelineDO guideline = guidelineService.getGuideline(guidelineId);

--
Gitblit v1.9.3