liujie
2026-04-09 3adfcc5a9829a0231bf95c1a7e3aaad1d28b05d5
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
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
package com.estate.expert.admin.controller.stat;
 
import com.deepoove.poi.XWPFTemplate;
import com.estate.expert.admin.enums.BizResultCode;
import com.estate.expert.admin.service.CheckTaskService;
import com.estate.expert.admin.service.ReportService;
import com.estate.expert.admin.service.ReportTemplateService;
import com.estate.expert.admin.utils.wordtopdf.PdfUtils;
import com.estate.expert.admin.utils.wordtopdf.WordToPdfTest;
import com.estate.expert.common.auth.IgnoreAuth;
import com.estate.expert.common.rpc.Result;
import fr.opensagres.poi.xwpf.converter.pdf.PdfConverter;
import fr.opensagres.poi.xwpf.converter.pdf.PdfOptions;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.rendering.ImageType;
import org.apache.pdfbox.rendering.PDFRenderer;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
 
@Api(tags = "管理后台/统计/报告下载")
@Slf4j
@CrossOrigin
@Controller
@RequestMapping("/admin/stat/report")
@Validated
public class ReportController {
 
    @Resource
    private ReportService reportService;
 
    @Resource
    private CheckTaskService checkTaskService;
 
    @Resource
    private ReportTemplateService reportTemplateService;
 
    @Value("${file.upload.dir}/reports")
    private String REPORT_UPLOAD_DIR;
 
    @ApiOperation("模糊评价报告下载")
    @GetMapping("/fuzzyReport")
    @IgnoreAuth
    public void fuzzyReport(@ApiParam("检查任务ID") @RequestParam(value = "checkTaskId") Integer checkTaskId,
                              @ApiParam("报告模版ID") @RequestParam(value = "templateId") Integer templateId,
                              @ApiParam("uuid") @RequestParam(value = "uuid",required = false) String uuid,
                              HttpServletResponse response) throws IOException {
        try (var doc = reportService.fuzzyReport(checkTaskId, templateId)) {
            download(doc, response, "模糊评价", checkTaskId, templateId,uuid);
        }
    }
 
    @ApiOperation("打分评价报告下载")
    @GetMapping("/scoreReport")
    @IgnoreAuth
    public void scoreReport(@ApiParam("检查任务ID") @RequestParam(value = "checkTaskId") Integer checkTaskId,
                          @ApiParam("报告模版ID") @RequestParam(value = "templateId") Integer templateId,
                            @ApiParam("uuid") @RequestParam(value = "uuid",required = false) String uuid,
                          HttpServletResponse response) throws IOException {
        try (var doc = reportService.scoreReport(checkTaskId, templateId)) {
            download(doc, response, "打分评价", checkTaskId, templateId,uuid);
        }
    }
 
    @ApiOperation("模版示例下载")
    @GetMapping("/example")
    @IgnoreAuth
    public void example(@ApiParam("报告模版ID") @RequestParam(value = "templateId") Integer templateId,
                          HttpServletResponse response) throws IOException {
        try (var doc = reportService.fuzzyReport(1, templateId)) {
            download(doc, response, "示例",1, templateId,null);
        }
    }
 
