From 0ac2c77e27a7c6ddbb30c3bebe0983724b97a027 Mon Sep 17 00:00:00 2001 From: orgin Date: Mon, 25 Sep 2023 17:23:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20gamma=20LC=20SCAC=20Baseline=20=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jeecg/common/util/GammaReportUtil.java | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 jeecg-boot-base-core/src/main/java/org/jeecg/common/util/GammaReportUtil.java 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 new file mode 100644 index 00000000..76d6aba6 --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/GammaReportUtil.java @@ -0,0 +1,90 @@ +package org.jeecg.common.util; + +import org.jeecg.modules.entity.vo.BaseControls; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.PrintWriter; +import java.util.List; + +public class GammaReportUtil { + public static void writeBaseline(BaseControls baseCtrl, 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("#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(); + } + } + public static void writeSCAC(BaseControls baseCtrl, 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("#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) { + // 每行的数量 + int numPerLine = 5; + int nBL = baseline.size(), nGroupBL = nBL / 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()); + } + + for(int i = 1; i < nGroupBL; i++) + { + out.printf("%" + (columnWidths[i] + 15) + "s", baseline.get(i-1)); + if(i % numPerLine == 0){ + out.println(""); + } + } + } +}