人工交互beta,gamma存储并上传日志,报告文件

This commit is contained in:
qiaoqinzheng 2024-01-15 19:30:07 +08:00
parent 76acc20a7d
commit 55f9cd49e1
8 changed files with 664 additions and 224 deletions

View File

@ -27,6 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.*;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.util.*;
import java.util.stream.Collectors;
@ -628,44 +629,6 @@ public class PHDFileUtil extends AbstractLogOrReport {
return rData;
}
// public File analyzeFile(String path, String fileName) {
// //连接ftp
// FTPClient ftpClient = ftpUtil.LoginFTP();
// InputStream inputStream = null;
// File file = null;
// try {
// //被动模式
// ftpClient.enterLocalPassiveMode();
// //设置文件类型--二进制文件
// ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
// //
// ftpClient.setControlEncoding("UTF-8");
// ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
// //切换文件路径
// ftpClient.changeWorkingDirectory(path);
// inputStream = ftpClient.retrieveFileStream(fileName);
// if (Objects.nonNull(inputStream)){
// file = File.createTempFile("betaGamma", null);
// //将ftp文件的输入流复制给临时文件
// FileUtils.copyInputStreamToFile(inputStream, file);
// }
// } catch (IOException e) {
// throw new RuntimeException(e);
// } finally {
// try {
// if (Objects.nonNull(ftpClient)){
// ftpClient.disconnect();
// }
// if (Objects.nonNull(inputStream)){
// inputStream.close();
// }
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
// return file;
// }
public boolean analyzeSpectrum(File sampleTmp, File gasTmp, File detTmp, BgCalibratePara BgCalPara, Map<String, Object> map, BetaDataFile betaDataFile) {
boolean bRet = true;
//调用动态库解析文件
@ -1987,6 +1950,449 @@ public class PHDFileUtil extends AbstractLogOrReport {
}
}
public String OutPutRnRpt(BetaDataFile betaDataFile) {
GardsCalibrationSpectrum gammaCalibrationParamS = new GardsCalibrationSpectrum();
GardsCalibrationSpectrum gammaCalibrationParamG = new GardsCalibrationSpectrum();
GardsCalibrationSpectrum gammaCalibrationParamD = new GardsCalibrationSpectrum();
GardsCalibrationSpectrum gammaCalibrationParamES = new GardsCalibrationSpectrum();
GardsCalibrationSpectrum gammaCalibrationParamEG = new GardsCalibrationSpectrum();
GardsCalibrationSpectrum gammaCalibrationParamED = new GardsCalibrationSpectrum();
GardsCalibrationSpectrum betaCalibrationParamS = new GardsCalibrationSpectrum();
GardsCalibrationSpectrum betaCalibrationParamG = new GardsCalibrationSpectrum();
GardsCalibrationSpectrum betaCalibrationParamD = new GardsCalibrationSpectrum();
GardsCalibrationSpectrum betaCalibrationParamES = new GardsCalibrationSpectrum();
GardsCalibrationSpectrum betaCalibrationParamEG = new GardsCalibrationSpectrum();
GardsCalibrationSpectrum betaCalibrationParamED = new GardsCalibrationSpectrum();
StringBuffer strBuffer = new StringBuffer();
//对分析后的内容进行数据获取
List<GardsROIChannelsSpectrum> channelsSpectrums = betaDataFile.getRoiChannelsSpectrumList();
List<GardsROIChannelsSpectrum> roiChannelsSpectrumsSample = channelsSpectrums.stream().filter(item -> item.getDataType().equalsIgnoreCase("S")).collect(Collectors.toList());
List<GardsROIChannelsSpectrum> roiChannelsSpectrumsGas = channelsSpectrums.stream().filter(item -> item.getDataType().equalsIgnoreCase("G")).collect(Collectors.toList());
List<GardsROIChannelsSpectrum> roiChannelsSpectrumsDet = channelsSpectrums.stream().filter(item -> item.getDataType().equalsIgnoreCase("D")).collect(Collectors.toList());
List<GardsROIResultsSpectrum> resultsSpectrums = betaDataFile.getRoiResultsSpectrumList();
List<GardsXeResultsSpectrum> xeResultsSpectrums = betaDataFile.getXeResultsSpectrumList();
//#SAMPLE: LIMITS PER ROI GAMMA
List<GardsCalibrationSpectrum> gammaCalibrationParamList = betaDataFile.getGammaCalibrationSpectrumList();
List<GardsCalibrationSpectrum> gammaCalibrationSpectrumEList = betaDataFile.getGammaCalibrationSpectrumEList();
for (int i=0; i<gammaCalibrationParamList.size(); i++) {
if (gammaCalibrationParamList.get(i).getDataType().equals("S")) {
gammaCalibrationParamS = gammaCalibrationParamList.get(i);
} else if (gammaCalibrationParamList.get(i).getDataType().equals("G")) {
gammaCalibrationParamG = gammaCalibrationParamList.get(i);
} else if (gammaCalibrationParamList.get(i).getDataType().equals("D")) {
gammaCalibrationParamD = gammaCalibrationParamList.get(i);
}
}
for (int i=0; i<gammaCalibrationSpectrumEList.size(); i++) {
if (gammaCalibrationSpectrumEList.get(i).getDataType().equals("S")) {
gammaCalibrationParamES = gammaCalibrationSpectrumEList.get(i);
} else if (gammaCalibrationSpectrumEList.get(i).getDataType().equals("G")) {
gammaCalibrationParamEG = gammaCalibrationSpectrumEList.get(i);
} else if (gammaCalibrationSpectrumEList.get(i).getDataType().equals("D")) {
gammaCalibrationParamED = gammaCalibrationSpectrumEList.get(i);
}
}
//#SAMPLE: LIMITS PER ROI BETA
List<GardsCalibrationSpectrum> betaCalibrationParamList = betaDataFile.getBetaCalibrationSpectrumList();
List<GardsCalibrationSpectrum> betaCalibrationSpectrumEList = betaDataFile.getBetaCalibrationSpectrumEList();
for (int i=0; i<betaCalibrationParamList.size(); i++) {
if (betaCalibrationParamList.get(i).getDataType().equals("S")) {
betaCalibrationParamS = betaCalibrationParamList.get(i);
} else if (betaCalibrationParamList.get(i).getDataType().equals("G")) {
betaCalibrationParamG = betaCalibrationParamList.get(i);
} else if (betaCalibrationParamList.get(i).getDataType().equals("D")) {
betaCalibrationParamD = betaCalibrationParamList.get(i);
}
}
for (int i=0; i<betaCalibrationSpectrumEList.size(); i++) {
if (betaCalibrationSpectrumEList.get(i).getDataType().equals("S")) {
betaCalibrationParamES = betaCalibrationSpectrumEList.get(i);
} else if (betaCalibrationSpectrumEList.get(i).getDataType().equals("G")) {
betaCalibrationParamEG = betaCalibrationSpectrumEList.get(i);
} else if (betaCalibrationSpectrumEList.get(i).getDataType().equals("D")) {
betaCalibrationParamED = betaCalibrationSpectrumEList.get(i);
}
}
Information information = new Information();
//sampleFile 相关数据
try {
EnergySpectrumStruct sampleSourceData = betaDataFile.getSampleStruct();
if (Objects.nonNull(sampleSourceData)) {
information.setSample_measid_name(sampleSourceData.measurement_id);
information.setSample_det_measid_name(sampleSourceData.detector_bk_measurement_id);
information.setSample_gas_measid_name(sampleSourceData.gas_bk_measurement_id);
information.setSit_det_code(sampleSourceData.site_code);
information.setSample_type(sampleSourceData.system_type);
information.setGeometry(sampleSourceData.sample_geometry);
information.setSpectral_qualifie(sampleSourceData.spectrum_quantity);
String transmit_dtg_str=sampleSourceData.transmit_date+StringPool.SPACE+sampleSourceData.transmit_time;
Date transmit_dtg = DateUtils.parseDate(transmit_dtg_str);
information.setTransmit_dtg(transmit_dtg);
information.setDetect_code(sampleSourceData.detector_code);
information.setMeasurementID(sampleSourceData.measurement_id.replace("\\","/"));
information.setBkgdMeasurementID(sampleSourceData.detector_bk_measurement_id.replace("\\","/"));
information.setGasBkgdMeasurementID(sampleSourceData.gas_bk_measurement_id.replace("\\","/"));
information.setSampleRefId(sampleSourceData.sample_ref_id);
String collect_start_str = sampleSourceData.collection_start_date+StringPool.SPACE+sampleSourceData.collection_start_time;
Date collect_start = DateUtils.parseDate(collect_start_str);
information.setCollect_start(collect_start);
String collect_stop_str = sampleSourceData.collection_stop_date+StringPool.SPACE+sampleSourceData.collection_stop_time;
Date collect_stop = DateUtils.parseDate(collect_stop_str);
information.setCollect_stop(collect_stop);
information.setS_xe_stable_volume(sampleSourceData.air_volume);
String acquisition_start_str = sampleSourceData.acquisition_start_date+StringPool.SPACE+sampleSourceData.acquisition_start_time;
Date acquisition_start = DateUtils.parseDate(acquisition_start_str);
information.setAcquisition_start(acquisition_start);
long dataTime = (long) (acquisition_start.getTime() + sampleSourceData.acquisition_real_time * 1000);
String acquisition_stop_str = DateUtils.formatDate(new Date(dataTime), "yyyy/MM/dd HH:mm:ss");
Date acquisition_stop = DateUtils.parseDate(acquisition_stop_str);
information.setAcquisition_stop(acquisition_stop);
information.setAcquisition_real_sec(sampleSourceData.acquisition_real_time);
information.setAcquisition_live_sec(sampleSourceData.acquisition_live_time);
information.setS_volume_of_Xe(sampleSourceData.sample_volume_of_Xe);
}
EnergySpectrumStruct gasSourceData = betaDataFile.getGasStruct();
if (Objects.nonNull(gasSourceData)) {
information.setGas_measid_name(gasSourceData.measurement_id);
}
EnergySpectrumStruct detSourceData = betaDataFile.getDetStruct();
if (Objects.nonNull(detSourceData)) {
information.setDet_measid_name(detSourceData.measurement_id);
}
strBuffer.append(titleFormat("%sCNL06 GENERATED REPORT%s", 60, StringPool.SPACE, StringPool.SPACE));
strBuffer.append(System.lineSeparator());
strBuffer.append(titleFormat("%sREVIEWED RADIONUCLIDE REPORT%s", 57, StringPool.SPACE, StringPool.SPACE));
strBuffer.append(System.lineSeparator());
strBuffer.append(titleFormat("%s(Noble Gas Version)%s", 61, StringPool.SPACE, StringPool.SPACE));
strBuffer.append(System.lineSeparator());
strBuffer.append(titleFormat("%sCreation Date "+DateUtils.formatDate(new Date(), "yyyy/MM/dd-HH:mm:ss")+"%s", 54, StringPool.SPACE, StringPool.SPACE));
strBuffer.append(System.lineSeparator());
strBuffer.append(System.lineSeparator());
strBuffer.append("#FILE INFORMATION");
strBuffer.append(System.lineSeparator());
strBuffer.append(rowFormat("%sSampleMeasID:%-15s%s", StringPool.SPACE, StringPool.SPACE, information.getMeasurementID()));
strBuffer.append(System.lineSeparator());
strBuffer.append(rowFormat("%sGASBKMeasID:%-16s%s", StringPool.SPACE, StringPool.SPACE, information.getGasBkgdMeasurementID()));
strBuffer.append(System.lineSeparator());
strBuffer.append(rowFormat("%sSRID:%-23s%s", StringPool.SPACE, StringPool.SPACE, information.getSampleRefId()));
strBuffer.append(System.lineSeparator());
strBuffer.append(rowFormat("%sDetector Type:%-14s%s", StringPool.SPACE, StringPool.SPACE, "3D b-g"));
strBuffer.append(System.lineSeparator());
strBuffer.append(System.lineSeparator());
strBuffer.append("#COLLECTION INFORMATION");
strBuffer.append(System.lineSeparator());
strBuffer.append(rowFormat("%sStation CODE:%-15s%s", StringPool.SPACE, StringPool.SPACE, information.getSit_det_code()));
strBuffer.append(System.lineSeparator());
strBuffer.append(rowFormat("%sDetector CODE:%-14s%s", StringPool.SPACE, StringPool.SPACE, information.getDetect_code()));
strBuffer.append(System.lineSeparator());
strBuffer.append(rowFormat("%sCollection Start:%-11s%s", StringPool.SPACE, StringPool.SPACE, DateUtils.formatDate(information.getCollect_start(), "yyyy/MM/dd HH:mm:ss")));
strBuffer.append(System.lineSeparator());
strBuffer.append(rowFormat("%sCollection Stop:%-12s%s", StringPool.SPACE, StringPool.SPACE, DateUtils.formatDate(information.getCollect_stop(), "yyyy/MM/dd HH:mm:ss")));
strBuffer.append(System.lineSeparator());
strBuffer.append(rowFormat("%sCollection TIME(h):%-9s%s", StringPool.SPACE, StringPool.SPACE, String.valueOf(((information.getCollect_stop().getTime()-information.getCollect_start().getTime())/1000)/3600)));
strBuffer.append(System.lineSeparator());
strBuffer.append(rowFormat("%sAir Volume[cm3]:%-12s%s", StringPool.SPACE, StringPool.SPACE, String.valueOf(information.getS_xe_stable_volume())));
strBuffer.append(System.lineSeparator());
strBuffer.append(rowFormat("%sXe Volume[cm3]:%-13s%s", StringPool.SPACE, StringPool.SPACE, String.valueOf(information.getS_volume_of_Xe())));
strBuffer.append(System.lineSeparator());
strBuffer.append(System.lineSeparator());
strBuffer.append("#ACQUISITION INFORMATION");
strBuffer.append(System.lineSeparator());
strBuffer.append(rowFormat("%sAcquisition Start:%-10s%s", StringPool.SPACE, StringPool.SPACE, DateUtils.formatDate(information.getAcquisition_start(), "yyyy/MM/dd HH:mm:ss")));
strBuffer.append(System.lineSeparator());
strBuffer.append(rowFormat("%sAcq Real Time(s):%-11s%s", StringPool.SPACE, StringPool.SPACE, String.valueOf(information.getAcquisition_real_sec())));
strBuffer.append(System.lineSeparator());
strBuffer.append(rowFormat("%sAcq Live Time:%-14s%s", StringPool.SPACE, StringPool.SPACE, String.valueOf(information.getAcquisition_live_sec())));
strBuffer.append(System.lineSeparator());
strBuffer.append(System.lineSeparator());
strBuffer.append("#SOFTWARE");
strBuffer.append(System.lineSeparator());
strBuffer.append(rowFormat("%sversion:%-20s%s", StringPool.SPACE, StringPool.SPACE, "1.0.1"));
strBuffer.append(System.lineSeparator());
strBuffer.append(System.lineSeparator());
strBuffer.append("#SAMPLE Old CALIBRATION");
strBuffer.append(System.lineSeparator());
strBuffer.append(rowFormat("%sOld Beta%-43sOld Gamma%-42s", StringPool.SPACE, StringPool.SPACE, StringPool.SPACE));
strBuffer.append(System.lineSeparator());
//拼接历史计算公式 CH
String oldBetaSampleCHStr = rowFormat("%sCH(x) = (%s)+(%s)*x+(%s)x*x", StringPool.SPACE, NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaToUiOld().get(0)),
NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaToUiOld().get(1)), NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaToUiOld().get(2)));
String oldGammaSampleCHStr = rowFormat("CH(x) = (%s)+(%s)*x+(%s)x*x%-24s", NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaToUiOld().get(0)), NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaToUiOld().get(1)),
NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaToUiOld().get(2)), StringPool.SPACE);
strBuffer.append(rowFormat("%s%-"+(52-oldBetaSampleCHStr.length())+"s%s", oldBetaSampleCHStr, StringPool.SPACE, oldGammaSampleCHStr));
strBuffer.append(System.lineSeparator());
//拼接历史计算公式 E
String oldBetaSampleEStr = rowFormat("%sE(x) = (%s)+(%s)*x+(%s)x*x", StringPool.SPACE, NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaOld().get(0)),
NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaOld().get(1)), NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaOld().get(2)));
String oldGammaSampleEStr = rowFormat("E(x) = (%s)+(%s)*x+(%s)x*x%-24s", NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaOld().get(0)), NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaOld().get(1)),
NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaOld().get(2)), StringPool.SPACE);
strBuffer.append(rowFormat("%s%-"+(52-oldBetaSampleEStr.length())+"s%s", oldBetaSampleEStr, StringPool.SPACE, oldGammaSampleEStr));
strBuffer.append(System.lineSeparator());
strBuffer.append(System.lineSeparator());
strBuffer.append("#SAMPLE New CALIBRATION");
strBuffer.append(System.lineSeparator());
strBuffer.append(rowFormat("%sNew Beta%-43sNew Gamma%-42s", StringPool.SPACE, StringPool.SPACE, StringPool.SPACE));
strBuffer.append(System.lineSeparator());
//拼接新计算公式 CH
String newBetaSampleCHStr = rowFormat("%sCH(x) = (%s)+(%s)*x+(%s)x*x", StringPool.SPACE,
(Objects.isNull(betaCalibrationParamES.getCoeff1())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaToUiOld().get(0)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamES.getCoeff1()))),
(Objects.isNull(betaCalibrationParamES.getCoeff2())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaToUiOld().get(1)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamES.getCoeff2()))),
(Objects.isNull(betaCalibrationParamES.getCoeff3())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaToUiOld().get(2)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamES.getCoeff3()))));
String newGammaSampleCHStr = rowFormat("CH(x) = (%s)+(%s)*x+(%s)x*x%-24s", (Objects.isNull(gammaCalibrationParamES.getCoeff1())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaToUiOld().get(0)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamES.getCoeff1()))),
(Objects.isNull(gammaCalibrationParamES.getCoeff2())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaToUiOld().get(1)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamES.getCoeff2()))),
(Objects.isNull(gammaCalibrationParamES.getCoeff3())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaToUiOld().get(2)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamES.getCoeff3()))),
StringPool.SPACE);
strBuffer.append(rowFormat("%s%-"+(52-newBetaSampleCHStr.length())+"s%s", newBetaSampleCHStr, StringPool.SPACE, newGammaSampleCHStr));
strBuffer.append(System.lineSeparator());
//拼接新计算公式 E
String newBetaSampleEStr = rowFormat("%sE(x) = (%s)+(%s)*x+(%s)x*x", StringPool.SPACE,
(Objects.isNull(betaCalibrationParamS.getCoeff1())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaOld().get(0)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamS.getCoeff1()))),
(Objects.isNull(betaCalibrationParamS.getCoeff2())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaOld().get(1)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamS.getCoeff2()))),
(Objects.isNull(betaCalibrationParamS.getCoeff3())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaOld().get(2)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamS.getCoeff3()))));
String newGammaSampleEStr = rowFormat("E(x) = (%s)+(%s)*x+(%s)x*x%-24s", (Objects.isNull(gammaCalibrationParamS.getCoeff1())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaOld().get(0)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamS.getCoeff1()))),
(Objects.isNull(gammaCalibrationParamS.getCoeff2())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaOld().get(1)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamS.getCoeff2()))),
(Objects.isNull(gammaCalibrationParamS.getCoeff3())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaOld().get(2)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamS.getCoeff3()))),
StringPool.SPACE);
strBuffer.append(rowFormat("%s%-"+(52-newBetaSampleEStr.length())+"s%s", newBetaSampleEStr, StringPool.SPACE, newGammaSampleEStr));
strBuffer.append(System.lineSeparator());
strBuffer.append(System.lineSeparator());
strBuffer.append("#SAMPLE: LIMITS PER ROI");
strBuffer.append(System.lineSeparator());
String limitRoi = "%s%-15s%-15s%-15s";
strBuffer.append(rowFormat(limitRoi, StringPool.SPACE, "Roi", "Beta", "Gamma"));
strBuffer.append(System.lineSeparator());
if (CollectionUtils.isNotEmpty(roiChannelsSpectrumsSample)) {
for (GardsROIChannelsSpectrum channelsSpectrum:roiChannelsSpectrumsSample) {
strBuffer.append(rowFormat(limitRoi, StringPool.SPACE, String.valueOf(channelsSpectrum.getRoi()), channelsSpectrum.getBChanStart()+" to "+channelsSpectrum.getBChanStop(), channelsSpectrum.getGChanStart()+" to "+channelsSpectrum.getGChanStop()));
strBuffer.append(System.lineSeparator());
}
}
strBuffer.append(System.lineSeparator());
strBuffer.append("#DET Old CALIBRATION");
strBuffer.append(System.lineSeparator());
strBuffer.append(rowFormat("%sOld Beta%-43sOld Gamma%-42s", StringPool.SPACE, StringPool.SPACE, StringPool.SPACE));
strBuffer.append(System.lineSeparator());
//拼接历史计算公式 CH
String oldBetaDetCHStr = rowFormat("%sCH(x) = (%s)+(%s)*x+(%s)x*x", StringPool.SPACE, NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaToUiOld().get(0)),
NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaToUiOld().get(1)), NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaToUiOld().get(2)));
String oldGammaDetCHStr = rowFormat("CH(x) = (%s)+(%s)*x+(%s)x*x%-24s", NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaToUiOld().get(0)),
NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaToUiOld().get(1)), NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaToUiOld().get(2)),
StringPool.SPACE);
strBuffer.append(rowFormat("%s%-"+(52-oldBetaDetCHStr.length())+"s%s", oldBetaDetCHStr, StringPool.SPACE, oldGammaDetCHStr));
strBuffer.append(System.lineSeparator());
//拼接历史计算公式 E
String oldBetaDetEStr = rowFormat("%sE(x) = (%s)+(%s)*x+(%s)x*x", StringPool.SPACE, NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaOld().get(0)),
NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaOld().get(1)), NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaOld().get(2)));
String oldGammaDetEStr = rowFormat("E(x) = (%s)+(%s)*x+(%s)x*x%-24s", NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaOld().get(0)),
NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaOld().get(1)), NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaOld().get(2)),
StringPool.SPACE);
strBuffer.append(rowFormat("%s%-"+(52-oldBetaDetEStr.length())+"s%s", oldBetaDetEStr, StringPool.SPACE, oldGammaDetEStr));
strBuffer.append(System.lineSeparator());
strBuffer.append(System.lineSeparator());
strBuffer.append("#DET New CALIBRATION");
strBuffer.append(System.lineSeparator());
strBuffer.append(rowFormat("%sNew Beta%-43sNew Gamma%-42s", StringPool.SPACE, StringPool.SPACE, StringPool.SPACE));
strBuffer.append(System.lineSeparator());
//拼接新计算公式 CH
String newBetaDetCHStr = rowFormat("%sCH(x) = (%s)+(%s)*x+(%s)x*x", StringPool.SPACE,
(Objects.isNull(betaCalibrationParamED.getCoeff1())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaToUiOld().get(0)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamED.getCoeff1()))),
(Objects.isNull(betaCalibrationParamED.getCoeff2())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaToUiOld().get(1)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamED.getCoeff2()))),
(Objects.isNull(betaCalibrationParamED.getCoeff3())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaToUiOld().get(2)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamED.getCoeff3()))));
String newGammaDetCHStr = rowFormat("CH(x) = (%s)+(%s)*x+(%s)x*x%-24s", (Objects.isNull(gammaCalibrationParamED.getCoeff1())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaToUiOld().get(0)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamED.getCoeff1()))),
(Objects.isNull(gammaCalibrationParamED.getCoeff2())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaToUiOld().get(1)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamED.getCoeff2()))),
(Objects.isNull(gammaCalibrationParamED.getCoeff3())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaToUiOld().get(2)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamED.getCoeff3()))),
StringPool.SPACE);
strBuffer.append(rowFormat("%s%-"+(52-newBetaDetCHStr.length())+"s%s", newBetaDetCHStr, StringPool.SPACE, newGammaDetCHStr));
strBuffer.append(System.lineSeparator());
//拼接新计算公式 E
String newBetaDetEStr = rowFormat("%sE(x) = (%s)+(%s)*x+(%s)x*x", StringPool.SPACE,
(Objects.isNull(betaCalibrationParamD.getCoeff1())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaOld().get(0)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamD.getCoeff1()))),
(Objects.isNull(betaCalibrationParamD.getCoeff2())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaOld().get(1)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamD.getCoeff2()))),
(Objects.isNull(betaCalibrationParamD.getCoeff3())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaOld().get(2)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamD.getCoeff3()))));
String newGammaDetEStr = rowFormat("E(x) = (%s)+(%s)*x+(%s)x*x%-24s", (Objects.isNull(gammaCalibrationParamD.getCoeff1())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaOld().get(0)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamD.getCoeff1()))),
(Objects.isNull(gammaCalibrationParamD.getCoeff2())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaOld().get(1)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamD.getCoeff2()))),
(Objects.isNull(gammaCalibrationParamD.getCoeff3())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaOld().get(2)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamD.getCoeff3()))),
StringPool.SPACE);
strBuffer.append(rowFormat("%s%-"+(52-newBetaDetEStr.length())+"s%s", newBetaDetEStr, StringPool.SPACE, newGammaDetEStr));
strBuffer.append(System.lineSeparator());
strBuffer.append(System.lineSeparator());
strBuffer.append("#DET: LIMITS PER ROI");
strBuffer.append(System.lineSeparator());
strBuffer.append(rowFormat(limitRoi, StringPool.SPACE, "Roi", "Beta", "Gamma"));
strBuffer.append(System.lineSeparator());
if (CollectionUtils.isNotEmpty(roiChannelsSpectrumsDet)) {
for (GardsROIChannelsSpectrum channelsSpectrum:roiChannelsSpectrumsDet) {
strBuffer.append(rowFormat(limitRoi, StringPool.SPACE, String.valueOf(channelsSpectrum.getRoi()), channelsSpectrum.getBChanStart()+" to "+channelsSpectrum.getBChanStop(), channelsSpectrum.getGChanStart()+" to "+channelsSpectrum.getGChanStop()));
strBuffer.append(System.lineSeparator());
}
}
strBuffer.append(System.lineSeparator());
strBuffer.append("#GAS Old CALIBRATION");
strBuffer.append(System.lineSeparator());
strBuffer.append(rowFormat("%sOld Beta%-43sOld Gamma%-42s", StringPool.SPACE, StringPool.SPACE, StringPool.SPACE));
strBuffer.append(System.lineSeparator());
//拼接历史计算公式 CH
String oldBetaGasCHStr = rowFormat("%sCH(x) = (%s)+(%s)*x+(%s)x*x", StringPool.SPACE, NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaToUiOld().get(0)),
NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaToUiOld().get(1)), NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaToUiOld().get(2)));
String oldGammaGasCHStr = rowFormat("CH(x) = (%s)+(%s)*x+(%s)x*x%-24s", NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaToUiOld().get(0)),
NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaToUiOld().get(1)), NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaToUiOld().get(2)),
StringPool.SPACE);
strBuffer.append(rowFormat("%s%-"+(52-oldBetaGasCHStr.length())+"s%s", oldBetaGasCHStr, StringPool.SPACE, oldGammaGasCHStr));
strBuffer.append(System.lineSeparator());
String oldBetaGasEStr = rowFormat("%sE(x) = (%s)+(%s)*x+(%s)x*x", StringPool.SPACE, NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaOld().get(0)),
NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaOld().get(1)), NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaOld().get(2)));
String oldGammaGasEStr = rowFormat("E(x) = (%s)+(%s)*x+(%s)x*x%-24s", NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaOld().get(0)),
NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaOld().get(1)), NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaOld().get(2)),
StringPool.SPACE);
strBuffer.append(rowFormat("%s%-"+(52-oldBetaGasEStr.length())+"s%s", oldBetaGasEStr, StringPool.SPACE, oldGammaGasEStr));
strBuffer.append(System.lineSeparator());
strBuffer.append(System.lineSeparator());
strBuffer.append("#GAS New CALIBRATION");
strBuffer.append(System.lineSeparator());
strBuffer.append(rowFormat("%sNew Beta%-43sNew Gamma%-42s", StringPool.SPACE, StringPool.SPACE, StringPool.SPACE));
strBuffer.append(System.lineSeparator());
//拼接新计算公式 CH
String newBetaGasCHStr = rowFormat("%sCH(x) = (%s)+(%s)*x+(%s)x*x", StringPool.SPACE,
(Objects.isNull(betaCalibrationParamEG.getCoeff1())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaToUiOld().get(0)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamEG.getCoeff1()))),
(Objects.isNull(betaCalibrationParamEG.getCoeff2())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaToUiOld().get(1)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamEG.getCoeff2()))),
(Objects.isNull(betaCalibrationParamEG.getCoeff3())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaToUiOld().get(2)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamEG.getCoeff3()))));
String newGammaGasCHStr = rowFormat("CH(x) = (%s)+(%s)*x+(%s)x*x%-24s", (Objects.isNull(gammaCalibrationParamEG.getCoeff1())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaToUiOld().get(0)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamEG.getCoeff1()))),
(Objects.isNull(gammaCalibrationParamEG.getCoeff2())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaToUiOld().get(1)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamEG.getCoeff2()))),
(Objects.isNull(gammaCalibrationParamEG.getCoeff3())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaToUiOld().get(2)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamEG.getCoeff3()))),
StringPool.SPACE);
strBuffer.append(rowFormat("%s%-"+(52-newBetaGasCHStr.length())+"s%s", newBetaGasCHStr, StringPool.SPACE, newGammaGasCHStr));
strBuffer.append(System.lineSeparator());
//拼接新计算公式 E
String newBetaGasEStr = rowFormat("%sE(x) = (%s)+(%s)*x+(%s)x*x", StringPool.SPACE,
(Objects.isNull(betaCalibrationParamG.getCoeff1())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaOld().get(0)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamG.getCoeff1()))),
(Objects.isNull(betaCalibrationParamG.getCoeff2())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaOld().get(1)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamG.getCoeff2()))),
(Objects.isNull(betaCalibrationParamG.getCoeff3())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaOld().get(2)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamG.getCoeff3()))));
String newGammaGasEStr = rowFormat("E(x) = (%s)+(%s)*x+(%s)x*x%-24s", (Objects.isNull(gammaCalibrationParamG.getCoeff1())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaOld().get(0)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamG.getCoeff1()))),
(Objects.isNull(gammaCalibrationParamG.getCoeff2())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaOld().get(1)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamG.getCoeff2()))),
(Objects.isNull(gammaCalibrationParamG.getCoeff3())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaOld().get(2)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamG.getCoeff3()))),
StringPool.SPACE);
strBuffer.append(rowFormat("%s%-"+(52-newBetaGasEStr.length())+"s%s", newBetaGasEStr, StringPool.SPACE, newGammaGasEStr));
strBuffer.append(System.lineSeparator());
strBuffer.append(System.lineSeparator());
strBuffer.append("#GAS: LIMITS PER ROI");
strBuffer.append(System.lineSeparator());
strBuffer.append(rowFormat(limitRoi, StringPool.SPACE, "Roi", "Beta", "Gamma"));
strBuffer.append(System.lineSeparator());
if (CollectionUtils.isNotEmpty(roiChannelsSpectrumsGas)) {
for (GardsROIChannelsSpectrum channelsSpectrum:roiChannelsSpectrumsGas) {
strBuffer.append(rowFormat(limitRoi, StringPool.SPACE, String.valueOf(channelsSpectrum.getRoi()), channelsSpectrum.getBChanStart()+" to "+channelsSpectrum.getBChanStop(), channelsSpectrum.getGChanStart()+" to "+channelsSpectrum.getGChanStop()));
strBuffer.append(System.lineSeparator());
}
}
strBuffer.append(System.lineSeparator());
strBuffer.append("#GROSS COUNTS PER ROI");
strBuffer.append(System.lineSeparator());
String grossRoi = "%s%-15s%-15s%-15s%-15s";
strBuffer.append(rowFormat(grossRoi, StringPool.SPACE, "Roi", "Sample", "GasBkgnd", "DetBkgnd"));
strBuffer.append(System.lineSeparator());
if (CollectionUtils.isNotEmpty(resultsSpectrums)) {
for (GardsROIResultsSpectrum resultsSpectrum:resultsSpectrums) {
strBuffer.append(rowFormat(grossRoi, StringPool.SPACE, String.valueOf(resultsSpectrum.getRoi()), String.valueOf(resultsSpectrum.getSGross()), String.valueOf(resultsSpectrum.getGGross()), String.valueOf(resultsSpectrum.getBGross())));
strBuffer.append(System.lineSeparator());
}
}
strBuffer.append(System.lineSeparator());
strBuffer.append("#NET COUNTS AND LC PER ROI");
strBuffer.append(System.lineSeparator());
String netRoi = "%s%-15s%-25s%-15s";
if (betaDataFile.isBProcessed()) {
if (CollectionUtils.isNotEmpty(resultsSpectrums)) {
if (Objects.isNull(resultsSpectrums.get(0).getLcCts())) {
strBuffer.append(rowFormat(netRoi, StringPool.SPACE, "Roi", "Net count", StringPool.SPACE));
strBuffer.append(System.lineSeparator());
if (CollectionUtils.isNotEmpty(resultsSpectrums)) {
for (GardsROIResultsSpectrum resultsSpectrum:resultsSpectrums){
strBuffer.append(rowFormat(netRoi, StringPool.SPACE, String.valueOf(resultsSpectrum.getRoi()), NumberFormatUtil.numberSixLen(String.valueOf(resultsSpectrum.getNet()))+" +/- "+NumberFormatUtil.numberSixLen(String.valueOf(resultsSpectrum.getNetErr())), StringPool.SPACE));
strBuffer.append(System.lineSeparator());
}
}
} else {
strBuffer.append(rowFormat(netRoi, StringPool.SPACE, "Roi", "Net count", "LC"));
strBuffer.append(System.lineSeparator());
if (CollectionUtils.isNotEmpty(resultsSpectrums)) {
for (GardsROIResultsSpectrum resultsSpectrum:resultsSpectrums){
strBuffer.append(rowFormat(netRoi, StringPool.SPACE, String.valueOf(resultsSpectrum.getRoi()), NumberFormatUtil.numberSixLen(String.valueOf(resultsSpectrum.getNet()))+" +/- "+NumberFormatUtil.numberSixLen(String.valueOf(resultsSpectrum.getNetErr())), NumberFormatUtil.numberSixLen(String.valueOf(resultsSpectrum.getLcCts()))));
strBuffer.append(System.lineSeparator());
}
}
}
} else {
strBuffer.append(rowFormat(netRoi, StringPool.SPACE, "Roi", "Net count", "LC"));
strBuffer.append(System.lineSeparator());
}
} else {
if (CollectionUtils.isNotEmpty(resultsSpectrums)) {
if (Objects.isNull(resultsSpectrums.get(0).getLcCts())) {
strBuffer.append(rowFormat(netRoi, StringPool.SPACE, "Roi", "Net count", StringPool.SPACE));
strBuffer.append(System.lineSeparator());
if (CollectionUtils.isNotEmpty(resultsSpectrums)) {
for (GardsROIResultsSpectrum resultsSpectrum:resultsSpectrums){
strBuffer.append(rowFormat(netRoi, StringPool.SPACE, String.valueOf(resultsSpectrum.getRoi()), NumberFormatUtil.numberSixLen(String.valueOf(resultsSpectrum.getNet()))+" +/- "+NumberFormatUtil.numberSixLen(String.valueOf(Math.sqrt(resultsSpectrum.getNetErr()))), StringPool.SPACE));
strBuffer.append(System.lineSeparator());
}
}
} else {
strBuffer.append(rowFormat(netRoi, StringPool.SPACE, "Roi", "Net count", "LC"));
strBuffer.append(System.lineSeparator());
if (CollectionUtils.isNotEmpty(resultsSpectrums)) {
for (GardsROIResultsSpectrum resultsSpectrum:resultsSpectrums){
strBuffer.append(rowFormat(netRoi, StringPool.SPACE, String.valueOf(resultsSpectrum.getRoi()), NumberFormatUtil.numberSixLen(String.valueOf(resultsSpectrum.getNet()))+" +/- "+NumberFormatUtil.numberSixLen(String.valueOf(Math.sqrt(resultsSpectrum.getNetErr()))), NumberFormatUtil.numberSixLen(String.valueOf(resultsSpectrum.getLcCts()))));
strBuffer.append(System.lineSeparator());
}
}
}
} else {
strBuffer.append(rowFormat(netRoi, StringPool.SPACE, "Roi", "Net count", "LC"));
strBuffer.append(System.lineSeparator());
}
}
strBuffer.append(System.lineSeparator());
strBuffer.append("#CONCENTRATION AND LC PER ROI");
strBuffer.append(System.lineSeparator());
String conLcRoi = "%s%-15s%-25s%-15s%-15s";
strBuffer.append(rowFormat(conLcRoi, StringPool.SPACE, "Roi", "Conc(mBq/m3)", "LC(mBq/m3)", "MDC(mBq/m3):"));
strBuffer.append(System.lineSeparator());
if (betaDataFile.isBProcessed()) {
if (CollectionUtils.isNotEmpty(resultsSpectrums)) {
for (GardsROIResultsSpectrum resultsSpectrum:resultsSpectrums){
strBuffer.append(rowFormat(conLcRoi, StringPool.SPACE, String.valueOf(resultsSpectrum.getRoi()), NumberFormatUtil.numberSixLen(String.valueOf(resultsSpectrum.getConc()))+" +/- "+NumberFormatUtil.numberSixLen(String.valueOf(resultsSpectrum.getConcErr())), NumberFormatUtil.numberSixLen(String.valueOf(resultsSpectrum.getLc())), NumberFormatUtil.numberSixLen(String.valueOf(resultsSpectrum.getMdc()))));
strBuffer.append(System.lineSeparator());
}
}
} else {
if (CollectionUtils.isNotEmpty(resultsSpectrums)) {
for (GardsROIResultsSpectrum resultsSpectrum:resultsSpectrums){
strBuffer.append(rowFormat(conLcRoi, StringPool.SPACE, String.valueOf(resultsSpectrum.getRoi()), NumberFormatUtil.numberSixLen(String.valueOf(resultsSpectrum.getConcErr()))+" +/- "+NumberFormatUtil.numberSixLen(String.valueOf(resultsSpectrum.getConcErr())), NumberFormatUtil.numberSixLen(String.valueOf(resultsSpectrum.getLc())), NumberFormatUtil.numberSixLen(String.valueOf(resultsSpectrum.getMdc()))));
strBuffer.append(System.lineSeparator());
}
}
}
strBuffer.append(System.lineSeparator());
strBuffer.append("#RESULT SUMMARY");
strBuffer.append(System.lineSeparator());
String resultSum = "%s%-15s%-25s%-15s%-15s%-15s";
strBuffer.append(rowFormat(resultSum, StringPool.SPACE, "Nuclide Name", "Conc", "LC", "MDC", "NID Flag"));
strBuffer.append(System.lineSeparator());
if (CollectionUtils.isNotEmpty(xeResultsSpectrums)) {
for (GardsXeResultsSpectrum xeResultsSpectrum:xeResultsSpectrums) {
strBuffer.append(rowFormat(resultSum, StringPool.SPACE, xeResultsSpectrum.getNuclideName(), NumberFormatUtil.numberSixLen(String.valueOf(xeResultsSpectrum.getConc()))+" +/- "+NumberFormatUtil.numberSixLen(String.valueOf(xeResultsSpectrum.getConcErr())), NumberFormatUtil.numberSixLen(String.valueOf(xeResultsSpectrum.getLc())), NumberFormatUtil.numberSixLen(String.valueOf(xeResultsSpectrum.getMdc())), String.valueOf(xeResultsSpectrum.getNidFlag())));
strBuffer.append(System.lineSeparator());
}
}
strBuffer.append(System.lineSeparator());
} catch (ParseException e) {
throw new RuntimeException(e);
}
return strBuffer.toString();
}
public List<GardsXeResultsView> viewXeData(List<GardsXeResultsSpectrum> xeResultsSpectrumList) {
List<GardsXeResultsView> xeResultsViewList = new LinkedList<>();
if (CollectionUtils.isNotEmpty(xeResultsSpectrumList)) {
@ -2004,4 +2410,6 @@ public class PHDFileUtil extends AbstractLogOrReport {
return xeResultsViewList;
}
}

View File

@ -32,8 +32,8 @@ public class SpectrumAnalysesController {
@GetMapping("getDBSearchList")
@ApiOperation(value = "查询查询条件数据接口", notes = "查询查询条件数据接口")
public Result getDBSearchList(HttpServletRequest request, boolean AllUsers) {
return spectrumAnalysisService.getDBSearchList(request, AllUsers);
public Result getDBSearchList(HttpServletRequest request, boolean AllUsers, String sampleType) {
return spectrumAnalysisService.getDBSearchList(request, AllUsers, sampleType);
}
@GetMapping("getDBSpectrumList")

View File

@ -17,7 +17,9 @@
TOTALCOUNTS = #{analyses.totalCounts},
BASELINE_PATH = #{analyses.baselinePath},
LC_PATH = #{analyses.lcPath},
SCAC_PATH = #{analyses.scacPath}
SCAC_PATH = #{analyses.scacPath},
LOG_PATH = #{analyses.logPath},
REPORT_PAHT = #{analyses.reportPath}
WHERE
IDANALYSIS = #{analyses.idAnalysis}
</update>

View File

@ -900,7 +900,9 @@
USEDGASPHD=#{gardsAnalyses.usedgasphd},
USEDDETPHD=#{gardsAnalyses.useddetphd},
USEDGASPHD_ID=#{gardsAnalyses.usedgasphdId},
USEDDETPHD_ID=#{gardsAnalyses.useddetphdId}
USEDDETPHD_ID=#{gardsAnalyses.useddetphdId},
LOG_PATH = #{gardsAnalyses.logPath},
REPORT_PAHT = #{gardsAnalyses.reportPath}
WHERE
SAMPLE_ID=#{gardsAnalyses.sampleId}
AND ANALYST=#{gardsAnalyses.analyst}
@ -921,7 +923,9 @@
USEDGASPHD,
USEDDETPHD,
USEDGASPHD_ID,
USEDDETPHD_ID)
USEDDETPHD_ID,
LOG_PATH,
REPORT_PAHT)
VALUES(#{gardsAnalyses.sampleId},
to_date(#{gardsAnalyses.analysisBeginStr},'YYYY-MM-DD hh24:mi:ss'),
to_date(#{gardsAnalyses.analysisEndStr},'YYYY-MM-DD hh24:mi:ss'),

View File

@ -16,7 +16,7 @@ public interface ISpectrumAnalysisService {
Result initValue(String dbName, Integer sampleId, String analyst, String sampleFileName, String gasFileName, String detFileName, String qcFileName, HttpServletRequest request);
Result getDBSearchList(HttpServletRequest request, boolean AllUsers);
Result getDBSearchList(HttpServletRequest request, boolean AllUsers, String sampleType);
Result getDBSpectrumList(QueryRequest queryRequest, GardsSampleDataSpectrum gardsSampleData, String dbName, String[] menuTypes, boolean AllUsers, boolean CollectStopB, boolean AcqStartB, Date startDate, Date endDate, HttpServletRequest request);

View File

@ -3,6 +3,7 @@ package org.jeecg.modules.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.ReUtil;
@ -27,6 +28,7 @@ import org.jeecg.common.constant.DateConstant;
import org.jeecg.common.constant.RedisConstant;
import org.jeecg.common.properties.ParameterProperties;
import org.jeecg.common.properties.SpectrumPathProperties;
import org.jeecg.common.properties.TaskProperties;
import org.jeecg.common.system.util.JwtUtil;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.*;
@ -187,6 +189,8 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
// 从数据库中读取phd其他相关信息
boolean bRet = getResultFromDB(dbName, analyst, sampleId, phd, result);
if (!redisUtil.hasKey(userName+StringPool.DASH+phd.getHeader().getSystem_type()) || !redisUtil.hasKey(userName+StringPool.DASH+phd.getHeader().getSystem_type()+"-list")) {
//读取缓存的全部核素信息
Map<String, NuclideLines> allNuclideMap = (Map<String, NuclideLines>) redisUtil.get("AllNuclideMap");
// 查询当前用户关联的核素信息
List<String> userLib = new LinkedList<>();
// 从postgreSql中获取当前用户关注的核素信息 如果当前用户没有 则返回管理员的
@ -195,7 +199,12 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
userLib = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase());
}
userLib = userLib.stream().sorted().collect(Collectors.toList());
Map<String, NuclideLines> nuclideMap = GetNuclideLines(userLib);
Map<String, NuclideLines> nuclideMap = new HashMap<>();
for (Map.Entry<String, NuclideLines> entry:allNuclideMap.entrySet()) {
if (userLib.contains(entry.getKey())) {
nuclideMap.put(entry.getKey(), entry.getValue());
}
}
redisUtil.set(userName+StringPool.DASH+phd.getHeader().getSystem_type()+"-list", userLib);
redisUtil.set(userName+StringPool.DASH+phd.getHeader().getSystem_type(), nuclideMap);
}
@ -219,6 +228,8 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
return result;
}
if (!redisUtil.hasKey(userName+StringPool.DASH+phd.getHeader().getSystem_type()) || !redisUtil.hasKey(userName+StringPool.DASH+phd.getHeader().getSystem_type()+"-list")) {
//读取缓存的全部核素信息
Map<String, NuclideLines> allNuclideMap = (Map<String, NuclideLines>) redisUtil.get("AllNuclideMap");
// 查询当前用户关联的核素信息
List<String> userLib = new LinkedList<>();
// 从postgreSql中获取当前用户关注的核素信息 如果当前用户没有 则返回管理员的
@ -227,7 +238,12 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
userLib = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase());
}
userLib = userLib.stream().sorted().collect(Collectors.toList());
Map<String, NuclideLines> nuclideMap = GetNuclideLinesLocal(userLib);
Map<String, NuclideLines> nuclideMap = new HashMap<>();
for (Map.Entry<String, NuclideLines> entry:allNuclideMap.entrySet()) {
if (userLib.contains(entry.getKey())) {
nuclideMap.put(entry.getKey(), entry.getValue());
}
}
redisUtil.set(userName+StringPool.DASH+phd.getHeader().getSystem_type()+"-list", userLib);
redisUtil.set(userName+StringPool.DASH+phd.getHeader().getSystem_type(), nuclideMap);
}
@ -497,6 +513,8 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
// 从数据库中读取phd其他相关信息
boolean bRet = getResultFromDB(dbName, analyst, sampleId, phd, result);
if (!redisUtil.hasKey(userName+StringPool.DASH+phd.getHeader().getSystem_type()) || !redisUtil.hasKey(userName+StringPool.DASH+phd.getHeader().getSystem_type()+"-list")) {
//读取缓存的全部核素信息
Map<String, NuclideLines> allNuclideMap = (Map<String, NuclideLines>) redisUtil.get("AllNuclideMap");
// 查询当前用户关联的核素信息
List<String> userLib = new LinkedList<>();
// 从postgreSql中获取当前用户关注的核素信息 如果当前用户没有 则返回管理员的
@ -505,7 +523,12 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
userLib = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase());
}
userLib = userLib.stream().sorted().collect(Collectors.toList());
Map<String, NuclideLines> nuclideMap = GetNuclideLines(userLib);
Map<String, NuclideLines> nuclideMap = new HashMap<>();
for (Map.Entry<String, NuclideLines> entry:allNuclideMap.entrySet()) {
if (userLib.contains(entry.getKey())) {
nuclideMap.put(entry.getKey(), entry.getValue());
}
}
redisUtil.set(userName+StringPool.DASH+phd.getHeader().getSystem_type()+"-list", userLib);
redisUtil.set(userName+StringPool.DASH+phd.getHeader().getSystem_type(), nuclideMap);
}
@ -879,6 +902,8 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
return result;
}
if (!redisUtil.hasKey(userName+StringPool.DASH+phd.getHeader().getSystem_type()) || !redisUtil.hasKey(userName+StringPool.DASH+phd.getHeader().getSystem_type()+"-list")) {
//读取缓存的全部核素信息
Map<String, NuclideLines> allNuclideMap = (Map<String, NuclideLines>) redisUtil.get("AllNuclideMap");
// 查询当前用户关联的核素信息
List<String> userLib = new LinkedList<>();
// 从postgreSql中获取当前用户关注的核素信息 如果当前用户没有 则返回管理员的
@ -887,7 +912,12 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
userLib = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase());
}
userLib = userLib.stream().sorted().collect(Collectors.toList());
Map<String, NuclideLines> nuclideMap = GetNuclideLinesLocal(userLib);
Map<String, NuclideLines> nuclideMap = new HashMap<>();
for (Map.Entry<String, NuclideLines> entry:allNuclideMap.entrySet()) {
if (userLib.contains(entry.getKey())) {
nuclideMap.put(entry.getKey(), entry.getValue());
}
}
redisUtil.set(userName+StringPool.DASH+phd.getHeader().getSystem_type()+"-list", userLib);
redisUtil.set(userName+StringPool.DASH+phd.getHeader().getSystem_type(), nuclideMap);
}
@ -1002,7 +1032,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
result.error500("The comparison file path does not exist");
return result;
}
compareFilePath = ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + compareFilePath;
compareFilePath = StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + compareFilePath;
File compareFile = ftpUtil.downloadFile(compareFilePath, "betaGamma");
if (Objects.isNull(compareFile)) {
result.error500("The comparison file path does not exist");
@ -1086,7 +1116,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
result.error500("The comparison file path does not exist");
return result;
}
stripFilePath = ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + stripFilePath;
stripFilePath = StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + stripFilePath;
File stripFile = ftpUtil.downloadFile(stripFilePath, "betaGamma");
if (Objects.isNull(stripFile)) {
result.error500("The comparison file path does not exist");
@ -1317,85 +1347,6 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
return result;
}
public Map<String, NuclideLines> GetNuclideLines(List<String> nuclideList) {
Map<String, NuclideLines> mapLines = new HashMap<>();
if (nuclideList.size() < 1) {
return mapLines;
}
for (String name : nuclideList) {
NuclideLines nlines = new NuclideLines();
List<NuclideLine> nuclideLineList = spectrumAnalysisMapper.getNuclideLines(name);
for (int j = 0; j < nuclideLineList.size(); j++) {
nlines.getFullNames().add(nuclideLineList.get(j).getFullName());
nlines.getVenergy().add(nuclideLineList.get(j).getEnergy());
nlines.getVuncertE().add(nuclideLineList.get(j).getEnergyUncert());
nlines.getVyield().add(nuclideLineList.get(j).getYield() / 100);
nlines.getVuncertY().add(nuclideLineList.get(j).getYieldUncert());
if (Objects.nonNull(nuclideLineList.get(j).getKeyFlag()) && nuclideLineList.get(j).getKeyFlag().intValue() > 0) {
nlines.key_flag = j;
nlines.maxYeildIdx = j;
}
}
mapLines.put(name, nlines);
}
List<HalfData> halfs = spectrumAnalysisMapper.getHalf(nuclideList);
for (int m = 0; m < halfs.size(); m++) {
NuclideLines nuclideLines = mapLines.get(halfs.get(m).getName());
nuclideLines.setHalflife(halfs.get(m).getHalf() == null ? 0 : halfs.get(m).getHalf() * 86400);// 将天转换成秒
mapLines.put(halfs.get(m).getName(), nuclideLines);
}
return mapLines;
}
public Map<String, NuclideLines> GetNuclideLinesLocal(List<String> nuclideList) {
Map<String, NuclideLines> mapLines = new HashMap<>();
if (nuclideList.size() < 1) {
return mapLines;
}
//需要查询的两个表的名称
String table_lines = "lines";
String table_lib = "libdata";
// 建立数据库连接
Connection conn = dbUtil.openDB();
Statement statement = null;
try {
statement = conn.createStatement();
for (String name : nuclideList) {
NuclideLines nlines = new NuclideLines();
//根据核素名称查询相关核素信息
String sql1 = "select fullname, energy, energy_uncert, yield, yield_uncert, key_flag from "+table_lines+" where name = '"+name+"' Order by energy";
ResultSet resultSet = statement.executeQuery(sql1);
int j=0;
while (resultSet.next()) {
nlines.getFullNames().add(resultSet.getString("fullname"));
nlines.getVenergy().add(resultSet.getDouble("energy"));
nlines.getVuncertE().add(resultSet.getDouble("energy_uncert"));
nlines.getVyield().add(resultSet.getDouble("yield") / 100);
nlines.getVuncertY().add(resultSet.getDouble("yield_uncert"));
if (Objects.nonNull(resultSet.getInt("key_flag")) && resultSet.getInt("key_flag") > 0) {
nlines.key_flag = j;
nlines.maxYeildIdx = j;
}
++j;
}
mapLines.put(name, nlines);
}
String names = "'" + String.join("','", nuclideList) + "'";
String sql2 = "select name, halflife from "+table_lib+" where name in ("+names+")";
ResultSet executeQuery = statement.executeQuery(sql2);
while (executeQuery.next()) {
NuclideLines nuclideLines = mapLines.get(executeQuery.getString("name"));
nuclideLines.setHalflife(Double.valueOf(executeQuery.getDouble("halflife")) == null ? 0 : executeQuery.getDouble("halflife") * 86400);// 将天转换成秒
mapLines.put(executeQuery.getString("name"), nuclideLines);
}
} catch (SQLException e) {
throw new RuntimeException(e);
} finally {
dbUtil.close(statement, conn);
}
return mapLines;
}
@Override
public Result InteractiveTool(Integer sampleId, String fileName, HttpServletRequest request) {
Result result = new Result();
@ -4149,6 +4100,8 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
boolean save = defaultNuclideSpectrumService.saveNuclidesByUserName(userLibraryName, userName, phd.getHeader().getSystem_type().toUpperCase());
if (save) {
result.success("Modified successfully");
// 重新计算峰值
Map<String, NuclideLines> allNuclideMap = (Map<String, NuclideLines>) redisUtil.get("AllNuclideMap");
// 查询当前用户关联的核素信息
List<String> userLib = new LinkedList<>();
// 从postgreSql中获取当前用户关注的核素信息 如果当前用户没有 则返回管理员的
@ -4156,7 +4109,12 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
if (CollectionUtils.isEmpty(userLib)) {
userLib = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase());
}
Map<String, NuclideLines> nuclideMap = GetNuclideLines(userLib);
Map<String, NuclideLines> nuclideMap = new HashMap<>();
for (Map.Entry<String, NuclideLines> entry:allNuclideMap.entrySet()) {
if (userLib.contains(entry.getKey())) {
nuclideMap.put(entry.getKey(), entry.getValue());
}
}
redisUtil.set(userName+StringPool.DASH+phd.getHeader().getSystem_type()+"-list", userLib);
redisUtil.set(userName+StringPool.DASH+phd.getHeader().getSystem_type(), nuclideMap);
} else {
@ -4977,7 +4935,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
}
@Override
@Transactional
@Transactional(rollbackFor = Exception.class)
public Result saveToDB(String fileName, HttpServletRequest request) {
Result result = new Result();
String userName = JwtUtil.getUserNameByToken(request);
@ -5088,6 +5046,39 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
mdcSpectrumService.saveMDCGamma(phd, idAnalysis);
if (bRet) {
phd.setStatus("R");
//分析成功后存储日志文件和报告文件
{
String logPathName = middleData.analyses_absolute_LogPath.substring(0, middleData.analyses_absolute_LogPath.lastIndexOf(StringPool.SLASH));
String logFileName = middleData.analyses_absolute_LogPath.substring(middleData.analyses_absolute_LogPath.lastIndexOf(StringPool.SLASH)+1);
File logFile = new File(logFileName);
try {
FileUtil.writeString(gammaFileUtil.GetLogContent(middleData), logFile, "UTF-8");
FileInputStream in = new FileInputStream(logFile);
ftpUtil.saveFile(logPathName, logFileName, in);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
} finally {
if (Objects.nonNull(logFile)) {
logFile.delete();
}
}
}
{
String rptPathName = middleData.analyses_absolute_ReportPath.substring(0, middleData.analyses_absolute_ReportPath.lastIndexOf(StringPool.SLASH));
String rptFileName = middleData.analyses_absolute_ReportPath.substring(middleData.analyses_absolute_ReportPath.lastIndexOf(StringPool.SLASH)+1);
File rptFile = new File(rptFileName);
try {
FileUtil.writeString(gammaFileUtil.GetReportContent(middleData), rptFile, "UTF-8");
FileInputStream in = new FileInputStream(rptFile);
ftpUtil.saveFile(rptPathName, rptFileName, in);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
} finally {
if (Objects.nonNull(rptFile)) {
rptFile.delete();
}
}
}
List<String> paths = new LinkedList<>();
paths.add(middleData.analyses_lc_filePath);
paths.add(middleData.analyses_scac_filePath);

View File

@ -40,6 +40,8 @@ public class GardsAnalysesSpectrumServiceImpl extends ServiceImpl<GardsAnalysesM
analyses.setBaselinePath(middleData.analyses_baseline_filePath);
analyses.setLcPath(middleData.analyses_lc_filePath);
analyses.setScacPath(middleData.analyses_scac_filePath);
analyses.setLogPath(middleData.analyses_LogPath);
analyses.setReportPath(middleData.analyses_ReportPath);
int insert = this.baseMapper.insert(analyses);
return insert;
} catch (ParseException e) {
@ -65,6 +67,8 @@ public class GardsAnalysesSpectrumServiceImpl extends ServiceImpl<GardsAnalysesM
analyses.setBaselinePath(middleData.analyses_baseline_filePath);
analyses.setLcPath(middleData.analyses_lc_filePath);
analyses.setScacPath(middleData.analyses_scac_filePath);
analyses.setLogPath(middleData.analyses_LogPath);
analyses.setReportPath(middleData.analyses_ReportPath);
this.baseMapper.updateEntity(analyses);
}

View File

@ -3,6 +3,7 @@ package org.jeecg.modules.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.ReUtil;
import cn.hutool.core.util.StrUtil;
@ -31,6 +32,7 @@ import org.jeecg.modules.base.abstracts.AbstractLogOrReport;
import org.jeecg.modules.base.bizVo.BetaRLR;
import org.jeecg.modules.base.dto.*;
import org.jeecg.modules.base.entity.configuration.GardsDetectors;
import org.jeecg.modules.base.entity.configuration.GardsStations;
import org.jeecg.modules.base.entity.original.GardsSampleData;
import org.jeecg.modules.base.entity.rnman.*;
import org.jeecg.modules.base.enums.*;
@ -114,6 +116,8 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
private IGardsHistogramSpectrumService histogramService;
@Autowired
private RedisStreamUtil redisStreamUtil;
@Autowired
private NameStandUtil nameStandUtil;
@Override
@ -126,14 +130,34 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
}
@Override
public Result getDBSearchList(HttpServletRequest request, boolean AllUsers) {
public Result getDBSearchList(HttpServletRequest request, boolean AllUsers, String sampleType) {
Result result = new Result();
//接收返回结果
Map<String, List<String>> map = new HashMap<>();
//查询谱对应的台站类型
if (StringUtils.isBlank(sampleType)){
result.error500("谱类型不能为空");
return result;
}
List<String> menuTypes = new LinkedList<>();
if (sampleType.equalsIgnoreCase("All")) {
menuTypes.add(SystemType.BETA.getType());
menuTypes.add(SystemType.GAMMA.getType());
} else if (sampleType.equalsIgnoreCase("Beta")) {
menuTypes.add(SystemType.BETA.getType());
} else if (sampleType.equalsIgnoreCase("Gamma")) {
menuTypes.add(SystemType.GAMMA.getType());
}
List<String> stationTypes = sysDictService.findStationType(menuTypes);
if (CollectionUtils.isEmpty(stationTypes)) {
result.error500("请先补充数据字典中当前系统类型对应的台站类型信息");
return result;
}
//获取台站编码
List<String> stationCodes = new LinkedList<>();
List<String> detectorCodes = new LinkedList<>();
//根据台站id查询台站名称
Map<String, String> stationMap = (Map<String, String>)redisUtil.get("stationMap");
//查询台站信息接口
HashMap<String, Object> stationMap = (HashMap<String, Object>)redisUtil.get("stationInfoMap");
//从redis中获取探测器信息
Map<Integer, String> detectorInfoMap = (Map<Integer, String>)redisUtil.get("detectorsMap");
//获取台站信息
@ -145,24 +169,26 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
result.error500("Description Failed to obtain the current login user information");
return result;
}
//查询用户当天排班的台站信息
userStations = userTaskUtil.findUserStation(userName);
//判断当前用户在当天是否有排班任务的台站信息
if (CollectionUtils.isNotEmpty(userStations)) {
if (CollectionUtils.isNotEmpty(stationMap)){
for (Map.Entry<String, String> entry:stationMap.entrySet()) {
if (userStations.contains(entry.getKey())) {
stationCodes.add(entry.getValue());
for (Map.Entry<String, Object> entry:stationMap.entrySet()) {
GardsStations value = (GardsStations)entry.getValue();
if (userStations.contains(entry.getKey()) && StringUtils.isNotBlank(value.getType()) && stationTypes.contains(value.getType())) {
stationCodes.add(value.getStationCode());
}
}
}
if (CollectionUtils.isNotEmpty(detectorInfoMap)) {
for (Map.Entry<Integer, String> entry:detectorInfoMap.entrySet()) {
if (String.valueOf(entry.getKey()).length() <= 3) {
if (userStations.contains(String.valueOf(entry.getKey()))) {
if (String.valueOf(entry.getValue()).length() <= 5) {
if (stationCodes.contains(String.valueOf(entry.getValue()))) {
detectorCodes.add(entry.getValue());
}
} else {
if (userStations.contains(String.valueOf(entry.getKey()).substring(0, 3))) {
if (stationCodes.contains(String.valueOf(entry.getValue()).substring(0, 5))) {
detectorCodes.add(entry.getValue());
}
}
@ -171,13 +197,24 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
}
} else {
if (CollectionUtils.isNotEmpty(stationMap)) {
for (Map.Entry<String, String> entry: stationMap.entrySet()) {
stationCodes.add(entry.getValue());
for (Map.Entry<String, Object> entry: stationMap.entrySet()) {
GardsStations value = (GardsStations) entry.getValue();
if (StringUtils.isNotBlank(value.getType()) && stationTypes.contains(value.getType())) {
stationCodes.add(value.getStationCode());
}
}
}
if (CollectionUtils.isNotEmpty(detectorInfoMap)) {
for (Map.Entry<Integer, String> entry: detectorInfoMap.entrySet()) {
detectorCodes.add(entry.getValue());
if (String.valueOf(entry.getValue()).length() <= 5) {
if (stationCodes.contains(String.valueOf(entry.getValue()))) {
detectorCodes.add(entry.getValue());
}
} else {
if (stationCodes.contains(String.valueOf(entry.getValue()).substring(0, 5))) {
detectorCodes.add(entry.getValue());
}
}
}
}
}
@ -448,7 +485,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
List<String> filePaths = new LinkedList<>();
//判断sample信息是否存在
if (Objects.nonNull(sample)) {
betaDataFile.setSampleFilePathName(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH +dbSpectrumFilePath.getSampleFilePath());
betaDataFile.setSampleFilePathName(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH +dbSpectrumFilePath.getSampleFilePath());
betaDataFile.setSampleFileName(sampleFileName);
sampleTmp = ftpUtil.downloadFile(betaDataFile.getSampleFilePathName(), "betaGamma");
if (Objects.nonNull(sampleTmp)) {
@ -462,7 +499,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
}
//判断gas信息是否存在
if (Objects.nonNull(gasBg)) {
betaDataFile.setGasFilePathName(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH +dbSpectrumFilePath.getGasBgFilePath());
betaDataFile.setGasFilePathName(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH +dbSpectrumFilePath.getGasBgFilePath());
betaDataFile.setGasFileName(gasFileName);
gasTmp = ftpUtil.downloadFile(betaDataFile.getGasFilePathName(), "betaGamma");
if (Objects.nonNull(gasTmp)) {
@ -476,7 +513,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
}
//判断det信息是否存在
if (Objects.nonNull(detBg)) {
betaDataFile.setDetFilePathName(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH +dbSpectrumFilePath.getDetBgFilePath());
betaDataFile.setDetFilePathName(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH +dbSpectrumFilePath.getDetBgFilePath());
betaDataFile.setDetFileName(detFileName);
detTmp = ftpUtil.downloadFile(betaDataFile.getDetFilePathName(), "betaGamma");
if (Objects.nonNull(detTmp)) {
@ -490,7 +527,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
}
//判断qc信息是否存在
if (Objects.nonNull(qc)) {
betaDataFile.setQcFilePathName(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH +dbQcFilePath);
betaDataFile.setQcFilePathName(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH +dbQcFilePath);
betaDataFile.setQcFileName(qcFileName);
qcTmp = ftpUtil.downloadFile(betaDataFile.getQcFilePathName(), "betaGamma");
if (Objects.nonNull(qcTmp)) {
@ -569,7 +606,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
//获取用户名
String userName = JwtUtil.getUserNameByToken(request);
//上传文件路径
String path = ftpUtil.getFtpRootPath() + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName;
String path = StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName;
Map<String, Object> resultMap = new HashMap<>();
Map<String, Object> sampleMap = new HashMap<>();
Map<String, Object> gasBgMap = new HashMap<>();
@ -849,7 +886,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
InputStream inputStream = null;
ServletOutputStream outputStream = null;
try {
inputStream = ftpUtil.downloadFileStream(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + reportPath + ".txt");
inputStream = ftpUtil.downloadFileStream(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + reportPath + ".txt");
if (Objects.nonNull(inputStream)){
outputStream = response.getOutputStream();
byte[] buffer = new byte[1024];
@ -3693,7 +3730,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
InputStream inputStream = null;
ServletOutputStream outputStream = null;
try {
inputStream = ftpUtil.downloadFileStream(ftpUtil.getFtpRootPath() + spectrumPathProperties.getLogPath() + StringPool.SLASH + logPath);
inputStream = ftpUtil.downloadFileStream(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getLogPath() + StringPool.SLASH + logPath);
if (Objects.nonNull(inputStream)){
outputStream = response.getOutputStream();
byte[] buffer = new byte[1024];
@ -3754,7 +3791,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
}
@Override
@Transactional
@Transactional(rollbackFor = Exception.class)
public Result saveToDB(BgDataAnlyseResultIn anlyseResultIn, HttpServletRequest request) {
Result result = new Result();
Map<String, Object> map = new HashMap<>();
@ -3868,6 +3905,22 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
result.error500("sampleFile save failed");
return result;
}
//获取日志报告文件存放路径
EnergySpectrumStruct sampleStruct = betaDataFile.getSampleStruct();
String dataType = sampleStruct.data_type;
String subDirSavePath = "";
subDirSavePath+=nameStandUtil.GetSysTemSubdir(sampleStruct.system_type);
subDirSavePath+=nameStandUtil.GetDateTypeSubdir(dataType);
String path = nameStandUtil.SetFileDir(subDirSavePath, betaDataFile.getSampleFileName());
Map<String, String> fileNameMap = nameStandUtil.NameStandard(dataType, sampleStruct.spectrum_quantity, sampleStruct.acquisition_live_time, betaDataFile.getSampleFileName(), sampleStruct.measurement_id);
String logName = fileNameMap.get("log");
String qsLogPath= path+StringPool.SLASH+userName+"_"+logName;
qsLogPath = qsLogPath.replace(StringPool.BACK_SLASH, StringPool.SLASH);
String rptName = fileNameMap.get("rpt");
String qsReportPath="Arr"+StringPool.SLASH+path+StringPool.SLASH+userName+"_"+rptName;
qsReportPath = qsReportPath.replace(StringPool.BACK_SLASH, StringPool.SLASH);
String analyses_absolute_LogPath=spectrumPathProperties.getLogPath()+StringPool.SLASH+qsLogPath;
String analyses_absolute_ReportPath=spectrumPathProperties.getSaveFilePath()+StringPool.SLASH+qsReportPath;
//根据文件名称查询对应的sampleId--- sampleFile gasFile detFile
sampleId = spectrumAnalysisMapper.getSampleId(sampleFilePathName);
gasId = spectrumAnalysisMapper.getSampleId(gasFilePathName);
@ -3887,6 +3940,8 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
gardsAnalyses.setUsedgasphdId(gasId);
gardsAnalyses.setUseddetphdId(detId);
gardsAnalyses.setAnalyst(anlyseResultIn.getUserName());
gardsAnalyses.setLogPath(qsLogPath);
gardsAnalyses.setReportPath(qsReportPath);
if (Objects.nonNull(isExist)){
spectrumAnalysisMapper.updateGardsAnalyses(gardsAnalyses);
}else {//如果没有分析过就新增--GARDS_ANALYSES
@ -3981,19 +4036,53 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
try {
if (StringUtils.isNotBlank(betaDataFile.getSampleTmpPath())) {
File sampleTmp = new File(betaDataFile.getSampleTmpPath());
ftpUtil.saveFile(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + sampleFilePathName.substring(0, sampleFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getSampleFileName(), new FileInputStream(sampleTmp));
ftpUtil.saveFile(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + sampleFilePathName.substring(0, sampleFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getSampleFileName(), new FileInputStream(sampleTmp));
}
if (StringUtils.isNotBlank(betaDataFile.getGasTmpPath())) {
File gasTmp = new File(betaDataFile.getGasTmpPath());
ftpUtil.saveFile(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + gasFilePathName.substring(0, gasFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getGasFileName(), new FileInputStream(gasTmp));
ftpUtil.saveFile(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + gasFilePathName.substring(0, gasFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getGasFileName(), new FileInputStream(gasTmp));
}
if (StringUtils.isNotBlank(betaDataFile.getDetTmpPath())) {
File detTmp = new File(betaDataFile.getDetTmpPath());
ftpUtil.saveFile(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + detFilePathName.substring(0, detFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getDetFileName(), new FileInputStream(detTmp));
ftpUtil.saveFile(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + detFilePathName.substring(0, detFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getDetFileName(), new FileInputStream(detTmp));
}
if (StringUtils.isNotBlank(betaDataFile.getQcTmpPath())) {
File qcTmp = new File(betaDataFile.getQcTmpPath());
ftpUtil.saveFile(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + qcFilePathName.substring(0, qcFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getQcFileName(), new FileInputStream(qcTmp));
ftpUtil.saveFile(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + qcFilePathName.substring(0, qcFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getQcFileName(), new FileInputStream(qcTmp));
}
//分析成功后存储日志文件和报告文件
{
String logPathName = analyses_absolute_LogPath.substring(0, analyses_absolute_LogPath.lastIndexOf(StringPool.SLASH));
String logFileName = analyses_absolute_LogPath.substring(analyses_absolute_LogPath.lastIndexOf(StringPool.SLASH)+1);
String logFilePath = parameterProperties.getLogFilePath() + File.separator + DateUtils.formatDate(new Date(), "yyyy-MM-dd") + File.separator + betaDataFile.getSampleFileName().replace("PHD", "log");
File logFile = new File(logFilePath);
try {
FileInputStream in = new FileInputStream(logFile);
ftpUtil.saveFile(logPathName, logFileName, in);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
} finally {
if (Objects.nonNull(logFile)) {
logFile.delete();
}
}
}
{
String rptContent = phdFileUtil.OutPutRnRpt(betaDataFile);
String rptPathName = analyses_absolute_ReportPath.substring(0, analyses_absolute_ReportPath.lastIndexOf(StringPool.SLASH));
String rptFileName = analyses_absolute_ReportPath.substring(analyses_absolute_ReportPath.lastIndexOf(StringPool.SLASH)+1);
File rptFile = new File(rptFileName);
try {
FileUtil.writeString(rptContent, rptFile, "UTF-8");
FileInputStream in = new FileInputStream(rptFile);
ftpUtil.saveFile(rptPathName, rptFileName, in);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
} finally {
if (Objects.nonNull(rptFile)) {
rptFile.delete();
}
}
}
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
@ -5454,6 +5543,17 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
roiResultsSpectrumList.add(roiResults);
}
anlyseResultIn.setRoiResultsSpectrumList(roiResultsSpectrumList);
betaDataFile.getXeResultsSpectrumList().forEach(item -> {
if (item.getNuclideName().equals(XeNuclideName.XE_131m.getType())) {
item.setNidFlag(anlyseResultIn.getXe131mFlag());
} else if (item.getNuclideName().equals(XeNuclideName.XE_133.getType())) {
item.setNidFlag(anlyseResultIn.getXe133Flag());
} else if (item.getNuclideName().equals(XeNuclideName.XE_133m.getType())) {
item.setNidFlag(anlyseResultIn.getXe133mFlag());
} else if (item.getNuclideName().equals(XeNuclideName.XE_135.getType())) {
item.setNidFlag(anlyseResultIn.getXe135Flag());
}
});
}
}
} catch (Exception e) {
@ -5542,75 +5642,6 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
return calibrationPairsList;
}
// public void getROILimit(BgDataAnlyseResultIn anlyseResultIn) {
// File sampleTmp = null;
// try {
// //获取ftp文件路径下临时文件
// sampleTmp = phdFileUtil.analyzeFile(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName());
// if (Objects.nonNull(sampleTmp)){
// EnergySpectrumStruct sourceData = EnergySpectrumHandler.getSourceData(sampleTmp.getAbsolutePath());
// List<Double> poiBX1 = sourceData.POI_B_x1;
// List<Double> poiBX2 = sourceData.POI_B_x2;
// List<Double> poiGY1 = sourceData.POI_G_y1;
// List<Double> poiGY2 = sourceData.POI_G_y2;
// //ROI Limit
// List<String> report_limit_roi = new LinkedList<>();
// for(int pos=1;pos<=poiBX1.size();pos++) {
// report_limit_roi.add(String.valueOf(pos));
// }
// List<String> beginB = new LinkedList<>();
// for(int pos=1;pos<=poiBX1.size();pos++) {
// beginB.add(String.valueOf(poiBX1.get(pos)));
// }
// List<String> endB = new LinkedList<>();
// for(int pos=0;pos<poiBX2.size();pos++) {
// endB.add(String.valueOf(poiBX2.get(pos)));
// }
// List<String> beginG = new LinkedList<>();
// for(int pos=1;pos<=poiGY1.size();pos++) {
// beginG.add(String.valueOf(poiGY1.get(pos)));
// }
// List<String> endG = new LinkedList<>();
// for(int pos=0;pos<poiGY2.size();pos++) {
// endG.add(String.valueOf(poiGY2.get(pos)));
// }
// //ratios
// List<String> ratio_id = sourceData.ratio_id;
// List<String> ROI_num_highter_G_energy_ROI = sourceData.ROI_num_highter_G_energy_ROI;
// List<String> ROI_num_lower_G_energy_ROI = sourceData.ROI_num_lower_G_energy_ROI;
// List<Double> count_ratio = sourceData.count_ratio;
// List<Double> count_ratio_uncertainty = sourceData.count_ratio_uncertainty;
// List<String> countRatioList = new LinkedList<>();
// for(int pos=0;pos<count_ratio.size();pos++) {
// countRatioList.add(String.valueOf(count_ratio.get(pos)));
// }
// List<String> countRatioUncertaintyList = new LinkedList<>();
// for(int pos=0;pos<count_ratio_uncertainty.size();pos++) {
// countRatioUncertaintyList.add(String.valueOf(count_ratio_uncertainty.get(pos)));
// }
// //bg_efficiency
// List<Double> bg_efficiency = sourceData.bg_efficiency;
// List<String> nuclide_name = sourceData.nuclide_name;
// List<String> ROI_number = sourceData.ROI_number;
// List<Double> uncertainty = sourceData.uncertainty;
// List<String> efficiencyList = new LinkedList<>();
// for(int pos=0;pos<bg_efficiency.size();pos++) {
// efficiencyList.add(String.valueOf(bg_efficiency.get(pos)));
// }
// List<String> uncertaintyList = new LinkedList<>();
// for(int pos=0;pos<uncertainty.size();pos++) {
// uncertaintyList.add(String.valueOf(uncertainty.get(pos)));
// }
// }
// } catch (Exception e){
// e.printStackTrace();
// } finally {
// if (Objects.nonNull(sampleTmp)) {
// sampleTmp.delete();
// }
// }
// }
public List<GardsCalibration> getCalibration(BgDataAnlyseResultIn anlyseResultIn, Integer sampleId, Integer gasId, Integer detId, Integer idAnalysis) {
List<GardsCalibration> calibrationSpectrumList = new LinkedList<>();
if (Objects.nonNull(sampleId)) {