update:修改sava文件名

This commit is contained in:
nieziyan 2023-11-01 09:31:04 +08:00
parent bc59a15887
commit 7ed2207730
3 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,17 @@
package org.jeecg.modules.base.dto;
import lombok.Data;
@Data
public class DBInfo {
private String tableName;
private Integer numRow;
private Double dataSize;
private Double indexSize;
private Double used;
}

View File

@ -4503,6 +4503,10 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
String dataType = phd.getMsgInfo().getData_type().substring(0, 1);
String format = ".txt";
String txtFileName = String.format("%s-%s_%s_%s_RESULT%s", detectorCode, date, time, dataType, format);
if (StrUtil.isNotBlank(fileName)){
if (StrUtil.contains(fileName, ".PHD"))
txtFileName = StrUtil.replace(fileName, ".PHD", ".txt");
}
// 导出数据内容到txt文本
OutputStream fos = null;
try {
@ -4641,6 +4645,10 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
String dataType = phd.getMsgInfo().getData_type().substring(0, 1);
String format = ".xls";
String xlsFileName = String.format("%s-%s_%s_%s_RESULT%s", detectorCode, date, time, dataType, format);
if (StrUtil.isNotBlank(fileName)){
if (StrUtil.contains(fileName, ".PHD"))
xlsFileName = StrUtil.replace(fileName, ".PHD", ".xls");
}
String template = SAVETOEXCEL_G.getName();
// 导出时使用默认文件名 file.xls
ExportUtil.exportXls(response, template, data, xlsFileName);

View File

@ -4452,6 +4452,11 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
PrintWriter writer = null;
try {
String export = "saveToHtml.html";
String sampleFileName = anlyseResultIn.getSampleFileName();
if (StrUtil.isNotBlank(sampleFileName)){
if (StrUtil.contains(sampleFileName, ".PHD"))
export = StrUtil.replace(sampleFileName, ".PHD", ".html");
}
writer = ExportUtil.htmlWriter(response, export);
writer.write(result);
} catch (IOException e) {
@ -4469,6 +4474,11 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
// 将Null值替换为"",避免空指针异常(集合为空集合,不能为null)
analyze.replaceAll((key, value) -> ObjectUtil.isNull(value) ? "" : value);
String export = "SaveToExcel.xls";
String sampleFileName = anlyseResultIn.getSampleFileName();
if (StrUtil.isNotBlank(sampleFileName)){
if (StrUtil.contains(sampleFileName, ".PHD"))
export = StrUtil.replace(sampleFileName, ".PHD", ".xls");
}
String template = SAVETOEXCEL.getName();
ExportUtil.exportXls(response, template, analyze,export);
}
@ -4544,6 +4554,11 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
newLines.add(line);
}
String export = "SaveToTxt.txt";
String sampleFileName = anlyseResultIn.getSampleFileName();
if (StrUtil.isNotBlank(sampleFileName)){
if (StrUtil.contains(sampleFileName, ".PHD"))
export = StrUtil.replace(sampleFileName, ".PHD", ".txt");
}
writer = ExportUtil.streamWriter(response, export);
for (String newLine : newLines) {
writer.println(newLine);