From fbd353ea39927abac1db0fa7e85ec5de0fa890f2 Mon Sep 17 00:00:00 2001 From: xiaoguangbin Date: Mon, 25 Sep 2023 19:00:37 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9Agamma=20=E7=94=9F=E6=88=90lc=20scac?= =?UTF-8?q?=20baseline=E5=B7=A5=E5=85=B7=E5=84=AA=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jeecg/common/util/GammaReportUtil.java | 57 +++++++++---------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/GammaReportUtil.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/GammaReportUtil.java index 76d6aba6..5b384d97 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/GammaReportUtil.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/GammaReportUtil.java @@ -6,9 +6,10 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.util.List; +import java.util.Objects; public class GammaReportUtil { - public static void writeBaseline(BaseControls baseCtrl, String path){ + public static void writeFile(BaseControls baseCtrl, String path){ // 创建文件 File file = new File(path); try { @@ -19,7 +20,7 @@ public class GammaReportUtil { String high = String.valueOf(baseCtrl.getRg_high()); out.printf("%" + (low.length() + 15) + "s", low); out.printf("%" + (high.length() + 15) + "s", high); - + out.println(""); out.println("#XCtrl"); format(baseCtrl.getXCtrl(), out); @@ -38,53 +39,49 @@ public class GammaReportUtil { e.printStackTrace(); } } - public static void writeSCAC(BaseControls baseCtrl, String path){ + public static void writeFile(List data, String fileType, String path){ // 创建文件 File file = new File(path); try { // 创建PrintWriter对象 PrintWriter out = new PrintWriter(file); - out.println("#AnalyseRange"); - String low = String.valueOf(baseCtrl.getRg_low()); - String high = String.valueOf(baseCtrl.getRg_high()); - out.printf("%" + (low.length() + 15) + "s", low); - out.printf("%" + (high.length() + 15) + "s", high); + out.println("#" + fileType); + out.printf("%" + (String.valueOf(data.size()).length() + 15) + "s", data.size() + "\n"); + format(data, out); - out.println("#XCtrl"); - format(baseCtrl.getXCtrl(), out); - - out.println("#YCtrl"); - format(baseCtrl.getYCtrl(), out); - - out.println("#YSlope"); - format(baseCtrl.getYSlope(), out); - - out.println("#Baseline"); - format(baseCtrl.getBaseline(), out); - - out.println("#StepCounts"); - format(baseCtrl.getStepCounts(), out); } catch (FileNotFoundException e) { e.printStackTrace(); } } - private static void format(List baseline, PrintWriter out) { + private static void format(List data, PrintWriter out) { // 每行的数量 int numPerLine = 5; - int nBL = baseline.size(), nGroupBL = nBL / numPerLine * numPerLine; + int i,n = data.size(), nGroupBL = n / numPerLine * numPerLine; // 计算每列数据中最长的字符串长度 - int[] columnWidths = new int[baseline.size()]; - for (int i = 0; i < baseline.size(); i++) { - columnWidths[i] = Math.max(columnWidths[i], baseline.get(i).toString().length()); + int[] columnWidths = new int[data.size()]; + for (i = 0; i < data.size(); i++) { + String col = Objects.isNull(data.get(i)) ? "" : String.valueOf(data.get(i)); + columnWidths[i] = Math.max(columnWidths[i], col.length()); } - for(int i = 1; i < nGroupBL; i++) + out.printf("%" + (String.valueOf(data.size()).length() + 15) + "s", data.size() + "\n"); + + for(i = 0; i < nGroupBL; i++) { - out.printf("%" + (columnWidths[i] + 15) + "s", baseline.get(i-1)); - if(i % numPerLine == 0){ + String col = Objects.isNull(data.get(i)) ? "nan" : String.valueOf(data.get(i)); + out.printf("%" + (columnWidths[i] + 15) + "s", col); + if((i+1) % numPerLine == 0) { out.println(""); } } + if(i < n) + { + for(; i