From 6d29cd107cc2d75f9cc855174bd5bec3608de527 Mon Sep 17 00:00:00 2001
From: 林致杰 <1003392067@qq.com>
Date: 星期二, 15 三月 2022 18:02:42 +0800
Subject: [PATCH] JAQ表1-表4替换处理

---
 src/main/java/com/ots/common/utils/poi/WordUtil.java |  590 +++++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 490 insertions(+), 100 deletions(-)

diff --git a/src/main/java/com/ots/common/utils/poi/WordUtil.java b/src/main/java/com/ots/common/utils/poi/WordUtil.java
index 34a17cc..f192245 100644
--- a/src/main/java/com/ots/common/utils/poi/WordUtil.java
+++ b/src/main/java/com/ots/common/utils/poi/WordUtil.java
@@ -1,6 +1,10 @@
 package com.ots.common.utils.poi;
 import cn.hutool.core.collection.CollUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.ots.common.enums.ReportTypeEnum;
 import com.ots.common.enums.ReportTypeNameEnum;
+import com.ots.common.enums.TableEnum;
 import com.ots.common.enums.TemplateTypeEnum;
 import com.ots.common.utils.StringUtils;
 import com.ots.framework.config.EssConfig;
@@ -8,69 +12,48 @@
 import com.ots.project.exam.domain.TReportTemplate;
 import com.ots.project.exam.dto.JAQTableStyle;
 import com.ots.project.exam.dto.WordParam;
+import com.ots.project.tool.PdfUtil;
 import com.ots.project.tool.ShellTool;
 import com.ots.project.tool.exam.ExamUtil;
 import com.ots.project.tool.exam.ImageUtil;
 import com.ots.project.tool.exam.ZipUtil;
-import com.ots.project.tool.report.JAQ.condition.Table1;
-import com.ots.project.tool.report.JAQ.condition.Table2;
-import com.ots.project.tool.report.JAQ.condition.Table3;
-import com.ots.project.tool.report.JAQ.condition.Table4;
+import com.ots.project.tool.report.PAQ.chart.PAQChart;
 import org.apache.commons.collections.map.HashedMap;
 import org.apache.poi.ooxml.POIXMLDocument;
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.util.Units;
-import org.apache.poi.xwpf.usermodel.Document;
-import org.apache.poi.xwpf.usermodel.IBodyElement;
-import org.apache.poi.xwpf.usermodel.IRunElement;
-import org.apache.poi.xwpf.usermodel.XWPFChart;
-import org.apache.poi.xwpf.usermodel.XWPFDocument;
-import org.apache.poi.xwpf.usermodel.XWPFHeader;
-import org.apache.poi.xwpf.usermodel.XWPFParagraph;
-import org.apache.poi.xwpf.usermodel.XWPFRun;
-import org.apache.poi.xwpf.usermodel.XWPFTable;
-import org.apache.poi.xwpf.usermodel.XWPFTableCell;
-import org.apache.poi.xwpf.usermodel.XWPFTableRow;
+import org.apache.poi.xwpf.usermodel.*;
 import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlObject;
+import org.dom4j.DocumentException;
 import org.jetbrains.annotations.Nullable;
-import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource;
-import org.openxmlformats.schemas.drawingml.x2006.chart.CTBarChart;
-import org.openxmlformats.schemas.drawingml.x2006.chart.CTBarSer;
-import org.openxmlformats.schemas.drawingml.x2006.chart.CTChart;
-import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource;
-import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumVal;
-import org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea;
-import org.openxmlformats.schemas.drawingml.x2006.chart.CTScatterChart;
-import org.openxmlformats.schemas.drawingml.x2006.chart.CTScatterSer;
+import org.openxmlformats.schemas.drawingml.x2006.chart.*;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTGraphicalObject;
 import org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.CTAnchor;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDrawing;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPPr;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
 import java.awt.image.BufferedImage;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
+import java.io.*;
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 public class WordUtil {
     private static final Logger log = LoggerFactory.getLogger(WordUtil.class);
     public static String tempFilePath = "/Users/shawnli/Downloads/";
     private static String noRunChange = "";
+    private static Map<String, String> colorLabel = new HashMap<String, String>() {{
+        put("<YellowText>", "</YellowText>");
+    }};
+    private static Map<String, String> fontSize = new HashMap<String, String>() {{
+        put("<FontSize_11>", "</FontSize_11>");
+    }};
     public static final int DEFAULT_FONT_SIZE = 10;
     
     public static boolean changWord(String inputUrl, String outputUrl,
@@ -197,6 +180,9 @@
                 if (run.toString().indexOf("%TTime%") != -1) {
                     run.setText(textMap.get("reportGenerationDate").toString(), 0);
                 }
+                if (run.toString().indexOf("%LIBSAQGS0018%") != -1) {
+                    run.setText(textMap.get("LIBSAQGS0018").toString(), 0);
+                }
             }
         }
     }
@@ -256,7 +242,7 @@
         int width = (int) Math.round(bufferedImage.getWidth());
         int height = (int) Math.round(bufferedImage.getHeight());
         int emuSelf = 3000;