    @Autowired
    private PdfUtils pdfUtils;
 
 
    @ApiOperation("模糊评价报告PDF下载(新接口)- 通过Word链接转换")
    @GetMapping("/fuzzyReportPdfNew")
    @IgnoreAuth
    @ResponseBody
    public Result fuzzyReportPdfNew( @RequestParam(value = "uuid", required = false) String uuid,
                                  HttpServletResponse response) throws Exception {
 
        try {
//            String test = pdfUtils.test("F:\\file\\estate\\reports\\1769239688785.docx");
            String s = WordToPdfTest.testSingleFileConversion(uuid);
            return Result.success(s);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
 
    }
 
 
    @ApiOperation("模糊评价报告PDF下载")
    @GetMapping("/fuzzyReportPdf")
    @IgnoreAuth
    public void fuzzyReportPdf(@ApiParam("检查任务ID") @RequestParam(value = "checkTaskId") Integer checkTaskId,
                               @ApiParam("报告模版ID") @RequestParam(value = "templateId") Integer templateId,
                               HttpServletResponse response) throws IOException {
        downloadPdf(checkTaskId, templateId, response, "模糊评价", true);
    }
 
    @ApiOperation("打分评价报告PDF下载")
    @GetMapping("/scoreReportPdf")
    @IgnoreAuth
    public void scoreReportPdf(@ApiParam("检查任务ID") @RequestParam(value = "checkTaskId") Integer checkTaskId,
                               @ApiParam("报告模版ID") @RequestParam(value = "templateId") Integer templateId,
                               HttpServletResponse response) throws IOException {
        downloadPdf(checkTaskId, templateId, response, "打分评价", false);
    }
 
    @ApiOperation("检查报告转换状态")
    @GetMapping("/checkConversionStatus")
    @ResponseBody
    @IgnoreAuth
    public Result<ConversionStatus> checkConversionStatus(@ApiParam("文件UUID") @RequestParam(value = "uuid") String uuid) {
        try {
            ConversionStatus status = new ConversionStatus();
            status.setUuid(uuid);
 
            // 检查Word文件是否存在
            Path wordPath = Path.of(REPORT_UPLOAD_DIR).resolve(uuid + ".docx");
            status.setWordFileExists(Files.exists(wordPath));
 
            // 检查图片文件
            Path imageDir = Path.of(REPORT_UPLOAD_DIR, "images");
            if (Files.exists(imageDir)) {
                try (var stream = Files.list(imageDir)) {
                    long imageCount = stream.filter(path -> {
                        String fileName = path.getFileName().toString();
                        return fileName.startsWith(uuid + "_page_") && fileName.endsWith(".png");
                    }).count();
                    status.setImageCount((int) imageCount);
                    status.setConversionCompleted(imageCount > 0);
                }
            } else {
                status.setImageCount(0);
                status.setConversionCompleted(false);
            }
 
            return Result.success(status);
 
        } catch (Exception e) {
            log.error("检查转换状态失败: uuid={}", uuid, e);
            return Result.error("检查转换状态失败: " + e.getMessage());
        }
    }
 
    private void download(XWPFTemplate doc, HttpServletResponse response, String typeName,
                          Integer checkTaskId, Integer templateId,String uuid) throws IOException {
        ByteArrayOutputStream docOutputStream = null;
        OutputStream out = null;
        BufferedOutputStream bos = null;
 
        try {
            var checkTask = checkTaskService.get(checkTaskId, true);
            var reportTemplate = reportTemplateService.get(templateId);
            BizResultCode.TASK_NOT_FOUND.check(checkTask == null);
 
            var docName = checkTask.getProject().getName() + "_" + reportTemplate.getName() + "_" + typeName;
            String encodedFileName = URLEncoder.encode(docName, "UTF-8");
            response.setContentType("application/octet-stream");
            response.setHeader("Content-disposition", "attachment;filename=\"" + encodedFileName + ".docx\"");
 
            // 先将文档写入字节数组
            docOutputStream = new ByteArrayOutputStream();
            doc.write(docOutputStream);
            byte[] docBytes = docOutputStream.toByteArray();
 
            // 写入响应流供用户下载
            out = response.getOutputStream();
            bos = new BufferedOutputStream(out);
            bos.write(docBytes);
            bos.flush();
            out.flush();
 
            // 保存文件到服务器
            if(uuid!=null && !uuid.isEmpty()){
                saveFileToServer(docBytes, docName + ".docx",uuid);
            }
        } catch (Exception e) {
            log.error("文档下载失败", e);
            throw new IOException("文档下载失败: " + e.getMessage(), e);
        } finally {
            if (docOutputStream != null) {
                try {
                    docOutputStream.close();
                } catch (Exception e) {
                    log.warn("关闭输出流失败", e);
                }
            }
        }
    }
 
    private void downloadPdf(Integer checkTaskId, Integer templateId, HttpServletResponse response,
                             String typeName, boolean isFuzzy) throws IOException {
        ByteArrayOutputStream pdfOutputStream = null;
        OutputStream out = null;
        BufferedOutputStream bos = null;
 
        try {
            var checkTask = checkTaskService.get(checkTaskId, true);
            var reportTemplate = reportTemplateService.get(templateId);
            BizResultCode.TASK_NOT_FOUND.check(checkTask == null);
 
            var docName = checkTask.getProject().getName() + "_" + reportTemplate.getName() + "_" + typeName;
            String encodedFileName = URLEncoder.encode(docName, "UTF-8");
            response.setContentType("application/pdf");
            response.setHeader("Content-disposition", "attachment;filename=\"" + encodedFileName + ".pdf\"");
 
            // 先将PDF写入字节数组
            pdfOutputStream = new ByteArrayOutputStream();
            if (isFuzzy) {
                reportService.fuzzyReportPdf(checkTaskId, templateId, pdfOutputStream);
            } else {
                reportService.scoreReportPdf(checkTaskId, templateId, pdfOutputStream);
            }
            byte[] pdfBytes = pdfOutputStream.toByteArray();
 
            // 写入响应流供用户下载
            out = response.getOutputStream();
            bos = new BufferedOutputStream(out);
            bos.write(pdfBytes);
            bos.flush();
            out.flush();
 
            // 保存文件到服务器
            saveFileToServer(pdfBytes, docName + ".pdf",null);
 
        } catch (Exception e) {
            log.error("PDF下载失败", e);
            throw new IOException("PDF下载失败: " + e.getMessage(), e);
        } finally {
            if (pdfOutputStream != null) {
                try {
                    pdfOutputStream.close();
                } catch (Exception e) {
                    log.warn("关闭输出流失败", e);
                }
            }
        }
    }
 
    /**
     * 将Word文档转换为PDF并下载
     * @param doc Word文档模板
     * @param response HTTP响应
     * @param typeName 报告类型名称
     * @param checkTaskId 检查任务ID
     * @param templateId 模板ID
     * @throws IOException IO异常
     */
    private void downloadAsPdf(XWPFTemplate doc, HttpServletResponse response, String typeName,
                               Integer checkTaskId, Integer templateId) throws IOException {
        ByteArrayOutputStream docOutputStream = null;
        ByteArrayInputStream docInputStream = null;
        ByteArrayOutputStream pdfOutputStream = null;
        XWPFDocument document = null;
        OutputStream out = null;
        BufferedOutputStream bos = null;
 
        try {
            var checkTask = checkTaskService.get(checkTaskId, true);
            var reportTemplate = reportTemplateService.get(templateId);
            BizResultCode.TASK_NOT_FOUND.check(checkTask == null);
 
            var docName = checkTask.getProject().getName() + "_" + reportTemplate.getName() + "_" + typeName;
            String encodedFileName = URLEncoder.encode(docName, "UTF-8");
            response.setContentType("application/pdf");
            response.setHeader("Content-disposition", "attachment;filename=\"" + encodedFileName + ".pdf\"");
 
            // 将Word模板写入字节数组
            docOutputStream = new ByteArrayOutputStream();
            doc.write(docOutputStream);
 
            // 从字节数组读取Word文档
            docInputStream = new ByteArrayInputStream(docOutputStream.toByteArray());
            document = new XWPFDocument(docInputStream);
 
            // 配置PDF选项
            PdfOptions options = PdfOptions.create();
            options.fontEncoding("UTF-8");
 
            // 先将PDF转换到字节数组
            pdfOutputStream = new ByteArrayOutputStream();
            PdfConverter.getInstance().convert(document, pdfOutputStream, options);
            byte[] pdfBytes = pdfOutputStream.toByteArray();
 
            // 写入响应流供用户下载
            out = response.getOutputStream();
            bos = new BufferedOutputStream(out);
            bos.write(pdfBytes);
            bos.flush();
            out.flush();
 
            // 保存文件到服务器
            saveFileToServer(pdfBytes, docName + ".pdf",null);
 
        } catch (Exception e) {
            log.error("Word转PDF失败", e);
            throw new IOException("Word转PDF失败: " + e.getMessage(), e);
        } finally {
            // 关闭资源
            if (document != null) {
                try {
                    document.close();
                } catch (Exception e) {
                    log.warn("关闭Word文档失败", e);
                }
            }
            if (pdfOutputStream != null) {
                try {
                    pdfOutputStream.close();
                } catch (Exception e) {
                    log.warn("关闭PDF输出流失败", e);
                }
            }
            if (docInputStream != null) {
                try {
                    docInputStream.close();
                } catch (Exception e) {
                    log.warn("关闭输入流失败", e);
                }
            }
            if (docOutputStream != null) {
                try {
                    docOutputStream.close();
                } catch (Exception e) {
                    log.warn("关闭输出流失败", e);
                }
            }
        }
    }
 
    /**
     * 保存文件到服务器
     * @param fileBytes 文件字节数组
     * @param fileName 文件名
     */
    private String saveFileToServer(byte[] fileBytes, String fileName,String uuid) {
        try {
            // 确保目录存在
            Path reportDir = Path.of(REPORT_UPLOAD_DIR).toAbsolutePath().normalize();
            if (!Files.exists(reportDir)) {
                Files.createDirectories(reportDir);
            }
            //文件名随机
            fileName =uuid+".docx";
            // 保存文件
            Path filePath = reportDir.resolve(fileName);
            Files.write(filePath, fileBytes, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
 
            log.info("文件已保存到服务器: {}", filePath.toString());
            System.out.println("文件已保存到服务器: " + filePath.toString());
            return fileName;
        } catch (Exception e) {
            log.error("保存文件到服务器失败: {}", fileName, e);
            System.out.println("保存文件到服务器失败: " + e.getMessage());
            // 不抛出异常,避免影响用户下载
        }
        return null;
    }
 
    /**
     * 将Word文档转换为图片并保存到服务器
     * @param docBytes Word文档字节数组
     * @param uuid 文件唯一标识
     */
    private void convertWordToImagesAndSave(byte[] docBytes, String uuid) {
        ByteArrayInputStream docInputStream = null;
        XWPFDocument document = null;
        ByteArrayOutputStream pdfOutputStream = null;
        PDDocument pdfDocument = null;
 
        try {
            // 1. 将Word文档转换为PDF
            docInputStream = new ByteArrayInputStream(docBytes);
            document = new XWPFDocument(docInputStream);
 
            pdfOutputStream = new ByteArrayOutputStream();
            PdfOptions options = PdfOptions.create();
            options.fontEncoding("UTF-8");
            PdfConverter.getInstance().convert(document, pdfOutputStream, options);
 
            byte[] pdfBytes = pdfOutputStream.toByteArray();
 
            // 2. 将PDF转换为图片
            ByteArrayInputStream pdfInputStream = new ByteArrayInputStream(pdfBytes);
            pdfDocument = PDDocument.load(pdfInputStream);
            PDFRenderer pdfRenderer = new PDFRenderer(pdfDocument);
 
            // 确保图片目录存在
            Path imageDir = Path.of(REPORT_UPLOAD_DIR, "images").toAbsolutePath().normalize();
            if (!Files.exists(imageDir)) {
                Files.createDirectories(imageDir);
            }
 
            // 转换每一页为图片
            int pageCount = pdfDocument.getNumberOfPages();
            log.info("开始转换Word为图片,共{}页", pageCount);
 
            for (int i = 0; i < pageCount; i++) {
                // 渲染PDF页面为图片,DPI设置为300以获得高质量图片
                BufferedImage image = pdfRenderer.renderImageWithDPI(i, 300, ImageType.RGB);
 
                // 保存图片
                String imageFileName = uuid + "_page_" + (i + 1) + ".png";
                Path imagePath = imageDir.resolve(imageFileName);
                ImageIO.write(image, "PNG", imagePath.toFile());
 
                log.info("页面{}已转换为图片: {}", i + 1, imagePath.toString());
            }
 
            log.info("Word文档已成功转换为{}张图片", pageCount);
 
        } catch (Exception e) {
            log.error("Word转图片失败: uuid={}", uuid, e);
            // 不抛出异常,避免影响用户下载
        } finally {
            // 关闭资源
            if (pdfDocument != null) {
                try {
                    pdfDocument.close();
                } catch (Exception e) {
                    log.warn("关闭PDF文档失败", e);
                }
            }
            if (document != null) {
                try {
                    document.close();
                } catch (Exception e) {
                    log.warn("关闭Word文档失败", e);
                }
            }
            if (pdfOutputStream != null) {
                try {
                    pdfOutputStream.close();
                } catch (Exception e) {
                    log.warn("关闭PDF输出流失败", e);
                }
            }
            if (docInputStream != null) {
                try {
                    docInputStream.close();
                } catch (Exception e) {
                    log.warn("关闭文档输入流失败", e);
                }
            }
        }
    }
 
    /**
     * 从文件名中提取页码
     * @param fileName 文件名,格式:uuid_page_N.png
     * @return 页码
     */
    private int extractPageNumber(String fileName) {
        try {
            // 文件名格式:uuid_page_N.png
            String[] parts = fileName.replace(".png", "").split("_page_");
            if (parts.length == 2) {
                return Integer.parseInt(parts[1]);
            }
        } catch (Exception e) {
            log.warn("解析页码失败: {}", fileName, e);
        }
        return 0;
    }
 
    /**
     * 通过Word文档URL转换为PDF并下载
     * @param wordUrl Word文档的URL地址
     * @param fileName 文件名(可选)
     * @param response HTTP响应
     * @throws IOException IO异常
     */
    private void downloadPdfFromWordUrl(String wordUrl, String fileName, HttpServletResponse response) throws IOException {
        InputStream wordInputStream = null;
        XWPFDocument document = null;
        ByteArrayOutputStream pdfOutputStream = null;
        OutputStream out = null;
        BufferedOutputStream bos = null;
        HttpURLConnection connection = null;
 
        try {
            log.info("开始从URL下载Word文档: {}", wordUrl);
 
            // 1. 从URL下载Word文档
            URL url = new URL(wordUrl);
            connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("GET");
            connection.setConnectTimeout(30000); // 30秒连接超时
            connection.setReadTimeout(60000);    // 60秒读取超时
            connection.setRequestProperty("User-Agent", "Mozilla/5.0");
 
            int responseCode = connection.getResponseCode();
            if (responseCode != HttpURLConnection.HTTP_OK) {
                throw new IOException("下载Word文档失败,HTTP状态码: " + responseCode);
            }
 
            wordInputStream = connection.getInputStream();
            log.info("Word文档下载成功,开始转换为PDF");
 
            // 2. 读取Word文档
            document = new XWPFDocument(wordInputStream);
 
            // 3. 转换为PDF
            pdfOutputStream = new ByteArrayOutputStream();
            PdfOptions options = PdfOptions.create();
            options.fontEncoding("UTF-8");
 
            // 确保图表不丢失的关键配置
            PdfConverter.getInstance().convert(document, pdfOutputStream, options);
 
            byte[] pdfBytes = pdfOutputStream.toByteArray();
            log.info("PDF转换成功,大小: {} bytes", pdfBytes.length);
 
            // 4. 设置响应头(修复中文乱码)
            String downloadFileName = fileName != null && !fileName.isEmpty()
                ? fileName
                : "report_" + System.currentTimeMillis();
 
            if (!downloadFileName.toLowerCase().endsWith(".pdf")) {
                downloadFileName += ".pdf";
            }
 
            // 使用RFC 5987规范处理中文文件名
            String encodedFileName = URLEncoder.encode(downloadFileName, "UTF-8").replaceAll("\\+", "%20");
 
            response.setContentType("application/pdf");
            response.setCharacterEncoding("UTF-8");
            response.setHeader("Content-Disposition",
                "attachment; filename=\"" + encodedFileName + "\"; filename*=UTF-8''" + encodedFileName);
            response.setContentLength(pdfBytes.length);
 
            // 5. 写入响应流
            out = response.getOutputStream();
            bos = new BufferedOutputStream(out);
            bos.write(pdfBytes);
            bos.flush();
            out.flush();
 
            log.info("PDF文档下载成功: {}", downloadFileName);
 
        } catch (Exception e) {
            log.error("从Word URL转换PDF失败: url={}", wordUrl, e);
            throw new IOException("从Word URL转换PDF失败: " + e.getMessage(), e);
        } finally {
            // 关闭资源
            if (document != null) {
                try {
                    document.close();
                } catch (Exception e) {
                    log.warn("关闭Word文档失败", e);
                }
            }
            if (pdfOutputStream != null) {
                try {
                    pdfOutputStream.close();
                } catch (Exception e) {
                    log.warn("关闭PDF输出流失败", e);
                }
            }
            if (wordInputStream != null) {
                try {
                    wordInputStream.close();
                } catch (Exception e) {
                    log.warn("关闭Word输入流失败", e);
                }
            }
            if (connection != null) {
                try {
                    connection.disconnect();
                } catch (Exception e) {
                    log.warn("断开HTTP连接失败", e);
                }
            }
        }
    }
 
    /**
     * 转换状态内部类
     */
    public static class ConversionStatus {
        private String uuid;
        private boolean wordFileExists;
        private int imageCount;
        private boolean conversionCompleted;
 
        public String getUuid() {
            return uuid;
        }
 
        public void setUuid(String uuid) {
            this.uuid = uuid;
        }
 
        public boolean isWordFileExists() {
            return wordFileExists;
        }
 
        public void setWordFileExists(boolean wordFileExists) {
            this.wordFileExists = wordFileExists;
        }
 
        public int getImageCount() {
            return imageCount;
        }
 
        public void setImageCount(int imageCount) {
            this.imageCount = imageCount;
        }
 
        public boolean isConversionCompleted() {
            return conversionCompleted;
        }
 
        public void setConversionCompleted(boolean conversionCompleted) {
            this.conversionCompleted = conversionCompleted;
        }
    }
 
}