Merge remote-tracking branch 'origin/station' into station

This commit is contained in:
nieziyan 2023-11-03 19:14:45 +08:00
commit 45811d00e0
6 changed files with 822 additions and 495 deletions

View File

@ -62,7 +62,7 @@ public class GardsSampleDataServiceImpl extends ServiceImpl<GardsSampleDataMappe
*/ */
@Override @Override
public GardsSampleData getSampleIdAndInputFileName(String measurementId, String dataType, String systemType) { public GardsSampleData getSampleIdAndInputFileName(String measurementId, String dataType, String systemType) {
String detectorId = measurementId.substring(0, 8); String detectorId = measurementId.substring(0, 9);
final List<GardsSampleData> sampleDatas = this.baseMapper.getSampleIdAndInputFileName(measurementId, dataType, systemType, detectorId); final List<GardsSampleData> sampleDatas = this.baseMapper.getSampleIdAndInputFileName(measurementId, dataType, systemType, detectorId);
if(!CollectionUtils.isEmpty(sampleDatas)){ if(!CollectionUtils.isEmpty(sampleDatas)){
//如果查询出多条则需要根据inputFileName字段降序排序后返回第一个 //如果查询出多条则需要根据inputFileName字段降序排序后返回第一个

View File

@ -65,6 +65,10 @@ public class GammaFileUtil extends AbstractLogOrReport {
phd.setFilename(fileName); phd.setFilename(fileName);
String fromPath = pathName + StringPool.SLASH + fileName; String fromPath = pathName + StringPool.SLASH + fileName;
File file = ftpUtil.downloadFile(fromPath, "betaGamma"); File file = ftpUtil.downloadFile(fromPath, "betaGamma");
if (Objects.isNull(file)) {
result.error500("ftp file can't find");
return false;
}
try { try {
//读取文件信息 //读取文件信息
EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(file.getAbsolutePath()); EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(file.getAbsolutePath());
@ -238,7 +242,7 @@ public class GammaFileUtil extends AbstractLogOrReport {
return true; return true;
} }
public void SetBaseInfo(PHDFile phd) { public void SetBaseInfo(PHDFile phd, String prefixName) {
String pathName = phd.getFilepath(); String pathName = phd.getFilepath();
String fileName = phd.getFilename(); String fileName = phd.getFilename();
//文件名称需要加上自动处理的前缀以及修改不同的文件后缀名 //文件名称需要加上自动处理的前缀以及修改不同的文件后缀名
@ -248,7 +252,7 @@ public class GammaFileUtil extends AbstractLogOrReport {
File scacFile = null; File scacFile = null;
InputStream inputStreamBase = null; InputStream inputStreamBase = null;
try { try {
String lcFileName = "RNAUTO_"+subFileName + ".lc"; String lcFileName = prefixName+"_"+subFileName + ".lc";
String fromPathLc = pathName + StringPool.SLASH + lcFileName; String fromPathLc = pathName + StringPool.SLASH + lcFileName;
lcFile = ftpUtil.downloadFile(fromPathLc, "betaGamma"); lcFile = ftpUtil.downloadFile(fromPathLc, "betaGamma");
@ -258,7 +262,7 @@ public class GammaFileUtil extends AbstractLogOrReport {
//将数据结果赋值给 phdFile的vLc //将数据结果赋值给 phdFile的vLc
phd.setVLc(vDataLc); phd.setVLc(vDataLc);
String scacFileName = "RNAUTO_"+subFileName + ".scac"; String scacFileName = prefixName+"_"+subFileName + ".scac";
String fromPathScac = pathName + StringPool.SLASH + scacFileName; String fromPathScac = pathName + StringPool.SLASH + scacFileName;
scacFile = ftpUtil.downloadFile(fromPathScac, "betaGamma"); scacFile = ftpUtil.downloadFile(fromPathScac, "betaGamma");
@ -268,7 +272,7 @@ public class GammaFileUtil extends AbstractLogOrReport {
//将数据结果赋值给 phdFile的vLc //将数据结果赋值给 phdFile的vLc
phd.setVScac(vDataScac); phd.setVScac(vDataScac);
String baselineFileName = "RNAUTO_"+subFileName + ".baseline"; String baselineFileName = prefixName+"_"+subFileName + ".baseline";
String fromPathBase = pathName + StringPool.SLASH + baselineFileName; String fromPathBase = pathName + StringPool.SLASH + baselineFileName;
inputStreamBase = ftpUtil.downloadFileStream(fromPathBase); inputStreamBase = ftpUtil.downloadFileStream(fromPathBase);
// 调用处理BaseCtrl的方法 // 调用处理BaseCtrl的方法
@ -861,7 +865,7 @@ public class GammaFileUtil extends AbstractLogOrReport {
return true; return true;
} }
public List<String> DetailedInfo(Integer sampleId, PHDFile phd) { public List<String> DetailedInfo(String sampleId, PHDFile phd) {
try { try {
// Sample_Id, Station_Code, Detector_Code, System_Type, Data_Type, Spectral_Qualifier, // Sample_Id, Station_Code, Detector_Code, System_Type, Data_Type, Spectral_Qualifier,
// SRID, Sample_Status, Collect_Start, Sampling_Time, Quantity, Flow_Rate, // SRID, Sample_Status, Collect_Start, Sampling_Time, Quantity, Flow_Rate,
@ -872,7 +876,7 @@ public class GammaFileUtil extends AbstractLogOrReport {
detailInfo.add(""); detailInfo.add("");
} }
//读取phdFile的数据 修改detailInfo的数据 //读取phdFile的数据 修改detailInfo的数据
detailInfo.set(0, Objects.nonNull(sampleId)?sampleId.toString():""); // Sample_Id detailInfo.set(0, StringUtils.isNotBlank(sampleId)?sampleId:""); // Sample_Id
detailInfo.set(1, phd.getHeader().getSite_code()); // Station_Code detailInfo.set(1, phd.getHeader().getSite_code()); // Station_Code
detailInfo.set(2, phd.getHeader().getDetector_code()); // Detector_Code detailInfo.set(2, phd.getHeader().getDetector_code()); // Detector_Code
detailInfo.set(3, phd.getHeader().getSystem_type().toUpperCase()); // System_Type detailInfo.set(3, phd.getHeader().getSystem_type().toUpperCase()); // System_Type
@ -3020,9 +3024,21 @@ public class GammaFileUtil extends AbstractLogOrReport {
anylseEnd = DateUtils.formatDate(new Date(), "yyyy/MM/dd HH:mm:ss"); anylseEnd = DateUtils.formatDate(new Date(), "yyyy/MM/dd HH:mm:ss");
middleData.analyses_analysisBegin = anylseBegin; middleData.analyses_analysisBegin = anylseBegin;
middleData.analyses_analysisEnd = anylseEnd; middleData.analyses_analysisEnd = anylseEnd;
} else if (type.equals(MiddleDataType.InterAction.getType())){ //如果是人工交互分析 则先上传phd对应文件信息
//上传本次文件到ftp人工交互存储路径下
File sampleTmp = null;
try {
sampleTmp = analyzeFile(StringPool.SLASH + ftpUtil.getFtpRootPath() + fileAnlyse.getFilepath(), fileAnlyse.getFilename());
if (Objects.nonNull(sampleTmp)) {
bRet = ftpUtil.saveFile(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + middleData.analyses_save_filePath.substring(0, middleData.analyses_save_filePath.lastIndexOf(StringPool.SLASH)), middleData.analyses_save_filePath.substring(middleData.analyses_save_filePath.lastIndexOf(StringPool.SLASH)+1), new FileInputStream(sampleTmp));
}
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
} finally {
sampleTmp.delete();
}
} }
//gards_analyses //gards_analyses
String qsBaseLinePath = path+StringPool.SLASH+middleData.analyses_analyst+"_"+baselineName; String qsBaseLinePath = path+StringPool.SLASH+middleData.analyses_analyst+"_"+baselineName;
qsBaseLinePath = qsBaseLinePath.replace(StringPool.BACK_SLASH, StringPool.SLASH); qsBaseLinePath = qsBaseLinePath.replace(StringPool.BACK_SLASH, StringPool.SLASH);

View File

@ -605,7 +605,8 @@ public class PHDFileUtil extends AbstractLogOrReport {
return file; return file;
} }
public void analyzeSpectrum(File sampleTmp, File gasTmp, File detTmp, BgCalibratePara BgCalPara, Map<String, Object> map) { public boolean analyzeSpectrum(File sampleTmp, File gasTmp, File detTmp, BgCalibratePara BgCalPara, Map<String, Object> map) {
boolean bRet = true;
//调用动态库解析文件 //调用动态库解析文件
BgAnalyseResult analyseResult = null; BgAnalyseResult analyseResult = null;
if (Objects.isNull(BgCalPara)) { if (Objects.isNull(BgCalPara)) {
@ -613,84 +614,90 @@ public class PHDFileUtil extends AbstractLogOrReport {
} else { } else {
analyseResult = EnergySpectrumHandler.bgReAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath(), BgCalPara); analyseResult = EnergySpectrumHandler.bgReAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath(), BgCalPara);
} }
EnergySpectrumStruct sample = analyzeFileSourceData(sampleTmp); if (StringUtils.isNotBlank(analyseResult.error_log) && !analyseResult.error_log.equalsIgnoreCase("no error.")) {
EnergySpectrumStruct gas = analyzeFileSourceData(gasTmp); bRet = false;
EnergySpectrumStruct det = analyzeFileSourceData(detTmp); return bRet;
String sampleFileName = (String) map.get("sampleFileName"); } else {
String logName = sampleFileName.replace("PHD", "log"); EnergySpectrumStruct sample = analyzeFileSourceData(sampleTmp);
OutPutRnLog(analyseResult, sample, gas, det, logName); EnergySpectrumStruct gas = analyzeFileSourceData(gasTmp);
//需要返回到前端的XeData数据 EnergySpectrumStruct det = analyzeFileSourceData(detTmp);
List<GardsXeResultsSpectrum> xeResultsSpectrumList = new LinkedList<>(); String sampleFileName = (String) map.get("sampleFileName");
//存入计算后得到的xeData数据 String logName = sampleFileName.replace("PHD", "log");
GardsXeResultsSpectrum xe131m = new GardsXeResultsSpectrum(); OutPutRnLog(analyseResult, sample, gas, det, logName);
xe131m.setNuclideName(XeNuclideName.XE_131m.getType()); //需要返回到前端的XeData数据
xe131m.setConc(analyseResult.Xe131m_con); List<GardsXeResultsSpectrum> xeResultsSpectrumList = new LinkedList<>();
xe131m.setConcErr(analyseResult.Xe131m_uncer); //存入计算后得到的xeData数据
xe131m.setLc(analyseResult.LC_Xe131m); GardsXeResultsSpectrum xe131m = new GardsXeResultsSpectrum();
xe131m.setMdc(analyseResult.MDC_Xe131m); xe131m.setNuclideName(XeNuclideName.XE_131m.getType());
xe131m.setNidFlag(analyseResult.XE_131m_NID_FLAG); xe131m.setConc(analyseResult.Xe131m_con);
xeResultsSpectrumList.add(xe131m); xe131m.setConcErr(analyseResult.Xe131m_uncer);
GardsXeResultsSpectrum xe133 = new GardsXeResultsSpectrum(); xe131m.setLc(analyseResult.LC_Xe131m);
xe133.setNuclideName(XeNuclideName.XE_133.getType()); xe131m.setMdc(analyseResult.MDC_Xe131m);
xe133.setConc(analyseResult.Xe133_con); xe131m.setNidFlag(analyseResult.XE_131m_NID_FLAG);
xe133.setConcErr(analyseResult.Xe133_uncer); xeResultsSpectrumList.add(xe131m);
xe133.setLc(analyseResult.LC_Xe133); GardsXeResultsSpectrum xe133 = new GardsXeResultsSpectrum();
xe133.setMdc(analyseResult.MDC_Xe133); xe133.setNuclideName(XeNuclideName.XE_133.getType());
xe133.setNidFlag(analyseResult.XE_133_NID_FLAG); xe133.setConc(analyseResult.Xe133_con);
xeResultsSpectrumList.add(xe133); xe133.setConcErr(analyseResult.Xe133_uncer);
GardsXeResultsSpectrum xe133m = new GardsXeResultsSpectrum(); xe133.setLc(analyseResult.LC_Xe133);
xe133m.setNuclideName(XeNuclideName.XE_133m.getType()); xe133.setMdc(analyseResult.MDC_Xe133);
xe133m.setConc(analyseResult.Xe133m_con); xe133.setNidFlag(analyseResult.XE_133_NID_FLAG);
xe133m.setConcErr(analyseResult.Xe133m_uncer); xeResultsSpectrumList.add(xe133);
xe133m.setLc(analyseResult.LC_Xe133m); GardsXeResultsSpectrum xe133m = new GardsXeResultsSpectrum();
xe133m.setMdc(analyseResult.MDC_Xe133m); xe133m.setNuclideName(XeNuclideName.XE_133m.getType());
xe133m.setNidFlag(analyseResult.XE_133m_NID_FLAG); xe133m.setConc(analyseResult.Xe133m_con);
xeResultsSpectrumList.add(xe133m); xe133m.setConcErr(analyseResult.Xe133m_uncer);
GardsXeResultsSpectrum xe135 = new GardsXeResultsSpectrum(); xe133m.setLc(analyseResult.LC_Xe133m);
xe135.setNuclideName(XeNuclideName.XE_135.getType()); xe133m.setMdc(analyseResult.MDC_Xe133m);
xe135.setConc(analyseResult.Xe135_con); xe133m.setNidFlag(analyseResult.XE_133m_NID_FLAG);
xe135.setConcErr(analyseResult.Xe135_uncer); xeResultsSpectrumList.add(xe133m);
xe135.setLc(analyseResult.LC_Xe135); GardsXeResultsSpectrum xe135 = new GardsXeResultsSpectrum();
xe135.setMdc(analyseResult.MDC_Xe135); xe135.setNuclideName(XeNuclideName.XE_135.getType());
xe135.setNidFlag(analyseResult.XE_135_NID_FLAG); xe135.setConc(analyseResult.Xe135_con);
xeResultsSpectrumList.add(xe135); xe135.setConcErr(analyseResult.Xe135_uncer);
map.put("XeData", xeResultsSpectrumList); xe135.setLc(analyseResult.LC_Xe135);
//新计算得到的边界值 xe135.setMdc(analyseResult.MDC_Xe135);
if (CollectionUtils.isNotEmpty(analyseResult.S_ROI_B_Boundary_start)) { xe135.setNidFlag(analyseResult.XE_135_NID_FLAG);
List<Boundary> boundaryList = new LinkedList<>(); xeResultsSpectrumList.add(xe135);
for (int i=0; i<analyseResult.S_ROI_B_Boundary_start.size(); i++) { map.put("XeData", xeResultsSpectrumList);
Boundary boundary = new Boundary(); //新计算得到的边界值
boundary.setMinX(analyseResult.S_ROI_B_Boundary_start.get(i)); if (CollectionUtils.isNotEmpty(analyseResult.S_ROI_B_Boundary_start)) {
boundary.setMaxX(analyseResult.S_ROI_B_Boundary_stop.get(i)); List<Boundary> boundaryList = new LinkedList<>();
boundary.setMinY(analyseResult.S_ROI_G_Boundary_start.get(i)); for (int i=0; i<analyseResult.S_ROI_B_Boundary_start.size(); i++) {
boundary.setMaxY(analyseResult.S_ROI_G_Boundary_stop.get(i)); Boundary boundary = new Boundary();
boundaryList.add(boundary); boundary.setMinX(analyseResult.S_ROI_B_Boundary_start.get(i));
boundary.setMaxX(analyseResult.S_ROI_B_Boundary_stop.get(i));
boundary.setMinY(analyseResult.S_ROI_G_Boundary_start.get(i));
boundary.setMaxY(analyseResult.S_ROI_G_Boundary_stop.get(i));
boundaryList.add(boundary);
}
map.put("SampleBoundary", boundaryList);
} }
map.put("SampleBoundary", boundaryList); if (CollectionUtils.isNotEmpty(analyseResult.G_ROI_B_Boundary_start)) {
} List<Boundary> boundaryList = new LinkedList<>();
if (CollectionUtils.isNotEmpty(analyseResult.G_ROI_B_Boundary_start)) { for (int i=0; i<analyseResult.G_ROI_B_Boundary_start.size(); i++) {
List<Boundary> boundaryList = new LinkedList<>(); Boundary boundary = new Boundary();
for (int i=0; i<analyseResult.G_ROI_B_Boundary_start.size(); i++) { boundary.setMinX(analyseResult.G_ROI_B_Boundary_start.get(i));
Boundary boundary = new Boundary(); boundary.setMaxX(analyseResult.G_ROI_B_Boundary_stop.get(i));
boundary.setMinX(analyseResult.G_ROI_B_Boundary_start.get(i)); boundary.setMinY(analyseResult.G_ROI_G_Boundary_start.get(i));
boundary.setMaxX(analyseResult.G_ROI_B_Boundary_stop.get(i)); boundary.setMaxY(analyseResult.G_ROI_G_Boundary_stop.get(i));
boundary.setMinY(analyseResult.G_ROI_G_Boundary_start.get(i)); boundaryList.add(boundary);
boundary.setMaxY(analyseResult.G_ROI_G_Boundary_stop.get(i)); }
boundaryList.add(boundary); map.put("GasBoundary", boundaryList);
} }
map.put("GasBoundary", boundaryList); if (CollectionUtils.isNotEmpty(analyseResult.D_ROI_B_Boundary_start)) {
} List<Boundary> boundaryList = new LinkedList<>();
if (CollectionUtils.isNotEmpty(analyseResult.D_ROI_B_Boundary_start)) { for (int i=0; i<analyseResult.D_ROI_B_Boundary_start.size(); i++) {
List<Boundary> boundaryList = new LinkedList<>(); Boundary boundary = new Boundary();
for (int i=0; i<analyseResult.D_ROI_B_Boundary_start.size(); i++) { boundary.setMinX(analyseResult.D_ROI_B_Boundary_start.get(i));
Boundary boundary = new Boundary(); boundary.setMaxX(analyseResult.D_ROI_B_Boundary_stop.get(i));
boundary.setMinX(analyseResult.D_ROI_B_Boundary_start.get(i)); boundary.setMinY(analyseResult.D_ROI_G_Boundary_start.get(i));
boundary.setMaxX(analyseResult.D_ROI_B_Boundary_stop.get(i)); boundary.setMaxY(analyseResult.D_ROI_G_Boundary_stop.get(i));
boundary.setMinY(analyseResult.D_ROI_G_Boundary_start.get(i)); boundaryList.add(boundary);
boundary.setMaxY(analyseResult.D_ROI_G_Boundary_stop.get(i)); }
boundaryList.add(boundary); map.put("DetBoundary", boundaryList);
} }
map.put("DetBoundary", boundaryList); return bRet;
} }
} }
@ -1239,16 +1246,24 @@ public class PHDFileUtil extends AbstractLogOrReport {
//换行 //换行
out.append(System.lineSeparator()); out.append(System.lineSeparator());
//第三十六行数据 //第三十六行数据
if (bgAnalyseResult.s_b_fitting_c_e.size() > 0) { if (bgAnalyseResult.s_b_fitting_c_e != null && CollectionUtils.isNotEmpty(bgAnalyseResult.s_b_fitting_c_e)) {
out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_b_fitting_c_e.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_b_fitting_c_e.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_b_fitting_c_e.get(2))))); if (bgAnalyseResult.s_b_fitting_c_e.size() > 0) {
out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_b_fitting_c_e.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_b_fitting_c_e.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_b_fitting_c_e.get(2)))));
} else {
out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", "?", "?", "?"));
}
} else { } else {
out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", "?", "?", "?")); out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", "?", "?", "?"));
} }
//换行 //换行
out.append(System.lineSeparator()); out.append(System.lineSeparator());
//第三十七行数据 //第三十七行数据
if (bgAnalyseResult.s_b_fitting_e_c.size() > 0) { if (bgAnalyseResult.s_b_fitting_e_c != null && CollectionUtils.isNotEmpty(bgAnalyseResult.s_b_fitting_e_c)) {
out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_b_fitting_e_c.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_b_fitting_e_c.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_b_fitting_e_c.get(2))))); if (bgAnalyseResult.s_b_fitting_e_c.size() > 0) {
out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_b_fitting_e_c.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_b_fitting_e_c.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_b_fitting_e_c.get(2)))));
} else {
out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", "?", "?", "?"));
}
} else { } else {
out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", "?", "?", "?")); out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", "?", "?", "?"));
} }
@ -1261,16 +1276,24 @@ public class PHDFileUtil extends AbstractLogOrReport {
//换行 //换行
out.append(System.lineSeparator()); out.append(System.lineSeparator());
//第三十六行数据 //第三十六行数据
if (bgAnalyseResult.s_g_fitting_c_e.size() > 0) { if (bgAnalyseResult.s_g_fitting_c_e !=null && CollectionUtils.isNotEmpty(bgAnalyseResult.s_g_fitting_c_e)) {
out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_g_fitting_c_e.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_g_fitting_c_e.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_g_fitting_c_e.get(2))))); if (bgAnalyseResult.s_g_fitting_c_e.size() > 0) {
out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_g_fitting_c_e.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_g_fitting_c_e.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_g_fitting_c_e.get(2)))));
} else {
out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", "?", "?", "?"));
}
} else { } else {
out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", "?", "?", "?")); out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", "?", "?", "?"));
} }
//换行 //换行
out.append(System.lineSeparator()); out.append(System.lineSeparator());
//第三十七行数据 //第三十七行数据
if (bgAnalyseResult.s_g_fitting_e_c.size() > 0) { if (bgAnalyseResult.s_g_fitting_e_c != null && CollectionUtils.isNotEmpty(bgAnalyseResult.s_g_fitting_e_c)) {
out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_g_fitting_e_c.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_g_fitting_e_c.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_g_fitting_e_c.get(2))))); if (bgAnalyseResult.s_g_fitting_e_c.size() > 0) {
out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_g_fitting_e_c.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_g_fitting_e_c.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_g_fitting_e_c.get(2)))));
} else {
out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", "?", "?", "?"));
}
} else { } else {
out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", "?", "?", "?")); out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", "?", "?", "?"));
} }
@ -1323,20 +1346,28 @@ public class PHDFileUtil extends AbstractLogOrReport {
//换行 //换行
out.append(System.lineSeparator()); out.append(System.lineSeparator());
//第四十四行数据 //第四十四行数据
if (bgAnalyseResult.d_b_fitting_c_e.size() > 0) { if (bgAnalyseResult.d_b_fitting_c_e != null && CollectionUtils.isNotEmpty(bgAnalyseResult.d_b_fitting_c_e)) {
out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_b_fitting_c_e.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_b_fitting_c_e.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_b_fitting_c_e.get(2))))); if (bgAnalyseResult.d_b_fitting_c_e.size() > 0) {
out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_b_fitting_c_e.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_b_fitting_c_e.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_b_fitting_c_e.get(2)))));
} else {
out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", "?", "?", "?"));
}
} else { } else {
out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", "?", "?", "?")); out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", "?", "?", "?"));
} }
//换行 //换行
out.append(System.lineSeparator()); out.append(System.lineSeparator());
//第四十五行数据 //第四十五行数据
if (bgAnalyseResult.d_b_fitting_e_c.size() > 0) { if (bgAnalyseResult.d_b_fitting_e_c != null && CollectionUtils.isNotEmpty(bgAnalyseResult.d_b_fitting_e_c)) {
out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_b_fitting_e_c.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_b_fitting_e_c.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_b_fitting_e_c.get(2))))); if (bgAnalyseResult.d_b_fitting_e_c.size() > 0) {
out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_b_fitting_e_c.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_b_fitting_e_c.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_b_fitting_e_c.get(2)))));
} else {
out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", "?", "?", "?"));
}
} else { } else {
out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", "?", "?", "?")); out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", "?", "?", "?"));
} }
//换行 //换行
out.append(System.lineSeparator()); out.append(System.lineSeparator());
//换行 //换行
@ -1346,16 +1377,24 @@ public class PHDFileUtil extends AbstractLogOrReport {
//换行 //换行
out.append(System.lineSeparator()); out.append(System.lineSeparator());
//第四十四行数据 //第四十四行数据
if (bgAnalyseResult.d_g_fitting_c_e.size() > 0) { if (bgAnalyseResult.d_g_fitting_c_e != null && CollectionUtils.isNotEmpty(bgAnalyseResult.d_g_fitting_c_e)) {
out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_g_fitting_c_e.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_g_fitting_c_e.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_g_fitting_c_e.get(2))))); if (bgAnalyseResult.d_g_fitting_c_e.size() > 0) {
out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_g_fitting_c_e.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_g_fitting_c_e.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_g_fitting_c_e.get(2)))));
} else {
out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", "?", "?", "?"));
}
} else { } else {
out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", "?", "?", "?")); out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", "?", "?", "?"));
} }
//换行 //换行
out.append(System.lineSeparator()); out.append(System.lineSeparator());
//第四十五行数据 //第四十五行数据
if (bgAnalyseResult.d_g_fitting_e_c.size() > 0) { if (bgAnalyseResult.d_g_fitting_e_c != null && CollectionUtils.isNotEmpty(bgAnalyseResult.d_g_fitting_e_c)) {
out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_g_fitting_e_c.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_g_fitting_e_c.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_g_fitting_e_c.get(2))))); if (bgAnalyseResult.d_g_fitting_e_c.size() > 0) {
out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_g_fitting_e_c.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_g_fitting_e_c.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_g_fitting_e_c.get(2)))));
} else {
out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", "?", "?", "?"));
}
} else { } else {
out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", "?", "?", "?")); out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", "?", "?", "?"));
} }
@ -1403,16 +1442,24 @@ public class PHDFileUtil extends AbstractLogOrReport {
//换行 //换行
out.append(System.lineSeparator()); out.append(System.lineSeparator());
//第五十一行数据 //第五十一行数据
if (bgAnalyseResult.g_b_fitting_c_e.size() > 0) { if (bgAnalyseResult.g_b_fitting_c_e != null && CollectionUtils.isNotEmpty(bgAnalyseResult.g_b_fitting_c_e)) {
out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_b_fitting_c_e.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_b_fitting_c_e.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_b_fitting_c_e.get(2))))); if (bgAnalyseResult.g_b_fitting_c_e.size() > 0) {
out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_b_fitting_c_e.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_b_fitting_c_e.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_b_fitting_c_e.get(2)))));
} else {
out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", "?", "?", "?"));
}
} else { } else {
out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", "?", "?", "?")); out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", "?", "?", "?"));
} }
//换行 //换行
out.append(System.lineSeparator()); out.append(System.lineSeparator());
//第五十二行数据 //第五十二行数据
if (bgAnalyseResult.g_b_fitting_e_c.size() > 0) { if (bgAnalyseResult.g_b_fitting_e_c != null && CollectionUtils.isNotEmpty(bgAnalyseResult.g_b_fitting_e_c)) {
out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_b_fitting_e_c.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_b_fitting_e_c.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_b_fitting_e_c.get(2))))); if (bgAnalyseResult.g_b_fitting_e_c.size() > 0) {
out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_b_fitting_e_c.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_b_fitting_e_c.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_b_fitting_e_c.get(2)))));
} else {
out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", "?", "?", "?"));
}
} else { } else {
out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", "?", "?", "?")); out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", "?", "?", "?"));
} }
@ -1425,16 +1472,24 @@ public class PHDFileUtil extends AbstractLogOrReport {
//换行 //换行
out.append(System.lineSeparator()); out.append(System.lineSeparator());
//第五十四行数据 //第五十四行数据
if (bgAnalyseResult.g_g_fitting_c_e.size() > 0) { if (bgAnalyseResult.g_g_fitting_c_e != null && CollectionUtils.isNotEmpty(bgAnalyseResult.g_g_fitting_c_e)) {
out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_g_fitting_c_e.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_g_fitting_c_e.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_g_fitting_c_e.get(2))))); if (bgAnalyseResult.g_g_fitting_c_e.size() > 0) {
out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_g_fitting_c_e.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_g_fitting_c_e.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_g_fitting_c_e.get(2)))));
} else {
out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", "?", "?", "?"));
}
} else { } else {
out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", "?", "?", "?")); out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", "?", "?", "?"));
} }
//换行 //换行
out.append(System.lineSeparator()); out.append(System.lineSeparator());
//第五十五行数据 //第五十五行数据
if (bgAnalyseResult.g_g_fitting_e_c.size() > 0) { if (bgAnalyseResult.g_g_fitting_e_c != null && CollectionUtils.isNotEmpty(bgAnalyseResult.g_g_fitting_e_c)) {
out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_g_fitting_e_c.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_g_fitting_e_c.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_g_fitting_e_c.get(2))))); if (bgAnalyseResult.g_g_fitting_e_c.size() > 0) {
out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_g_fitting_e_c.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_g_fitting_e_c.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_g_fitting_e_c.get(2)))));
} else {
out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", "?", "?", "?"));
}
} else { } else {
out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", "?", "?", "?")); out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", "?", "?", "?"));
} }

