From d85aa8fbdb87bead85b8aaba57dc0c6f31542be4 Mon Sep 17 00:00:00 2001
From: wzp <2040239371@qq.com>
Date: 星期三, 31 一月 2024 08:56:07 +0800
Subject: [PATCH] 增加API测试

---
 src/main/java/com/ots/project/tool/report/APIFan/chart/APIFanChart.java                      |  380 ++++++++++++++++++++++++++++++++++++++++++
 src/main/java/com/ots/common/utils/poi/WordUtil.java                                         |    4 
 src/main/java/com/ots/project/tool/report/reportCalculation/request/CalculationTypeEnum.java |    2 
 src/main/java/com/ots/common/enums/ReportTypeEnum.java                                       |   18 +
 src/main/java/com/ots/project/tool/PdfUtil.java                                              |    4 
 src/main/java/com/ots/project/tool/report/APIFan/APIFanReport.java                           |   76 ++++++++
 6 files changed, 476 insertions(+), 8 deletions(-)

diff --git a/src/main/java/com/ots/common/enums/ReportTypeEnum.java b/src/main/java/com/ots/common/enums/ReportTypeEnum.java
index 2ebab18..269660b 100644
--- a/src/main/java/com/ots/common/enums/ReportTypeEnum.java
+++ b/src/main/java/com/ots/common/enums/ReportTypeEnum.java
@@ -3,9 +3,21 @@
 import java.util.Objects;
 @Getter
 public enum ReportTypeEnum {
-    Brief("Brief", "绠�鏄撶増"), Complete("Complete", "瀹屾暣鐗�"), SAQ("SAQ", "SAQ鎶ュ憡"), RuiLin("RuiLin", "鐫块偦鎶ュ憡"), CAQ("CAQ", "CAQ鎶ュ憡"),
-    JAQ("JAQ","JAQ鎶ュ憡"),MAQ("MAQ", "MAQ鎶ュ憡"),MAQV2("MAQV2", "MAQV2鎶ュ憡"),PAQ("PAQ", "PAQ鎶ュ憡"),MAQIAR("MAQIAR", "MAQIAR鎶ュ憡"),
-    MAQTR("MAQTR", "MAQTR鎶ュ憡"),CIAQ("CIAQ", "CIAQ鎶ュ憡"),VAQ("VAQ", "VAQ鎶ュ憡"),LAQ("LAQ", "LAQ鎶ュ憡");
+    Brief("Brief", "绠�鏄撶増"),
+    Complete("Complete", "瀹屾暣鐗�"),
+    SAQ("SAQ", "SAQ鎶ュ憡"),
+    RuiLin("RuiLin", "鐫块偦鎶ュ憡"),
+    CAQ("CAQ", "CAQ鎶ュ憡"),
+    JAQ("JAQ","JAQ鎶ュ憡"),
+    MAQ("MAQ", "MAQ鎶ュ憡"),
+    MAQV2("MAQV2", "MAQV2鎶ュ憡"),
+    PAQ("PAQ", "PAQ鎶ュ憡"),
+    MAQIAR("MAQIAR", "MAQIAR鎶ュ憡"),
+    MAQTR("MAQTR", "MAQTR鎶ュ憡"),
+    CIAQ("CIAQ", "CIAQ鎶ュ憡"),
+    VAQ("VAQ", "VAQ鎶ュ憡"),
+    LAQ("LAQ", "LAQ鎶ュ憡"),
+    APIFan("APIFan","APIFan鎶ュ憡");
     private final String code;
     private final String message;
     ReportTypeEnum(String code, String message) {
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 2912bf1..c5010c7 100644
--- a/src/main/java/com/ots/common/utils/poi/WordUtil.java
+++ b/src/main/java/com/ots/common/utils/poi/WordUtil.java
@@ -1181,9 +1181,9 @@
                 changColorIfJAQ(textMap, out, reportName, tReportTemplate.getReportType());
             //}
 
-            //PAQ銆丮AQTR閲囩敤銆丆IAQ鏂扮殑doc杞琾df
+            //PAQ銆丮AQTR閲囩敤銆丆IAQ銆丄PIFan鏂扮殑doc杞琾df
             if(ReportTypeEnum.PAQ.getCode().equals(reportType) || ReportTypeEnum.MAQTR.getCode().equals(reportType)
-                    || ReportTypeEnum.CIAQ.getCode().equals(reportType)){
+                    || ReportTypeEnum.CIAQ.getCode().equals(reportType) ||ReportTypeEnum.APIFan.getCode().equals(reportType)){
                 PdfUtil.convertPDF(EssConfig.getProfile() + "/" + reportName);
             }else if(ReportTypeEnum.LAQ.getCode().equals(reportType)){
                 PdfUtil.dockerConvertPDF(EssConfig.getProfile(),EssConfig.getDocx2pdfPath(),reportName);
diff --git a/src/main/java/com/ots/project/tool/PdfUtil.java b/src/main/java/com/ots/project/tool/PdfUtil.java
index 20b8711..5a2b380 100644
--- a/src/main/java/com/ots/project/tool/PdfUtil.java
+++ b/src/main/java/com/ots/project/tool/PdfUtil.java
@@ -17,7 +17,7 @@
      * 璁剧疆鐢ㄦ埛瀛椾綋浣嶇疆
      */
     public static void setFont() {
-        String[] fonts = {"C:\\Users\\澶уご\\AppData\\Local\\Microsoft\\Windows\\Fonts\\", "C:\\Users\\datou\\AppData\\Local\\Microsoft\\Windows\\Fonts\\", "/usr/share/fonts"};
+        String[] fonts = {"C:\\Windows\\Fonts", "C:\\Users\\datou\\AppData\\Local\\Microsoft\\Windows\\Fonts\\", "/usr/share/fonts"};
         List<FontSourceBase> fontSources = new ArrayList(Arrays.asList(FontSettings.getDefaultInstance().getFontsSources()));
         for (int i = 0; i < fonts.length; i++) {
             FolderFontSource folderFontSource = new FolderFontSource(fonts[i], true);
@@ -106,7 +106,7 @@
 
     public static void main(String[] args) {
         //convertPDF("D:\\娴嬭瘎绯荤粺\\home\\鏋梍PAQ_GS_TH.docx");
-        convertPDF("C:\\Users\\澶уご\\Desktop\\鏋�3_CIAQ_IA_CN.docx");
+        convertPDF("C:\\Users\\mac\\Desktop\\API_Fan_IA_CN.docx");
     }
 
 }
diff --git a/src/main/java/com/ots/project/tool/report/APIFan/APIFanReport.java b/src/main/java/com/ots/project/tool/report/APIFan/APIFanReport.java
new file mode 100644
index 0000000..cf7d361
--- /dev/null
+++ b/src/main/java/com/ots/project/tool/report/APIFan/APIFanReport.java
@@ -0,0 +1,76 @@
+package com.ots.project.tool.report.APIFan;
+
+import com.ots.common.enums.LangTypeEnum;
+import com.ots.common.enums.ReportTypeEnum;
+import com.ots.project.tool.report.MAQNEW.base.BaseCondition_V2;
+import com.ots.project.tool.report.MAQNEW.condition.ScoreCharacteristics_V2;
+import com.ots.project.tool.report.MAQNEW.condition.SimpleMessage_V2;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class APIFanReport {
+    private String questionnaireTaker;
+    private String questionnaireID;
+    private String reportGenerationDate;
+    private String userName;
+    private String questionnaireEmail;
+    private String questionnaireStartTime;
+    private String questionnaireEndTime;
+    private ReportTypeEnum reportTypeEnum;
+    private LangTypeEnum langType;
+
+    /**
+     * 鏍规嵁鎶ュ憡绫诲瀷鍒濆鍖栨暟鎹�
+     * @param reportTypeEnum
+     * @return
+     */
+    public List<BaseCondition_V2> getParamList(ReportTypeEnum reportTypeEnum) {
+        return init(reportTypeEnum);
+    }
+    /**
+     * 鏍规嵁鎶ュ憡绫诲瀷鍒濆鍖栨墍鏈�
+     * @param reportTypeEnum
+     * @return
+     */
+    private List<BaseCondition_V2> init(ReportTypeEnum reportTypeEnum) {
+        List<BaseCondition_V2> paramList = new ArrayList<>();
+
+        //鏅�氫俊鎭�
+        paramList.addAll(getSimpleMessageCoreIds().stream().map(p -> {
+            SimpleMessage_V2 simpleMessage = new SimpleMessage_V2(p);
+            return simpleMessage;
+        }).collect(Collectors.toList()));
+
+        //琛ㄦ牸璁$畻鏁板��
+        paramList.addAll(getScoreCharacteristicsList().stream().map(p -> {
+            ScoreCharacteristics_V2 scoreCharacteristics = new ScoreCharacteristics_V2(p);
+            return scoreCharacteristics;
+        }).collect(Collectors.toList()));
+
+        return paramList;
+    }
+
+
+    /**
+     * 琛ㄦ牸璁$畻鏁板��
+     * @return
+     */
+    private List<String> getScoreCharacteristicsList() {
+        return Arrays.asList("P_Total", "P_Retent09", "P_Social01", "P_Cooper02", "P_Analth03",
+                "P_Initia04", "P_Persis05", "P_Depend06", "P_Emotct07", "P_Stress08",
+                "P_SdecepT1", "P_Sdecept10", "P_ImpmgT1", "P_Impmg11", "BST1",
+                "BST2");
+    }
+
+    /**
+     * 鏅�氭枃鏈浛鎹ibrary
+     * @return
+     */
+    private List<String> getSimpleMessageCoreIds() {
+        return new ArrayList<>();
+    }
+
+}
diff --git a/src/main/java/com/ots/project/tool/report/APIFan/chart/APIFanChart.java b/src/main/java/com/ots/project/tool/report/APIFan/chart/APIFanChart.java
new file mode 100644
index 0000000..46fdc78
--- /dev/null
+++ b/src/main/java/com/ots/project/tool/report/APIFan/chart/APIFanChart.java
@@ -0,0 +1,380 @@
+package com.ots.project.tool.report.APIFan.chart;
+
+import com.ots.project.tool.report.MAQ.base.RowData;
+import com.ots.project.tool.report.MAQ.base.SeriesData;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.ooxml.POIXMLDocument;
+import org.apache.poi.ooxml.POIXMLDocumentPart;
+import org.apache.poi.xssf.usermodel.XSSFCell;
+import org.apache.poi.xssf.usermodel.XSSFRow;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.apache.poi.xwpf.usermodel.XWPFChart;
+import org.apache.poi.xwpf.usermodel.XWPFDocument;
+import org.openxmlformats.schemas.drawingml.x2006.chart.*;
+
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ *@ClassName APIFanChart
+ *@Description 鏌卞舰鍥炬暟鎹浛鎹�
+ */
+@Slf4j
+public class APIFanChart {
+    //region 鍥惧舰鍙橀噺瀹氫箟
+    private static String p_total;//宸ヤ綔琛ㄧ幇棰勬祴鍒嗘暟
+    private static String p_retent09;//鐣欒亴棰勬祴鍒嗘暟
+    private static String p_social01;//1.绀句氦鎬�
+    private static String p_cooper02;//2.鍚堜綔鎬�
+    private static String p_analth03;//3.闂瑙e喅鍜岄�傚簲鎬�
+    private static String p_initia04;//4.涓诲姩鎬�
+    private static String p_persis05;//5.鍧氶煣鎬�
+    private static String p_depend06;//6.鍙潬鎬�
+    private static String p_emotct07;//7.鎯呯华鐨勮嚜鎴戞帶鍒�
+    private static String p_stress08;//8.鍘嬪姏鐨勫蹇嶅害
+
+    //鑷垜璁ょ煡鍑嗙‘搴�
+    private static String p_sdecepT1;
+    private static String p_sdecept10;
+    //鑷垜闃愯堪鐨勭湡瀹炲害
+    private static String p_impmgT1;
+    private static String p_impmg11;
+    //鐩存帴鎾掕皫
+    private static String bst1;
+    private static String bst2;
+    //endregion
+
+    public static void main(String[] args) throws IOException {
+        try (
+                OutputStream os = new FileOutputStream("C:\\Users\\mac\\Desktop\\API_Fan_IA_CN_222.docx");
+                XWPFDocument document = new XWPFDocument(POIXMLDocument.openPackage("C:\\Users\\mac\\Desktop\\API_Fan_IA_CN.docx")))
+        {
+            Map<String, Object> textMap = new HashMap<String, Object>();
+            textMap.put("P_Total","52");
+            textMap.put("P_Retent09","53");
+            textMap.put("P_Social01","54");
+            textMap.put("P_Cooper02","55");
+            textMap.put("P_Analth03","56");
+            textMap.put("P_Initia04","57");
+            textMap.put("P_Persis05","58");
+            textMap.put("P_Depend06","59");
+            textMap.put("P_Emotct07","60");
+            textMap.put("P_Stress08","61");
+            textMap.put("P_SdecepT1","62");
+            textMap.put("P_Sdecept10","63");
+            textMap.put("P_ImpmgT1","64");
+            textMap.put("P_Impmg11","65");
+            textMap.put("BST1","66");
+            textMap.put("BST2","67");
+            changeChart(document,textMap);
+            document.write(os);
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 鏇挎崲Excel鍥捐〃鏁版嵁
+     * @param document 鏂囨。瀵硅薄
+     * @param textMap 鎶ュ憡瀛楀吀閿�煎
+     * @return
+     */
+    public static boolean changeChart(XWPFDocument document, Map<String, Object> textMap){
+        List<SeriesData> seriesDatas = initData(textMap);
+        if(seriesDatas == null){
+            log.error("鏇挎崲APIFan鍥捐〃鏁版嵁,鍒濆鍖栨暟鎹け璐�!");
+            return false;
+        }
+        //鍥捐〃鏁版嵁
+        changePAQChart(document,seriesDatas);
+        return true;
+    }
+
+
+    /**
+     * 鍒ゆ柇鏄惁涓虹┖
+     * @param value
+     * @return
+     */
+    public static boolean checkParamsIsNull(String... value) {
+        for (int i = 0; i < value.length; i++) {
+            if (Objects.isNull(value[i])) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * 鍒濆鍖栨姤鍛婃暟鎹�
+     * @param textMap
+     * @return
+     */
+    public static List<SeriesData> initData(Map<String, Object> textMap){
+        //region 鑾峰彇鍛戒腑鏁板��
+        p_total = (String) textMap.get("P_Total");
+        p_retent09 = (String) textMap.get("P_Retent09");
+        p_social01 = (String) textMap.get("P_Social01");
+        p_cooper02 = (String) textMap.get("P_Cooper02");
+        p_analth03 = (String) textMap.get("P_Analth03");
+        p_initia04 = (String) textMap.get("P_Initia04");
+        p_persis05 = (String) textMap.get("P_Persis05");
+        p_depend06 = (String) textMap.get("P_Depend06");
+        p_emotct07 = (String) textMap.get("P_Emotct07");
+        p_stress08 = (String) textMap.get("P_Stress08");
+
+        p_sdecepT1 = (String) textMap.get("P_SdecepT1");
+        p_sdecept10 = (String) textMap.get("P_Sdecept10");
+        p_impmgT1 = (String) textMap.get("P_ImpmgT1");
+        p_impmg11 = (String) textMap.get("P_Impmg11");
+        bst1 = (String) textMap.get("BST1");
+        bst2 = (String) textMap.get("BST2");
+
+        String[]  paramValue = new String[]{p_total, p_retent09, p_social01,p_cooper02,p_analth03,p_initia04,
+                p_persis05,p_depend06,p_emotct07,p_stress08,p_sdecepT1, p_sdecept10,p_impmgT1,p_impmg11,bst1,bst2};
+
+        //鍒ゆ柇鏄惁涓虹┖
+        if (checkParamsIsNull(paramValue))
+        {
+            return null;
+        }
+
+        //endregion
+
+        Double P_Total = Double.valueOf(p_total);
+        Double P_Retent09 = Double.valueOf(p_retent09);
+        Double P_Social01 = Double.valueOf(p_social01);
+        Double P_Cooper02 = Double.valueOf(p_cooper02);
+        Double P_Analth03 = Double.valueOf(p_analth03);
+        Double P_Initia04 = Double.valueOf(p_initia04);
+        Double P_Persis05 = Double.valueOf(p_persis05);
+        Double P_Depend06 = Double.valueOf(p_depend06);
+        Double P_Emotct07 = Double.valueOf(p_emotct07);
+        Double P_Stress08 = Double.valueOf(p_stress08);
+        Double P_SdecepT1 = Double.valueOf(p_sdecepT1);
+        Double P_Sdecept10 = Double.valueOf(p_sdecept10);
+        Double P_ImpmgT1 = Double.valueOf(p_impmgT1);
+        Double P_Impmg11 = Double.valueOf(p_impmg11);
+        Double BST1 = Double.valueOf(bst1);
+        Double BST2 = Double.valueOf(bst2);
+        // 娴嬭瘯鏁版嵁
+        List<SeriesData> seriesDatas = Arrays.asList(
+                new SeriesData("鐣欒亴棰勬祴鍒嗘暟", Arrays.asList(
+                        new RowData("鐣欒亴棰勬祴鍒嗘暟", P_Retent09)
+                )),
+                new SeriesData("浜烘牸鍓栧儚", Arrays.asList(
+                        new RowData("浜烘牸鍓栧儚", P_Social01),
+                        new RowData("浜烘牸鍓栧儚", P_Cooper02),
+                        new RowData("浜烘牸鍓栧儚", P_Analth03),
+                        new RowData("浜烘牸鍓栧儚", P_Initia04),
+                        new RowData("浜烘牸鍓栧儚", P_Persis05),
+                        new RowData("浜烘牸鍓栧儚", P_Depend06),
+                        new RowData("浜烘牸鍓栧儚", P_Emotct07),
+                        new RowData("浜烘牸鍓栧儚", P_Stress08)
+
+                )),
+                new SeriesData("鑷垜璁ょ煡鐨勫噯纭害", Arrays.asList(
+                        new RowData("鑷垜璁ょ煡鐨勫噯纭害", P_Sdecept10),//椤哄簭瑕佸�掔疆
+                        new RowData("鑷垜璁ょ煡鐨勫噯纭害", P_SdecepT1)//椤哄簭瑕佸�掔疆
+
+                )),
+                new SeriesData("鑷垜闃愯堪鐨勭湡瀹炲害", Arrays.asList(
+                        new RowData("鑷垜闃愯堪鐨勭湡瀹炲害", P_Impmg11),//椤哄簭瑕佸�掔疆
+                        new RowData("鑷垜闃愯堪鐨勭湡瀹炲害", P_ImpmgT1)//椤哄簭瑕佸�掔疆
+
+                )),
+                new SeriesData("鐩存帴鎾掕皫", Arrays.asList(
+                        new RowData("鐩存帴鎾掕皫", BST2),//椤哄簭瑕佸�掔疆
+                        new RowData("鐩存帴鎾掕皫", BST1)//椤哄簭瑕佸�掔疆
+                )),
+                new SeriesData("宸ヤ綔琛ㄧ幇棰勬祴鍒嗘暟", Arrays.asList(
+                        new RowData("宸ヤ綔琛ㄧ幇棰勬祴鍒嗘暟", P_Total)
+                ))
+        );
+        return seriesDatas;
+    }
+
+    /**
+     * 鏇挎崲word鍥捐〃 鏁g偣鍥捐窡鏌卞舰鍥剧粍鍚堝浘褰�
+     * @param doc
+     * @param seriesDatas
+     */
+    public static void changePAQChart(XWPFDocument doc,List<SeriesData> seriesDatas) {
+        try {
+            //鍔ㄦ�佸埛鏂板浘琛�
+            List<POIXMLDocumentPart> relations = doc.getRelations();
+            int k=0;
+            for (POIXMLDocumentPart part : relations) {
+                if (part instanceof XWPFChart) {
+                    // 鍥捐〃鍏冪礌
+                    XWPFChart chart = (XWPFChart) part;
+
+                    // 鏌ョ湅閲岄潰鐨勫浘琛ㄦ暟鎹紝鎵嶈兘鐭ラ亾鏄粈涔堝浘琛�
+                    CTPlotArea plot = chart.getCTChart().getPlotArea();
+                    // excel鍐呯疆琛ㄦ牸
+                    XSSFWorkbook workbook = chart.getWorkbook();
+                    XSSFSheet sheet = workbook.getSheetAt(0);
+
+
+                    //鏌卞舰鍥�
+                    if (!plot.getBarChartList().isEmpty()) {
+                        CTBarChart barChart = plot.getBarChartArray(0);
+                        //鍒锋柊鍐呯疆excel鏁版嵁
+                        List<SeriesData> excelData = new ArrayList<>();
+                        excelData.add(seriesDatas.get(k));
+
+                        refreshExcel(excelData, workbook, sheet);
+                        workbook.write(chart.getPackagePart().getOutputStream());
+
+                        //鏌卞舰鍥炬暟鎹簮
+                        List<SeriesData> barDatas = seriesDatas;
+                        int i = 0;
+                        for (CTBarSer ser : barChart.getSerList()) {
+                            //鏇存柊鏌卞舰鍥炬暟鎹紦瀛�
+                            updateBarChart(barDatas.get(k), ser.getVal());
+                            ++i;
+                        }
+
+                        ++k;
+                    }
+                }
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("API-fan鏌卞舰鍥惧浘褰㈠け璐ワ細{}",e);
+        }
+    }
+
+    /**
+     * 鏇存柊鍥捐〃鐨勫叧鑱� excel
+     *
+     * @param seriesDatas
+     * @param workbook
+     * @param sheet
+     */
+    protected static void refreshExcel(List<SeriesData> seriesDatas, XSSFWorkbook workbook, XSSFSheet sheet) {
+        XSSFRow title = sheet.getRow(0);
+        //閬嶅巻鏁版嵁鏁扮粍杩涜excel璧嬪��
+        for (int i = 0; i < seriesDatas.size(); i++) {
+            SeriesData data = seriesDatas.get(i);
+            if (data.name != null && !data.name.isEmpty()) {
+                // 绗�2琛屾爣棰�
+                XSSFCell cell = title.getCell(i+1);
+                if (cell == null) {
+                    cell = title.createCell(i + 1);
+                }
+                cell.setCellValue(data.name);
+            }
+            int size = data.value.size();
+            //閬嶅巻鏁版嵁杩涜璧嬪��
+            for (int j = 0; j < size; j++) {
+                //浠庣浜岃寮�濮嬭祴鍊�
+                XSSFRow row = sheet.getRow(j + 1);
+                if (row == null) {
+                    row = sheet.createRow(j + 1);
+                }
+                RowData cellValu = data.value.get(j);
+
+                //绗�2鍒楀紑濮嬭祴鍊�
+                XSSFCell cell = row.getCell(i+1);
+                if (cell == null) {
+                    cell = row.createCell(i+1);
+                }
+                cell.setCellValue(cellValu.value);
+            }
+            //鍒犻櫎澶氫綑琛屾暟
+//            int lastRowNum = sheet.getLastRowNum();
+//            if (lastRowNum > size) {
+//                for (int idx = lastRowNum; idx > size; idx--) {
+//                    sheet.removeRow(sheet.getRow(idx));
+//                }
+//            }
+        }
+    }
+
+
+    /**
+     * 鏇存柊 鏌卞舰鍥� 鐨勭紦瀛樻暟鎹�
+     *
+     * @param seriesDatas   鏁版嵁
+     * @param numDataSource 鏁版嵁鐨勭紦瀛�
+     */
+    protected static void updateBarChart(SeriesData seriesDatas, CTNumDataSource numDataSource) {
+        //鑾峰彇鏌卞舰鍥炬暟鎹暟閲�
+        long ptNumCnt = numDataSource.getNumRef().getNumCache().getPtCount().getVal();
+        int dataSize = seriesDatas.value.size();
+        for (int i = 0; i < dataSize; i++) {
+            RowData cellValu = seriesDatas.value.get(i);
+            CTNumVal val = ptNumCnt > i ? numDataSource.getNumRef().getNumCache().getPtArray(i)
+                    : numDataSource.getNumRef().getNumCache().addNewPt();
+            val.setIdx(i);
+            val.setV(String.format("%.0f", cellValu.value));
+
+        }
+
+        // 鏇存柊瀵瑰簲excel鐨勮寖鍥�
+        numDataSource.getNumRef().setF(
+                replaceRowEnd(numDataSource.getNumRef().getF(),
+                        ptNumCnt,
+                        dataSize));
+
+        // 鍒犻櫎澶氱殑
+        if (ptNumCnt > dataSize) {
+            for (int idx = dataSize; idx < ptNumCnt; idx++) {
+                numDataSource.getNumRef().getNumCache().removePt(dataSize);
+            }
+        }
+        // 鏇存柊涓暟
+        numDataSource.getNumRef().getNumCache().getPtCount().setVal(dataSize);
+    }
+
+
+    /**
+     * 鏇挎崲 褰㈠锛� Sheet1!$A$2:$A$4 鐨勫瓧绗�
+     *
+     * @param range
+     * @return
+     */
+    public static String replaceRowEnd(String range, long oldSize, long newSize) {
+        Pattern pattern = Pattern.compile("(:\\$[A-Z]+\\$)(\\d+)");
+        Matcher matcher = pattern.matcher(range);
+        if (matcher.find()) {
+            long old = Long.parseLong(matcher.group(2));
+            return range.replaceAll("(:\\$[A-Z]+\\$)(\\d+)", "$1" + Long.toString(old - oldSize + newSize));
+        }
+        return range;
+    }
+
+    /**
+     * 鑾峰彇鍥捐〃鏈夊摢浜涚被鍨�
+     * @param part
+     */
+    public static void getChartType(POIXMLDocumentPart part){
+        XWPFChart chart = (XWPFChart) part;
+        //鏍规嵁灞炴�х涓�鍒楀悕绉板垏鎹㈡暟鎹被鍨�
+        CTChart ctChart = chart.getCTChart();
+        CTPlotArea plotArea = ctChart.getPlotArea();
+
+        if (!plotArea.getBarChartList().isEmpty()) {
+            System.out.println("鏌辩姸鍥緖"+plotArea.getBarChartList().size()+"}");
+        }
+        if (!plotArea.getPieChartList().isEmpty()) {
+            System.out.println("楗煎浘{"+plotArea.getPieChartList().size()+"}");
+        }
+        if (!plotArea.getLineChartList().isEmpty()) {
+            System.out.println("绾垮舰鍥緖"+plotArea.getLineChartList().size()+"}");
+        }
+        if (!plotArea.getBar3DChartList().isEmpty()) {
+            System.out.println("鏌辩姸鍥�3D{"+plotArea.getBar3DChartList().size()+"}");
+        }
+        if (!plotArea.getScatterChartList().isEmpty()) {
+            System.out.println("鏁g偣鍥緖"+plotArea.getScatterChartList().size()+"}");
+        }
+    }
+}
diff --git a/src/main/java/com/ots/project/tool/report/reportCalculation/request/CalculationTypeEnum.java b/src/main/java/com/ots/project/tool/report/reportCalculation/request/CalculationTypeEnum.java
index 2d7a18c..11c878e 100644
--- a/src/main/java/com/ots/project/tool/report/reportCalculation/request/CalculationTypeEnum.java
+++ b/src/main/java/com/ots/project/tool/report/reportCalculation/request/CalculationTypeEnum.java
@@ -1,5 +1,5 @@
 package com.ots.project.tool.report.reportCalculation.request;
 
 public enum CalculationTypeEnum {
-    MAQ, SAQ, RUILIN, CAQ, JAQ,PAQ,CIAQ
+    MAQ, SAQ, RUILIN, CAQ, JAQ,PAQ,CIAQ,APIFan
 }

--
Gitblit v1.9.1