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(""); + } + } + } +}