fei
10 小时以前 359f1d48b1d859a23cd35a425d2cffb1e9d1c811
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
package com.ruoyi.web.controller.archive;
 
 
 
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.LocalDate;
import java.util.*;
import java.util.List;
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletResponse;
 
import com.aspose.words.License;
import com.deepoove.poi.XWPFTemplate;
import com.drew.imaging.ImageMetadataReader;
import com.drew.metadata.Metadata;
import com.drew.metadata.exif.ExifIFD0Directory;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.StringUtils;
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.ExcelUtilManySheet;
import com.ruoyi.common.utils.poi.ExcelUtilManySheetSecond;
import com.ruoyi.domain.ArchiveCategory;
import com.ruoyi.domain.ArchiveProjectName;
import com.ruoyi.domain.ArchiveRecords;
import com.ruoyi.domain.DocumentMaterials;
import com.ruoyi.domain.vo.*;
import com.ruoyi.framework.config.ServerConfig;
import com.ruoyi.framework.web.domain.server.Sys;
import com.ruoyi.service.IArchiveProjectNameService;
import com.ruoyi.service.IArchiveRecordsService;
import com.ruoyi.service.IDocumentMaterialsService;
import com.ruoyi.service.impl.BarcodeService;
import com.ruoyi.service.impl.pdfGenerateService;
import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream;
import com.sun.xml.internal.ws.api.addressing.WSEndpointReference;
import org.apache.commons.imaging.ImageInfo;
import org.apache.commons.imaging.Imaging;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
 
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;
 
import static com.ruoyi.common.core.page.TableSupport.PAGE_NUM;
import static com.ruoyi.common.core.page.TableSupport.PAGE_SIZE;
 
/**
 * 【文件材料综合信息】Controller
 *
 * @author ruoyi
 * @date 2025-07-28
 */
@RestController
@RequestMapping("/system/materials")
public class DocumentMaterialsController extends BaseController
{
    @Autowired
    private IArchiveProjectNameService iArchiveProjectNameService;
    @Autowired
    private BarcodeService barcodeService;
    @Autowired
    private ServerConfig serverConfig;
    @Autowired
    private pdfGenerateService pdfGenerateService;
    @Autowired
    private IDocumentMaterialsService documentMaterialsService;
 
    @Autowired
    private IArchiveRecordsService iArchiveRecordsService;
    /**
     * 判断PageNumber是否连续
     */
    @PreAuthorize("@ss.hasPermi('system:materials:list')")
    @GetMapping("/isPageNubLegal/{recordId}")
    public AjaxResult judgePageLegal(@PathVariable("recordId") Integer recordId)
    {
 
        boolean res = documentMaterialsService.isPageNumberIslegal(recordId);
        int cnt = documentMaterialsService.getFileCount(recordId);
        HashMap<String, Object> data = new HashMap<>();
        data.put("res",res);
        data.put("total",cnt);
        return AjaxResult.success(data);
    }
    /**
     * 拿到对应的案卷材料个数
     */
    @PreAuthorize("@ss.hasPermi('system:materials:list')")
    @GetMapping("/getFileCount/{recordId}")
    public AjaxResult getFileCount(@PathVariable("recordId") Integer recordId)
    {
 
        int cnt = documentMaterialsService.getFileCount(recordId);
        return AjaxResult.success(cnt);
    }
 
    /**
     * 判断卷内目录是否上传了附件
     */
    @PreAuthorize("@ss.hasPermi('system:materials:list')")
    @GetMapping("/judge/{recordId}")
    public AjaxResult judge(@PathVariable("recordId") Integer recordId)
    {
 
        Boolean cnt = documentMaterialsService.judgeInfo(recordId);
        return AjaxResult.success(cnt);
    }
    
