From 4492eb59029f65625b26869dc2e86a3b8f00bd1a Mon Sep 17 00:00:00 2001 From: xiaoguangbin Date: Tue, 26 Sep 2023 22:34:04 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9Abaseline=E7=AD=89=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E7=94=9F=E6=88=90=E5=86=85=E5=AE=B9=E5=AF=B9=E9=BD=90=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jeecg/common/util/GammaReportUtil.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 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 e13840ad..f879f7e0 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 @@ -14,6 +14,7 @@ import java.util.Objects; public class GammaReportUtil { private static FTPUtil ftpUtil = ApplicationContextUtil.getContext().getBean(FTPUtil.class); + private static int colLength = 15; public static void writeFile(BaseControls baseCtrl, String path){ // 获取系统的临时目录 String tempDir = System.getProperty("java.io.tmpdir"); @@ -26,8 +27,8 @@ public class GammaReportUtil { 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.printf("%" + (low.length() + (colLength - low.length())) + "s", low); + out.printf("%" + (high.length() + (colLength - high.length())) + "s", high); out.println(""); out.println("#XCtrl"); format(baseCtrl.getXCtrl(), out); @@ -65,7 +66,7 @@ public class GammaReportUtil { try { out = new PrintWriter(file); out.println("#" + fileType); - out.printf("%" + (String.valueOf(data.size()).length() + 15) + "s", data.size() + "\n"); + out.printf("%" + (String.valueOf(data.size()).length() + (colLength - String.valueOf(data.size()).length())) + "s", data.size() + "\n"); format(data, out); String targetPath = StringUtils.substringBeforeLast(path, StringPool.SLASH); @@ -84,6 +85,7 @@ public class GammaReportUtil { private static void format(List data, PrintWriter out) { // 每行的数量 int numPerLine = 5; + int i,n = data.size(), nGroupBL = n / numPerLine * numPerLine; // 计算每列数据中最长的字符串长度 int[] columnWidths = new int[data.size()]; @@ -92,12 +94,11 @@ public class GammaReportUtil { columnWidths[i] = Math.max(columnWidths[i], col.length()); } - out.printf("%" + (String.valueOf(data.size()).length() + 15) + "s", data.size() + "\n"); + out.printf("%" + (String.valueOf(data.size()).length() + (colLength - String.valueOf(data.size()).length())) + "s", data.size() + "\n"); for(i = 0; i < nGroupBL; i++) { - System.out.print(i+">>>>"+data.get(i)); - out.printf("%" + (columnWidths[i] + 15) + "s", getValue(data.get(i))); + out.printf("%" + (columnWidths[i] + (colLength - columnWidths[i])) + "s", getValue(data.get(i))); if((i+1) % numPerLine == 0) { out.println(""); } @@ -105,7 +106,7 @@ public class GammaReportUtil { if(i < n) { for(; i