fei
2025-11-17 131cd265f4711691fe22ff50c44f523c65cd7022
ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/ArchiveRecordsController.java
@@ -1,17 +1,28 @@
package com.ruoyi.web.controller.archive;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.bean.BeanUtil;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.file.FileUploadUtils;
import com.ruoyi.common.utils.file.FileUtils;
import com.ruoyi.common.utils.poi.ExcelExp;
import com.ruoyi.common.utils.poi.ExcelUtilManySheetFour;
import com.ruoyi.common.utils.poi.ExcelUtilManySheetSecond;
import com.ruoyi.domain.ArchiveRecords;
import com.ruoyi.domain.vo.AnalysisResult;
import com.ruoyi.domain.DocumentMaterials;
import com.ruoyi.domain.vo.*;
import com.ruoyi.framework.config.ServerConfig;
import com.ruoyi.service.IArchiveRecordsService;
import com.ruoyi.service.IDocumentMaterialsService;
import com.ruoyi.service.impl.BarcodeService;
import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -39,9 +50,11 @@
{
    @Autowired
    private IArchiveRecordsService archiveRecordsService;
    @Autowired
    private BarcodeService barcodeService;
    @Autowired
    private IDocumentMaterialsService iDocumentMaterialsService;
    /**
     * 查询档案完成情况
     */
@@ -91,9 +104,17 @@
    @PreAuthorize("@ss.hasPermi('system:records:export')")
    @Log(title = "档案记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ArchiveRecords archiveRecords)
    public void export(HttpServletResponse response, ArchiveRecords archiveRecords, @RequestParam(value = "ids", required = false) Long[] ids)
    {
        List<ArchiveRecords> list = archiveRecordsService.selectArchiveRecordsList(archiveRecords);
        List<ArchiveRecords> list;
        System.out.println(ids);
        // 如果提供了ids参数,则根据ids导出指定记录
        if (ids != null && ids.length > 0) {
            list = archiveRecordsService.selectArchiveRecordsByIds(ids);
        } else {
            // 否则根据查询条件导出
            list = archiveRecordsService.selectArchiveRecordsList(archiveRecords);
        }
        ExcelUtil<ArchiveRecords> util = new ExcelUtil<ArchiveRecords>(ArchiveRecords.class);
        util.exportExcel(response, list, "档案记录数据");
    }
@@ -174,9 +195,100 @@
    @PreAuthorize("@ss.hasPermi('system:records:edit')")
    @Log(title = "修改状态", businessType = BusinessType.IMPORT)
    @GetMapping(value = "/updateStatusById/{id}")
    public AjaxResult updateStatusById(@PathVariable("id") String id)
    @GetMapping(value = "/updateStatusById/{status}/{id}")
    public AjaxResult updateStatusById(@PathVariable("status") String status,@PathVariable("id") String id)
    {
        return new AjaxResult(200, archiveRecordsService.updateArchiveById(Long.parseLong(id))+"");
        return new AjaxResult(200, archiveRecordsService.updateArchiveById(status, Long.parseLong(id))+"");
    }
    @PostMapping("/model")
    public void getExportModel(HttpServletResponse response){
        List<ArchiveRecordModelExp> list = Collections.singletonList(new ArchiveRecordModelExp());
        ExcelUtil<ArchiveRecordModelExp> util = new ExcelUtil<>(ArchiveRecordModelExp.class);
        util.exportExcel(response,list,"档案信息导入模板");
    }
    @PostMapping("/modelOther")
    public void getExportModelOther(HttpServletResponse response){
        List<ArchiveRecordModelOther> list = Collections.singletonList(new ArchiveRecordModelOther());
        ExcelUtil<ArchiveRecordModelOther> util = new ExcelUtil<>(ArchiveRecordModelOther.class);
        util.exportExcel(response,list,"档案信息导入模板");
    }
    @PreAuthorize("@ss.hasPermi('system:records:list')")
    @Log(title = "是否允许提交", businessType = BusinessType.IMPORT)
    @GetMapping(value = "/whether/{recordId}")
    public AjaxResult whether(@PathVariable("recordId") Long recordId)
    {
        return AjaxResult.success( archiveRecordsService.whether(recordId));
    }
    @PostMapping(value={"/recordFileList/{includeQrCode}/{selectedSignatures}/{selectedAnnotations}", "/recordFileList/{includeQrCode}", "/recordFileList/{includeQrCode}/{selectedSignatures}","/recordFileList/{includeQrCode}/{selectedAnnotations}"})
    //导出excle
    public void getSpecialArchiveInfo(HttpServletResponse response, @RequestParam("recordId")Long recordId, @PathVariable(name = "includeQrCode",required = false) boolean includeQrCode, @PathVariable(name = "selectedSignatures",required = false) int[] selectedSignatures, @PathVariable(name = "selectedAnnotations",required = false) int[] selectedAnnotations) throws IOException {
        System.out.println("uuuuuuuuuuuuuuuuuuusssss88888888888888");
//        System.out.println(selectedSignatures[0]);
//        System.out.println(selectedAnnotations[0]);
        System.out.println(includeQrCode);
        //二维码是否生成
        String code = "2024050000029250";
        byte [] bt = barcodeService.generateBarcodeImage(code);
        //签名选择
        String [] sig = {"业务科室移交人:","审批科移交人:","档案整理公司:"};
        List<String> arrLis = new ArrayList<>();
        if(selectedSignatures!=null){
            for(int si: selectedSignatures)
            {
                arrLis.add(sig[si]);
            }
        }
        //注选择
        String [] ann = { "本清单由档案形成部门完成",
                "文件类型必须录入,包括结论材料、过程材料、申请材料,其他材料",
                "公开属性必须录入,主动公开、依申请公开、免予公开",
                "保管期限:30年或永久",
                "页号按照正式录入页码为准"};
        List<String> arrAn = new ArrayList<>();
        if(selectedAnnotations!=null) {
            for (int ar : selectedAnnotations) {
                arrAn.add(ann[ar]);
            }
        }
        List<DocumentMaterialsFileList> arsi = new ArrayList<>();
//        DocumentMaterials documentMaterials = new DocumentMaterials();
//        documentMaterials.setRecordId(recordId);
        List<DocumentMaterialsFileList> lst = iDocumentMaterialsService.selectDocumentMaterialsFileList(recordId);
        // 复制属性到SmallObject列表
        for (DocumentMaterialsFileList bigObject : lst) {
            DocumentMaterialsFileList smallObject = new DocumentMaterialsFileList();
            BeanUtil.copyProperties(bigObject, smallObject); // 复制属性
            arsi.add(smallObject);
        }
      //  arsi.add(aIV);
        ExcelExp e3 = new ExcelExp("文件材料移交目录清单",arsi, DocumentMaterialsFileList.class);
       // ExcelExp e4 = new ExcelExp("案卷封面",  arsi, recordId1, imgr1,sedcode, ArchiveInfoVo.class);
        List<ExcelExp> mysheet1 = new ArrayList<ExcelExp>();
        mysheet1.add(e3);
       // mysheet1.add(e4);
        //ByteOutputStream bos2 = new ByteOutputStream();
        ExcelUtilManySheetFour<List<ExcelExp>> util3 = new ExcelUtilManySheetFour<List<ExcelExp>>(mysheet1);
        //拿到caseTitle和inquiryNumber
        String inquiryNumber = "";
        String caseTitle = "";
        if(!arsi.isEmpty())
        {
            inquiryNumber = arsi.get(0).getInquiryNumber();
            caseTitle = arsi.get(0).getCaseTitle();
        }
        util3.exportExcelManySheet(response, mysheet1, includeQrCode,bt, arrLis, arrAn, inquiryNumber, caseTitle);
    }
}