From 75d225e77d932a27a6fc50ad41786081fcd460d0 Mon Sep 17 00:00:00 2001
From: linzhijie <19970921lzj>
Date: 星期日, 25 四月 2021 15:58:49 +0800
Subject: [PATCH] 合并代码优化

---
 src/main/java/com/ots/common/utils/poi/WordUtil.java |   40 +++++++++++++++++++++++++++-------------
 1 files changed, 27 insertions(+), 13 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 368610e..822094f 100644
--- a/src/main/java/com/ots/common/utils/poi/WordUtil.java
+++ b/src/main/java/com/ots/common/utils/poi/WordUtil.java
@@ -369,17 +369,19 @@
             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);
                         }
@@ -835,17 +837,22 @@
         String filePath = getTemplateDownLoadPathByUpLoad(fileName);
         
         XWPFDocument document = new XWPFDocument(POIXMLDocument.openPackage(getTemplateDownLoadPathByUpLoad(fileName)));
-        
+
+        //璁剧疆鏂囨湰
         changeText(document, textMap);
 
+        //鏇存敼鏂囨湰妗�
         if (Objects.equals(reportType, ReportTypeEnum.MAQV2.getCode())) {
             changeTextBox(document, textMap);
         }
-        
+
+        //鎻掑叆琛ㄦ牸
         addTableValue(document, autoTableMap);
-        
+
+        //鏇存敼琛ㄦ牸鐨勫��
         changeTable(document, textMap);
-        
+
+        //璁剧疆鍥捐〃鎺т欢
         changChar(textMap, document, reportType, templateType);
         document.write(out);
     }
@@ -929,6 +936,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;
@@ -937,20 +952,19 @@
         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, ReportTypeEnum.MAQV2.getCode())) {
             setMAQ_V2CompleteChars(textMap, charts);
-        } else if (StringUtils.equals(reportType, "RuiLin")) {
+        } 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_People32 = textMap.get("P_Task31").toString();
-        String p_Task31 = textMap.get("P_People32").toString();
+        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();
@@ -981,8 +995,8 @@
                     List<CTBarSer> serList = ctBarChart.getSerList();
                     CTBarSer ctBarSer = serList.get(0);
                     CTNumDataSource val = ctBarSer.getVal();
-                    val.getNumRef().getNumCache().getPtList().get(0).setV(p_Task31);
-                    val.getNumRef().getNumCache().getPtList().get(1).setV(p_People32);
+                    val.getNumRef().getNumCache().getPtList().get(0).setV(p_People32);
+                    val.getNumRef().getNumCache().getPtList().get(1).setV(p_Task31);
                 }
             } catch (Exception e) {
                 e.printStackTrace();

--
Gitblit v1.9.1