fix:baseline等文件生成内容对齐优化
This commit is contained in:
parent
960b8be389
commit
4492eb5902
|
@ -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<Double> 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<n; ++i){
|
||||
out.printf("%" + (columnWidths[i] + 15) + "s", getValue(data.get(i)));
|
||||
out.printf("%" + (columnWidths[i] + (colLength - columnWidths[i])) + "s", getValue(data.get(i)));
|
||||
}
|
||||
}
|
||||
out.println("");
|
||||
|
|
Loading…
Reference in New Issue
Block a user