-        run.addPicture(in, Document.PICTURE_TYPE_PNG, "TEST",  width * emuSelf, height * emuSelf);
+        run.addPicture(in, Document.PICTURE_TYPE_PNG, "TEST", width * emuSelf, height * emuSelf);
         in.close();
         if (wordParam.isMove()) {
             
@@ -274,7 +260,7 @@
     public static CTAnchor getAnchorWithGraphic(CTGraphicalObject ctGraphicalObject,
                                                 String deskFileName, int width, int height,
                                                 int leftOffset, int topOffset, boolean behind, int topPosition) {
-        long relativeHeight = 251649024l + topPosition;
+        long relativeHeight = 251649024L + topPosition;
         String anchorXML =
                 "<wp:anchor xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" "
                         + "simplePos=\"0\" relativeHeight=\"" + relativeHeight + "\" behindDoc=\"" + ((behind) ? 1 : 0) + "\" locked=\"0\" layoutInCell=\"1\" allowOverlap=\"1\">"
@@ -306,6 +292,13 @@
         List<XWPFTable> tables = document.getTables();
         setTableValue(document, textMap, tables);
     }
+
+    /**
+     * 璁剧疆琛ㄦ牸鍊�
+     * @param document
+     * @param textMap
+     * @param tables
+     */
     private static void setTableValue(XWPFDocument document, Map<String, Object> textMap, List<XWPFTable> tables) {
         for (int i = 0; i < tables.size(); i++) {
             
@@ -313,8 +306,10 @@
             try {
                 XWPFTable table = tables.get(i);
                 if (table.getRows().size() > 0) {
-                    
-                    log.info("琛ㄦ牸鏁版嵁锛�"+ table.getText());
+                    log.info("琛ㄨ鏁�:{}",table.getRows().size());
+                    log.info("琛ㄦ牸鏁版嵁锛�" + table.getText());
+                    //澧炲姞琛ㄦ牸鎴栬�呮笡灏戣〃鏍�
+                    addOrDelTableRow(table,i,textMap);
                     if (checkText(table.getText())) {
                         List<XWPFTableRow> rows = table.getRows();
                         
@@ -326,7 +321,158 @@
             }
         }
     }
-    
+
+    /**
+     * 澧炲姞琛ㄦ牸鎴栬�呮笡灏戣〃鏍�
+     * @param table 琛ㄦ牸
+     * @param index 琛ㄧ储寮�
+     * @param textMap 璧嬪�煎璞�
+     */
+    private static void addOrDelTableRow(XWPFTable table, int index, Map<String, Object> textMap) {
+
+        try {
+            TableEnum tableEnum = TableEnum.codeOf(index);
+            Integer tableNum = Integer.valueOf(textMap.get(tableEnum.getName()).toString());
+            Integer rows = table.getRows().size();
+
+            //琛�1-琛�3 闇�鍓旈櫎琛ㄥご
+            Integer contentRows = rows - 1;
+            //琛�4 闇�鍓旈櫎琛ㄥご璺熷熬閮ㄩ鐣欒鏁�
+            if(tableEnum == TableEnum.table4){
+                contentRows = rows - 6;
+                rows -= 5;
+            }
+
+
+            //闄愬埗琛屾暟涓嶄负绌� 鍜� 闄愬埗琛屾暟璺熸姤鍛婄幇鏈変笉涓�鑷撮渶杩涜澶勭悊
+            if(tableNum != null && !tableNum.equals(contentRows)){
+
+                if(tableNum > contentRows){
+                    //澧炲姞琛屾暟
+                    Integer addRow = tableNum - contentRows;
+                    log.info("{}澧炲姞{}琛�",tableEnum.getName(),addRow);
+                    for (int i = rows; i < rows+addRow; i++) {
+                        addJAQTable(table,tableEnum,i,textMap);
+                    }
+                }else{
+                    //鍑忓皯琛屾暟
+                    Integer delRow = tableNum - rows;
+                    log.info("{}鍑忓皯{}琛屾暟",TableEnum.codeOf(index).getName(),delRow);
+                }
+
+            }
+
+        }catch (Exception e){
+            e.printStackTrace();
+            log.info("琛▄}澧炲姞琛ㄦ牸鎴栬�呮笡灏戣〃鏍煎紓甯�",index+1);
+        }
+    }
+
+    /**
+     * 娣诲姞JAQ琛ㄦ牸
+     * @param tableEnum
+     * @param index
+     */
+    private static void addJAQTable(XWPFTable table,TableEnum tableEnum,Integer index,Map<String, Object> textMap){
+
+        // 鍦ㄨ〃鏍间腑鎸囧畾鐨勪綅缃柊澧炰竴琛�
+        insertRow(table,1,index);
+
+        //XWPFTableRow row = table.createRow();
+        XWPFTableRow row = table.getRows().get(index);
+        List<XWPFTableCell> cells = row.getTableCells();
+        XWPFTableCell cell;
+       /* for (int i = 0; i < cells.size(); i++) {
+            XWPFTableCell cell = cells.get(i);
+            cell.setText("test");
+            log.info(cell.getText());
+        }*/
+        switch (tableEnum){
+            case table1:
+                cell = cells.get(0);
+                cells.get(0).setText(textMap.get("T1rank"+index)+"");
+                cells.get(1).setText(textMap.get("T1com"+index)+"");
+                cells.get(2).setText(textMap.get("T1com"+index+"IF_M")+"");
+                cells.get(3).setText(textMap.get("T1com"+index+"IF_L")+"-"+textMap.get("T1com"+index+"IF_H"));
+                break;
+            case table2:
+                cell = cells.get(0);
+                cells.get(0).setText(textMap.get("T2rank"+index)+"");
+                cells.get(1).setText(textMap.get("T2com"+index)+"");
+                cells.get(2).setText(textMap.get("T2Com"+index+"I_M")+"");
+                cells.get(3).setText(textMap.get("T2com"+index+"I_L")+"-"+textMap.get("T2com"+index+"I_H"));
+                break;
+            case table3:
+                cell = cells.get(0);
+                cells.get(0).setText(textMap.get("T3rank"+index)+"");
+                cells.get(1).setText(textMap.get("T3item"+index)+"");
+                cells.get(2).setText(textMap.get("T3item"+index+"IF_M")+"");
+                cells.get(3).setText(textMap.get("T3com"+index)+"");
+                break;
+            case table4:
+                cell = cells.get(0);
+                cells.get(0).setText("#"+textMap.get("T4rank"+index)+".  "+textMap.get("T4com"+index));
+
+                //瀛愰泦鍚堥暱搴�
+                Integer table4ChildrenNum = Integer.valueOf(textMap.get(TableEnum.table4Children.getName()).toString());
+                StringBuilder sb = new StringBuilder();
+                List<String> str = new ArrayList<>();
+                for (int j = 1; j <= table4ChildrenNum; j++) {
+                    sb.append(textMap.get("T4com"+index+"item"+j)+"\t");
+                    str.add(textMap.get("T4com"+index+"item"+j)+"");
+                }
+
+                //瀵规煇涓崟鍏冩牸璁剧疆娈佃惤锛宻pa
+                XWPFParagraph para = cells.get(1).getParagraphs().get(0);
+                //椤昏璁剧疆锛屼笉鐒朵腑鏂囨崲琛屼細寰堢敓纭緢闅剧湅
+                para.setAlignment(ParagraphAlignment.LEFT);
+
+                for(String text : str){
+                    //瀵规煇涓钀借缃牸寮�
+                    XWPFRun run = para.createRun();
+                    //run.addBreak(BreakType.TEXT_WRAPPING);//鎹㈣
+                    run.setText(text.trim());
+                    //鎹㈣
+                    //run.addBreak();
+                }
+
+                cells.get(1).setText(sb.toString());
+                break;
+        }
+    }
+
+    /**
+     * insertRow 鍦╳ord琛ㄦ牸涓寚瀹氫綅缃彃鍏ヤ竴琛岋紝骞跺皢鏌愪竴琛岀殑鏍峰紡澶嶅埗鍒版柊澧炶
+     * @param copyrowIndex 闇�瑕佸鍒剁殑琛屼綅缃�
+     * @param newrowIndex 闇�瑕佹柊澧炰竴琛岀殑浣嶇疆
+     * */
+    public static void insertRow(XWPFTable table, int copyrowIndex, int newrowIndex) {
+        // 鍦ㄨ〃鏍间腑鎸囧畾鐨勪綅缃柊澧炰竴琛�
+        XWPFTableRow targetRow = table.insertNewTableRow(newrowIndex);
+        // 鑾峰彇闇�瑕佸鍒惰瀵硅薄
+        XWPFTableRow copyRow = table.getRow(copyrowIndex);
+        //澶嶅埗琛屽璞�
+        targetRow.getCtRow().setTrPr(copyRow.getCtRow().getTrPr());
+        //鎴栬闇�瑕佸鍒剁殑琛岀殑鍒�
+        List<XWPFTableCell> copyCells = copyRow.getTableCells();
+        //澶嶅埗鍒楀璞�
+        XWPFTableCell targetCell = null;
+        for (int i = 0; i < copyCells.size(); i++) {
+            XWPFTableCell copyCell = copyCells.get(i);
+            targetCell = targetRow.addNewTableCell();
+            targetCell.getCTTc().setTcPr(copyCell.getCTTc().getTcPr());
+            if (copyCell.getParagraphs() != null && copyCell.getParagraphs().size() > 0) {
+                targetCell.getParagraphs().get(0).getCTP().setPPr(copyCell.getParagraphs().get(0).getCTP().getPPr());
+                if (copyCell.getParagraphs().get(0).getRuns() != null
+                        && copyCell.getParagraphs().get(0).getRuns().size() > 0) {
+                    XWPFRun cellR = targetCell.getParagraphs().get(0).createRun();
+                    cellR.setBold(copyCell.getParagraphs().get(0).getRuns().get(0).isBold());
+                }
+            }
+        }
+
+    }
+
     private static void addTableValue(XWPFDocument document, Map<Integer, Map<Integer, List<String[]>>> autoTableMap) {
         if (Objects.isNull(autoTableMap)) {
             return;
@@ -350,7 +496,7 @@
             }
         }
     }
-    private static void setTableMap(Map<String, Object> tableMap, Map<Integer, List<String[]>> mapRowsMap) {
+   /* private static void setTableMap(Map<String, Object> tableMap, Map<Integer, List<String[]>> mapRowsMap) {
         if (Objects.isNull(tableMap) || tableMap.isEmpty()) {
             return;
         }
@@ -382,24 +528,26 @@
             table4List.add(t.toRow());
         }
         mapRowsMap.put(3, table4List);
-    }
+    }*/
     
     public static void eachTable(List<XWPFTableRow> rows, Map<String, Object> textMap, XWPFDocument document) throws IOException, org.apache.poi.openxml4j.exceptions.InvalidFormatException {
         for (XWPFTableRow row : rows) {
             List<XWPFTableCell> cells = row.getTableCells();
             for (XWPFTableCell cell : cells) {
                 
-
+                //濡傛灉褰撳墠琛ㄦ牸鍖呭惈%灏变唬琛ㄩ渶瑕佹浛鎹�
                 if (checkText(cell.getText())) {
                     List<XWPFParagraph> paragraphs = cell.getParagraphs();
                     for (XWPFParagraph paragraph : paragraphs) {
-                        
+                        //鑾峰彇鎵�鏈夎
                         List<IRunElement> iRunElements = paragraph.getIRuns();
                         List<XWPFRun> runs = new ArrayList<>();
+                        //閬嶅巻鎵�鏈夎
                         for (IRunElement iRunElement : iRunElements) {
                             runs.add((XWPFRun) iRunElement);
                         }
                         int runPosition = 0;
+                        //鏇挎崲鎵�鏈夎〃鏍肩殑鏂囧瓧
                         for (XWPFRun run : runs) {
                             setTextValue(textMap, document, paragraph, runPosition, run);
                         }
@@ -409,7 +557,7 @@
         }
     }
     private static void setTextValue(Map<String, Object> textMap, XWPFDocument document, XWPFParagraph paragraph, int runPosition, XWPFRun run) {
-        System.out.println("琛ㄦ牸鐨勶細" + run.toString());
+        log.info("琛ㄦ牸鐨勶細{}", run.toString());
         try {
             run.setText(changeValue(run.toString(), textMap, run, paragraph, document, runPosition), 0);
         } catch (Exception e) {
@@ -439,16 +587,34 @@
             }
         }
     }
-    
+
+    //鏍¢獙鏂囨湰鏄惁闇�瑕佹浛鎹�
     public static boolean checkText(String text) {
+        //鏇挎崲鏂囨湰鍖呭惈%
         if (text.indexOf("%") != -1 || StringUtils.equals(text, "N/A NONE")) {
-            return true;
+            //鍙湁%澶т簬1 鎵嶉�氳繃
+            if(getCount(text) > 1){
+                return true;
+            }
+            return false;
         }
         return false;
     }
+
+    //鍒ゆ柇%鍑虹幇鐨勬鏁�
+    public static int getCount(String text){
+        //鏃ч暱搴�
+        int oldLength = text.length();
+        text = text.replace("%", "");
+        //鏂伴暱搴�
+        int newLength = text.length();
+        //鍑虹幇娆℃暟 = 鏃ч暱搴� - 鏂伴暱搴�
+        int count = oldLength - newLength;
+        return count;
+    }
     
     public static String changeValue(String runValue, Map<String, Object> textMap, XWPFRun run, XWPFParagraph paragraph, XWPFDocument document, int runPosition) throws IOException, org.apache.poi.openxml4j.exceptions.InvalidFormatException {
-        
+        log.debug("changeText:{}",runValue);
         Set<Map.Entry<String, Object>> textSets = textMap.entrySet();
         for (Map.Entry<String, Object> textSet : textSets) {
             
@@ -466,7 +632,11 @@
                 if (runValue.indexOf("<BoldText>") != -1) {
                     return setOtherStyle(runValue, paragraph, runPosition, run);
                 }
-                break;
+                //鏈変簺琛ㄦ牸鍙兘瀛樺湪澶氫釜瀛楀吀 闇�鏇挎崲澶氭涓嶈兘杞绘槗break
+                //娌℃湁鍙浛鎹㈠唴瀹圭洿鎺reak
+                if(getTextSize(runValue) == 0){
+                    break;
+                }
             }
         }
         
@@ -497,6 +667,7 @@
                     insertRun.setText(originalRunStr);
                     insertRun.setBold(oldRun.isBold());
                     insertRun.setColor(oldRun.getColor());
+                    insertRun.setFontFamily(oldRun.getFontFamily());
                     int fontSize = oldRun.getFontSize();
                     insertRun.setFontSize((fontSize == -1) ? DEFAULT_FONT_SIZE : fontSize);
                 }
@@ -507,12 +678,24 @@
                 if (StringUtils.isNotEmpty(newRunStr)) {
                     newRunStr = newRunStr.replaceAll("<BoldText>", "");
                     newRunStr = newRunStr.replaceAll("</BoldText>", "");
+                    
+                    String rgbStr = getRGBStr(newRunStr, oldRun);
+                    if (rgbStr == null) {
+                        rgbStr = oldRun.getColor();
+                    }
+                    
+                    int fontSize = getFontSize(newRunStr, oldRun);
+                    if (fontSize == -1) {
+                        fontSize = oldRun.getFontSize();
+                    }
+                    newRunStr = getfinalStr(newRunStr);
                     stringList.add(newRunStr);
                     XWPFRun insertRun = paragraph.insertNewRun(runPosition++);
                     insertRun.setText(newRunStr);
                     insertRun.setBold(true);
-                    insertRun.setColor(oldRun.getColor());
-                    int fontSize = oldRun.getFontSize();
+                    insertRun.setColor(rgbStr);
+                    String fontFamily = oldRun.getFontFamily();
+                    insertRun.setFontFamily(fontFamily);
                     insertRun.setFontSize((fontSize == -1) ? DEFAULT_FONT_SIZE : fontSize);
                 }
                 pointer = position;
@@ -522,6 +705,7 @@
                 insertRun.setText(runValue.substring(pointer, end));
                 insertRun.setBold(oldRun.isBold());
                 insertRun.setColor(oldRun.getColor());
+                insertRun.setFontFamily(oldRun.getFontFamily());
                 int fontSize = oldRun.getFontSize();
                 insertRun.setFontSize((fontSize == -1) ? DEFAULT_FONT_SIZE : fontSize);
                 pointer = end;
@@ -531,38 +715,71 @@
         paragraph.removeRun(runPosition);
         return "NoChangValue";
     }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+    private static int getFontSize(String newRunStr, XWPFRun oldRun) {
+        int font = -1;
+        for (String lab : fontSize.keySet()) {
+            if (newRunStr.contains(lab)) {
+                int fontSize = getFontSize(lab);
+                if (fontSize != -1) {
+                    font = fontSize;
+                    break;
+                }
+            }
+        }
+        return font;
+    }
+    private static int getFontSize(String lab) {
+        int font = -1;
+        int index = lab.indexOf("_");
+        String size = lab.substring(index + 1, lab.length() - 1);
+        try{
+            font = Integer.parseInt(size);
+        }catch (Exception e){}
+        return font;
+    }
+    private static String getfinalStr(String newRunStr) {
+        String result = newRunStr;
+        for (String lab : colorLabel.keySet()) {
+            if (newRunStr.contains(lab)) {
+                newRunStr = newRunStr.replaceAll(lab, "");
+                newRunStr = newRunStr.replaceAll(colorLabel.get(lab), "");
+                result = newRunStr;
+            }
+        }
+        for (String lab : fontSize.keySet()) {
+            if (newRunStr.contains(lab)) {
+                newRunStr = newRunStr.replaceAll(lab, "");
+                newRunStr = newRunStr.replaceAll(fontSize.get(lab), "");
+                result = newRunStr;
+            }
+        }
+        return result;
+    }
+    private static String getRGBStr(String newRunStr, XWPFRun oldRun) {
+        String rgbStr = null;
+        for (String lab : colorLabel.keySet()) {
+            if (newRunStr.contains(lab)) {
+                String colorByLab = getColorByLab(lab);
+                if (colorByLab != null) {
+                    rgbStr = colorByLab;
+                    break;
+                }
+            }
+        }
+        return rgbStr;
+    }
+    private static String getColorByLab(String lab) {
+        String rgbStr = null;
+        switch (lab) {
+            case "<YellowText>":
+                rgbStr = "ff9900";
+                break;
+            default:
+                rgbStr = "000000";
+                break;
+        }
+        return rgbStr;
+    }
 
 
     private static void changOtherPicture(XWPFParagraph paragraph) {
@@ -694,10 +911,15 @@
             setChageWord(fileName, out, textMap, tReportTemplate.getReportType(), templateType, autoTableMap);
             out.flush();
             changColorIfJAQ(textMap, out, reportName, tReportTemplate.getReportType());
-            ShellTool.execLibreofficeCommand("pdf", EssConfig.getProfile() + "/" + reportName, EssConfig.getProfile() + "/");
+            //PAQ閲囩敤鏂扮殑doc杞琾df
+            if(!ReportTypeEnum.PAQ.getCode().equals(reportType)){
+                ShellTool.execLibreofficeCommand("pdf", EssConfig.getProfile() + "/" + reportName, EssConfig.getProfile() + "/");
+            }else{
+                PdfUtil.convertPDF(EssConfig.getProfile() + "/" + reportName);
+            }
             zipFilePath = getPdfPath(reportName);
             
-             deleteFileStrList.add(EssConfig.getProfile() + "/" + reportName);
+            deleteFileStrList.add(EssConfig.getProfile() + "/" + reportName);
         } catch (Exception ex) {
             returnMessage = returnMessage + ex.getMessage();
             deleteFileStrList.add(EssConfig.getProfile() + "/" + reportName);
@@ -717,7 +939,7 @@
     }
     private static void changColorIfJAQ(Map<String, Object> textMap, FileOutputStream out, String reportName, String reportType) throws IOException {
         if (Objects.equals(reportType, "JAQ")) {
-            changTableColor(reportName, out, (List<JAQTableStyle>)textMap.get("JAQTableStyle"));
+            changTableColor(reportName, out, (List<JAQTableStyle>) textMap.get("JAQTableStyle"));
         }
     }
     private static String getTypeIfIsSAQ(TReportTemplate tReportTemplate, String reportType) {
@@ -727,7 +949,7 @@
         return reportType;
     }
     private static String getPdfPath(String reportName) {
-        return reportName.substring(0,reportName.lastIndexOf(".")) + ".pdf";
+        return reportName.substring(0, reportName.lastIndexOf(".")) + ".pdf";
     }
     public static void deleteFileByStr(List<String> deleteFileStrList) {
         
@@ -772,19 +994,84 @@
         }
         return new FileOutputStream(outFile);
     }
-    private static void setChageWord(String fileName, OutputStream out, Map<String, Object> textMap, String reportType, String templateType, Map<Integer, Map<Integer, List<String[]>>> autoTableMap) throws IOException, org.apache.poi.openxml4j.exceptions.InvalidFormatException {
+    private static void setChageWord(String fileName, OutputStream out, Map<String, Object> textMap, String reportType, String templateType, Map<Integer, Map<Integer, List<String[]>>> autoTableMap) throws IOException, org.apache.poi.openxml4j.exceptions.InvalidFormatException, DocumentException {
         String filePath = getTemplateDownLoadPathByUpLoad(fileName);
         
         XWPFDocument document = new XWPFDocument(POIXMLDocument.openPackage(getTemplateDownLoadPathByUpLoad(fileName)));
-        
+
+        //璁剧疆鏂囨湰
         changeText(document, textMap);
-        
+
+        //璁剧疆鏂囨湰妗�
+        changeTextBox(document, textMap);
+
+        //璁剧疆鍥捐〃
+        if (Objects.equals(reportType, ReportTypeEnum.PAQ.getCode())) {
+            PAQChart.changeChart(document, textMap);
+        }
+
+        //鎻掑叆琛ㄦ牸
         addTableValue(document, autoTableMap);
-        
+
+        //鏇存敼琛ㄦ牸鐨勫��
         changeTable(document, textMap);
-        
+
+        //璁剧疆鍥捐〃鎺т欢
         changChar(textMap, document, reportType, templateType);
         document.write(out);
+    }
+    private static void changeTextBox(XWPFDocument document, Map<String, Object> textMap) throws DocumentException {
+        List<XWPFParagraph> paragraphs = document.getParagraphs();
+        
+        for (XWPFParagraph paragraph : paragraphs) {
+            CTR[] rArray = paragraph.getCTP().getRArray();
+            for (XmlObject ctr : rArray) {
+                Node domNode = ctr.getDomNode();
+                setTextVal(domNode, textMap);
+            }
+        }
+    }
+    private static void setTextVal(Node node, Map<String, Object> textMap) {
+        if ("w:t".equalsIgnoreCase(node.getNodeName())) {
+            Node wtItem = node.getChildNodes().item(0);
+            if (wtItem != null) {
+                wtItem.setNodeValue(getValByKey(wtItem.getNodeValue(), textMap));
+            }
+            return;
+        }
+        NodeList childNodes = node.getChildNodes();
+        for (int i = 0; i < childNodes.getLength(); i++) {
+            setTextVal(childNodes.item(i), textMap);
+        }
+    }
+    private static String getValByKey(String text, Map<String, Object> textMap) {
+        log.debug("changeTextBox:{}",text);
+        if (!checkText(text)) {
+            return text;
+        }
+        String repText = "";
+        Set<Map.Entry<String, Object>> textSets = textMap.entrySet();
+        for (Map.Entry<String, Object> textSet : textSets) {
+            
+            String key = "%" + textSet.getKey() + "%";
+            if (text.indexOf(key) != -1) {
+                text = text.replaceAll(key, (String) textMap.get(textSet.getKey()));
+                repText = text;
+                if (checkText(text)) {
+                    continue;
+                } else {
+                    break;
+                }
+            }
+        }
+        if (repText.indexOf("<BoldText>") != -1) {
+            repText = repText.replaceAll("<BoldText>", "");
+            repText = repText.replaceAll("</BoldText>", "");
+        }
+        if (repText.indexOf("N/A NONE") != -1) {
+            repText = repText.replaceAll("N/A NONE", "");
+        }
+        return repText;
     }
     public static void changTableColor(String fileName, OutputStream out, List<JAQTableStyle> jaqTableStyleList) throws IOException {
         if (StringUtils.isEmpty(fileName) || CollUtil.isEmpty(jaqTableStyleList)) {
@@ -814,6 +1101,14 @@
         document.write(out);
         out.flush();
     }
+
+    /**
+     * 璁剧疆鍥炬爣鎺т欢
+     * @param textMap
+     * @param document
+     * @param reportType
+     * @param templateType
+     */
     private static void changChar(Map<String, Object> textMap, XWPFDocument document, String reportType, String templateType) {
         if (StringUtils.isEmpty(reportType) || StringUtils.isEmpty(templateType)) {
             return;
@@ -822,13 +1117,55 @@
         if (ExamUtil.isListEmpty(charts)) {
             return;
         }
-        if (StringUtils.equals(reportType, "MAQ")) {
-            
+        if (StringUtils.equals(reportType, ReportTypeEnum.MAQ.getCode())) {
             setMAQCompleteChars(textMap, charts);
-        } else if (StringUtils.equals(reportType, "RuiLin")){
+        } else if (StringUtils.equals(reportType, ReportTypeEnum.MAQV2.getCode()) || StringUtils.equals(reportType, ReportTypeEnum.MAQIAR.getCode())) {
+            setMAQ_V2CompleteChars(textMap, charts);
+        } else if (StringUtils.equals(reportType, ReportTypeEnum.RuiLin.getCode())) {
             setRuiLinChar(textMap, charts);
         } else {
             return;
+        }
+    }
+    private static void setMAQ_V2CompleteChars(Map<String, Object> textMap, List<XWPFChart> charts) {
+        String p_Task31 = textMap.get("P_Task31").toString();
+        String p_People32 = textMap.get("P_People32").toString();
+        String P_INCON25 = textMap.get("P_INCON25").toString();
+        String P_IM24 = textMap.get("P_IM24").toString();
+        String P_SDE23 = textMap.get("P_SDE23").toString();
+        
+        for (XWPFChart xwpfChart : charts) {
+            try {
+                CTChart ctChart = xwpfChart.getCTChart();
+                CTPlotArea ctPlotArea = ctChart.getPlotArea();
+                List<CTScatterChart> scatterChartList = ctPlotArea.getScatterChartList();
+                List<CTBarChart> barChartList = ctPlotArea.getBarChartList();
+                if (scatterChartList.size() != 0 && barChartList.size() != 0) {
+                    CTScatterChart ctScatterChart = scatterChartList.get(0);
+                    CTScatterSer ctScatterSer = ctScatterChart.getSerList().get(0);
+                    CTAxDataSource xVal = ctScatterSer.getXVal();
+                    List<CTNumVal> ptList = xVal.getNumRef().getNumCache().getPtList();
+                    ptList.get(0).setV(P_INCON25);
+                    ptList.get(1).setV(P_IM24);
+                    ptList.get(2).setV(P_SDE23);
+                } else if (scatterChartList.size() != 0 && barChartList.size() == 0) {
+                    CTScatterChart ctScatterChart = scatterChartList.get(0);
+                    CTScatterSer ctScatterSer = ctScatterChart.getSerList().get(0);
+                    CTAxDataSource xVal = ctScatterSer.getXVal();
+                    CTNumDataSource yVal = ctScatterSer.getYVal();
+                    xVal.getNumRef().getNumCache().getPtList().get(0).setV(p_Task31);
+                    yVal.getNumRef().getNumCache().getPtList().get(0).setV(p_People32);
+                } else if (barChartList.size() != 0) {
+                    CTBarChart ctBarChart = barChartList.get(0);
+                    List<CTBarSer> serList = ctBarChart.getSerList();
+                    CTBarSer ctBarSer = serList.get(0);
+                    CTNumDataSource val = ctBarSer.getVal();
+                    val.getNumRef().getNumCache().getPtList().get(0).setV(p_People32);
+                    val.getNumRef().getNumCache().getPtList().get(1).setV(p_Task31);
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
         }
     }
     private static void setRuiLinChar(Map<String, Object> textMap, List<XWPFChart> charts) {
@@ -1101,4 +1438,57 @@
             textMap.put("JAQTableStyle", jaqTableStyleList);
         }
     }
+
+    public static int getTextSize(String runValue){
+        Pattern pattern = Pattern.compile("%\\w+%");
+        Matcher matcher = pattern.matcher(runValue);
+        List<String> result = new ArrayList<>();
+        while(matcher.find()){
+            result.add(matcher.group());
+        }
+        return result.size();
+    }
+
+
+    public static void main(String[] args) {
+/*        if (!checkText("浜烘墠閫夋嫈鐨勭洰鐨勫氨鏄壘鍒拌兘澶熻儨浠诲伐浣溿�佹効鎰忔壙鎷呭伐浣滐紝涓斾笌缁勭粐鐨勯渶姹傘�佹枃鍖栥�佷环鍊艰鐩稿尮閰嶇殑浜恒�侾AQ鎶ュ憡鏄牴鎹�欓�変汉瀵筆AQ闂嵎涓鐩殑浣滅瓟淇℃伅鑰岀敓鎴愮殑锛屾祴閲忕殑鏄�欓�変汉鍦ㄥ伐浣滀腑鍋忓ソ鐨勮涓洪鏍笺�侾AQ涔熷寘鎷簡瀵逛綔绛旂湡瀹炴�х殑娴嬮噺锛屽悓鏃朵篃瑁呭叆浜員AI涓撴湁鐨勪綔鍋囬槻鑼冪▼搴忥紝鍙互鏈夋晥闄嶄綆鍊欓�変汉鐨勪吉瑁呭ソ鍊惧悜锛堝叏鐞�30%鐨勮嚜璇勯棶鍗蜂腑閮藉嚭鐜颁簡浼濂界幇璞★級銆�")) {
+            System.out.println("11");
+        }*/
+
+        try {
+            InputStream is = new FileInputStream("C:\\Users\\澶уご\\Desktop\\JAQ涓枃鐗�.docx");
+            XWPFDocument document = new XWPFDocument(is);
+
+            String result = "{\"T3Line21C\":\"1\",\"T4com8item1\":\"JAQ0127\",\"T1com8IF_H\":\"12.92\",\"T4com8item3\":\"JAQ0046\",\"T4com8item2\":\"JAQ0108\",\"T1com8IF_L\":\"12.16\",\"T1com8IF_M\":\"12.54\",\"T3item2\":\"JAQ0092\",\"T2com1I_L\":\"3.80\",\"T3item3\":\"JAQ0019\",\"T3item4\":\"JAQ0027\",\"T3item5\":\"JAQ0021\",\"T3item6\":\"JAQ0044\",\"T3item7\":\"JAQ0045\",\"T2Com13I_M\":\"3.40\",\"T3item8\":\"JAQ0105\",\"T3item9\":\"JAQ0002\",\"T2com1I_H\":\"4.20\",\"T3item3IF_M\":\"18.00\",\"T3Line10C\":\"0\",\"T3Line22C\":\"0\",\"T1com15IF_H\":\"15.20\",\"T1com15IF_L\":\"7.28\",\"T3Line9C\":\"0\",\"T1com1IF_M\":\"15.62\",\"T1com15IF_M\":\"11.24\",\"T1com1IF_L\":\"14.44\",\"T2com6I_L\":\"3.60\",\"T1com1IF_H\":\"16.80\",\"T1com4IF_M\":\"14.78\",\"T1com4IF_L\":\"14.44\",\"T3Line11C\":\"0\",\"T2com6I_H\":\"4.00\",\"T1com4IF_H\":\"15.12\",\"T3item16IF_M\":\"16.00\",\"T3com18\":\"23. 婵�鍔变粬浜篭",\"T4com6item1\":\"JAQ0049\",\"T3com17\":\"11. 瀹㈡埛瀵煎悜锛堝唴閮ㄥ拰澶栭儴锛塡",\"T4com6item3\":\"JAQ0135\",\"T3com19\":\"14. 鍒ゆ柇鍜屽喅绛朶",\"T4com6item2\":\"JAQ0025\",\"T3Line8C\":\"0\",\"T3com10\":\"20. 鎺堟潈\",\"T3item13IF_M\":\"16.00\",\"T3com12\":\"19. 浜哄憳閰嶇疆涓庝汉鎵嶅煿鍏籠",\"T3com11\":\"1. 閫傚簲鎬у拰鍙橀潻绠$悊\",\"T3com14\":\"15. 璁″垝鍜岀粍缁嘰",\"T3Line23C\":\"0\",\"T3com13\":\"20. 鎺堟潈\",\"T3com16\":\"23. 婵�鍔变粬浜篭",\"T3com15\":\"18. 绠$悊浠栦汉\",\"T1com11IF_L\":\"10.88\",\"T1com11IF_M\":\"11.90\",\"T1com11IF_H\":\"12.92\",\"T2com14I_H\":\"3.40\",\"T2com1\":\"1. 閫傚簲鎬у拰鍙橀潻绠$悊\",\"T2com2\":\"20. 鎺堟潈\",\"T3Line6C\":\"0\",\"T2com9\":\"6. 鍘嬪姏蹇嶅彈-鎯呯华闊ф�",\"T2com7\":\"15. 璁″垝鍜岀粍缁嘰",\"T2com8\":\"19. 浜哄憳閰嶇疆涓庝汉鎵嶅煿鍏籠",\"T2com5\":\"5. 缂滃瘑鎬",\"T3item7IF_M\":\"18.00\",\"T3Line7C\":\"0\",\"T2com6\":\"9. 鍚岀悊蹇僜",\"T2Com14I_M\":\"3.40\",\"T3item24IF_M\":\"16.00\",\"T2com3\":\"23. 婵�鍔变粬浜篭",\"T2Com5I_M\":\"3.80\",\"T2com4\":\"11. 瀹㈡埛瀵煎悜锛堝唴閮ㄥ拰澶栭儴锛塡",\"T2com14I_L\":\"3.40\",\"T3Line12C\":\"0\",\"T3Line24C\":\"1\",\"T2com15I_H\":\"3.80\",\"T2com15I_L\":\"2.60\",\"T1com4\":\"1. 閫傚簲鎬у拰鍙橀潻绠$悊\",\"T4com2item2\":\"JAQ0089\",\"T1com5\":\"9. 鍚岀悊蹇僜",\"T4com2item3\":\"JAQ0129\",\"T1com6\":\"5. 缂滃瘑鎬",\"T1com7\":\"8. 鍥㈤槦鍗忎綔\",\"T4com2item1\":\"JAQ0105\",\"T1com8\":\"19. 浜哄憳閰嶇疆涓庝汉鎵嶅煿鍏籠",\"T1com9\":\"6. 鍘嬪姏蹇嶅彈-鎯呯华闊ф�",\"T2Com6I_M\":\"3.80\",\"T1com1\":\"23. 婵�鍔变粬浜篭",\"T1com2\":\"20. 鎺堟潈\",\"T1com3\":\"11. 瀹㈡埛瀵煎悜锛堝唴閮ㄥ拰澶栭儴锛塡",\"T2Line9C\":\"0\",\"T1com7IF_H\":\"17.60\",\"T2com5I_H\":\"4.00\",\"T1com7IF_M\":\"12.70\",\"T3Line13C\":\"0\",\"T1com7IF_L\":\"7.80\",\"T3Line25C\":\"0\",\"T2com5I_L\":\"3.60\",\"T1com2IF_M\":\"15.56\",\"T1com2IF_L\":\"14.40\",\"T1com2IF_H\":\"16.72\",\"琛�4瀛愰泦鍚圽":\"3\",\"T2rank1\":\"1\",\"T3item4IF_M\":\"18.00\",\"T3item27IF_M\":\"16.00\",\"T2rank3\":\"3\",\"T3com21\":\"12. 鍒嗘瀽鍜屾壒鍒ゆ�ф�濈淮\",\"T2rank2\":\"2\",\"T3com20\":\"5. 缂滃瘑鎬",\"T2rank5\":\"5\",\"T3com23\":\"6. 鍘嬪姏蹇嶅彈-鎯呯华闊ф�",\"T2rank4\":\"4\",\"T3com22\":\"3. 涓诲姩鎬",\"T2rank7\":\"7\",\"T3com25\":\"11. 瀹㈡埛瀵煎悜锛堝唴閮ㄥ拰澶栭儴锛塡",\"T2rank6\":\"6\",\"T3com24\":\"2. 瀛︿範鏁忛攼搴",\"T2rank9\":\"9\",\"T3Line14C\":\"0\",\"T3com27\":\"20. 鎺堟潈\",\"T2rank8\":\"8\",\"T3com26\":\"1. 閫傚簲鎬у拰鍙橀潻绠$悊\",\"T3Line26C\":\"0\",\"T3item23IF_M\":\"16.00\",\"T3item27\":\"JAQ0076\",\"T3item26\":\"JAQ0113\",\"T3item25\":\"JAQ0107\",\"T3item24\":\"JAQ0065\",\"T3item23\":\"JAQ0064\",\"T1rank9\":\"9\",\"T3item22\":\"JAQ0068\",\"T3item21\":\"JAQ0052\",\"T3item20\":\"JAQ0049\",\"T1rank6\":\"6\",\"T1com3IF_M\":\"14.88\",\"T1rank5\":\"5\",\"T1com3IF_L\":\"12.96\",\"T1rank8\":\"8\",\"T1rank7\":\"7\",\"T1rank2\":\"2\",\"T1rank1\":\"1\",\"T2Com15I_M\":\"3.20\",\"T1rank4\":\"4\",\"T1rank3\":\"3\",\"T3Line27C\":\"0\",\"琛�1\":\"15\",\"琛�2\":\"15\",\"琛�3\":\"27\",\"琛�4\":\"10\",\"T1com3IF_H\":\"16.80\",\"T3Line15C\":\"1\",\"T4com1item3\":\"JAQ0023\",\"T3item8IF_M\":\"18.00\",\"T3item17IF_M\":\"16.00\",\"T4com7item3\":\"JAQ0003\",\"T3item19\":\"JAQ0033\",\"T3item18\":\"JAQ0023\",\"T4com7item1\":\"JAQ0001\",\"T3item12IF_M\":\"16.00\",\"T3item17\":\"JAQ0020\",\"T4com7item2\":\"JAQ0042\",\"T3item16\":\"JAQ0133\",\"T3item15\":\"JAQ0012\",\"T1com12IF_M\":\"11.58\",\"T3item14\":\"JAQ0131\",\"T3item13\":\"JAQ0129\",\"T3item12\":\"JAQ0127\",\"T3item11\":\"JAQ0006\",\"T3item10\":\"JAQ0089\",\"T4com10\":\"24. 缁勭粐鏁忛攼搴",\"T3item1\":\"JAQ0128\",\"T1com12IF_H\":\"12.96\",\"T1com12IF_L\":\"10.20\",\"T2Com10I_M\":\"3.50\",\"T2com10I_H\":\"4.40\",\"T3Line16C\":\"0\",\"T2Com1I_M\":\"4.00\",\"T2com4I_H\":\"4.20\",\"T2com10I_L\":\"2.60\",\"T4com1item2\":\"JAQ0133\",\"T2com4I_L\":\"3.60\",\"T4com1item1\":\"JAQ0019\",\"T1com13IF_H\":\"12.92\",\"T2Line4C\":\"0\",\"T3item5IF_M\":\"18.00\",\"T2com11I_H\":\"3.60\",\"T3Line1C\":\"0\",\"T4com9item3\":\"JAQ0114\",\"T4rank10\":\"10\",\"T1com13IF_L\":\"10.20\",\"T1com13IF_M\":\"11.56\",\"T3Line17C\":\"0\",\"T2Com2I_M\":\"4.00\",\"T2com11I_L\":\"3.40\",\"T2com9I_L\":\"3.00\",\"T4com9item1\":\"JAQ0064\",\"T4com9item2\":\"JAQ0050\",\"T2com9I_H\":\"4.00\",\"T2Line5C\":\"0\",\"T3item26IF_M\":\"16.00\",\"T4com10item3\":\"JAQ0079\",\"T2Com7I_M\":\"3.60\",\"T2Line6C\":\"0\",\"T3Line18C\":\"0\",\"T2com12\":\"24. 缁勭粐鏁忛攼搴",\"T2com13\":\"16. 鍒涢�犳�",\"T2com14\":\"25. 鍟嗕笟涓庢垬鐣ユ晱閿愬害\",\"T2Line11C\":\"0\",\"T2com15\":\"3. 涓诲姩鎬",\"T3rank27\":\"27\",\"T2com10\":\"8. 鍥㈤槦鍗忎綔\",\"T2com11\":\"14. 鍒ゆ柇鍜屽喅绛朶",\"T4com5item3\":\"JAQ0097\",\"T4com5item1\":\"JAQ0044\",\"T4com5item2\":\"JAQ0004\",\"T4com3\":\"11. 瀹㈡埛瀵煎悜锛堝唴閮ㄥ拰澶栭儴锛塡",\"T4com4\":\"1. 閫傚簲鎬у拰鍙橀潻绠$悊\",\"T4com1\":\"23. 婵�鍔变粬浜篭",\"T3item9IF_M\":\"18.00\",\"T3item22IF_M\":\"16.00\",\"T4com2\":\"20. 鎺堟潈\",\"T4com7\":\"8. 鍥㈤槦鍗忎綔\",\"T3item2IF_M\":\"18.00\",\"T4com8\":\"19. 浜哄憳閰嶇疆涓庝汉鎵嶅煿鍏籠",\"T4com5\":\"9. 鍚岀悊蹇僜",\"T2Com8I_M\":\"3.60\",\"T2Com11I_M\":\"3.50\",\"T4com6\":\"5. 缂滃瘑鎬",\"T2com3I_H\":\"4.20\",\"T3rank22\":\"22\",\"T3rank21\":\"21\",\"T3rank20\":\"20\",\"T4com9\":\"6. 鍘嬪姏蹇嶅彈-鎯呯华闊ф�",\"T2Line7C\":\"0\",\"T3Line19C\":\"0\",\"T2com3I_L\":\"3.80\",\"T3rank26\":\"26\",\"T3rank25\":\"25\",\"T3rank24\":\"24\",\"T3rank23\":\"23\",\"T2Line10C\":\"0\",\"T1com6IF_M\":\"13.00\",\"T1com6IF_L\":\"10.80\",\"T3item18IF_M\":\"16.00\",\"T1com6IF_H\":\"15.20\",\"T3item11IF_M\":\"16.00\",\"T2Line8C\":\"0\",\"T2com8I_L\":\"3.40\",\"T1com9IF_M\":\"12.10\",\"T3rank1\":\"1\",\"T2com8I_H\":\"3.80\",\"T3rank2\":\"2\",\"T3item10IF_M\":\"18.00\",\"T1com14IF_M\":\"11.40\",\"T1com14IF_L\":\"8.40\",\"T3rank9\":\"9\",\"T3Line5C\":\"0\",\"T3rank7\":\"7\",\"T3rank8\":\"8\",\"T3rank5\":\"5\",\"T3rank6\":\"6\",\"T3rank3\":\"3\",\"T3rank4\":\"4\",\"T4rank7\":\"7\",\"T4rank6\":\"6\",\"T4rank5\":\"5\",\"T4rank4\":\"4\",\"T4com3item3\":\"JAQ0107\",\"T4com3item2\":\"JAQ0020\",\"T4rank9\":\"9\",\"T4com3item1\":\"JAQ0045\",\"T4rank8\":\"8\",\"T3item6IF_M\":\"18.00\",\"T1com14IF_H\":\"14.40\",\"T4rank3\":\"3\",\"T2Line13C\":\"0\",\"T4rank2\":\"2\",\"T4rank1\":\"1\",\"T3rank19\":\"19\",\"T2Line1C\":\"0\",\"T3rank18\":\"18\",\"T2Line12C\":\"0\",\"T3rank17\":\"17\",\"T3rank16\":\"16\",\"T2com12I_H\":\"4.00\",\"T3Line4C\":\"0\",\"T3item20IF_M\":\"16.00\",\"T2Com12I_M\":\"3.50\",\"T2Com3I_M\":\"4.00\",\"T3item14IF_M\":\"16.00\",\"T3rank11\":\"11\",\"T3rank10\":\"10\",\"T2com2I_H\":\"4.40\",\"T1com9IF_H\":\"15.20\",\"T2com12I_L\":\"3.00\",\"T3rank15\":\"15\",\"T3rank14\":\"14\",\"T2com2I_L\":\"3.60\",\"T3rank13\":\"13\",\"T1com9IF_L\":\"9.00\",\"T3rank12\":\"12\",\"T2rank14\":\"14\",\"T2rank13\":\"13\",\"T2rank15\":\"15\",\"T2rank10\":\"10\",\"T2com13I_H\":\"4.00\",\"T3item15IF_M\":\"16.00\",\"T2Line2C\":\"0\",\"T2rank12\":\"12\",\"T2rank11\":\"11\",\"T3Line3C\":\"0\",\"T1com10IF_M\":\"12.10\",\"T1com10IF_L\":\"9.00\",\"T2Com4I_M\":\"3.90\",\"T4com10item2\":\"JAQ0014\",\"T1com10IF_H\":\"15.20\",\"T4com10item1\":\"JAQ0027\",\"T2com13I_L\":\"2.80\",\"T3item25IF_M\":\"16.00\",\"T3item1IF_M\":\"18.00\",\"T3item21IF_M\":\"16.00\",\"T2com7I_L\":\"3.40\",\"T2Line15C\":\"1\",\"T3com6\":\"9. 鍚岀悊蹇僜",\"T3com7\":\"11. 瀹㈡埛瀵煎悜锛堝唴閮ㄥ拰澶栭儴锛塡",\"T3Line20C\":\"0\",\"T2com7I_H\":\"3.80\",\"T3com8\":\"20. 鎺堟潈\",\"T3com9\":\"15. 璁″垝鍜岀粍缁嘰",\"T3com2\":\"16. 鍒涢�犳�",\"T3com3\":\"23. 婵�鍔变粬浜篭",\"T3com4\":\"24. 缁勭粐鏁忛攼搴",\"T2Line3C\":\"0\",\"T3com5\":\"1. 閫傚簲鎬у拰鍙橀潻绠$悊\",\"T1rank15\":\"15\",\"T1rank14\":\"14\",\"T1rank13\":\"13\",\"T1rank12\":\"12\",\"T1rank11\":\"11\",\"T1rank10\":\"10\",\"T3Line2C\":\"0\",\"T1com5IF_H\":\"15.20\",\"T1com10\":\"24. 缁勭粐鏁忛攼搴",\"T1com11\":\"25. 鍟嗕笟涓庢垬鐣ユ晱閿愬害\",\"T2Com9I_M\":\"3.50\",\"T1com12\":\"14. 鍒ゆ柇鍜屽喅绛朶",\"T1com13\":\"15. 璁″垝鍜岀粍缁嘰",\"T1com14\":\"16. 鍒涢�犳�",\"T1com15\":\"26. 姝g洿銆佷俊浠诲拰鍏俊鍔沑",\"T3item19IF_M\":\"16.00\",\"T1com5IF_M\":\"13.72\",\"T3com1\":\"1. 閫傚簲鎬у拰鍙橀潻绠$悊\",\"T4com4item1\":\"JAQ0128\",\"T1com5IF_L\":\"12.24\",\"T2Line14C\":\"0\",\"T4com4item2\":\"JAQ0021\",\"T4com4item3\":\"JAQ0006\"}";
+
+            JSONObject jsonObject = JSONObject.parseObject(result);
+            //json瀵硅薄杞琈ap
+            Map<String,Object> textMap = jsonObject;
+
+/*            Map<Integer,Map<Integer, List<String[]>>> autoTableMap = new HashMap<>();
+            Map<Integer,List<String[]>> map = new HashMap<>();
+            String[] arr = new String[]{"1","2","3","4"};
+            String[] arr1 = new String[]{"1","2","3","4"};
+            List<String[]> list = new ArrayList<>();
+            list.add(arr);
+            list.add(arr1);
+            map.put(0,list);
+
+            autoTableMap.put(0,map);
+
+            //鎻掑叆琛ㄦ牸
+            addTableValue(document, autoTableMap);*/
+
+            //鏇存敼琛ㄦ牸鐨勫��
+            changeTable(document, textMap);
+
+            //寤虹珛鏂囦欢瀵硅薄
+            File file = new File("C:\\Users\\澶уご\\Desktop\\JAQ涓枃鐗�1.docx");
+            FileOutputStream out = new FileOutputStream(file);
+            document.write(out);
+            out.flush();
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+    }
 }

--
Gitblit v1.9.1