Browse Source

修改为freemarker

aQiu6 3 months ago
parent
commit
2053a0b837
34 changed files with 134 additions and 7213 deletions
  1. BIN
      download.pdf
  2. BIN
      jijinhui.docx
  3. 0 1
      jijinhui/[Content_Types].xml
  4. 0 2
      jijinhui/_rels/.rels
  5. 0 2
      jijinhui/customXml/_rels/item1.xml.rels
  6. 0 2
      jijinhui/customXml/item1.xml
  7. 0 2
      jijinhui/customXml/itemProps1.xml
  8. 0 2
      jijinhui/docProps/app.xml
  9. 0 2
      jijinhui/docProps/core.xml
  10. 0 2
      jijinhui/docProps/custom.xml
  11. 0 8
      jijinhui/word/_rels/document.xml.rels
  12. 0 3452
      jijinhui/word/document.xml
  13. 0 1
      jijinhui/word/fontTable.xml
  14. 0 2
      jijinhui/word/footer1.xml
  15. 0 2
      jijinhui/word/footer2.xml
  16. 0 1
      jijinhui/word/footer3.xml
  17. 0 2
      jijinhui/word/header1.xml
  18. BIN
      jijinhui/word/media/image1.jpeg
  19. BIN
      jijinhui/word/media/pic1.png
  20. 0 1
      jijinhui/word/numbering.xml
  21. 0 1
      jijinhui/word/settings.xml
  22. 0 1
      jijinhui/word/styles.xml
  23. 0 1
      jijinhui/word/theme/theme1.xml
  24. BIN
      jijinhui1.docx
  25. 37 19
      src/main/java/org/example/mybatisplus/Controller/IndexController.java
  26. 3 1
      src/main/java/org/example/mybatisplus/module/ServiceProviderAuditReport.java
  27. 1 0
      src/main/java/org/example/mybatisplus/module/vo/Attachment.java
  28. 1 1
      src/main/java/org/example/mybatisplus/module/vo/BusinessAbnormal.java
  29. 1 1
      src/main/java/org/example/mybatisplus/module/vo/DishonestPerson.java
  30. 1 1
      src/main/java/org/example/mybatisplus/module/vo/SevereViolation.java
  31. 51 0
      src/main/java/org/example/mybatisplus/tools/DocxGenerator.java
  32. 39 1
      src/main/java/org/example/mybatisplus/tools/WordToPdfUtil.java
  33. 0 3702
      src/main/resources/jijinhui.xml
  34. BIN
      src/main/resources/jijinhui1.zip

BIN
download.pdf


BIN
jijinhui.docx


File diff suppressed because it is too large
+ 0 - 1
jijinhui/[Content_Types].xml


+ 0 - 2
jijinhui/_rels/.rels

@@ -1,2 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml"/><Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties" Target="docProps/custom.xml"/></Relationships>

+ 0 - 2
jijinhui/customXml/_rels/item1.xml.rels

@@ -1,2 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlProps" Target="itemProps1.xml"/></Relationships>

+ 0 - 2
jijinhui/customXml/item1.xml

@@ -1,2 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<s:customData xmlns="http://www.wps.cn/officeDocument/2013/wpsCustomData" xmlns:s="http://www.wps.cn/officeDocument/2013/wpsCustomData"><customSectProps><customSectPr/><customSectPr/></customSectProps><customShpExts><customShpInfo spid="_x0000_s1026" textRotate="1"/></customShpExts></s:customData>

+ 0 - 2
jijinhui/customXml/itemProps1.xml

@@ -1,2 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<ds:datastoreItem ds:itemID="{B1977F7D-205B-4081-913C-38D41E755F92}" xmlns:ds="http://schemas.openxmlformats.org/officeDocument/2006/customXml"><ds:schemaRefs><ds:schemaRef ds:uri="http://www.wps.cn/officeDocument/2013/wpsCustomData"/></ds:schemaRefs></ds:datastoreItem>

+ 0 - 2
jijinhui/docProps/app.xml

