fei
4 天以前 2f1ae9c10a1751438d09b3d848677deb883631aa
ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/ArchiveRecordsController.java
@@ -1,10 +1,10 @@
package com.ruoyi.web.controller.archive;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.bean.BeanUtil;
@@ -172,7 +172,64 @@
        System.out.println("090sdfsdf");
        return new AjaxResult(0, archiveRecordsService.updateStatusByIds(ids) + "");
    }
    /**
     *
     */
    @PreAuthorize("@ss.hasPermi('system:records:list')")
    @Log(title = "档案记录", businessType = BusinessType.UPDATE)
    @PostMapping(value = "/getAllFilesCounts")
    public AjaxResult getAllFileCounts(@RequestBody Long[] ids) {
// 1. 初始化Map,用于存储recordId和对应的文件数
        Map<Long, Integer> recordFileCountMap = new HashMap<>();
// 2. 获取基础上传路径
        String filePath = RuoYiConfig.getUploadPath();
// 3. 遍历每个recordId,计算文件数并放入Map
        for (Long recordId : ids) {
            // 拼接当前recordId的目录路径
            File desc = new File(filePath + File.separator + recordId);
            int fileCount = 0;
            try {
                // 判断目录是否存在且是目录
                if (desc.exists() && desc.isDirectory()) {
                    // 过滤出仅文件(排除子目录)
                    File[] files = desc.listFiles(new FileFilter() {
                        @Override
                        public boolean accept(File file) {
                            return file.isFile(); // 只统计文件,不统计目录
                        }
                    });
                    // 避免空指针(空目录时listFiles返回null)
                    if (files != null) {
                        fileCount = files.length;
                    }
                } else {
                    // 目录不存在/不是目录,文件数为0
                    fileCount = 0;
                    // 可选:日志提示
                    // log.warn("目录不存在或非目录:{}", desc.getAbsolutePath());
                }
            } catch (SecurityException e) {
                // 权限不足等异常,文件数置0
                fileCount = 0;
                // 可选:日志记录异常
                // log.error("获取目录[{}]文件数失败:{}", recordId, e.getMessage(), e);
            }
            // 4. 将recordId和对应的文件数放入Map
            recordFileCountMap.put(recordId, fileCount);
        }
        return new AjaxResult(200,"拿到所有对应的数据", recordFileCountMap);
    }
    /**
     * 删除档案记录
     */
@@ -193,9 +250,9 @@
    @PreAuthorize("@ss.hasPermi('system:records:edit')")
    @Log(title = "修改状态", businessType = BusinessType.IMPORT)
    @GetMapping(value = "/updateStatusById/{status}/{id}")
    public AjaxResult updateStatusById(@PathVariable("status") String status, @PathVariable("id") String id) {
        return new AjaxResult(200, archiveRecordsService.updateArchiveById(status, Long.parseLong(id)) + "");
    @GetMapping(value = "/updateStatusById/{status}/{id}/{operator}")
    public AjaxResult updateStatusById(@PathVariable("status") String status, @PathVariable("id") String id, @PathVariable("operator") String operator) {
        return new AjaxResult(200, archiveRecordsService.updateArchiveById(status, Long.parseLong(id), operator)+"");
    }
@@ -203,7 +260,7 @@
    public void getExportModel(HttpServletResponse response) {
        List<ArchiveRecordModelExp> list = Collections.singletonList(new ArchiveRecordModelExp());
        ExcelUtil<ArchiveRecordModelExp> util = new ExcelUtil<>(ArchiveRecordModelExp.class);
        util.exportExcel(response, list, "档案信息导入模板");
        util.exportExcel(response, list, "档案信息");
    }
@@ -211,7 +268,7 @@
    public void getExportModelOther(HttpServletResponse response) {
        List<ArchiveRecordModelOther> list = Collections.singletonList(new ArchiveRecordModelOther());
        ExcelUtil<ArchiveRecordModelOther> util = new ExcelUtil<>(ArchiveRecordModelOther.class);
        util.exportExcel(response, list, "档案信息导入模板");
        util.exportExcel(response, list, "档案信息");
    }
    @PreAuthorize("@ss.hasPermi('system:records:list')")
@@ -259,11 +316,19 @@
        List<DocumentMaterialsFileList> arsi = new ArrayList<>();
//        DocumentMaterials documentMaterials = new DocumentMaterials();
//        documentMaterials.setRecordId(recordId);
        List<DocumentMaterialsFileList> lst = iDocumentMaterialsService.selectDocumentMaterialsFileList(searSigAnn.getRecordId());
                ArchiveRecords archiveRecords = archiveRecordsService.selectArchiveRecordsById(searSigAnn.getRecordId());
        List<DocumentMaterialsVo> lst = iDocumentMaterialsService.findArchMInfo(searSigAnn.getRecordId().toString(), archiveRecords.getPageCount());
       // List<DocumentMaterialsFileList> lst =
        //拿到卷内目录的excel
//        List<DocumentMaterialsVoSmall> lst = dsvs.stream().map(res1 -> new DocumentMaterialsVoSmall(res1.getNum(), res1.getDocumentNumber(),res1.getCreator(),
//                res1.getTitle(), res1.getDate(), res1.getPageNumberFormatted(), res1.getRemarks())).collect(Collectors.toList());
        //iDocumentMaterialsService.selectDocumentMaterialsFileList(searSigAnn.getRecordId());
        // 复制属性到SmallObject列表
        for (DocumentMaterialsFileList bigObject : lst) {
        for (DocumentMaterialsVo bigObject : lst) {
            DocumentMaterialsFileList smallObject = new DocumentMaterialsFileList();
            BeanUtil.copyProperties(bigObject, smallObject); // 复制属性
            System.out.println(bigObject);