[测评系统]--测评系统核心代码库
林致杰
2022-08-15 bce3ed8cfae1da18f9b75f70bdc533d9605f49aa
src/main/java/com/ots/project/tool/report/MAQTR/chart/MAQTRChart.java
@@ -9,6 +9,7 @@
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ooxml.POIXMLDocument;
import org.apache.poi.ooxml.POIXMLDocumentPart;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
@@ -36,7 +37,7 @@
            OutputStream os = new FileOutputStream("C:\\Users\\大头\\Desktop\\MAQ组别报告\\林_PAQ_IA_CN2.docx");
            XWPFDocument document = new XWPFDocument(POIXMLDocument.openPackage("C:\\Users\\大头\\Desktop\\MAQ组别报告\\终稿【0607中文版】MAQ组别对比报告(1).docx"));
            String fileName = "C:\\Users\\大头\\Desktop\\MAQ组别报告\\MAQ组别导入数据模板 (2).xlsx";
            String fileName = "C:\\Users\\大头\\Desktop\\MAQ组别报告\\MAQ组别导入数据模板 -3组(1).xlsx";
            //变更图表数据
            changeMAQTRChart(document,fileName);
            document.write(os);
@@ -54,10 +55,10 @@
     */
    public static Map<String,Map<Integer,Double>> replaceContent(String fileName){
        //平均值集合
        Map<String,Map<Integer,Double>> averageMap = new HashMap<>();
        Map<String,Map<Integer,Double>> averageMap = new TreeMap<>();
        try {
            XSSFWorkbook wb = new XSSFWorkbook(new FileInputStream(fileName));
            Map<String,Map<Integer,List<Double>>> dataMap = new HashMap<>();
            Map<String,Map<Integer,List<Double>>> dataMap = new TreeMap<>();
            for (int i = 0; i < wb.getNumberOfSheets(); i++) {
                XSSFSheet sheet = wb.getSheetAt(i);
                String companyName = sheet.getRow(1).getCell(0).getStringCellValue();
@@ -67,7 +68,7 @@
                //行
                for (int j = 1; j <= sheet.getLastRowNum(); j++) {
                    XSSFRow row = sheet.getRow(j);
                    if(row == null){
                    if(isEmptyRow(row)){
                        break;
                    }
                    //列
@@ -77,16 +78,27 @@
                            break;
                        }
                        //不是分数 忽略
                        switch (cell.getCellType()) {
                            case STRING:
                                break;
                        Double cellValue = null;
                        try {
                            switch (cell.getCellType()) {
                                case STRING:
                                    cellValue = Double.valueOf(cell.getStringCellValue());
                                    break;
                                case NUMERIC:
                                    cellValue = cell.getNumericCellValue();
                                    break;
                            }
                        }catch (Exception e){
                            log.error("获取分数失败,{}"+e.getMessage());
                            e.printStackTrace();
                        }
                        //归类个性
                        if(map.get(k) != null){
                            map.get(k).add(cell.getNumericCellValue());
                            map.get(k).add(cellValue);
                        }else {
                            List<Double> list = new ArrayList<>();
                            list.add(cell.getNumericCellValue());
                            list.add(cellValue);
                            map.put(k,list);
                        }
                    }
@@ -466,6 +478,29 @@
    }
    /**
     * 空行判断
     * @param row
     * @return
     */
    public static boolean isEmptyRow(XSSFRow row){
        if(row == null || row.toString().isEmpty()){
            return  true;
        }else{
            Iterator<Cell> it = row.iterator();
            boolean isEmpty = true;
            while (it.hasNext()){
                Cell cell = it.next();
                if(cell.getCellType() != CellType.BLANK){
                    isEmpty = false;
                    break;
                }
            }
            return isEmpty;
        }
    }
    /**
     * 更新图表的关联 excel
     *
     * @param seriesDatas