Merge remote-tracking branch 'origin/SelfStation' into SelfStation
This commit is contained in:
commit
c0ba24aae4
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -27,14 +27,14 @@ import org.jeecg.modules.base.bizVo.AttributeItemVo;
|
|||
import org.jeecg.modules.base.dto.*;
|
||||
import org.jeecg.modules.base.entity.original.GardsSampleData;
|
||||
import org.jeecg.modules.base.entity.rnauto.*;
|
||||
import org.jeecg.modules.base.enums.DSType;
|
||||
import org.jeecg.modules.base.enums.MiddleDataType;
|
||||
import org.jeecg.modules.base.enums.SpectrumType;
|
||||
import org.jeecg.modules.base.enums.*;
|
||||
import org.jeecg.modules.config.datasource.DataSourceSwitcher;
|
||||
import org.jeecg.modules.eneity.event.SpectrumErrorEvent;
|
||||
import org.jeecg.modules.entity.vo.*;
|
||||
import org.jeecg.modules.enums.ErrorType;
|
||||
import org.jeecg.modules.exception.AnalySpectrumException;
|
||||
import org.jeecg.modules.exception.CAnalyseException;
|
||||
import org.jeecg.modules.exception.FileNotExistException;
|
||||
import org.jeecg.modules.file.FileOperation;
|
||||
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
|
||||
import org.jeecg.modules.native_jni.struct.BgBoundary;
|
||||
|
@ -124,9 +124,9 @@ public class Sample_C_Analysis {
|
|||
*/
|
||||
private String arrFileName;
|
||||
|
||||
/*
|
||||
* 自建台站谱解析所需的四个Gamms谱对象
|
||||
* */
|
||||
/*
|
||||
* 自建台站谱解析所需的四个Gamms谱对象
|
||||
*/
|
||||
private PHDFile phdFile1;
|
||||
private PHDFile phdFile2;
|
||||
private PHDFile phdFile3;
|
||||
|
@ -136,6 +136,18 @@ public class Sample_C_Analysis {
|
|||
|
||||
private Map<Integer, GStoreMiddleProcessData> middleDataMap;
|
||||
|
||||
protected Date startAnalysisTime;
|
||||
|
||||
protected Date endAnalysisTime;
|
||||
|
||||
protected GardsSampleData detSampleData = null;
|
||||
|
||||
protected EnergySpectrumStruct detStruct = null;
|
||||
|
||||
private String detFileFinalPath;
|
||||
|
||||
protected ParsingProcessLog parsingProcessLog;
|
||||
|
||||
public Sample_C_Analysis(AbstractS_D_Q_G_SpectrumHandler spectrumHandler, EnergySpectrumStruct sampleStruct, SpectrumServiceQuotes serviceQuotes,
|
||||
GardsSampleData sampleData) {
|
||||
this.spectrumHandler = spectrumHandler;
|
||||
|
@ -144,6 +156,7 @@ public class Sample_C_Analysis {
|
|||
this.sampleStruct = sampleStruct;
|
||||
this.systemType = sampleStruct.system_type;
|
||||
this.dataType = sampleStruct.data_type;
|
||||
this.parsingProcessLog = spectrumHandler.parsingProcessLog;
|
||||
this.sampleInputFilename = sampleData.getInputFileName();
|
||||
this.sampleFilename = StringUtils.substring(sampleData.getInputFileName(),
|
||||
sampleData.getInputFileName().lastIndexOf((StringConstant.SLASH))+1);
|
||||
|
@ -152,6 +165,20 @@ public class Sample_C_Analysis {
|
|||
public void analysis() throws CAnalyseException, AnalySpectrumException{
|
||||
log.info("SelfStaion自动处理分析--Start");
|
||||
try {
|
||||
this.startAnalysisTime = new Date();
|
||||
|
||||
//声明分析日志对象
|
||||
// parsingProcessLog.setSample_C_Analysis(this);
|
||||
|
||||
//查询det数据(sampleId,inputFileName) sample数据在构造函数已经传过来
|
||||
this.queryPHDFile();
|
||||
|
||||
//查找det谱PHD文件 sample谱PHD文件位置在构造函数已经传过来
|
||||
this.getPHDFile();
|
||||
|
||||
// Beta谱进行分析 TODO Analysis
|
||||
|
||||
|
||||
//获取PHD文件的路径以及文件名称信息
|
||||
String sampleFilePathName = spectrumHandler.spectrumFile.getAbsolutePath().replace("\\", StringPool.SLASH);
|
||||
this.sampleFilePath = sampleFilePathName.substring(0, sampleFilePathName.lastIndexOf(StringPool.SLASH));
|
||||
|
@ -235,6 +262,8 @@ public class Sample_C_Analysis {
|
|||
} else {
|
||||
throw new CAnalyseException("Sample Analyse Error at "+DateUtils.formatDate(new Date(),"yyyy-MM-dd HH:mm:ss"));
|
||||
}
|
||||
}finally {
|
||||
this.endAnalysisTime = new Date();
|
||||
}
|
||||
log.info("SelfStaion自动处理分析--End");
|
||||
}
|
||||
|
@ -342,6 +371,43 @@ public class Sample_C_Analysis {
|
|||
return rootPath + saveFilePath + StrUtil.SLASH + saveRelativePath;
|
||||
}
|
||||
|
||||
private void queryPHDFile() throws FileNotExistException {
|
||||
//查询det和gas能谱文
|
||||
this.detSampleData = serviceQuotes.getSampleDataService().getSampleIdAndInputFileName(this.sampleStruct.detector_bk_measurement_id, DataTypeAbbr.DETBKPHD.getType(), this.sampleStruct.system_type);
|
||||
|
||||
//如果找不到sample、det、gas谱文件数据则解析失败修改记录状态
|
||||
if(StringUtils.isEmpty(this.sampleData.getInputFileName()) || Objects.isNull(this.detSampleData) || StringUtils.isEmpty(this.detSampleData.getInputFileName())){
|
||||
parsingProcessLog.setFileNotExist(true);
|
||||
|
||||
this.serviceQuotes.getSampleDataService().updateStatus(SampleStatus.FAIL.getValue(),this.sampleData.getInputFileName());
|
||||
ErrorLogManager.getInstance().write(new SpectrumErrorEvent(new Date(), ErrorType.GAS_OR_DET_ERROR,this.sampleFilename));
|
||||
throw new FileNotExistException("gas or det file is no exist or is error..");
|
||||
}
|
||||
}
|
||||
|
||||
private void getPHDFile() throws FileNotExistException {
|
||||
boolean flag = false;
|
||||
|
||||
//det谱PHD文件本地路径
|
||||
StringBuilder detFileFinalPath = new StringBuilder();
|
||||
detFileFinalPath.append(this.serviceQuotes.getSpectrumPathProperties().getRootPath());
|
||||
detFileFinalPath.append(this.serviceQuotes.getSpectrumPathProperties().getSaveFilePath());
|
||||
detFileFinalPath.append(StrUtil.SLASH);
|
||||
detFileFinalPath.append(detSampleData.getInputFileName());
|
||||
this.detFileFinalPath = detFileFinalPath.toString();
|
||||
File detFile = new File(this.detFileFinalPath);
|
||||
if(!detFile.exists()){
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if(flag){
|
||||
parsingProcessLog.setFileNotExist(true);
|
||||
ErrorLogManager.getInstance().write(new SpectrumErrorEvent(new Date(), ErrorType.GAS_OR_DET_ERROR,this.sampleFilename));
|
||||
throw new FileNotExistException("gas or det file is no exist or is error..");
|
||||
}
|
||||
this.detStruct = EnergySpectrumHandler.getSourceData(this.detFileFinalPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取计算MDC参数文件方法
|
||||
*/
|
||||
|
@ -451,8 +517,9 @@ public class Sample_C_Analysis {
|
|||
final TransactionStatus transactionStatus = serviceQuotes.getTransactionManager().getTransaction(serviceQuotes.getTransactionDefinition());
|
||||
try {
|
||||
Integer sampleId = this.sampleData.getSampleId();
|
||||
// 保存分析结果 ==> INSERT INTO RNAUTO.GARDS_ANALYSES
|
||||
saveAnalysis(middleDatas[0], sampleId);
|
||||
// 保存分析结果 ==> INSERT INTO RNAUTO.GARDS_ANALYSES TODO 填充Beta分析产生的报告和日志地址
|
||||
saveAnalysis(sampleId, this.detSampleData, this.startAnalysisTime,
|
||||
this.endAnalysisTime, null, null);
|
||||
// 获取分析结果ID ==> SELECT IDANALYSIS
|
||||
idAnalysis = serviceQuotes.getAnalysesService().getIdAnalysis(sampleId);
|
||||
// 保存分析结果 ==> INSERT INTO RNAUTO.GARDS_ANALYSES
|
||||
|
@ -1334,31 +1401,25 @@ public class Sample_C_Analysis {
|
|||
}
|
||||
}
|
||||
|
||||
public void saveAnalysis(GStoreMiddleProcessData middleData, Integer sampleId){
|
||||
GardsAnalyses analysis = toAnalysis(middleData);
|
||||
public void saveAnalysis(Integer sampleId, GardsSampleData detSampleData, Date analysisBegin,
|
||||
Date analysisEnd, String logPath, String reportPath){
|
||||
GardsAnalyses analysis = new GardsAnalyses();
|
||||
analysis.setSampleId(sampleId);
|
||||
analysis.setCategory(1);//按C++代码写死的1,该字段是分级结果张博士还没有想好数据要不要分级1,2,3,4
|
||||
analysis.setAnalysisBegin(analysisBegin);
|
||||
analysis.setAnalysisEnd(analysisEnd);
|
||||
analysis.setType(AnalysesType.AUTO.getValue());
|
||||
analysis.setSoftware(serviceQuotes.getSoftwareProperties().getSwName());
|
||||
analysis.setSwVersion(serviceQuotes.getSoftwareProperties().getSwVersion());
|
||||
analysis.setAnalyst(serviceQuotes.getSoftwareProperties().getAnalyst());
|
||||
analysis.setComments("test");//按C++代码写死的test
|
||||
analysis.setUseddetphd(detSampleData.getInputFileName());
|
||||
analysis.setUseddetphdId(detSampleData.getSampleId());
|
||||
analysis.setLogPath(FileOperation.separatorConvert(logPath));
|
||||
analysis.setReportPath(FileOperation.separatorConvert(reportPath));
|
||||
serviceQuotes.getAnalysesService().save(analysis);
|
||||
}
|
||||
|
||||
private GardsAnalyses toAnalysis(GStoreMiddleProcessData middleData){
|
||||
GardsAnalyses gardsAnalyses = new GardsAnalyses();
|
||||
String dateTime = DateConstant.DATE_BIAS_TIME;
|
||||
String analysisBegin = middleData.getAnalyses_analysisBegin();
|
||||
Date analysis_Begin = DateUtil.parse(analysisBegin, dateTime)
|
||||
.toJdkDate();
|
||||
gardsAnalyses.setAnalysisBegin(analysis_Begin);
|
||||
String analysisEnd = middleData.getAnalyses_analysisEnd();
|
||||
Date analysis_End = DateUtil.parse(analysisEnd, dateTime)
|
||||
.toJdkDate();
|
||||
gardsAnalyses.setAnalysisEnd(analysis_End);
|
||||
gardsAnalyses.setType(middleData.getAnalyses_type());
|
||||
gardsAnalyses.setSoftware(middleData.getAnalyses_software());
|
||||
gardsAnalyses.setSwVersion(middleData.getAnalyses_swVersion());
|
||||
gardsAnalyses.setAnalyst(middleData.getAnalyses_analyst());
|
||||
gardsAnalyses.setComments(middleData.getAnalyses_comments());
|
||||
return gardsAnalyses;
|
||||
}
|
||||
|
||||
/* public <T1,T2> List<T2> mapFields(T1 source, T2 tartget, String baseLine, Map<String,String> fieldMap) {
|
||||
try {
|
||||
List<T2> result = new ArrayList<>();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -43,6 +44,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;
|
||||
|
@ -5387,6 +5390,88 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf
|
|||
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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user