diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ExportUtil.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ExportUtil.java index 1dbe6319..678bc2c8 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ExportUtil.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ExportUtil.java @@ -13,6 +13,7 @@ import org.apache.poi.ss.usermodel.Workbook; import org.jeecgframework.poi.excel.ExcelExportUtil; import org.jeecgframework.poi.excel.entity.ExportParams; import org.jeecgframework.poi.excel.entity.TemplateExportParams; +import org.jeecgframework.poi.excel.entity.enmus.ExcelType; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.DefaultResourceLoader; import org.springframework.core.io.Resource; @@ -104,6 +105,29 @@ public class ExportUtil { } } + public static void exportXls(HttpServletResponse response, List> dataList, String fileName){ + Workbook workbook = null; + OutputStream outputStream = null; + try { + // 设置文件名、Excel类型(xls|xlsx) + outputStream = ExportUtil.xls(response,fileName); + workbook = ExcelExportUtil. + exportExcel(dataList, ExcelType.HSSF); + workbook.write(outputStream); + } catch (IOException e) { + e.printStackTrace(); + }finally { + try { + if (ObjectUtil.isNotNull(outputStream)) + outputStream.close(); + if (ObjectUtil.isNotNull(workbook)) + workbook.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + public static void exportXls(HttpServletResponse response, Class target, List data){ exportXls(response, target, data, "file.xls"); } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SelfStationController.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SelfStationController.java index 32bda5d5..ec16ec2b 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SelfStationController.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SelfStationController.java @@ -427,4 +427,16 @@ public class SelfStationController { public Result viewBGLogViewer(String sampleFileName, HttpServletRequest request) { return selfStationService.viewBGLogViewer(sampleFileName, request); } + + @GetMapping("peakInformation") + @ApiOperation(value = "查看Peak Information页面数据", notes = "查看Peak Information页面数据") + public Result peakInformation(String sampleFileName, HttpServletRequest request){ + return selfStationService.peakInformation(sampleFileName, request); + } + + @GetMapping("exportPeakInformation") + @ApiOperation(value = "导出Peak Information页面数据", notes = "导出Peak Information页面数据") + public void exportPeakInformation(String sampleFileName, HttpServletRequest request, HttpServletResponse response){ + selfStationService.exportPeakInformation(sampleFileName, request, response); + } } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISelfStationService.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISelfStationService.java index 496b7b70..f1d954b7 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISelfStationService.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISelfStationService.java @@ -138,4 +138,8 @@ public interface ISelfStationService { Result viewAutomaticAnalysisLog(Integer sampleId); Result viewBGLogViewer(String sampleFileName, HttpServletRequest request); + + Result peakInformation(String sampleFileName, HttpServletRequest request); + + void exportPeakInformation(String sampleFileName, HttpServletRequest request, HttpServletResponse response); } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SelfStationServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SelfStationServiceImpl.java index 0290db0f..196fc622 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SelfStationServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SelfStationServiceImpl.java @@ -1,5 +1,6 @@ package org.jeecg.modules.service.impl; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.ListUtil; import cn.hutool.core.io.FileUtil; import cn.hutool.core.util.ObjectUtil; @@ -42,6 +43,8 @@ import org.jeecg.modules.native_jni.CalValuesHandler; import org.jeecg.modules.native_jni.EnergySpectrumHandler; import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct; import org.jeecg.modules.service.*; +import org.jeecgframework.poi.excel.entity.ExportParams; +import org.jeecgframework.poi.excel.entity.enmus.ExcelType; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -5412,6 +5415,88 @@ public class SelfStationServiceImpl implements ISelfStationService { return Result.OK(result); } + @Override + public Result peakInformation(String sampleFileName, HttpServletRequest request) { + String userName = JwtUtil.getUserNameByToken(request); + Cache selfCache = selfStationCache.getSelfCache(); + SelfStationData selfStationData = selfCache.getIfPresent(sampleFileName + StringPool.DASH + userName); + if (ObjectUtil.isNull(selfStationData)) + return Result.error("Please select the parse file first!"); + Map> result = new HashMap<>(); + SelfStationVueData sampleVueData = selfStationData.getSampleVueData(); + PHDFile phd1 = sampleVueData.getROIOnePHDFile(); + PHDFile phd2 = sampleVueData.getROITwoPHDFile(); + PHDFile phd3 = sampleVueData.getROIThreePHDFile(); + PHDFile phd4 = sampleVueData.getROIFourPHDFile(); + List phdFiles = ListUtil.toList(phd1, phd2, phd3, phd4); + for (int i = 0; i < phdFiles.size(); i++) { + PHDFile phdFile = phdFiles.get(i); + List vPeak = phdFile.getVPeak(); + if (CollUtil.isEmpty(vPeak)) continue; + List tablePeaks = new LinkedList<>(); + for (PeakInfo peak : vPeak) { + TablePeak tablePeak = new TablePeak(); + tablePeak.setEnergy(String.format("%.3f", peak.energy)); + tablePeak.setCentroid(String.format("%.3f", peak.peakCentroid)); + tablePeak.setMultiplet(String.valueOf(peak.multiIndex)); + tablePeak.setFwhm(String.format("%.3f", peak.fwhm)); + tablePeak.setNetArea(String.format("%.3f", peak.area)); + tablePeak.setAreaErr(peak.area > 0 ? String.format("%.3f", (peak.areaErr / peak.area) * 100) : "0"); + tablePeak.setSignificant(String.format("%.3f", peak.significance)); + tablePeak.setSensitivity(String.format("%.3f", peak.sensitivity)); + tablePeak.setIndentify(org.apache.commons.lang3.StringUtils.join(peak.nuclides, ";")); + tablePeaks.add(tablePeak); + } + result.put("Gamma_ROI_" + (i + 1), tablePeaks); + } + return Result.OK(result); + } + + @Override + public void exportPeakInformation(String sampleFileName, HttpServletRequest request, HttpServletResponse response) { + String userName = JwtUtil.getUserNameByToken(request); + Cache selfCache = selfStationCache.getSelfCache(); + SelfStationData selfStationData = selfCache.getIfPresent(sampleFileName + StringPool.DASH + userName); + if (ObjectUtil.isNull(selfStationData)) return; + SelfStationVueData sampleVueData = selfStationData.getSampleVueData(); + PHDFile phd1 = sampleVueData.getROIOnePHDFile(); + PHDFile phd2 = sampleVueData.getROITwoPHDFile(); + PHDFile phd3 = sampleVueData.getROIThreePHDFile(); + PHDFile phd4 = sampleVueData.getROIFourPHDFile(); + List phdFiles = ListUtil.toList(phd1, phd2, phd3, phd4); + List> dataList = new ArrayList<>(); + for (int i = 0; i < phdFiles.size(); i++) { + PHDFile phdFile = phdFiles.get(i); + List vPeak = phdFile.getVPeak(); + if (CollUtil.isEmpty(vPeak)) continue; + Map data = new HashMap<>(); + ExportParams exportParam = new ExportParams(); + exportParam.setSheetName("ROI_" + (i + 1)); + data.put("title", exportParam); + data.put("entity", TablePeak.class); + List tablePeaks = new LinkedList<>(); + for (int j = 0; j < vPeak.size(); j++) { + PeakInfo peak = vPeak.get(j); + TablePeak tablePeak = new TablePeak(); + tablePeak.setNo(j + 1); + tablePeak.setEnergy(String.format("%.3f", peak.energy)); + tablePeak.setCentroid(String.format("%.3f", peak.peakCentroid)); + tablePeak.setMultiplet(String.valueOf(peak.multiIndex)); + tablePeak.setFwhm(String.format("%.3f", peak.fwhm)); + tablePeak.setNetArea(String.format("%.3f", peak.area)); + tablePeak.setAreaErr(peak.area > 0 ? String.format("%.3f", (peak.areaErr / peak.area) * 100) : "0"); + tablePeak.setSignificant(String.format("%.3f", peak.significance)); + tablePeak.setSensitivity(String.format("%.3f", peak.sensitivity)); + tablePeak.setIndentify(org.apache.commons.lang3.StringUtils.join(peak.nuclides, ";")); + tablePeaks.add(tablePeak); + } + data.put("data", tablePeaks); + dataList.add(data); + } + if (CollUtil.isNotEmpty(dataList)) + ExportUtil.exportXls(response, dataList, "PeakInformation.xls"); + } + @Transactional public boolean SaveSampleToDB(PHDFile phd, String input_file_name) { boolean bRet = false;