View File

@ -22,7 +22,7 @@ public class BgDataAnlyseResultIn implements Serializable {
/** /**
* 标识本次操作是否进行过解析 * 标识本次操作是否进行过解析
*/ */
private boolean bProcessed; private boolean savedAnalysisResult;
/** /**
* 分析员名称 * 分析员名称
@ -266,7 +266,7 @@ public class BgDataAnlyseResultIn implements Serializable {
public BgDataAnlyseResultIn() { public BgDataAnlyseResultIn() {
comment = ""; comment = "";
bProcessed = false; savedAnalysisResult = false;
userName = ""; userName = "";
stationName = ""; stationName = "";
dbName = ""; dbName = "";

View File

@ -85,6 +85,8 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
@Autowired @Autowired
private FileFtransitUtil fileFtransitUtil; private FileFtransitUtil fileFtransitUtil;
@Autowired @Autowired
private NameStandUtil nameStandUtil;
@Autowired
private DBUtil dbUtil; private DBUtil dbUtil;
@Autowired @Autowired
private UserTaskUtil userTaskUtil; private UserTaskUtil userTaskUtil;
@ -160,9 +162,24 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
return result; return result;
} }
// 声明基础数组信息 // 声明基础数组信息
gammaFileUtil.SetBaseInfo(phd); if (dbName.equals("auto")) {
gammaFileUtil.SetBaseInfo(phd, "RNAUTO");
} else if (dbName.equals("man")) {
gammaFileUtil.SetBaseInfo(phd, userName);
}
// 从数据库中读取相关信息 // 从数据库中读取相关信息
boolean bRet = getResultFromDB(dbName, userName, sampleId, phd, result); boolean bRet = getResultFromDB(dbName, userName, sampleId, phd, result);
if (!redisUtil.hasKey(fileName+"-"+userName)) {
// 查询当前用户关联的核素信息
List<String> userLib = new LinkedList<>();
// 从postgreSql中获取当前用户关注的核素信息 如果当前用户没有 则返回管理员的
userLib = defaultNuclideSpectrumService.findNuclidesByUserName(userName, phd.getHeader().getSystem_type().toUpperCase());
if (CollectionUtils.isEmpty(userLib)) {
userLib = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase());
}
Map<String, NuclideLines> nuclideMap = GetNuclideLines(userLib);
redisUtil.set(fileName+"-"+userName, nuclideMap);
}
if (!bRet) { if (!bRet) {
return result; return result;
} }
@ -171,6 +188,17 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
String pathName = ftpUtil.getFtpRootPath() + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; String pathName = ftpUtil.getFtpRootPath() + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName;
String fileName = samfileName; String fileName = samfileName;
boolean flag = gammaFileUtil.loadFile(pathName, fileName, phd, result); boolean flag = gammaFileUtil.loadFile(pathName, fileName, phd, result);
if (!redisUtil.hasKey(fileName+"-"+userName)) {
// 查询当前用户关联的核素信息
List<String> userLib = new LinkedList<>();
// 从postgreSql中获取当前用户关注的核素信息 如果当前用户没有 则返回管理员的
userLib = defaultNuclideSpectrumService.findNuclidesByUserName(userName, phd.getHeader().getSystem_type().toUpperCase());
if (CollectionUtils.isEmpty(userLib)) {
userLib = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase());
}
Map<String, NuclideLines> nuclideMap = GetNuclideLines(userLib);
redisUtil.set(fileName+"-"+userName, nuclideMap);
}
if (!flag) { if (!flag) {
return result; return result;
} }
@ -437,18 +465,24 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
return result; return result;
} }
// 加载phd数据所需的lcscacbaseline数据 // 加载phd数据所需的lcscacbaseline数据
gammaFileUtil.SetBaseInfo(phd); if (dbName.equals("auto")) {
gammaFileUtil.SetBaseInfo(phd, "RNAUTO");
} else if (dbName.equals("man")) {
gammaFileUtil.SetBaseInfo(phd, userName);
}
// 从数据库中读取phd其他相关信息 // 从数据库中读取phd其他相关信息
boolean bRet = getResultFromDB(dbName, userName, sampleId, phd, result); boolean bRet = getResultFromDB(dbName, userName, sampleId, phd, result);
// 查询当前用户关联的核素信息 if (!redisUtil.hasKey(fileName+"-"+userName)) {
List<String> userLib = new LinkedList<>(); // 查询当前用户关联的核素信息
// 从postgreSql中获取当前用户关注的核素信息 如果当前用户没有 则返回管理员的 List<String> userLib = new LinkedList<>();
userLib = defaultNuclideSpectrumService.findNuclidesByUserName(userName, phd.getHeader().getSystem_type().toUpperCase()); // 从postgreSql中获取当前用户关注的核素信息 如果当前用户没有 则返回管理员的
if (CollectionUtils.isEmpty(userLib)) { userLib = defaultNuclideSpectrumService.findNuclidesByUserName(userName, phd.getHeader().getSystem_type().toUpperCase());
userLib = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase()); if (CollectionUtils.isEmpty(userLib)) {
userLib = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase());
}
Map<String, NuclideLines> nuclideMap = GetNuclideLines(userLib);
redisUtil.set(fileName+"-"+userName, nuclideMap);
} }
Map<String, NuclideLines> nuclideMap = GetNuclideLines(userLib);
redisUtil.set(fileName+"-"+userName, nuclideMap);
// 判断数据库信息是否读取正常 // 判断数据库信息是否读取正常
if (!bRet) { if (!bRet) {
return result; return result;
@ -460,7 +494,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
List<String> qcstate = gammaFileUtil.Qcstate(phd); List<String> qcstate = gammaFileUtil.Qcstate(phd);
map.put("QCFlag", qcstate); map.put("QCFlag", qcstate);
// 更新 Detailed Information 信息 // 更新 Detailed Information 信息
List<String> detailedInfo = gammaFileUtil.DetailedInfo(sampleId, phd); List<String> detailedInfo = gammaFileUtil.DetailedInfo(String.valueOf(sampleId), phd);
map.put("DetailedInformation", detailedInfo); map.put("DetailedInformation", detailedInfo);
// 更新 ACQ 模块中各时间信息 // 更新 ACQ 模块中各时间信息
map.put("start_time", phd.getAcq().getAcquisition_start_date() + "\n" + phd.getAcq().getAcquisition_start_time()); map.put("start_time", phd.getAcq().getAcquisition_start_date() + "\n" + phd.getAcq().getAcquisition_start_time());
@ -486,7 +520,14 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
public boolean getResultFromDB(String dbName, String userName, Integer sampleId, PHDFile phd, Result result) { public boolean getResultFromDB(String dbName, String userName, Integer sampleId, PHDFile phd, Result result) {
// 判断连接的数据库 // 判断连接的数据库
String T_analy, T_calib, T_peaks, T_param, T_nuc_line, T_nuc_act, T_qc, T_setting; String T_analy = "";
String T_calib = "";
String T_peaks = "";
String T_param = "";
String T_nuc_line = "";
String T_nuc_act = "";
String T_qc = "";
String T_setting = "";
if (dbName.equals("auto")) { if (dbName.equals("auto")) {
T_analy = "RNAUTO.GARDS_ANALYSES"; T_analy = "RNAUTO.GARDS_ANALYSES";
T_calib = "RNAUTO.GARDS_CALIBRATION_PAIRS"; T_calib = "RNAUTO.GARDS_CALIBRATION_PAIRS";
@ -496,7 +537,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
T_nuc_act = "RNAUTO.GARDS_NUCL_IDED"; T_nuc_act = "RNAUTO.GARDS_NUCL_IDED";
T_qc = "RNAUTO.GARDS_QC_CHECK"; T_qc = "RNAUTO.GARDS_QC_CHECK";
userName = "RNAUTO"; userName = "RNAUTO";
} else { } else if (dbName.equals("man")) {
T_analy = "RNMAN.GARDS_ANALYSES"; T_analy = "RNMAN.GARDS_ANALYSES";
T_calib = "RNMAN.GARDS_CALIBRATION_PAIRS"; T_calib = "RNMAN.GARDS_CALIBRATION_PAIRS";
T_peaks = "RNMAN.GARDS_PEAKS"; T_peaks = "RNMAN.GARDS_PEAKS";
@ -793,24 +834,26 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
phd = new PHDFile(); phd = new PHDFile();
// 加载文件内容 // 加载文件内容
boolean bRet = gammaFileUtil.loadFile(path, fileName, phd, result); boolean bRet = gammaFileUtil.loadFile(path, fileName, phd, result);
// 查询当前用户关联的核素信息
List<String> userLib = new LinkedList<>();
// 从postgreSql中获取当前用户关注的核素信息 如果当前用户没有 则返回管理员的
userLib = defaultNuclideSpectrumService.findNuclidesByUserName(userName, phd.getHeader().getSystem_type().toUpperCase());
if (CollectionUtils.isEmpty(userLib)) {
userLib = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase());
}
Map<String, NuclideLines> nuclideMap = GetNuclideLines(userLib);
redisUtil.set(fileName+"-"+userName, nuclideMap);
if (!bRet) { if (!bRet) {
return result; return result;
} }
if (!redisUtil.hasKey(fileName+"-"+userName)) {
// 查询当前用户关联的核素信息
List<String> userLib = new LinkedList<>();
// 从postgreSql中获取当前用户关注的核素信息 如果当前用户没有 则返回管理员的
userLib = defaultNuclideSpectrumService.findNuclidesByUserName(userName, phd.getHeader().getSystem_type().toUpperCase());
if (CollectionUtils.isEmpty(userLib)) {
userLib = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase());
}
Map<String, NuclideLines> nuclideMap = GetNuclideLines(userLib);
redisUtil.set(fileName+"-"+userName, nuclideMap);
}
} }
// 更新 QC Flags 状态 // 更新 QC Flags 状态
List<String> qcstate = gammaFileUtil.Qcstate(phd); List<String> qcstate = gammaFileUtil.Qcstate(phd);
map.put("QCFlag", qcstate); map.put("QCFlag", qcstate);
// 更新 Detailed Information 信息 // 更新 Detailed Information 信息
List<String> detailedInfo = gammaFileUtil.DetailedInfo(null, phd); List<String> detailedInfo = gammaFileUtil.DetailedInfo(phd.getId_sample(), phd);
map.put("DetailedInformation", detailedInfo); map.put("DetailedInformation", detailedInfo);
// 更新 ACQ 模块中各时间信息 // 更新 ACQ 模块中各时间信息
map.put("start_time", phd.getAcq().getAcquisition_start_date() + "\n" + phd.getAcq().getAcquisition_start_time()); map.put("start_time", phd.getAcq().getAcquisition_start_date() + "\n" + phd.getAcq().getAcquisition_start_time());
@ -839,6 +882,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
String key = fileName + StrUtil.DASHED + username; String key = fileName + StrUtil.DASHED + username;
// 删除指定key的Cache // 删除指定key的Cache
localCache.deletePHDCache(key); localCache.deletePHDCache(key);
redisUtil.del(key);
} }
@Override @Override
@ -4328,26 +4372,36 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
public Result saveToDB(String fileName, HttpServletRequest request) { public Result saveToDB(String fileName, HttpServletRequest request) {
Result result = new Result(); Result result = new Result();
String userName = JwtUtil.getUserNameByToken(request); String userName = JwtUtil.getUserNameByToken(request);
boolean bRet = true; boolean bRet = false;
Cache<String, PHDFile> phdCache = localCache.getPHDCache(); Cache<String, PHDFile> phdCache = localCache.getPHDCache();
PHDFile phd = phdCache.getIfPresent(fileName + "-" + userName); PHDFile phd = phdCache.getIfPresent(fileName + "-" + userName);
if (Objects.isNull(phd)) { if (Objects.isNull(phd)) {
result.error500("Please select the parse file first"); result.error500("Please select the parse file first");
return result; return result;
} }
// 查看分析员是否有权限操作当前台站信息 if (!phd.isBAnalyed()) {
// 判断当前分析员是否有过排班任务 result.error500("Please first Reprocessing!");
Integer stationId = spectrumAnalysisMapper.getStationId(phd.getHeader().getSite_code()); return result;
boolean bAnalysisResultWriteAuthority = userTaskUtil.CheckUserWriteAuthorityForStation(userName, stationId);
// 如果用户没有权限操作 则查看当前用户是否是高级分析员/管理员
if (!bAnalysisResultWriteAuthority) {
List<String> roleCodes = userTaskUtil.findRoleCodeByUserName(userName);
// 如果只是分析员 则无法保存数据库 返回信息
if (roleCodes.contains(RoleType.Role_Analyst) && !roleCodes.contains(RoleType.Role_SuperAnalyst) && !roleCodes.contains(RoleType.Role_Manager)) {
bRet = false;
}
} }
if (!bRet) { //获取当前操作的台站的id
Integer stationId = spectrumAnalysisMapper.getStationId(phd.getHeader().getSite_code());
//判断当前分析员当天是否有对应台站的排班任务
List<String> userStation = userTaskUtil.findUserStation(userName);
boolean bAnalysisResultWriteAuthority = false;
if (userStation.contains(String.valueOf(stationId))) {
bAnalysisResultWriteAuthority = true;
}
//根据系统类型获取系统存储前缀
String sysTemSubdir = nameStandUtil.GetSysTemSubdir(phd.getHeader().getSystem_type());
//根据数据类型获取数据存储前缀
String dateTypeSubdir = nameStandUtil.GetDateTypeSubdir(phd.getMsgInfo().getData_type());
//格式化名称
Map<String, String> nameMap = nameStandUtil.NameStandard(phd);
String mSaveFileName = nameMap.get("saveFile");
//判断当前分析员是否有过历史分析当前文件
Integer isExist = spectrumAnalysisMapper.SampleIsExist(sysTemSubdir+ dateTypeSubdir + StringPool.SLASH + mSaveFileName, userName);
// 如果用户没有权限操作 则查看当前用户是否是高级分析员/管理员
if (!bAnalysisResultWriteAuthority && Objects.isNull(isExist)) {
result.error500("You have no permission to save results to DB!"); result.error500("You have no permission to save results to DB!");
return result; return result;
} }
@ -4366,7 +4420,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
phd.setStatus(sampleData.getStatus()); phd.setStatus(sampleData.getStatus());
} else { } else {
// 如果sampleData为空 存储数据 // 如果sampleData为空 存储数据
SaveSampleToDB(phd, middleData.analyses_save_filePath); bRet = SaveSampleToDB(phd, middleData.analyses_save_filePath);
} }
if (!bRet) { if (!bRet) {
result.error500("The Database hasn't this Spectrum(" + phd.getFilename() + ") and Insert it to Database failed."); result.error500("The Database hasn't this Spectrum(" + phd.getFilename() + ") and Insert it to Database failed.");
@ -4386,8 +4440,6 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
if (StringUtils.isBlank(idAnalysis)) { if (StringUtils.isBlank(idAnalysis)) {
// RNMAN.GARDS_ANALYSES 表插入数据 // RNMAN.GARDS_ANALYSES 表插入数据
analysesSpectrumService.insertEntity(middleData, phd, userName, comments); analysesSpectrumService.insertEntity(middleData, phd, userName, comments);
// 查询idAnalysis
idAnalysis = spectrumAnalysisMapper.getIdAnalysisByIdAnalyst(phd.getId_sample(), userName);
// 修改sample_data状态 // 修改sample_data状态
spectrumAnalysisMapper.updateAnalysesStatus(middleData.analyses_save_filePath); spectrumAnalysisMapper.updateAnalysesStatus(middleData.analyses_save_filePath);
} else { } else {
@ -4427,27 +4479,48 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
paths.add(middleData.analyses_lc_filePath); paths.add(middleData.analyses_lc_filePath);
paths.add(middleData.analyses_scac_filePath); paths.add(middleData.analyses_scac_filePath);
paths.add(middleData.analyses_baseline_filePath); paths.add(middleData.analyses_baseline_filePath);
if (false) paths.add(middleData.analyses_save_filePath); if (bRet) {
paths.add(middleData.analyses_save_filePath);
}
} else { } else {
result.error500("Save analysis results to DB failed."); result.error500("Save analysis results to DB failed.");
return result; return result;
} }
Map<String, Object> map = new HashMap<>();
//更新detial Information
List<String> detailedInfo = gammaFileUtil.DetailedInfo(phd.getId_sample(), phd);
map.put("DetailedInformation", detailedInfo);
result.setSuccess(true);
result.setResult(map);
return result; return result;
} }
@Transactional @Transactional
public void SaveSampleToDB(PHDFile phd, String input_file_name) { public boolean SaveSampleToDB(PHDFile phd, String input_file_name) {
boolean bRet = false;
String sit_det_code = phd.getHeader().getSite_code(); String sit_det_code = phd.getHeader().getSite_code();
String detect_code = phd.getHeader().getDetector_code(); String detect_code = phd.getHeader().getDetector_code();
// 查询 station_id detect_id // 查询 station_id detect_id
Integer station_id = spectrumAnalysisMapper.getStationId(sit_det_code); Integer station_id = spectrumAnalysisMapper.getStationId(sit_det_code);
Integer detect_id = spectrumAnalysisMapper.getDetectorId(detect_code); Integer detect_id = spectrumAnalysisMapper.getDetectorId(detect_code);
// ORIGINAL.GARDS_SAMPLE_DATA 表数据 // ORIGINAL.GARDS_SAMPLE_DATA 表数据
sampleDataSpectrumService.saveSampleDataGamma(phd, input_file_name, station_id, detect_id); Integer saveSampleDataGamma = sampleDataSpectrumService.saveSampleDataGamma(phd, input_file_name, station_id, detect_id);
if (saveSampleDataGamma > 0) {
bRet = true;
} else {
bRet = false;
return bRet;
}
// 查询新增后的 sample_id 的值赋给变量 DECLARESAMPLEID // 查询新增后的 sample_id 的值赋给变量 DECLARESAMPLEID
Integer sampleId = spectrumAnalysisMapper.getSampleId(input_file_name); Integer sampleId = spectrumAnalysisMapper.getSampleId(input_file_name);
// ORIGINAL.GARDS_SAMPLE_AUX 表数据 // ORIGINAL.GARDS_SAMPLE_AUX 表数据
sampleAuxSpectrumService.saveSampleAuxGamma(phd, sampleId); Integer saveSampleAuxGamma = sampleAuxSpectrumService.saveSampleAuxGamma(phd, sampleId);
if (saveSampleAuxGamma > 0) {
bRet = true;
} else {
bRet = false;
return bRet;
}
// ORIGINAL.gards_sample_description 数据表 // ORIGINAL.gards_sample_description 数据表
sampleDescriptionSpectrumService.saveSampleDescriptionGamma(phd, sampleId); sampleDescriptionSpectrumService.saveSampleDescriptionGamma(phd, sampleId);
// ORIGINAL.GARDS_SAMPLE_CERT ORIGINAL.GARDS_SAMPLE_CERT_LINE 数据表 // ORIGINAL.GARDS_SAMPLE_CERT ORIGINAL.GARDS_SAMPLE_CERT_LINE 数据表
@ -4456,17 +4529,18 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
sampleCertLineSpectrumService.saveSampleCertLineGamma(phd, sampleId); sampleCertLineSpectrumService.saveSampleCertLineGamma(phd, sampleId);
} }
// gards_ calibration_pairs_orig数据表 // gards_ calibration_pairs_orig数据表
calibrationPairsOrigSpectrumService.saveCalibrationPairsOrigGamma(phd, sampleId); Integer saveCalibrationPairsOrigGamma = calibrationPairsOrigSpectrumService.saveCalibrationPairsOrigGamma(phd, sampleId);
// gards_total_efficiency _pairs数据表(IDC没有) // gards_total_efficiency _pairs数据表(IDC没有)
totalEfficiencyPairsSpectrumService.saveTotalEfficiencyPairsGamma(phd, sampleId); Integer saveTotalEfficiencyPairsGamma = totalEfficiencyPairsSpectrumService.saveTotalEfficiencyPairsGamma(phd, sampleId);
// gards_spectrum数据表 // gards_spectrum数据表
spectrumService.saveSpectrumGamma(phd, sampleId, input_file_name); Integer saveSpectrumGamma = spectrumService.saveSpectrumGamma(phd, sampleId, input_file_name);
// 根据文件名称获取sample基础数据信息 // 根据文件名称获取sample基础数据信息
GardsSampleDataSpectrum samplData = spectrumAnalysisMapper.findSampleByFilePath(input_file_name); GardsSampleDataSpectrum samplData = spectrumAnalysisMapper.findSampleByFilePath(input_file_name);
if (Objects.nonNull(samplData)) { if (Objects.nonNull(samplData)) {
phd.setId_sample(samplData.getSampleId().toString()); phd.setId_sample(samplData.getSampleId().toString());
phd.setStatus(samplData.getStatus()); phd.setStatus(samplData.getStatus());
} }
return bRet;
} }
@Override @Override
@ -4523,20 +4597,22 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
// 换行 // 换行
strBuild.append(System.lineSeparator()); strBuild.append(System.lineSeparator());
// 文本内容第三块数据 // 文本内容第三块数据
List<List<String>> peakNuclides = phd.getVPeak().stream().map(item -> item.nuclides).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(phd.getVPeak())) {
List<String> nuclides = new LinkedList<>(); List<List<String>> peakNuclides = phd.getVPeak().stream().map(item -> item.nuclides).collect(Collectors.toList());
for (int i = 0; i < peakNuclides.size(); i++) { List<String> nuclides = new LinkedList<>();
List<String> peakNuclide = peakNuclides.get(i); for (int i = 0; i < peakNuclides.size(); i++) {
nuclides.addAll(peakNuclide); List<String> peakNuclide = peakNuclides.get(i);
nuclides.addAll(peakNuclide);
}
nuclides = nuclides.stream().distinct().collect(Collectors.toList());
String nuclideStr = "";
for (int i = 0; i < nuclides.size(); i++) {
nuclideStr += " " + nuclides.get(i);
}
strBuild.append(nuclideStr);
// 换行
strBuild.append(System.lineSeparator());
} }
nuclides = nuclides.stream().distinct().collect(Collectors.toList());
String nuclideStr = "";
for (int i = 0; i < nuclides.size(); i++) {
nuclideStr += " " + nuclides.get(i);
}
strBuild.append(nuclideStr);
// 换行
strBuild.append(System.lineSeparator());
// 换行 // 换行
strBuild.append(System.lineSeparator()); strBuild.append(System.lineSeparator());
// 文本内容第四块 // 文本内容第四块
@ -4569,42 +4645,44 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
strBuild.append(System.lineSeparator()); strBuild.append(System.lineSeparator());
// 文本内容第五块数据 // 文本内容第五块数据
Map<String, NuclideActMda> mapNucActMda = phd.getMapNucActMda(); Map<String, NuclideActMda> mapNucActMda = phd.getMapNucActMda();
for (Map.Entry<String, NuclideActMda> entry : mapNucActMda.entrySet()) { if (CollectionUtils.isNotEmpty(mapNucActMda)) {
String key = entry.getKey(); for (Map.Entry<String, NuclideActMda> entry : mapNucActMda.entrySet()) {
NuclideActMda nuc = entry.getValue(); String key = entry.getKey();
String halflifeValue = ""; NuclideActMda nuc = entry.getValue();
if (nuc.isBCalculateMDA()) { String halflifeValue = "";
String units = "S"; if (nuc.isBCalculateMDA()) {
double halflife = nuc.getHalflife(); String units = "S";
if (halflife >= 31556736) {// 1年 = 365.24 * 24 * 60 * 60 = 31556736s double halflife = nuc.getHalflife();
halflife /= 31556736; if (halflife >= 31556736) {// 1年 = 365.24 * 24 * 60 * 60 = 31556736s
units = "A"; halflife /= 31556736;
} else if (halflife >= 86400) {// 1天 = 24 * 60 * 60 = 86400s units = "A";
halflife /= 86400; } else if (halflife >= 86400) {// 1天 = 24 * 60 * 60 = 86400s
units = "D"; halflife /= 86400;
} else if (halflife >= 3600) { units = "D";
halflife /= 3600; } else if (halflife >= 3600) {
units = "H"; halflife /= 3600;
units = "H";
}
halflifeValue = NumberFormatUtil.numberFormat(String.valueOf(halflife)) + units;
}
String efficiency = NumberFormatUtil.numberFormat(String.valueOf(nuc.getEfficiency()));
String activity = NumberFormatUtil.numberFormat(String.valueOf(nuc.getActivity()));
String actErr = "";
if (nuc.getActivity() > 0) {
actErr = NumberFormatUtil.numberFormat(String.valueOf(nuc.getAct_err() / nuc.getActivity() * 100));
}
String mda = NumberFormatUtil.numberFormat(String.valueOf(nuc.getMda()));
String conc = NumberFormatUtil.numberFormat(String.valueOf(nuc.getConcentration()));
String mdc = NumberFormatUtil.numberFormat(String.valueOf(nuc.getMdc()));
if (nuc.getCalculateIdx() >= 0 && nuc.getCalculateIdx() < nuc.getVEnergy().size()) {
String yield = NumberFormatUtil.numberFormat(String.valueOf(nuc.getVYield().get(nuc.getCalculateIdx()) * 100));
String energy = NumberFormatUtil.numberFormat(String.valueOf(nuc.getVEnergy().get(nuc.getCalculateIdx())));
strBuild.append(rowFormat(title5, key, halflifeValue, yield, energy, efficiency, activity, actErr, mda, conc, mdc));
strBuild.append(System.lineSeparator());
} else {
strBuild.append(rowFormat(title5, key, halflifeValue, "NULL", "NULL", efficiency, activity, actErr, mda, conc, mdc));
strBuild.append(System.lineSeparator());
} }
halflifeValue = NumberFormatUtil.numberFormat(String.valueOf(halflife)) + units;
}
String efficiency = NumberFormatUtil.numberFormat(String.valueOf(nuc.getEfficiency()));
String activity = NumberFormatUtil.numberFormat(String.valueOf(nuc.getActivity()));
String actErr = "";
if (nuc.getActivity() > 0) {
actErr = NumberFormatUtil.numberFormat(String.valueOf(nuc.getAct_err() / nuc.getActivity() * 100));
}
String mda = NumberFormatUtil.numberFormat(String.valueOf(nuc.getMda()));
String conc = NumberFormatUtil.numberFormat(String.valueOf(nuc.getConcentration()));
String mdc = NumberFormatUtil.numberFormat(String.valueOf(nuc.getMdc()));
if (nuc.getCalculateIdx() >= 0 && nuc.getCalculateIdx() < nuc.getVEnergy().size()) {
String yield = NumberFormatUtil.numberFormat(String.valueOf(nuc.getVYield().get(nuc.getCalculateIdx()) * 100));
String energy = NumberFormatUtil.numberFormat(String.valueOf(nuc.getVEnergy().get(nuc.getCalculateIdx())));
strBuild.append(rowFormat(title5, key, halflifeValue, yield, energy, efficiency, activity, actErr, mda, conc, mdc));
strBuild.append(System.lineSeparator());
} else {
strBuild.append(rowFormat(title5, key, halflifeValue, "NULL", "NULL", efficiency, activity, actErr, mda, conc, mdc));
strBuild.append(System.lineSeparator());
} }
} }
strBuild.append(System.lineSeparator()); strBuild.append(System.lineSeparator());

View File

@ -3,7 +3,6 @@ package org.jeecg.modules.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil; import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.ReUtil; import cn.hutool.core.util.ReUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
@ -13,7 +12,6 @@ import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.cache.Cache; import com.google.common.cache.Cache;
import com.google.common.collect.Lists;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.net.ftp.FTP; import org.apache.commons.net.ftp.FTP;
@ -35,7 +33,7 @@ import org.jeecg.modules.base.dto.ROIChannelsDto;
import org.jeecg.modules.base.dto.ROIResultsDto; import org.jeecg.modules.base.dto.ROIResultsDto;
import org.jeecg.modules.base.dto.XeResultsDto; import org.jeecg.modules.base.dto.XeResultsDto;
import org.jeecg.modules.base.entity.configuration.GardsDetectors; import org.jeecg.modules.base.entity.configuration.GardsDetectors;
import org.jeecg.modules.base.entity.original.*; import org.jeecg.modules.base.entity.original.GardsSampleData;
import org.jeecg.modules.base.entity.rnman.*; import org.jeecg.modules.base.entity.rnman.*;
import org.jeecg.modules.base.enums.*; import org.jeecg.modules.base.enums.*;
import org.jeecg.modules.entity.*; import org.jeecg.modules.entity.*;
@ -58,13 +56,10 @@ import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.*; import java.io.*;
import java.net.URLEncoder;
import java.sql.*;
import java.text.ParseException; import java.text.ParseException;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.Date;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -393,6 +388,26 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
phdFileUtil.getLightColor(sampleMap,gasBgMap,detBgMap,qcMap); phdFileUtil.getLightColor(sampleMap,gasBgMap,detBgMap,qcMap);
String sampleFileName = String.valueOf(sampleMap.get("fileName")); String sampleFileName = String.valueOf(sampleMap.get("fileName"));
Cache<String, Map<String, Object>> cache = betaCache.getBetaCache(); Cache<String, Map<String, Object>> cache = betaCache.getBetaCache();
Map<String, Object> dataCache = cache.getIfPresent(sampleFileName + "-" + userName + "-data");
if (CollectionUtils.isNotEmpty(dataCache)) {
SpectrumData sample = (SpectrumData) dataCache.get("sample");
if (Objects.nonNull(sample)) {
sampleMap.put("spectrumData", sample);
}
SpectrumData gas = (SpectrumData) dataCache.get("gas");
if (Objects.nonNull(gas)) {
gasBgMap.put("spectrumData", gas);
}
SpectrumData det = (SpectrumData) dataCache.get("det");
if (Objects.nonNull(det)) {
detBgMap.put("spectrumData", det);
}
SpectrumData qc = (SpectrumData) dataCache.get("qc");
if (Objects.nonNull(qc)) {
qcMap.put("spectrumData", qc);
}
}
Map<String, Object> xeDataMap = cache.getIfPresent(sampleFileName + "-" + userName + "-xeData"); Map<String, Object> xeDataMap = cache.getIfPresent(sampleFileName + "-" + userName + "-xeData");
if (CollectionUtils.isNotEmpty(xeDataMap)) { if (CollectionUtils.isNotEmpty(xeDataMap)) {
xeResultsSpectrumList = (List<GardsXeResultsSpectrum>) xeDataMap.get("XeData"); xeResultsSpectrumList = (List<GardsXeResultsSpectrum>) xeDataMap.get("XeData");
@ -429,9 +444,9 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
xeData.setColor("green"); xeData.setColor("green");
xeData.setNidFlag(1); xeData.setNidFlag(1);
} }
xeData.setMdc(Double.valueOf(String.format("%."+(6 - String.valueOf(xeData.getMdc()).substring(0, String.valueOf(xeData.getMdc()).lastIndexOf(StringPool.DOT)).length())+"f", xeData.getMdc()))); xeData.setMdc(Double.valueOf(String.format("%."+(6 - String.valueOf(Math.abs(xeData.getMdc())).substring(0, String.valueOf(Math.abs(xeData.getMdc())).lastIndexOf(StringPool.DOT)).length())+"f", xeData.getMdc())));
xeData.setConc(Double.valueOf(String.format("%."+(6 - String.valueOf(xeData.getConc()).substring(0, String.valueOf(xeData.getConc()).lastIndexOf(StringPool.DOT)).length())+"f", xeData.getConc()))); xeData.setConc(Double.valueOf(String.format("%."+(6 - String.valueOf(Math.abs(xeData.getConc())).substring(0, String.valueOf(Math.abs(xeData.getConc())).lastIndexOf(StringPool.DOT)).length())+"f", xeData.getConc())));
xeData.setConcErr(Double.valueOf(String.format("%."+((6 - String.valueOf(xeData.getConcErr()).substring(0, String.valueOf(xeData.getConcErr()).lastIndexOf(StringPool.DOT)).length()))+"f", xeData.getConcErr()))); xeData.setConcErr(Double.valueOf(String.format("%."+((6 - String.valueOf(Math.abs(xeData.getConcErr())).substring(0, String.valueOf(Math.abs(xeData.getConcErr())).lastIndexOf(StringPool.DOT)).length()))+"f", xeData.getConcErr())));
} }
} }
resultMap.put("XeData", xeResultsSpectrumList); resultMap.put("XeData", xeResultsSpectrumList);
@ -490,6 +505,25 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
phdFileUtil.getLightColor(sampleMap,gasBgMap,detBgMap,qcMap); phdFileUtil.getLightColor(sampleMap,gasBgMap,detBgMap,qcMap);
//获取本地缓存信息 //获取本地缓存信息
Cache<String, Map<String, Object>> cache = betaCache.getBetaCache(); Cache<String, Map<String, Object>> cache = betaCache.getBetaCache();
Map<String, Object> dataCache = cache.getIfPresent(sampleFileName + "-" + userName + "-data");
if (CollectionUtils.isNotEmpty(dataCache)) {
SpectrumData sample = (SpectrumData) dataCache.get("sample");
if (Objects.nonNull(sample)) {
sampleMap.put("spectrumData", sample);
}
SpectrumData gas = (SpectrumData) dataCache.get("gas");
if (Objects.nonNull(gas)) {
gasBgMap.put("spectrumData", gas);
}
SpectrumData det = (SpectrumData) dataCache.get("det");
if (Objects.nonNull(det)) {
detBgMap.put("spectrumData", det);
}
SpectrumData qc = (SpectrumData) dataCache.get("qc");
if (Objects.nonNull(qc)) {
qcMap.put("spectrumData", qc);
}
}
//根据key获取缓存数据 //根据key获取缓存数据
Map<String, Object> xeDataMap = cache.getIfPresent(sampleFileName + "-" + userName + "-xeData"); Map<String, Object> xeDataMap = cache.getIfPresent(sampleFileName + "-" + userName + "-xeData");
//如果缓存数据存在 则将缓存数据取出使用 //如果缓存数据存在 则将缓存数据取出使用
@ -516,9 +550,9 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
xeData.setColor("green"); xeData.setColor("green");
xeData.setNidFlag(1); xeData.setNidFlag(1);
} }
xeData.setMdc(Double.valueOf(String.format("%.6f", xeData.getMdc()))); xeData.setMdc(Double.valueOf(String.format("%."+(6 - String.valueOf(Math.abs(xeData.getMdc())).substring(0, String.valueOf(Math.abs(xeData.getMdc())).lastIndexOf(StringPool.DOT)).length())+"f", xeData.getMdc())));
xeData.setConc(Double.valueOf(String.format("%.6f", xeData.getConc()))); xeData.setConc(Double.valueOf(String.format("%."+(6 - String.valueOf(Math.abs(xeData.getConc())).substring(0, String.valueOf(Math.abs(xeData.getConc())).lastIndexOf(StringPool.DOT)).length())+"f", xeData.getConc())));
xeData.setConcErr(Double.valueOf(String.format("%.6f", xeData.getConcErr()))); xeData.setConcErr(Double.valueOf(String.format("%."+((6 - String.valueOf(Math.abs(xeData.getConcErr())).substring(0, String.valueOf(Math.abs(xeData.getConcErr())).lastIndexOf(StringPool.DOT)).length()))+"f", xeData.getConcErr())));
} }
} }
if (CollectionUtils.isNotEmpty(sampleBoundary)) { if (CollectionUtils.isNotEmpty(sampleBoundary)) {
@ -562,6 +596,9 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
if (Objects.nonNull(inputStream)){ if (Objects.nonNull(inputStream)){
//声明一个临时文件 //声明一个临时文件
file = File.createTempFile("betaGamma", null); file = File.createTempFile("betaGamma", null);
if (Objects.isNull(file)) {
throw new RuntimeException("ftp file can't find!");
}
//将ftp文件的输入流复制给临时文件 //将ftp文件的输入流复制给临时文件
FileUtils.copyInputStreamToFile(inputStream, file); FileUtils.copyInputStreamToFile(inputStream, file);
map = phdFileUtil.getSourceData(file.getAbsolutePath(), sampleId, status); map = phdFileUtil.getSourceData(file.getAbsolutePath(), sampleId, status);
@ -599,6 +636,8 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
betaCache.deleteBetaCache(analyseKey); betaCache.deleteBetaCache(analyseKey);
String xeKey = sampleFileName + "-" + userName + "-xeData"; String xeKey = sampleFileName + "-" + userName + "-xeData";
betaCache.deleteBetaCache(xeKey); betaCache.deleteBetaCache(xeKey);
String dataKey = sampleFileName + "-" + userName + "-data";
betaCache.deleteBetaCache(dataKey);
} }
@Override @Override
@ -3082,9 +3121,9 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
xeData.setColor("green"); xeData.setColor("green");
xeData.setNidFlag(1); xeData.setNidFlag(1);
} }
xeData.setMdc(Double.valueOf(String.format("%."+(6 - String.valueOf(xeData.getMdc()).substring(0, String.valueOf(xeData.getMdc()).lastIndexOf(StringPool.DOT)).length())+"f", xeData.getMdc()))); xeData.setMdc(Double.valueOf(String.format("%."+(6 - String.valueOf(Math.abs(xeData.getMdc())).substring(0, String.valueOf(Math.abs(xeData.getMdc())).lastIndexOf(StringPool.DOT)).length())+"f", xeData.getMdc())));
xeData.setConc(Double.valueOf(String.format("%."+(6 - String.valueOf(xeData.getConc()).substring(0, String.valueOf(xeData.getConc()).lastIndexOf(StringPool.DOT)).length())+"f", xeData.getConc()))); xeData.setConc(Double.valueOf(String.format("%."+(6 - String.valueOf(Math.abs(xeData.getConc())).substring(0, String.valueOf(Math.abs(xeData.getConc())).lastIndexOf(StringPool.DOT)).length())+"f", xeData.getConc())));
xeData.setConcErr(Double.valueOf(String.format("%."+((6 - String.valueOf(xeData.getConcErr()).substring(0, String.valueOf(xeData.getConcErr()).lastIndexOf(StringPool.DOT)).length()))+"f", xeData.getConcErr()))); xeData.setConcErr(Double.valueOf(String.format("%."+((6 - String.valueOf(Math.abs(xeData.getConcErr())).substring(0, String.valueOf(Math.abs(xeData.getConcErr())).lastIndexOf(StringPool.DOT)).length()))+"f", xeData.getConcErr())));
} }
} }
map.put("xeData", analyseResult); map.put("xeData", analyseResult);
@ -3110,14 +3149,14 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
xeData.setColor("green"); xeData.setColor("green");
xeData.setNidFlag(1); xeData.setNidFlag(1);
} }
xeData.setMdc(Double.valueOf(String.format("%."+(6 - String.valueOf(xeData.getMdc()).substring(0, String.valueOf(xeData.getMdc()).lastIndexOf(StringPool.DOT)).length())+"f", xeData.getMdc()))); xeData.setMdc(Double.valueOf(String.format("%."+(6 - String.valueOf(Math.abs(xeData.getMdc())).substring(0, String.valueOf(Math.abs(xeData.getMdc())).lastIndexOf(StringPool.DOT)).length())+"f", xeData.getMdc())));
xeData.setConc(Double.valueOf(String.format("%."+(6 - String.valueOf(xeData.getConc()).substring(0, String.valueOf(xeData.getConc()).lastIndexOf(StringPool.DOT)).length())+"f", xeData.getConc()))); xeData.setConc(Double.valueOf(String.format("%."+(6 - String.valueOf(Math.abs(xeData.getConc())).substring(0, String.valueOf(Math.abs(xeData.getConc())).lastIndexOf(StringPool.DOT)).length())+"f", xeData.getConc())));
xeData.setConcErr(Double.valueOf(String.format("%."+((6 - String.valueOf(xeData.getConcErr()).substring(0, String.valueOf(xeData.getConcErr()).lastIndexOf(StringPool.DOT)).length()))+"f", xeData.getConcErr()))); xeData.setConcErr(Double.valueOf(String.format("%."+((6 - String.valueOf(Math.abs(xeData.getConcErr())).substring(0, String.valueOf(Math.abs(xeData.getConcErr())).lastIndexOf(StringPool.DOT)).length()))+"f", xeData.getConcErr())));
} }
map.put("bProcessed", true);
map.put("savedAnalysisResult", true);
} }
map.put("XeData", analyseResult); map.put("XeData", analyseResult);
map.put("bProcessed", true);
map.put("savedAnalysisResult", true);
result.setSuccess(true); result.setSuccess(true);
result.setResult(map); result.setResult(map);
} }
@ -3191,14 +3230,14 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
xeData.setColor("green"); xeData.setColor("green");
xeData.setNidFlag(1); xeData.setNidFlag(1);
} }
xeData.setMdc(Double.valueOf(String.format("%."+(6 - String.valueOf(xeData.getMdc()).substring(0, String.valueOf(xeData.getMdc()).lastIndexOf(StringPool.DOT)).length())+"f", xeData.getMdc()))); xeData.setMdc(Double.valueOf(String.format("%."+(6 - String.valueOf(Math.abs(xeData.getMdc())).substring(0, String.valueOf(Math.abs(xeData.getMdc())).lastIndexOf(StringPool.DOT)).length())+"f", xeData.getMdc())));
xeData.setConc(Double.valueOf(String.format("%."+(6 - String.valueOf(xeData.getConc()).substring(0, String.valueOf(xeData.getConc()).lastIndexOf(StringPool.DOT)).length())+"f", xeData.getConc()))); xeData.setConc(Double.valueOf(String.format("%."+(6 - String.valueOf(Math.abs(xeData.getConc())).substring(0, String.valueOf(Math.abs(xeData.getConc())).lastIndexOf(StringPool.DOT)).length())+"f", xeData.getConc())));
xeData.setConcErr(Double.valueOf(String.format("%."+((6 - String.valueOf(xeData.getConcErr()).substring(0, String.valueOf(xeData.getConcErr()).lastIndexOf(StringPool.DOT)).length()))+"f", xeData.getConcErr()))); xeData.setConcErr(Double.valueOf(String.format("%."+((6 - String.valueOf(Math.abs(xeData.getConcErr())).substring(0, String.valueOf(Math.abs(xeData.getConcErr())).lastIndexOf(StringPool.DOT)).length()))+"f", xeData.getConcErr())));
} }
map.put("bProcessed", true);
map.put("savedAnalysisResult", true);
} }
map.put("XeData", analyseResultList); map.put("XeData", analyseResultList);
map.put("bProcessed", true);
map.put("savedAnalysisResult", true);
result.setSuccess(true); result.setSuccess(true);
result.setResult(map); result.setResult(map);
} }
@ -3323,99 +3362,105 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
gasTmp = phdFileUtil.analyzeFile(gasFilePath, gasFileName); gasTmp = phdFileUtil.analyzeFile(gasFilePath, gasFileName);
//获取det文件 //获取det文件
detTmp = phdFileUtil.analyzeFile(detFilePath, detFileName); detTmp = phdFileUtil.analyzeFile(detFilePath, detFileName);
//调用重新分析算法 获取算法结果 if (Objects.nonNull(sampleTmp) && Objects.nonNull(gasTmp) && Objects.nonNull(detTmp)) {
BgAnalyseResult analyseResult = EnergySpectrumHandler.bgReAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath(), spectrum_group.BgCalPara); //调用重新分析算法 获取算法结果
//生成分析操作日志 BgAnalyseResult analyseResult = EnergySpectrumHandler.bgReAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath(), spectrum_group.BgCalPara);
EnergySpectrumStruct sample = phdFileUtil.analyzeFileSourceData(sampleTmp); if (StringUtils.isNotBlank(analyseResult.error_log) && !analyseResult.error_log.equalsIgnoreCase("no error.")) {
EnergySpectrumStruct gas = phdFileUtil.analyzeFileSourceData(gasTmp); return Collections.EMPTY_LIST;
EnergySpectrumStruct det = phdFileUtil.analyzeFileSourceData(detTmp); } else {
String logName = sampleFileName.replace("PHD", "log"); //生成分析操作日志
phdFileUtil.OutPutRnLog(analyseResult, sample, gas, det, logName); EnergySpectrumStruct sample = phdFileUtil.analyzeFileSourceData(sampleTmp);
//存入分析用到的数据 EnergySpectrumStruct gas = phdFileUtil.analyzeFileSourceData(gasTmp);
map.put("reAnalyseParam", spectrum_group.BgCalPara); EnergySpectrumStruct det = phdFileUtil.analyzeFileSourceData(detTmp);
//存入计算后得到的xeData数据 String logName = sampleFileName.replace("PHD", "log");
GardsXeResultsSpectrum xe131m = new GardsXeResultsSpectrum(); phdFileUtil.OutPutRnLog(analyseResult, sample, gas, det, logName);
xe131m.setNuclideName(XeNuclideName.XE_131m.getType()); //存入分析用到的数据
xe131m.setConc(analyseResult.Xe131m_con); map.put("reAnalyseParam", spectrum_group.BgCalPara);
xe131m.setConcErr(analyseResult.Xe131m_uncer); //存入计算后得到的xeData数据
xe131m.setLc(analyseResult.LC_Xe131m); GardsXeResultsSpectrum xe131m = new GardsXeResultsSpectrum();
xe131m.setMdc(analyseResult.MDC_Xe131m); xe131m.setNuclideName(XeNuclideName.XE_131m.getType());
xe131m.setNidFlag(analyseResult.XE_131m_NID_FLAG); xe131m.setConc(analyseResult.Xe131m_con);
xeResultsSpectrumList.add(xe131m); xe131m.setConcErr(analyseResult.Xe131m_uncer);
GardsXeResultsSpectrum xe133 = new GardsXeResultsSpectrum(); xe131m.setLc(analyseResult.LC_Xe131m);
xe133.setNuclideName(XeNuclideName.XE_133.getType()); xe131m.setMdc(analyseResult.MDC_Xe131m);
xe133.setConc(analyseResult.Xe133_con); xe131m.setNidFlag(analyseResult.XE_131m_NID_FLAG);
xe133.setConcErr(analyseResult.Xe133_uncer); xeResultsSpectrumList.add(xe131m);
xe133.setLc(analyseResult.LC_Xe133); GardsXeResultsSpectrum xe133 = new GardsXeResultsSpectrum();
xe133.setMdc(analyseResult.MDC_Xe133); xe133.setNuclideName(XeNuclideName.XE_133.getType());
xe133.setNidFlag(analyseResult.XE_133_NID_FLAG); xe133.setConc(analyseResult.Xe133_con);
xeResultsSpectrumList.add(xe133); xe133.setConcErr(analyseResult.Xe133_uncer);
GardsXeResultsSpectrum xe133m = new GardsXeResultsSpectrum(); xe133.setLc(analyseResult.LC_Xe133);
xe133m.setNuclideName(XeNuclideName.XE_133m.getType()); xe133.setMdc(analyseResult.MDC_Xe133);
xe133m.setConc(analyseResult.Xe133m_con); xe133.setNidFlag(analyseResult.XE_133_NID_FLAG);
xe133m.setConcErr(analyseResult.Xe133m_uncer); xeResultsSpectrumList.add(xe133);
xe133m.setLc(analyseResult.LC_Xe133m); GardsXeResultsSpectrum xe133m = new GardsXeResultsSpectrum();
xe133m.setMdc(analyseResult.MDC_Xe133m); xe133m.setNuclideName(XeNuclideName.XE_133m.getType());
xe133m.setNidFlag(analyseResult.XE_133m_NID_FLAG); xe133m.setConc(analyseResult.Xe133m_con);
xeResultsSpectrumList.add(xe133m); xe133m.setConcErr(analyseResult.Xe133m_uncer);
GardsXeResultsSpectrum xe135 = new GardsXeResultsSpectrum(); xe133m.setLc(analyseResult.LC_Xe133m);
xe135.setNuclideName(XeNuclideName.XE_135.getType()); xe133m.setMdc(analyseResult.MDC_Xe133m);
xe135.setConc(analyseResult.Xe135_con); xe133m.setNidFlag(analyseResult.XE_133m_NID_FLAG);
xe135.setConcErr(analyseResult.Xe135_uncer); xeResultsSpectrumList.add(xe133m);
xe135.setLc(analyseResult.LC_Xe135); GardsXeResultsSpectrum xe135 = new GardsXeResultsSpectrum();
xe135.setMdc(analyseResult.MDC_Xe135); xe135.setNuclideName(XeNuclideName.XE_135.getType());
xe135.setNidFlag(analyseResult.XE_135_NID_FLAG); xe135.setConc(analyseResult.Xe135_con);
xeResultsSpectrumList.add(xe135); xe135.setConcErr(analyseResult.Xe135_uncer);
xeMap.put("XeData", xeResultsSpectrumList); xe135.setLc(analyseResult.LC_Xe135);
//新计算得到的边界值 xe135.setMdc(analyseResult.MDC_Xe135);
if (CollectionUtils.isNotEmpty(analyseResult.S_ROI_B_Boundary_start)) { xe135.setNidFlag(analyseResult.XE_135_NID_FLAG);
List<Boundary> boundaryList = new LinkedList<>(); xeResultsSpectrumList.add(xe135);
for (int i=0; i<analyseResult.S_ROI_B_Boundary_start.size(); i++) { xeMap.put("XeData", xeResultsSpectrumList);
Boundary boundary = new Boundary(); //新计算得到的边界值
boundary.setMinX(analyseResult.S_ROI_B_Boundary_start.get(i)); if (CollectionUtils.isNotEmpty(analyseResult.S_ROI_B_Boundary_start)) {
boundary.setMaxX(analyseResult.S_ROI_B_Boundary_stop.get(i)); List<Boundary> boundaryList = new LinkedList<>();
boundary.setMinY(analyseResult.S_ROI_G_Boundary_start.get(i)); for (int i=0; i<analyseResult.S_ROI_B_Boundary_start.size(); i++) {
boundary.setMaxY(analyseResult.S_ROI_G_Boundary_stop.get(i)); Boundary boundary = new Boundary();
boundaryList.add(boundary); boundary.setMinX(analyseResult.S_ROI_B_Boundary_start.get(i));
} boundary.setMaxX(analyseResult.S_ROI_B_Boundary_stop.get(i));
xeMap.put("SampleBoundary", boundaryList); boundary.setMinY(analyseResult.S_ROI_G_Boundary_start.get(i));
} boundary.setMaxY(analyseResult.S_ROI_G_Boundary_stop.get(i));
if (CollectionUtils.isNotEmpty(analyseResult.G_ROI_B_Boundary_start)) { boundaryList.add(boundary);
List<Boundary> boundaryList = new LinkedList<>(); }
for (int i=0; i<analyseResult.G_ROI_B_Boundary_start.size(); i++) { xeMap.put("SampleBoundary", boundaryList);
Boundary boundary = new Boundary();
boundary.setMinX(analyseResult.G_ROI_B_Boundary_start.get(i));
boundary.setMaxX(analyseResult.G_ROI_B_Boundary_stop.get(i));
boundary.setMinY(analyseResult.G_ROI_G_Boundary_start.get(i));
boundary.setMaxY(analyseResult.G_ROI_G_Boundary_stop.get(i));
boundaryList.add(boundary);
}
xeMap.put("GasBoundary", boundaryList);
}
if (CollectionUtils.isNotEmpty(analyseResult.D_ROI_B_Boundary_start)) {
List<Boundary> boundaryList = new LinkedList<>();
for (int i=0; i<analyseResult.D_ROI_B_Boundary_start.size(); i++) {
Boundary boundary = new Boundary();
boundary.setMinX(analyseResult.D_ROI_B_Boundary_start.get(i));
boundary.setMaxX(analyseResult.D_ROI_B_Boundary_stop.get(i));
boundary.setMinY(analyseResult.D_ROI_G_Boundary_start.get(i));
boundary.setMaxY(analyseResult.D_ROI_G_Boundary_stop.get(i));
boundaryList.add(boundary);
}
xeMap.put("DetBoundary", boundaryList);
}
if (analyseData.isQcData()) {
if (StringUtils.isNotBlank(qcFilePath)) {
EnergySpectrumStruct struct = phdFileUtil.analyzeFileSourceData(qcFilePath, qcFileName);
if (Objects.nonNull(struct)) {
phdFileUtil.CalQCBoundary(betaList, gammaList, betaFittingParaToUi, gammaFittingParaToUi, struct, xeMap);
} }
if (CollectionUtils.isNotEmpty(analyseResult.G_ROI_B_Boundary_start)) {
List<Boundary> boundaryList = new LinkedList<>();
for (int i=0; i<analyseResult.G_ROI_B_Boundary_start.size(); i++) {
Boundary boundary = new Boundary();
boundary.setMinX(analyseResult.G_ROI_B_Boundary_start.get(i));
boundary.setMaxX(analyseResult.G_ROI_B_Boundary_stop.get(i));
boundary.setMinY(analyseResult.G_ROI_G_Boundary_start.get(i));
boundary.setMaxY(analyseResult.G_ROI_G_Boundary_stop.get(i));
boundaryList.add(boundary);
}
xeMap.put("GasBoundary", boundaryList);
}
if (CollectionUtils.isNotEmpty(analyseResult.D_ROI_B_Boundary_start)) {
List<Boundary> boundaryList = new LinkedList<>();
for (int i=0; i<analyseResult.D_ROI_B_Boundary_start.size(); i++) {
Boundary boundary = new Boundary();
boundary.setMinX(analyseResult.D_ROI_B_Boundary_start.get(i));
boundary.setMaxX(analyseResult.D_ROI_B_Boundary_stop.get(i));
boundary.setMinY(analyseResult.D_ROI_G_Boundary_start.get(i));
boundary.setMaxY(analyseResult.D_ROI_G_Boundary_stop.get(i));
boundaryList.add(boundary);
}
xeMap.put("DetBoundary", boundaryList);
}
if (analyseData.isQcData()) {
if (StringUtils.isNotBlank(qcFilePath)) {
EnergySpectrumStruct struct = phdFileUtil.analyzeFileSourceData(qcFilePath, qcFileName);
if (Objects.nonNull(struct)) {
phdFileUtil.CalQCBoundary(betaList, gammaList, betaFittingParaToUi, gammaFittingParaToUi, struct, xeMap);
}
}
}
//将重新计算的参数以及重新计算后的xeData的数据缓存到本地缓存中
cache.put(sampleFileName + "-" + userName + "-reAnalyseParam", map);
cache.put(sampleFileName + "-" + userName + "-xeData", xeMap);
betaCache.setBetaCache(cache);
} }
} }
//将重新计算的参数以及重新计算后的xeData的数据缓存到本地缓存中
cache.put(sampleFileName + "-" + userName + "-reAnalyseParam", map);
cache.put(sampleFileName + "-" + userName + "-xeData", xeMap);
betaCache.setBetaCache(cache);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
@ -3539,100 +3584,106 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
sampleTmp = phdFileUtil.analyzeFile(sampleFilePath, sampleFileName); sampleTmp = phdFileUtil.analyzeFile(sampleFilePath, sampleFileName);
gasTmp = phdFileUtil.analyzeFile(gasFilePath, gasFileName); gasTmp = phdFileUtil.analyzeFile(gasFilePath, gasFileName);
detTmp = phdFileUtil.analyzeFile(detFilePath, detFileName); detTmp = phdFileUtil.analyzeFile(detFilePath, detFileName);
BgAnalyseResult analyseResult = EnergySpectrumHandler.bgReAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath(), spectrum_group.BgCalPara); if (Objects.nonNull(sampleTmp) && Objects.nonNull(gasTmp) && Objects.nonNull(detTmp)) {
//生成分析操作日志 BgAnalyseResult analyseResult = EnergySpectrumHandler.bgReAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath(), spectrum_group.BgCalPara);
EnergySpectrumStruct sample = phdFileUtil.analyzeFileSourceData(sampleTmp); if (StringUtils.isNotBlank(analyseResult.error_log) && !analyseResult.error_log.equalsIgnoreCase("no error.")) {
EnergySpectrumStruct gas = phdFileUtil.analyzeFileSourceData(gasTmp); analyseResultMap.put(sampleFileName, Collections.EMPTY_LIST);
EnergySpectrumStruct det = phdFileUtil.analyzeFileSourceData(detTmp); } else {
String logName = sampleFileName.replace("PHD", "log"); //生成分析操作日志
phdFileUtil.OutPutRnLog(analyseResult, sample, gas, det, logName); EnergySpectrumStruct sample = phdFileUtil.analyzeFileSourceData(sampleTmp);
//存入重新分析的参数 EnergySpectrumStruct gas = phdFileUtil.analyzeFileSourceData(gasTmp);
map.put("reAnalyseParam", spectrum_group.BgCalPara); EnergySpectrumStruct det = phdFileUtil.analyzeFileSourceData(detTmp);
//存入xeData数据 String logName = sampleFileName.replace("PHD", "log");
List<GardsXeResultsSpectrum> xeResultsSpectrumList = new LinkedList<>(); phdFileUtil.OutPutRnLog(analyseResult, sample, gas, det, logName);
GardsXeResultsSpectrum xe131m = new GardsXeResultsSpectrum(); //存入重新分析的参数
xe131m.setNuclideName(XeNuclideName.XE_131m.getType()); map.put("reAnalyseParam", spectrum_group.BgCalPara);
xe131m.setConc(analyseResult.Xe131m_con); //存入xeData数据
xe131m.setConcErr(analyseResult.Xe131m_uncer); List<GardsXeResultsSpectrum> xeResultsSpectrumList = new LinkedList<>();
xe131m.setLc(analyseResult.LC_Xe131m); GardsXeResultsSpectrum xe131m = new GardsXeResultsSpectrum();
xe131m.setMdc(analyseResult.MDC_Xe131m); xe131m.setNuclideName(XeNuclideName.XE_131m.getType());
xe131m.setNidFlag(analyseResult.XE_131m_NID_FLAG); xe131m.setConc(analyseResult.Xe131m_con);
xeResultsSpectrumList.add(xe131m); xe131m.setConcErr(analyseResult.Xe131m_uncer);
GardsXeResultsSpectrum xe133 = new GardsXeResultsSpectrum(); xe131m.setLc(analyseResult.LC_Xe131m);
xe133.setNuclideName(XeNuclideName.XE_133.getType()); xe131m.setMdc(analyseResult.MDC_Xe131m);
xe133.setConc(analyseResult.Xe133_con); xe131m.setNidFlag(analyseResult.XE_131m_NID_FLAG);
xe133.setConcErr(analyseResult.Xe133_uncer); xeResultsSpectrumList.add(xe131m);
xe133.setLc(analyseResult.LC_Xe133); GardsXeResultsSpectrum xe133 = new GardsXeResultsSpectrum();
xe133.setMdc(analyseResult.MDC_Xe133); xe133.setNuclideName(XeNuclideName.XE_133.getType());
xe133.setNidFlag(analyseResult.XE_133_NID_FLAG); xe133.setConc(analyseResult.Xe133_con);
xeResultsSpectrumList.add(xe133); xe133.setConcErr(analyseResult.Xe133_uncer);
GardsXeResultsSpectrum xe133m = new GardsXeResultsSpectrum(); xe133.setLc(analyseResult.LC_Xe133);
xe133m.setNuclideName(XeNuclideName.XE_133m.getType()); xe133.setMdc(analyseResult.MDC_Xe133);
xe133m.setConc(analyseResult.Xe133m_con); xe133.setNidFlag(analyseResult.XE_133_NID_FLAG);
xe133m.setConcErr(analyseResult.Xe133m_uncer); xeResultsSpectrumList.add(xe133);
xe133m.setLc(analyseResult.LC_Xe133m); GardsXeResultsSpectrum xe133m = new GardsXeResultsSpectrum();
xe133m.setMdc(analyseResult.MDC_Xe133m); xe133m.setNuclideName(XeNuclideName.XE_133m.getType());
xe133m.setNidFlag(analyseResult.XE_133m_NID_FLAG); xe133m.setConc(analyseResult.Xe133m_con);
xeResultsSpectrumList.add(xe133m); xe133m.setConcErr(analyseResult.Xe133m_uncer);
GardsXeResultsSpectrum xe135 = new GardsXeResultsSpectrum(); xe133m.setLc(analyseResult.LC_Xe133m);
xe135.setNuclideName(XeNuclideName.XE_135.getType()); xe133m.setMdc(analyseResult.MDC_Xe133m);
xe135.setConc(analyseResult.Xe135_con); xe133m.setNidFlag(analyseResult.XE_133m_NID_FLAG);
xe135.setConcErr(analyseResult.Xe135_uncer); xeResultsSpectrumList.add(xe133m);
xe135.setLc(analyseResult.LC_Xe135); GardsXeResultsSpectrum xe135 = new GardsXeResultsSpectrum();
xe135.setMdc(analyseResult.MDC_Xe135); xe135.setNuclideName(XeNuclideName.XE_135.getType());
xe135.setNidFlag(analyseResult.XE_135_NID_FLAG); xe135.setConc(analyseResult.Xe135_con);
xeResultsSpectrumList.add(xe135); xe135.setConcErr(analyseResult.Xe135_uncer);
xeMap.put("XeData", xeResultsSpectrumList); xe135.setLc(analyseResult.LC_Xe135);
//新计算得到的边界值 xe135.setMdc(analyseResult.MDC_Xe135);
if (CollectionUtils.isNotEmpty(analyseResult.S_ROI_B_Boundary_start)) { xe135.setNidFlag(analyseResult.XE_135_NID_FLAG);
List<Boundary> boundaryList = new LinkedList<>(); xeResultsSpectrumList.add(xe135);
for (int i=0; i<analyseResult.S_ROI_B_Boundary_start.size(); i++) { xeMap.put("XeData", xeResultsSpectrumList);
Boundary boundary = new Boundary(); //新计算得到的边界值
boundary.setMinX(analyseResult.S_ROI_B_Boundary_start.get(i)); if (CollectionUtils.isNotEmpty(analyseResult.S_ROI_B_Boundary_start)) {
boundary.setMaxX(analyseResult.S_ROI_B_Boundary_stop.get(i)); List<Boundary> boundaryList = new LinkedList<>();
boundary.setMinY(analyseResult.S_ROI_G_Boundary_start.get(i)); for (int i=0; i<analyseResult.S_ROI_B_Boundary_start.size(); i++) {
boundary.setMaxY(analyseResult.S_ROI_G_Boundary_stop.get(i)); Boundary boundary = new Boundary();
boundaryList.add(boundary); boundary.setMinX(analyseResult.S_ROI_B_Boundary_start.get(i));
} boundary.setMaxX(analyseResult.S_ROI_B_Boundary_stop.get(i));
xeMap.put("SampleBoundary", boundaryList); boundary.setMinY(analyseResult.S_ROI_G_Boundary_start.get(i));
} boundary.setMaxY(analyseResult.S_ROI_G_Boundary_stop.get(i));
if (CollectionUtils.isNotEmpty(analyseResult.G_ROI_B_Boundary_start)) { boundaryList.add(boundary);
List<Boundary> boundaryList = new LinkedList<>(); }
for (int i=0; i<analyseResult.G_ROI_B_Boundary_start.size(); i++) { xeMap.put("SampleBoundary", boundaryList);
Boundary boundary = new Boundary();
boundary.setMinX(analyseResult.G_ROI_B_Boundary_start.get(i));
boundary.setMaxX(analyseResult.G_ROI_B_Boundary_stop.get(i));
boundary.setMinY(analyseResult.G_ROI_G_Boundary_start.get(i));
boundary.setMaxY(analyseResult.G_ROI_G_Boundary_stop.get(i));
boundaryList.add(boundary);
}
xeMap.put("GasBoundary", boundaryList);
}
if (CollectionUtils.isNotEmpty(analyseResult.D_ROI_B_Boundary_start)) {
List<Boundary> boundaryList = new LinkedList<>();
for (int i=0; i<analyseResult.D_ROI_B_Boundary_start.size(); i++) {
Boundary boundary = new Boundary();
boundary.setMinX(analyseResult.D_ROI_B_Boundary_start.get(i));
boundary.setMaxX(analyseResult.D_ROI_B_Boundary_stop.get(i));
boundary.setMinY(analyseResult.D_ROI_G_Boundary_start.get(i));
boundary.setMaxY(analyseResult.D_ROI_G_Boundary_stop.get(i));
boundaryList.add(boundary);
}
xeMap.put("DetBoundary", boundaryList);
}
if (analyseData.isQcData()) {
if (StringUtils.isNotBlank(qcFilePath)) {
EnergySpectrumStruct struct = phdFileUtil.analyzeFileSourceData(qcFilePath, qcFileName);
if (Objects.nonNull(struct)) {
phdFileUtil.CalQCBoundary(betaList, gammaList, betaFittingParaToUi, gammaFittingParaToUi, struct, xeMap);
} }
if (CollectionUtils.isNotEmpty(analyseResult.G_ROI_B_Boundary_start)) {
List<Boundary> boundaryList = new LinkedList<>();
for (int i=0; i<analyseResult.G_ROI_B_Boundary_start.size(); i++) {
Boundary boundary = new Boundary();
boundary.setMinX(analyseResult.G_ROI_B_Boundary_start.get(i));
boundary.setMaxX(analyseResult.G_ROI_B_Boundary_stop.get(i));
boundary.setMinY(analyseResult.G_ROI_G_Boundary_start.get(i));
boundary.setMaxY(analyseResult.G_ROI_G_Boundary_stop.get(i));
boundaryList.add(boundary);
}
xeMap.put("GasBoundary", boundaryList);
}
if (CollectionUtils.isNotEmpty(analyseResult.D_ROI_B_Boundary_start)) {
List<Boundary> boundaryList = new LinkedList<>();
for (int i=0; i<analyseResult.D_ROI_B_Boundary_start.size(); i++) {
Boundary boundary = new Boundary();
boundary.setMinX(analyseResult.D_ROI_B_Boundary_start.get(i));
boundary.setMaxX(analyseResult.D_ROI_B_Boundary_stop.get(i));
boundary.setMinY(analyseResult.D_ROI_G_Boundary_start.get(i));
boundary.setMaxY(analyseResult.D_ROI_G_Boundary_stop.get(i));
boundaryList.add(boundary);
}
xeMap.put("DetBoundary", boundaryList);
}
if (analyseData.isQcData()) {
if (StringUtils.isNotBlank(qcFilePath)) {
EnergySpectrumStruct struct = phdFileUtil.analyzeFileSourceData(qcFilePath, qcFileName);
if (Objects.nonNull(struct)) {
phdFileUtil.CalQCBoundary(betaList, gammaList, betaFittingParaToUi, gammaFittingParaToUi, struct, xeMap);
}
}
}
//将重新计算的参数以及重新计算后的xeData的数据缓存到本地缓存中
cache.put(sampleFileName + "-" + userName + "-reAnalyseParam", map);
cache.put(sampleFileName + "-" + userName + "-xeData", xeMap);
betaCache.setBetaCache(cache);
analyseResultMap.put(sampleFileName, xeResultsSpectrumList);
} }
} }
//将重新计算的参数以及重新计算后的xeData的数据缓存到本地缓存中
cache.put(sampleFileName + "-" + userName + "-reAnalyseParam", map);
cache.put(sampleFileName + "-" + userName + "-xeData", xeMap);
betaCache.setBetaCache(cache);
analyseResultMap.put(sampleFileName, xeResultsSpectrumList);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -3732,40 +3783,45 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
BgCalPara = (BgCalibratePara) reAnalyseParam.get("reAnalyseParam"); BgCalPara = (BgCalibratePara) reAnalyseParam.get("reAnalyseParam");
} }
//调用分析方法 //调用分析方法
phdFileUtil.analyzeSpectrum(sampleTmp, gasTmp, detTmp, BgCalPara, map); boolean bRet = phdFileUtil.analyzeSpectrum(sampleTmp, gasTmp, detTmp, BgCalPara, map);
//分析qc文件信息并重新计算qc边界值 if (bRet) {
if (StringUtils.isNotBlank(qcPath)) { //分析qc文件信息并重新计算qc边界值
EnergySpectrumStruct struct = phdFileUtil.analyzeFileSourceData(qcPath, qcFileName); if (StringUtils.isNotBlank(qcPath)) {
if (Objects.nonNull(struct)) { EnergySpectrumStruct struct = phdFileUtil.analyzeFileSourceData(qcPath, qcFileName);
phdFileUtil.CalQCBoundary(betaList, gammaList, betaFittingParaToUi, gammaFittingParaToUi, struct, map); if (Objects.nonNull(struct)) {
} phdFileUtil.CalQCBoundary(betaList, gammaList, betaFittingParaToUi, gammaFittingParaToUi, struct, map);
}
if (CollectionUtils.isNotEmpty(map)) {
List<GardsXeResultsSpectrum> xeDataList = (List<GardsXeResultsSpectrum>) map.get("XeData");
if (CollectionUtils.isNotEmpty(xeDataList)){
for (GardsXeResultsSpectrum xeData:xeDataList) {
Double conc = xeData.getConc();
Double mdc = xeData.getMdc();
if (conc < 0){
xeData.setColor("red");
xeData.setNidFlag(0);
} else if (0<conc && conc < mdc) {
xeData.setColor("#ffcc30");
xeData.setNidFlag(0);
} else if (conc > mdc) {
xeData.setColor("green");
xeData.setNidFlag(1);
}
xeData.setMdc(Double.valueOf(String.format("%."+(6 - String.valueOf(xeData.getMdc()).substring(0, String.valueOf(xeData.getMdc()).lastIndexOf(StringPool.DOT)).length())+"f", xeData.getMdc())));
xeData.setConc(Double.valueOf(String.format("%."+(6 - String.valueOf(xeData.getConc()).substring(0, String.valueOf(xeData.getConc()).lastIndexOf(StringPool.DOT)).length())+"f", xeData.getConc())));
xeData.setConcErr(Double.valueOf(String.format("%."+((6 - String.valueOf(xeData.getConcErr()).substring(0, String.valueOf(xeData.getConcErr()).lastIndexOf(StringPool.DOT)).length()))+"f", xeData.getConcErr())));
} }
} }
//更新分析后的缓存信息 if (CollectionUtils.isNotEmpty(map)) {
cache.put(sampleFileName + "-" + userName + "-xeData", map); List<GardsXeResultsSpectrum> xeDataList = (List<GardsXeResultsSpectrum>) map.get("XeData");
betaCache.setBetaCache(cache); if (CollectionUtils.isNotEmpty(xeDataList)){
map.put("bProcessed", true); for (GardsXeResultsSpectrum xeData:xeDataList) {
map.put("savedAnalysisResult", true); Double conc = xeData.getConc();
Double mdc = xeData.getMdc();
if (conc < 0){
xeData.setColor("red");
xeData.setNidFlag(0);
} else if (0<conc && conc < mdc) {
xeData.setColor("#ffcc30");
xeData.setNidFlag(0);
} else if (conc > mdc) {
xeData.setColor("green");
xeData.setNidFlag(1);
}
xeData.setMdc(Double.valueOf(String.format("%."+(6 - String.valueOf(Math.abs(xeData.getMdc())).substring(0, String.valueOf(Math.abs(xeData.getMdc())).lastIndexOf(StringPool.DOT)).length())+"f", xeData.getMdc())));
xeData.setConc(Double.valueOf(String.format("%."+(6 - String.valueOf(Math.abs(xeData.getConc())).substring(0, String.valueOf(Math.abs(xeData.getConc())).lastIndexOf(StringPool.DOT)).length())+"f", xeData.getConc())));
xeData.setConcErr(Double.valueOf(String.format("%."+((6 - String.valueOf(Math.abs(xeData.getConcErr())).substring(0, String.valueOf(Math.abs(xeData.getConcErr())).lastIndexOf(StringPool.DOT)).length()))+"f", xeData.getConcErr())));
}
}
//更新分析后的缓存信息
cache.put(sampleFileName + "-" + userName + "-xeData", map);
betaCache.setBetaCache(cache);
map.put("bProcessed", true);
map.put("savedAnalysisResult", true);
}
} else {
map.clear();
map.put("XeData", Collections.EMPTY_LIST);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -3876,41 +3932,49 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
if (CollectionUtils.isNotEmpty(reAnalyseParam)) { if (CollectionUtils.isNotEmpty(reAnalyseParam)) {
BgCalPara = (BgCalibratePara) reAnalyseParam.get("reAnalyseParam"); BgCalPara = (BgCalibratePara) reAnalyseParam.get("reAnalyseParam");
} }
//调用分析方法 if(Objects.nonNull(sampleTmp) && Objects.nonNull(gasTmp) && Objects.nonNull(detTmp)) {
phdFileUtil.analyzeSpectrum(sampleTmp, gasTmp, detTmp, BgCalPara, map); //调用分析方法
//分析qc文件信息并重新计算qc边界值 boolean bRet = phdFileUtil.analyzeSpectrum(sampleTmp, gasTmp, detTmp, BgCalPara, map);
if (StringUtils.isNotBlank(qcPath)) { if (bRet) {
EnergySpectrumStruct struct = phdFileUtil.analyzeFileSourceData(qcPath, qcFileName); //分析qc文件信息并重新计算qc边界值
if (Objects.nonNull(struct)) { if (StringUtils.isNotBlank(qcPath)) {
phdFileUtil.CalQCBoundary(betaList, gammaList, betaFittingParaToUi, gammaFittingParaToUi, struct, map); EnergySpectrumStruct struct = phdFileUtil.analyzeFileSourceData(qcPath, qcFileName);
} if (Objects.nonNull(struct)) {
} phdFileUtil.CalQCBoundary(betaList, gammaList, betaFittingParaToUi, gammaFittingParaToUi, struct, map);
List<GardsXeResultsSpectrum> xeDataList = (List<GardsXeResultsSpectrum>) map.get("XeData"); }
if (CollectionUtils.isNotEmpty(xeDataList)){
for (GardsXeResultsSpectrum xeData:xeDataList) {
Double conc = xeData.getConc();
Double mdc = xeData.getMdc();
if (conc < 0){
xeData.setColor("red");
xeData.setNidFlag(0);
} else if (0<conc && conc < mdc) {
xeData.setColor("#ffcc30");
xeData.setNidFlag(0);
} else if (conc > mdc) {
xeData.setColor("green");
xeData.setNidFlag(1);
} }
xeData.setMdc(Double.valueOf(String.format("%."+(6 - String.valueOf(xeData.getMdc()).substring(0, String.valueOf(xeData.getMdc()).lastIndexOf(StringPool.DOT)).length())+"f", xeData.getMdc()))); List<GardsXeResultsSpectrum> xeDataList = (List<GardsXeResultsSpectrum>) map.get("XeData");
xeData.setConc(Double.valueOf(String.format("%."+(6 - String.valueOf(xeData.getConc()).substring(0, String.valueOf(xeData.getConc()).lastIndexOf(StringPool.DOT)).length())+"f", xeData.getConc()))); if (CollectionUtils.isNotEmpty(xeDataList)){
xeData.setConcErr(Double.valueOf(String.format("%."+((6 - String.valueOf(xeData.getConcErr()).substring(0, String.valueOf(xeData.getConcErr()).lastIndexOf(StringPool.DOT)).length()))+"f", xeData.getConcErr()))); for (GardsXeResultsSpectrum xeData:xeDataList) {
Double conc = xeData.getConc();
Double mdc = xeData.getMdc();
if (conc < 0){
xeData.setColor("red");
xeData.setNidFlag(0);
} else if (0<conc && conc < mdc) {
xeData.setColor("#ffcc30");
xeData.setNidFlag(0);
} else if (conc > mdc) {
xeData.setColor("green");
xeData.setNidFlag(1);
}
xeData.setMdc(Double.valueOf(String.format("%."+(6 - String.valueOf(Math.abs(xeData.getMdc())).substring(0, String.valueOf(Math.abs(xeData.getMdc())).lastIndexOf(StringPool.DOT)).length())+"f", xeData.getMdc())));
xeData.setConc(Double.valueOf(String.format("%."+(6 - String.valueOf(Math.abs(xeData.getConc())).substring(0, String.valueOf(Math.abs(xeData.getConc())).lastIndexOf(StringPool.DOT)).length())+"f", xeData.getConc())));
xeData.setConcErr(Double.valueOf(String.format("%."+((6 - String.valueOf(Math.abs(xeData.getConcErr())).substring(0, String.valueOf(Math.abs(xeData.getConcErr())).lastIndexOf(StringPool.DOT)).length()))+"f", xeData.getConcErr())));
}
}
//更新分析后的缓存信息
cache.put(sampleFileName + "-" + userName + "-xeData", map);
betaCache.setBetaCache(cache);
map.put("bProcessed", true);
map.put("savedAnalysisResult", true);
mapList.put(sampleFileName, map);
} else {
map.clear();
map.put("XeData", Collections.EMPTY_LIST);
mapList.put(sampleFileName, map);
} }
} }
//更新分析后的缓存信息
cache.put(sampleFileName + "-" + userName + "-xeData", map);
betaCache.setBetaCache(cache);
map.put("bProcessed", true);
map.put("savedAnalysisResult", true);
mapList.put(sampleFileName, map);
} }
} }
} catch (Exception e) { } catch (Exception e) {
@ -4018,8 +4082,18 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
@Transactional @Transactional
public Result saveToDB(BgDataAnlyseResultIn anlyseResultIn, HttpServletRequest request) { public Result saveToDB(BgDataAnlyseResultIn anlyseResultIn, HttpServletRequest request) {
Result result = new Result(); Result result = new Result();
Map<String, Object> map = new HashMap<>();
//根据请求体获取用户名 //根据请求体获取用户名
String userName = JwtUtil.getUserNameByToken(request); String userName = JwtUtil.getUserNameByToken(request);
Integer sampleId = null;
Integer gasId = null;
Integer detId = null;
Integer qcId = null;
//判断保存分析结果标识
if (!anlyseResultIn.isSavedAnalysisResult()) {
result.error500("Please first Analyse File!");
return result;
}
//用户名赋值到 分析员 //用户名赋值到 分析员
anlyseResultIn.setUserName(userName); anlyseResultIn.setUserName(userName);
//从本地缓存获取beta gamma的数组 //从本地缓存获取beta gamma的数组
@ -4074,19 +4148,19 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
String beginDate = DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss"); String beginDate = DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss");
//获取当前时间作为人工分析结束时间 //获取当前时间作为人工分析结束时间
String endDate = DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss"); String endDate = DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss");
//判断当前分析员是否有过排班任务 //根据台站名称获取台站id
Integer stationId = spectrumAnalysisMapper.getStationId(anlyseResultIn.getStationName()); Integer stationId = spectrumAnalysisMapper.getStationId(anlyseResultIn.getStationName());
//判断当前分析员是否有过当前台站的排班任务 //判断当前分析员当天是否有对应台站的排班任务
boolean bAnalysisResultWriteAuthority = userTaskUtil.CheckUserWriteAuthorityForStation(anlyseResultIn.getUserName(), stationId); List<String> userStation = userTaskUtil.findUserStation(userName);
if ( !bAnalysisResultWriteAuthority ){ boolean bAnalysisResultWriteAuthority = false;
result.error500("This user has no right to store the results of the analysis to the database."); if (userStation.contains(String.valueOf(stationId))) {
return result; bAnalysisResultWriteAuthority = true;
} }
//获取ROI Limit数据 //获取ROI Limit数据
// getROILimit(anlyseResultIn); // getROILimit(anlyseResultIn);
//根据sample文件名称模糊查询sampleId //根据sample文件名称模糊查询sampleId
if (StringUtils.isNotBlank(anlyseResultIn.getDbName())) { if (StringUtils.isNotBlank(anlyseResultIn.getDbName())) {
Integer sampleId = spectrumAnalysisMapper.getSampleIdLikeFileName(anlyseResultIn.getSampleFileName()); sampleId = spectrumAnalysisMapper.getSampleIdLikeFileName(anlyseResultIn.getSampleFileName());
Integer analysisID = null; Integer analysisID = null;
if (anlyseResultIn.getDbName().equals("auto")) { if (anlyseResultIn.getDbName().equals("auto")) {
anlyseResultIn.setDbName("RNAUTO"); anlyseResultIn.setDbName("RNAUTO");
@ -4120,16 +4194,22 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
anlyseResultIn.setDetFilePath(ftpUtil.getFtpRootPath() + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName); anlyseResultIn.setDetFilePath(ftpUtil.getFtpRootPath() + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName);
anlyseResultIn.setQcFilePath(ftpUtil.getFtpRootPath() + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName); anlyseResultIn.setQcFilePath(ftpUtil.getFtpRootPath() + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName);
} }
//处理数据 获取对应的channel/energy值
getChannelAndEnergy(anlyseResultIn, betaList, gammaList);
//分析文件内容
analyzePHDFile(anlyseResultIn, BgCalPara, betaFittingPara, gammaFittingPara);
//处理文件名称 //处理文件名称
String sampleFilePathName = phdFileUtil.NameStandardBy(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName()); String sampleFilePathName = phdFileUtil.NameStandardBy(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName());
String gasFilePathName = phdFileUtil.NameStandardBy(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName()); String gasFilePathName = phdFileUtil.NameStandardBy(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName());
String detFilePathName = phdFileUtil.NameStandardBy(anlyseResultIn.getDetFilePath(), anlyseResultIn.getDetFileName()); String detFilePathName = phdFileUtil.NameStandardBy(anlyseResultIn.getDetFilePath(), anlyseResultIn.getDetFileName());
String qcFilePathName = phdFileUtil.NameStandardBy(anlyseResultIn.getQcFilePath(), anlyseResultIn.getQcFileName()); String qcFilePathName = phdFileUtil.NameStandardBy(anlyseResultIn.getQcFilePath(), anlyseResultIn.getQcFileName());
//判断当前分析员是否有过历史分析当前文件
Integer isExist = spectrumAnalysisMapper.SampleIsExist(sampleFilePathName, anlyseResultIn.getUserName());
//如果当前分析员在当天没有排班任务 并且 没有历史分析过当前文件 则不允许进行保存操作
if ( !bAnalysisResultWriteAuthority && Objects.isNull(isExist) ){
result.error500("You have no permission to save results to DB!");
return result;
}
//处理数据 获取对应的channel/energy值
getChannelAndEnergy(anlyseResultIn, betaList, gammaList);
//分析文件内容
analyzePHDFile(anlyseResultIn, BgCalPara, betaFittingPara, gammaFittingPara);
//判断文件是否存储过 如果没有则解析文件并进行存储 //判断文件是否存储过 如果没有则解析文件并进行存储
if ( !OriginalDataStore(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName(), gasFilePathName, anlyseResultIn.getUserName()) ){ if ( !OriginalDataStore(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName(), gasFilePathName, anlyseResultIn.getUserName()) ){
result.error500("gasFile save failed"); result.error500("gasFile save failed");
@ -4144,17 +4224,16 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
result.error500("qcFile save failed"); result.error500("qcFile save failed");
return result; return result;
} }
qcId = spectrumAnalysisMapper.getSampleId(qcFilePathName);
} }
if ( !OriginalDataStore(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName(), sampleFilePathName, anlyseResultIn.getUserName()) ){ if ( !OriginalDataStore(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName(), sampleFilePathName, anlyseResultIn.getUserName()) ){
result.error500("sampleFile save failed"); result.error500("sampleFile save failed");
return result; return result;
} }
//判断当前分析员是否有过历史分析当前文件
Integer isExist = spectrumAnalysisMapper.SampleIsExist(sampleFilePathName, anlyseResultIn.getUserName());
//根据文件名称查询对应的sampleId--- sampleFile gasFile detFile //根据文件名称查询对应的sampleId--- sampleFile gasFile detFile
Integer sampleId = spectrumAnalysisMapper.getSampleId(sampleFilePathName); sampleId = spectrumAnalysisMapper.getSampleId(sampleFilePathName);
Integer gasId = spectrumAnalysisMapper.getSampleId(gasFilePathName); gasId = spectrumAnalysisMapper.getSampleId(gasFilePathName);
Integer detId = spectrumAnalysisMapper.getSampleId(detFilePathName); detId = spectrumAnalysisMapper.getSampleId(detFilePathName);
//如果分析过就修改原记录--GARDS_ANALYSES //如果分析过就修改原记录--GARDS_ANALYSES
GardsAnalysesSpectrum gardsAnalyses = new GardsAnalysesSpectrum(); GardsAnalysesSpectrum gardsAnalyses = new GardsAnalysesSpectrum();
gardsAnalyses.setSampleId(sampleId); gardsAnalyses.setSampleId(sampleId);
@ -4263,13 +4342,16 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
File sampleTmp = null; File sampleTmp = null;
File gasTmp = null; File gasTmp = null;
File detTmp = null; File detTmp = null;
File qcTmp = null;
try { try {
sampleTmp = phdFileUtil.analyzeFile(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName()); sampleTmp = phdFileUtil.analyzeFile(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName());
gasTmp = phdFileUtil.analyzeFile(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName()); gasTmp = phdFileUtil.analyzeFile(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName());
detTmp = phdFileUtil.analyzeFile(anlyseResultIn.getDetFilePath(), anlyseResultIn.getDetFileName()); detTmp = phdFileUtil.analyzeFile(anlyseResultIn.getDetFilePath(), anlyseResultIn.getDetFileName());
ftpUtil.saveFile(StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + sampleFilePathName.substring(0, sampleFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getSampleFileName(), new FileInputStream(sampleTmp)); qcTmp = phdFileUtil.analyzeFile(anlyseResultIn.getQcFilePath(), anlyseResultIn.getQcFileName());
ftpUtil.saveFile(StringPool.SLASH + 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 + sampleFilePathName.substring(0, sampleFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getSampleFileName(), new FileInputStream(sampleTmp));
ftpUtil.saveFile(StringPool.SLASH + 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 + gasFilePathName.substring(0, gasFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getGasFileName(), new FileInputStream(gasTmp));
ftpUtil.saveFile(StringPool.SLASH + 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 + qcFilePathName.substring(0, qcFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getQcFileName(), new FileInputStream(qcTmp));
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} finally { } finally {
@ -4277,7 +4359,26 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
gasTmp.delete(); gasTmp.delete();
detTmp.delete(); detTmp.delete();
} }
if (Objects.nonNull(sampleId)) {
SpectrumData sampleData = getSpectrumData(sampleId);
map.put("sample", sampleData);
}
if (Objects.nonNull(gasId)) {
SpectrumData gasData = getSpectrumData(gasId);
map.put("gas", gasData);
}
if (Objects.nonNull(detId)) {
SpectrumData detData = getSpectrumData(detId);
map.put("det", detData);
}
if (Objects.nonNull(qcId)) {
SpectrumData qcData = getSpectrumData(qcId);
map.put("qc", qcData);
}
cache.put(anlyseResultIn.getSampleFileName()+"-"+userName+"-data", map);
betaCache.setBetaCache(cache);
result.setSuccess(true); result.setSuccess(true);
result.setResult(map);
return result; return result;
} }
@ -5782,4 +5883,81 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
return roiResultsList; return roiResultsList;
} }
public SpectrumData getSpectrumData(Integer sampleId) {
//根据 sampleId获取sampleData的数据内容
GardsSampleDataSpectrum sampleData = spectrumAnalysisMapper.getSampleData(sampleId);
//获取文件存储路径
String inputFileName = sampleData.getInputFileName();
//拼接完整的ftp路径
String filePath = StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + inputFileName;
File file = ftpUtil.downloadFile(filePath, "betaGamma");
EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(file.getAbsolutePath());
SpectrumData spectrumData = new SpectrumData();
try {
//封装散点图下的基础数据信息
//Station Code
String stationCode = struct.site_code;
//Detector Code
String detectorCode = struct.detector_code;
//Data Type
String dataType = struct.data_type;
//Collection Start
Date CollectionStart = null;
if ( StringUtils.isNotBlank(struct.collection_start_date) && StringUtils.isNotBlank(struct.collection_start_time) ){
CollectionStart = DateUtils.parseDate(struct.collection_start_date + StringPool.SPACE + struct.collection_start_time);
}
//Collection Stop
Date CollectionStop = null;
if ( StringUtils.isNotBlank(struct.collection_stop_date) && StringUtils.isNotBlank(struct.collection_stop_time) ){
CollectionStop = DateUtils.parseDate(struct.collection_stop_date + StringPool.SPACE + struct.collection_stop_time);
}
//Collection Time
String CollectionTime = "";
if ( Objects.nonNull(CollectionStart) && Objects.nonNull(CollectionStop) ){
CollectionTime = String.format ("%.2f",Double.valueOf(CollectionStop.getTime()/1000 - CollectionStart.getTime()/ 1000));
}
//Acquisition Start
Date AcquisitionStart = null;
if ( StringUtils.isNotBlank(struct.collection_start_date) && StringUtils.isNotBlank(struct.collection_start_time) ){
AcquisitionStart = DateUtils.parseDate(struct.acquisition_start_date + StringPool.SPACE + struct.acquisition_start_time);
}
//Acq Real Time
double AcquisitionRealTime = struct.acquisition_real_time;
//Acq live Time
double AcquisitionLiveTime = struct.acquisition_live_time;
//Air Volume[m3]
double airVolume = struct.air_volume;
//Xe Volume[m3]
double xeVolume = struct.sample_volume_of_Xe;
//xeCollectionYield
double xeCollectionYield = struct.Xe_collection_yield;
//gasBkMeasurementId
String gasBkMeasurementId = struct.gas_bk_measurement_id;
//detectorBkMeasurementId
String detectorBkMeasurementId = struct.detector_bk_measurement_id;
//measurementId
String measurementId = struct.measurement_id;
spectrumData.setSampleId(sampleId);
spectrumData.setStatus(sampleData.getStatus());
spectrumData.setStationCode(stationCode);
spectrumData.setDetectorCode(detectorCode);
spectrumData.setDataType(dataType);
spectrumData.setCollectionStart(CollectionStart);
spectrumData.setCollectionStop(CollectionStop);
spectrumData.setCollectionTime(CollectionTime);
spectrumData.setAcquisitionStart(AcquisitionStart);
spectrumData.setAcquisitionRealTime(AcquisitionRealTime);
spectrumData.setAcquisitionLiveTime(AcquisitionLiveTime);
spectrumData.setAirVolume(airVolume);
spectrumData.setXeVolume(xeVolume);
spectrumData.setYield(xeCollectionYield);
spectrumData.setGasBkMeasurementId(gasBkMeasurementId);
spectrumData.setDetectorBkMeasurementId(detectorBkMeasurementId);
spectrumData.setMeasurementId(measurementId);
} catch (ParseException e) {
throw new RuntimeException(e);
}
return spectrumData;
}
} }