diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/abstracts/AbstractLogOrReport.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/abstracts/AbstractLogOrReport.java index a30176d5..3ee4e4af 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/abstracts/AbstractLogOrReport.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/abstracts/AbstractLogOrReport.java @@ -1,5 +1,13 @@ package org.jeecg.modules.base.abstracts; +import com.baomidou.mybatisplus.core.toolkit.StringPool; +import org.apache.commons.lang3.StringUtils; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + /** * 日志/报告格式化抽象类 */ @@ -39,4 +47,98 @@ public abstract class AbstractLogOrReport { return String.format(source,args); } + public String attributeFormat(String[] titles, String[] contents) { + //得到第一列的最大宽度 + int a_width=0; + for(int pos=0;posa_width) { + a_width = titles[pos].length(); + } + } + //得到第二列的最大宽度 + int c_width=0; + for(int pos=0;posc_width) { + c_width = contents[pos].length(); + } + } + //拼接最终结果 + StringBuilder rData = new StringBuilder(); + for(int pos=0;posa_width) { + a_width = titles[pos].length(); + } + } + //得到第二列的最大宽度 + int c_width=0; + for(int pos=0;posc_width) { + c_width = contents[pos].length(); + } + } + //拼接最终结果 + StringBuilder rData = new StringBuilder(); + for(int pos=0;pos> GetReportFixedWidth(String[] cells, String[] datas, int maxWidth) { + Map> map =new HashMap<>(); + List titles = new LinkedList<>(); + List contents = new LinkedList<>(); + //根据固定宽度切割过长的数据 + for (int i=0; i maxWidth) { + //计算需要切割成多少份 + double numParts = Math.ceil(data.length() / maxWidth); + for (int j=0; j0) { - strBuffer.append("Energy Calibration ["+middleData.calibration_pairs_E_Input+" ]\n"); - strBuffer.append("Function: "+middleData.calibration_E_functionTypeDef+"\n"); - strBuffer.append("E: "+middleData.calibration_E_functionDef+"\n"); - strBuffer.append("P: "+middleData.calibration_E_coeff_string+"\n"); - strBuffer.append("Err: "+middleData.calibration_E_uncoeff_string+"\n"); - strBuffer.append("Data: "+middleData.calibration_pairs_E_Input+"\n"); + String title = String.format("Energy Calibration [%s ]", middleData.calibration_pairs_E_Input); + String[] dataTitle = new String[]{title, "Function:", "E:", "P:", "Err:", "Data:"}; + String[] dataContent = new String[]{"", middleData.calibration_E_functionTypeDef, middleData.calibration_E_functionDef, middleData.calibration_E_coeff_string, middleData.calibration_E_uncoeff_string, middleData.calibration_pairs_E_Input}; + strBuffer.append(attributeGFormat(dataTitle, dataContent)); } + //文本日志内容第七部分数据 if(middleData.calibration_pairs_R_idCalPoint.size()>0) { - strBuffer.append("Resolution Calibration ["+middleData.calibration_pairs_R_Input+" ]\n"); - strBuffer.append("Function: "+middleData.calibration_R_functionTypeDef+"\n"); - strBuffer.append("E: "+middleData.calibration_R_functionDef+"\n"); - strBuffer.append("P: "+middleData.calibration_R_coeff_string+"\n"); - strBuffer.append("Err: "+middleData.calibration_R_uncoeff_string+"\n"); - strBuffer.append("Data: "+middleData.calibration_pairs_R_Input+"\n"); + String title = String.format("Resolution Calibration [%s ]", middleData.calibration_pairs_R_Input); + String[] dataTitle = new String[]{title, "Function:", "E:", "P:", "Err:", "Data:"}; + String[] dataContent = new String[]{"", middleData.calibration_R_functionTypeDef, middleData.calibration_R_functionDef, middleData.calibration_R_coeff_string, middleData.calibration_R_uncoeff_string, middleData.calibration_pairs_R_Input}; + strBuffer.append(attributeGFormat(dataTitle, dataContent)); } + //文本日志内容第八部分数据 if(middleData.calibration_pairs_EF_idCalPoint.size()>0) { - strBuffer.append("Efficiency Calibration ["+middleData.calibration_pairs_EF_Input+" ]\n"); - strBuffer.append("Function: "+middleData.calibration_EF_functionTypeDef+"\n"); - strBuffer.append("E: "+middleData.calibration_EF_functionDef+"\n"); - strBuffer.append("P: "+middleData.calibration_EF_coeff_string+"\n"); - strBuffer.append("Err: "+middleData.calibration_EF_uncoeff_string+"\n"); - strBuffer.append("Data: "+middleData.calibration_pairs_EF_Input+"\n"); + String title = String.format("Efficiency Calibration [%s ]", middleData.calibration_pairs_EF_Input); + String[] dataTitle = new String[]{title, "Function:", "E:", "P:", "Err:", "Data:"}; + String[] dataContent = new String[]{"", middleData.calibration_EF_functionTypeDef, middleData.calibration_EF_functionDef, middleData.calibration_EF_coeff_string, middleData.calibration_EF_uncoeff_string, middleData.calibration_pairs_EF_Input}; + strBuffer.append(attributeGFormat(dataTitle, dataContent)); } + //文本日志内容第九部分数据 if(middleData.calibration_pairs_T_idCalPoint.size()>0) { - strBuffer.append("Tot_efficiency Calibration ["+middleData.calibration_pairs_T_Input+" ]\n"); - strBuffer.append("Function: "+middleData.calibration_T_functionTypeDef+"\n"); - strBuffer.append("E: "+middleData.calibration_T_functionDef+"\n"); - strBuffer.append("P: "+middleData.calibration_T_coeff_string+"\n"); - strBuffer.append("Err: "+middleData.calibration_T_uncoeff_string+"\n"); - strBuffer.append("Data: "+middleData.calibration_pairs_T_Input+"\n"); + String title = String.format("Tot_efficiency Calibration [%s ]", middleData.calibration_pairs_T_Input); + String[] dataTitle = new String[]{title, "Function:", "E:", "P:", "Err:", "Data:"}; + String[] dataContent = new String[]{"", middleData.calibration_T_functionTypeDef, middleData.calibration_T_functionDef, middleData.calibration_T_coeff_string, middleData.calibration_T_uncoeff_string, middleData.calibration_pairs_T_Input}; + strBuffer.append(attributeGFormat(dataTitle, dataContent)); } - strBuffer.append("\n"); - strBuffer.append("........................................ Calibration Finished ........................................"); - strBuffer.append("\n"); - strBuffer.append("..................................... Starting Spectrum Analysis ....................................."); - strBuffer.append("\n"); - strBuffer.append("PROCESSING PARAMETERS.....\n"); - strBuffer.append("ECutAnalysis_Low : "+middleData.setting_specSetup.getECutAnalysis_Low()+"\n"); - strBuffer.append("ECutAnalysis_High : "+middleData.setting_specSetup.getECutAnalysis_High()+"\n"); - strBuffer.append("EnergyTolerance : "+middleData.setting_specSetup.getEnergyTolerance()+"\n"); - strBuffer.append("BaseImprovePSS : "+middleData.setting_specSetup.getBaseImprovePSS()+"\n"); - strBuffer.append("PSS_low : "+middleData.setting_specSetup.getPss_low()+"\n"); - strBuffer.append("k_back : "+middleData.setting_specSetup.getK_back()+"\n"); - strBuffer.append("k_alpha : "+middleData.setting_specSetup.getK_alpha()+"\n"); - strBuffer.append("k_beta : "+middleData.setting_specSetup.getK_beta()+"\n"); - strBuffer.append("RiskLevelK : "+middleData.setting_specSetup.getRiskLevelK()+"\n"); - strBuffer.append("refTime_act : "+middleData.setting_specSetup.getRefTime_act()+"\n"); - strBuffer.append("refTime_conc : "+middleData.setting_specSetup.getRefTime_conc()+"\n"); - strBuffer.append("\n"); - strBuffer.append("CALIBRATION PARAMETERS.....\n"); - strBuffer.append("\n"); - strBuffer.append("CalibrationPSS_low : "+middleData.setting_specSetup.getCalibrationPSS_low()+"\n"); - strBuffer.append("CalibrationPSS_high : "+middleData.setting_specSetup.getCalibrationPSS_high()+"\n"); - strBuffer.append("bUpdateCal : "+(middleData.setting_specSetup.isBUpdateCal()?"1":"0")+"\n"); - strBuffer.append("KeepCalPeakSearchPeaks : "+(middleData.setting_specSetup.isKeepCalPeakSearchPeaks()?"1":"0")+"\n"); - strBuffer.append("\n"); + //文本日志内容第十一部分头部信息 + String logHead11 = "%s Calibration Finished %s"; + strBuffer.append(titleFormat(logHead11, 40, StringPool.DOT, StringPool.DOT)); + //换行 + strBuffer.append(System.lineSeparator()); + //换行 + strBuffer.append(System.lineSeparator()); + //文本日志内容第十二部分头部信息 + String logHead12 = "%s Starting Spectrum Analysis %s"; + strBuffer.append(titleFormat(logHead12, 40, StringPool.DOT, StringPool.DOT)); + //换行 + strBuffer.append(System.lineSeparator()); + //换行 + strBuffer.append(System.lineSeparator()); + //文本内容第十三部分头部信息 + String logHead13 = "PROCESSING PARAMETERS%s"; + strBuffer.append(titleFormat(logHead13, 5, StringPool.DOT)); + //换行 + strBuffer.append(System.lineSeparator()); + //换行 + strBuffer.append(System.lineSeparator()); + //文本内容第十部分数据 + String[] dataTitles10 = new String[]{"ECutAnalysis_Low", "ECutAnalysis_High", "EnergyTolerance", "BaseImprovePSS", "PSS_low", "k_back", "k_alpha", "k_beta", "RiskLevelK", "refTime_act", "refTime_conc"}; + String[] dataContent10 = new String[]{String.valueOf(middleData.setting_specSetup.getECutAnalysis_Low()), String.valueOf(middleData.setting_specSetup.getECutAnalysis_High()), + String.valueOf(middleData.setting_specSetup.getEnergyTolerance()), String.valueOf(middleData.setting_specSetup.getBaseImprovePSS()), + String.valueOf(middleData.setting_specSetup.getPss_low()), String.valueOf(middleData.setting_specSetup.getK_back()), String.valueOf(middleData.setting_specSetup.getK_alpha()), + String.valueOf(middleData.setting_specSetup.getK_beta()), String.valueOf(middleData.setting_specSetup.getRiskLevelK()), + String.valueOf(middleData.setting_specSetup.getRefTime_act()), String.valueOf(middleData.setting_specSetup.getRefTime_conc())}; + strBuffer.append(attributeFormat(dataTitles10, dataContent10)); + //文本内容第十四部分头部信息 + String logHead14 = "CALIBRATION PARAMETERS%s"; + strBuffer.append(titleFormat(logHead14, 5, StringPool.DOT)); + //换行 + strBuffer.append(System.lineSeparator()); + //换行 + strBuffer.append(System.lineSeparator()); + //文本内容第十一部分数据 + String[] dataTitle11 = new String[]{"CalibrationPSS_low", "CalibrationPSS_high", "bUpdateCal", "KeepCalPeakSearchPeaks"}; + String[] dataContent11 = new String[]{String.valueOf(middleData.setting_specSetup.getCalibrationPSS_low()), String.valueOf(middleData.setting_specSetup.getCalibrationPSS_high()), (middleData.setting_specSetup.isBUpdateCal()?"1":"0"), (middleData.setting_specSetup.isKeepCalPeakSearchPeaks()?"1":"0")}; + strBuffer.append(attributeFormat(dataTitle11, dataContent11)); + //获取peak的数据 double peaksUsed = 0; for(int m=0;m1) - { + //判断核素信息内容长度是否大于1 + if(middleData.nucl_ided_Nuclidename.size()>1) { qsNuclidesName = qsNuclidesName+middleData.nucl_ided_Nuclidename.get(middleData.nucl_ided_Nuclidename.size()-1); } - strBuffer.append("Nuclide Identified.....\n"); - strBuffer.append("\n"); - strBuffer.append("Nuclides Identified : "+qsNuclidesName+"\n"); - strBuffer.append("Keyline Activities for Nuclides with defined Reference Line : \n"); - strBuffer.append("Activity Reference Time : "+middleData.sample_acquisiton_start+"\n"); - strBuffer.append("Concentration Reference Time : "+middleData.sample_collection_start+"\n"); - strBuffer.append("\n"); + //文本内容第十六部分头部信息 + String logHead16 = "Nuclide Identified%s"; + strBuffer.append(titleFormat(logHead16, 5, StringPool.DOT)); + //换行 + strBuffer.append(System.lineSeparator()); + //换行 + strBuffer.append(System.lineSeparator()); + //文本内容第十四部分数据 + String[] dataTitle14 = new String[]{"Nuclides Identified", "Keyline Activities for Nuclides with defined Reference Line", "Activity Reference Time", "Concentration Reference Time"}; + String[] dataContent14 = new String[]{qsNuclidesName, "", middleData.sample_acquisiton_start, middleData.sample_collection_start}; + strBuffer.append(attributeFormat(dataTitle14, dataContent14)); + //换行 + strBuffer.append(System.lineSeparator()); + //换行 + strBuffer.append(System.lineSeparator()); + //文本内容第十五部分数据 for (int i=0;i> reportMap1 = GetReportFixedWidth(cells1, datas1, 30); + List title1 = reportMap1.get("title"); + List content1 = reportMap1.get("content"); + for (int i=0; i< title1.size(); i++) { + String title = title1.get(i); + String content = content1.get(i); + strBuffer.append(String.format("%s:%-30s%s", title, StringPool.SPACE, content)); + //换行 + strBuffer.append(System.lineSeparator()); + } + //报告内容第二部分数据 + String[] cell2 = new String[]{" Analysis General Comments"}; + String[] datas2 = new String[]{middleData.NDC_Analysis_General_Comments}; + //根据固定宽度切割数据 + Map> reportMap2 = GetReportFixedWidth(cell2, datas2, 30); + List title2 = reportMap2.get("title"); + List content2 = reportMap2.get("content"); + for (int i=0; i< title2.size(); i++) { + String title = title2.get(i); + String content = content2.get(i); + strBuffer.append(String.format("%s:%-30s%s", title, StringPool.SPACE, content)); + //换行 + strBuffer.append(System.lineSeparator()); + } + //获取核素信息 String qsNuclidesName = ""; for(int m=0;m1) { qsNuclidesName = qsNuclidesName+middleData.nucl_ided_Nuclidename.get(middleData.nucl_ided_Nuclidename.size()-1); } - strBuffer.append("#ACTIVITY SUMMARY\n"); - strBuffer.append(" Nuclides Identified: "+qsNuclidesName+"\n"); - strBuffer.append(" Keyline Activities for Nuclides: \n"); - strBuffer.append(" with defined Reference Line: \n"); - strBuffer.append(" Activity Reference Time: "+middleData.sample_acquisiton_start+"\n"); - strBuffer.append(" Concentration Reference Time: "+middleData.sample_collection_start+"\n"); - strBuffer.append(" \n"); - strBuffer.append(" \n"); - strBuffer.append(" \n"); - strBuffer.append(" Nuclide Halflife(s) Activity(Bq) RelErr% MDA(Bq) Conc(uBq/m^3) MDC\n"); - for (int i=0; i> reportMap3 = GetReportFixedWidth(cells3, datas3, 30); + List title3 = reportMap3.get("title"); + List content3 = reportMap3.get("content"); + for (int i=0; i< title3.size(); i++) { + String title = title3.get(i); + String content = content3.get(i); + strBuffer.append(String.format("%s:%-30s%s", title, StringPool.SPACE, content)); + //换行 + strBuffer.append(System.lineSeparator()); } - strBuffer.append(" \n"); - strBuffer.append("#PEAK SEARCH RESULTS\n"); - strBuffer.append(StringPool.SPACE+middleData.peaks_idPeak.size()+" peaks reported\n"); + strBuffer.append(String.format("%s:%-30s%s", " Keyline Activities for Nuclides", StringPool.SPACE, "")); + //换行 + strBuffer.append(System.lineSeparator()); + strBuffer.append(String.format("%s:%-30s%s", " with defined Reference Line", StringPool.SPACE, "")); + //换行 + strBuffer.append(System.lineSeparator()); + strBuffer.append(String.format("%s:%-30s%s", " Activity Reference Time", StringPool.SPACE, middleData.sample_acquisiton_start)); + //换行 + strBuffer.append(System.lineSeparator()); + strBuffer.append(String.format("%s:%-30s%s", " Concentration Reference Time", StringPool.SPACE, middleData.sample_collection_start)); + //换行 + strBuffer.append(System.lineSeparator()); + //换行 + strBuffer.append(System.lineSeparator()); + //换行 + strBuffer.append(System.lineSeparator()); + String nuclideTitle = "%-41s%-33s%-15s%-14s%-15s%-21s%-15s"; + String[] nuclideData = new String[]{" Nuclide", "Halflife(s)", "Activity(Bq)", "RelErr%", "MDA(Bq)", "Conc(uBq/m^3)", "MDC"}; + strBuffer.append(rowFormat(nuclideTitle, nuclideData)); + strBuffer.append(System.lineSeparator()); + for (int i=0; i0) { - strBuffer.append("#Calibration\n"); - strBuffer.append(" Energy Calibration ["+middleData.calibration_pairs_E_Input+" ]\n"); - strBuffer.append(" Function: "+middleData.calibration_E_functionTypeDef+"\n"); - strBuffer.append(" E: "+middleData.calibration_E_functionDef+"\n"); - strBuffer.append(" P: "+middleData.calibration_E_coeff_string+"\n"); - strBuffer.append(" Err: "+middleData.calibration_E_uncoeff_string+"\n"); - strBuffer.append(" Data: "+middleData.calibration_pairs_E_Input+"\n"); - strBuffer.append("\n"); - strBuffer.append("\n"); - strBuffer.append("\n"); + strBuffer.append("#Calibration"); + //换行 + strBuffer.append(System.lineSeparator()); + strBuffer.append(" Energy Calibration ["+middleData.calibration_pairs_E_Input+" ]"); + //换行 + strBuffer.append(System.lineSeparator()); + strBuffer.append(String.format("%s:%-30s%s", " Function", StringPool.SPACE, middleData.calibration_E_functionTypeDef)); + //换行 + strBuffer.append(System.lineSeparator()); + strBuffer.append(String.format("%s:%-30s%s", " E", StringPool.SPACE, middleData.calibration_E_functionDef)); + //换行 + strBuffer.append(System.lineSeparator()); + String[] cells4 = new String[]{" P"}; + String[] datas4 = new String[]{middleData.calibration_E_coeff_string}; + //根据固定宽度切割数据 + Map> reportMap4 = GetReportFixedWidth(cells4, datas4, 30); + List title4 = reportMap4.get("title"); + List content4 = reportMap4.get("content"); + for (int i=0; i< title4.size(); i++) { + String title = title4.get(i); + String content = content4.get(i); + strBuffer.append(String.format("%s:%-30s%s", title, StringPool.SPACE, content)); + //换行 + strBuffer.append(System.lineSeparator()); + } + //换行 + strBuffer.append(System.lineSeparator()); + strBuffer.append(String.format("%s:%-30s%s", " Err", StringPool.SPACE, middleData.calibration_E_uncoeff_string)); + //换行 + strBuffer.append(System.lineSeparator()); + strBuffer.append(String.format("%s:%-30s%s", " Data", StringPool.SPACE, middleData.calibration_pairs_E_Input)); + //换行 + strBuffer.append(System.lineSeparator()); + //换行 + strBuffer.append(System.lineSeparator()); + //换行 + strBuffer.append(System.lineSeparator()); } if(middleData.calibration_pairs_R_idCalPoint.size()>0) { - strBuffer.append(" Resolution Calibration ["+middleData.calibration_pairs_R_Input+" ]\n"); - strBuffer.append(" Function: "+middleData.calibration_R_functionTypeDef+"\n"); - strBuffer.append(" E: "+middleData.calibration_R_functionDef+"\n"); - strBuffer.append(" P: "+middleData.calibration_R_coeff_string+"\n"); - strBuffer.append(" Err: "+middleData.calibration_R_uncoeff_string+"\n"); - strBuffer.append(" Data: "+middleData.calibration_pairs_R_Input+"\n"); - strBuffer.append("\n"); - strBuffer.append("\n"); - strBuffer.append("\n"); + strBuffer.append(" Resolution Calibration ["+middleData.calibration_pairs_R_Input+" ]"); + //换行 + strBuffer.append(System.lineSeparator()); + strBuffer.append(String.format("%s:%-30s%s", " Function", StringPool.SPACE, middleData.calibration_R_functionTypeDef)); + //换行 + strBuffer.append(System.lineSeparator()); + strBuffer.append(String.format("%s:%-30s%s", " E", StringPool.SPACE, middleData.calibration_R_functionDef)); + //换行 + strBuffer.append(System.lineSeparator()); + String[] cells5 = new String[]{" P"}; + String[] datas5 = new String[]{middleData.calibration_R_coeff_string}; + //根据固定宽度切割数据 + Map> reportMap5 = GetReportFixedWidth(cells5, datas5, 30); + List title5 = reportMap5.get("title"); + List content5 = reportMap5.get("content"); + for (int i=0; i< title5.size(); i++) { + String title = title5.get(i); + String content = content5.get(i); + strBuffer.append(String.format("%s:%-30s%s", title, StringPool.SPACE, content)); + //换行 + strBuffer.append(System.lineSeparator()); + } + strBuffer.append(String.format("%s:%-30s%s", " Err", StringPool.SPACE, middleData.calibration_R_uncoeff_string)); + //换行 + strBuffer.append(System.lineSeparator()); + strBuffer.append(String.format("%s:%-30s%s", " Data", StringPool.SPACE, middleData.calibration_pairs_R_Input)); + //换行 + strBuffer.append(System.lineSeparator()); + //换行 + strBuffer.append(System.lineSeparator()); } if(middleData.calibration_pairs_EF_idCalPoint.size()>0) { - strBuffer.append(" Efficiency Calibration ["+middleData.calibration_pairs_EF_Input+" ]\n"); - strBuffer.append(" Function: "+middleData.calibration_EF_functionTypeDef+"\n"); - strBuffer.append(" E: "+middleData.calibration_EF_functionDef+"\n"); - strBuffer.append(" P: "+middleData.calibration_EF_coeff_string+"\n"); - strBuffer.append(" Err: "+middleData.calibration_EF_uncoeff_string+"\n"); - strBuffer.append(" Data: "+middleData.calibration_pairs_EF_Input+"\n"); - strBuffer.append("\n"); - strBuffer.append("\n"); - strBuffer.append("\n"); + strBuffer.append(" Efficiency Calibration ["+middleData.calibration_pairs_EF_Input+" ]"); + //换行 + strBuffer.append(System.lineSeparator()); + strBuffer.append(String.format("%s:%-30s%s", " Function", StringPool.SPACE, middleData.calibration_EF_functionTypeDef)); + //换行 + strBuffer.append(System.lineSeparator()); + strBuffer.append(String.format("%s:%-30s%s", " E", StringPool.SPACE, middleData.calibration_EF_functionDef)); + //换行 + strBuffer.append(System.lineSeparator()); + String[] cells6 = new String[]{" P"}; + String[] datas6 = new String[]{middleData.calibration_EF_coeff_string}; + //根据固定宽度切割数据 + Map> reportMap6 = GetReportFixedWidth(cells6, datas6, 30); + List title6 = reportMap6.get("title"); + List content6 = reportMap6.get("content"); + for (int i=0; i< title6.size(); i++) { + String title = title6.get(i); + String content = content6.get(i); + strBuffer.append(String.format("%s:%-30s%s", title, StringPool.SPACE, content)); + //换行 + strBuffer.append(System.lineSeparator()); + } + strBuffer.append(String.format("%s:%-30s%s", " Err", StringPool.SPACE, middleData.calibration_EF_uncoeff_string)); + //换行 + strBuffer.append(System.lineSeparator()); + strBuffer.append(String.format("%s:%-30s%s", " Data", StringPool.SPACE, middleData.calibration_pairs_EF_Input)); + //换行 + strBuffer.append(System.lineSeparator()); + //换行 + strBuffer.append(System.lineSeparator()); } if(middleData.calibration_pairs_T_idCalPoint.size()>0) { - strBuffer.append(" Tot_efficiency Calibration ["+middleData.calibration_pairs_T_Input+" ]\n"); - strBuffer.append(" Function: "+middleData.calibration_T_functionTypeDef+"\n"); - strBuffer.append(" E: "+middleData.calibration_T_functionDef+"\n"); - strBuffer.append(" P: "+middleData.calibration_T_coeff_string+"\n"); - strBuffer.append(" Err: "+middleData.calibration_T_uncoeff_string+"\n"); - strBuffer.append(" Data: "+middleData.calibration_pairs_T_Input+"\n"); - strBuffer.append("\n"); - strBuffer.append("\n"); - strBuffer.append("\n"); + strBuffer.append(" Tot_efficiency Calibration ["+middleData.calibration_pairs_T_Input+" ]"); + //换行 + strBuffer.append(System.lineSeparator()); + strBuffer.append(String.format("%s:%-30s%s", " Function", StringPool.SPACE, middleData.calibration_T_functionTypeDef)); + //换行 + strBuffer.append(System.lineSeparator()); + strBuffer.append(String.format("%s:%-30s%s", " E", StringPool.SPACE, middleData.calibration_T_functionDef)); + //换行 + strBuffer.append(System.lineSeparator()); + String[] cells7 = new String[]{" P"}; + String[] datas7 = new String[]{middleData.calibration_T_coeff_string}; + //根据固定宽度切割数据 + Map> reportMap7 = GetReportFixedWidth(cells7, datas7, 30); + List title7 = reportMap7.get("title"); + List content7 = reportMap7.get("content"); + for (int i=0; i< title7.size(); i++) { + String title = title7.get(i); + String content = content7.get(i); + strBuffer.append(String.format("%s:%-30s%s", title, StringPool.SPACE, content)); + //换行 + strBuffer.append(System.lineSeparator()); + } + strBuffer.append(String.format("%s:%-30s%s", " Err", StringPool.SPACE, middleData.calibration_T_uncoeff_string)); + //换行 + strBuffer.append(System.lineSeparator()); + strBuffer.append(String.format("%s:%-30s%s", " Data", StringPool.SPACE, middleData.calibration_pairs_T_Input)); + //换行 + strBuffer.append(System.lineSeparator()); + //换行 + strBuffer.append(System.lineSeparator()); } - strBuffer.append("#DATA QUALITY FLAGS\n"); - strBuffer.append(" Name Pass/Fail Value Test\n"); + strBuffer.append("#DATA QUALITY FLAGS"); + //换行 + strBuffer.append(System.lineSeparator()); + String qualityTitle = "%-41s%-33s%-15s%-14s"; + strBuffer.append(rowFormat(qualityTitle, " Name", "Pass/Fail", "Value", "Test")); + //换行 + strBuffer.append(System.lineSeparator()); for (int i=0;i data_types = new LinkedList<>(); - data_types.add("SAMPLEPHD"); - data_types.add("SPHDF"); - data_types.add("SPHDP"); - data_types.add("GASBKPHD"); - data_types.add("BLANKPHD"); - data_types.add("DETBKPHD"); - data_types.add("QCPHD"); - data_types.add("CALIBPHD"); - - if(!data_types.contains(phd.getMsgInfo().getData_type())){ - return spectrum.toString(); - } - - // #Header - spectrum.append("#Header "+phd.getHeader().getDesignator()+"\r\n"); - spectrum.append(RightFill(phd.getHeader().getSite_code(), 5)+ - StringPool.SPACE+RightFill(phd.getHeader().getDetector_code(), 9)+ - StringPool.SPACE+RightFill(phd.getHeader().getSystem_type().toUpperCase(), 1)+ - StringPool.SPACE+RightFill(phd.getHeader().getSample_geometry(), 17)+ - StringPool.SPACE+RightFill(phd.getHeader().getSpectrum_quantity(), 4)+"\r\n"); - spectrum.append(phd.getHeader().getSample_ref_id() + "\r\n"); - spectrum.append(RightFill(phd.getHeader().getMeasurement_id(), 31)+StringPool.SPACE+RightFill(phd.getHeader().getDetector_bk_measurement_id(), 31)+StringPool.SPACE+phd.getHeader().getGas_bk_measurement_id()+"\r\n"); - spectrum.append(phd.getHeader().getTransmit_date()+StringPool.SPACE+phd.getHeader().getTransmit_time()+"\r\n"); - - // #Comment - if(StringUtils.isNotBlank(phd.getOriTotalCmt())) { - String comment = phd.getOriTotalCmt().replace("\r\n", "\n"); - comment.replace("\n", "\r\n"); - spectrum.append("#Comment\r\n"); - spectrum.append(comment + "\r\n"); - } - - // #Collection - spectrum.append("#Collection\r\n"); - spectrum.append(phd.getCollect().getCollection_start_date()+StringPool.SPACE+phd.getCollect().getCollection_start_time()+ - StringPool.SPACE+phd.getCollect().getCollection_stop_date()+StringPool.SPACE+phd.getCollect().getCollection_stop_time()+StringPool.SPACE+phd.getCollect().getAir_volume()+"\r\n"); - - // #Acquisition - spectrum.append("#Acquisition\r\n"); - spectrum.append(phd.getAcq().getAcquisition_start_date()+StringPool.SPACE+phd.getAcq().getAcquisition_start_time()+ - StringPool.SPACE+RightFill(String.format("%.2f", phd.getAcq().getAcquisition_real_time()), 14)+ - StringPool.SPACE+RightFill(String.format("%.2f", phd.getAcq().getAcquisition_live_time()), 14)+"\r\n"); - - // #Processing - if(phd.getProcess().getSample_volume_of_Xe() > 0) { - spectrum.append("#Processing\r\n"); - spectrum.append(RightFill(String.valueOf(phd.getProcess().getSample_volume_of_Xe()), 8)+StringPool.SPACE+RightFill(String.valueOf(phd.getProcess().getUncertainty_1()), 8)+"\r\n"+ - StringPool.SPACE+RightFill(String.valueOf(phd.getProcess().getXe_collection_yield()), 8)+StringPool.SPACE+RightFill(String.valueOf(phd.getProcess().getUncertainty_2()), 8)+"\r\n"+ - StringPool.SPACE+phd.getProcess().getArchive_bottle_id()+"\r\n"); - } - - // #Sample - if(phd.getSampleBlock().getDimension_1() > 0) { - spectrum.append("#Sample\r\n"); - spectrum.append(phd.getSampleBlock().getDimension_1()+" "+phd.getSampleBlock().getDimension_2()+"\r\n"); - } - - // Certificate - if(CollectionUtils.isNotEmpty(phd.getCertificate().getG_energy())) { - spectrum.append("#Certificate\r\n"); - spectrum.append(phd.getCertificate().getTotal_source_activity()+""+ phd.getCertificate().getAssay_date()+"" - + phd.getCertificate().getAssay_time()+""+phd.getCertificate().getUnits_activity() + "\r\n"); - - int fieldWidth = 12; - for(int i=0; i 0) { - spectrum.append("#TotalEff\r\n"); - TotaleffBlock g_totE = phd.getUsedTotEKD(); - for(int i=0; i= peakNum) i -= 1; - if(bFind) bFind = t_bFind; + if(bFind) { + bFind = t_bFind; + } return i; } @@ -4041,4 +4221,299 @@ public class GammaFileUtil { return file; } + public String makeUpSpectrum(PHDFile phd) { + StringBuilder spectrum = new StringBuilder(); + //PHD文本内容头部部分 + spectrum.append("BEGIN IMS2.0"); + //换行 + spectrum.append(System.lineSeparator()); + //PHD文本内容 MSGTYPE部分 + String msgType = "MSG_TYPE %s"; + spectrum.append(rowFormat(msgType, phd.getMsgInfo().getMsg_type())); + //换行 + spectrum.append(System.lineSeparator()); + //PHD文本内容 MSGID部分 + String msgId = "MSG_ID %s %s"; + spectrum.append(rowFormat(msgId, phd.getMsgInfo().getMsg_id(), phd.getMsgInfo().getMsg_src_code())); + //换行 + spectrum.append(System.lineSeparator()); + if(phd.getMsgInfo().isVerify_srid()) { + spectrum.append("REF_ID"); + //换行 + spectrum.append(System.lineSeparator()); + String refId = "%s %s %s %s"; + spectrum.append(rowFormat(refId, phd.getMsgInfo().getRef_id_str(), phd.getMsgInfo().getRef_src_code(), phd.getMsgInfo().getSeq_num(), phd.getMsgInfo().getTot_num())); + //换行 + spectrum.append(System.lineSeparator()); + String prodId = "PROD_ID %s %s"; + spectrum.append(rowFormat(prodId, phd.getMsgInfo().getProduct_id(), phd.getMsgInfo().getDelivery_id())); + //换行 + spectrum.append(System.lineSeparator()); + } + String dataType = "DATA_TYPE %s"; + spectrum.append(rowFormat(dataType, phd.getMsgInfo().getData_type())); + //换行 + spectrum.append(System.lineSeparator()); + + List data_types = new LinkedList<>(); + data_types.add("SAMPLEPHD"); + data_types.add("SPHDF"); + data_types.add("SPHDP"); + data_types.add("GASBKPHD"); + data_types.add("BLANKPHD"); + data_types.add("DETBKPHD"); + data_types.add("QCPHD"); + data_types.add("CALIBPHD"); + + if(!data_types.contains(phd.getMsgInfo().getData_type())) { + return spectrum.toString(); + } + + // #Header + String header = "#Header %s"; + spectrum.append(rowFormat(header, phd.getHeader().getDesignator())); + //换行 + spectrum.append(System.lineSeparator()); + String headerData = "%s %s %s %s %s"; + String siteCode = RightFill(phd.getHeader().getSite_code(), 5); + String detectorCode = RightFill(phd.getHeader().getDetector_code(), 9); + String systemType = RightFill(phd.getHeader().getSystem_type(), 1); + String sampleGeometry = RightFill(phd.getHeader().getSample_geometry(), 17); + String spectrumQuantity = RightFill(phd.getHeader().getSpectrum_quantity(), 4); + spectrum.append(rowFormat(headerData, siteCode, detectorCode, systemType, sampleGeometry, spectrumQuantity)); + //换行 + spectrum.append(System.lineSeparator()); + spectrum.append(phd.getHeader().getSample_ref_id()); + //换行 + spectrum.append(System.lineSeparator()); + String headerData2 = "%s %s %s"; + String measurement_id = RightFill(phd.getHeader().getMeasurement_id(), 31); + String detector_bk_measurement_id = RightFill(phd.getHeader().getDetector_bk_measurement_id(), 31); + spectrum.append(rowFormat(headerData2, measurement_id, detector_bk_measurement_id, phd.getHeader().getGas_bk_measurement_id())); + //换行 + spectrum.append(System.lineSeparator()); + String headerData3 = "%s %s"; + spectrum.append(rowFormat(headerData3, phd.getHeader().getTransmit_date(), phd.getHeader().getTransmit_time())); + //换行 + spectrum.append(System.lineSeparator()); + + // #Comment + if(StringUtils.isNotBlank(phd.getOriTotalCmt())) { + String comment = phd.getOriTotalCmt().replace("\r\n", System.lineSeparator()); + comment.replace(System.lineSeparator(), System.lineSeparator()); + spectrum.append("#Comment"); + spectrum.append(System.lineSeparator()); + spectrum.append(comment); + spectrum.append(System.lineSeparator()); + } + + // #Collection + spectrum.append("#Collection"); + spectrum.append(System.lineSeparator()); + String collection = "%s %s %s %s %s"; + spectrum.append(rowFormat(collection, phd.getCollect().getCollection_start_date(), phd.getCollect().getCollection_start_time(), phd.getCollect().getCollection_stop_date(), phd.getCollect().getCollection_stop_time(), String.valueOf(phd.getCollect().getAir_volume()))); + //换行 + spectrum.append(System.lineSeparator()); + + // #Acquisition + spectrum.append("#Acquisition"); + spectrum.append(System.lineSeparator()); + String acquisition = "%s %s %s %s"; + String acqRealTime = RightFill(String.format("%.2f", phd.getAcq().getAcquisition_real_time()), 14); + String acqLiveTime = RightFill(String.format("%.2f", phd.getAcq().getAcquisition_live_time()), 14); + spectrum.append(rowFormat(acquisition, phd.getAcq().getAcquisition_start_date(), phd.getAcq().getAcquisition_start_time(), acqRealTime, acqLiveTime)); + //换行 + spectrum.append(System.lineSeparator()); + + // #Processing + if(phd.getProcess().getSample_volume_of_Xe() > 0) { + spectrum.append("#Processing"); + spectrum.append(System.lineSeparator()); + String processing = "%s %s"; + String processing2 = "%s %s"; + String processing3 = "%s"; + String sample_volume_of_Xe = RightFill(String.valueOf(phd.getProcess().getSample_volume_of_Xe()), 8); + String uncertainty_1 = RightFill(String.valueOf(phd.getProcess().getUncertainty_1()), 8); + String xe_collection_yield = RightFill(String.valueOf(phd.getProcess().getXe_collection_yield()), 8); + String uncertainty_2 = RightFill(String.valueOf(phd.getProcess().getUncertainty_2()), 8); + String archive_bottle_id = RightFill(String.valueOf(phd.getProcess().getArchive_bottle_id()), 8); + spectrum.append(rowFormat(processing, sample_volume_of_Xe, uncertainty_1)); + //换行 + spectrum.append(System.lineSeparator()); + spectrum.append(rowFormat(processing2, xe_collection_yield, uncertainty_2)); + //换行 + spectrum.append(System.lineSeparator()); + spectrum.append(rowFormat(processing3, archive_bottle_id)); + //换行 + spectrum.append(System.lineSeparator()); + } + + // #Sample + if(phd.getSampleBlock().getDimension_1() > 0) { + spectrum.append("#Sample"); + //换行 + spectrum.append(System.lineSeparator()); + String sample = "%s %s"; + spectrum.append(rowFormat(sample, String.valueOf(phd.getSampleBlock().getDimension_1()), String.valueOf(phd.getSampleBlock().getDimension_2()))); + //换行 + spectrum.append(System.lineSeparator()); + } + + // Certificate + if(CollectionUtils.isNotEmpty(phd.getCertificate().getG_energy())) { + spectrum.append("#Certificate"); + //换行 + spectrum.append(System.lineSeparator()); + spectrum.append(phd.getCertificate().getTotal_source_activity()); + spectrum.append(phd.getCertificate().getAssay_date()); + spectrum.append(phd.getCertificate().getAssay_time()); + spectrum.append(phd.getCertificate().getUnits_activity()); + //换行 + spectrum.append(System.lineSeparator()); + String certificate = "%-12s %-12s %-12s %-12s %-12s %-12s %-12s %-12s %-12s %-12s"; + for(int i=0; i 0) { + spectrum.append("#TotalEff"); + //换行 + spectrum.append(System.lineSeparator()); + TotaleffBlock g_totE = phd.getUsedTotEKD(); + for(int i=0; i CreateShapeCP(BaseControls baseControls) { + List shapes = new LinkedList<>(); + for(int i=0; i allLines = FileUtils.readLines(file, ftpUtil.getEncoding()); @@ -299,6 +302,9 @@ public class PHDFileUtil { if (Objects.nonNull(iStream)){ iStream.close(); } + if (Objects.nonNull(file)) { + file.delete(); + } } catch (IOException e) { throw new RuntimeException(e); } @@ -455,6 +461,7 @@ public class PHDFileUtil { return map; } InputStream inputStream = null; + File file = null; try { //切换被动模式 ftpClient.enterLocalPassiveMode(); @@ -468,7 +475,7 @@ public class PHDFileUtil { inputStream = ftpClient.retrieveFileStream(sampleFileName); if (Objects.nonNull(inputStream)) { //声明一个临时文件 - File file = File.createTempFile("betaGamma", null); + file = File.createTempFile("betaGamma", null); //将ftp文件的输入流复制给临时文件 FileUtils.copyInputStreamToFile(inputStream, file); //加载sampleFile内容 @@ -501,7 +508,9 @@ public class PHDFileUtil { if (inputStream!=null){ inputStream.close(); } - + if (Objects.nonNull(file)) { + file.delete(); + } } catch (IOException e) { throw new RuntimeException(e); } @@ -514,76 +523,7 @@ public class PHDFileUtil { FTPClient ftpClient = ftpUtil.LoginFTP(); InputStream inputStream = null; File file = null; - try { - //被动模式 - ftpClient.enterLocalPassiveMode(); - //设置文件类型--二进制文件 - ftpClient.setFileType(FTP.BINARY_FILE_TYPE); - // - ftpClient.setControlEncoding("UTF-8"); - ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); - //切换文件路径 - ftpClient.changeWorkingDirectory(filePath); - inputStream = ftpClient.retrieveFileStream(fileName); - if (Objects.nonNull(inputStream)){ - file = File.createTempFile("betaGamma", null); - //将ftp文件的输入流复制给临时文件 - FileUtils.copyInputStreamToFile(inputStream, file); - } - } catch (IOException e) { - throw new RuntimeException(e); - } finally { - try { - if (Objects.nonNull(ftpClient)){ - ftpClient.disconnect(); - } - if (inputStream != null){ - inputStream.close(); - } - } catch (IOException e) { - throw new RuntimeException(e); - } - } - //加载动态库 - //System.loadLibrary("ReadPHDFile"); - EnergySpectrumStruct sourceData = EnergySpectrumHandler.getSourceData(file.getAbsolutePath()); - String systemType = sourceData.system_type; - String dataType = sourceData.data_type; StringBuffer path = new StringBuffer(); - if(systemType.contains("B")) { - path.append("Spectrum"); - path.append(StringPool.SLASH+"Xenon"); - path.append(StringPool.SLASH+"Sauna"); - } else if(systemType.contains("G")) { - path.append("Spectrum"); - path.append(StringPool.SLASH+"Xenon"); - path.append(StringPool.SLASH+"Spalax"); - } - if(dataType.contains("SAMPLEPHD")) { - path.append(StringPool.SLASH+"Samplephd"); - } else if(dataType.contains("DETBKPHD")) { - path.append(StringPool.SLASH+"Detbkphd"); - } else if(dataType.contains("GASBKPHD")) { - path.append(StringPool.SLASH+"Gasbkphd"); - } else if(dataType.contains("QCPHD")) { - path.append(StringPool.SLASH+"Qcphd"); - } - int pos = fileName.indexOf('-'); - if(-1 == pos) { - - } else if(fileName.length() >= pos+7) { - path.append(StringPool.SLASH+fileName.substring(pos+1,pos+5)); - path.append(StringPool.SLASH+fileName.substring(pos+5,pos+7)); - } - path.append(StringPool.SLASH+fileName); - return path.toString(); - } - - public BgBoundary CalBoundary(String filePath, String fileName){ - //连接ftp - FTPClient ftpClient = ftpUtil.LoginFTP(); - InputStream inputStream = null; - File file = null; try { //被动模式 ftpClient.enterLocalPassiveMode(); @@ -599,6 +539,35 @@ public class PHDFileUtil { file = File.createTempFile("betaGamma", null); //将ftp文件的输入流复制给临时文件 FileUtils.copyInputStreamToFile(inputStream, file); + EnergySpectrumStruct sourceData = EnergySpectrumHandler.getSourceData(file.getAbsolutePath()); + String systemType = sourceData.system_type; + String dataType = sourceData.data_type; + if(systemType.contains("B")) { + path.append("Spectrum"); + path.append(StringPool.SLASH+"Xenon"); + path.append(StringPool.SLASH+"Sauna"); + } else if(systemType.contains("G")) { + path.append("Spectrum"); + path.append(StringPool.SLASH+"Xenon"); + path.append(StringPool.SLASH+"Spalax"); + } + if(dataType.contains("SAMPLEPHD")) { + path.append(StringPool.SLASH+"Samplephd"); + } else if(dataType.contains("DETBKPHD")) { + path.append(StringPool.SLASH+"Detbkphd"); + } else if(dataType.contains("GASBKPHD")) { + path.append(StringPool.SLASH+"Gasbkphd"); + } else if(dataType.contains("QCPHD")) { + path.append(StringPool.SLASH+"Qcphd"); + } + int pos = fileName.indexOf('-'); + if(-1 == pos) { + + } else if(fileName.length() >= pos+7) { + path.append(StringPool.SLASH+fileName.substring(pos+1,pos+5)); + path.append(StringPool.SLASH+fileName.substring(pos+5,pos+7)); + } + path.append(StringPool.SLASH+fileName); } } catch (IOException e) { throw new RuntimeException(e); @@ -610,31 +579,14 @@ public class PHDFileUtil { if (inputStream != null){ inputStream.close(); } + if (Objects.nonNull(file)) { + file.delete(); + } } catch (IOException e) { throw new RuntimeException(e); } } - //加载dll工具库 - //System.loadLibrary("ReadPHDFile"); - EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(file.getAbsolutePath()); - //计算边界值 - List gCentroidChannel = struct.g_centroid_channel; - List gEnergy = struct.g_energy; - List bChannel = struct.b_channel; - List bElectronEnergy = struct.b_electron_energy; - CalcBgBoundaryParam calcBgBoundaryParam = new CalcBgBoundaryParam(); - calcBgBoundaryParam.g_e_cal = EnergySpectrumHandler.GetFileFittingPara(gEnergy, gCentroidChannel); - calcBgBoundaryParam.b_e_cal = EnergySpectrumHandler.GetFileFittingPara(bElectronEnergy, bChannel); - calcBgBoundaryParam.b_energy = struct.b_electron_energy; - calcBgBoundaryParam.b_channel = struct.b_channel; - calcBgBoundaryParam.g_channel = struct.g_centroid_channel; - calcBgBoundaryParam.g_energy = struct.g_energy; - calcBgBoundaryParam.ROI_B_start_x1 = struct.POI_B_x1; - calcBgBoundaryParam.ROI_B_stop_x2 = struct.POI_B_x2; - calcBgBoundaryParam.ROI_G_start_y1 = struct.POI_G_y1; - calcBgBoundaryParam.ROI_G_stop_y2 = struct.POI_G_y2; - BgBoundary bgBoundary = EnergySpectrumHandler.CalcBgBoundary(calcBgBoundaryParam); - return bgBoundary; + return path.toString(); } public List FileNameByStandardForm(String filePath, String sampleFileName){ @@ -744,42 +696,122 @@ public class PHDFileUtil { return file; } - public BgDataAnlyseResultIn analyzeSpectrum(File sampleTmp, File gasTmp, File detTmp, Map map) { - //加载dll工具库 - //System.loadLibrary("ReadPHDFile"); + public void analyzeSpectrum(File sampleTmp, File gasTmp, File detTmp, BgCalibratePara BgCalPara, Map map) { //调用动态库解析文件 - BgAnalyseResult bgAnalyseResult = EnergySpectrumHandler.bgAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath()); - BgDataAnlyseResultIn resultIn = new BgDataAnlyseResultIn(); - resultIn.setXe131m_con(bgAnalyseResult.Xe131m_con); - resultIn.setXe131m_uncer(bgAnalyseResult.Xe131m_uncer); - resultIn.setMdc_Xe131m(bgAnalyseResult.MDC_Xe131m); - resultIn.setLc_Xe131m(bgAnalyseResult.LC_Xe131m); - resultIn.setXe131mFlag(bgAnalyseResult.XE_131m_NID_FLAG); - resultIn.setXe133_con(bgAnalyseResult.Xe133_con); - resultIn.setXe133_uncer(bgAnalyseResult.Xe133_uncer); - resultIn.setMdc_Xe133(bgAnalyseResult.MDC_Xe133); - resultIn.setLc_Xe133(bgAnalyseResult.LC_Xe133); - resultIn.setXe133Flag(bgAnalyseResult.XE_133_NID_FLAG); - resultIn.setXe133m_con(bgAnalyseResult.Xe133m_con); - resultIn.setXe133m_uncer(bgAnalyseResult.Xe133m_uncer); - resultIn.setMdc_Xe133m(bgAnalyseResult.MDC_Xe133m); - resultIn.setLc_Xe133m(bgAnalyseResult.LC_Xe133m); - resultIn.setXe133mFlag(bgAnalyseResult.XE_133m_NID_FLAG); - resultIn.setXe135_con(bgAnalyseResult.Xe135_con); - resultIn.setXe135_uncer(bgAnalyseResult.Xe135_uncer); - resultIn.setMdc_Xe135(bgAnalyseResult.MDC_Xe135); - resultIn.setLc_Xe135(bgAnalyseResult.LC_Xe135); - resultIn.setXe135Flag(bgAnalyseResult.XE_135_NID_FLAG); - map.put("bProcessed", true); - return resultIn; + BgAnalyseResult analyseResult = null; + if (Objects.isNull(BgCalPara)) { + analyseResult = EnergySpectrumHandler.bgAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath()); + } else { + analyseResult = EnergySpectrumHandler.bgReAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath(), BgCalPara); + } + //需要返回到前端的XeData数据 + List xeResultsSpectrumList = new LinkedList<>(); + //存入计算后得到的xeData数据 + GardsXeResultsSpectrum xe131m = new GardsXeResultsSpectrum(); + xe131m.setNuclideName(XeNuclideName.XE_131m.getType()); + xe131m.setConc(analyseResult.Xe131m_con); + xe131m.setConcErr(analyseResult.Xe131m_uncer); + xe131m.setLc(analyseResult.LC_Xe131m); + xe131m.setMdc(analyseResult.MDC_Xe131m); + xe131m.setNidFlag(analyseResult.XE_131m_NID_FLAG); + xeResultsSpectrumList.add(xe131m); + GardsXeResultsSpectrum xe133 = new GardsXeResultsSpectrum(); + xe133.setNuclideName(XeNuclideName.XE_133.getType()); + xe133.setConc(analyseResult.Xe133_con); + xe133.setConcErr(analyseResult.Xe133_uncer); + xe133.setLc(analyseResult.LC_Xe133); + xe133.setMdc(analyseResult.MDC_Xe133); + xe133.setNidFlag(analyseResult.XE_133_NID_FLAG); + xeResultsSpectrumList.add(xe133); + GardsXeResultsSpectrum xe133m = new GardsXeResultsSpectrum(); + xe133m.setNuclideName(XeNuclideName.XE_133m.getType()); + xe133m.setConc(analyseResult.Xe133m_con); + xe133m.setConcErr(analyseResult.Xe133m_uncer); + xe133m.setLc(analyseResult.LC_Xe133m); + xe133m.setMdc(analyseResult.MDC_Xe133m); + xe133m.setNidFlag(analyseResult.XE_133m_NID_FLAG); + xeResultsSpectrumList.add(xe133m); + GardsXeResultsSpectrum xe135 = new GardsXeResultsSpectrum(); + xe135.setNuclideName(XeNuclideName.XE_135.getType()); + xe135.setConc(analyseResult.Xe135_con); + xe135.setConcErr(analyseResult.Xe135_uncer); + xe135.setLc(analyseResult.LC_Xe135); + xe135.setMdc(analyseResult.MDC_Xe135); + xe135.setNidFlag(analyseResult.XE_135_NID_FLAG); + xeResultsSpectrumList.add(xe135); + map.put("XeData", xeResultsSpectrumList); + //新计算得到的边界值 + if (CollectionUtils.isNotEmpty(analyseResult.S_ROI_B_Boundary_start)) { + List boundaryList = new LinkedList<>(); + for (int i=0; i boundaryList = new LinkedList<>(); + for (int i=0; i boundaryList = new LinkedList<>(); + for (int i=0; i> cache = betaCache.getBetaCache(); +// //根据qc文件名称-用户名-beta的方式获取beta的内容 +// Map betaMap = cache.getIfPresent(anlyseResultIn.getQcFileName() + "-" + userName + "-beta"); +// List betaList = new LinkedList<>(); +// List betaFittingPara = new LinkedList<>(); +// List betaFittingParaToUi = new LinkedList<>(); +// if (CollectionUtils.isNotEmpty(betaMap)) { +// betaList = (List)betaMap.get("Series"); +// betaFittingPara = (List) betaMap.get("fittingPara"); +// betaFittingParaToUi = (List) betaMap.get("fittingParaToUi"); +// } +// //根据qc文件名称-用户名-gamma的方式获取gamma的内容 +// Map gammaMap = cache.getIfPresent(anlyseResultIn.getQcFileName() + "-" + userName + "-gamma"); +// List gammaList = new LinkedList<>(); +// List gammaFittingPara = new LinkedList<>(); +// List gammaFittingParaToUi = new LinkedList<>(); +// if (CollectionUtils.isNotEmpty(gammaMap)) { +// gammaList = (List)gammaMap.get("Series"); +// gammaFittingPara = (List) gammaMap.get("fittingPara"); +// gammaFittingParaToUi = (List) gammaMap.get("fittingParaToUi"); +// } +// } + public EnergySpectrumStruct analyzeFileSourceData(String filePath, String fileName) { //加载dll工具库 //System.loadLibrary("ReadPHDFile"); EnergySpectrumStruct struct = new EnergySpectrumStruct(); FTPClient ftpClient = ftpUtil.LoginFTP(); InputStream inputStream = null; + File file = null; try { //切换被动模式 ftpClient.enterLocalPassiveMode(); @@ -791,7 +823,7 @@ public class PHDFileUtil { inputStream = ftpClient.retrieveFileStream(fileName); if (Objects.nonNull(inputStream)){ //声明一个临时文件 - File file = File.createTempFile("betaGamma", null); + file = File.createTempFile("betaGamma", null); //将ftp文件的输入流复制给临时文件 FileUtils.copyInputStreamToFile(inputStream, file); struct = EnergySpectrumHandler.getSourceData(file.getAbsolutePath()); @@ -806,6 +838,9 @@ public class PHDFileUtil { if (Objects.nonNull(inputStream)){ inputStream.close(); } + if (Objects.nonNull(file)) { + file.delete(); + } } catch (IOException e) { throw new RuntimeException(e); } @@ -945,4 +980,5 @@ public class PHDFileUtil { result.put("xeResults", xeResultsSpectrumList); return result; } + } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java index 9d83e607..7b6a7310 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java @@ -3,11 +3,7 @@ package org.jeecg.modules.controller; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.jeecg.common.api.vo.Result; -import org.jeecg.common.base.BaseMap; -import org.jeecg.common.constant.GlobalConstants; -import org.jeecg.common.constant.WebSocketHandlerConst; import org.jeecg.modules.base.bizVo.GammaRLR; -import org.jeecg.modules.base.entity.postgre.SysUser; import org.jeecg.modules.entity.vo.*; import org.jeecg.modules.feignclient.SystemClient; import org.jeecg.modules.service.IGammaService; @@ -40,18 +36,6 @@ public class GammaController { return gammaService.initValue(sampleId, dbName, fileName, request); } - @GetMapping("analysisProcess") - @ApiOperation(value = "分析进度", notes = "分析进度") - public void message(String message) { -// Result user = systemClient.getUserData(); - BaseMap params = new BaseMap(); - params.put(GlobalConstants.HANDLER_NAME, WebSocketHandlerConst.GAMMA_ANALYSIS_HANDLER); - params.put("userId", "message.userId"); - // userId, fileName, process - params.put("message", message); - // 通过 redis 订阅发送 websocket 消息 - redisTemplate.convertAndSend(GlobalConstants.REDIS_TOPIC_NAME, params);; - } @GetMapping("testFun") public Result testFun(String fileName,HttpServletRequest request){ @@ -110,7 +94,7 @@ public class GammaController { @PostMapping("acceptResults") @ApiOperation(value = "InteractiveTool页面Insert页面save", notes = "InteractiveTool页面Insert页面save") public Result acceptResults(@RequestBody AcceptInfo acceptInfo, HttpServletRequest request) { - return gammaService.acceptResults(acceptInfo.getFileName(), acceptInfo.isAccept(), acceptInfo.getOldPeak(), request); + return gammaService.acceptResults(acceptInfo.getFileName(), acceptInfo.isAccept(), acceptInfo.getOldPeak(), acceptInfo.getNewPeak(), acceptInfo.getFlag(), request); } @GetMapping("deletePeak") @@ -119,6 +103,11 @@ public class GammaController { return gammaService.deletePeak(fileName, curRow, request); } + @GetMapping("fitPeak") + public Result fitPeak(int left, int right, String fileName, HttpServletRequest request) { + return gammaService.fitPeak(left, right, fileName, request); + } + @GetMapping("getSelPosNuclide") @ApiOperation(value = "InteractiveTool页面选择channel加载对应核素信息接口", notes = "InteractiveTool页面选择channel加载对应核素信息接口") public Result getSelPosNuclide(Integer sampleId, String fileName, int channel, HttpServletRequest request) { @@ -179,6 +168,16 @@ public class GammaController { return gammaService.searchNuclide(sampleId, fileName, energy, tolerance, request); } + @PostMapping("replotBaseLine") + public Result replotBaseLine(@RequestBody BaseLineCtrls baseLineCtrls, HttpServletRequest request) { + return gammaService.replotBaseLine(baseLineCtrls, request); + } + + @PostMapping("acceptBaseLine") + public Result acceptBaseLine(@RequestBody BaseLineCtrls baseLineCtrls, HttpServletRequest request) { + return gammaService.acceptBaseLine(baseLineCtrls, request); + } + @GetMapping("ZeroTime") @ApiOperation(value = "Zero Time页面数据", notes = "Zero Time页面数据") public Result ZeroTime() { @@ -477,6 +476,7 @@ public class GammaController { } @GetMapping("saveToTxt") + @ApiOperation(value = "Save To TXT接口", notes = "Save To TXT接口") public void saveToTxt(String fileName, HttpServletRequest request, HttpServletResponse response) { gammaService.saveToTxt(fileName, request, response); } @@ -485,4 +485,10 @@ public class GammaController { public void saveToExcel(String fileName, HttpServletResponse response) { gammaService.saveToExcel(fileName, response); } + @GetMapping("saveToPHD") + @ApiOperation(value = "Save To PHD接口", notes = "Save To PHD接口") + public void saveToPHD(String fileName, HttpServletRequest request, HttpServletResponse response) { + gammaService.saveToPHD(fileName, request, response); + } + } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SpectrumAnalysesController.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SpectrumAnalysesController.java index 33c7305b..10abc7c9 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SpectrumAnalysesController.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SpectrumAnalysesController.java @@ -197,13 +197,14 @@ public class SpectrumAnalysesController { String sampleFileName = analyseBetaInfo.getSampleFileNames().get(0); String gasFileName = analyseBetaInfo.getGasFileNames().get(0); String detFileName = analyseBetaInfo.getDetFileNames().get(0); - return spectrumAnalysisService.analyseCurrentSpectrum(dbName, sampleId, sampleFileName, gasFileName, detFileName, request); + String qcFileName = analyseBetaInfo.getQcFileNames().get(0); + return spectrumAnalysisService.analyseCurrentSpectrum(dbName, sampleId, sampleFileName, gasFileName, detFileName, qcFileName, request); } @PostMapping("analyseAllSpectrum") @ApiOperation(value = "解析全部加载文件数据", notes = "解析全部加载文件数据") public Result analyseAllSpectrum(@RequestBody AnalyseBetaInfo analyseBetaInfo, HttpServletRequest request) { - return spectrumAnalysisService.analyseAllSpectrum(analyseBetaInfo.getDbNames(), analyseBetaInfo.getSampleIds(), analyseBetaInfo.getSampleFileNames(), analyseBetaInfo.getGasFileNames(), analyseBetaInfo.getDetFileNames(), request); + return spectrumAnalysisService.analyseAllSpectrum(analyseBetaInfo.getDbNames(), analyseBetaInfo.getSampleIds(), analyseBetaInfo.getSampleFileNames(), analyseBetaInfo.getGasFileNames(), analyseBetaInfo.getDetFileNames(), analyseBetaInfo.getQcFileNames(), analyseBetaInfo.getCurrentFileName(), request); } @PostMapping("saveToDB") diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/AcceptInfo.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/AcceptInfo.java index 11ba9d7e..0f25a9f0 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/AcceptInfo.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/AcceptInfo.java @@ -14,4 +14,8 @@ public class AcceptInfo implements Serializable { private List oldPeak; + private List newPeak; + + private String flag; + } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/AnalyseBetaInfo.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/AnalyseBetaInfo.java index 0a4cd16d..a44f3551 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/AnalyseBetaInfo.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/AnalyseBetaInfo.java @@ -18,4 +18,8 @@ public class AnalyseBetaInfo implements Serializable { private List detFileNames; + private List qcFileNames; + + private String currentFileName; + } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/BaseLineCtrls.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/BaseLineCtrls.java new file mode 100644 index 00000000..568830e5 --- /dev/null +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/BaseLineCtrls.java @@ -0,0 +1,10 @@ +package org.jeecg.modules.entity.vo; + +import lombok.Data; + +@Data +public class BaseLineCtrls extends BaseControls { + + private String fileName; + +} diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/BgDataAnlyseResultIn.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/BgDataAnlyseResultIn.java index df0bfa60..fa0b6baa 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/BgDataAnlyseResultIn.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/BgDataAnlyseResultIn.java @@ -8,6 +8,7 @@ import org.jeecg.modules.entity.GardsROIResultsSpectrum; import org.jeecg.modules.entity.GardsXeResultsSpectrum; import java.io.Serializable; +import java.util.LinkedList; import java.util.List; @Data @@ -263,4 +264,90 @@ public class BgDataAnlyseResultIn implements Serializable { List XeData; + public BgDataAnlyseResultIn() { + comment = ""; + bProcessed = false; + userName = ""; + stationName = ""; + dbName = ""; + sampleFilePath = ""; + sampleFileName = ""; + gasFilePath = ""; + gasFileName = ""; + detFilePath = ""; + detFileName = ""; + qcFilePath = ""; + qcFileName = ""; + bGammaEnergyValidSample = false; + bBetaEnergyValidSample = false; + bGammaEnergyValidGas = false; + bBetaEnergyValidGas = false; + bGammaEnergyValidDet = false; + bBetaEnergyValidDet = false; + checkSample = false; + checkGas = false; + checkDet = false; + g_channel_sample = new LinkedList<>(); + g_energy_sample = new LinkedList<>(); + b_channel_sample = new LinkedList<>(); + b_energy_sample = new LinkedList<>(); + g_channel_gas = new LinkedList<>(); + g_energy_gas = new LinkedList<>(); + b_channel_gas = new LinkedList<>(); + b_energy_gas = new LinkedList<>(); + g_channel_det = new LinkedList<>(); + g_energy_det = new LinkedList<>(); + b_channel_det = new LinkedList<>(); + b_energy_det = new LinkedList<>(); + param_a_c2e_g_sample = ""; + param_b_c2e_g_sample = ""; + param_c_c2e_g_sample = ""; + param_a_c2e_g_gas = ""; + param_b_c2e_g_gas = ""; + param_c_c2e_g_gas = ""; + param_a_c2e_g_det = ""; + param_b_c2e_g_det = ""; + param_c_c2e_g_det = ""; + param_a_c2e_b = ""; + param_b_c2e_b = ""; + param_c_c2e_b = ""; + mdc_Xe135 = 0.0; + mdc_Xe131m = 0.0; + mdc_Xe133m = 0.0; + mdc_Xe133 = 0.0; + xe135_con = 0.0; + xe135_uncer = 0.0; + xe131m_con = 0.0; + xe131m_uncer = 0.0; + xe133m_con = 0.0; + xe133m_uncer = 0.0; + xe133_con = 0.0; + xe133_uncer = 0.0; + lc_Xe135 = 0.0; + lc_Xe131m = 0.0; + lc_Xe133m = 0.0; + lc_Xe133 = 0.0; + xe131mFlag = 0; + xe133Flag = 0; + xe133mFlag = 0; + xe135Flag = 0; + gammaCalibrationSpectrumList = new LinkedList<>(); + gammaCalibrationSCE = new GardsCalibrationSpectrum(); + gammaCalibrationSEC = new GardsCalibrationSpectrum(); + gammaCalibrationGCE = new GardsCalibrationSpectrum(); + gammaCalibrationGEC = new GardsCalibrationSpectrum(); + gammaCalibrationDCE = new GardsCalibrationSpectrum(); + gammaCalibrationDEC = new GardsCalibrationSpectrum(); + betaCalibrationSpectrumList = new LinkedList<>(); + betaCalibrationSCE = new GardsCalibrationSpectrum(); + betaCalibrationSEC = new GardsCalibrationSpectrum(); + betaCalibrationGCE = new GardsCalibrationSpectrum(); + betaCalibrationGEC = new GardsCalibrationSpectrum(); + betaCalibrationDCE= new GardsCalibrationSpectrum(); + betaCalibrationDEC = new GardsCalibrationSpectrum(); + roiChannelsSpectrumList = new LinkedList<>(); + roiResultsSpectrumList = new LinkedList<>(); + XeData = new LinkedList<>(); + } + } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGammaService.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGammaService.java index bac4eb22..658ebc27 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGammaService.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGammaService.java @@ -34,10 +34,12 @@ public interface IGammaService{ Result insertPeak(Integer sampleId, String fileName, Integer curChan, HttpServletRequest request); - Result acceptResults(String fileName, boolean accept, List oldPeak, HttpServletRequest request); + Result acceptResults(String fileName, boolean accept, List oldPeak, List newPeak, String flag, HttpServletRequest request); Result deletePeak(String fileName, int curRow, HttpServletRequest request); + Result fitPeak(int left, int right, String fileName, HttpServletRequest request); + Result getSelPosNuclide(Integer sampleId, String fileName, int channel, HttpServletRequest request); Result addNuclide(Integer curRow, String nuclideName, String fileName, List list_identify, HttpServletRequest request); @@ -58,6 +60,10 @@ public interface IGammaService{ Result searchNuclide(Integer sampleId, String fileName, Double energy, Double tolerance, HttpServletRequest request); + Result replotBaseLine(BaseLineCtrls baseLineCtrls, HttpServletRequest request); + + Result acceptBaseLine(BaseLineCtrls baseLineCtrls, HttpServletRequest request); + Result ZeroTime(); Result ZeroTimeAnalyse(String nuclide1, String nuclide2, Double product1, Double product2, String target, String energyTFH, String date, String time); @@ -163,4 +169,7 @@ public interface IGammaService{ void saveToTxt(String fileName, HttpServletRequest request, HttpServletResponse response); void saveToExcel(String fileName, HttpServletResponse response); + + void saveToPHD(String fileName, HttpServletRequest request, HttpServletResponse response); + } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISpectrumAnalysisService.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISpectrumAnalysisService.java index b6391040..a3bd6a44 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISpectrumAnalysisService.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISpectrumAnalysisService.java @@ -66,9 +66,9 @@ public interface ISpectrumAnalysisService { Result ReAnalyse(AnalyseData analyseData, HttpServletRequest request); - Result analyseCurrentSpectrum(String dbName, Integer sampleId, String sampleFileName, String gasFileName, String detFileName, HttpServletRequest request); + Result analyseCurrentSpectrum(String dbName, Integer sampleId, String sampleFileName, String gasFileName, String detFileName, String qcFileName, HttpServletRequest request); - Result analyseAllSpectrum(List dbNames, List sampleIds, List sampleFileNames, List gasFileNames, List detFileNames, HttpServletRequest request); + Result analyseAllSpectrum(List dbNames, List sampleIds, List sampleFileNames, List gasFileNames, List detFileNames, List qcFileNames, String currentFileName, HttpServletRequest request); Result saveToDB(BgDataAnlyseResultIn anlyseResultIn, HttpServletRequest request); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java index 3017c195..19e076bf 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java @@ -371,6 +371,16 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class); phd.setUsedTotEPara(value); } + if (entry.getKey().equalsIgnoreCase("mapNucActMda")) { + HashMap jsonMap = JSON.parseObject(JSON.toJSONString(entry.getValue()), HashMap.class); + Map value = new HashMap<>(); + for (Map.Entry objectEntry:jsonMap.entrySet()) { + String key = objectEntry.getKey(); + NuclideActMda entryValue = JSON.parseObject(JSON.toJSONString(objectEntry.getValue()), NuclideActMda.class); + value.put(key, entryValue); + } + phd.setMapNucActMda(value); + } } BeanUtils.copyProperties(phd.getSetting(), phd.getUsedSetting()); @@ -382,7 +392,6 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi peak.recoilDeltaChan = "1"; } } - gammaFileUtil.NuclidesIdent(phd, nuclideLinesMap); gammaFileUtil.RunQC(phd); result.setResult(phd); } catch (JsonProcessingException e) { @@ -1137,15 +1146,10 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi insertInput.rg_high = phd.getBaseCtrls().getRg_high(); insertInput.curChan = curChan; insertInput.vCount = m_vCount; - ObjectMapper mapper = new ObjectMapper(); - try { - String value = mapper.writeValueAsString(insertInput); - System.out.println(value); - } catch (JsonProcessingException e) { - throw new RuntimeException(e); - } StructInsertOutput structInsertOutput = CalValuesHandler.insertPeaks(insertInput); - List indexs = new LinkedList<>(); + List newPeak = new LinkedList<>(); + List newPeaks = new LinkedList<>(); + newPeaks.addAll(phd.getVPeak()); if (structInsertOutput.vIdx.size()>0){ for (int j=0; j vIdx = new LinkedList<>(); int ii = 0; - for (PeakInfo peak:phd.getVPeak()){ + for (PeakInfo peak: newPeaks){ if(peak.peakCentroid >= right){ break; } else if(peak.peakCentroid > left) { @@ -1190,21 +1194,21 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi ii++; } - List tablePeaksList = FitPeakBaseLine(phd, vIdx); + List tablePeaksList = FitPeakBaseLine(newPeaks, phd.getUsedEnerPara().getP(), vIdx); map.put("tablePeaksList", tablePeaksList); map.put("oldPeaks", vOriPeaks); + map.put("newPeaks", newPeak); result.setSuccess(true); result.setResult(map); return result; } - public List FitPeakBaseLine(PHDFile phd, List vIdx) { + public List FitPeakBaseLine(List vPeaks, List p, List vIdx) { List tablePeaksList = new LinkedList<>(); int peakNum = vIdx.size(); for (int i=0; i oldPeak, HttpServletRequest request) { + public Result acceptResults(String fileName, boolean accept, List oldPeak, List newPeak, String flag, HttpServletRequest request) { Result result = new Result(); String userName = JwtUtil.getUserNameByToken(request); Cache phdCache = localCache.getPHDCache(); @@ -1256,7 +1260,28 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi HashMap map = new HashMap<>(); //根据boolean 决定是否保留本次数据 如果保留则不需要操作vPeak 并重新拟合线 if (accept){ - //算法有问题 --- 需要等等处理 + if (flag.equalsIgnoreCase("fit")) {//如果传递的flag标识 是 fit则进行修改峰值等数据 + for (int j=0; j vPeak = gammaFileUtil.InitPeakTable(phd.getVPeak()); @@ -1303,7 +1328,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi if(curRow >= 0 && curRow < peakNum) { phd.getVPeak().remove(curRow); -// gammaFileUtil.PeaksChanged(phd); + gammaFileUtil.PeaksChanged(phd); for (int i=0;i map = new HashMap<>(); + //获取用户名 + String userName = JwtUtil.getUserNameByToken(request); + Cache phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(fileName+"-"+userName); + if (Objects.isNull(phd)){ + result.error500("请先选择解析文件!"); + return result; + } + //判断当前phd文件对应的peak的数据是否小于1 + if(phd.getVPeak().size() < 1) { + result.error500("No peak to fit."); + return result; + } + //判断当前选择的左侧道值是否大于右侧道值 + if(left > right) { + int temp = left; + left = right; + right = temp; + } + + // 找出与插入峰相关联的峰的索引 + List vIdx = new LinkedList<>(); + int ii = 0; + for(PeakInfo peak: phd.getVPeak()) { + if(peak.peakCentroid >= right) { + break; + } else if(peak.peakCentroid > left) { + vIdx.add(ii); + } + ii++; + } + if(CollectionUtils.isEmpty(vIdx)) { + result.error500("There are 0 peak between channel "+left+" and "+right); + return result; + } + // 备份原来的峰列表 + List vOriPeaks = phd.getVPeak(); + List newPeak = new LinkedList<>(); + for (int i=0; i tablePeaksList = FitPeakBaseLine(phd.getVPeak(), phd.getUsedEnerPara().getP(), vIdx); + map.put("tablePeaksList", tablePeaksList); + map.put("oldPeaks", vOriPeaks); + map.put("newPeaks", newPeak); + result.setSuccess(true); + result.setResult(map); + return result; + } + @Override public Result getSelPosNuclide(Integer sampleId, String fileName, int channel, HttpServletRequest request) { Result result = new Result(); @@ -1674,6 +1755,102 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi return result; } + @Override + public Result replotBaseLine(BaseLineCtrls baseLineCtrls, HttpServletRequest request) { +// Result result = new Result(); +// HashMap map = new HashMap<>(); +// //获取用户名 +// String userName = JwtUtil.getUserNameByToken(request); +// //获取文件名称 +// String fileName = baseLineCtrls.getFileName(); +// Cache phdCache = localCache.getPHDCache(); +// PHDFile phd = phdCache.getIfPresent(fileName+"-"+userName); +// if (Objects.isNull(phd)){ +// result.error500("请先选择解析文件!"); +// return result; +// } +// List m_vCount = new LinkedList<>(); +// long m_nCount = phd.getSpec().getNum_g_channel(); +// long m_nSChan = phd.getSpec().getBegin_channel(); +// //获取当前角色的颜色配置 +// Map colorMap = sysUserColorService.initColor(userName); +// // 确保绘制曲线时所有谱都是从1道开始 +// int i = 0; +// if(m_nSChan == 0){ +// i = 1; +// } +// for(; i peakSet = gammaFileUtil.PeakSet(phd.getVPeak(), baseLineCtrls.getBaseline(), colorMap.get("Color_peak"), m_nCount, null, false); +// m_chart->AddData(CreateTempBaseLine(m_data->m_Color[Color_base], "BaseLine")); +// CreateShapeCP(MyChartSpace::Shape_Round); +// +// if(m_baseCtrl.BaseStack.size() > 2) m_baseCtrl.BaseStack.remove(1, m_baseCtrl.BaseStack.size()-2); +// } + + return null; + } + + @Override + public Result acceptBaseLine(BaseLineCtrls baseLineCtrls, HttpServletRequest request) { + Result result = new Result(); + HashMap map = new HashMap<>(); + //获取用户名 + String userName = JwtUtil.getUserNameByToken(request); + //获取文件名称 + String fileName = baseLineCtrls.getFileName(); + Cache phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(fileName+"-"+userName); + if (Objects.isNull(phd)){ + result.error500("请先选择解析文件!"); + return result; + } + if(baseLineCtrls.getBaseStack().size() > 1) { + for (int i=0; i m_vCount = new LinkedList<>(); + long m_nCount = phd.getSpec().getNum_g_channel(); + long m_nSChan = phd.getSpec().getBegin_channel(); + //获取当前角色的颜色配置 + Map colorMap = sysUserColorService.initColor(userName); + // 确保绘制曲线时所有谱都是从1道开始 + int i = 0; + if(m_nSChan == 0){ + i = 1; + } + for(; i differance = gammaFileUtil.Differance(phd, phd.getVPeak(), m_vCount, m_nCount); + map.put("barChart", differance); + ChartData channelBaseLine = gammaFileUtil.Channel_BaseLine(phd, m_nCount, colorMap.get("Color_Base")); + map.put("channelBaseLineChart", channelBaseLine); + List peakSet = gammaFileUtil.PeakSet(phd.getVPeak(), phd.getVBase(), colorMap.get("Color_peak"), m_nCount, null, false); + map.put("peakSet", peakSet); + List shapeData = gammaFileUtil.CreateShapeCP(phd.getBaseCtrls()); + map.put("shapeData", shapeData); + //更新主界面的 Chart + gammaFileUtil.UpdateChart(phd, map, colorMap); + result.setSuccess(true); + result.setResult(map); + return result; + } + @Override public Result ZeroTime() { Result result = new Result(); @@ -3269,7 +3446,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi result.error500("请先选择解析文件!"); return result; } - String spectrum = gammaFileUtil.MakeUpSpectrum(phd); + String spectrum = gammaFileUtil.makeUpSpectrum(phd); result.setSuccess(true); result.setResult(spectrum); return result; @@ -3929,161 +4106,200 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi String userName = JwtUtil.getUserNameByToken(request); Cache phdCache = localCache.getPHDCache(); PHDFile phd = phdCache.getIfPresent(fileName+"-"+userName); - StringBuilder strBuild = new StringBuilder(); - //txt文本内容 - //文本内容第一块头部信息 - String title1 = " %s The Results of Peak Searching %s"; - //文本内容第一块头部信息匹配 - strBuild.append(titleFormat(title1, 51, StringPool.ASTERISK, StringPool.ASTERISK)); - //换行 - strBuild.append(System.lineSeparator()); - //换行 - strBuild.append(System.lineSeparator()); - //文本内容第二块 - //文本内容第二块匹配格式 - String title2 = "%-12s %-12s %-12s %-12s %-12s %-12s %-12s %-12s %-12s %-12s"; - //文本内容第二块头部信息 - String[] titleArgs2 = new String[]{"PeakID", "Energy(keV)", "Centroid", "Multiplet", "FWHM(keV)", "NetArea", "NAErr%", "Signif", "Sensit", "Nuclide"}; - //文本内容第二块头部信息匹配 - strBuild.append(rowFormat(title2, titleArgs2)); - //换行 - strBuild.append(System.lineSeparator()); - //换行 - strBuild.append(System.lineSeparator()); - //遍历数组进行文本内容第二块数据匹配 - for (int i=0; i> peakNuclides = phd.getVPeak().stream().map(item -> item.nuclides).collect(Collectors.toList()); - List nuclides = new LinkedList<>(); - for (int i=0; i peakNuclide = peakNuclides.get(i); - nuclides.addAll(peakNuclide); - } - nuclides = nuclides.stream().distinct().collect(Collectors.toList()); - String nuclideStr = ""; - for (int i=0; i mapNucActMda = phd.getMapNucActMda(); - for (Map.Entry entry:mapNucActMda.entrySet()) { - String key = entry.getKey(); - NuclideActMda nuc = entry.getValue(); - String halflifeValue = ""; - if(nuc.isBCalculateMDA()) { - String units = "S"; - double halflife = nuc.getHalflife(); - if(halflife >= 31556736) {// 1年 = 365.24 * 24 * 60 * 60 = 31556736s - halflife /= 31556736; - units = "A"; - } else if(halflife >= 86400) {// 1天 = 24 * 60 * 60 = 86400s - halflife /= 86400; - units = "D"; - } else if(halflife >= 3600) { - halflife /= 3600; - units = "H"; + //换行 + strBuild.append(System.lineSeparator()); + //文本内容第二块 + //文本内容第二块匹配格式 + String title2 = "%-12s %-12s %-12s %-12s %-12s %-12s %-12s %-12s %-12s %-12s"; + //文本内容第二块头部信息 + String[] titleArgs2 = new String[]{"PeakID", "Energy(keV)", "Centroid", "Multiplet", "FWHM(keV)", "NetArea", "NAErr%", "Signif", "Sensit", "Nuclide"}; + //文本内容第二块头部信息匹配 + strBuild.append(rowFormat(title2, titleArgs2)); + //换行 + strBuild.append(System.lineSeparator()); + //遍历数组进行文本内容第二块数据匹配 + for (int i=0; i> peakNuclides = phd.getVPeak().stream().map(item -> item.nuclides).collect(Collectors.toList()); + List nuclides = new LinkedList<>(); + for (int i=0; i peakNuclide = peakNuclides.get(i); + nuclides.addAll(peakNuclide); + } + nuclides = nuclides.stream().distinct().collect(Collectors.toList()); + String nuclideStr = ""; + for (int i=0; i mapNucActMda = phd.getMapNucActMda(); + for (Map.Entry entry:mapNucActMda.entrySet()) { + String key = entry.getKey(); + NuclideActMda nuc = entry.getValue(); + String halflifeValue = ""; + if(nuc.isBCalculateMDA()) { + String units = "S"; + double halflife = nuc.getHalflife(); + if(halflife >= 31556736) {// 1年 = 365.24 * 24 * 60 * 60 = 31556736s + halflife /= 31556736; + units = "A"; + } else if(halflife >= 86400) {// 1天 = 24 * 60 * 60 = 86400s + halflife /= 86400; + units = "D"; + } else if(halflife >= 3600) { + 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 = 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 = 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()); - String detectorCode = phd.getHeader().getDetector_code(); - String date = phd.getAcq().getAcquisition_start_date().replace("/", ""); - String time = phd.getAcq().getAcquisition_start_time().replace(":", "").substring(0, 4); - String dataType = phd.getMsgInfo().getData_type().substring(0, 1); - String format = ".txt"; - String txtFileName = String.format("%s-%s_%s_%s_RESULT%s", detectorCode, date, time, dataType, format); - //导出数据内容到txt文本 - OutputStream fos = null; - try { - //设置响应类型 - response.setContentType("application/octet-stream"); - //解决中文不能生成文件 - response.setHeader("Content-Disposition", "attachment; fileName=" + URLEncoder.encode(txtFileName,"UTF-8")); - fos = response.getOutputStream(); - fos.write(strBuild.toString().getBytes()); - } catch (FileNotFoundException e) { - throw new RuntimeException(e); - } catch (IOException e) { - throw new RuntimeException(e); - } finally { + strBuild.append(System.lineSeparator()); + String detectorCode = phd.getHeader().getDetector_code(); + String date = phd.getAcq().getAcquisition_start_date().replace("/", ""); + String time = phd.getAcq().getAcquisition_start_time().replace(":", "").substring(0, 4); + String dataType = phd.getMsgInfo().getData_type().substring(0, 1); + String format = ".txt"; + String txtFileName = String.format("%s-%s_%s_%s_RESULT%s", detectorCode, date, time, dataType, format); + //导出数据内容到txt文本 + OutputStream fos = null; try { - if (Objects.nonNull(fos)) { - fos.close(); - } + //设置响应类型 + response.setContentType("application/octet-stream"); + //解决中文不能生成文件 + response.setHeader("Content-Disposition", "attachment; fileName=" + URLEncoder.encode(txtFileName,"UTF-8")); + fos = response.getOutputStream(); + fos.write(strBuild.toString().getBytes()); + } catch (FileNotFoundException e) { + throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); + } finally { + try { + if (Objects.nonNull(fos)) { + fos.close(); + } + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } + } + + @Override + public void saveToPHD(String fileName, HttpServletRequest request, HttpServletResponse response) { + //获取当前登陆用户名 + String userName = JwtUtil.getUserNameByToken(request); + //读取本地缓存的phd文件信息 + Cache phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(fileName+"-"+userName); + if (Objects.nonNull(phd)) { + String detectorCode = phd.getHeader().getDetector_code(); + String date = phd.getAcq().getAcquisition_start_date().replace("/", ""); + String time = phd.getAcq().getAcquisition_start_time().replace(":", "").substring(0, 4); + String dataType = phd.getMsgInfo().getData_type().substring(0, 1); + String phdFileName = String.format("%s-%s_%s_%s.PHD", detectorCode, date, time, dataType); + String spectrum = gammaFileUtil.makeUpSpectrum(phd); + //导出数据内容到txt文本 + OutputStream fos = null; + try { + //设置响应类型 + response.setContentType("application/octet-stream"); + //解决中文不能生成文件 + response.setHeader("Content-Disposition", "attachment; fileName=" + URLEncoder.encode(phdFileName,"UTF-8")); + fos = response.getOutputStream(); + fos.write(spectrum.getBytes()); + } catch (FileNotFoundException e) { + throw new RuntimeException(e); + } catch (IOException e) { + throw new RuntimeException(e); + } finally { + try { + if (Objects.nonNull(fos)) { + fos.close(); + } + } catch (IOException e) { + throw new RuntimeException(e); + } } } } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java index fed6defc..98d20232 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java @@ -219,10 +219,12 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { List> resultList = new LinkedList<>(); String userName = JwtUtil.getUserNameByToken(request); String filePath = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH +userName; - String sampleRx = "[a-zA-Z]{3}[0-9]{2}_[0-9]{3}-[0-9]{8}_[0-9]{4}_S.*.PHD"; + String sampleRx = "[a-zA-Z]{3}[0-9]{2}_[0-9]{3}-[0-9]{8}_[0-9]{4}_S_(FULL_|PREL_)\\d+\\.PHD"; Pattern regexPattern = Pattern.compile(sampleRx); String sampleRx1 = "[a-zA-Z]{3}[0-9]{2}_[0-9]{3}-[0-9]{8}_[0-9]{4}_S_(FULL_|PREL_)\\d+\\.\\d+\\.PHD"; Pattern regexPattern1 = Pattern.compile(sampleRx1); + String sampleRx2 = "[a-zA-Z]{3}[0-9]{2}_[0-9]{3}-[0-9]{8}_[0-9]{4}_S_.PHD"; + Pattern regexPattern2 = Pattern.compile(sampleRx2); //判断传递的文件名称是否包含, List matchFileNames = new LinkedList<>(); if (fileName.contains(StringPool.COMMA)) { @@ -234,7 +236,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { for (String matchFileName :matchFileNames) { Map map =new HashMap<>(); //判断sample文件名称是否匹配正则表达式 如果满足 则查询出对应的文件信息 - if ( regexPattern.matcher(matchFileName).find()){ + if ( regexPattern.matcher(matchFileName).find() || regexPattern1.matcher(matchFileName).find() || regexPattern2.matcher(matchFileName).find() ){ //查询sampleFile文件内容信息 获取文件内容 获取大致的gas det文件名称 Map fileData = phdFileUtil.getFileData(filePath, matchFileName); if (CollectionUtils.isEmpty(fileData)) { @@ -299,17 +301,14 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { @Override public Result getDBSpectrumChart(String dbName, Integer sampleId, HttpServletRequest request) { Result result = new Result(); + //获取当前的用户名称 String userName = JwtUtil.getUserNameByToken(request); - Cache> cache = betaCache.getBetaCache(); - Map cacheMap = new HashMap<>(); Map resultMap = new HashMap<>(); - List gammaCalibrationSpectrumList= new LinkedList<>(); - List betaCalibrationSpectrumList = new LinkedList<>(); - List roiChannelsSpectrumList = new LinkedList<>(); - List roiResultsSpectrumList = new LinkedList<>(); - List gammaCalibrationPairsList = new LinkedList<>(); - List betaCalibrationPairsList = new LinkedList<>(); + boolean bProcessed = false; List xeResultsSpectrumList = new LinkedList<>(); + List sampleBoundary = new LinkedList<>(); + List gasBoundary = new LinkedList<>(); + List detBoundary = new LinkedList<>(); if (Objects.isNull(sampleId)){ result.error500("请选择一条数据"); return result; @@ -317,51 +316,16 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { Integer analysisID = null; if (dbName.equalsIgnoreCase("auto")){ dbName = "RNAUTO"; - analysisID = spectrumAnalysisMapper.getAnalysisID("RNAUTO", sampleId, "RNAUTO"); - gammaCalibrationSpectrumList = spectrumAnalysisMapper.ReadGammaCalibrationParam("RNAUTO", analysisID, sampleId); - betaCalibrationSpectrumList = spectrumAnalysisMapper.ReadBetaCalibrationParam("RNAUTO", analysisID, sampleId); - roiChannelsSpectrumList = spectrumAnalysisMapper.ReadROIChannels("RNAUTO", analysisID, sampleId); - roiResultsSpectrumList = spectrumAnalysisMapper.ReadROIResults("RNAUTO", analysisID, sampleId); - xeResultsSpectrumList = spectrumAnalysisMapper.ReadXeResults("RNAUTO", analysisID, sampleId); + analysisID = spectrumAnalysisMapper.getAnalysisID(dbName, sampleId, "RNAUTO"); + xeResultsSpectrumList = spectrumAnalysisMapper.ReadXeResults(dbName, analysisID, sampleId); } else if (dbName.equalsIgnoreCase("man")){ dbName = "RNMAN"; - analysisID = spectrumAnalysisMapper.getAnalysisID("RNMAN", sampleId, userName); - gammaCalibrationPairsList = spectrumAnalysisMapper.ReadGammaFitChannelEnergy(analysisID, sampleId); - gammaCalibrationSpectrumList = spectrumAnalysisMapper.ReadGammaCalibrationParam("RNMAN", analysisID, sampleId); - betaCalibrationPairsList = spectrumAnalysisMapper.ReadBetaFitChannelEnergy(analysisID, sampleId); - betaCalibrationSpectrumList = spectrumAnalysisMapper.ReadBetaCalibrationParam("RNMAN", analysisID, sampleId); - roiChannelsSpectrumList = spectrumAnalysisMapper.ReadROIChannels("RNMAN", analysisID, sampleId); - roiResultsSpectrumList = spectrumAnalysisMapper.ReadROIResults("RNMAN", analysisID, sampleId); - xeResultsSpectrumList = spectrumAnalysisMapper.ReadXeResults("RNMAN", analysisID, sampleId); - cacheMap.put("gammaCalibrationPairsList", gammaCalibrationPairsList); - cacheMap.put("betaCalibrationPairsList", betaCalibrationPairsList); + analysisID = spectrumAnalysisMapper.getAnalysisID(dbName, sampleId, userName); + xeResultsSpectrumList = spectrumAnalysisMapper.ReadXeResults(dbName, analysisID, sampleId); }else { result.error500("数据库类型不存在"); return result; } - cacheMap.put("gammaCalibrationSpectrumList", gammaCalibrationSpectrumList); - cacheMap.put("betaCalibrationSpectrumList", betaCalibrationSpectrumList); - cacheMap.put("roiChannelsSpectrumList", roiChannelsSpectrumList); - cacheMap.put("roiResultsSpectrumList", roiResultsSpectrumList); - cacheMap.put("xeResultsSpectrumList", xeResultsSpectrumList); - //Xe - if (CollectionUtils.isNotEmpty(xeResultsSpectrumList)){ - for (GardsXeResultsSpectrum xeData:xeResultsSpectrumList) { - Double conc = xeData.getConc(); - Double mdc = xeData.getMdc(); - if (conc < 0){ - xeData.setColor("red"); - xeData.setNidFlag(0); - } else if (0 mdc) { - xeData.setColor("green"); - xeData.setNidFlag(1); - } - } - resultMap.put("XeData", xeResultsSpectrumList); - } //查询数据库文件信息 SpectrumFileRecord dbSpectrumFilePath = spectrumAnalysisMapper.getDBSpectrumFilePath(dbName, sampleId, analysisID); List filePath = new LinkedList<>(); @@ -378,8 +342,6 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { String fileName = sampleFilePath.substring(sampleFilePath.lastIndexOf(StringPool.SLASH)+1); sampleMap = this.fenxi(pathName, fileName, sample.getSampleId(), sample.getStatus()); resultMap.put("sample",sampleMap); - cache.put(fileName+"-"+userName, cacheMap); - betaCache.setBetaCache(cache); } if(StringUtils.isNotBlank(dbSpectrumFilePath.getGasBgFilePath())){ String gasBgFilePath = dbSpectrumFilePath.getGasBgFilePath(); @@ -417,11 +379,47 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } } phdFileUtil.getLightColor(sampleMap,gasBgMap,detBgMap,qcMap); - resultMap.put("bProcessed", false); + String sampleFileName = String.valueOf(sampleMap.get("fileName")); + Cache> cache = betaCache.getBetaCache(); + Map xeDataMap = cache.getIfPresent(sampleFileName + "-" + userName + "-xeData"); + if (CollectionUtils.isNotEmpty(xeDataMap)) { + xeResultsSpectrumList = (List) xeDataMap.get("XeData"); + sampleBoundary = (List) xeDataMap.get("SampleBoundary"); + gasBoundary = (List) xeDataMap.get("GasBoundary"); + detBoundary = (List) xeDataMap.get("DetBoundary"); + bProcessed = true; + if (CollectionUtils.isNotEmpty(sampleBoundary)) { + sampleMap.put("Boundary", sampleBoundary); + } + if (CollectionUtils.isNotEmpty(gasBoundary)) { + gasBgMap.put("Boundary", gasBoundary); + } + if (CollectionUtils.isNotEmpty(detBoundary)) { + detBgMap.put("Boundary", detBoundary); + } + } + //Xe + if (CollectionUtils.isNotEmpty(xeResultsSpectrumList)){ + for (GardsXeResultsSpectrum xeData:xeResultsSpectrumList) { + Double conc = xeData.getConc(); + Double mdc = xeData.getMdc(); + if (conc < 0){ + xeData.setColor("red"); + xeData.setNidFlag(0); + } else if (0 mdc) { + xeData.setColor("green"); + xeData.setNidFlag(1); + } + } + } + resultMap.put("XeData", xeResultsSpectrumList); + resultMap.put("bProcessed", bProcessed); resultMap.put("savedAnalysisResult", true); } else { resultMap.clear(); - cacheMap.clear(); } result.setSuccess(true); result.setResult(resultMap); @@ -434,11 +432,17 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { String userName = JwtUtil.getUserNameByToken(request); String path = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; Map resultMap = new HashMap<>(); + List xeResultsSpectrumList = new LinkedList<>(); + List sampleBoundary = new LinkedList<>(); + List gasBoundary = new LinkedList<>(); + List detBoundary = new LinkedList<>(); List filePath = new LinkedList<>(); Map sampleMap = new HashMap<>(); Map gasBgMap = new HashMap<>(); Map detBgMap = new HashMap<>(); Map qcMap = new HashMap<>(); + boolean bProcessed = false; + boolean savedAnalysisResult = false; if(StringUtils.isNotBlank(sampleFileName)){ String sampleFilePath = path + sampleFileName; filePath.add(sampleFilePath); @@ -464,9 +468,48 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { resultMap.put("qc", qcMap); } phdFileUtil.getLightColor(sampleMap,gasBgMap,detBgMap,qcMap); - resultMap.put("XeData", new LinkedList<>()); - resultMap.put("bProcessed", false); - resultMap.put("savedAnalysisResult", false); + //获取本地缓存信息 + Cache> cache = betaCache.getBetaCache(); + //根据key获取缓存数据 + Map xeDataMap = cache.getIfPresent(sampleFileName + "-" + userName + "-xeData"); + //如果缓存数据存在 则将缓存数据取出使用 + if (CollectionUtils.isNotEmpty(xeDataMap)) { + xeResultsSpectrumList = (List) xeDataMap.get("XeData"); + sampleBoundary = (List) xeDataMap.get("SampleBoundary"); + gasBoundary = (List) xeDataMap.get("GasBoundary"); + detBoundary = (List) xeDataMap.get("DetBoundary"); + bProcessed = true; + savedAnalysisResult = true; + //Xe + if (CollectionUtils.isNotEmpty(xeResultsSpectrumList)){ + for (GardsXeResultsSpectrum xeData:xeResultsSpectrumList) { + Double conc = xeData.getConc(); + Double mdc = xeData.getMdc(); + if (conc < 0){ + xeData.setColor("red"); + xeData.setNidFlag(0); + } else if (0 mdc) { + xeData.setColor("green"); + xeData.setNidFlag(1); + } + } + } + if (CollectionUtils.isNotEmpty(sampleBoundary)) { + sampleMap.put("Boundary", sampleBoundary); + } + if (CollectionUtils.isNotEmpty(gasBoundary)) { + gasBgMap.put("Boundary", gasBoundary); + } + if (CollectionUtils.isNotEmpty(detBoundary)) { + detBgMap.put("Boundary", detBoundary); + } + } + resultMap.put("XeData", xeResultsSpectrumList); + resultMap.put("bProcessed", bProcessed); + resultMap.put("savedAnalysisResult", savedAnalysisResult); result.setSuccess(true); result.setResult(resultMap); return result; @@ -1276,8 +1319,6 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { file = File.createTempFile("betaGamma", null); //将ftp文件的输入流复制给临时文件 FileUtils.copyInputStreamToFile(inputStream, file); - //加载dll工具库 - //System.loadLibrary("ReadPHDFile"); EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(file.getAbsolutePath()); rlrDataValues.setSrid(struct.sample_ref_id); rlrDataValues.setColloct_start_date(struct.collection_start_date); @@ -2411,6 +2452,9 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { @Override public Result ReAnalyse(AnalyseData analyseData, HttpServletRequest request) { Result result = new Result(); + //声明接收当前分析后的返回结果的map + Map map = new HashMap<>(); + //获取当前登陆的用户名 String userName = JwtUtil.getUserNameByToken(request); if ("CurrentSpectrum".equals(analyseData.getApplyType())) { String dbName = analyseData.getDbNames().get(0); @@ -2429,17 +2473,25 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { String sampleFilePath = dbSpectrumFilePath.getSampleFilePath().substring(0, dbSpectrumFilePath.getSampleFilePath().lastIndexOf(StringPool.SLASH)); String gasFilePath = dbSpectrumFilePath.getGasBgFilePath().substring(0, dbSpectrumFilePath.getGasBgFilePath().lastIndexOf(StringPool.SLASH)); String detFilePath = dbSpectrumFilePath.getDetBgFilePath().substring(0, dbSpectrumFilePath.getDetBgFilePath().lastIndexOf(StringPool.SLASH)); - BgAnalyseResult analyseResult = BetaGammaAnalyzeCurrentProcess(analyseData, sampleFilePath, gasFilePath, detFilePath, userName); + List analyseResult = BetaGammaAnalyzeCurrentProcess(analyseData, sampleFilePath, gasFilePath, detFilePath, userName); + map.put("xeData", analyseResult); + map.put("bProcessed", true); + map.put("savedAnalysisResult", true); result.setSuccess(true); - result.setResult(analyseResult); + result.setResult(map); } } else { String path = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; - BgAnalyseResult analyseResult = BetaGammaAnalyzeCurrentProcess(analyseData, path, path, path, userName); + List analyseResult = BetaGammaAnalyzeCurrentProcess(analyseData, path, path, path, userName); + map.put("XeData", analyseResult); + map.put("bProcessed", true); + map.put("savedAnalysisResult", true); result.setSuccess(true); - result.setResult(analyseResult); + result.setResult(map); } } else if ("AllSpectrum".equals(analyseData.getApplyType())) { + //获取当前选中的文件名称 + String currentFileName = analyseData.getCurrentFileName(); List> loadDataList = new LinkedList<>(); for (int i=0; i m_loadData = new HashMap<>(); @@ -2481,66 +2533,61 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { m_loadData.put("qcFileName", qcFileName); loadDataList.add(m_loadData); } - BetaGammaAnalyzeAllProcess(loadDataList, analyseData, userName); + List analyseResultList = BetaGammaAnalyzeAllProcess(loadDataList, analyseData, userName, currentFileName); + map.put("XeData", analyseResultList); + map.put("bProcessed", true); + map.put("savedAnalysisResult", true); + result.setSuccess(true); + result.setResult(map); } -// if (analyseData.isBBetaEnergyValid()) { -// ui->BetaOriginalChartView->SetFittingParam(fit_analy_param.b_calibration_param.param_a_c2e_new, -// fit_analy_param.b_calibration_param.param_b_c2e_new, -// fit_analy_param.b_calibration_param.param_c_c2e_new); -// ui->BetaProjectedChartView->SetFittingParam(fit_analy_param.b_calibration_param.param_a_c2e_new, -// fit_analy_param.b_calibration_param.param_b_c2e_new, -// fit_analy_param.b_calibration_param.param_c_c2e_new); -// } -// if (analyseData.isBGammaEnergyValid()) { -// ui->GammaOriginalChartView->SetFittingParam(fit_analy_param.g_calibration_param.param_a_c2e_new, -// fit_analy_param.g_calibration_param.param_b_c2e_new, -// fit_analy_param.g_calibration_param.param_c_c2e_new); -// ui->GammaProjectedChartView->SetFittingParam(fit_analy_param.g_calibration_param.param_a_c2e_new, -// fit_analy_param.g_calibration_param.param_b_c2e_new, -// fit_analy_param.g_calibration_param.param_c_c2e_new); -// } return result; } - private BgAnalyseResult BetaGammaAnalyzeCurrentProcess(AnalyseData analyseData, String sampleFilePath, String gasFilePath, String detFilePath, String userName) { - //System.loadLibrary("ReadPHDFile"); + private List BetaGammaAnalyzeCurrentProcess(AnalyseData analyseData, String sampleFilePath, String gasFilePath, String detFilePath, String userName) { //根据文件路径 文件名称获取对应的临时文件 File sampleTmp = null; File gasTmp = null; File detTmp = null; - BgAnalyseResult analyseResult = null; + //需要返回到前端的XeData数据 + List xeResultsSpectrumList = new LinkedList<>(); try { + //sample文件名称 List sampleFileNames = analyseData.getSampleFileNames(); String sampleFileName = sampleFileNames.get(0); + //gas文件名称 List gasFileNames = analyseData.getGasFileNames(); String gasFileName = gasFileNames.get(0); + //det文件名称 List detFileNames = analyseData.getDetFileNames(); String detFileName = detFileNames.get(0); + //qc文件名称 List qcFileNames = analyseData.getQcFileNames(); String qcFileName = qcFileNames.get(0); + //存储重新分析字段的实体类 SpectrumGroup spectrum_group = new SpectrumGroup(); + //声明一个map 缓存重新分析用到的数据 + Map map = new HashMap<>(); + //声明一个map 缓存xeData计算后的结果 + Map xeMap = new HashMap<>(); //从本地缓存获取beta gamma的数组 Cache> cache = betaCache.getBetaCache(); //根据qc文件名称-用户名-beta的方式获取beta的内容 Map betaMap = cache.getIfPresent(qcFileName + "-" + userName + "-beta"); - List betaList = new LinkedList<>(); List betaFittingPara = new LinkedList<>(); List betaFittingParaToUi = new LinkedList<>(); if (CollectionUtils.isNotEmpty(betaMap)) { - betaList = (List)betaMap.get("Series"); betaFittingPara = (List) betaMap.get("fittingPara"); betaFittingParaToUi = (List) betaMap.get("fittingParaToUi"); } //根据qc文件名称-用户名-gamma的方式获取gamma的内容 Map gammaMap = cache.getIfPresent(qcFileName + "-" + userName + "-gamma"); - List gammaList = new LinkedList<>(); List gammaFittingPara = new LinkedList<>(); List gammaFittingParaToUi = new LinkedList<>(); if (CollectionUtils.isNotEmpty(gammaMap)) { - gammaList = (List)gammaMap.get("Series"); gammaFittingPara = (List) gammaMap.get("fittingPara"); gammaFittingParaToUi = (List) gammaMap.get("fittingParaToUi"); } + //判断是否对beta页面进行过分析 if (analyseData.isBetaEnergyValid()) { List beCal = new LinkedList<>(); beCal.add(Double.valueOf(betaFittingParaToUi.get(0))); @@ -2552,7 +2599,23 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { bc2e.add(Double.valueOf(betaFittingPara.get(1))); bc2e.add(Double.valueOf(betaFittingPara.get(2))); spectrum_group.b_c2e = bc2e; + if (analyseData.isSampleData()) { + map.put("bBetaEnergyValidSample", true); + } else { + map.put("bBetaEnergyValidSample", false); + } + if (analyseData.isGasBgData()) { + map.put("bBetaEnergyValidGas", true); + } else { + map.put("bBetaEnergyValidGas", false); + } + if (analyseData.isDetBgData()) { + map.put("bBetaEnergyValidDet", true); + } else { + map.put("bBetaEnergyValidDet", false); + } } + //判断是否对gamma页面进行过分析 if (analyseData.isGammaEnergyValid()) { List geCal = new LinkedList<>(); geCal.add(Double.valueOf(gammaFittingParaToUi.get(0))); @@ -2564,15 +2627,115 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { gc2e.add(Double.valueOf(gammaFittingPara.get(1))); gc2e.add(Double.valueOf(gammaFittingPara.get(2))); spectrum_group.g_c2e = gc2e; + if (analyseData.isSampleData()) { + map.put("bGammaEnergyValidSample", true); + } else { + map.put("bGammaEnergyValidSample", false); + } + if (analyseData.isGasBgData()) { + map.put("bGammaEnergyValidGas", true); + } else { + map.put("bGammaEnergyValidGas", false); + } + if (analyseData.isDetBgData()) { + map.put("bGammaEnergyValidDet", true); + } else { + map.put("bGammaEnergyValidDet", false); + } } + //判断是否勾选了sample spectrum_group.BgCalPara.bApplyNewCalicSample = analyseData.isSampleData(); + //判断是否勾选了gas spectrum_group.BgCalPara.bApplyNewCalicGasBg = analyseData.isGasBgData(); + //判断是否勾选了det spectrum_group.BgCalPara.bApplyNewCalicDetBg = analyseData.isDetBgData(); + //判断是否勾选了qc spectrum_group.BgCalPara.bApplyNewCalicQc = analyseData.isQcData(); + //获取sample文件 sampleTmp = phdFileUtil.analyzeFile(sampleFilePath, sampleFileName); + //获取gas文件 gasTmp = phdFileUtil.analyzeFile(gasFilePath, gasFileName); + //获取det文件 detTmp = phdFileUtil.analyzeFile(detFilePath, detFileName); - 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); + //存入分析用到的数据 + map.put("reAnalyseParam", spectrum_group.BgCalPara); + //存入计算后得到的xeData数据 + GardsXeResultsSpectrum xe131m = new GardsXeResultsSpectrum(); + xe131m.setNuclideName(XeNuclideName.XE_131m.getType()); + xe131m.setConc(analyseResult.Xe131m_con); + xe131m.setConcErr(analyseResult.Xe131m_uncer); + xe131m.setLc(analyseResult.LC_Xe131m); + xe131m.setMdc(analyseResult.MDC_Xe131m); + xe131m.setNidFlag(analyseResult.XE_131m_NID_FLAG); + xeResultsSpectrumList.add(xe131m); + GardsXeResultsSpectrum xe133 = new GardsXeResultsSpectrum(); + xe133.setNuclideName(XeNuclideName.XE_133.getType()); + xe133.setConc(analyseResult.Xe133_con); + xe133.setConcErr(analyseResult.Xe133_uncer); + xe133.setLc(analyseResult.LC_Xe133); + xe133.setMdc(analyseResult.MDC_Xe133); + xe133.setNidFlag(analyseResult.XE_133_NID_FLAG); + xeResultsSpectrumList.add(xe133); + GardsXeResultsSpectrum xe133m = new GardsXeResultsSpectrum(); + xe133m.setNuclideName(XeNuclideName.XE_133m.getType()); + xe133m.setConc(analyseResult.Xe133m_con); + xe133m.setConcErr(analyseResult.Xe133m_uncer); + xe133m.setLc(analyseResult.LC_Xe133m); + xe133m.setMdc(analyseResult.MDC_Xe133m); + xe133m.setNidFlag(analyseResult.XE_133m_NID_FLAG); + xeResultsSpectrumList.add(xe133m); + GardsXeResultsSpectrum xe135 = new GardsXeResultsSpectrum(); + xe135.setNuclideName(XeNuclideName.XE_135.getType()); + xe135.setConc(analyseResult.Xe135_con); + xe135.setConcErr(analyseResult.Xe135_uncer); + xe135.setLc(analyseResult.LC_Xe135); + xe135.setMdc(analyseResult.MDC_Xe135); + xe135.setNidFlag(analyseResult.XE_135_NID_FLAG); + xeResultsSpectrumList.add(xe135); + xeMap.put("XeData", xeResultsSpectrumList); + //新计算得到的边界值 + if (CollectionUtils.isNotEmpty(analyseResult.S_ROI_B_Boundary_start)) { + List boundaryList = new LinkedList<>(); + for (int i=0; i boundaryList = new LinkedList<>(); + for (int i=0; i boundaryList = new LinkedList<>(); + for (int i=0; i> loadDataList, AnalyseData analyseData, String userName){ - List analyseResultList = new LinkedList<>(); + private List BetaGammaAnalyzeAllProcess(List> loadDataList, AnalyseData analyseData, String userName, String currentFileName){ + Map> analyseResultMap = new HashMap<>(); File sampleTmp = null; File gasTmp = null; File detTmp = null; @@ -2603,26 +2766,27 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { String sampleFilePath = m_loadData.get("sampleFilePath"); String gasFilePath = m_loadData.get("gasFilePath"); String detFilePath = m_loadData.get("detFilePath"); + //存储重新分析字段的实体类 SpectrumGroup spectrum_group = new SpectrumGroup(); + //声明一个map 缓存重新分析用到的数据 + Map map = new HashMap<>(); + //声明一个map 缓存xeData计算后的结果 + Map xeMap = new HashMap<>(); //从本地缓存获取beta gamma的数组 Cache> cache = betaCache.getBetaCache(); //根据qc文件名称-用户名-beta的方式获取beta的内容 Map betaMap = cache.getIfPresent(qcFileName + "-" + userName + "-beta"); - List betaList = new LinkedList<>(); List betaFittingPara = new LinkedList<>(); List betaFittingParaToUi = new LinkedList<>(); if (CollectionUtils.isNotEmpty(betaMap)) { - betaList = (List)betaMap.get("Series"); betaFittingPara = (List) betaMap.get("fittingPara"); betaFittingParaToUi = (List) betaMap.get("fittingParaToUi"); } //根据qc文件名称-用户名-gamma的方式获取gamma的内容 Map gammaMap = cache.getIfPresent(qcFileName + "-" + userName + "-gamma"); - List gammaList = new LinkedList<>(); List gammaFittingPara = new LinkedList<>(); List gammaFittingParaToUi = new LinkedList<>(); if (CollectionUtils.isNotEmpty(gammaMap)) { - gammaList = (List)gammaMap.get("Series"); gammaFittingPara = (List) gammaMap.get("fittingPara"); gammaFittingParaToUi = (List) gammaMap.get("fittingParaToUi"); } @@ -2638,6 +2802,21 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { bc2e.add(Double.valueOf(betaFittingPara.get(1))); bc2e.add(Double.valueOf(betaFittingPara.get(2))); spectrum_group.b_c2e = bc2e; + if (analyseData.isSampleData()) { + map.put("bBetaEnergyValidSample", true); + } else { + map.put("bBetaEnergyValidSample", false); + } + if (analyseData.isGasBgData()) { + map.put("bBetaEnergyValidGas", true); + } else { + map.put("bBetaEnergyValidGas", false); + } + if (analyseData.isDetBgData()) { + map.put("bBetaEnergyValidDet", true); + } else { + map.put("bBetaEnergyValidDet", false); + } } if (analyseData.isGammaEnergyValid()) { List geCal = new LinkedList<>(); @@ -2650,17 +2829,109 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { gc2e.add(Double.valueOf(gammaFittingPara.get(1))); gc2e.add(Double.valueOf(gammaFittingPara.get(2))); spectrum_group.g_c2e = gc2e; + if (analyseData.isSampleData()) { + map.put("bGammaEnergyValidSample", true); + } else { + map.put("bGammaEnergyValidSample", false); + } + if (analyseData.isGasBgData()) { + map.put("bGammaEnergyValidGas", true); + } else { + map.put("bGammaEnergyValidGas", false); + } + if (analyseData.isDetBgData()) { + map.put("bGammaEnergyValidDet", true); + } else { + map.put("bGammaEnergyValidDet", false); + } } spectrum_group.BgCalPara.bApplyNewCalicSample = analyseData.isSampleData(); spectrum_group.BgCalPara.bApplyNewCalicGasBg = analyseData.isGasBgData(); spectrum_group.BgCalPara.bApplyNewCalicDetBg = analyseData.isDetBgData(); spectrum_group.BgCalPara.bApplyNewCalicQc = analyseData.isQcData(); - sampleTmp = phdFileUtil.analyzeFile(sampleFilePath, sampleFileName); gasTmp = phdFileUtil.analyzeFile(gasFilePath, gasFileName); detTmp = phdFileUtil.analyzeFile(detFilePath, detFileName); BgAnalyseResult analyseResult = EnergySpectrumHandler.bgReAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath(), spectrum_group.BgCalPara); - analyseResultList.add(analyseResult); + //存入重新分析的参数 + map.put("reAnalyseParam", spectrum_group.BgCalPara); + //存入xeData数据 + List xeResultsSpectrumList = new LinkedList<>(); + GardsXeResultsSpectrum xe131m = new GardsXeResultsSpectrum(); + xe131m.setNuclideName(XeNuclideName.XE_131m.getType()); + xe131m.setConc(analyseResult.Xe131m_con); + xe131m.setConcErr(analyseResult.Xe131m_uncer); + xe131m.setLc(analyseResult.LC_Xe131m); + xe131m.setMdc(analyseResult.MDC_Xe131m); + xe131m.setNidFlag(analyseResult.XE_131m_NID_FLAG); + xeResultsSpectrumList.add(xe131m); + GardsXeResultsSpectrum xe133 = new GardsXeResultsSpectrum(); + xe133.setNuclideName(XeNuclideName.XE_133.getType()); + xe133.setConc(analyseResult.Xe133_con); + xe133.setConcErr(analyseResult.Xe133_uncer); + xe133.setLc(analyseResult.LC_Xe133); + xe133.setMdc(analyseResult.MDC_Xe133); + xe133.setNidFlag(analyseResult.XE_133_NID_FLAG); + xeResultsSpectrumList.add(xe133); + GardsXeResultsSpectrum xe133m = new GardsXeResultsSpectrum(); + xe133m.setNuclideName(XeNuclideName.XE_133m.getType()); + xe133m.setConc(analyseResult.Xe133m_con); + xe133m.setConcErr(analyseResult.Xe133m_uncer); + xe133m.setLc(analyseResult.LC_Xe133m); + xe133m.setMdc(analyseResult.MDC_Xe133m); + xe133m.setNidFlag(analyseResult.XE_133m_NID_FLAG); + xeResultsSpectrumList.add(xe133m); + GardsXeResultsSpectrum xe135 = new GardsXeResultsSpectrum(); + xe135.setNuclideName(XeNuclideName.XE_135.getType()); + xe135.setConc(analyseResult.Xe135_con); + xe135.setConcErr(analyseResult.Xe135_uncer); + xe135.setLc(analyseResult.LC_Xe135); + xe135.setMdc(analyseResult.MDC_Xe135); + xe135.setNidFlag(analyseResult.XE_135_NID_FLAG); + xeResultsSpectrumList.add(xe135); + xeMap.put("XeData", xeResultsSpectrumList); + //新计算得到的边界值 + if (CollectionUtils.isNotEmpty(analyseResult.S_ROI_B_Boundary_start)) { + List boundaryList = new LinkedList<>(); + for (int i=0; i boundaryList = new LinkedList<>(); + for (int i=0; i boundaryList = new LinkedList<>(); + for (int i=0; i map = new HashMap<>(); //拼接ftp上传临时文件路径 @@ -2694,6 +2966,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { File sampleTmp = null; File gasTmp = null; File detTmp = null; + BgCalibratePara BgCalPara = null; try { //如果sampleId不为空 说明数据来源数据库 查询出对应的文件路径 if (Objects.nonNull(sampleId) && StringUtils.isNotBlank(dbName)){ @@ -2725,9 +2998,18 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { return result; } map.put("sampleFileName", sampleFileName); - BgDataAnlyseResultIn resultIn = phdFileUtil.analyzeSpectrum(sampleTmp, gasTmp, detTmp, map); - if (Objects.nonNull(resultIn)) { - List xeDataList = getXeDataList(resultIn, sampleId, analysisID); + //获取本地缓存的数据信息 + Cache> cache = betaCache.getBetaCache(); + //根据key获取重新分析的参数 + Map reAnalyseParam = cache.getIfPresent(sampleFileName + "-" + userName + "-reAnalyseParam"); + //判断重新分析的参数信息是否为空 + if (CollectionUtils.isNotEmpty(reAnalyseParam)) { + BgCalPara = (BgCalibratePara) reAnalyseParam.get("reAnalyseParam"); + } + //调用分析方法 + phdFileUtil.analyzeSpectrum(sampleTmp, gasTmp, detTmp, BgCalPara, map); + if (CollectionUtils.isNotEmpty(map)) { + List xeDataList = (List) map.get("XeData"); if (CollectionUtils.isNotEmpty(xeDataList)){ for (GardsXeResultsSpectrum xeData:xeDataList) { Double conc = xeData.getConc(); @@ -2743,8 +3025,11 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { xeData.setNidFlag(1); } } - map.put("XeData", xeDataList); } + //更新分析后的缓存信息 + cache.put(sampleFileName + "-" + userName + "-xeData", map); + betaCache.setBetaCache(cache); + map.put("bProcessed", true); map.put("savedAnalysisResult", true); } } catch (Exception e) { @@ -2766,10 +3051,10 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } @Override - public Result analyseAllSpectrum(List dbNames, List sampleIds, List sampleFileNames, List gasFileNames, List detFileNames, HttpServletRequest request) { + public Result analyseAllSpectrum(List dbNames, List sampleIds, List sampleFileNames, List gasFileNames, List detFileNames, List qcFileNames, String currentFileName, HttpServletRequest request) { Result result = new Result(); String userName = JwtUtil.getUserNameByToken(request); - List> mapList = new LinkedList<>(); + Map> mapList = new HashMap<>(); File sampleTmp = null; File gasTmp = null; File detTmp = null; @@ -2781,6 +3066,8 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { String sampleFileName = sampleFileNames.get(i); String gasFileName = gasFileNames.get(i); String detFileName = detFileNames.get(i); + String qcFileName = qcFileNames.get(i); + BgCalibratePara BgCalPara = null; Map map = new HashMap<>(); //声明一个实体类获取数据库中文件路径 SpectrumFileRecord dbSpectrumFilePath = new SpectrumFileRecord(); @@ -2819,8 +3106,17 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { gasTmp = phdFileUtil.analyzeFile(gasPath, gasFileName); detTmp = phdFileUtil.analyzeFile(detPath, detFileName); map.put("sampleFileName", sampleFileName); - BgDataAnlyseResultIn resultIn = phdFileUtil.analyzeSpectrum(sampleTmp, gasTmp, detTmp, map); - List xeDataList = getXeDataList(resultIn, sampleId, analysisID); + //获取本地缓存的数据信息 + Cache> cache = betaCache.getBetaCache(); + //根据key获取重新分析的参数 + Map reAnalyseParam = cache.getIfPresent(sampleFileName + "-" + userName + "-reAnalyseParam"); + //判断重新分析的参数信息是否为空 + if (CollectionUtils.isNotEmpty(reAnalyseParam)) { + BgCalPara = (BgCalibratePara) reAnalyseParam.get("reAnalyseParam"); + } + //调用分析方法 + phdFileUtil.analyzeSpectrum(sampleTmp, gasTmp, detTmp, BgCalPara, map); + List xeDataList = (List) map.get("XeData"); if (CollectionUtils.isNotEmpty(xeDataList)){ for (GardsXeResultsSpectrum xeData:xeDataList) { Double conc = xeData.getConc(); @@ -2836,10 +3132,13 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { xeData.setNidFlag(1); } } - map.put("XeData", xeDataList); } + //更新分析后的缓存信息 + cache.put(sampleFileName + "-" + userName + "-xeData", map); + betaCache.setBetaCache(cache); + map.put("bProcessed", true); map.put("savedAnalysisResult", true); - mapList.add(map); + mapList.put(sampleFileName, map); } } } catch (Exception e) { @@ -2856,7 +3155,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } } result.setSuccess(true); - result.setResult(mapList); + result.setResult(mapList.get(currentFileName)); return result; } @@ -2886,6 +3185,36 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { gammaList = (List)gammaMap.get("Series"); gammaFittingPara = (List) gammaMap.get("fittingPara"); } + //根据qc文件名称-用户名-reAnalyseParam获取重新分析用到的参数 + Map reAnalyseParam = cache.getIfPresent(anlyseResultIn.getSampleFileName() + "-" + userName + "-reAnalyseParam"); + BgCalibratePara BgCalPara = null; + if (CollectionUtils.isNotEmpty(reAnalyseParam)) { + BgCalPara = (BgCalibratePara) reAnalyseParam.get("reAnalyseParam"); + Boolean bGammaEnergyValidSample = (Boolean) reAnalyseParam.get("bGammaEnergyValidSample"); + if (Objects.nonNull(bGammaEnergyValidSample)) { + anlyseResultIn.setBGammaEnergyValidSample(bGammaEnergyValidSample); + } + Boolean bBetaEnergyValidSample = (Boolean) reAnalyseParam.get("bBetaEnergyValidSample"); + if (Objects.nonNull(bBetaEnergyValidSample)) { + anlyseResultIn.setBBetaEnergyValidSample(bBetaEnergyValidSample); + } + Boolean bGammaEnergyValidGas = (Boolean) reAnalyseParam.get("bGammaEnergyValidGas"); + if (Objects.nonNull(bGammaEnergyValidGas)) { + anlyseResultIn.setBGammaEnergyValidGas(bGammaEnergyValidGas); + } + Boolean bBetaEnergyValidGas = (Boolean) reAnalyseParam.get("bBetaEnergyValidGas"); + if (Objects.nonNull(bBetaEnergyValidGas)) { + anlyseResultIn.setBBetaEnergyValidGas(bBetaEnergyValidGas); + } + Boolean bGammaEnergyValidDet = (Boolean) reAnalyseParam.get("bGammaEnergyValidDet"); + if (Objects.nonNull(bGammaEnergyValidDet)) { + anlyseResultIn.setBGammaEnergyValidDet(bGammaEnergyValidDet); + } + Boolean bBetaEnergyValidDet = (Boolean) reAnalyseParam.get("bBetaEnergyValidDet"); + if (Objects.nonNull(bBetaEnergyValidDet)) { + anlyseResultIn.setBBetaEnergyValidDet(bBetaEnergyValidDet); + } + } //获取当前时间作为人工分析开始时间 String beginDate = DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss"); //获取当前时间作为人工分析结束时间 @@ -2940,7 +3269,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { //处理数据 获取对应的channel/energy值 getChannelAndEnergy(anlyseResultIn, betaList, gammaList); //分析文件内容 - analyzePHDFile(anlyseResultIn, betaFittingPara, gammaFittingPara); + analyzePHDFile(anlyseResultIn, BgCalPara, betaFittingPara, gammaFittingPara); //处理文件名称 String sampleFilePathName = phdFileUtil.NameStandardBy(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName()); String gasFilePathName = phdFileUtil.NameStandardBy(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName()); @@ -3128,6 +3457,36 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { gammaFittingPara = (List) gammaMap.get("fittingPara"); gammaFittingParaToUi = (List) gammaMap.get("fittingParaToUi"); } + //根据qc文件名称-用户名-reAnalyseParam获取重新分析用到的参数 + Map reAnalyseParam = cache.getIfPresent(anlyseResultIn.getSampleFileName() + "-" + userName + "-reAnalyseParam"); + BgCalibratePara BgCalPara = null; + if (CollectionUtils.isNotEmpty(reAnalyseParam)) { + BgCalPara = (BgCalibratePara) reAnalyseParam.get("reAnalyseParam"); + Boolean bGammaEnergyValidSample = (Boolean) reAnalyseParam.get("bGammaEnergyValidSample"); + if (Objects.nonNull(bGammaEnergyValidSample)) { + anlyseResultIn.setBGammaEnergyValidSample(bGammaEnergyValidSample); + } + Boolean bBetaEnergyValidSample = (Boolean) reAnalyseParam.get("bBetaEnergyValidSample"); + if (Objects.nonNull(bBetaEnergyValidSample)) { + anlyseResultIn.setBBetaEnergyValidSample(bBetaEnergyValidSample); + } + Boolean bGammaEnergyValidGas = (Boolean) reAnalyseParam.get("bGammaEnergyValidGas"); + if (Objects.nonNull(bGammaEnergyValidGas)) { + anlyseResultIn.setBGammaEnergyValidGas(bGammaEnergyValidGas); + } + Boolean bBetaEnergyValidGas = (Boolean) reAnalyseParam.get("bBetaEnergyValidGas"); + if (Objects.nonNull(bBetaEnergyValidGas)) { + anlyseResultIn.setBBetaEnergyValidGas(bBetaEnergyValidGas); + } + Boolean bGammaEnergyValidDet = (Boolean) reAnalyseParam.get("bGammaEnergyValidDet"); + if (Objects.nonNull(bGammaEnergyValidDet)) { + anlyseResultIn.setBGammaEnergyValidDet(bGammaEnergyValidDet); + } + Boolean bBetaEnergyValidDet = (Boolean) reAnalyseParam.get("bBetaEnergyValidDet"); + if (Objects.nonNull(bBetaEnergyValidDet)) { + anlyseResultIn.setBBetaEnergyValidDet(bBetaEnergyValidDet); + } + } if (StringUtils.isNotBlank(anlyseResultIn.getDbName())) { Integer sampleId = spectrumAnalysisMapper.getSampleIdLikeFileName(anlyseResultIn.getSampleFileName()); Integer analysisID = null; @@ -3164,7 +3523,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { //处理数据 获取对应的channel/energy值 getChannelAndEnergy(anlyseResultIn, betaList, gammaList); //分析文件内容 - analyzeSavePHDFile(anlyseResultIn, betaFittingPara, gammaFittingPara, betaFittingParaToUi, gammaFittingParaToUi); + analyzeSavePHDFile(anlyseResultIn, BgCalPara, betaFittingPara, gammaFittingPara, betaFittingParaToUi, gammaFittingParaToUi); // 返回需要Save的数据 return anlyseResultIn; } @@ -3598,7 +3957,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } } - public void analyzeSavePHDFile(BgDataAnlyseResultIn anlyseResultIn,List betaFittingPara, List gammaFittingPara,List betaFittingParaToUi, List gammaFittingParaToUi) { + public void analyzeSavePHDFile(BgDataAnlyseResultIn anlyseResultIn, BgCalibratePara BgCalPara, List betaFittingPara, List gammaFittingPara,List betaFittingParaToUi, List gammaFittingParaToUi) { File sampleTmp = null; File gasTmp = null; File detTmp = null; @@ -3613,10 +3972,10 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { //Gamma Energy Calibration页面 如果点击过fitting使BGammaEnergyValid并且有勾选 //如果三个sampleData,GasData,DetData数据都是被勾选状态 则需要传递新的参数重新分析 否则不需要改变数据分析当前文件内容 BgAnalyseResult bgAnalyseResult = null; - if (anlyseResultIn.isCheckSample() && anlyseResultIn.isCheckGas() && anlyseResultIn.isCheckDet()) { + if (Objects.isNull(BgCalPara)) { bgAnalyseResult = EnergySpectrumHandler.bgAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath()); } else { - bgAnalyseResult = EnergySpectrumHandler.bgAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath()); + bgAnalyseResult = EnergySpectrumHandler.bgReAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath(), BgCalPara); } List xeResultsSpectrumList = new LinkedList<>(); GardsXeResults xe131m = new GardsXeResults(); @@ -3862,7 +4221,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } } - public void analyzePHDFile(BgDataAnlyseResultIn anlyseResultIn,List betaFittingPara, List gammaFittingPara) { + public void analyzePHDFile(BgDataAnlyseResultIn anlyseResultIn, BgCalibratePara BgCalPara, List betaFittingPara, List gammaFittingPara) { File sampleTmp = null; File gasTmp = null; File detTmp = null; @@ -3875,11 +4234,12 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { //Gamma Energy Calibration页面 如果点击过fitting使BGammaEnergyValid并且有勾选 //如果三个sampleData,GasData,DetData数据都是被勾选状态 则需要传递新的参数重新分析 否则不需要改变数据分析当前文件内容 BgAnalyseResult bgAnalyseResult = null; - if (anlyseResultIn.isCheckSample() && anlyseResultIn.isCheckGas() && anlyseResultIn.isCheckDet()) { + if (Objects.isNull(BgCalPara)) { bgAnalyseResult = EnergySpectrumHandler.bgAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath()); } else { - bgAnalyseResult = EnergySpectrumHandler.bgAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath()); + bgAnalyseResult = EnergySpectrumHandler.bgReAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath(), BgCalPara); } + //处理XeData的数据 List xeResultsSpectrumList = new LinkedList<>(); GardsXeResults xe131m = new GardsXeResults(); xe131m.setNuclideName(XeNuclideName.XE_131m.getType()); @@ -3914,6 +4274,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { xe135.setNidFlag(anlyseResultIn.getXe135Flag()); xeResultsSpectrumList.add(xe135); anlyseResultIn.setXeData(xeResultsSpectrumList); + //处理GammaCalibration的数据 List gammaCalibrationSpectrumList = new LinkedList<>(); if (anlyseResultIn.isBGammaEnergyValidSample()) { GardsCalibrationSpectrum gammaCalibrationS = new GardsCalibrationSpectrum(); @@ -3961,6 +4322,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { gammaCalibrationSpectrumList.add(gammaCalibrationD); } anlyseResultIn.setGammaCalibrationSpectrumList(gammaCalibrationSpectrumList); + //处理BetaCalibration数据 List betaCalibrationSpectrumList = new LinkedList<>(); if (anlyseResultIn.isBBetaEnergyValidSample()) { GardsCalibrationSpectrum betaCalibrationS = new GardsCalibrationSpectrum(); @@ -4008,6 +4370,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { betaCalibrationSpectrumList.add(betaCalibrationD); } anlyseResultIn.setBetaCalibrationSpectrumList(betaCalibrationSpectrumList); + //存储roiChannel数据 List roiChannelsSpectrumList = new LinkedList<>(); for (int i=0; i roiResultsSpectrumList = new LinkedList<>(); for (int i=0; i getCalibrationPairs(BgDataAnlyseResultIn anlyseResultIn, Integer sampleId, Integer gasId, Integer detId, Integer idAnalysis) { List calibrationPairsList = new LinkedList<>(); for (int i=0; i< anlyseResultIn.getB_channel_sample().size(); i++){ @@ -4440,58 +4803,56 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { file = File.createTempFile("betaGamma", null); //将ftp文件的输入流复制给临时文件 FileUtils.copyInputStreamToFile(inputStream, file); - } - //加载动态库 - //System.loadLibrary("ReadPHDFile"); - //读取文件内容 - EnergySpectrumStruct sourceData = EnergySpectrumHandler.getSourceData(file.getAbsolutePath()); - //获取文件中块名信息 - List readLines = getFileBlockList(file); - //查询台站id - Integer stationId = spectrumAnalysisMapper.getStationId(sourceData.site_code); - Integer detectorId = spectrumAnalysisMapper.getDetectorId(sourceData.detector_code); - if(Objects.isNull(stationId) || Objects.isNull(detectorId)) { - String error = "get station_id or detect_id error"; - return false; - } - //新增Gards_Sample_Data表数据 - sampleDataSpectrumService.saveSampleData(sourceData, stationId, detectorId, filePathName, readLines); - //获取sampleId - Integer sampleId = spectrumAnalysisMapper.getSampleId(filePathName); - //存储Gards_Sample_Aux表数据 - sampleAuxSpectrumService.saveSampleAux(sourceData, sampleId, readLines); - //判断文件是否包含Comment块 新增Gards_Description数据 - if (readLines.contains(SampleFileHeader.COMMENT.getMessage())){ - sampleDescriptionSpectrumService.saveSampleDescription(sourceData, sampleId); - } - //判断文件是否包含Certificate块 新增Gards_Sample_Cert数据 - if (readLines.contains(SampleFileHeader.CERTIFICATE.getMessage())){ - sampleCertSpectrumService.saveSampleCert(sourceData, sampleId); - sampleCertLineSpectrumService.saveSampleCertLine(sourceData, sampleId); - } - //新增Gards_Calibration_Pairs_Orig数据 - calibrationPairsOrigSpectrumService.saveGardsCalibrationPairsOrig(sourceData, sampleId, readLines); - //判断文件是否包含b-gEfficiency块 新增Gards_Sample_Cert数据 - if (readLines.contains(SampleFileHeader.BGEFFICIENCY.getMessage())){ - bgEfficiencyPairsSpectrumService.saveBgEfficiencyPairs(sourceData, sampleId); - } - //判断文件是否包含TotalEff块 新增Gards_Sample_Cert数据 - if (readLines.contains(SampleFileHeader.TOTALEFF.getMessage())){ - totalEfficiencyPairsSpectrumService.saveTotalEfficiencyPairs(sourceData, sampleId); - } - //判断文件是否包含Ratios块 新增Gards_Sample_Ratios数据 - if (readLines.contains(SampleFileHeader.RATIOS.getMessage())){ - sampleRatiosSpectrumService.saveSampleRatios(sourceData, sampleId); - } - //判断是否包含ROI_Limits块 新增Gards_ROI_Limits数据 - if (readLines.contains(SampleFileHeader.ROILIMITS.getMessage())){ - roiLimitsSpectrumService.saveRoiLimits(sourceData, sampleId); - } - //新增Gards_Spectrum数据 - spectrumService.saveSpectrum(sourceData, sampleId, readLines, filePathName); - //判断是否包含Histogram块 新增Gards_Histogram数据 - if (readLines.contains(SampleFileHeader.HISTOGRAM.getMessage())){ - histogramService.saveHistogram(sourceData, sampleId, filePathName); + //读取文件内容 + EnergySpectrumStruct sourceData = EnergySpectrumHandler.getSourceData(file.getAbsolutePath()); + //获取文件中块名信息 + List readLines = getFileBlockList(file); + //查询台站id + Integer stationId = spectrumAnalysisMapper.getStationId(sourceData.site_code); + Integer detectorId = spectrumAnalysisMapper.getDetectorId(sourceData.detector_code); + if(Objects.isNull(stationId) || Objects.isNull(detectorId)) { + String error = "get station_id or detect_id error"; + return false; + } + //新增Gards_Sample_Data表数据 + sampleDataSpectrumService.saveSampleData(sourceData, stationId, detectorId, filePathName, readLines); + //获取sampleId + Integer sampleId = spectrumAnalysisMapper.getSampleId(filePathName); + //存储Gards_Sample_Aux表数据 + sampleAuxSpectrumService.saveSampleAux(sourceData, sampleId, readLines); + //判断文件是否包含Comment块 新增Gards_Description数据 + if (readLines.contains(SampleFileHeader.COMMENT.getMessage())){ + sampleDescriptionSpectrumService.saveSampleDescription(sourceData, sampleId); + } + //判断文件是否包含Certificate块 新增Gards_Sample_Cert数据 + if (readLines.contains(SampleFileHeader.CERTIFICATE.getMessage())){ + sampleCertSpectrumService.saveSampleCert(sourceData, sampleId); + sampleCertLineSpectrumService.saveSampleCertLine(sourceData, sampleId); + } + //新增Gards_Calibration_Pairs_Orig数据 + calibrationPairsOrigSpectrumService.saveGardsCalibrationPairsOrig(sourceData, sampleId, readLines); + //判断文件是否包含b-gEfficiency块 新增Gards_Sample_Cert数据 + if (readLines.contains(SampleFileHeader.BGEFFICIENCY.getMessage())){ + bgEfficiencyPairsSpectrumService.saveBgEfficiencyPairs(sourceData, sampleId); + } + //判断文件是否包含TotalEff块 新增Gards_Sample_Cert数据 + if (readLines.contains(SampleFileHeader.TOTALEFF.getMessage())){ + totalEfficiencyPairsSpectrumService.saveTotalEfficiencyPairs(sourceData, sampleId); + } + //判断文件是否包含Ratios块 新增Gards_Sample_Ratios数据 + if (readLines.contains(SampleFileHeader.RATIOS.getMessage())){ + sampleRatiosSpectrumService.saveSampleRatios(sourceData, sampleId); + } + //判断是否包含ROI_Limits块 新增Gards_ROI_Limits数据 + if (readLines.contains(SampleFileHeader.ROILIMITS.getMessage())){ + roiLimitsSpectrumService.saveRoiLimits(sourceData, sampleId); + } + //新增Gards_Spectrum数据 + spectrumService.saveSpectrum(sourceData, sampleId, readLines, filePathName); + //判断是否包含Histogram块 新增Gards_Histogram数据 + if (readLines.contains(SampleFileHeader.HISTOGRAM.getMessage())){ + histogramService.saveHistogram(sourceData, sampleId, filePathName); + } } return true; } catch (IOException e) { diff --git a/jeecg-server-cloud/armd-abnormal-alarm-start/src/main/resources/logback-spring.xml b/jeecg-server-cloud/armd-abnormal-alarm-start/src/main/resources/logback-spring.xml index 60d4c7df..82198bd8 100644 --- a/jeecg-server-cloud/armd-abnormal-alarm-start/src/main/resources/logback-spring.xml +++ b/jeecg-server-cloud/armd-abnormal-alarm-start/src/main/resources/logback-spring.xml @@ -17,7 +17,7 @@ - ${LOG_HOME}/jeecg-system-%d{yyyy-MM-dd}.%i.log + ${LOG_HOME}/abnormal-alarm-%d{yyyy-MM-dd}.%i.log 30 10MB @@ -39,7 +39,7 @@ %p%d%msg%M%F{32}%L - ${LOG_HOME}/error-log.html + ${LOG_HOME}/abnormal-alarm-error.html @@ -47,7 +47,7 @@ - ${LOG_HOME}/jeecg-system-%d{yyyy-MM-dd}.%i.html + ${LOG_HOME}/abnormal-alarm-%d{yyyy-MM-dd}.%i.html 30 10MB diff --git a/jeecg-server-cloud/armd-auto-process-start/src/main/resources/logback-spring.xml b/jeecg-server-cloud/armd-auto-process-start/src/main/resources/logback-spring.xml index 60d4c7df..79dcfb72 100644 --- a/jeecg-server-cloud/armd-auto-process-start/src/main/resources/logback-spring.xml +++ b/jeecg-server-cloud/armd-auto-process-start/src/main/resources/logback-spring.xml @@ -17,7 +17,7 @@ - ${LOG_HOME}/jeecg-system-%d{yyyy-MM-dd}.%i.log + ${LOG_HOME}/auto-process-%d{yyyy-MM-dd}.%i.log 30 10MB @@ -39,7 +39,7 @@ %p%d%msg%M%F{32}%L - ${LOG_HOME}/error-log.html + ${LOG_HOME}/auto-process-error.html @@ -47,7 +47,7 @@ - ${LOG_HOME}/jeecg-system-%d{yyyy-MM-dd}.%i.html + ${LOG_HOME}/auto-process-%d{yyyy-MM-dd}.%i.html 30 10MB diff --git a/jeecg-server-cloud/armd-cloud-gateway/src/main/resources/logback-spring.xml b/jeecg-server-cloud/armd-cloud-gateway/src/main/resources/logback-spring.xml index 50b9921c..50e7c335 100644 --- a/jeecg-server-cloud/armd-cloud-gateway/src/main/resources/logback-spring.xml +++ b/jeecg-server-cloud/armd-cloud-gateway/src/main/resources/logback-spring.xml @@ -17,7 +17,7 @@ - ${LOG_HOME}/jeecg-gateway-%d{yyyy-MM-dd}.%i.log + ${LOG_HOME}/gateway-%d{yyyy-MM-dd}.%i.log 30 10MB diff --git a/jeecg-server-cloud/armd-log-manage-start/src/main/resources/logback-spring.xml b/jeecg-server-cloud/armd-log-manage-start/src/main/resources/logback-spring.xml index 60d4c7df..092efa9d 100644 --- a/jeecg-server-cloud/armd-log-manage-start/src/main/resources/logback-spring.xml +++ b/jeecg-server-cloud/armd-log-manage-start/src/main/resources/logback-spring.xml @@ -17,7 +17,7 @@ - ${LOG_HOME}/jeecg-system-%d{yyyy-MM-dd}.%i.log + ${LOG_HOME}/log-manage-%d{yyyy-MM-dd}.%i.log 30 10MB @@ -39,7 +39,7 @@ %p%d%msg%M%F{32}%L - ${LOG_HOME}/error-log.html + ${LOG_HOME}/log-manage-error.html @@ -47,7 +47,7 @@ - ${LOG_HOME}/jeecg-system-%d{yyyy-MM-dd}.%i.html + ${LOG_HOME}/log-manage-%d{yyyy-MM-dd}.%i.html 30 10MB diff --git a/jeecg-server-cloud/armd-spectrum-analysis-start/src/main/resources/logback-spring.xml b/jeecg-server-cloud/armd-spectrum-analysis-start/src/main/resources/logback-spring.xml index 60d4c7df..c6e9bb49 100644 --- a/jeecg-server-cloud/armd-spectrum-analysis-start/src/main/resources/logback-spring.xml +++ b/jeecg-server-cloud/armd-spectrum-analysis-start/src/main/resources/logback-spring.xml @@ -17,7 +17,7 @@ - ${LOG_HOME}/jeecg-system-%d{yyyy-MM-dd}.%i.log + ${LOG_HOME}/spectrum-analysis-%d{yyyy-MM-dd}.%i.log 30 10MB @@ -39,7 +39,7 @@ %p%d%msg%M%F{32}%L - ${LOG_HOME}/error-log.html + ${LOG_HOME}/spectrum-analysis-error.html @@ -47,7 +47,7 @@ - ${LOG_HOME}/jeecg-system-%d{yyyy-MM-dd}.%i.html + ${LOG_HOME}/spectrum-analysis-%d{yyyy-MM-dd}.%i.html 30 10MB diff --git a/jeecg-server-cloud/armd-station-operation-start/src/main/resources/logback-spring.xml b/jeecg-server-cloud/armd-station-operation-start/src/main/resources/logback-spring.xml index 60d4c7df..e6cd4af6 100644 --- a/jeecg-server-cloud/armd-station-operation-start/src/main/resources/logback-spring.xml +++ b/jeecg-server-cloud/armd-station-operation-start/src/main/resources/logback-spring.xml @@ -17,7 +17,7 @@ - ${LOG_HOME}/jeecg-system-%d{yyyy-MM-dd}.%i.log + ${LOG_HOME}/station-operation-%d{yyyy-MM-dd}.%i.log 30 10MB @@ -39,7 +39,7 @@ %p%d%msg%M%F{32}%L - ${LOG_HOME}/error-log.html + ${LOG_HOME}/station-operation-error.html @@ -47,7 +47,7 @@ - ${LOG_HOME}/jeecg-system-%d{yyyy-MM-dd}.%i.html + ${LOG_HOME}/station-operation-%d{yyyy-MM-dd}.%i.html 30 10MB diff --git a/jeecg-server-cloud/armd-system-cloud-start/src/main/resources/logback-spring.xml b/jeecg-server-cloud/armd-system-cloud-start/src/main/resources/logback-spring.xml index 60d4c7df..e2964448 100644 --- a/jeecg-server-cloud/armd-system-cloud-start/src/main/resources/logback-spring.xml +++ b/jeecg-server-cloud/armd-system-cloud-start/src/main/resources/logback-spring.xml @@ -17,7 +17,7 @@ - ${LOG_HOME}/jeecg-system-%d{yyyy-MM-dd}.%i.log + ${LOG_HOME}/system-cloud-%d{yyyy-MM-dd}.%i.log 30 10MB @@ -39,7 +39,7 @@ %p%d%msg%M%F{32}%L - ${LOG_HOME}/error-log.html + ${LOG_HOME}/system-cloud-error.html @@ -47,7 +47,7 @@ - ${LOG_HOME}/jeecg-system-%d{yyyy-MM-dd}.%i.html + ${LOG_HOME}/system-cloud-%d{yyyy-MM-dd}.%i.html 30 10MB diff --git a/jeecg-server-cloud/armd-web-statistics-start/src/main/resources/logback-spring.xml b/jeecg-server-cloud/armd-web-statistics-start/src/main/resources/logback-spring.xml index 60d4c7df..89527ce4 100644 --- a/jeecg-server-cloud/armd-web-statistics-start/src/main/resources/logback-spring.xml +++ b/jeecg-server-cloud/armd-web-statistics-start/src/main/resources/logback-spring.xml @@ -17,7 +17,7 @@ - ${LOG_HOME}/jeecg-system-%d{yyyy-MM-dd}.%i.log + ${LOG_HOME}/web-statistics-%d{yyyy-MM-dd}.%i.log 30 10MB @@ -39,7 +39,7 @@ %p%d%msg%M%F{32}%L - ${LOG_HOME}/error-log.html + ${LOG_HOME}/web-statistics-error.html @@ -47,7 +47,7 @@ - ${LOG_HOME}/jeecg-system-%d{yyyy-MM-dd}.%i.html + ${LOG_HOME}/web-statistics-%d{yyyy-MM-dd}.%i.html 30 10MB