From 6dde5668381a27e8b5a7170a7bbd16dbc2580510 Mon Sep 17 00:00:00 2001 From: qiaoqinzheng Date: Fri, 15 Sep 2023 10:12:37 +0800 Subject: [PATCH] =?UTF-8?q?beta=E5=8A=9F=E8=83=BDsaveToDB=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=20beta=E5=8A=9F=E8=83=BD=E5=A2=9E=E5=8A=A0=E5=88=86?= =?UTF-8?q?=E6=9E=90=E6=96=87=E4=BB=B6=E6=96=B9=E6=B3=95=20gamma=E6=96=B0?= =?UTF-8?q?=E5=A2=9EsaveDataEnergy=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SpectrumAnalysesController.java | 4 +- .../entity/vo/BgDataAnlyseResultIn.java | 47 +++--- .../org/jeecg/modules/entity/vo/PeakInfo.java | 69 ++++++++ .../mapper/SpectrumAnalysisMapper.java | 19 ++- .../mapper/xml/SpectrumAnalysisMapper.xml | 99 ++++++------ .../modules/native_jni/CalValuesHandler.java | 19 +++ .../native_jni/struct/BgAnalyseResult.java | 27 ++-- .../service/ISpectrumAnalysisService.java | 2 +- .../service/impl/GammaServiceImpl.java | 4 +- .../impl/SpectrumAnalysisServiceImpl.java | 150 +++++++++++++----- 10 files changed, 310 insertions(+), 130 deletions(-) create mode 100644 jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/PeakInfo.java 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 451b1a23..826f8636 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 @@ -212,8 +212,8 @@ public class SpectrumAnalysesController { } @PostMapping("saveToDB") - public Result saveToDB(@RequestBody BgDataAnlyseResultIn anlyseResultIn) { - return spectrumAnalysisService.saveToDB(anlyseResultIn); + public Result saveToDB(@RequestBody BgDataAnlyseResultIn anlyseResultIn, HttpServletRequest request) { + return spectrumAnalysisService.saveToDB(anlyseResultIn, request); } } 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 2f500869..51ed7a7d 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 @@ -32,6 +32,11 @@ public class BgDataAnlyseResultIn implements Serializable { */ private String stationName; + /** + * 加载数据库名称 + */ + private String dbName; + /** * sample文件路径 */ @@ -63,7 +68,7 @@ public class BgDataAnlyseResultIn implements Serializable { private String detFileName; /** - * qc文件名称 + * qc文件路径 */ private String qcFilePath; @@ -182,32 +187,32 @@ public class BgDataAnlyseResultIn implements Serializable { private String param_b_c2e_b_det; private String param_c_c2e_b_det; - private double MDC_Xe135; //MDC XE135 - private double MDC_Xe131m; //MDC XE131m - private double MDC_Xe133m; //MDC XE133m - private double MDC_Xe133; //MDC XE133 + private double mdc_Xe135; //MDC XE135 + private double mdc_Xe131m; //MDC XE131m + private double mdc_Xe133m; //MDC XE133m + private double mdc_Xe133; //MDC XE133 - private double Xe135_con; //135不浓度 - private double Xe135_uncer; //135不确定度 - private double Xe131m_con; - private double Xe131m_uncer; - private double Xe133m_con; - private double Xe133m_uncer; - private double Xe133_con; - private double Xe133_uncer; + private double xe135_con; //135不浓度 + private double xe135_uncer; //135不确定度 + private double xe131m_con; + private double xe131m_uncer; + private double xe133m_con; + private double xe133m_uncer; + private double xe133_con; + private double xe133_uncer; - private double LC_Xe135; //LC XE135 - private double LC_Xe131m; //LC XE131m - private double LC_Xe133m; //LC XE133m - private double LC_Xe133; //LC XE133 + private double lc_Xe135; //LC XE135 + private double lc_Xe131m; //LC XE131m + private double lc_Xe133m; //LC XE133m + private double lc_Xe133; //LC XE133 - private int Xe131mFlag; + private int xe131mFlag; - private int Xe133Flag; + private int xe133Flag; - private int Xe133mFlag; + private int xe133mFlag; - private int Xe135Flag; + private int xe135Flag; List gammaCalibrationSpectrumList; diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/PeakInfo.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/PeakInfo.java new file mode 100644 index 00000000..459421d3 --- /dev/null +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/PeakInfo.java @@ -0,0 +1,69 @@ +package org.jeecg.modules.entity.vo; + + +import java.io.Serializable; +import java.util.LinkedList; +import java.util.List; + +public class PeakInfo implements Serializable { + + public int index; //峰序号 + + public int multiIndex; //重峰序号 + + public int left; //峰的左边界 + + public int right; //峰的右边界 + + public double peakCentroid; //峰拟合后加权峰中心道 + + public double energy; + + public double fwhmc; //半高宽 + + public double fwhm; //以keV为单位的半高宽 + + public double area; //净面积 + + public double areaErr; // + + public double efficiency; + + public double lc; + + public double ld; + + public double meanBackCount; + + public double backgroundArea; + + public double significance; + + public double sensitivity; + + public double stepRatio; + + public double tail; + + public double tailAlpha; + + public double upperTail; + + public double upperTailAlpha; + + public double BWWidthChan; + + public String recoilBetaChan; + + public String recoilDeltaChan; + + public String comments; + + public List nuclides; + + public PeakInfo(){ + nuclides = new LinkedList<>(); + comments = ""; + } + +} diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/SpectrumAnalysisMapper.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/SpectrumAnalysisMapper.java index 391690f6..911e709d 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/SpectrumAnalysisMapper.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/SpectrumAnalysisMapper.java @@ -9,8 +9,7 @@ import org.jeecg.modules.base.entity.configuration.GardsDetectors; import org.jeecg.modules.base.entity.configuration.GardsNuclLib; import org.jeecg.modules.base.entity.configuration.GardsNuclLinesLib; import org.jeecg.modules.base.entity.original.GardsSampleData; -import org.jeecg.modules.base.entity.rnman.GardsAnalySetting; -import org.jeecg.modules.base.entity.rnman.GardsCalibrationPairs; +import org.jeecg.modules.base.entity.rnman.*; import org.jeecg.modules.entity.*; import org.jeecg.modules.entity.vo.*; @@ -136,23 +135,27 @@ public interface SpectrumAnalysisMapper { void deleteCalibrationPairs(Integer idAnalysis); @InterceptorIgnore(tenantLine = "true") - void insertCalibrationPairs(List calibrationPairsList); + void insertCalibrationPairs(@Param(value = "calibrationPairs") GardsCalibrationPairs calibrationPairs); void deleteCalibration(Integer idAnalysis); - void insertCalibration(List calibrationList); + @InterceptorIgnore(tenantLine = "true") + void insertCalibration(@Param(value = "calibration") GardsCalibration calibration); void deleteROIChannels(Integer idAnalysis); - void insertROIChannels(List roiChannelsList); + @InterceptorIgnore(tenantLine = "true") + void insertROIChannels(@Param(value = "roiChannels") GardsRoiChannels roiChannels); void deleteXeResult(Integer idAnalysis); - void insertXeResult(List xeResults); + @InterceptorIgnore(tenantLine = "true") + void insertXeResult(@Param(value = "xeResult") GardsXeResults xeResult); void deleteROIResults(Integer idAnalysis); - void insertROIResults(List roiResultsSpectrumList); + @InterceptorIgnore(tenantLine = "true") + void insertROIResults(@Param(value = "roiResultsSpectrum") GardsRoiResults roiResultsSpectrum); String getIdAnalysisByIdAnalyst(@Param(value = "sampleId") String sampleId, @Param(value = "userName") String userName); @@ -166,4 +169,6 @@ public interface SpectrumAnalysisMapper { void deleteAnalySetting(Integer idAnalysis); + Integer getSampleIdLikeFileName(@Param(value = "fileName") String fileName); + } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/xml/SpectrumAnalysisMapper.xml b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/xml/SpectrumAnalysisMapper.xml index 2fc9b382..5d2c4d47 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/xml/SpectrumAnalysisMapper.xml +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/xml/SpectrumAnalysisMapper.xml @@ -824,11 +824,10 @@ - INSERT INTO RNMAN.GARDS_CALIBRATION_PAIRS(SAMPLE_ID,IDANALYSIS,SAMPLE_TYPE,CALTYPE,INPUT,IDCALPOINT,XVALUE,YVALUE) + INSERT INTO + RNMAN.GARDS_CALIBRATION_PAIRS(SAMPLE_ID,IDANALYSIS,SAMPLE_TYPE,CALTYPE,INPUT,IDCALPOINT,XVALUE,YVALUE) VALUES - (#{calibrationPairs.sampleId},#{calibrationPairs.idAnalysis},#{calibrationPairs.sampleType},#{calibrationPairs.caltype},#{calibrationPairs.input},#{calibrationPairs.idCalPoint},#{calibrationPairs.xValue},#{calibrationPairs.yValue}) - @@ -849,19 +848,17 @@ COEFF1, COEFF2, COEFF3) - - VALUES(#{calibration.sampleId}, - #{calibration.idAnalysis}, - #{calibration.sampleType}, - #{calibration.calType}, - #{calibration.function}, - #{calibration.functionDef}, - #{calibration.startOfRange}, - #{calibration.endOfRange}, - #{calibration.coeff1}, - #{calibration.coeff2}, - #{calibration.coeff3}) - + VALUES(#{calibration.sampleId}, + #{calibration.idAnalysis}, + #{calibration.sampleType}, + #{calibration.calType}, + #{calibration.function}, + #{calibration.functionDef}, + #{calibration.startOfRange}, + #{calibration.endOfRange}, + #{calibration.coeff1}, + #{calibration.coeff2}, + #{calibration.coeff3}) @@ -879,15 +876,13 @@ B_CHAN_STOP, G_CHAN_START, G_CHAN_STOP) - - VALUES(#{roiChannels.sampleId}, - #{roiChannels.idAnalysis}, - #{roiChannels.roi}, - #{roiChannels.bChanStart}, - #{roiChannels.bChanStop}, - #{roiChannels.gChanStart}, - #{roiChannels.gChanStop}) - + VALUES(#{roiChannels.sampleId}, + #{roiChannels.idAnalysis}, + #{roiChannels.roi}, + #{roiChannels.bChanStart}, + #{roiChannels.bChanStop}, + #{roiChannels.gChanStart}, + #{roiChannels.gChanStop}) @@ -904,16 +899,14 @@ MDC, LC, NID_FLAG) - - VALUES(#{xeResult.sampleId}, - #{xeResult.idAnalysis}, - #{xeResult.nuclideName}, - #{xeResult.conc}, - #{xeResult.concErr}, - #{xeResult.mdc}, - #{xeResult.lc}, - #{xeResult.nidFlag}) - + VALUES(#{xeResult.sampleId}, + #{xeResult.idAnalysis}, + #{xeResult.nuclideName}, + #{xeResult.conc}, + #{xeResult.concErr}, + #{xeResult.mdc}, + #{xeResult.lc}, + #{xeResult.nidFlag}) @@ -937,23 +930,21 @@ CONC_ERR, MDC, NID_FLAG) - - VALUES(#{roiResultsSpectrum.sampleId}, - #{roiResultsSpectrum.idAnalysis}, - #{roiResultsSpectrum.roi}, - #{roiResultsSpectrum.lc}, - #{roiResultsSpectrum.sGross}, - #{roiResultsSpectrum.gGross}, - #{roiResultsSpectrum.bGross}, - #{roiResultsSpectrum.sNet}, - #{roiResultsSpectrum.gNet}, - #{roiResultsSpectrum.net}, - #{roiResultsSpectrum.netErr}, - #{roiResultsSpectrum.conc}, - #{roiResultsSpectrum.concErr}, - #{roiResultsSpectrum.mdc}, - #{roiResultsSpectrum.nidFlag}) - + VALUES(#{roiResultsSpectrum.sampleId}, + #{roiResultsSpectrum.idAnalysis}, + #{roiResultsSpectrum.roi}, + #{roiResultsSpectrum.lc}, + #{roiResultsSpectrum.sGross}, + #{roiResultsSpectrum.gGross}, + #{roiResultsSpectrum.bGross}, + #{roiResultsSpectrum.sNet}, + #{roiResultsSpectrum.gNet}, + #{roiResultsSpectrum.net}, + #{roiResultsSpectrum.netErr}, + #{roiResultsSpectrum.conc}, + #{roiResultsSpectrum.concErr}, + #{roiResultsSpectrum.mdc}, + #{roiResultsSpectrum.nidFlag}) + select SAMPLE_ID from ORIGINAL.GARDS_SAMPLE_DATA WHERE INPUT_FILE_NAME LIKE CONCAT('%', #{fileName}) + + \ No newline at end of file diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/native_jni/CalValuesHandler.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/native_jni/CalValuesHandler.java index de41b46f..69f296fd 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/native_jni/CalValuesHandler.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/native_jni/CalValuesHandler.java @@ -6,6 +6,7 @@ import org.jeecg.modules.entity.vo.StructInsertOutput; import org.jeecg.modules.native_jni.struct.CalValuesOut; import java.util.List; +import java.util.Map; public class CalValuesHandler { @@ -25,4 +26,22 @@ public class CalValuesHandler { public static native StructInsertOutput ComputePeakRange(int peakSize, int m_nCount, List vCentroid, List vFwhmCh, List vTail, List vUpperTail); + public static native List calValues(int cal, int m_nChans); + + public static native List GetFwhmcAll(int m_nChans); + + public static native List calculateLC(List BaseLine, List FwhmcAll, double RiskLevelK); + + public static native List calculateSCAC(List Spectrum, List BaseLine, List FwhmcAll); + + public static native boolean armaAny(List Spectrum); + + public static native String calUpdate(String dataType, List certEne, boolean E1, boolean R, boolean E2, boolean KeepCalPeakSearchPeaks, double k_back, double k_alpha, double k_beta); + + public static native String peakSearch(double ECutLow, double ECutHigh, double deltaE, double pssLow, double k_back, double k_alpha, double k_beta); + + public static native String baseImprove(double BaseImprovePSS, double k_back, double k_alpha, double k_beta); + + public static native String fitPeakFull(); + } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/native_jni/struct/BgAnalyseResult.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/native_jni/struct/BgAnalyseResult.java index 0cf767be..c06585dd 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/native_jni/struct/BgAnalyseResult.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/native_jni/struct/BgAnalyseResult.java @@ -3,8 +3,7 @@ package org.jeecg.modules.native_jni.struct; import java.util.List; public class BgAnalyseResult { - - /************************** GARDS_XE_RESULTS START**************************/ +/************************** GARDS_XE_RESULTS START**************************/ /************************** XE_131m **************************/ public double Xe131m_con; public double Xe131m_uncer; @@ -47,34 +46,38 @@ public class BgAnalyseResult { public List ROI_con_uncer_err; public List MDC; public List dNidFlag; + public List LC_CTS; /************************** GARDS_ROI_RESULTS end **************************/ /************************** GARDS_CALIBRATION START**************************/ - public List s_b_fitting_c_e; public List s_b_fitting_e_c; public int s_b_fitting_type; public String s_b_fitting_type_def; - public List s_g_fitting_c_e; public List s_g_fitting_e_c; public int s_g_fitting_type; public String s_g_fitting_type_def; - public List g_b_fitting_c_e; + public List s_b_fitting_c_e; + public List s_g_fitting_c_e; + public List g_b_fitting_e_c; public int g_b_fitting_type; public String g_b_fitting_type_def; - public List g_g_fitting_c_e; public List g_g_fitting_e_c; public int g_g_fitting_type; public String g_g_fitting_type_def; - public List d_b_fitting_c_e; + public List g_b_fitting_c_e; + public List g_g_fitting_c_e; + public List d_b_fitting_e_c; public int d_b_fitting_type; public String d_b_fitting_type_def; - public List d_g_fitting_c_e; public List d_g_fitting_e_c; public int d_g_fitting_type; public String d_g_fitting_type_def; + public List d_b_fitting_c_e; + public List d_g_fitting_c_e; + /************************** GARDS_CALIBRATION end **************************/ /************************** GARDS_ROI_CHANNELS START**************************/ @@ -141,24 +144,31 @@ public class BgAnalyseResult { ", ROI_con_uncer_err=" + ROI_con_uncer_err + ", MDC=" + MDC + ", dNidFlag=" + dNidFlag + + ", LC_CTS=" + LC_CTS + ", s_b_fitting_e_c=" + s_b_fitting_e_c + ", s_b_fitting_type=" + s_b_fitting_type + ", s_b_fitting_type_def='" + s_b_fitting_type_def + '\'' + ", s_g_fitting_e_c=" + s_g_fitting_e_c + ", s_g_fitting_type=" + s_g_fitting_type + ", s_g_fitting_type_def='" + s_g_fitting_type_def + '\'' + + ", s_b_fitting_c_e=" + s_b_fitting_c_e + + ", s_g_fitting_c_e=" + s_g_fitting_c_e + ", g_b_fitting_e_c=" + g_b_fitting_e_c + ", g_b_fitting_type=" + g_b_fitting_type + ", g_b_fitting_type_def='" + g_b_fitting_type_def + '\'' + ", g_g_fitting_e_c=" + g_g_fitting_e_c + ", g_g_fitting_type=" + g_g_fitting_type + ", g_g_fitting_type_def='" + g_g_fitting_type_def + '\'' + + ", g_b_fitting_c_e=" + g_b_fitting_c_e + + ", g_g_fitting_c_e=" + g_g_fitting_c_e + ", d_b_fitting_e_c=" + d_b_fitting_e_c + ", d_b_fitting_type=" + d_b_fitting_type + ", d_b_fitting_type_def='" + d_b_fitting_type_def + '\'' + ", d_g_fitting_e_c=" + d_g_fitting_e_c + ", d_g_fitting_type=" + d_g_fitting_type + ", d_g_fitting_type_def='" + d_g_fitting_type_def + '\'' + + ", d_b_fitting_c_e=" + d_b_fitting_c_e + + ", d_g_fitting_c_e=" + d_g_fitting_c_e + ", S_ROI=" + S_ROI + ", S_ROI_B_Boundary_start=" + S_ROI_B_Boundary_start + ", S_ROI_B_Boundary_stop=" + S_ROI_B_Boundary_stop + @@ -178,5 +188,4 @@ public class BgAnalyseResult { ", error_log='" + error_log + '\'' + '}'; } - } 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 b244b686..72ed5eb2 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 @@ -72,6 +72,6 @@ public interface ISpectrumAnalysisService { Result analyseAllSpectrum(List dbNames, List sampleIds, List sampleFileNames, List gasFileNames, List detFileNames, HttpServletRequest request); - Result saveToDB(BgDataAnlyseResultIn anlyseResultIn); + 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 ffe06796..da9bfc23 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 @@ -1222,9 +1222,9 @@ public class GammaServiceImpl implements IGammaService { for (int i=0; i ObjectUtil.isNull(value) ? "" : value); String export = "RLR-Beta.xls"; String template = RLR_B.getName(); - ExportUtil.exportXls(response, template, dataMap, export); + ExportUtil.exportXls(response, template, dataMap,export); + } + + public static void main(String[] args) { + BetaRLR betaRLR = new BetaRLR(); + Map dataMap = BeanUtil.beanToMap(betaRLR); + dataMap.replaceAll((key, value) -> ObjectUtil.isNull(value) ? "" : value); + dataMap.forEach((key, value) -> System.out.println(key + "---" + value)); } @Override @@ -2639,9 +2646,10 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { @Override @Transactional - public Result saveToDB(BgDataAnlyseResultIn anlyseResultIn) { + public Result saveToDB(BgDataAnlyseResultIn anlyseResultIn, HttpServletRequest request) { Result result = new Result(); - Map map = new HashMap<>(); + String userName = JwtUtil.getUserNameByToken(request); + anlyseResultIn.setUserName(userName); String beginDate = DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss"); String endDate = DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss"); //判断当前分析员是否有过排班任务 @@ -2655,10 +2663,43 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { getChannelAndEnergy(anlyseResultIn); //获取ROI Limit数据 // getROILimit(anlyseResultIn); + //根据sample文件名称模糊查询sampleId + if (StringUtils.isNotBlank(anlyseResultIn.getDbName())) { + if (anlyseResultIn.getDbName().equals("auto")) { + anlyseResultIn.setDbName("RNAUTO"); + } else if (anlyseResultIn.getDbName().equals("man")) { + anlyseResultIn.setDbName("RNMAN"); + } + Integer sampleId = spectrumAnalysisMapper.getSampleIdLikeFileName(anlyseResultIn.getSampleFileName()); + if (Objects.nonNull(sampleId)) { + SpectrumFileRecord dbSpectrumFilePath = spectrumAnalysisMapper.getDBSpectrumFilePath(anlyseResultIn.getDbName(), sampleId); + if (StringUtils.isNotBlank(dbSpectrumFilePath.getSampleFilePath())){ + anlyseResultIn.setSampleFilePath(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getSampleFilePath().substring(0, dbSpectrumFilePath.getSampleFilePath().lastIndexOf(StringPool.SLASH))); + } + if (StringUtils.isNotBlank(dbSpectrumFilePath.getGasBgFilePath())) { + anlyseResultIn.setGasFilePath(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getGasBgFilePath().substring(0, dbSpectrumFilePath.getGasBgFilePath().lastIndexOf(StringPool.SLASH))); + } + if (StringUtils.isNotBlank(dbSpectrumFilePath.getDetBgFilePath())) { + anlyseResultIn.setDetFilePath(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getDetBgFilePath().substring(0, dbSpectrumFilePath.getDetBgFilePath().lastIndexOf(StringPool.SLASH))); + } + if ( Objects.nonNull(dbSpectrumFilePath.getCollectStart()) && StringUtils.isNotBlank(dbSpectrumFilePath.getSiteDetCode()) ) { + String collectStartStr = DateUtils.formatDate(dbSpectrumFilePath.getCollectStart(), "yyyy/MM/dd HH:mm:ss"); + anlyseResultIn.setQcFilePath(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + spectrumAnalysisMapper.getQCFilePath(dbSpectrumFilePath.getSiteDetCode(), collectStartStr)); + } + } + } else { + anlyseResultIn.setSampleFilePath(StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName); + anlyseResultIn.setGasFilePath(StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName); + anlyseResultIn.setDetFilePath(StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName); + anlyseResultIn.setQcFilePath(StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName); + } + + //处理文件名称 String sampleFilePathName = phdFileUtil.NameStandardBy(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName()); String gasFilePathName = phdFileUtil.NameStandardBy(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName()); String detFilePathName = phdFileUtil.NameStandardBy(anlyseResultIn.getDetFilePath(), anlyseResultIn.getDetFileName()); + String qcFilePathName = phdFileUtil.NameStandardBy(anlyseResultIn.getQcFilePath(), anlyseResultIn.getQcFileName()); //判断文件是否存储过 如果没有则解析文件并进行存储 if ( !OriginalDataStore(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName(), gasFilePathName, anlyseResultIn.getUserName()) ){ result.error500("gasFile save failed"); @@ -2668,6 +2709,12 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { result.error500("detFile save failed"); return result; } + if (StringUtils.isNotBlank(anlyseResultIn.getQcFileName())) { + if ( !OriginalDataStore(anlyseResultIn.getQcFilePath(), anlyseResultIn.getQcFileName(), qcFilePathName, anlyseResultIn.getUserName()) ){ + result.error500("qcFile save failed"); + return result; + } + } if ( !OriginalDataStore(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName(), sampleFilePathName, anlyseResultIn.getUserName()) ){ result.error500("sampleFile save failed"); return result; @@ -2707,11 +2754,15 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { if (Objects.nonNull(isExist)){ //根据idAnalysis删除GARDS_CALIBRATION_PAIRS表数据 spectrumAnalysisMapper.deleteCalibrationPairs(idAnalysis); - //新增GARDS_CALIBRATION_PAIRS表数据 - spectrumAnalysisMapper.insertCalibrationPairs(calibrationPairsList); + //遍历新增GARDS_CALIBRATION_PAIRS表数据 + for (GardsCalibrationPairs calibrationPairs:calibrationPairsList) { + spectrumAnalysisMapper.insertCalibrationPairs(calibrationPairs); + } }else {//如果没有分析过--新增GARDS_CALIBRATION_PAIRS表数据 - //新增GARDS_CALIBRATION_PAIRS表数据 - spectrumAnalysisMapper.insertCalibrationPairs(calibrationPairsList); + //遍历新增GARDS_CALIBRATION_PAIRS表数据 + for (GardsCalibrationPairs calibrationPairs:calibrationPairsList) { + spectrumAnalysisMapper.insertCalibrationPairs(calibrationPairs); + } } //gards_calibration 数据表 List calibrationList = getCalibration(anlyseResultIn, sampleId, gasId, detId, idAnalysis); @@ -2719,11 +2770,15 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { if (Objects.nonNull(isExist)) { //删除Gards_Calibration表数据 spectrumAnalysisMapper.deleteCalibration(idAnalysis); - //新增数据 - calibrationSpectrumService.saveGardsCalibration(calibrationList); + //新增Gards_Calibration表数据数据 + for (GardsCalibration calibration:calibrationList) { + spectrumAnalysisMapper.insertCalibration(calibration); + } } else { - //新增数据 - calibrationSpectrumService.saveGardsCalibration(calibrationList); + //新增Gards_Calibration表数据数据 + for (GardsCalibration calibration:calibrationList) { + spectrumAnalysisMapper.insertCalibration(calibration); + } } //gards_roi_channels数据表 List roiChannelsList = new LinkedList<>(); @@ -2735,21 +2790,29 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { //删除gards_roi_channels数据表数据 spectrumAnalysisMapper.deleteROIChannels(idAnalysis); //新增gards_roi_channels数据表数据 - roiChannelsSpectrumService.saveGardsROIChannels(roiChannelsList); + for (GardsRoiChannels roiChannels:roiChannelsList) { + spectrumAnalysisMapper.insertROIChannels(roiChannels); + } }else {//没有分析过 //新增gards_roi_channels数据表数据 - roiChannelsSpectrumService.saveGardsROIChannels(roiChannelsList); + for (GardsRoiChannels roiChannels:roiChannelsList) { + spectrumAnalysisMapper.insertROIChannels(roiChannels); + } } //gards_Xe_results数据表 - List xeResults = getXeResults(anlyseResultIn, sampleId, idAnalysis); + List xeResultsList = getXeResults(anlyseResultIn, sampleId, idAnalysis); if(Objects.nonNull(isExist)) { //删除gards_Xe_results数据表数据 spectrumAnalysisMapper.deleteXeResult(idAnalysis); //新增gards_Xe_results数据表数据 - xeResultsSpectrumService.saveGardsXeResults(xeResults); + for (GardsXeResults xeResults:xeResultsList) { + spectrumAnalysisMapper.insertXeResult(xeResults); + } } else { //新增gards_Xe_results数据表数据 - xeResultsSpectrumService.saveGardsXeResults(xeResults); + for (GardsXeResults xeResults:xeResultsList) { + spectrumAnalysisMapper.insertXeResult(xeResults); + } } //gards_roi_results数据表 List roiResultsSpectrumList = getROIResult(anlyseResultIn.getRoiResultsSpectrumList(), sampleId, idAnalysis, isExist); @@ -2757,10 +2820,25 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { //删除gards_roi_results数据表数据 spectrumAnalysisMapper.deleteROIResults(idAnalysis); //新增gards_roi_results数据表数据 - roiResultsSpectrumService.saveGardsROIResults(roiResultsSpectrumList); + for (GardsRoiResults roiResults:roiResultsSpectrumList) { + spectrumAnalysisMapper.insertROIResults(roiResults); + } } else { //新增gards_roi_results数据表数据 - roiResultsSpectrumService.saveGardsROIResults(roiResultsSpectrumList); + for (GardsRoiResults roiResults:roiResultsSpectrumList) { + spectrumAnalysisMapper.insertROIResults(roiResults); + } + } + //上传本次文件到ftp人工交互存储路径下 + File sampleTmp = phdFileUtil.analyzeFile(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName()); + File gasTmp = phdFileUtil.analyzeFile(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName()); + File detTmp = phdFileUtil.analyzeFile(anlyseResultIn.getDetFilePath(), anlyseResultIn.getDetFileName()); + try { + ftpUtil.saveFile(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePathName.substring(0, sampleFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getSampleFileName(), new FileInputStream(sampleTmp)); + ftpUtil.saveFile(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + gasFilePathName.substring(0, gasFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getGasFileName(), new FileInputStream(gasTmp)); + ftpUtil.saveFile(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + detFilePathName.substring(0, detFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getDetFileName(), new FileInputStream(detTmp)); + } catch (FileNotFoundException e) { + throw new RuntimeException(e); } result.setSuccess(true); return result; @@ -3072,7 +3150,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { GardsRoiChannels roiChannels = new GardsRoiChannels(); roiChannels.setSampleId(sampleId); roiChannels.setIdAnalysis(idAnalysis); - roiChannels.setRoi(i); + roiChannels.setRoi(i+1); roiChannels.setBChanStart(roiChannelsSpectrumList.get(i).getBChanStart()); roiChannels.setBChanStop(roiChannelsSpectrumList.get(i).getBChanStop()); roiChannels.setGChanStart(roiChannelsSpectrumList.get(i).getGChanStart()); @@ -3090,8 +3168,8 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { xe131m.setNuclideName(XeNuclideName.XE_131m.getType()); xe131m.setConc(anlyseResultIn.getXe131m_con()); xe131m.setConcErr(anlyseResultIn.getXe131m_uncer()); - xe131m.setMdc(anlyseResultIn.getMDC_Xe131m()); - xe131m.setLc(anlyseResultIn.getLC_Xe131m()); + xe131m.setMdc(anlyseResultIn.getMdc_Xe131m()); + xe131m.setLc(anlyseResultIn.getLc_Xe131m()); xe131m.setNidFlag(anlyseResultIn.getXe131mFlag()); xeResultsList.add(xe131m); //Xe133 @@ -3101,8 +3179,8 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { xe133.setNuclideName(XeNuclideName.XE_133.getType()); xe133.setConc(anlyseResultIn.getXe133_con()); xe133.setConcErr(anlyseResultIn.getXe133_uncer()); - xe133.setMdc(anlyseResultIn.getMDC_Xe133()); - xe133.setLc(anlyseResultIn.getLC_Xe133()); + xe133.setMdc(anlyseResultIn.getMdc_Xe133()); + xe133.setLc(anlyseResultIn.getLc_Xe133()); xe133.setNidFlag(anlyseResultIn.getXe133Flag()); xeResultsList.add(xe133); //Xe133m @@ -3112,8 +3190,8 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { xe133m.setNuclideName(XeNuclideName.XE_133m.getType()); xe133m.setConc(anlyseResultIn.getXe133m_con()); xe133m.setConcErr(anlyseResultIn.getXe133m_uncer()); - xe133m.setMdc(anlyseResultIn.getMDC_Xe133m()); - xe133m.setLc(anlyseResultIn.getLC_Xe133m()); + xe133m.setMdc(anlyseResultIn.getMdc_Xe133m()); + xe133m.setLc(anlyseResultIn.getLc_Xe133m()); xe133m.setNidFlag(anlyseResultIn.getXe133mFlag()); xeResultsList.add(xe133m); //Xe135 @@ -3123,8 +3201,8 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { xe135.setNuclideName(XeNuclideName.XE_135.getType()); xe135.setConc(anlyseResultIn.getXe135_con()); xe135.setConcErr(anlyseResultIn.getXe135_uncer()); - xe135.setMdc(anlyseResultIn.getMDC_Xe135()); - xe135.setLc(anlyseResultIn.getLC_Xe135()); + xe135.setMdc(anlyseResultIn.getMdc_Xe135()); + xe135.setLc(anlyseResultIn.getLc_Xe135()); xe135.setNidFlag(anlyseResultIn.getXe135Flag()); xeResultsList.add(xe135); return xeResultsList; @@ -3139,8 +3217,8 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { xe131m.setNuclideName(XeNuclideName.XE_131m.getType()); xe131m.setConc(anlyseResultIn.getXe131m_con()); xe131m.setConcErr(anlyseResultIn.getXe131m_uncer()); - xe131m.setMdc(anlyseResultIn.getMDC_Xe131m()); - xe131m.setLc(anlyseResultIn.getLC_Xe131m()); + xe131m.setMdc(anlyseResultIn.getMdc_Xe131m()); + xe131m.setLc(anlyseResultIn.getLc_Xe131m()); xe131m.setNidFlag(anlyseResultIn.getXe131mFlag()); xeResultsList.add(xe131m); //Xe133 @@ -3150,8 +3228,8 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { xe133.setNuclideName(XeNuclideName.XE_133.getType()); xe133.setConc(anlyseResultIn.getXe133_con()); xe133.setConcErr(anlyseResultIn.getXe133_uncer()); - xe133.setMdc(anlyseResultIn.getMDC_Xe133()); - xe133.setLc(anlyseResultIn.getLC_Xe133()); + xe133.setMdc(anlyseResultIn.getMdc_Xe133()); + xe133.setLc(anlyseResultIn.getLc_Xe133()); xe133.setNidFlag(anlyseResultIn.getXe133Flag()); xeResultsList.add(xe133); //Xe133m @@ -3161,8 +3239,8 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { xe133m.setNuclideName(XeNuclideName.XE_133m.getType()); xe133m.setConc(anlyseResultIn.getXe133m_con()); xe133m.setConcErr(anlyseResultIn.getXe133m_uncer()); - xe133m.setMdc(anlyseResultIn.getMDC_Xe133m()); - xe133m.setLc(anlyseResultIn.getLC_Xe133m()); + xe133m.setMdc(anlyseResultIn.getMdc_Xe133m()); + xe133m.setLc(anlyseResultIn.getLc_Xe133m()); xe133m.setNidFlag(anlyseResultIn.getXe133mFlag()); xeResultsList.add(xe133m); //Xe135 @@ -3172,8 +3250,8 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { xe135.setNuclideName(XeNuclideName.XE_135.getType()); xe135.setConc(anlyseResultIn.getXe135_con()); xe135.setConcErr(anlyseResultIn.getXe135_uncer()); - xe135.setMdc(anlyseResultIn.getMDC_Xe135()); - xe135.setLc(anlyseResultIn.getLC_Xe135()); + xe135.setMdc(anlyseResultIn.getMdc_Xe135()); + xe135.setLc(anlyseResultIn.getLc_Xe135()); xe135.setNidFlag(anlyseResultIn.getXe135Flag()); xeResultsList.add(xe135); return xeResultsList; @@ -3305,7 +3383,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { GardsRoiResults roiResults = new GardsRoiResults(); roiResults.setSampleId(sampleId); roiResults.setIdAnalysis(idAnalysis); - roiResults.setRoi(i); + roiResults.setRoi(i+1); roiResults.setLc(roiResultsSpectrumList.get(i).getLc()); roiResults.setSGross(roiResultsSpectrumList.get(i).getSGross()); roiResults.setGGross(roiResultsSpectrumList.get(i).getGGross());