@@ -1,2 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"><Template>Normal</Template><Pages>15</Pages><Words>779</Words><Characters>932</Characters><Lines>1</Lines><Paragraphs>1</Paragraphs><TotalTime>335</TotalTime><ScaleCrop>false</ScaleCrop><LinksUpToDate>false</LinksUpToDate><CharactersWithSpaces>1149</CharactersWithSpaces><Application>WPS Office_12.1.0.20305_F1E327BC-269C-435d-A152-05C5408002CA</Application><DocSecurity>0</DocSecurity></Properties>

+ 0 - 2
jijinhui/docProps/core.xml

@@ -1,2 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><dcterms:created xsi:type="dcterms:W3CDTF">2024-11-17T07:09:00Z</dcterms:created><dc:creator>Joanna Ying Yan</dc:creator><cp:lastModifiedBy>WPS_1720887080</cp:lastModifiedBy><dcterms:modified xsi:type="dcterms:W3CDTF">2025-03-09T22:24:59Z</dcterms:modified><dc:title>Diligence Report</dc:title><cp:revision>1</cp:revision></cp:coreProperties>

+ 0 - 2
jijinhui/docProps/custom.xml

@@ -1,2 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"><property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="2" name="CRO"><vt:lpwstr>wqlLaW5nc29mdCBQREYgdG8gV1BTIDEwMA</vt:lpwstr></property><property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="3" name="Created"><vt:filetime>2024-09-26T16:37:59Z</vt:filetime></property><property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="4" name="KSOProductBuildVer"><vt:lpwstr>2052-12.1.0.20305</vt:lpwstr></property><property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="5" name="ICV"><vt:lpwstr>54CFA10719CC4BCF8A37486EC79A01DB_13</vt:lpwstr></property><property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="6" name="KSOTemplateDocerSaveRecord"><vt:lpwstr>eyJoZGlkIjoiMmZlN2IzYmRhZjk1NzA0MzY5NmI3ZjdhYTgxYTcxYTkiLCJ1c2VySWQiOiIxNjE1NDU2NTEyIn0=</vt:lpwstr></property></Properties>

+ 0 - 8
jijinhui/word/_rels/document.xml.rels

@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
-<#if image??>
-  <Relationship
-      Id="${image.relationId}"
-      Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"
-      Target="media/${image.fileName}"/>
-  </#if><Relationship Id="rId9" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml" Target="../customXml/item1.xml"/><Relationship Id="rId8" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="media/image1.jpeg"/><Relationship Id="rId7" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" Target="theme/theme1.xml"/><Relationship Id="rId6" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer" Target="footer3.xml"/><Relationship Id="rId5" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer" Target="footer2.xml"/><Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/header" Target="header1.xml"/><Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer" Target="footer1.xml"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings" Target="settings.xml"/><Relationship Id="rId11" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable" Target="fontTable.xml"/><Relationship Id="rId10" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering" Target="numbering.xml"/><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/></Relationships>

File diff suppressed because it is too large
+ 0 - 3452
jijinhui/word/document.xml


File diff suppressed because it is too large
+ 0 - 1
jijinhui/word/fontTable.xml


+ 0 - 2
jijinhui/word/footer1.xml

@@ -1,2 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<w:ftr xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" xmlns:wpsCustomData="http://www.wps.cn/officeDocument/2013/wpsCustomData" mc:Ignorable="w14 w15 wp14"><w:p w14:paraId="27889BE9"><w:pPr><w:pStyle w:val="9"/><w:spacing w:line="188" w:lineRule="auto"/><w:ind w:left="1"/><w:rPr><w:rFonts w:hint="eastAsia"/><w:sz w:val="12"/><w:szCs w:val="12"/></w:rPr></w:pPr></w:p></w:ftr>

+ 0 - 2
jijinhui/word/footer2.xml

@@ -1,2 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<w:ftr xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" xmlns:wpsCustomData="http://www.wps.cn/officeDocument/2013/wpsCustomData" mc:Ignorable="w14 w15 wp14"><w:p w14:paraId="422FAE12"><w:pPr><w:pStyle w:val="9"/><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:eastAsia="Arial" w:cs="Arial"/><w:sz w:val="20"/><w:szCs w:val="20"/></w:rPr></w:pPr></w:p></w:ftr>

File diff suppressed because it is too large
+ 0 - 1
jijinhui/word/footer3.xml


+ 0 - 2
jijinhui/word/header1.xml

