From 54aecc07ca143841e66e25dc587bd2629fa0ba8f Mon Sep 17 00:00:00 2001
From: 林致杰 <1003392067@qq.com>
Date: 星期二, 02 八月 2022 15:08:09 +0800
Subject: [PATCH] 增加空行判断

---
 src/main/java/com/ots/project/tool/report/MAQTR/chart/MAQTRChart.java |   39 ++++++++++++++++++++++++++++-----------
 1 files changed, 28 insertions(+), 11 deletions(-)

diff --git a/src/main/java/com/ots/project/tool/report/MAQTR/chart/MAQTRChart.java b/src/main/java/com/ots/project/tool/report/MAQTR/chart/MAQTRChart.java
index 0dd7306..068f2bc 100644
--- a/src/main/java/com/ots/project/tool/report/MAQTR/chart/MAQTRChart.java
+++ b/src/main/java/com/ots/project/tool/report/MAQTR/chart/MAQTRChart.java
@@ -34,9 +34,9 @@
     public static void main(String[] args) throws IOException {
         try {
             OutputStream os = new FileOutputStream("C:\\Users\\澶уご\\Desktop\\MAQ缁勫埆鎶ュ憡\\鏋梍PAQ_IA_CN2.docx");
-            XWPFDocument document = new XWPFDocument(POIXMLDocument.openPackage("C:\\Users\\澶уご\\Desktop\\MAQ缁勫埆鎶ュ憡\\缁堢銆�0607涓枃鐗堛�慚AQ缁勫埆瀵规瘮鎶ュ憡.docx"));
+            XWPFDocument document = new XWPFDocument(POIXMLDocument.openPackage("C:\\Users\\澶уご\\Desktop\\MAQ缁勫埆鎶ュ憡\\缁堢銆�0607涓枃鐗堛�慚AQ缁勫埆瀵规瘮鎶ュ憡(1).docx"));
 
-            String fileName = "C:\\Users\\澶уご\\Desktop\\MAQ缁勫埆鎶ュ憡\\缁勫埆瀵规瘮鎶ュ憡娴嬭瘯鏁版嵁.xlsx";
+            String fileName = "C:\\Users\\澶уご\\Desktop\\MAQ缁勫埆鎶ュ憡\\MAQ缁勫埆瀵煎叆鏁版嵁妯℃澘 (2).xlsx";
             //鍙樻洿鍥捐〃鏁版嵁
             changeMAQTRChart(document,fileName);
             document.write(os);
@@ -62,20 +62,26 @@
                 XSSFSheet sheet = wb.getSheetAt(i);
                 String companyName = sheet.getRow(1).getCell(0).getStringCellValue();
                 Map<Integer,List<Double>> map = new HashMap<>();
+                //缁熻浜烘暟
+                int person = 0;
                 //琛�
                 for (int j = 1; j <= sheet.getLastRowNum(); j++) {
                     XSSFRow row = sheet.getRow(j);
+                    if(row == null){
+                        break;
+                    }
                     //鍒�
                     for (int k = 1; k < row.getLastCellNum(); k++) {
                         XSSFCell cell = row.getCell(k);
-/*
-                        if (CellType.NUMERIC == cell.getCellType()) {
-                            System.out.println(cell.getNumericCellValue());
-                        } else if (CellType.STRING == cell.getCellType()) {
-                            System.out.println(cell.getStringCellValue());
+                        if(cell == null){
+                            break;
                         }
-*/
-                        //table1 澶氫釜绛旈缁撴灉澶勭悊
+                        //涓嶆槸鍒嗘暟 蹇界暐
+                        switch (cell.getCellType()) {
+                            case STRING:
+                                break;
+                        }
+                        //褰掔被涓��
                         if(map.get(k) != null){
                             map.get(k).add(cell.getNumericCellValue());
                         }else {
@@ -84,7 +90,15 @@
                             map.put(k,list);
                         }
                     }
+                    person++;
                 }
+
+                //璁剧疆浜烘暟
+                List<Double> list = new ArrayList<>();
+                list.add(Double.valueOf(person));
+                map.put(999,list);
+
+                //璁剧疆涓嶅悓鍥㈤槦鐨勬暟鎹�
                 dataMap.put(companyName,map);
             }
             //骞冲潎鍊奸泦鍚�
@@ -139,8 +153,8 @@
                 //鍔ㄦ�佸��
                 for (Map.Entry<String,Map<Integer,Double>> map : dataMap.entrySet()) {
                     SeriesData valSeriesData = new SeriesData();
-                    valSeriesData.setName(map.getKey());
                     Map<Integer,Double> valMap = map.getValue();
+                    valSeriesData.setName(map.getKey()+"锛坣="+ valMap.get(999).intValue() +"锛�");
                     List<RowData> valRowDataList = new ArrayList<>();
                     for (int i = oneIndex; i > 0; i--) {
                         RowData rowData = new RowData();
@@ -196,8 +210,8 @@
                 //鍔ㄦ�佸��
                 for (Map.Entry<String,Map<Integer,Double>> map : dataMap.entrySet()) {
                     SeriesData valSeriesData = new SeriesData();
-                    valSeriesData.setName(map.getKey());
                     Map<Integer,Double> valMap = map.getValue();
+                    valSeriesData.setName(map.getKey()+"锛坣="+valMap.get(999).intValue()+"锛�");
                     List<RowData> valRowDataList = new ArrayList<>();
                     for (int i = twoIndex; i > oneIndex; i--) {
                         RowData rowData = new RowData();
@@ -498,6 +512,9 @@
             //log.error("lastRowNum:{},size:{}",lastRowNum,size);
             if (lastRowNum > size) {
                 for (int idx = lastRowNum; idx > size; idx--) {
+                    if(sheet.getRow(idx) == null){
+                        continue;
+                    }
                     sheet.removeRow(sheet.getRow(idx));
                 }
             }

--
Gitblit v1.9.1