From 1812b1e5ca7472ab8b1dfee3e822efa7a4737607 Mon Sep 17 00:00:00 2001 From: qiaoqinzheng Date: Mon, 20 Nov 2023 10:15:55 +0800 Subject: [PATCH] =?UTF-8?q?beta=E5=AF=BC=E5=87=BAQC=20Result=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3txt=E5=AF=BC=E5=87=BA=E5=8A=9F=E8=83=BD=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E8=B0=83=E7=94=A8=E6=8E=A5=E5=8F=A3=E7=9A=84=E5=BD=A2?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SpectrumAnalysesController.java | 5 ++ .../service/ISpectrumAnalysisService.java | 2 + .../impl/SpectrumAnalysisServiceImpl.java | 51 +++++++++++++++++++ 3 files changed, 58 insertions(+) diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SpectrumAnalysesController.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SpectrumAnalysesController.java index 9c6e5263..555626aa 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SpectrumAnalysesController.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SpectrumAnalysesController.java @@ -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) { diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISpectrumAnalysisService.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISpectrumAnalysisService.java index 361b7234..07a5cdf0 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISpectrumAnalysisService.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISpectrumAnalysisService.java @@ -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); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java index 0031f0d8..953c449a 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java @@ -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 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();