@@ -1,2 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<w:hdr xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" xmlns:wpsCustomData="http://www.wps.cn/officeDocument/2013/wpsCustomData" mc:Ignorable="w14 w15 wp14"><w:p w14:paraId="7585BF1D"><w:pPr><w:pStyle w:val="11"/></w:pPr></w:p></w:hdr>

BIN
jijinhui/word/media/image1.jpeg


BIN
jijinhui/word/media/pic1.png


File diff suppressed because it is too large
+ 0 - 1
jijinhui/word/numbering.xml


File diff suppressed because it is too large
+ 0 - 1
jijinhui/word/settings.xml


File diff suppressed because it is too large
+ 0 - 1
jijinhui/word/styles.xml


File diff suppressed because it is too large
+ 0 - 1
jijinhui/word/theme/theme1.xml


BIN
jijinhui1.docx


+ 37 - 19
src/main/java/org/example/mybatisplus/Controller/IndexController.java

@@ -7,10 +7,9 @@ import io.swagger.annotations.ApiParam;
 import org.example.mybatisplus.model.auto.CmsEnterpriseRiskInfoCheckBO;
 import org.example.mybatisplus.model.auto.CmsEnterpriseRiskInfoDeclaration;
 import org.example.mybatisplus.model.auto.CmsEnterpriseRiskQxbInfoBO;
-import org.example.mybatisplus.module.AuditResult;
-import org.example.mybatisplus.module.BasicInfo;
-import org.example.mybatisplus.module.ServiceProviderAuditReport;
-import org.example.mybatisplus.module.vo.ServiceProviderInfo;
+import org.example.mybatisplus.module.*;
+import org.example.mybatisplus.module.vo.*;
+import org.example.mybatisplus.tools.DocxGenerator;
 import org.example.mybatisplus.tools.WordPoiExporter;
 import org.example.mybatisplus.tools.WordToPdfUtil;
 import org.springframework.core.io.FileSystemResource;
