feat:自建台站pekaInfomation

This commit is contained in:
nieziyan 2024-08-09 09:17:55 +08:00
parent 56e7c6adc5
commit 8aeebe3047
4 changed files with 125 additions and 0 deletions

View File

@ -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 <T> void exportXls(HttpServletResponse response, List<Map<String, Object>> 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 <T> void exportXls(HttpServletResponse response, Class<T> target, List<T> data){
exportXls(response, target, data, "file.xls");
}

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -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<String, SelfStationData> 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<String, List<TablePeak>> result = new HashMap<>();
SelfStationVueData sampleVueData = selfStationData.getSampleVueData();
PHDFile phd1 = sampleVueData.getROIOnePHDFile();
PHDFile phd2 = sampleVueData.getROITwoPHDFile();
PHDFile phd3 = sampleVueData.getROIThreePHDFile();
PHDFile phd4 = sampleVueData.getROIFourPHDFile();
List<PHDFile> phdFiles = ListUtil.toList(phd1, phd2, phd3, phd4);
for (int i = 0; i < phdFiles.size(); i++) {
PHDFile phdFile = phdFiles.get(i);
List<PeakInfo> vPeak = phdFile.getVPeak();
if (CollUtil.isEmpty(vPeak)) continue;
List<TablePeak> 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<String, SelfStationData> 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<PHDFile> phdFiles = ListUtil.toList(phd1, phd2, phd3, phd4);
List<Map<String, Object>> dataList = new ArrayList<>();
for (int i = 0; i < phdFiles.size(); i++) {
PHDFile phdFile = phdFiles.get(i);
List<PeakInfo> vPeak = phdFile.getVPeak();
if (CollUtil.isEmpty(vPeak)) continue;
Map<String, Object> data = new HashMap<>();
ExportParams exportParam = new ExportParams();
exportParam.setSheetName("ROI_" + (i + 1));
data.put("title", exportParam);
data.put("entity", TablePeak.class);
List<TablePeak> 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;