From 926c728f25e7f003c56260f6293b35d9ecf39e81 Mon Sep 17 00:00:00 2001
From: 林致杰 <1003392067@qq.com>
Date: 星期一, 22 十一月 2021 17:45:58 +0800
Subject: [PATCH] MAQ_IAR导出报告兼容

---
 src/main/java/com/ots/common/utils/poi/WordUtil.java |   59 ++++++++++++++++++++++-------------------------------------
 1 files changed, 22 insertions(+), 37 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 8ca167f..85c5913 100644
--- a/src/main/java/com/ots/common/utils/poi/WordUtil.java
+++ b/src/main/java/com/ots/common/utils/poi/WordUtil.java
@@ -18,6 +18,7 @@
 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 com.ots.project.tool.report.SAQ.chart.SAQChart;
 import org.apache.commons.collections.map.HashedMap;
 import org.apache.poi.ooxml.POIXMLDocument;
@@ -433,9 +434,25 @@
     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 {
@@ -605,38 +622,6 @@
         }
         return rgbStr;
     }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
 
 
     private static void changOtherPicture(XWPFParagraph paragraph) {
@@ -863,8 +848,8 @@
         changeTextBox(document, textMap);
 
         //璁剧疆鍥捐〃
-        if (Objects.equals(reportType, ReportTypeEnum.SAQ.getCode()) || Objects.equals(reportType, ReportTypeEnum.PAQ.getCode())) {
-            SAQChart.changeChart(document, textMap);
+        if (Objects.equals(reportType, ReportTypeEnum.PAQ.getCode())) {
+            PAQChart.changeChart(document, textMap);
         }
 
         //鎻掑叆琛ㄦ牸
@@ -874,7 +859,7 @@
         changeTable(document, textMap);
 
         //璁剧疆鍥捐〃鎺т欢
-        //changChar(textMap, document, reportType, templateType);
+        changChar(textMap, document, reportType, templateType);
         document.write(out);
     }
     private static void changeTextBox(XWPFDocument document, Map<String, Object> textMap) throws DocumentException {
@@ -976,7 +961,7 @@
         }
         if (StringUtils.equals(reportType, ReportTypeEnum.MAQ.getCode())) {
             setMAQCompleteChars(textMap, charts);
-        } else if (StringUtils.equals(reportType, ReportTypeEnum.MAQV2.getCode())) {
+        } else if (StringUtils.equals(reportType, ReportTypeEnum.MAQV2.getCode()) || StringUtils.equals(reportType, ReportTypeEnum.MAQ_IAR.getCode())) {
             setMAQ_V2CompleteChars(textMap, charts);
         } else if (StringUtils.equals(reportType, ReportTypeEnum.RuiLin.getCode())) {
             setRuiLinChar(textMap, charts);

--
Gitblit v1.9.1