@@ -26,13 +25,11 @@ import java.io.*;
 @ApiOperation("控制类")
 @RestController
 public class IndexController {
-    public static void main(String[] args) {
+    public static void main(String[] args) throws IOException {
 
-        String wordFilePath = System.getProperty("user.dir")+File.separator+ "jijinhui.docx";
         String wordExportpath = System.getProperty("user.dir")+File.separator+ "jijinhui1.docx";
         String pdfFilePath =System.getProperty("user.dir")+File.separator+  "download.pdf";
 
-        // todo:
         ServiceProviderInfo serviceProviderInfo=new ServiceProviderInfo();
         serviceProviderInfo.setName("海潮基金会");
         serviceProviderInfo.setType("基金会");
@@ -41,24 +38,43 @@ public class IndexController {
         auditResult.setAuditDate("2025-03-11");
         auditResult.setScore("222");
         auditResult.setOpinion("test");
-        // auditResult.setMocaRating("test");
-        // auditResult.setDonationIncomeScale("test");
-        // auditResult.setManagementExpense("test");
-        // auditResult.setOperationYears("2025");
-        // auditResult.setPublicExpenseGrowth("test");
-        BasicInfo basicInfo = new BasicInfo();
-        // ...
+        auditResult.setServiceProviderName("服务商2");
 
-        // 最后把所有片段合成一个完整报告
+        BasicInfo basicInfo = new BasicInfo();
+        basicInfo.setBasicInfoScore(new BasicInfoScore(
+                66l,
+                "哈哈哈",
+                "测试"
+        ));
+        // 将图片转换为 Base64 编码
+        String imageBase64 = DocxGenerator.convertImageToBase64("G:\\Code\\new\\fxy-tool\\src\\main\\resources\\pic1.png");
+        Attachment attach = new Attachment();
+        attach.setFileName("关联实体情况.png");
+
+        attach.setBase64(imageBase64);
+        basicInfo.setRelatedEntitiesImage(attach);
+        PublicRecord publicRecord=new PublicRecord();
+        publicRecord.setPublicRecordScore(new PublicRecordScore());
+        FinancialInfo financialInfo=new FinancialInfo();
+        financialInfo.setFinancialData1(new FinancialData());//new 空对象防止模板空指针
+        financialInfo.setFinancialData2(new FinancialData());
+        financialInfo.setFinancialData3(new FinancialData());
+        financialInfo.setFinancialData4(new FinancialData());
+        financialInfo.setFinancialScore(new FinancialScore());
+        ProjectInfo projectInfo=new ProjectInfo();
+        DocumentVo documentVo=new DocumentVo();
 
         ServiceProviderAuditReport report=new ServiceProviderAuditReport();
         report.setServiceProviderInfo(serviceProviderInfo);
         report.setAuditResult(auditResult);
         report.setBasicInfo(basicInfo);
+        report.setPublicRecord(publicRecord);
+        report.setFinancialInfo(financialInfo);
+        report.setProjectInfo(projectInfo);
+        report.setDocumentVo(documentVo);
         try {
-            JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(report));
             // 生成Word文档
-            WordPoiExporter.init(wordFilePath,wordExportpath,jsonObject);
+            DocxGenerator.init(report,"n_jjh.xml",wordExportpath);
             // 将Word文档转换为PDF
             WordToPdfUtil.wordToPdf(wordExportpath,pdfFilePath);
         } catch (Exception e) {
@@ -109,9 +125,11 @@ public class IndexController {
         report.setBasicInfo(basicInfo);
         report.setAuditResult(auditResult);
         try {
-            JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(report));
+            //JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(report));
+            // 生成Word文档
+            //WordPoiExporter.init(wordFilePath,wordExportpath,jsonObject);
             // 生成Word文档
-            WordPoiExporter.init(wordFilePath,wordExportpath,jsonObject);
+            DocxGenerator.init(report,"n_jjh.xml",wordExportpath);
             // 将Word文档转换为PDF
             WordToPdfUtil.wordToPdf(wordExportpath,pdfFilePath);
         } catch (Exception e) {

+ 3 - 1
src/main/java/org/example/mybatisplus/module/ServiceProviderAuditReport.java

@@ -5,6 +5,8 @@ import org.example.mybatisplus.module.vo.Attachment;
 import org.example.mybatisplus.module.vo.DocumentVo;
 import org.example.mybatisplus.module.vo.ServiceProviderInfo;
 
+import java.util.List;
+
 /**
  * 顶层报告类
  */
@@ -16,7 +18,7 @@ public class ServiceProviderAuditReport {
     private PublicRecord publicRecord;              // 公共记录
     private FinancialInfo financialInfo;             // 财务信息
     private ProjectInfo projectInfo;                 // 项目情况
-    private Attachment interestConflict;             // 利益冲突 
+    private List<Attachment> interestConflict;             // 利益冲突
     private DocumentVo documentVo;            // 附件列表
 }
 

+ 1 - 0
src/main/java/org/example/mybatisplus/module/vo/Attachment.java

@@ -12,4 +12,5 @@ public class Attachment {
     private String fileType;//附件类型,图片或pdf
     private String width;
     private String height;//图片显示高度
+    private String base64;//图片base64
 }

+ 1 - 1
src/main/java/org/example/mybatisplus/module/vo/BusinessAbnormal.java

@@ -8,5 +8,5 @@ public class BusinessAbnormal {
     private String inclusionDate;        // 列入日期
     private String decisionAuthority;       // 作出决定机关(列入)
     private String reason;                  // 列入经营异常名录原因
-    private Boolean isHistorical;           // 是否是历史记录
+    private String isHistorical;           // 是否是历史记录
 }

+ 1 - 1
src/main/java/org/example/mybatisplus/module/vo/DishonestPerson.java

@@ -11,6 +11,6 @@ public class DishonestPerson {
     private String executionSubject;        // 执行标的(原文为“执行标地”,修正为Subject)
     private String dishonestBehavior;       // 失信被执行人具体情形
     private String executingCourt;          // 执行法院
-    private Boolean isHistorical;           // 是否是历史记录(true/false)
+    private String isHistorical;           // 是否是历史记录(true/false)
 
 }

+ 1 - 1
src/main/java/org/example/mybatisplus/module/vo/SevereViolation.java

@@ -11,6 +11,6 @@ public class SevereViolation {
     private String inclusionDate;        // 列入日期
     private String decisionAuthority;       // 作出决定机关(列入)
     private String reason;                  // 列入严重违法失信企业名单原因
-    private Boolean isHistorical;           // 是否是历史记录
+    private String isHistorical;           // 是否是历史记录
 
 }

+ 51 - 0
src/main/java/org/example/mybatisplus/tools/DocxGenerator.java

@@ -0,0 +1,51 @@
+package org.example.mybatisplus.tools;
+
+import cn.hutool.extra.template.TemplateException;
+import freemarker.template.Configuration;
+import freemarker.template.Template;
+import org.example.mybatisplus.module.*;
+import org.example.mybatisplus.module.vo.*;
+
+import java.io.*;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Base64;
+
+public class DocxGenerator {
+    public static void init(ServiceProviderAuditReport report,String templatePath,String outpath) {
+        // 配置 Freemarker
+        Configuration cfg = new Configuration(Configuration.VERSION_2_3_31);
+        try {
+            // 设置模板文件所在的目录
+            cfg.setClassForTemplateLoading(DocxGenerator.class, "/");
+
+            // 加载模板
+            Template template = cfg.getTemplate(templatePath);
+
+            // 输出文件
+            File outputFile = new File(outpath);
+            try (Writer out = new FileWriter(outputFile)) {
+                // 处理模板并输出到文件
+                template.process(report, out);
+                System.out.println("XML file generated successfully: " + outputFile.getAbsolutePath());
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+        } catch (IOException | TemplateException e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 将图片转换为 Base64 编码
+     * @param imagePath 图片的文件路径
+     * @return Base64 编码的字符串
+     * @throws IOException 读取文件时可能抛出的异常
+     */
+    public static String convertImageToBase64(String imagePath) throws IOException {
+        Path path = Paths.get(imagePath);
+        byte[] imageBytes = Files.readAllBytes(path);
+        return Base64.getEncoder().encodeToString(imageBytes);
+    }
+}

+ 39 - 1
src/main/java/org/example/mybatisplus/tools/WordToPdfUtil.java

@@ -20,7 +20,7 @@ public class WordToPdfUtil {
             String wordFilePath = System.getProperty("user.dir")+File.separator+ "jijinhui.docx";
             String wordExportpath = System.getProperty("user.dir")+File.separator+ "jijinhui1.docx";
             String pdfFilePath =System.getProperty("user.dir")+File.separator+  "download.pdf";
-            wordToPdfUtil.wordToPdf(wordExportpath,pdfFilePath);
+            wordToPdfUtil.wordToPdf("I:\\WechatLog\\WeChat Files\\wxid_ap5s6toz51xy22\\FileStorage\\File\\2025-03\\135.docx",pdfFilePath);
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -73,7 +73,45 @@ public class WordToPdfUtil {
 
         return null;
     }
+    public static String xmlToWord(String wordPath, String pdfPath) throws Exception {
+        FileOutputStream os = null;
+        try {
+            // 从classpath中加载Apose的License文件,以启用无水印转换。
+            // 凭证 不然切换后有水印
+            //InputStream is = new ClassPathResource("/license.xml").getInputStream();
+
+            License aposeLic = new License();
+            //aposeLic.setLicense(is);
+            license = true;
+            // 检查License是否成功加载,如果未成功,则输出错误信息并中止转换。
+            if (!license) {
+                System.out.println("License验证不通过...");
+                return null;
+            }
+            // 创建一个空的PDF文件,准备写入转换后的内容。
+            //生成一个空的PDF文件
+            File file = new File(pdfPath);
+            os = new FileOutputStream(file);
+            // 创建一个Document对象,指定要转换的Word文档路径。
+            //要转换的word文件
+            Document doc = new Document(wordPath);
+            // 将Word文档保存为PDF格式,写入到之前创建的PDF文件中。
+            doc.save(os, SaveFormat.DOCX);
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            // 确保关闭文件输出流。
+            if (os != null) {
+                try {
+                    os.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
 
+        return null;
+    }
 
     /**
      * 将指定文件转换为PDF格式,并添加水印。

File diff suppressed because it is too large
+ 0 - 3702
src/main/resources/jijinhui.xml


BIN
src/main/resources/jijinhui1.zip


Some files were not shown because too many files changed in this diff