diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/ParameterProperties.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/ParameterProperties.java index a54db57d..255ea5f6 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/ParameterProperties.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/ParameterProperties.java @@ -11,6 +11,11 @@ import java.io.Serializable; @ConfigurationProperties(prefix = "parameter") public class ParameterProperties implements Serializable { + /** + * 分析后生成的日志文件路径 + */ + private String logFilePath; + /** * 算法计算需要用到的文件存储路径 */ diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/AnalyseData.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/AnalyseData.java index e025a9af..2f54a6ab 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/AnalyseData.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/AnalyseData.java @@ -12,6 +12,8 @@ public class AnalyseData implements Serializable { private String currentFileName; + private String currentQCFileName; + private boolean sampleData; private boolean gasBgData; diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/PHDFileUtil.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/PHDFileUtil.java index 4d328ec3..0310e566 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/PHDFileUtil.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/PHDFileUtil.java @@ -8,7 +8,9 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.net.ftp.FTP; import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPFile; +import org.jeecg.common.properties.ParameterProperties; import org.jeecg.common.properties.SpectrumPathProperties; +import org.jeecg.modules.base.abstracts.AbstractLogOrReport; import org.jeecg.modules.base.entity.rnman.GardsXeResults; import org.jeecg.modules.base.enums.DataType; import org.jeecg.modules.base.enums.DataTypeAbbr; @@ -26,21 +28,20 @@ import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; +import java.io.*; import java.text.ParseException; import java.util.*; import java.util.stream.Collectors; @Component -public class PHDFileUtil { +public class PHDFileUtil extends AbstractLogOrReport { @Autowired private FTPUtil ftpUtil; @Autowired private NameStandUtil nameStandUtil; + @Autowired + private ParameterProperties parameterProperties; public Map getSourceData(String filePath, Integer sampleId, String status) { EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(filePath); @@ -699,6 +700,12 @@ public class PHDFileUtil { } else { analyseResult = EnergySpectrumHandler.bgReAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath(), BgCalPara); } + EnergySpectrumStruct sample = analyzeFileSourceData(sampleTmp); + EnergySpectrumStruct gas = analyzeFileSourceData(gasTmp); + EnergySpectrumStruct det = analyzeFileSourceData(detTmp); + String sampleFileName = (String) map.get("sampleFileName"); + String logName = sampleFileName.replace("PHD", "log"); + OutPutRnLog(analyseResult, sample, gas, det, logName); //需要返回到前端的XeData数据 List xeResultsSpectrumList = new LinkedList<>(); //存入计算后得到的xeData数据 @@ -1029,1304 +1036,630 @@ public class PHDFileUtil { } map.put("QCBoundary", boundaryList); } - //todo---待实现的BG日志内容 -// public void OutPutRnLog(BgAnalyseResult bgAnalyseResult) { -// String logName = ""; -// BgSample sample = bgwork.GetSampleUseData(); -// BgGas gas = bgwork.GetGasUseData(); -// BgDetbgr detBgr = bgwork.GetDetbgrUseData(); -// BgAllGenerate allGenerate = bgwork.GetAllValue(); -// allGenerate.bProcessed = true; -// -// QVector logAtributeData; -// LOGFORMCREATE::AttributeContext logAtributeItem; -// -// QVector temp; -// for(int pos=0; pos s_channel = sample.s_e_c.b_e_c.channel; -// temp.clear(); -// for(int pos=0;pos s_energy = sample.s_e_c.b_e_c.energy; -// temp.clear(); -// for(int pos=0; pos s_uncertainty = sample.s_e_c.b_e_c.uncertainty; -// temp.clear(); -// for(int pos=0;pos s_gchannel = sample.s_e_c.g_e_c.channel; -// temp.clear(); -// for(int pos=0;pos s_genergy = sample.s_e_c.g_e_c.energy; -// temp.clear(); -// for(int pos=0;pos s_guncertainty = sample.s_e_c.g_e_c.uncertainty; -// temp.clear(); -// for(int pos=0;pos sample_gChannel = sample.s_e_c.g_e_c.channel; -// temp.clear(); -// for(int pos=0;pos sample_genergy = sample.s_e_c.g_e_c.energy; -// temp.clear(); -// for(int pos=0;pos sample_gerror = sample.s_e_c.g_e_c.uncertainty; -// temp.clear(); -// for(int pos=0;pos d_bchannel = detBgr.d_e_c.b_e_c.channel; -// temp.clear(); -// for(int pos=0;pos d_benergy = detBgr.d_e_c.b_e_c.energy; -// temp.clear(); -// for(int pos=0;pos d_buncertainty = detBgr.d_e_c.b_e_c.uncertainty; -// temp.clear(); -// for(int pos=0;pos deta_bChannel = detBgr.d_e_c.b_e_c.channel; -// temp.clear(); -// for(int pos=0;pos deta_benergy = detBgr.d_e_c.b_e_c.energy; -// temp.clear(); -// for(int pos=0;pos deta_berror = detBgr.d_e_c.b_e_c.uncertainty; -// temp.clear(); -// for(int pos=0;pos d_gchannel = detBgr.d_e_c.g_e_c.channel; -// temp.clear(); -// for(int pos=0;pos d_genergy = detBgr.d_e_c.g_e_c.energy; -// temp.clear(); -// for(int pos=0;pos d_guncertainty = detBgr.d_e_c.g_e_c.uncertainty; -// temp.clear(); -// for(int pos=0;pos deta_gChannel = detBgr.d_e_c.g_e_c.channel; -// temp.clear(); -// for( int pos=0; pos deta_genergy = detBgr.d_e_c.g_e_c.energy; -// temp.clear(); -// for(int pos=0;pos deta_gerror = detBgr.d_e_c.g_e_c.uncertainty; -// temp.clear(); -// for(int pos=0;pos gas_bChannel = gas.g_e_c.b_e_c.channel; -// temp.clear(); -// for(int pos=0;pos gas_benergy = gas.g_e_c.b_e_c.energy; -// temp.clear(); -// for(int pos=0;pos gas_berror = gas.g_e_c.b_e_c.uncertainty; -// temp.clear(); -// for(int pos=0;pos g_gchannel = gas.g_e_c.g_e_c.channel; -// temp.clear(); -// for(int pos=0; pos g_genergy = gas.g_e_c.g_e_c.energy; -// temp.clear(); -// for(int pos=0;pos g_guncertainty = gas.g_e_c.g_e_c.uncertainty; -// temp.clear(); -// for(int pos=0;pos gas_gChannel = gas.g_e_c.g_e_c.channel; -// temp.clear(); -// for(int pos=0;pos gas_genergy = gas.g_e_c.g_e_c.energy; -// temp.clear(); -// for(int pos=0;pos gas_gerror = gas.g_e_c.g_e_c.uncertainty; -// temp.clear(); -// for(int pos=0;pos logAtributeData_roi_c; -// LOGFORMCREATE::AttributeContext logAtributeItem_roi_c; -// -// QVector report_limit_roi; -// QVector report_limit_beta; -// QVector report_limit_gama; -// -// temp.clear(); -// for(int pos=1;pos<=sample.s_limit.ROI_B_start_x1.size();pos++) -// { -// temp.append(QString::number(pos)); -// } -// -// logAtributeItem_roi_c.context.clear(); -// logAtributeItem_roi_c.atrribute= QLatin1String("ROI"); -// logAtributeItem_roi_c.unit = QLatin1String(""); -// logAtributeItem_roi_c.context = temp; -// logAtributeData_roi_c.append(logAtributeItem_roi_c); -// report_limit_roi = temp; -// temp.clear(); -// for(int pos=0;pos begin; -// QVector end; -// QVector result; -// QString flag; -// begin.clear(); -// end.clear(); -// result.clear(); -// -// begin = temp; -// temp.clear(); -// for(int pos=0;pos e_c; -// QVector c_e; -// -// //报告使用 -// QVector report_b_e_c; -// QVector report_b_c_e; -// QVector report_g_e_c; -// QVector report_g_c_e; -// QVector report_s_b_boundary; -// QVector report_s_g_boundary; -// QVector report_s_boundary_roi; -// for(int pos=0;pos e_c; -// // QVector c_e; -// e_c.clear(); -// c_e.clear(); -// -// //报告使用 -// QVector report_g_b_e_c; -// QVector report_g_b_c_e; -// -// QVector report_g_g_e_c; -// QVector report_g_g_c_e; -// -// QVector report_g_b_boundary; -// QVector report_g_g_boundary; -// QVector report_g_boundary_roi; -// -// for(int pos=0;pos report_d_b_e_c; -// QVector report_d_b_c_e; -// QVector report_d_g_e_c; -// QVector report_d_g_c_e; -// QVector report_d_b_boundary; -// QVector report_d_g_boundary; -// QVector report_d_boundary_roi; -// for(int pos=0;posallGenerate.BgOther.MDCPara.MDC_Xe131m) -// { -// NID_FLAG=1; -// } -// NID_FLAG=0; -// if(allGenerate.BgOther.XeConUncer.Xe133_con>allGenerate.BgOther.MDCPara.MDC_Xe133) -// { -// NID_FLAG=1; -// } -// NID_FLAG=0; -// if(allGenerate.BgOther.XeConUncer.Xe133m_con>allGenerate.BgOther.MDCPara.MDC_Xe133m) -// { -// NID_FLAG=1; -// } -// NID_FLAG=0; -// if(allGenerate.BgOther.XeConUncer.Xe135_con>allGenerate.BgOther.MDCPara.MDC_Xe135) -// { -// NID_FLAG=1; -// } -// -// //报告使用 -// QVector report_gross_roi; -// QVector report_gross_sample; -// QVector report_gross_gasbkgnd; -// QVector report_gross_detbkgnd; -// -// QVector ROI_ID=temp; -// logAtributeData.clear(); -// logAtributeItem.context.clear(); -// logAtributeItem.atrribute= QLatin1String("ROI"); -// logAtributeItem.unit = QLatin1String(""); -// logAtributeItem.context = ROI_ID; -// logAtributeData.append(logAtributeItem); -// -// report_gross_roi = ROI_ID; -// -// QVector LC; -// temp.clear(); -// temp.append(UNASSIGNFLAG); -// for(int pos=0;pos netTemp; -// QVector netErrTemp; -// QVector netBq; -// netTemp.append(UNASSIGNFLAG); -// netErrTemp.append(UNASSIGNFLAG); -// netBq.append(UNASSIGNFLAG); -// -// if ( allGenerate.bProcessed ) -// { -// for(int pos=6;pos concTemp; -// QVector concErrTemp; -// concTemp.append(UNASSIGNFLAG); -// concErrTemp.append(UNASSIGNFLAG); -// -// if ( allGenerate.bProcessed ) -// { -// for(int pos=4;pos dNidFlag; -// dNidFlag.append(UNASSIGNFLAG); -// temp.clear(); -// temp.append(UNASSIGNFLAG); -// for(int pos=0;pos dTemp) -// { -// dNidFlag.append(QLatin1String("1")); -// } -// else -// { -// dNidFlag.append(QLatin1String("0")); -// } -// -// } -// } -// -// QVector MDC; -// MDC=temp; -// //Net counts and Lc per ROI... -// //报告使用 -// QVector report_net_counts_roi; -// QVector report_net_counts_netcount; -// QVector report_net_counts_lc; -// logAtributeData.clear(); -// logAtributeItem.context.clear(); -// logAtributeItem.atrribute= QLatin1String("ROI"); -// logAtributeItem.unit = QLatin1String(""); -// logAtributeItem.context = ROI_ID; -// logAtributeData.append(logAtributeItem); -// report_net_counts_roi = ROI_ID; -// flag = QLatin1String(" +/- "); -// begin.clear(); -// if(netTemp.size() == netBq.size()) -// { -// for(int pos=0;pos report_concentration_roi; -// QVector report_concentration_conc; -// QVector report_concentration_lc; -// QVector report_concentration_mdc; -// logAtributeData.clear(); -// logAtributeItem.context.clear(); -// logAtributeItem.atrribute= QLatin1String("ROI"); -// logAtributeItem.unit = QLatin1String(""); -// logAtributeItem.context = ROI_ID; -// logAtributeData.append(logAtributeItem); -// report_concentration_roi= ROI_ID; -// -// flag = QLatin1String(" +/- "); -// begin.clear(); -// if(concTemp.size() == concErrTemp.size()) -// { -// for(int pos=0;pos report_result_nulclide; -// QVector report_result_conc; -// QVector report_result_uncertainty; -// QVector report_result_MDC; -// QVector report_result_NID_flag; -// -// flag = QLatin1String(" +/- "); -// QVector title_mdc; -// title_mdc< conc_mdc; -// conc_mdc< lc_isotope; -// lc_isotope< mdc_isotope; -// mdc_isotope< nidFlag; -// if(allGenerate.BgOther.XeConUncer.Xe135_con>allGenerate.BgOther.MDCPara.MDC_Xe135) -// { -// nidFlag<allGenerate.BgOther.MDCPara.MDC_Xe131m) -// { -// nidFlag<allGenerate.BgOther.MDCPara.MDC_Xe133m) -// { -// nidFlag<allGenerate.BgOther.MDCPara.MDC_Xe133) -// { -// nidFlag< 0) { + lcCts = String.valueOf(bgAnalyseResult.LC_CTS.get(i-1)); + } + out.append(rowFormat(dataFormat9, roi, net, netErr, lcCts)); + //换行 + out.append(System.lineSeparator()); + //换行 + out.append(System.lineSeparator()); + } + //换行 + out.append(System.lineSeparator()); + //换行 + out.append(System.lineSeparator()); + //第六十四行数据 + out.append(titleFormat("Concentration and MDC per ROI%s", 5, StringPool.DOT)); + //换行 + out.append(System.lineSeparator()); + //换行 + out.append(System.lineSeparator()); + //第六十五行数据 + String dataFormat10 = "ROI : %-8sConc : %-2s+/- %-2smBq/m3 LC : %-2smBq/m3 MDC : %-2smBq/m3 "; + for (int i = 0; i < bgAnalyseResult.ROI.size(); i++) { + String roi = String.valueOf(bgAnalyseResult.ROI.get(i)); + String conc = String.valueOf(bgAnalyseResult.ROI_con_uncer.get(i)); + String concErr = String.valueOf(bgAnalyseResult.ROI_con_uncer_err.get(i)); + String lc = "0"; + if (i > 0) { + lc = String.valueOf(bgAnalyseResult.LC.get(i-1)); + } + String mdc = "0"; + if (i > 0) { + mdc = String.valueOf(bgAnalyseResult.MDC.get(i-1)); + } + out.append(rowFormat(dataFormat10, roi, conc, concErr, lc, mdc)); + //换行 + out.append(System.lineSeparator()); + //换行 + out.append(System.lineSeparator()); + } + //换行 + out.append(System.lineSeparator()); + //换行 + out.append(System.lineSeparator()); + //第六十六行信息 + out.append(titleFormat("Concentration and MDC per isotope%s", 5, StringPool.DOT)); + //换行 + out.append(System.lineSeparator()); + //换行 + out.append(System.lineSeparator()); + //第六十七行数据 + out.append(rowFormat("XE-135 Conc : %-9s+/- %-8smBq/m3 LC : %-9smBq/m3 MDC : %-9smBq/m3 Nid flag : %-6s", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.Xe135_con)), + NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.Xe135_uncer)), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.LC_Xe135)), + NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.MDC_Xe135)), String.valueOf(bgAnalyseResult.XE_135_NID_FLAG))); + //换行 + out.append(System.lineSeparator()); + //换行 + out.append(System.lineSeparator()); + //第六十八行数据 + out.append(rowFormat("XE-131M Conc : %-9s+/- %-8smBq/m3 LC : %-9smBq/m3 MDC : %-9smBq/m3 Nid flag : %-6s", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.Xe131m_con)), + NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.Xe131m_uncer)), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.LC_Xe131m)), + NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.MDC_Xe131m)), String.valueOf(bgAnalyseResult.XE_131m_NID_FLAG))); + //换行 + out.append(System.lineSeparator()); + //换行 + out.append(System.lineSeparator()); + //第六十九行数据 + out.append(rowFormat("XE-133 Conc : %-9s+/- %-8smBq/m3 LC : %-9smBq/m3 MDC : %-9smBq/m3 Nid flag : %-6s", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.Xe133_con)), + NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.Xe133_uncer)), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.LC_Xe133)), + NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.MDC_Xe133)), String.valueOf(bgAnalyseResult.XE_133_NID_FLAG))); + //换行 + out.append(System.lineSeparator()); + //换行 + out.append(System.lineSeparator()); + //第七十行数据 + out.append(rowFormat("XE-133M Conc : %-9s+/- %-8smBq/m3 LC : %-9smBq/m3 MDC : %-9smBq/m3 Nid flag : %-6s", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.Xe133m_con)), + NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.Xe133m_uncer)), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.LC_Xe133m)), + NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.MDC_Xe133m)), String.valueOf(bgAnalyseResult.XE_133m_NID_FLAG))); + //换行 + out.append(System.lineSeparator()); + //换行 + out.append(System.lineSeparator()); + //第七十一行信息 + out.append(titleFormat("%s NCC analysis finished %s", 40, StringPool.DOT, StringPool.DOT)); + //换行 + out.append(System.lineSeparator()); + //换行 + out.append(System.lineSeparator()); + //第七十二行信息 + out.append(titleFormat("%s Sample Analyse Successfully at %s %s", 25, StringPool.DASH, DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss"), StringPool.DASH)); + //换行 + out.append(System.lineSeparator()); + //换行 + out.append(System.lineSeparator()); + } + BufferedWriter bufferedWriter = null; + try { + bufferedWriter = new BufferedWriter(new FileWriter(logFile, true)); + bufferedWriter.write(out.toString()); + } catch (IOException e) { + throw new RuntimeException(e); + } finally { + try { + if (Objects.nonNull(bufferedWriter)) { + bufferedWriter.close(); + } + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } } 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 6b85d576..6d53b4d0 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 @@ -216,8 +216,8 @@ public class SpectrumAnalysesController { @GetMapping("viewBGLogViewer") @ApiOperation(value = "查看BG Log Viewer数据", notes = "查看BG Log Viewer数据") - public Result viewBGLogViewer(String dbName, Integer sampleId, String sampleFileName, String gasFileName, String detFileName, String qcFileName, HttpServletRequest request) { - return null; + public void viewBGLogViewer(String sampleFileName, HttpServletResponse response) { + spectrumAnalysisService.viewBGLogViewer(sampleFileName, response); } @PostMapping("saveToDB") 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 6655d250..4d9cd1f9 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 @@ -76,7 +76,7 @@ public interface ISpectrumAnalysisService { void viewAutomaticAnalysisLog(Integer sampleId, HttpServletResponse response); - Result viewBGLogViewer(String dbName, Integer sampleId, String sampleFileName, String gasFileName, String detFileName, String qcFileName, HttpServletRequest request); + void viewBGLogViewer(String sampleFileName, HttpServletResponse response); 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 53ecda17..516cd170 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 @@ -2519,6 +2519,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi try { // 设置响应类型 response.setContentType("application/octet-stream"); + response.setHeader("Access-Control-Expose-Headers", "Content-Disposition"); // 解决中文不能生成文件 response.setHeader("Content-Disposition", "attachment; fileName=" + URLEncoder.encode("EnergyCalibration.Ent", "UTF-8")); fos = response.getOutputStream(); @@ -2792,6 +2793,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi try { // 设置响应类型 response.setContentType("application/octet-stream"); + response.setHeader("Access-Control-Expose-Headers", "Content-Disposition"); // 解决中文不能生成文件 response.setHeader("Content-Disposition", "attachment; fileName=" + URLEncoder.encode("ResolutionCalibration.Ent", "UTF-8")); fos = response.getOutputStream(); @@ -3075,6 +3077,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi try { // 设置响应类型 response.setContentType("application/octet-stream"); + response.setHeader("Access-Control-Expose-Headers", "Content-Disposition"); // 解决中文不能生成文件 response.setHeader("Content-Disposition", "attachment; fileName=" + URLEncoder.encode("EfficiencyCalibration.Eft", "UTF-8")); fos = response.getOutputStream(); 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 ee798f3f..c4b667cd 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 @@ -24,6 +24,7 @@ import org.jeecg.common.api.vo.Result; import org.jeecg.common.cache.BetaCache; import org.jeecg.common.constant.DateConstant; import org.jeecg.common.constant.SymbolConstant; +import org.jeecg.common.properties.ParameterProperties; import org.jeecg.common.properties.SpectrumPathProperties; import org.jeecg.common.system.util.JwtUtil; import org.jeecg.common.system.vo.LoginUser; @@ -57,6 +58,7 @@ import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.*; +import java.net.URLEncoder; import java.sql.*; import java.text.ParseException; import java.time.LocalDateTime; @@ -83,6 +85,8 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { @Autowired private SpectrumPathProperties spectrumPathProperties; @Autowired + private ParameterProperties parameterProperties; + @Autowired private UserTaskUtil userTaskUtil; @Autowired private PHDFileUtil phdFileUtil; @@ -3103,6 +3107,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } else if ("AllSpectrum".equals(analyseData.getApplyType())) { //获取当前选中的文件名称 String currentFileName = analyseData.getCurrentFileName(); + String currentQCFileName = analyseData.getCurrentQCFileName(); List> loadDataList = new LinkedList<>(); for (int i=0; i m_loadData = new HashMap<>(); @@ -3154,7 +3159,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { m_loadData.put("qcFileName", qcFileName); loadDataList.add(m_loadData); } - List analyseResultList = BetaGammaAnalyzeAllProcess(loadDataList, analyseData, userName, currentFileName); + List analyseResultList = BetaGammaAnalyzeAllProcess(loadDataList, analyseData, userName, currentFileName, currentQCFileName); map.put("XeData", analyseResultList); map.put("bProcessed", true); map.put("savedAnalysisResult", true); @@ -3284,6 +3289,12 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { detTmp = phdFileUtil.analyzeFile(detFilePath, detFileName); //调用重新分析算法 获取算法结果 BgAnalyseResult analyseResult = EnergySpectrumHandler.bgReAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath(), spectrum_group.BgCalPara); + //生成分析操作日志 + EnergySpectrumStruct sample = phdFileUtil.analyzeFileSourceData(sampleTmp); + EnergySpectrumStruct gas = phdFileUtil.analyzeFileSourceData(gasTmp); + EnergySpectrumStruct det = phdFileUtil.analyzeFileSourceData(detTmp); + String logName = sampleFileName.replace("PHD", "log"); + phdFileUtil.OutPutRnLog(analyseResult, sample, gas, det, logName); //存入分析用到的数据 map.put("reAnalyseParam", spectrum_group.BgCalPara); //存入计算后得到的xeData数据 @@ -3385,7 +3396,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { return xeResultsSpectrumList; } - private List BetaGammaAnalyzeAllProcess(List> loadDataList, AnalyseData analyseData, String userName, String currentFileName){ + private List BetaGammaAnalyzeAllProcess(List> loadDataList, AnalyseData analyseData, String userName, String currentFileName, String currentQCFileName){ Map> analyseResultMap = new HashMap<>(); File sampleTmp = null; File gasTmp = null; @@ -3409,7 +3420,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { //从本地缓存获取beta gamma的数组 Cache> cache = betaCache.getBetaCache(); //根据qc文件名称-用户名-beta的方式获取beta的内容 - Map betaMap = cache.getIfPresent(qcFileName + "-" + userName + "-beta"); + Map betaMap = cache.getIfPresent(currentQCFileName + "-" + userName + "-beta"); List betaList = new LinkedList<>(); List betaFittingPara = new LinkedList<>(); List betaFittingParaToUi = new LinkedList<>(); @@ -3417,9 +3428,10 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { betaList = (List)betaMap.get("Series"); betaFittingPara = (List) betaMap.get("fittingPara"); betaFittingParaToUi = (List) betaMap.get("fittingParaToUi"); + cache.put(qcFileName+ "-" + userName + "-beta", betaMap); } //根据qc文件名称-用户名-gamma的方式获取gamma的内容 - Map gammaMap = cache.getIfPresent(qcFileName + "-" + userName + "-gamma"); + Map gammaMap = cache.getIfPresent(currentQCFileName + "-" + userName + "-gamma"); List gammaList = new LinkedList<>(); List gammaFittingPara = new LinkedList<>(); List gammaFittingParaToUi = new LinkedList<>(); @@ -3427,6 +3439,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { gammaList = (List)gammaMap.get("Series"); gammaFittingPara = (List) gammaMap.get("fittingPara"); gammaFittingParaToUi = (List) gammaMap.get("fittingParaToUi"); + cache.put(qcFileName+ "-" + userName + "-gamma", gammaMap); } if (analyseData.isBetaEnergyValid()) { @@ -3491,6 +3504,12 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { gasTmp = phdFileUtil.analyzeFile(gasFilePath, gasFileName); detTmp = phdFileUtil.analyzeFile(detFilePath, detFileName); BgAnalyseResult analyseResult = EnergySpectrumHandler.bgReAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath(), spectrum_group.BgCalPara); + //生成分析操作日志 + EnergySpectrumStruct sample = phdFileUtil.analyzeFileSourceData(sampleTmp); + EnergySpectrumStruct gas = phdFileUtil.analyzeFileSourceData(gasTmp); + EnergySpectrumStruct det = phdFileUtil.analyzeFileSourceData(detTmp); + String logName = sampleFileName.replace("PHD", "log"); + phdFileUtil.OutPutRnLog(analyseResult, sample, gas, det, logName); //存入重新分析的参数 map.put("reAnalyseParam", spectrum_group.BgCalPara); //存入xeData数据 @@ -3923,75 +3942,34 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } @Override - public Result viewBGLogViewer(String dbName, Integer sampleId, String sampleFileName, String gasFileName, String detFileName, String qcFileName, HttpServletRequest request) { - Result result = new Result(); - //获取用户名 - String userName = JwtUtil.getUserNameByToken(request); - //从本地缓存获取beta gamma的数组 - Cache> cache = betaCache.getBetaCache(); - //拼接ftp上传临时文件路径 - String path = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; - //声明一个实体类获取数据库中文件路径 - SpectrumFileRecord dbSpectrumFilePath = new SpectrumFileRecord(); - Integer analysisID = null; - String samplePath = ""; - String gasPath = ""; - String detPath = ""; - String qcPath = ""; - File sampleTmp = null; - File gasTmp = null; - File detTmp = null; - BgCalibratePara BgCalPara = null; + public void viewBGLogViewer(String sampleFileName, HttpServletResponse response) { + //日志路径及名称 + String logFilePath = parameterProperties.getLogFilePath() + File.separator + DateUtils.formatDate(new Date(), "yyyy-MM-dd") + File.separator + sampleFileName.replace("PHD", "log"); + FileInputStream inputStream = null; + OutputStream fos = null; try { - //如果sampleId不为空 说明数据来源数据库 查询出对应的文件路径 - if (Objects.nonNull(sampleId) && StringUtils.isNotBlank(dbName)){ - if (dbName.equalsIgnoreCase("auto")){ - dbName = "RNAUTO"; - analysisID = spectrumAnalysisMapper.getAnalysisID(dbName, sampleId, "RNAUTO"); - } else if (dbName.equalsIgnoreCase("man")){ - dbName = "RNMAN"; - analysisID = spectrumAnalysisMapper.getAnalysisID(dbName, sampleId, userName); - } - dbSpectrumFilePath = spectrumAnalysisMapper.getDBSpectrumFilePath(dbName, sampleId, analysisID); - samplePath = StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + dbSpectrumFilePath.getSampleFilePath().substring(0, dbSpectrumFilePath.getSampleFilePath().lastIndexOf(StringPool.SLASH)); - gasPath = StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + dbSpectrumFilePath.getGasBgFilePath().substring(0, dbSpectrumFilePath.getGasBgFilePath().lastIndexOf(StringPool.SLASH)); - detPath = StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + dbSpectrumFilePath.getDetBgFilePath().substring(0, dbSpectrumFilePath.getDetBgFilePath().lastIndexOf(StringPool.SLASH)); - GardsSampleData sampleData = spectrumAnalysisMapper.getSampleData(sampleId); - String collectStartStr = DateUtils.formatDate(sampleData.getCollectStart(), "yyyy/MM/dd HH:mm:ss"); - String dbQcFilePath = spectrumAnalysisMapper.getQCFilePath(sampleData.getSiteDetCode(), collectStartStr); - if (StringUtils.isNotBlank(dbQcFilePath)) { - qcPath=StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + dbQcFilePath.substring(0, dbQcFilePath.lastIndexOf(StringPool.SLASH)); - } - } else if ( (Objects.isNull(sampleId) && StringUtils.isNotBlank(dbName)) || (Objects.nonNull(sampleId) && StringUtils.isBlank(dbName)) ){ - result.error500("Data load From DB need to pass in sampleId and dbName"); - return result; - } else {//如果sampleId,dbNamed都为空 就指向ftp上传文件临时路径 - samplePath = path; - gasPath = path; - detPath = path; - qcPath = path; + inputStream = new FileInputStream(new File(logFilePath)); + fos = response.getOutputStream(); + byte[] buffer = new byte[1024]; + int bytesRead; + // 将文件输出流写入到输出流中 + while ((bytesRead = inputStream.read(buffer)) != -1) { + fos.write(buffer, 0, bytesRead); } - //根据文件路径 文件名称获取对应的临时文件 - sampleTmp = phdFileUtil.analyzeFile(samplePath, sampleFileName); - gasTmp = phdFileUtil.analyzeFile(gasPath, gasFileName); - detTmp = phdFileUtil.analyzeFile(detPath, detFileName); - //调用动态库解析文件 - //Gamma Energy Calibration页面 如果点击过fitting使BGammaEnergyValid并且有勾选 - //如果三个sampleData,GasData,DetData数据都是被勾选状态 则需要传递新的参数重新分析 否则不需要改变数据分析当前文件内容 - BgAnalyseResult bgAnalyseResult = null; - if (Objects.isNull(BgCalPara)) { - bgAnalyseResult = EnergySpectrumHandler.bgAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath()); - } else { - bgAnalyseResult = EnergySpectrumHandler.bgReAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath(), BgCalPara); - } - //拿分析的结果去生成日志内容 - } catch (Exception e) { - + e.printStackTrace(); } finally { - + try { + if (Objects.nonNull(inputStream)) { + inputStream.close(); + } + if (Objects.nonNull(fos)) { + fos.close(); + } + } catch (IOException e) { + throw new RuntimeException(e); + } } - return result; } @Override