beta导出QC Result接口txt导出功能改为调用接口的形式

This commit is contained in:
qiaoqinzheng 2023-11-20 10:15:55 +08:00
parent a3dee8432c
commit 1812b1e5ca
3 changed files with 58 additions and 0 deletions

View File

@ -115,6 +115,11 @@ public class SpectrumAnalysesController {
spectrumAnalysisService.exportQCResult(sampleId, dbName, sampleFileName, gasFileName ,detFileName, request,response);
}
@GetMapping("exportQCResultTXT")
public void exportQCResultTXT(Integer sampleId, String dbName, String sampleFileName, String gasFileName, String detFileName, HttpServletRequest request, HttpServletResponse response) {
spectrumAnalysisService.exportQCResultTXT(sampleId, dbName, sampleFileName, gasFileName, detFileName, request, response);
}
@GetMapping("viewRLR")
@ApiOperation(value = "查看RLR数据", notes = "查看RLR数据")
public Result viewRLR(Integer sampleId, String sampleFileName, String gasFileName, String detFileName, HttpServletRequest request) {

View File

@ -44,6 +44,8 @@ public interface ISpectrumAnalysisService {
void exportQCResult(Integer sampleId, String dbName, String sampleFileName, String gasFileName, String detFileName, HttpServletRequest request, HttpServletResponse response);
void exportQCResultTXT(Integer sampleId, String dbName, String sampleFileName, String gasFileName, String detFileName, HttpServletRequest request, HttpServletResponse response);
Result viewRLR(Integer sampleId, String sampleFileName, String gasFileName, String detFileName, HttpServletRequest request);
void exportRLR(BetaRLR betaRLR, HttpServletResponse response);

View File

@ -53,6 +53,7 @@ import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.text.ParseException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@ -1574,6 +1575,56 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
ExportUtil.exportXls(response,template,dataMap,export);
}
@Override
public void exportQCResultTXT(Integer sampleId, String dbName, String sampleFileName, String gasFileName, String detFileName, HttpServletRequest request, HttpServletResponse response) {
Result<QCResult> result = viewQCResult(sampleId, dbName, sampleFileName, gasFileName, detFileName, request);
QCResult qcResult = result.getResult();
if (ObjectUtil.isNull(qcResult)) return;
StringBuffer strBuffer = new StringBuffer();
strBuffer.append(System.lineSeparator());
strBuffer.append(System.lineSeparator());
strBuffer.append(rowFormat("%-25s", "#QC RESULT"));
strBuffer.append(System.lineSeparator());
String qcTitle = "%s%-24s%-21s%-10s%-9s";
strBuffer.append(rowFormat(qcTitle, StringPool.SPACE, "QC Flags", "Evaluation Metrics", "Value", "Status"));
strBuffer.append(System.lineSeparator());
strBuffer.append(rowFormat(qcTitle, StringPool.SPACE, "Collection Time (h)", qcResult.getCollectTimeEvaluationMetrics(), qcResult.getCollectTimeValue(), qcResult.getCollectTimeStatus()));
strBuffer.append(System.lineSeparator());
strBuffer.append(rowFormat(qcTitle, StringPool.SPACE, "Acqusition Time (h)", qcResult.getAcquisitionTimeEvaluationMetrics(), qcResult.getAcquisitionTimeValue(), qcResult.getAcquisitionTimeStatus()));
strBuffer.append(System.lineSeparator());
strBuffer.append(rowFormat(qcTitle, StringPool.SPACE, "Xenon Volume (ml)", qcResult.getXenonVolumeEvaluationMetrics(), qcResult.getXenonVolumeValue(), qcResult.getXenonVolumeStatus()));
strBuffer.append(System.lineSeparator());
strBuffer.append(rowFormat(qcTitle, StringPool.SPACE, "Gas Bg", qcResult.getGasBgEvaluationMetrics(), qcResult.getGasBgValue(), qcResult.isGasBgValueAndStatus()?"true":"false"));
strBuffer.append(System.lineSeparator());
strBuffer.append(rowFormat(qcTitle, StringPool.SPACE, "Det Bg", qcResult.getDetBgEvaluationMetrics(), qcResult.getDetBgValue(), qcResult.isDetBgValueAndStatus()?"true":"false"));
strBuffer.append(System.lineSeparator());
strBuffer.append(rowFormat(qcTitle, StringPool.SPACE, "MDC for Xe133 (mBq/m3)", qcResult.getXe133MDCEvaluationMetrics(), qcResult.getXe133MDCValue(), qcResult.getXe133MDCStatus()));
strBuffer.append(System.lineSeparator());
strBuffer.append(System.lineSeparator());
OutputStream fos = null;
try {
String fileName = sampleFileName.substring(0, sampleFileName.lastIndexOf(StringPool.DOT) - 1);
fileName = fileName + "_QC Result.txt";
// 设置响应类型
response.setContentType("application/octet-stream");
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
// 解决中文不能生成文件
response.setHeader("Content-Disposition", "attachment; fileName=" + URLEncoder.encode(fileName, "UTF-8"));
fos = response.getOutputStream();
fos.write(strBuffer.toString().getBytes());
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
try {
fos.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
@Override
public Result viewRLR(Integer sampleId, String sampleFileName, String gasFileName, String detFileName, HttpServletRequest request) {
Result result = new Result();