    /**
     * 根据页号添加中间记录的接口
     * 例如页号1,5,7,则添加页号为2,3,4(信息与1保持一致),6(信息与5保持一致)
     */
    @PreAuthorize("@ss.hasPermi('system:materials:edit')")
    @GetMapping("/addMiddleRecords/{recordId}/{maxPageNumber}")
    public AjaxResult addMiddleRecords(@PathVariable("recordId") Long recordId,@PathVariable("maxPageNumber")  Long maxPageNumber)
    {
        return documentMaterialsService.addMiddleRecordsByPageNumbers(recordId, maxPageNumber);
    }
    /**
     * 查询【文件材料综合信息】列表
     */
    @PreAuthorize("@ss.hasPermi('system:materials:list')")
    @GetMapping("/list")
    public AjaxResult list(DocumentMaterials documentMaterials)
    {
        Integer pageNum = Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1);
        Integer pageSize = Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10);
        return documentMaterialsService.selectDataList(documentMaterials, pageNum, pageSize);
    }
 
    /**
     * 导出【文件材料综合信息】列表
     */
    @PreAuthorize("@ss.hasPermi('system:materials:export')")
    @Log(title = "【文件材料综合信息】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DocumentMaterials documentMaterials, @RequestParam(value = "ids", required = false) Long[] ids)
    {
        List<DocumentMaterials> list;
        System.out.println(ids);
        // 如果提供了ids参数,则根据ids导出指定记录
        if (ids != null && ids.length > 0) {
            list = documentMaterialsService.selectDocumentMaterialsByIds(ids);
        } else {
            list = documentMaterialsService.selectDocumentMaterialsList(documentMaterials);
 
        }
        ExcelUtil<DocumentMaterials> util = new ExcelUtil<DocumentMaterials>(DocumentMaterials.class);
        util.exportExcel(response, list, "电子文件目录");
    }
 
    @PreAuthorize("@ss.hasPermi('system:materials:export')")
    @Log(title = "【导出卷内目录】", businessType = BusinessType.EXPORT)
    @PostMapping("/exportDir")
    public void exportDir(HttpServletResponse response, DocumentMaterials documentMaterials, @RequestParam(value = "ids", required = false) Long[] ids)
    {
        List<DocumentMaterials> list;
        System.out.println(ids);
        // 如果提供了ids参数,则根据ids导出指定记录
        if (ids != null && ids.length > 0) {
            list = documentMaterialsService.selectDocumentMaterialsByIds(ids);
        } else {
            list = documentMaterialsService.selectDocumentMaterialsList(documentMaterials);
 
        }
        // 根据visible字段筛选,只保留visible为1的记录
        List<DocumentMaterials> filteredList = list.stream()
                .filter(doc -> doc.getVisible() != null && doc.getVisible() == 1 && !Objects.equals(doc.getFileStyle(), "其他材料"))
                .collect(Collectors.toList());
        
        // 使用AtomicLong实现序号的递增
        AtomicLong nm = new AtomicLong(1L);
        // 将筛选后的DocumentMaterials转换为DocumentMaterialsVo
        List<DocumentMaterialsVoSmall> list1 = filteredList.stream().map(doc -> {
            DocumentMaterialsVoSmall vo = new DocumentMaterialsVoSmall();
            // 手动映射字段,使用getAndIncrement()方法获取当前值并递增
            vo.setNum(nm.getAndIncrement());
 
            vo.setDocumentNumber(doc.getDocumentNumber());
            vo.setCreator(doc.getCreator());
            vo.setTitle(doc.getTitle());
            vo.setDate(doc.getDate());
            vo.setPageNumber(doc.getPageNumber());
            vo.setRemarks(doc.getRemarks());
//            vo.setRecordId(doc.getRecordId() != null ? doc.getRecordId().toString() : null);
//            vo.setPublicity(doc.getPublicity());
            return vo;
        }).collect(Collectors.toList());
        
        ExcelUtil<DocumentMaterialsVoSmall> util = new ExcelUtil<DocumentMaterialsVoSmall>(DocumentMaterialsVoSmall.class);
        util.exportExcel(response, list1, "卷内目录");
    }
 
   // List<DocumentMaterialsVo> dsvs = documentMaterialsService.findArchMInfo(id.toString());
 
    /**
     * 获取【文件材料综合信息】详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:materials:query')")
    @GetMapping(value = "/{materialId}")
    public AjaxResult getInfo(@PathVariable("materialId") String materialId)
    {
        return success(documentMaterialsService.selectDocumentMaterialsByMaterialId(materialId));
    }
 
    /**
     * 新增【文件材料综合信息】
     */
    @PreAuthorize("@ss.hasPermi('system:materials:add')")
    @Log(title = "【文件材料综合信息】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DocumentMaterials documentMaterials)
    {
        documentMaterials.setVisible(1);
        int res = documentMaterialsService.insertDocumentMaterials(documentMaterials);
        System.out.println(res+"][[[[[[[[[[[[[[[[[[");
        return toAjax(res);
    }
 
    /**
     * 修改【文件材料综合信息】
     *
     * system:materials:edit
     */
    @PreAuthorize("@ss.hasPermi('system:materials:edit')")
    @Log(title = "【文件材料综合信息】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DocumentMaterials documentMaterials)
    {
        return toAjax(documentMaterialsService.updateDocumentMaterials(documentMaterials));
    }
 
    /**
     * 删除【文件材料综合信息】
     */
    @PreAuthorize("@ss.hasPermi('system:materials:remove')")
    @Log(title = "【文件材料综合信息】", businessType = BusinessType.DELETE)
    @DeleteMapping("/{materialIds}")
    public AjaxResult remove(@PathVariable String[] materialIds)
    {
        return toAjax(documentMaterialsService.deleteDocumentMaterialsByMaterialIds(materialIds));
    }
 
    public String getPageSize(double du)
    {
        if(du <= 8699840)
            return "A4";
        else if(du <= 17403188)
            return "A3";
        else if(du <= 34811347)
            return "A2";
        else if(du <= 69622674)
            return "A1";
        else
            return "A0";
    }
 
    @PostMapping("/upload/{recordId}")
    public AjaxResult uploadFile(MultipartFile file, @PathVariable Long recordId) throws Exception
    {
        // System.out.println("sdfd9999999999999999999999999999999");
        try
        {
            //根据文件名称,然后修改对应数据的url
            String fname = file.getOriginalFilename();
 
//            System.out.println(fname);
            // 上传文件路径
            String filePath = RuoYiConfig.getUploadPath();
//            System.out.println(filePath);
            // 上传并返回新文件名称
            String fileName = FileUploadUtils.upload(filePath, file);
            String url = serverConfig.getUrl() + fileName;
            AjaxResult ajax = AjaxResult.success();
            //分割文件名
            String [] nams = fname.split("\\.");
            System.out.println(fname);
            Long nam = Long.parseLong(nams[0]);
            //根据页号拿到案卷的详细信息
            System.out.println(recordId);
            System.out.println("0-------------");
 
            DocumentMaterials doc = documentMaterialsService.selectByPageNumber(nam, Math.toIntExact(recordId));
            if(doc==null)
                return AjaxResult.error("无对应页号,请检查清楚附件以及对应的输入!");
            else{
                if(doc.getSecurityLevel()!=null&&doc.getSecurityLevel().equals("该页另存"))
                {
 
                    //替换为了准备好的图像
                    //读取服务器上的图像
                 //   new InputStream();
                    String fp = filePath + "\\glc.jpg";
                    Path path = Paths.get(fp);
                    File fil = new File(fp);
                    //拿到图像属性
                    BufferedImage bufferedImage =   ImageIO.read(Files.newInputStream(path));
                    int wid = bufferedImage.getWidth();
                    int hei = bufferedImage.getHeight();
                    double sz =  Double.parseDouble(String.format("%.2f", Files.size(path)*1.0/1024));
                    System.out.println("ddsdsdsd");
                    System.out.println(wid+":"+hei+":"+sz);
 
                    //拿到图像的dpi信息
 
                    ImageInfo info = Imaging.getImageInfo(Files.readAllBytes(path));
 
 
                    int wdpi = info.getPhysicalWidthDpi() ;
                    int hdpi = info.getPhysicalHeightDpi();
                    System.out.println("DPI: " + info.getPhysicalWidthDpi());
                    //计算fileNumber
                    Long fileNumber = documentMaterialsService.getFiNum(nam,recordId);
                    //计算sizeType
                    String sizeType = getPageSize(wid*hei);
 
 
                    Graphics2D g2d = bufferedImage.createGraphics(); // 获取Graphics2D对象用于绘制
                    g2d.setFont(new Font("Arial", Font.BOLD, 80)); // 设置字体样式和大小
                    g2d.setColor(Color.black); // 设置字体颜色为白色,可根据需要调整颜色和字体样式
                    String pageNumber =      doc.getPageNumber()+""; // 页码字符串,可以根据需要修改或动态生成
                    int fontHeight = g2d.getFontMetrics().getHeight(); // 获取字体高度,用于定位文本位置
                    int x = bufferedImage.getWidth() - g2d.getFontMetrics().stringWidth(pageNumber) - 80; // 计算文本X坐标位置,确保在右下角附近
                    int y = bufferedImage.getHeight() - fontHeight / 2 - 100; // 计算文本Y坐标位置,垂直居中显示文本
                    g2d.drawString(pageNumber, x, y); // 在图片上绘制页码文本
 
 
                    System.out.println(pageNumber+"[[[[[[[[[[[[[[[");
                    g2d.dispose(); // 释放Graphics2D资源
//                    File outputFile = new File(filePath+"/output_image.jpg"); // 输出文件路径
//                    ImageIO.write(bufferedImage, "jpg", outputFile); // 保
                    //得到BufferedImage对象
                    MultipartFile multipartFile = null;
                    try {
                        //创建一个ByteArrayOutputStream
                        ByteArrayOutputStream os = new ByteArrayOutputStream();
                        //把BufferedImage写入ByteArrayOutputStream
                        ImageIO.write(bufferedImage, "jpg", os);
                        //ByteArrayOutputStream转成InputStream
                        InputStream input = new ByteArrayInputStream(os.toByteArray());
                        //InputStream转成MultipartFile
                        multipartFile = new MockMultipartFile(pageNumber, pageNumber+".jpg", "text/plain", input);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
 
                    // 上传并返回新文件名称
                    String fileName1 = FileUploadUtils.upload(filePath, multipartFile);
                    String url1 = serverConfig.getUrl() + fileName;
 
 
                    String us = "/profile/upload/0071.jpg";
                    documentMaterialsService.updateByPageNumber(nam, sizeType, fileNumber,wid, hei,wdpi, hdpi,  sz, fileName1, "jpg", recordId);
 
 
                }
                else
                {
                    //文件名称
                    String pname = nams[1];
                    ajax.put("url", url);
                    //拿到图像属性
                    BufferedImage bufferedImage = ImageIO.read(file.getInputStream());
                    int wid = bufferedImage.getWidth();
                    int hei = bufferedImage.getHeight();
                    double sz =  Double.parseDouble(String.format("%.2f", file.getSize()*1.0/1024));
                    System.out.println(wid+":"+hei+":"+sz);
                    //拿到图像的dpi信息
 
                    ImageInfo info = Imaging.getImageInfo(file.getBytes());
 
 
                    int wdpi = info.getPhysicalWidthDpi() ;
                    int hdpi = info.getPhysicalHeightDpi();
                    System.out.println("DPI: " + info.getPhysicalWidthDpi()+nam+"dds");
                    //计算fileNumber
                    Long fileNumber = documentMaterialsService.getFiNum(nam, recordId);
                    //计算sizeType
                    String sizeType = getPageSize(wid*hei);
                    //插入数据库对应的url当中
                    documentMaterialsService.updateByPageNumber(nam, sizeType, fileNumber,wid, hei,wdpi, hdpi,  sz, fileName, pname, recordId);
//
                }
            }
           System.out.println(url);
//            System.out.println(fileName);
            ajax.put("fileName", fileName);
//            System.out.println(FileUtils.getName(fileName));
            ajax.put("newFileName", FileUtils.getName(fileName));
            ajax.put("originalFilename", file.getOriginalFilename());
            return ajax;
        }
        catch (Exception e)
        {
            System.out.println("88888888882222222222222");
            System.out.println(e);
            return AjaxResult.error(e.getMessage());
        }
    }
 
 
    @Log(title = "档案详细信息记录导入", businessType = BusinessType.IMPORT)
    @PostMapping("/importData")
    public AjaxResult importData(@RequestParam("file") MultipartFile file, @RequestParam("recordId")String recordId) throws Exception
    {
        System.out.println(file);
        return documentMaterialsService.importExcel(file, recordId);
    }
 
    @PostMapping("/model")
    public void getExportModel(HttpServletResponse response){
        List<DocumentMaterialFileSmallVo> list = Collections.singletonList(new DocumentMaterialFileSmallVo());
        ExcelUtil<DocumentMaterialFileSmallVo> util = new ExcelUtil<>(DocumentMaterialFileSmallVo.class);
        util.exportExcel(response,list,"档案详细信息导入模板");
    }
    public  boolean getLicense() {
        boolean result = false;
        try {
            InputStream is = null;
 
            ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
            org.springframework.core.io.Resource[] resources = resolver.getResources("classpath:words.xml");
            is = resources[0].getInputStream();
            // ��Ŀ��lincense.xml��·��
            License aposeLic = new License();
            aposeLic.setLicense(is);
            result = true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }
    //导出备考表
    @PostMapping("/exportBack/{id}/{recordId}")
    public void exportBackInfo(HttpServletResponse response, @PathVariable Long id, @PathVariable String recordId)
    {
        //09-备考表.pdf
        String pdf09Path = "09-备考表.pdf";
 
        //根据项目名称拿到公司名称和项目负责人
 
        String compName = "广州盈家档案管理有限公司";
        String li_person = "仇翀";
        String sh_person = "曾瑞莹";
        ArchiveRecords archiveRecords = iArchiveRecordsService.selectArchiveRecordsById(id);
        ArchiveProjectName tmp = new ArchiveProjectName();
        tmp.setName(archiveRecords.getProjectName());
        List<ArchiveProjectName> projectName = iArchiveProjectNameService.selectArchiveProjectNameList(tmp);
        if(!projectName.isEmpty())
        {
            if(StringUtils.isEmpty(projectName.get(0).getCompanyName()))
                compName = projectName.get(0).getCompanyName();
            if(StringUtils.isEmpty(projectName.get(0).getCreatePerson()))
                li_person = projectName.get(0).getCreatePerson();
        }
        //  pdfGenerateService.generateFileStyleInfo(pdf09Path, aIV.getRecordId(), id);
        //拿到相关数据
        List<DocumentMaterialFileStyle> dmfs = documentMaterialsService.findFileStyleInfo(Math.toIntExact(id));
 
        LocalDate currentDate = LocalDate.now();
 
 
        String cdt = currentDate.getYear()+"年"+currentDate.getMonthValue()+"月"+currentDate.getDayOfMonth()+"日";
 
        HashMap<String, Object> hs = new HashMap<String, Object>();
        int allPages = 0;
        int texPages = 0;
        int picPages = 0;
        int patPages = 0;
        if(!dmfs.isEmpty())
        {
            for(DocumentMaterialFileStyle documentMaterialFileStyle:dmfs)
            {
                if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("文字材料"))
                    texPages = documentMaterialFileStyle.getCnt();
                if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("图样材料"))
                    patPages = documentMaterialFileStyle.getCnt();
                if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("照片材料"))
                    picPages = documentMaterialFileStyle.getCnt();
            }
        }
        allPages = texPages + picPages + patPages;
        hs.put("pages", allPages);
        hs.put("patPages", patPages);
        hs.put("picPages", picPages);
        hs.put("texPages", texPages);
        hs.put("volumeNumber", recordId);
        hs.put("company", compName);
        hs.put("time", cdt);
 
        if (!getLicense()) {
            System.out.println("没有相关证书!");
        }
 
 
        try {
 
            // 获取 Word 模板所在路径
//            String filepath = "09-备考表.docx";
//            // 通过 XWPFTemplate 编译文件并渲染数据到模板中
//            XWPFTemplate template = XWPFTemplate.compile(filepath).render(hs
//            );
            // 获取 Word 模板所在路径
            ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
            org.springframework.core.io.Resource resource = resolver.getResource("classpath:09.docx");
//                String filepath = resource.getFile().getAbsolutePath();
//                // 通过 XWPFTemplate 编译文件并渲染数据到模板中
//                XWPFTemplate template = XWPFTemplate.compile(filepath).render(hs
//                       );
 
            InputStream inputStream = resource.getInputStream();
            // 通过 XWPFTemplate 编译文件并渲染数据到模板中
            XWPFTemplate template = XWPFTemplate.compile(inputStream).render(hs
            );
 
            String renderedDocPath = "rendered_output.docx";
            File renderedFile = new File(renderedDocPath);
            try {
                // 将完成数据渲染的文档写出
                template.writeAndClose(new FileOutputStream(renderedFile));
            } catch (IOException e) {
                e.printStackTrace();
            }
 
            com.aspose.words.Document doc = new com.aspose.words.Document("rendered_output.docx");
            // 创建临时字节输出流
            ByteArrayOutputStream baobk = new ByteArrayOutputStream();
            // 将Word文档转换为PDF字节数组
            doc.save(response.getOutputStream(), com.aspose.words.SaveFormat.PDF);//ȫ��֧��DOC, DOCX, OOXML, RTF HTML, OpenDocument, PDF, EPUB, XPS, SWF �໥ת��
 
 
        } catch (Exception e) {
            e.printStackTrace();
        }
 
    }
 
 
    //导出卷内目录
    @PostMapping("/exportJuan/{id}")
 
    public void exportJuanInfo(HttpServletResponse response, @PathVariable Long id) throws IOException {
        List<DocumentMaterialsVo> dsvs = documentMaterialsService.findArchMInfo(id.toString());
 
        //拿到卷内目录的excel
        List<DocumentMaterialsVoSmall> list2 = dsvs.stream().map(res1 -> new DocumentMaterialsVoSmall(res1.getNum(), res1.getDocumentNumber(),res1.getCreator(),
                res1.getTitle(), res1.getDate(), res1.getPageNumberFormatted(), res1.getRemarks())).collect(Collectors.toList());
        if(!dsvs.isEmpty()) {
            String recordId = dsvs.get(0).getRecordId();
            byte[] imgr = barcodeService.generateBarcodeImage(recordId);
            ExcelExp e1 = new ExcelExp("卷内目录数据", dsvs, DocumentMaterialsVo.class);
            ExcelExp e2 = new ExcelExp("卷内数据", list2, recordId, imgr, DocumentMaterialsVoSmall.class);
            List<ExcelExp> mysheet = new ArrayList<ExcelExp>();
            mysheet.add(e1);
            mysheet.add(e2);
            ExcelUtilManySheet<List<ExcelExp>> util2 = new ExcelUtilManySheet<List<ExcelExp>>(mysheet);
          //  ZipEntry entr = new ZipEntry(fna + adir + "/" + "卷内目录" + ".xls");
            // ExcelUtil<DocumentMaterialsVo> util1 = new ExcelUtil<DocumentMaterialsVo>(DocumentMaterialsVo.class);
         //   System.out.println(dsvs);
         //  zos.putNextEntry(entr);
            ByteOutputStream bos8 = new ByteOutputStream();
 
            util2.exportExcelManySheet(bos8, mysheet);
 
            bos8.writeTo( response.getOutputStream());
 
 
        }
    }
 
    //导出案卷封面
    @PostMapping("/exportPageInfo/{id}/{recordId}")
    public void exportPageInfo(HttpServletResponse response, @PathVariable Long id, @PathVariable String recordId) throws IOException {
 
        ArchiveInfoVo aIV = iArchiveRecordsService.selectByRecordId(id);
 
        List<ArchiveInfoVo> arsi = new ArrayList<>();
        arsi.add(aIV);
 
        String recordId1 = recordId;
        byte[] imgr1 = barcodeService.generateBarcodeImage(recordId1);
        byte[] sedcode = pdfGenerateService.createQrCodeN(recordId1, 200, 200);
        ExcelExp e3 = new ExcelExp("案卷封面数据",arsi, ArchiveInfoVo.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();
        ExcelUtilManySheetSecond<List<ExcelExp>> util3 = new ExcelUtilManySheetSecond<List<ExcelExp>>(mysheet1);
 
        util3.exportExcelManySheet(bos2, mysheet1);
 
        //  System.out.println(bos2);
        bos2.writeTo(response.getOutputStream());
 
    }
 
 
}