From c49318a57faaa93b7d556d0502c30a6afc20cbf5 Mon Sep 17 00:00:00 2001 From: panbaolin <123456> Date: Fri, 22 Sep 2023 22:51:44 +0800 Subject: [PATCH 01/11] =?UTF-8?q?fix:1.=E5=AE=8C=E6=88=90=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=A4=84=E7=90=86B=E5=88=86=E6=9E=90=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E5=8A=9F=E8=83=BD2.=E4=BC=98=E5=8C=96=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=A4=84=E7=90=86=E5=8A=9F=E8=83=BD=E7=BB=93=E6=9E=84?= =?UTF-8?q?=E6=B5=8B=E8=AF=95B=E5=88=86=E6=9E=90=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/FileSourceHandleManager.java | 2 +- .../jeecg/modules/service/BlockConstant.java | 31 +- .../service/ISpectrumBaseBlockService.java | 3 +- .../GardsCalibrationPairsServiceImpl.java | 12 +- .../impl/GardsRoiResultsServiceImpl.java | 25 +- .../impl/GardsXeResultsServiceImpl.java | 12 +- .../impl/SpectrumBaseBlockServiceImpl.java | 12 +- .../modules/spectrum/AbstractLogOrReport.java | 65 ++ .../modules/spectrum/DetbkphdSpectrum.java | 20 +- .../modules/spectrum/GasbkphdSpectrum.java | 20 +- .../modules/spectrum/ParsingProcessLog.java | 755 ++++++++++++++++-- .../jeecg/modules/spectrum/QcphdSpectrum.java | 20 +- .../spectrum/S_D_Q_G_SpectrumHandler.java | 54 +- .../modules/spectrum/Sample_B_Analysis.java | 205 ++--- .../modules/spectrum/SamplephdSpectrum.java | 38 +- 15 files changed, 933 insertions(+), 341 deletions(-) create mode 100644 jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/AbstractLogOrReport.java diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/FileSourceHandleManager.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/FileSourceHandleManager.java index 16f76716..c18cbe1a 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/FileSourceHandleManager.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/FileSourceHandleManager.java @@ -159,7 +159,7 @@ public class FileSourceHandleManager { }catch (Exception e){ //解析失败会把文件上传到undeal目录 this.ftpUtil.saveFile(spectrumServiceQuotes.getSpectrumPathProperties().getFailPath(),this.fileName,new ByteArrayInputStream(fileContent.getBytes(StandardCharsets.UTF_8))); - log.error("Parsing the {} file of the undeal directory failed",fileName); + log.error("Parsing the {} file of the filesource directory failed",fileName); e.printStackTrace(); }finally { //解析成功或者失败都会删除源文件 diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/BlockConstant.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/BlockConstant.java index 9e3550ef..19528f40 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/BlockConstant.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/BlockConstant.java @@ -2,20 +2,27 @@ package org.jeecg.modules.service; public interface BlockConstant { - public final static String PHD = "PHD"; - public final static String SYSTEMTYPE_B = "B"; - public final static String ENERGY_CAL = "energy"; - public final static String RESOLUTION_CAL = "Resolution"; - public final static String SYSTEMTYPE_G = "G"; - public final static String EFFICIENCY_CAL ="efficiency"; + String PHD = "PHD"; + String SYSTEMTYPE_B = "B"; + String ENERGY_CAL = "energy"; + String RESOLUTION_CAL = "Resolution"; + String SYSTEMTYPE_G = "G"; + String EFFICIENCY_CAL ="efficiency"; - public final static String XE_131m = "Xe131m"; - public final static String XE_133m = "Xe133m"; - public final static String XE_133 = "Xe133"; - public final static String XE_135 = "Xe135"; + String XE_131m = "Xe131m"; + String XE_133m = "Xe133m"; + String XE_133 = "Xe133"; + String XE_135 = "Xe135"; - public final static String CH_Contant = "CH(x)"; - public final static String E_Contant = "E(x)"; + String CH_Contant = "CH(x)"; + String E_Contant = "E(x)"; + + String to_flag = " to "; + String arithmetic_flag = " +/- "; + String and_flag = " and "; + + String unit_kev = " keV"; + String unit_mbq = " mBq/m3"; } diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/ISpectrumBaseBlockService.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/ISpectrumBaseBlockService.java index 87ea970f..e7dfdbd3 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/ISpectrumBaseBlockService.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/ISpectrumBaseBlockService.java @@ -13,8 +13,9 @@ public interface ISpectrumBaseBlockService { * 不添加事务注解由调用方手动事务提交 * @param struct * @param fileName + * @param status * @return * @throws Exception */ - public GardsSampleData create(EnergySpectrumStruct struct,String fileName) throws Exception; + public GardsSampleData create(EnergySpectrumStruct struct,String fileName,String status) throws Exception; } diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsCalibrationPairsServiceImpl.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsCalibrationPairsServiceImpl.java index 6f721267..5f867db4 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsCalibrationPairsServiceImpl.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsCalibrationPairsServiceImpl.java @@ -65,19 +65,19 @@ public class GardsCalibrationPairsServiceImpl extends ServiceImpl 0){ + if(struct.g_record_count > 0){ List list = Lists.newArrayList(); - for (int i=0;i list = Lists.newArrayList(); - //C++那边没有补0,先加上后续解决后再删除 - analyseResult.LC.add(0,0.0D); for(int i=0;i fitting_e_c){ + String b_fittingEquation = this.getFittingEquation(fitting_type); + for(int i=0;iundeal目录 super.handleParseingFailFile(); throw e; }finally { - //结束流程日志 - super.storageProcessLogEnd(); + if(Objects.nonNull(this.parsingProcessLog)){ + this.parsingProcessLog.handleLog(); + } //删除本地临时文件 super.deleteLocalTemporaryFile(); } diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/GasbkphdSpectrum.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/GasbkphdSpectrum.java index e975fc03..7d61b387 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/GasbkphdSpectrum.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/GasbkphdSpectrum.java @@ -2,6 +2,8 @@ package org.jeecg.modules.spectrum; import lombok.extern.slf4j.Slf4j; import org.jeecg.modules.base.enums.DataType; +import org.jeecg.modules.base.enums.SampleStatus; +import java.util.Objects; /** * 气体谱处理 @@ -30,6 +32,8 @@ public class GasbkphdSpectrum extends S_D_Q_G_SpectrumHandler{ try{ //前置检查 this.preCheck(); + //声明日志处理对象 + super.initLogObj(); //打印当前处理的能谱类型 super.printCurrDataType(); //解析邮件内容 @@ -40,17 +44,21 @@ public class GasbkphdSpectrum extends S_D_Q_G_SpectrumHandler{ super.saveFileToFtp(); //结构体数据入库 super.handlerOriginalData(); - //处理流程日志 - super.handleProcessLog(); + //修改状态为解析完成 + super.status = SampleStatus.COMPLETE.getValue(); + super.updateStatus(); }catch (Exception e){ - //异常结束日志 - super.exceptionEndLog(e); + //修改状态为解析失败 + super.status = SampleStatus.FAIL.getValue(); + super.updateStatus(); + //处理解析失败的文件,上传到ftp->undeal目录 super.handleParseingFailFile(); throw e; }finally { - //结束流程日志 - super.storageProcessLogEnd(); + if(Objects.nonNull(this.parsingProcessLog)){ + this.parsingProcessLog.handleLog(); + } //删除本地临时文件 super.deleteLocalTemporaryFile(); } diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/ParsingProcessLog.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/ParsingProcessLog.java index 3ba08fe8..7234d754 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/ParsingProcessLog.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/ParsingProcessLog.java @@ -1,12 +1,22 @@ package org.jeecg.modules.spectrum; +import com.google.common.collect.Lists; import lombok.Setter; import org.jeecg.common.constant.StringConstant; import org.jeecg.common.properties.SpectrumPathProperties; import org.jeecg.common.util.DateUtils; +import org.jeecg.modules.base.enums.DataType; import org.jeecg.modules.base.enums.SampleStatus; +import org.jeecg.modules.base.enums.SystemType; +import org.jeecg.modules.native_jni.struct.BgAnalyseResult; +import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct; +import org.jeecg.modules.service.BlockConstant; + import java.io.ByteArrayInputStream; import java.nio.charset.StandardCharsets; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; /** * B谱邮件解析流程日志 @@ -14,17 +24,33 @@ import java.nio.charset.StandardCharsets; public class ParsingProcessLog { /** - * 日志内容 + * 存储日志内容 */ - private StringBuilder log = new StringBuilder(); + private StringBuilder storageLog = new StringBuilder(); + /** - * 日志存储结束标记 + * 分析日志内容 */ - private boolean logStoreEndFlag = false; + private StringBuilder analysisLog = new StringBuilder(); + /** - * 日志分析结束标记 + * PHD文件是否重复 */ - private boolean logAnalyseEndFlag = false; + @Setter + private boolean fileRepeat = false; + + /** + * Gas、Det文件是否存在 + */ + @Setter + private boolean fileNotExist = false; + + /** + * 分析数据是否存储成功 + */ + @Setter + private boolean analysisDataStoreFlag = false; + /** * 能谱处理父类 */ @@ -38,7 +64,11 @@ public class ParsingProcessLog { /** * 解析过程日志对象 */ - private StorageProcessLog processLog; + private StorageProcessLog storageProcessLog; + /** + * 分析流程日志对象 + */ + private AnalyseProcessLog analyseProcessLog; /** * 存储过程日志处理 @@ -46,7 +76,7 @@ public class ParsingProcessLog { protected class StorageProcessLog{ private static final String WRITE_INTO_START = "%s Write Data into Database at %s %s"; - private static final String APPLICATION_PATH = "ApplicationPath:%s,ApplicationName:%s,started by RNAUTO at %s"; + private static final String APPLICATION_PATH = "ApplicationPath: %s,ApplicationName: %s,started by RNAUTO at %s"; private static final String DATABASE_CONNECTED = "Successfully connected to database,source:%s,user=%s"; private static final String SOURCE_FILE = "SourceFile:%s"; private static final String STANDARD_FILE = "StandardFile:%s"; @@ -61,21 +91,27 @@ public class ParsingProcessLog { /** * 开始处理存储过程日志 */ - private void start(){ + private void handleStorageProcessLog(){ //获取数据源属性 final String oraUsername = spectrumHandler.spectrumServiceQuotes.getOraDataSourceProperties().getUsername(); final String oraUrl = spectrumHandler.spectrumServiceQuotes.getOraDataSourceProperties().getUrl(); final String startIntoDatabaseTime = DateUtils.formatDate(spectrumHandler.startIntoDatabaseTime, "yyyy-MM-dd HH:mm:ss"); final String standardFile = spectrumHandler.spectrumServiceQuotes.getFtpProperties().getFtpRootPath() + StringConstant.SLASH + spectrumHandler.ftpSavePath; - log.append(titleFormat(WRITE_INTO_START,26, StringConstant.DASH,startIntoDatabaseTime,StringConstant.DASH)); - log.append(System.lineSeparator()).append(System.lineSeparator()); - log.append(rowFormat(APPLICATION_PATH,spectrumHandler.getProjectAbsolutePath(),spectrumHandler.getProjectName(),startIntoDatabaseTime)); - log.append(System.lineSeparator()).append(System.lineSeparator()); - log.append(rowFormat(DATABASE_CONNECTED,oraUrl.substring(oraUrl.lastIndexOf(":")+1),oraUsername)); - log.append(System.lineSeparator()).append(System.lineSeparator()); - log.append(rowFormat(SOURCE_FILE,spectrumHandler.mailFile.getAbsolutePath())); - log.append(System.lineSeparator()); - log.append(rowFormat(STANDARD_FILE,standardFile)); + storageLog.append(titleFormat(WRITE_INTO_START,26, StringConstant.DASH,startIntoDatabaseTime,StringConstant.DASH)); + storageLog.append(System.lineSeparator()).append(System.lineSeparator()); + storageLog.append(rowFormat(APPLICATION_PATH,spectrumHandler.getProjectAbsolutePath(),spectrumHandler.getProjectName(),startIntoDatabaseTime)); + storageLog.append(System.lineSeparator()).append(System.lineSeparator()); + storageLog.append(rowFormat(DATABASE_CONNECTED,oraUrl.substring(oraUrl.lastIndexOf(":")+1),oraUsername)); + storageLog.append(System.lineSeparator()).append(System.lineSeparator()); + storageLog.append(rowFormat(SOURCE_FILE,spectrumHandler.mailFile.getAbsolutePath())); + storageLog.append(System.lineSeparator()); + storageLog.append(rowFormat(STANDARD_FILE,standardFile)); + storageLog.append(System.lineSeparator()).append(System.lineSeparator()); + if(fileRepeat){ + this.endOfFileRepeat(); + }else{ + this.end(); + } } /** @@ -83,10 +119,10 @@ public class ParsingProcessLog { */ private void endOfFileRepeat(){ final String endIntoDatabaseTime = DateUtils.formatDate(spectrumHandler.endIntoDatabaseTime, "yyyy-MM-dd HH:mm:ss"); - log.append(System.lineSeparator()).append(System.lineSeparator()); - log.append(rowFormat(FILE_REPEAT,spectrumHandler.ftpSavePath)); - log.append(System.lineSeparator()).append(System.lineSeparator()); - log.append(titleFormat(WRITE_INTO_ERROR,19,StringConstant.DASH,endIntoDatabaseTime,StringConstant.DASH)); + storageLog.append(rowFormat(FILE_REPEAT,spectrumHandler.ftpSavePath)); + storageLog.append(System.lineSeparator()).append(System.lineSeparator()); + storageLog.append(titleFormat(WRITE_INTO_ERROR,19,StringConstant.DASH,endIntoDatabaseTime,StringConstant.DASH)); + storageLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator()); } /** @@ -94,106 +130,663 @@ public class ParsingProcessLog { */ private void end(){ final String endIntoDatabaseTime = DateUtils.formatDate(spectrumHandler.endIntoDatabaseTime, "yyyy-MM-dd HH:mm:ss"); - log.append(System.lineSeparator()).append(System.lineSeparator()); - log.append(rowFormat(DETECTOR_ID,spectrumHandler.sampleData.getDetectorId().toString())); - log.append(System.lineSeparator()); - log.append(rowFormat(STATION_ID,spectrumHandler.sampleData.getStationId().toString())); - log.append(System.lineSeparator()); - log.append(rowFormat(SAMPLE_ID,spectrumHandler.sampleData.getSampleId().toString())); - log.append(System.lineSeparator()).append(System.lineSeparator()); - log.append(rowFormat(INSTANCE_STATUS, SampleStatus.UNTREATED.getValue())); - log.append(System.lineSeparator()).append(System.lineSeparator()); - log.append(titleFormat(WRITE_INTO_SUCCESS,19,StringConstant.DASH,endIntoDatabaseTime,StringConstant.DASH)); + storageLog.append(rowFormat(DETECTOR_ID,spectrumHandler.sampleData.getDetectorId().toString())); + storageLog.append(System.lineSeparator()); + storageLog.append(rowFormat(STATION_ID,spectrumHandler.sampleData.getStationId().toString())); + storageLog.append(System.lineSeparator()); + storageLog.append(rowFormat(SAMPLE_ID,spectrumHandler.sampleData.getSampleId().toString())); + storageLog.append(System.lineSeparator()).append(System.lineSeparator()); + storageLog.append(rowFormat(INSTANCE_STATUS,spectrumHandler.status)); + storageLog.append(System.lineSeparator()).append(System.lineSeparator()); + storageLog.append(titleFormat(WRITE_INTO_SUCCESS,19,StringConstant.DASH,endIntoDatabaseTime,StringConstant.DASH)); + storageLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator()); } } /** * 分析过程日志 */ - private class AnalyseProcessLog{ - private static final String anlyseResultsBegin = "%s Sample Analyse Beginning at %s %s"; - private static final String titleId = "%s Get DetaId and GasId %s"; - private static final String getDetaId = "%s Search DetFile :%s SampleID :%s"; - private static final String titleIdEnd = "%s Get DetaId and GasId finished %s"; - private static final String titleCalibration = "%s Read calibration data %s"; - private static final String setSampleBEnergyChannel = "Reading sample beta energy pairs(sampleID: %s)....."; - private static final String setSampleGEnergyChannel = "Reading sample gamma energy pairs(sampleID: %s)....."; - private static final String setDetaBEnergyChannel = "Reading DETBK Spectrum beta energy pairs(sampleID: %s)....."; - private static final String setDetaGEnergyChannel = "Reading DETBK Spectrum gamma energy pairs(sampleID: %s)....."; - private static final String setGasBEnergyChannel = "Reading GASBK Spectrum beta energy pairs(sampleID: %s)....."; - private static final String setGasGEnergyChannel = "Reading GASBK Spectrum gamma energy pairs(sampleID: %s)"; - private static final String getMeasurementTime = "Reading mesurement information....."; - - private static final String dataStore = "Data store %s ....."; - private static final String setStatus = "Instance status successfully set to: %s ....."; - private static final String anlyseResultsEnd = "%s Sample Analyse Successfully at %s %s"; - private static final String dataAnlyseError = "Data Anlyse Error:gas or det file is no exist or is error.."; - private static final String anlyseResultsErrorEnd="%s Sample Analyse Error at %s %s"; + private class AnalyseProcessLog extends AbstractLogOrReport implements BlockConstant { /** * 开始处理分析过程日志 */ - private void start(){ + private void handleAnalysisProcessLog(){ final String anlyseResultsBegin = "%s Sample Analyse Beginning at %s %s"; + final String storeResult = "Data store %s ....."; + final String storeStatus = "Instance status %s set to: %s....."; + final String analysisResultsEnd = "%s Sample Analyse %s at %s %s"; + String storeFlag = "successfully"; final String startAnalysisTime = DateUtils.formatDate(sample_B_Analysis.startAnalysisTime, "yyyy-MM-dd HH:mm:ss"); - log.append(titleFormat(anlyseResultsBegin,26,StringConstant.DASH,startAnalysisTime,StringConstant.DASH)); + final String endAnalysisTime = DateUtils.formatDate(sample_B_Analysis.endAnalysisTime, "yyyy-MM-dd HH:mm:ss"); + analysisLog.append(titleFormat(anlyseResultsBegin,26,StringConstant.DASH,startAnalysisTime,StringConstant.DASH)); + analysisLog.append(System.lineSeparator()).append(System.lineSeparator()); + + this.setDetAndGasIdLog(); + if(fileNotExist){ + // Gas谱或Det谱文件找不到异常结束 + fileNotExistException(); + } + this.readCalibrationData(); + this.reading_roi_limits(); + this.reading_roi_ratios(); + this.reading_B_G_Efficiency(); + this.NCC_analysis(); + + if(analysisDataStoreFlag == true){ + storeFlag = "error"; + } + analysisLog.append(rowFormat(storeResult,storeFlag)); + analysisLog.append(System.lineSeparator()).append(System.lineSeparator()); + analysisLog.append(rowFormat(storeStatus,storeFlag,spectrumHandler.status)); + analysisLog.append(System.lineSeparator()).append(System.lineSeparator()); + analysisLog.append(titleFormat(analysisResultsEnd,25,StringConstant.DASH,storeFlag,endAnalysisTime,StringConstant.DASH)); + analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator()); } + /** + * 处理获取Det和Gas文件日志 + */ private void setDetAndGasIdLog(){ - final String titleId = "%s Get DetaId and GasId %s"; - log.append(titleFormat(titleId,40,StringConstant.DOT,StringConstant.DOT)); + final String title = "%s Get DetaId and GasId %s"; + final String detaInfo = "%s Search DetFile :%s SampleID :%s"; + final String gasInfo = "%s Search GasFile :%s SampleID :%s"; + final String titleEnd = "%s Get DetaId and GasId finished %s"; + String detExist = "Error"; + String gasExist = "Error"; + String detMeasurementId = sample_B_Analysis.sampleStruct.detector_bk_measurement_id; + String gasMeasurementId = sample_B_Analysis.sampleStruct.gas_bk_measurement_id; + String detSampleId = StringConstant.ZERO; + String gasSampleId = StringConstant.ZERO; + if(Objects.nonNull(sample_B_Analysis.detSampleData)){ + detExist = "Successfully"; + detSampleId = sample_B_Analysis.detSampleData.getSampleId().toString(); + } + if(Objects.nonNull(sample_B_Analysis.gasSampleData)){ + gasExist = "Successfully"; + gasSampleId = sample_B_Analysis.gasSampleData.getSampleId().toString(); + } + analysisLog.append(titleFormat(title,40,StringConstant.DOT,StringConstant.DOT)); + analysisLog.append(System.lineSeparator()).append(System.lineSeparator()); + analysisLog.append(rowFormat(detaInfo,detExist,detMeasurementId,detSampleId)); + analysisLog.append(System.lineSeparator()).append(System.lineSeparator()); + analysisLog.append(rowFormat(gasInfo,gasExist,gasMeasurementId,gasSampleId)); + analysisLog.append(System.lineSeparator()).append(System.lineSeparator()); + analysisLog.append(titleFormat(titleEnd,35,StringConstant.DOT,StringConstant.DOT)); + analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator()); + } + + /** + * Gas谱或Det谱文件找不到异常结束 + */ + private void fileNotExistException(){ + final String dataAnlyseError = "%s Data Anlyse Error:gas or det file is no exist or is error.."; + final String anlyseResultsErrorEnd="%s Sample Analyse Error at %s %s"; + final String startAnalysisTime = DateUtils.formatDate(sample_B_Analysis.startAnalysisTime, "yyyy-MM-dd HH:mm:ss"); + analysisLog.append(rowFormat(dataAnlyseError,startAnalysisTime)); + analysisLog.append(System.lineSeparator()).append(System.lineSeparator()); + analysisLog.append(titleFormat(anlyseResultsErrorEnd,28,StringConstant.DASH,startAnalysisTime,StringConstant.DASH)); + analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator()); + } + + /** + * ... Read calibration data ... + */ + private void readCalibrationData(){ + final String titleCalibration = "%s Read calibration data %s"; + final String titleCalibrationFinished = "%s Read calibration finished %s"; + analysisLog.append(titleFormat(titleCalibration,39,StringConstant.DOT,StringConstant.DOT)); + analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator()); + + this.readSampleEnergyPairs(); + this.readDetEnergyPairs(); + this.readGasEnergyPairs(); + this.readingMesurementInformation(); + this.readingVolumeData(); + analysisLog.append(titleFormat(titleCalibrationFinished,37,StringConstant.DOT,StringConstant.DOT)); + analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator()); + } + + /** + * Reading sample beta/Gamma energy pairs + */ + private void readSampleEnergyPairs(){ + final String sampleEnergyPairsTitle = "Reading sample %s energy pairs(sampleID: %s)....."; + String format = "Channel : %-11s Energy : %-15s Error : %s"; + analysisLog.append(rowFormat(sampleEnergyPairsTitle,"beta",sample_B_Analysis.sampleData.getSampleId().toString())); + analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator()); + EnergySpectrumStruct struct = sample_B_Analysis.sampleStruct; + for(int i=0;i b_chan_start = analyseResult.S_ROI_B_Boundary_start; + List b_chan_stop = analyseResult.S_ROI_B_Boundary_stop; + List g_chan_start = analyseResult.S_ROI_G_Boundary_start; + List g_chan_stop = analyseResult.S_ROI_G_Boundary_stop; + List roi = analyseResult.S_ROI; + + analysisLog.append(rowFormat(title,sample_B_Analysis.sampleData.getSampleId().toString())); + analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator()); + + String channels = " channels"; + for (int i=0;i b_chan_start = analyseResult.G_ROI_B_Boundary_start; + List b_chan_stop = analyseResult.G_ROI_B_Boundary_stop; + List g_chan_start = analyseResult.G_ROI_G_Boundary_start; + List g_chan_stop = analyseResult.G_ROI_G_Boundary_stop; + List roi = analyseResult.G_ROI; + + analysisLog.append(rowFormat(title,sample_B_Analysis.gasSampleData.getSampleId().toString())); + analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator()); + + String channels = " channels"; + for (int i=0;i b_chan_start = analyseResult.G_ROI_B_Boundary_start; + List b_chan_stop = analyseResult.G_ROI_B_Boundary_stop; + List g_chan_start = analyseResult.G_ROI_G_Boundary_start; + List g_chan_stop = analyseResult.G_ROI_G_Boundary_stop; + List roi = analyseResult.G_ROI; + + analysisLog.append(rowFormat(title,sample_B_Analysis.gasSampleData.getSampleId().toString())); + analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator()); + + String channels = " channels"; + for (int i=0;i roi = analyseResult.ROI.stream().map(Object::toString).collect(Collectors.toList()); + List s_roi_cts = analyseResult.s_roi_cts.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList()); + List g_roi_cts = analyseResult.g_roi_cts.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList()); + List d_roi_cts = analyseResult.d_roi_cts.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList()); + + analysisLog.append(title); + analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator()); + for (int i=0;i roi_net_count = analyseResult.ROI_net_coutns; + List roi_net_count_err = analyseResult.ROI_net_coutns_err; + List roi = analyseResult.ROI.stream().map(String::valueOf).collect(Collectors.toList()); + //此参数需第一位补0 + analyseResult.LC_CTS.add(0,0D); + List lc = analyseResult.LC_CTS.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList()); + + analysisLog.append(title); + analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator()); + + for(int i=0;i con = analyseResult.ROI_con_uncer.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList()); + List conErr = analyseResult.ROI_con_uncer_err.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList()); + analyseResult.LC.add(0,0.0D); + analyseResult.MDC.add(0,0.0D); + List roi = analyseResult.ROI.stream().map(Object::toString).collect(Collectors.toList()); + List lc = analyseResult.LC.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList()); + List mdc = analyseResult.MDC.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList()); + + analysisLog.append(title); + analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator()); + + for(int i=0;ianalyseResult.MDC_Xe135?"1":"0"; + String xe_131m_nid_flag = analyseResult.Xe131m_con>analyseResult.MDC_Xe131m?"1":"0"; + String xe_133m_nid_flag = analyseResult.Xe133m_con>analyseResult.MDC_Xe133m?"1":"0"; + String xe_133_nid_flag = analyseResult.Xe133_con>analyseResult.MDC_Xe133?"1":"0"; + String[] nid_flag = {xe_135_nid_flag,xe_131m_nid_flag,xe_133m_nid_flag,xe_133_nid_flag}; + + analysisLog.append(title); + analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator()); + + for(int i=0;iundeal目录 super.handleParseingFailFile(); throw e; }finally { - //结束流程日志 - super.storageProcessLogEnd(); + if(Objects.nonNull(this.parsingProcessLog)){ + this.parsingProcessLog.handleLog(); + } //删除本地临时文件 super.deleteLocalTemporaryFile(); } diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/S_D_Q_G_SpectrumHandler.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/S_D_Q_G_SpectrumHandler.java index 6471f1fc..0fd305ef 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/S_D_Q_G_SpectrumHandler.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/S_D_Q_G_SpectrumHandler.java @@ -9,6 +9,7 @@ import org.jeecg.common.constant.StringConstant; import org.jeecg.common.properties.SpectrumPathProperties; import org.jeecg.modules.base.entity.original.GardsSampleData; import org.jeecg.modules.base.enums.DataType; +import org.jeecg.modules.base.enums.SampleStatus; import org.jeecg.modules.config.datasource.DataSourceSwitcher; import org.jeecg.modules.exception.AcquisitionBlockException; import org.jeecg.modules.exception.FileRepeatException; @@ -63,6 +64,10 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{ * 流程日志对象 */ protected ParsingProcessLog parsingProcessLog; + /** + * 能谱文件处理状态,默认为:未处理 + */ + protected String status = SampleStatus.UNTREATED.getValue(); /** * 前置检查 @@ -211,13 +216,15 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{ if(Objects.nonNull(query)){ this.sampleData = query; this.endIntoDatabaseTime = new Date(); + //设置文件重复标记为true + this.parsingProcessLog.setFileRepeat(true); throw new FileRepeatException("file repeat"); } DataSourceSwitcher.switchToOracle(); final TransactionStatus transactionStatus = spectrumServiceQuotes.getTransactionManager().getTransaction(spectrumServiceQuotes.getTransactionDefinition()); try{ //存储基础数据 - this.sampleData = spectrumServiceQuotes.getSpectrumBaseBlockService().create(this.sourceData,super.ftpSavePath); + this.sampleData = spectrumServiceQuotes.getSpectrumBaseBlockService().create(this.sourceData,super.ftpSavePath,status); //存储其他块数据 for(String labels : spectrumFileLabels){ final ISpectrumBlockService spectrumBlockService = spectrumServiceQuotes.getSpectrumBlockService().get(labels); @@ -237,6 +244,22 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{ } } + /** + * 修改解析状态 + */ + protected void updateStatus(){ + this.spectrumServiceQuotes.getSampleDataService().updateStatus(this.status,this.sampleData.getInputFileName()); + } + + /** + * 声明日志处理对象 + */ + protected void initLogObj(){ + ParsingProcessLog parsingProcessLog = new ParsingProcessLog(); + parsingProcessLog.setSpectrumHandler(this); + this.parsingProcessLog = parsingProcessLog; + } + /** * 获取项目绝对路径 * @return @@ -268,33 +291,4 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{ } return Strings.EMPTY; } - - /** - * 创建流程日志对象处理解析流程日志 - */ - protected void handleProcessLog(){ - ParsingProcessLog parsingProcessLog = new ParsingProcessLog(); - parsingProcessLog.setSpectrumHandler(this); - parsingProcessLog.storageProcessLogStart(); - this.parsingProcessLog = parsingProcessLog; - } - - /** - * 异常结束日志 - * @param e - */ - protected void exceptionEndLog(Exception e){ - if(e instanceof FileRepeatException){ - this.parsingProcessLog.endOfFileRepeat(); - } - } - - /** - * 正常结束日志 - */ - protected void storageProcessLogEnd(){ - if(Objects.nonNull(this.parsingProcessLog)){ - this.parsingProcessLog.storageProcessLogEnd(); - } - } } \ No newline at end of file diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_B_Analysis.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_B_Analysis.java index f4aed486..81b45857 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_B_Analysis.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_B_Analysis.java @@ -12,7 +12,6 @@ import org.jeecg.modules.base.entity.original.GardsSampleData; import org.jeecg.modules.base.entity.rnauto.GardsAnalyses; import org.jeecg.modules.base.enums.DataType; import org.jeecg.modules.base.enums.DataTypeAbbr; -import org.jeecg.modules.base.enums.FittingEquation; import org.jeecg.modules.base.enums.SampleStatus; import org.jeecg.modules.config.datasource.DataSourceSwitcher; import org.jeecg.modules.exception.BAnalyseException; @@ -40,38 +39,30 @@ public class Sample_B_Analysis implements BlockConstant { */ private static final String ARR_FILE_SUFFIX = ".txt"; private static final String ARR_FILE_NAME_TAIL = "_rpt"; - /** - * 正常分析过程日志 - */ - private StringBuilder analysesLog = new StringBuilder(); - /** - * 分析过程当前状态 - */ - private String currAnalysesStatus = null; /** * Sample谱结构体数据 */ - private EnergySpectrumStruct sampleStruct = null; + protected EnergySpectrumStruct sampleStruct = null; /** * sample谱原始数据 */ - private GardsSampleData sampleData = null; + protected GardsSampleData sampleData = null; /** * gas谱结构体数据 */ - private EnergySpectrumStruct gasStruct = null; + protected EnergySpectrumStruct gasStruct = null; /** * gas谱原始数据 */ - private GardsSampleData detSampleData = null; + protected GardsSampleData detSampleData = null; /** * det谱结构体数据 */ - private EnergySpectrumStruct detStruct = null; + protected EnergySpectrumStruct detStruct = null; /** * det谱原始数据 */ - private GardsSampleData gasSampleData = null; + protected GardsSampleData gasSampleData = null; /** * sample谱PHD文件临时路径 */ @@ -111,7 +102,7 @@ public class Sample_B_Analysis implements BlockConstant { /** * 分析结果 */ - private BgAnalyseResult analyseResult; + protected BgAnalyseResult analyseResult; /** * 开始分析时间 */ @@ -121,11 +112,16 @@ public class Sample_B_Analysis implements BlockConstant { */ protected Date endAnalysisTime; + /** + * 流程日志对象 + */ + protected ParsingProcessLog parsingProcessLog; + public Sample_B_Analysis() { } public Sample_B_Analysis(GardsSampleData sampleData, String sampleTempFilePath, SpectrumServiceQuotes spectrumServiceQuotes, - EnergySpectrumStruct sampleStruct, FTPUtils ftpUtil, String logFilePath, String logFileName){ + EnergySpectrumStruct sampleStruct, FTPUtils ftpUtil, String logFilePath, String logFileName,ParsingProcessLog parsingProcessLog){ this.sampleData = sampleData; this.sampleTempFilePath = sampleTempFilePath; this.spectrumServiceQuotes = spectrumServiceQuotes; @@ -133,6 +129,7 @@ public class Sample_B_Analysis implements BlockConstant { this.ftpUtil = ftpUtil; this.logFilePath = logFilePath; this.logFileName = logFileName; + this.parsingProcessLog = parsingProcessLog; } /** @@ -140,8 +137,9 @@ public class Sample_B_Analysis implements BlockConstant { */ public void start() throws BAnalyseException { try{ - //修改状态为分析中 - this.updateStatus(SampleStatus.IN_PROCESS.getValue()); + this.startAnalysisTime = new Date(); + //声明分析日志对象 + parsingProcessLog.setSample_B_Analysis(this); //查询det、gas数据(sampleId,inputFileName),sample数据在构造函数已经传过来 this.queryPHDFile(); //构造报告文件存储路径及文件名称,日志文件存储路径及文件名称在原始库存储阶段已存在,已经传过来 @@ -155,28 +153,16 @@ public class Sample_B_Analysis implements BlockConstant { //生成报告 Sample_B_Analysis.B_AnalysisReport report = new Sample_B_Analysis.B_AnalysisReport(); report.start(); - //修改状态为分析成功 - this.updateStatus(SampleStatus.COMPLETE.getValue()); }catch (Exception e){ - //修改状态为分析失败 - this.spectrumServiceQuotes.getSampleDataService().updateStatus(SampleStatus.FAIL.getValue(),this.sampleData.getInputFileName()); e.printStackTrace(); throw new BAnalyseException("Sample Analyse Error at "+DateUtils.formatDate(new Date(),"yyyy-MM-dd HH:mm:ss")); }finally { + this.endAnalysisTime = new Date(); //删除下载的det和gas临时文件 this.deleteLocalTemporaryFile(); } } - /** - * 修改状态 - * @param analysesStatus - */ - private void updateStatus(String analysesStatus){ - this.currAnalysesStatus = analysesStatus; - this.spectrumServiceQuotes.getSampleDataService().updateStatus(this.currAnalysesStatus,this.sampleData.getInputFileName()); - } - /** * 查询det、gas数据,sample在构造函数已经传过来 * @throws FileNotExistException @@ -188,8 +174,9 @@ public class Sample_B_Analysis implements BlockConstant { //如果找不到sample、det、gas谱文件数据则解析失败修改记录状态 if(StringUtils.isEmpty(this.sampleData.getInputFileName()) || Objects.isNull(this.detSampleData) || StringUtils.isEmpty(this.detSampleData.getInputFileName()) || Objects.isNull(this.gasSampleData) || StringUtils.isEmpty(this.gasSampleData.getInputFileName())){ - this.spectrumServiceQuotes.getSampleDataService().updateStatus(SampleStatus.FAIL.getValue(),this.sampleData.getInputFileName()); + parsingProcessLog.setFileNotExist(true); + this.spectrumServiceQuotes.getSampleDataService().updateStatus(SampleStatus.FAIL.getValue(),this.sampleData.getInputFileName()); throw new FileNotExistException("gas or det file is no exist or is error.."); } } @@ -224,14 +211,12 @@ public class Sample_B_Analysis implements BlockConstant { * 调用dll库的分析B谱结果 */ private void autoAnalyse() throws BAnalyseException, FileNotExistException { - this.startAnalysisTime = new Date(); System.out.println("sam:"+this.sampleTempFilePath); System.out.println("gas:"+this.gasTempFilePath); System.out.println("det:"+this.detTempFilePath); BgAnalyseResult analyseResult = EnergySpectrumHandler.bgAnalyse(this.sampleTempFilePath,this.gasTempFilePath,this.detTempFilePath); System.out.println(analyseResult); - this.endAnalysisTime = new Date(); if(Objects.isNull(analyseResult) || !analyseResult.analyse_flag){ throw new BAnalyseException("THE PHD file cannot be parsed:"+this.sampleTempFilePath+","+this.gasTempFilePath+","+this.detTempFilePath); } @@ -263,10 +248,11 @@ public class Sample_B_Analysis implements BlockConstant { detTempFilePath = this.spectrumServiceQuotes.getTaskProperties().getTemporaryStoragePath()+ File.separator+detFileName; if(flag){ + parsingProcessLog.setFileNotExist(true); throw new FileNotExistException("gas or det file is no exist or is error.."); } - this.detStruct = EnergySpectrumHandler.getSourceData(detSampleData.getInputFileName()); - this.gasStruct = EnergySpectrumHandler.getSourceData(gasSampleData.getInputFileName()); + this.detStruct = EnergySpectrumHandler.getSourceData(detTempFilePath); + this.gasStruct = EnergySpectrumHandler.getSourceData(gasTempFilePath); } /** @@ -309,6 +295,8 @@ public class Sample_B_Analysis implements BlockConstant { //提交事务 spectrumServiceQuotes.getTransactionManager().commit(transactionStatus); }catch (Exception e){ + //设置分析数据存储失败标记 + this.parsingProcessLog.setAnalysisDataStoreFlag(false); //回滚事务 spectrumServiceQuotes.getTransactionManager().rollback(transactionStatus); throw e; @@ -343,7 +331,7 @@ public class Sample_B_Analysis implements BlockConstant { /** * B谱分析报告 */ - private class B_AnalysisReport{ + private class B_AnalysisReport extends AbstractLogOrReport{ /** * 模版内容 */ @@ -483,10 +471,10 @@ public class Sample_B_Analysis implements BlockConstant { */ private void handleSampleCalibration() throws IOException { String[] betaArr = {CH_Contant+this.calibration(analyseResult.s_b_fitting_type,analyseResult.s_b_fitting_e_c), - E_Contant+this.calibration(analyseResult.s_b_fitting_type,analyseResult.s_b_fitting_c_e)}; + E_Contant+super.calibration(analyseResult.s_b_fitting_type,analyseResult.s_b_fitting_c_e)}; String[] gammaArr = {CH_Contant+this.calibration(analyseResult.s_g_fitting_type,analyseResult.s_g_fitting_e_c), - E_Contant+this.calibration(analyseResult.s_g_fitting_type,analyseResult.s_g_fitting_c_e)}; + E_Contant+super.calibration(analyseResult.s_g_fitting_type,analyseResult.s_g_fitting_c_e)}; this.handleTwoParamFormat("#SAMPLE CALIBRATION",betaArr,gammaArr); } @@ -515,10 +503,10 @@ public class Sample_B_Analysis implements BlockConstant { * 处理#DET CALIBRATION 模块 */ private void handleDetCalibration() throws IOException { - String[] betaArr = {CH_Contant+this.calibration(analyseResult.d_b_fitting_type,analyseResult.d_b_fitting_e_c), + String[] betaArr = {CH_Contant+super.calibration(analyseResult.d_b_fitting_type,analyseResult.d_b_fitting_e_c), E_Contant+this.calibration(analyseResult.d_b_fitting_type,analyseResult.d_b_fitting_c_e)}; - String[] gammaArr = {CH_Contant+this.calibration(analyseResult.d_g_fitting_type,analyseResult.d_g_fitting_e_c), + String[] gammaArr = {CH_Contant+super.calibration(analyseResult.d_g_fitting_type,analyseResult.d_g_fitting_e_c), E_Contant+this.calibration(analyseResult.d_g_fitting_type,analyseResult.d_g_fitting_c_e)}; this.handleTwoParamFormat("#DET CALIBRATION",betaArr,gammaArr); @@ -549,10 +537,10 @@ public class Sample_B_Analysis implements BlockConstant { */ private void handleGasCalibration() throws IOException { String[] betaArr = {CH_Contant+this.calibration(analyseResult.g_b_fitting_type,analyseResult.g_b_fitting_e_c), - E_Contant+this.calibration(analyseResult.g_b_fitting_type,analyseResult.g_b_fitting_c_e)}; + E_Contant+super.calibration(analyseResult.g_b_fitting_type,analyseResult.g_b_fitting_c_e)}; String[] gammaArr = {CH_Contant+this.calibration(analyseResult.g_g_fitting_type,analyseResult.g_g_fitting_e_c), - E_Contant+this.calibration(analyseResult.g_g_fitting_type,analyseResult.g_g_fitting_c_e)}; + E_Contant+super.calibration(analyseResult.g_g_fitting_type,analyseResult.g_g_fitting_c_e)}; this.handleTwoParamFormat("#GAS CALIBRATION",betaArr,gammaArr); } @@ -569,10 +557,9 @@ public class Sample_B_Analysis implements BlockConstant { List roi = analyseResult.G_ROI.stream().map(Object::toString).collect(Collectors.toList()); List beta = Lists.newArrayList(); List gamma = Lists.newArrayList(); - String flag = " to "; for(int i=0;i roi = analyseResult.ROI.stream().map(Object::toString).collect(Collectors.toList()); - List s_roi_cts = analyseResult.s_roi_cts.stream().map(v->formatToStr5(v)).collect(Collectors.toList()); - List g_roi_cts = analyseResult.g_roi_cts.stream().map(v->formatToStr5(v)).collect(Collectors.toList()); - List d_roi_cts = analyseResult.d_roi_cts.stream().map(v->formatToStr5(v)).collect(Collectors.toList()); + List s_roi_cts = analyseResult.s_roi_cts.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList()); + List g_roi_cts = analyseResult.g_roi_cts.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList()); + List d_roi_cts = analyseResult.d_roi_cts.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList()); this.handleFourParamFormat("#GROSS COUNTS PER ROI",roi,s_roi_cts,g_roi_cts,d_roi_cts); } @@ -599,11 +586,10 @@ public class Sample_B_Analysis implements BlockConstant { List roi = analyseResult.ROI.stream().map(Object::toString).collect(Collectors.toList()); //此参数需第一位补0 analyseResult.LC_CTS.add(0,0D); - List lc = analyseResult.LC_CTS.stream().map(v->formatToStr5(v)).collect(Collectors.toList()); + List lc = analyseResult.LC_CTS.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList()); List netCount = Lists.newArrayList(); - String flag = " +/- "; for(int i=0;i con = analyseResult.ROI_con_uncer; List conErr = analyseResult.ROI_con_uncer_err; analyseResult.LC.add(0,0.0D); - String flag = " +/- "; + analyseResult.MDC.add(0,0.0D); List roi = analyseResult.ROI.stream().map(Object::toString).collect(Collectors.toList()); - List lc = analyseResult.LC.stream().map(v->formatToStr5(v)).collect(Collectors.toList()); - List mdc = Lists.newArrayList();//analyseResult.MDC.stream().map(Object::toString).collect(Collectors.toList()); - for(int i=0;i<10;i++){ - mdc.add("0.0"); - } + List lc = analyseResult.LC.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList()); + List mdc = analyseResult.MDC.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList()); List conc = Lists.newArrayList(); for(int i=0;ianalyseResult.MDC_Xe135?"1":"0"; String xe_131m_nid_flag = analyseResult.Xe131m_con>analyseResult.MDC_Xe131m?"1":"0"; @@ -664,46 +646,6 @@ public class Sample_B_Analysis implements BlockConstant { this.reportTmpFile.delete(); } - /** - * 获取sample、gas、det谱Beta和Gamma的CH(x)、E(x) - * @return - */ - private String calibration(Integer fitting_type, List fitting_e_c){ - String b_fittingEquation = this.getFittingEquation(fitting_type); - for(int i=0;i lines = FileUtils.readLines(file, "utf-8"); - - String[] betaArr = {"CH(x) = (-3.33443)+(0.398048)*x+(-0.000124015)x*x","E(x) = (12.0809)+(2.39764)*x+(0.00331138)x*x"}; - - String[] gammaArr = {"CH(x) = (0.879727)+(0.365551)*x+(-2.82212e-05)x*x","E(x) = (0.879727)+(0.365551)*x+(-2.82212e-05)x*x"}; - - for(int i=0;iundeal目录 super.handleParseingFailFile(); throw e; }finally { - //结束流程日志 - super.storageProcessLogEnd(); + if(Objects.nonNull(this.parsingProcessLog)){ + this.parsingProcessLog.handleLog(); + } //删除本地临时文件 super.deleteLocalTemporaryFile(); } @@ -65,14 +74,15 @@ public class SamplephdSpectrum extends S_D_Q_G_SpectrumHandler{ * @throws Exception */ protected void autoAnalysis() throws Exception { -// if(this.sourceData.system_type.equals(SystemType.BETA.getType())){ -// Sample_B_Analysis bAnalysis = new Sample_B_Analysis(super.sampleData,super.mailFile.getAbsolutePath(), -// super.spectrumServiceQuotes,super.sourceData,super.ftpUtil,super.logFilePath,super.logFileName); -// bAnalysis.start(); -// } - if (this.sourceData.system_type.equals(SystemType.GAMMA.getType())) { - Sample_G_Analysis sample_g_analysis = new Sample_G_Analysis(super.sourceData, super.spectrumServiceQuotes, super.sampleData); - sample_g_analysis.analysis(); + if(this.sourceData.system_type.equals(SystemType.BETA.getType())){ + Sample_B_Analysis bAnalysis = new Sample_B_Analysis(super.sampleData,super.mailFile.getAbsolutePath(), + super.spectrumServiceQuotes,super.sourceData,super.ftpUtil, + super.logFilePath,super.logFileName,super.parsingProcessLog); + bAnalysis.start(); } +// if (this.sourceData.system_type.equals(SystemType.GAMMA.getType())) { +// Sample_G_Analysis sample_g_analysis = new Sample_G_Analysis(super.sourceData, super.spectrumServiceQuotes, super.sampleData); +// sample_g_analysis.analysis(); +// } } } From 0e4b4039e3a708d4ecffe51c8746bc3cfb05097e Mon Sep 17 00:00:00 2001 From: qiaoqinzheng Date: Sun, 24 Sep 2023 18:43:20 +0800 Subject: [PATCH 02/11] =?UTF-8?q?GammaController=E6=96=B0=E5=A2=9EtestFun?= =?UTF-8?q?=E6=B5=8B=E8=AF=95dll=E5=88=86=E6=9E=90=E6=96=B9=E6=B3=95=20PHD?= =?UTF-8?q?File=E6=96=B0=E5=A2=9EuserId,xmlFilePath=E5=AD=97=E6=AE=B5=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=83=A8=E5=88=86=E5=AE=9E=E4=BD=93=E7=B1=BB?= =?UTF-8?q?=E5=86=85=E5=AD=97=E6=AE=B5=E5=A4=A7=E5=B0=8F=E5=86=99=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20CalValuesHandler=E5=8E=BB=E6=8E=89=E5=A4=9A?= =?UTF-8?q?=E4=BD=99=E7=9A=84=E8=AE=A1=E7=AE=97=E6=96=B9=E6=B3=95=EF=BC=8C?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=AE=9E=E7=8E=B0analyseSpectrum=E6=96=B9?= =?UTF-8?q?=E6=B3=95=20=E6=96=B0=E5=A2=9EBaseCtrlStack=E5=AE=9E=E4=BD=93?= =?UTF-8?q?=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/entity/vo/AcquisitionBlock.java | 4 +- .../jeecg/modules/entity/vo/BaseControls.java | 12 +- .../modules/entity/vo/BaseCtrlStack.java | 24 +++ .../modules/entity/vo/GEfficiencyBlock.java | 2 +- .../jeecg/modules/entity/vo/GEnergyBlock.java | 2 +- .../modules/entity/vo/GResolutionBlock.java | 2 +- .../jeecg/modules/entity/vo/NuclideLines.java | 16 +- .../org/jeecg/modules/entity/vo/PHDFile.java | 4 + .../jeecg/modules/entity/vo/SpecSetup.java | 2 +- .../java/org/jeecg/common/GammaFileUtil.java | 38 ++--- .../org/jeecg/common/util/GammaFileUtil.java | 147 ++++++++++++------ .../modules/controller/GammaController.java | 9 +- .../org/jeecg/modules/entity/vo/PeakInfo.java | 2 + .../modules/native_jni/CalValuesHandler.java | 20 +-- .../jeecg/modules/service/IGammaService.java | 2 +- .../service/impl/GammaServiceImpl.java | 103 ++++++++---- .../impl/GardsNuclLinesLibServiceImpl.java | 8 +- .../src/main/resources/application.yml | 2 +- 18 files changed, 254 insertions(+), 145 deletions(-) create mode 100644 jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/BaseCtrlStack.java diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/AcquisitionBlock.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/AcquisitionBlock.java index ad551e00..6808c1ee 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/AcquisitionBlock.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/AcquisitionBlock.java @@ -12,9 +12,9 @@ public class AcquisitionBlock implements Serializable { private String acquisition_start_time; // acquisition start time (hh : mm : ss . s) - private Double acquisition_real_time; // acquisition real time (s) + private double acquisition_real_time; // acquisition real time (s) - private Double acquisition_live_time; // acquisition live time (s) + private double acquisition_live_time; // acquisition live time (s) public AcquisitionBlock(){ acquisition_start_date=""; diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/BaseControls.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/BaseControls.java index f78b3977..aaec4cf0 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/BaseControls.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/BaseControls.java @@ -17,17 +17,19 @@ public class BaseControls implements Serializable { private List YSlope; private List Baseline; private List StepCounts; + private List BaseStack; public BaseControls(){ rg_low = 1; rg_high = 1; ReplotUsed = false; ReplotNeeded = false; - XCtrl=new LinkedList<>(); - YCtrl=new LinkedList<>(); - YSlope=new LinkedList<>(); - Baseline=new LinkedList<>(); - StepCounts=new LinkedList<>(); + XCtrl = new LinkedList<>(); + YCtrl = new LinkedList<>(); + YSlope = new LinkedList<>(); + Baseline = new LinkedList<>(); + StepCounts = new LinkedList<>(); + BaseStack = new LinkedList<>(); } } diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/BaseCtrlStack.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/BaseCtrlStack.java new file mode 100644 index 00000000..fef35815 --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/BaseCtrlStack.java @@ -0,0 +1,24 @@ +package org.jeecg.modules.entity.vo; + +import lombok.Data; + +import java.io.Serializable; +import java.util.LinkedList; +import java.util.List; + +@Data +public class BaseCtrlStack implements Serializable { + + private List cx; + + private List cy; + + private List cdy; + + public BaseCtrlStack(){ + cx = new LinkedList<>(); + cy = new LinkedList<>(); + cdy = new LinkedList<>(); + } + +} diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/GEfficiencyBlock.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/GEfficiencyBlock.java index 002936c2..b016d7dc 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/GEfficiencyBlock.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/GEfficiencyBlock.java @@ -15,7 +15,7 @@ public class GEfficiencyBlock implements Serializable { private List uncertainty; // uncertainty (counts in peak/photon emitted) - private Integer record_count; + private int record_count; public GEfficiencyBlock(){ g_energy = new LinkedList<>(); diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/GEnergyBlock.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/GEnergyBlock.java index b1c30949..a13d3f71 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/GEnergyBlock.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/GEnergyBlock.java @@ -15,7 +15,7 @@ public class GEnergyBlock implements Serializable { private List uncertainty; // uncertainty (channels) - private Integer record_count; + private int record_count; public GEnergyBlock(){ g_energy = new LinkedList<>(); diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/GResolutionBlock.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/GResolutionBlock.java index 90363fce..a1c9da7d 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/GResolutionBlock.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/GResolutionBlock.java @@ -15,7 +15,7 @@ public class GResolutionBlock implements Serializable { private List uncertainty; // uncertainty (keV) - private Integer record_count; + private int record_count; public GResolutionBlock(){ g_energy = new LinkedList<>(); diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/NuclideLines.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/NuclideLines.java index b5917aa8..994bbed0 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/NuclideLines.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/NuclideLines.java @@ -9,10 +9,10 @@ import java.util.List; @Data public class NuclideLines implements Serializable { public List fullNames; // 核素全名 - public List vEnergy; // 核素的所有γ射线能量 - public List vUncertE; - public List vYield; // 核素γ射线分支比 - public List vUncertY; + public List venergy; // 核素的所有γ射线能量 + public List vuncertE; + public List vyield; // 核素γ射线分支比 + public List vuncertY; public double halflife;// 单位:秒 public int key_flag; // 记录主射线下标 public int maxYeildIdx; @@ -22,10 +22,10 @@ public class NuclideLines implements Serializable { key_flag = -1; halflife = 0; fullNames=new LinkedList<>(); - vEnergy=new LinkedList<>(); - vUncertE=new LinkedList<>(); - vYield=new LinkedList<>(); - vUncertY=new LinkedList<>(); + venergy=new LinkedList<>(); + vuncertE=new LinkedList<>(); + vyield=new LinkedList<>(); + vuncertY=new LinkedList<>(); } } diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/PHDFile.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/PHDFile.java index 29b4fd5f..0739895b 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/PHDFile.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/PHDFile.java @@ -13,6 +13,10 @@ import java.util.Map; @JsonIgnoreProperties(ignoreUnknown = true) public class PHDFile implements Serializable { + private String userId; + + private String xmlFilePath; + private boolean isValid; // 是否有效谱 private boolean bAnalyed; // 记录是否被分析 diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/SpecSetup.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/SpecSetup.java index 3a86e209..60999248 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/SpecSetup.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/SpecSetup.java @@ -46,7 +46,7 @@ public class SpecSetup implements Serializable { public SpecSetup(){ eCutAnalysis_Low = 12.0; - eCutAnalysis_High = 12.0; + eCutAnalysis_High = -9999.0; energyTolerance = 0.5; calibrationPSS_high = 10.0; calibrationPSS_low = 5.0; diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/common/GammaFileUtil.java b/jeecg-module-auto-process/src/main/java/org/jeecg/common/GammaFileUtil.java index ca7b2c77..74796de3 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/common/GammaFileUtil.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/common/GammaFileUtil.java @@ -1603,8 +1603,8 @@ public class GammaFileUtil { } FilterNuclideLine(iter.getValue(), phd.getUsedSetting().getECutAnalysis_Low()); // 过滤核素能量小于ECutAnalysis_Low的射线 - List vEnergy = iter.getValue().vEnergy; // 该核素的所有γ射线能量 - List vYield = iter.getValue().vYield; + List vEnergy = iter.getValue().venergy; // 该核素的所有γ射线能量 + List vYield = iter.getValue().vyield; List vEffi = CalValuesHandler.calFcnEval(vEnergy, phd.getUsedEffiPara().getP()).counts; // 该核素所有γ射线能量处的探测效率 List vFit = new LinkedList<>(); // γ射线能量与峰中心道能量匹配标识 for (int i=0; i vE = lines.vEnergy; + List vE = lines.venergy; for(int i=0, j=0; i 0) { - List vY = lines.vYield; + if(lines.key_flag < 0 && lines.venergy.size() > 0) { + List vY = lines.vyield; lines.maxYeildIdx = 0; double maxYield = vY.get(0); for(int ii=1; ii nuclideLineList = spectrumAnalysisMapper.getNuclideLines(name); for(int j=0;j 0) { nlines.key_flag = j; nlines.maxYeildIdx = j; @@ -3932,7 +3932,7 @@ public class GammaFileUtil { ReadSpecialNuclides(mapHalflife, vNuclides); double energyWidth = phd.getUsedSetting().getEnergyTolerance(); - List vEnergy = lines.vEnergy; // 该核素的所有γ射线能量 + List vEnergy = lines.venergy; // 该核素的所有γ射线能量 double maxYield = 0; int mainPeakIdx = -1; // 记录核素主γ峰的索引下标 @@ -3945,9 +3945,9 @@ public class GammaFileUtil { break; } else if(vEnergy.get(i) <= energy + energyWidth) { ActMda.getVEnergy().add(vEnergy.get(i)); - ActMda.getVUncertE().add(lines.vUncertE.get(i)); - ActMda.getVYield().add(lines.vYield.get(i)); - ActMda.getVUncertY().add(lines.vUncertY.get(i)); + ActMda.getVUncertE().add(lines.vuncertE.get(i)); + ActMda.getVYield().add(lines.vyield.get(i)); + ActMda.getVUncertY().add(lines.vuncertY.get(i)); ActMda.getFullNames().add(lines.fullNames.get(i)); ActMda.getVPeakIdx().add(vPeakIdx.get(j)+1); if(lines.key_flag == i) { diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java index a315cfcc..58e7573a 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java @@ -1,9 +1,13 @@ package org.jeecg.common.util; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.StringPool; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.commons.lang3.StringUtils; import org.apache.commons.io.FileUtils; +import org.apache.commons.net.ftp.FTP; import org.apache.commons.net.ftp.FTPClient; import org.ejml.simple.SimpleMatrix; import org.jeecg.common.api.vo.Result; @@ -101,7 +105,7 @@ public class GammaFileUtil { //Comment phd.setOriTotalCmt(struct.comment); //Collection - if (StringUtils.isNotBlank(struct.collection_start_date) || StringUtils.isNotBlank(struct.collection_start_time) || StringUtils.isNotBlank(struct.collection_stop_date) || StringUtils.isNotBlank(struct.collection_stop_time) || Objects.nonNull(struct.air_volume)) { + if (StringUtils.isNotBlank(struct.collection_start_date) && StringUtils.isNotBlank(struct.collection_start_time) && StringUtils.isNotBlank(struct.collection_stop_date) && StringUtils.isNotBlank(struct.collection_stop_time) && Objects.nonNull(struct.air_volume)) { phd.getCollect().setCollection_start_date(struct.collection_start_date); phd.getCollect().setCollection_start_time(struct.collection_start_time); phd.getCollect().setCollection_stop_date(struct.collection_stop_date); @@ -117,7 +121,7 @@ public class GammaFileUtil { phd.getCollect().setAir_volume(0.0); } //Acquisition - if (StringUtils.isNotBlank(struct.acquisition_start_date) || StringUtils.isNotBlank(struct.acquisition_start_time) || Objects.nonNull(struct.acquisition_real_time) || Objects.nonNull(struct.acquisition_live_time)) { + if (StringUtils.isNotBlank(struct.acquisition_start_date) && StringUtils.isNotBlank(struct.acquisition_start_time) && Objects.nonNull(struct.acquisition_real_time) && Objects.nonNull(struct.acquisition_live_time)) { phd.getAcq().setAcquisition_start_date(struct.acquisition_start_date); phd.getAcq().setAcquisition_start_time(struct.acquisition_start_time); phd.getAcq().setAcquisition_real_time(struct.acquisition_real_time); @@ -130,7 +134,7 @@ public class GammaFileUtil { phd.getAcq().setAcquisition_real_time(0.0); } //Processing - if (Objects.nonNull(struct.sample_volume_of_Xe) || Objects.nonNull(struct.uncertainty_1) || Objects.nonNull(struct.Xe_collection_yield) || Objects.nonNull(struct.uncertainty_2) || StringUtils.isNotBlank(struct.archive_bottle_id)) { + if (Objects.nonNull(struct.sample_volume_of_Xe) && Objects.nonNull(struct.uncertainty_1) && Objects.nonNull(struct.Xe_collection_yield) && Objects.nonNull(struct.uncertainty_2) && StringUtils.isNotBlank(struct.archive_bottle_id)) { phd.getProcess().setSample_volume_of_Xe(struct.sample_volume_of_Xe); phd.getProcess().setUncertainty_1(struct.uncertainty_1); phd.getProcess().setXe_collection_yield(struct.Xe_collection_yield); @@ -143,7 +147,7 @@ public class GammaFileUtil { phd.getProcess().setUncertainty_2(0.0); } //Sample - if (Objects.nonNull(struct.dimension_1) || Objects.nonNull(struct.dimension_2)) { + if (Objects.nonNull(struct.dimension_1) && Objects.nonNull(struct.dimension_2)) { phd.getSampleBlock().setDimension_1(struct.dimension_1); phd.getSampleBlock().setDimension_2(struct.dimension_2); } else { @@ -151,14 +155,14 @@ public class GammaFileUtil { phd.getSampleBlock().setDimension_2(0.0); } //Calibration - if (StringUtils.isNotBlank(struct.date_calibration) || StringUtils.isNotBlank(struct.time_calibration)) { + if (StringUtils.isNotBlank(struct.date_calibration) && StringUtils.isNotBlank(struct.time_calibration)) { phd.getCalibration().setDate_calibration(struct.date_calibration); phd.getCalibration().setTime_calibration(struct.time_calibration); } //Certificate - if (Objects.nonNull(struct.total_source_activity) || StringUtils.isNotBlank(struct.assay_date) || StringUtils.isNotBlank(struct.assay_time) || StringUtils.isNotBlank(struct.units_activity) || CollectionUtils.isNotEmpty(struct.nuclide_name) - || CollectionUtils.isNotEmpty(struct.half_life_time) || CollectionUtils.isNotEmpty(struct.time_unit) || CollectionUtils.isNotEmpty(struct.activity_nuclide_time_assay) || CollectionUtils.isNotEmpty(struct.uncertainty) - || CollectionUtils.isNotEmpty(struct.cer_g_energy) || CollectionUtils.isNotEmpty(struct.g_intensity) || CollectionUtils.isNotEmpty(struct.electron_decay_mode) || CollectionUtils.isNotEmpty(struct.maximum_energy) || CollectionUtils.isNotEmpty(struct.intensity_b_particle) || Objects.nonNull(struct.record_count)) { + if (Objects.nonNull(struct.total_source_activity) && StringUtils.isNotBlank(struct.assay_date) && StringUtils.isNotBlank(struct.assay_time) && StringUtils.isNotBlank(struct.units_activity) && CollectionUtils.isNotEmpty(struct.nuclide_name) + && CollectionUtils.isNotEmpty(struct.half_life_time) && CollectionUtils.isNotEmpty(struct.time_unit) && CollectionUtils.isNotEmpty(struct.activity_nuclide_time_assay) && CollectionUtils.isNotEmpty(struct.uncertainty) + && CollectionUtils.isNotEmpty(struct.cer_g_energy) && CollectionUtils.isNotEmpty(struct.g_intensity) && CollectionUtils.isNotEmpty(struct.electron_decay_mode) && CollectionUtils.isNotEmpty(struct.maximum_energy) && CollectionUtils.isNotEmpty(struct.intensity_b_particle) && Objects.nonNull(struct.record_count)) { phd.getCertificate().setTotal_source_activity(struct.total_source_activity); phd.getCertificate().setAssay_date(struct.assay_date); phd.getCertificate().setAssay_time(struct.assay_time); @@ -176,7 +180,7 @@ public class GammaFileUtil { phd.getCertificate().setRecord_count(struct.record_count); } //g_Spectrum - if (Objects.nonNull(struct.num_g_channel) || Objects.nonNull(struct.g_energy_span) || Objects.nonNull(struct.g_begin_channel) || CollectionUtils.isNotEmpty(struct.g_counts)) { + if (Objects.nonNull(struct.num_g_channel) && Objects.nonNull(struct.g_energy_span) && Objects.nonNull(struct.g_begin_channel) && CollectionUtils.isNotEmpty(struct.g_counts)) { phd.getSpec().setNum_g_channel(struct.num_g_channel); phd.getSpec().setG_energy_span(struct.g_energy_span); phd.getSpec().setBegin_channel(struct.g_begin_channel); @@ -192,7 +196,7 @@ public class GammaFileUtil { } } //g_Energy - if (CollectionUtils.isNotEmpty(struct.g_energy) || CollectionUtils.isNotEmpty(struct.g_centroid_channel) || CollectionUtils.isNotEmpty(struct.g_uncertainty) || Objects.nonNull(struct.g_record_count)) { + if (CollectionUtils.isNotEmpty(struct.g_energy) && CollectionUtils.isNotEmpty(struct.g_centroid_channel) && CollectionUtils.isNotEmpty(struct.g_uncertainty) && Objects.nonNull(struct.g_record_count)) { GEnergyBlock gEnergyBlock = new GEnergyBlock(); gEnergyBlock.setG_energy(struct.g_energy); gEnergyBlock.setCentroid_channel(struct.g_centroid_channel); @@ -201,7 +205,7 @@ public class GammaFileUtil { phd.getMapEnerKD().put(CalName.CalPHD.getType(), gEnergyBlock); } //g_Resolution - if (CollectionUtils.isNotEmpty(struct.g_r_energy) || CollectionUtils.isNotEmpty(struct.g_r_FWHM) || CollectionUtils.isNotEmpty(struct.g_r_uncertainty) || Objects.nonNull(struct.g_r_record_count)) { + if (CollectionUtils.isNotEmpty(struct.g_r_energy) && CollectionUtils.isNotEmpty(struct.g_r_FWHM) && CollectionUtils.isNotEmpty(struct.g_r_uncertainty) && Objects.nonNull(struct.g_r_record_count)) { GResolutionBlock gResolutionBlock = new GResolutionBlock(); gResolutionBlock.setG_energy(struct.g_r_energy); gResolutionBlock.setFWHM(struct.g_r_FWHM); @@ -210,7 +214,7 @@ public class GammaFileUtil { phd.getMapResoKD().put(CalName.CalPHD.getType(), gResolutionBlock); } //g_Efficiency - if (CollectionUtils.isNotEmpty(struct.g_e_energy) || CollectionUtils.isNotEmpty(struct.g_e_efficiency) || CollectionUtils.isNotEmpty(struct.g_e_uncertainty) || Objects.nonNull(struct.g_e_record_count)) { + if (CollectionUtils.isNotEmpty(struct.g_e_energy) && CollectionUtils.isNotEmpty(struct.g_e_efficiency) && CollectionUtils.isNotEmpty(struct.g_e_uncertainty) && Objects.nonNull(struct.g_e_record_count)) { GEfficiencyBlock gEfficiencyBlock = new GEfficiencyBlock(); gEfficiencyBlock.setG_energy(struct.g_e_energy); gEfficiencyBlock.setEfficiency(struct.g_e_efficiency); @@ -219,7 +223,7 @@ public class GammaFileUtil { phd.getMapEffiKD().put(CalName.CalPHD.getType(), gEfficiencyBlock); } //TotalEff - if (CollectionUtils.isNotEmpty(struct.t_g_energy) || CollectionUtils.isNotEmpty(struct.total_efficiency) || CollectionUtils.isNotEmpty(struct.t_uncertainty) || Objects.nonNull(struct.t_record_count)) { + if (CollectionUtils.isNotEmpty(struct.t_g_energy) && CollectionUtils.isNotEmpty(struct.total_efficiency) && CollectionUtils.isNotEmpty(struct.t_uncertainty) && Objects.nonNull(struct.t_record_count)) { TotaleffBlock totaleffBlock = new TotaleffBlock(); totaleffBlock.setG_energy(struct.t_g_energy); totaleffBlock.setTotal_efficiency(struct.total_efficiency); @@ -365,10 +369,7 @@ public class GammaFileUtil { String baselineFileName = "RNAUTO_"+subFileName + ".baseline"; inputStream = ftpClient.retrieveFileStream(baselineFileName); if (Objects.nonNull(inputStream)){ - long start = System.currentTimeMillis(); ReadBaseCtrlInfo(phd, inputStream); - long end = System.currentTimeMillis(); - System.out.println(end-start); phd.setVBase(phd.getBaseCtrls().getBaseline()); } } catch (IOException e) { @@ -1469,7 +1470,7 @@ public class GammaFileUtil { return datalist; } - public boolean AnalyseData(PHDFile phd, ConfigureData configureData, List nuclides, boolean bSingle) { + public int AnalyseData(PHDFile phd, ConfigureData configureData, List nuclides, Result result) { //调用方法判断是否修改了参数 if (Objects.nonNull(configureData)){ SpecSetup phdSetting = phd.getSetting(); @@ -1487,8 +1488,9 @@ public class GammaFileUtil { } int change = SettingChanged(phd); - if(change == 0 && phd.getVPeak().size() > 0) return false; - else if(change == -1) { + if(change == 0 && phd.getVPeak().size() > 0) { + return change; + } else if(change == -1) { phd.setUsedEffi(phd.getNewEffi()); phd.setUsedEffiKD(phd.getMapEffiKD().get(phd.getNewEffi())); phd.setUsedEffiPara(phd.getMapEffiPara().get(phd.getNewEffi())); @@ -1496,24 +1498,31 @@ public class GammaFileUtil { Map nuclideLinesMap = GetNuclideLines(nuclides); NuclidesIdent(phd, nuclideLinesMap); RunQC(phd); - String Warning = "Finish three tasks:\n"+ + result.error500("Finish three tasks:\n"+ "\t1.Update efficiencies of all peaks;\n"+ "\t2.Identify nuclides again;\n"+ - "\t3.Test QC again."; + "\t3.Test QC again."); } else { - if(bSingle) { -// AnalyseFlowChart flow_dlg(this); -// flow_dlg.exec(); - } else { - Map nuclideLinesMap = GetNuclideLines(nuclides); -// AnalyseSpectrum(phd, nuclideLinesMap); - } + Map nuclideLinesMap = GetNuclideLines(nuclides); + AnalyseSpectrum(phd, nuclideLinesMap); } - return true; + return change; } - public boolean AnalyseSpectrum(PHDFile phd, Map map){ - return false; + public boolean AnalyseSpectrum(PHDFile phd, Map mapLines){ + System.loadLibrary("GammaAnaly"); + ObjectMapper mapper = new ObjectMapper(); + try { + String phdStr = mapper.writeValueAsString(phd); + String mapLinesStr = mapper.writeValueAsString(mapLines); + String analyseSpectrum = CalValuesHandler.analyseSpectrum(phdStr, mapLinesStr, ""); + JSONObject jsonObject = JSONObject.parseObject(analyseSpectrum); + String jsonString = jsonObject.toJSONString(); + + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + return true; } public int SettingChanged(PHDFile phd) { @@ -1598,8 +1607,8 @@ public class GammaFileUtil { } FilterNuclideLine(iter.getValue(), phd.getUsedSetting().getECutAnalysis_Low()); // 过滤核素能量小于ECutAnalysis_Low的射线 - List vEnergy = iter.getValue().vEnergy; // 该核素的所有γ射线能量 - List vYield = iter.getValue().vYield; + List vEnergy = iter.getValue().venergy; // 该核素的所有γ射线能量 + List vYield = iter.getValue().vyield; List vEffi = CalValuesHandler.calFcnEval(vEnergy, phd.getUsedEffiPara().getP()).counts; // 该核素所有γ射线能量处的探测效率 List vFit = new LinkedList<>(); // γ射线能量与峰中心道能量匹配标识 for (int i=0; i vE = lines.vEnergy; + List vE = lines.venergy; for(int i=0, j=0; i 0) { - List vY = lines.vYield; + if(lines.key_flag < 0 && lines.venergy.size() > 0) { + List vY = lines.vyield; lines.maxYeildIdx = 0; double maxYield = vY.get(0); for(int ii=1; ii nuclideLineList = spectrumAnalysisMapper.getNuclideLines(name); for(int j=0;j 0) { nlines.key_flag = j; nlines.maxYeildIdx = j; @@ -3941,7 +3950,7 @@ public class GammaFileUtil { ReadSpecialNuclides(mapHalflife, vNuclides); double energyWidth = phd.getUsedSetting().getEnergyTolerance(); - List vEnergy = lines.vEnergy; // 该核素的所有γ射线能量 + List vEnergy = lines.venergy; // 该核素的所有γ射线能量 double maxYield = 0; int mainPeakIdx = -1; // 记录核素主γ峰的索引下标 @@ -3954,9 +3963,9 @@ public class GammaFileUtil { break; } else if(vEnergy.get(i) <= energy + energyWidth) { ActMda.getVEnergy().add(vEnergy.get(i)); - ActMda.getVUncertE().add(lines.vUncertE.get(i)); - ActMda.getVYield().add(lines.vYield.get(i)); - ActMda.getVUncertY().add(lines.vUncertY.get(i)); + ActMda.getVUncertE().add(lines.vuncertE.get(i)); + ActMda.getVYield().add(lines.vyield.get(i)); + ActMda.getVUncertY().add(lines.vuncertY.get(i)); ActMda.getFullNames().add(lines.fullNames.get(i)); ActMda.getVPeakIdx().add(vPeakIdx.get(j)+1); if(lines.key_flag == i) { @@ -4160,4 +4169,42 @@ public class GammaFileUtil { return datalist; } + public File analyzeFile(String path, String fileName) { + //连接ftp + FTPClient ftpClient = ftpUtil.LoginFTP(); + InputStream inputStream = null; + File file = null; + try { + //被动模式 + ftpClient.enterLocalPassiveMode(); + //设置文件类型--二进制文件 + ftpClient.setFileType(FTP.BINARY_FILE_TYPE); + // + ftpClient.setControlEncoding("UTF-8"); + ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); + //切换文件路径 + ftpClient.changeWorkingDirectory(path); + inputStream = ftpClient.retrieveFileStream(fileName); + if (Objects.nonNull(inputStream)){ + file = File.createTempFile("tmp", null); + //将ftp文件的输入流复制给临时文件 + FileUtils.copyInputStreamToFile(inputStream, file); + } + } catch (IOException e) { + throw new RuntimeException(e); + } finally { + try { + if (Objects.nonNull(ftpClient)){ + ftpClient.disconnect(); + } + if (Objects.nonNull(inputStream)){ + inputStream.close(); + } + } catch (IOException e) { + throw new RuntimeException(e); + } + } + return file; + } + } 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 b4d947b1..b45f634c 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 @@ -43,18 +43,19 @@ public class GammaController { @GetMapping("analysisProcess") @ApiOperation(value = "分析进度", notes = "分析进度") public void message(String message) { - Result user = systemClient.getUserData(); +// Result user = systemClient.getUserData(); BaseMap params = new BaseMap(); params.put(GlobalConstants.HANDLER_NAME, WebSocketHandlerConst.GAMMA_ANALYSIS_HANDLER); - params.put("userId", user.getResult().getId()); + 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){ - return gammaService.testFun(fileName); + public Result testFun(String fileName,HttpServletRequest request){ + return gammaService.testFun(fileName, request); } @GetMapping("gammaByDB") 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 index 459421d3..77134382 100644 --- 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 @@ -64,6 +64,8 @@ public class PeakInfo implements Serializable { public PeakInfo(){ nuclides = new LinkedList<>(); comments = ""; + recoilBetaChan = "1"; + recoilDeltaChan = "1"; } } 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 93b40793..d08cf789 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 @@ -1,13 +1,11 @@ package org.jeecg.modules.native_jni; -import com.alibaba.fastjson.JSON; import org.jeecg.modules.entity.vo.PeakInfo; import org.jeecg.modules.entity.vo.StructInsertInput; 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 { @@ -27,22 +25,6 @@ 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, List Peaks); - - public static native String baseImprove(double BaseImprovePSS, double k_back, double k_alpha, double k_beta, double ECutLow, double ECutHigh, double deltaE, double pssLow); - - public static native String fitPeakFull(); + public static native String analyseSpectrum(String phd, String mapLines, String phdFilePath); } 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 b9bf8285..2bd327e6 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 @@ -13,7 +13,7 @@ public interface IGammaService{ Result initValue(Integer sampleId, String dbName, HttpServletRequest request); - Result testFun(String fileName); + Result testFun(String fileName, HttpServletRequest request); Result gammaByDB(String dbName, Integer sampleId, 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 e6b0055e..25042ab3 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 @@ -8,13 +8,18 @@ import cn.hutool.core.map.MapUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ReUtil; import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.StringPool; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; import com.google.common.cache.Cache; import org.apache.commons.net.ftp.FTPClient; +import org.codehaus.jettison.json.JSONString; import org.jeecg.common.api.vo.Result; import org.jeecg.common.cache.LocalCache; import org.jeecg.common.constant.DateConstant; @@ -30,6 +35,7 @@ import org.jeecg.modules.entity.*; import org.jeecg.modules.mapper.SpectrumAnalysisMapper; import org.jeecg.modules.native_jni.CalValuesHandler; import org.jeecg.modules.service.*; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -77,6 +83,8 @@ public class GammaServiceImpl implements IGammaService { private FTPUtil ftpUtil; @Value("${ZeroTime}") private String ZeroTimeStr; + @Value("${parameter.filePath}") + private String parameterFilePath; @Autowired private IGardsAnalysesSpectrumService analysesSpectrumService; @Autowired @@ -144,31 +152,62 @@ public class GammaServiceImpl implements IGammaService { } @Override - public Result testFun(String fileName) { + public Result testFun(String fileName, HttpServletRequest request) { Result result = new Result(); + Map map = new HashMap<>(); Cache phdCache = localCache.getPHDCache(); PHDFile phd = phdCache.getIfPresent(fileName); - Map map = new HashMap<>(); - System.loadLibrary("GammaAnaly"); -// List baseInfo_s_Energy = CalValuesHandler.calValues(0, phd.getSpec().getCounts().size()); -// map.put("baseInfo_s_Energy", baseInfo_s_Energy); -// List baseInfo_s_fwhmcAll = CalValuesHandler.GetFwhmcAll(phd.getSpec().getCounts().size()); -// map.put("baseInfo_s_fwhmcAll", baseInfo_s_fwhmcAll); -// List baseInfo_s_Lc = CalValuesHandler.calculateLC(phd.getBaseCtrls().getBaseline(), baseInfo_s_fwhmcAll, phd.getSetting().getRiskLevelK()); -// map.put("baseInfo_s_Lc", baseInfo_s_Lc); -// List values = gammaFileUtil.DoubleLimit_L(phd.getSpec().getCounts()); -// List baseInfo_s_Scac = CalValuesHandler.calculateSCAC(values, phd.getBaseCtrls().getBaseline(), baseInfo_s_fwhmcAll); -// map.put("baseInfo_s_Scac", baseInfo_s_Scac); -// boolean armaAny = CalValuesHandler.armaAny(values); -// map.put("armaAny", armaAny); - String dataType = phd.getMsgInfo().getData_type().substring(0, 1); - List gEnergy = phd.getCertificate().getG_energy(); - String calUpdateStr = CalValuesHandler.calUpdate(dataType, gEnergy, true, true, true, phd.getSetting().isKeepCalPeakSearchPeaks(), phd.getSetting().getK_back(), phd.getSetting().getK_alpha(), phd.getSetting().getK_beta()); - map.put("calUpdateStr", calUpdateStr); -// CalValuesHandler.peakSearch(phd.getSetting().getECutAnalysis_Low(), phd.getSetting().getECutAnalysis_High(), -// phd.getSetting().getEnergyTolerance(), phd.getSetting().getPSS_low(), phd.getSetting().getK_back(), phd.getSetting().getK_alpha(), phd.getSetting().getK_beta(), phd.getVPeak()); + if (Objects.isNull(phd)){ + result.error500("请先选择解析文件!"); + return result; + } + phd.setUserId("1"); + phd.setXmlFilePath(parameterFilePath); + String userName = JwtUtil.getUserNameByToken(request); + //获取当前角色的颜色配置 + Map colorMap = sysUserColorService.initColor(userName); + //查询当前用户关联的核素信息 + List nuclides = new LinkedList<>(); + //从postgreSql中获取当前用户关注的核素信息 如果当前用户没有 则返回管理员的 + nuclides = defaultNuclideSpectrumService.findNuclidesByUserName(userName, phd.getHeader().getSystem_type().toUpperCase()); + if (CollectionUtils.isEmpty(nuclides)){ + nuclides = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase()); + } + Map nuclideLinesMap = gammaFileUtil.GetNuclideLines(nuclides); + //解析获取临时文件信息 + File tmpFile = gammaFileUtil.analyzeFile(StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName, fileName); + ObjectMapper mapper = new ObjectMapper(); + try { + String phdStr = mapper.writeValueAsString(phd); + String mapLines = mapper.writeValueAsString(nuclideLinesMap); + String strValue = CalValuesHandler.analyseSpectrum(phdStr, mapLines, tmpFile.getAbsolutePath()); + PHDFile phdFile = JSON.parseObject(strValue, PHDFile.class); + phd.setVLc(phdFile.getVLc()); + phd.setVScac(phdFile.getVScac()); + phd.setVBase(phdFile.getVBase()); + phd.setVEnergy(phdFile.getVEnergy()); + phd.setVPeak(phdFile.getVPeak()); + for (PeakInfo peak:phd.getVPeak()) { + if (StringUtils.isBlank(peak.recoilBetaChan)) { + peak.recoilBetaChan = "1"; + } + if (StringUtils.isBlank(peak.recoilDeltaChan)) { + peak.recoilDeltaChan = "1"; + } + } + gammaFileUtil.UpdateChart(phd, map, colorMap); + // + gammaFileUtil.NuclidesIdent(phd, nuclideLinesMap); + // 更新 ‘QC Flags’ 状态 + List qcstate = gammaFileUtil.Qcstate(phd); + map.put("QCFlag", qcstate); + phdCache.put(fileName, phd); + localCache.setPHDCache(phdCache); + result.setResult(map); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } result.setSuccess(true); - result.setResult(map); return result; } @@ -369,8 +408,19 @@ public class GammaServiceImpl implements IGammaService { if (CollectionUtils.isEmpty(nuclides)){ nuclides = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase()); } - boolean flag = gammaFileUtil.AnalyseData(phd, configureData, nuclides, true); - if (flag){ + int flag = gammaFileUtil.AnalyseData(phd, configureData, nuclides, result); + if (flag == 0){ + String warning = "The spectrum needn't Analyed. Maybe:\n"+ + "1. It has already Analyed.\n"+ + "2. You didn't change any setting or calibration."; + result.error500(warning); + } else if (flag == -1){ + String warning = "Finish three tasks:\n"+ + "\t1.Update efficiencies of all peaks;\n"+ + "\t2.Identify nuclides again;\n"+ + "\t3.Test QC again."; + result.error500(warning); + } else { Map map = new HashMap<>(); phd.getUsedSetting().setECutAnalysis_Low(configureData.getECutAnalysis_Low()); phd.getUsedSetting().setECutAnalysis_High(configureData.getECutAnalysis_High()); @@ -386,11 +436,6 @@ public class GammaServiceImpl implements IGammaService { gammaFileUtil.UpdateChart(phd, map, colorMap); result.setSuccess(true); result.setResult(map); - }else { - String warning = "The spectrum needn't Analyed. Maybe:\n"+ - "1. It has already Analyed.\n"+ - "2. You didn't change any setting or calibration."; - result.error500(warning); } return result; } @@ -440,6 +485,8 @@ public class GammaServiceImpl implements IGammaService { map.put("energy", phd.getVEnergy()); //赋值BaseCtrls map.put("BaseCtrls", phd.getBaseCtrls()); + //FitBaseLine颜色 + map.put("FitBaseLine", colorMap.get("Color_Fitbase")); result.setSuccess(true); result.setResult(map); return result; diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/GardsNuclLinesLibServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/GardsNuclLinesLibServiceImpl.java index 45c3e3eb..2c411174 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/GardsNuclLinesLibServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/GardsNuclLinesLibServiceImpl.java @@ -76,10 +76,10 @@ public class GardsNuclLinesLibServiceImpl extends ServiceImpl 0){ diff --git a/jeecg-server-cloud/jeecg-auto-process-start/src/main/resources/application.yml b/jeecg-server-cloud/jeecg-auto-process-start/src/main/resources/application.yml index a5d0fe92..c74f45bc 100644 --- a/jeecg-server-cloud/jeecg-auto-process-start/src/main/resources/application.yml +++ b/jeecg-server-cloud/jeecg-auto-process-start/src/main/resources/application.yml @@ -15,5 +15,5 @@ spring: config: import: - optional:nacos:jeecg.yaml - - optional:nacos:jeecg-@profile.name@-pbl.yaml + - optional:nacos:jeecg-@profile.name@.yaml From f41a8dad0cecb9a2a96100f0e8c94a0e4ade551b Mon Sep 17 00:00:00 2001 From: xiaoguangbin Date: Sun, 24 Sep 2023 21:53:19 +0800 Subject: [PATCH 03/11] =?UTF-8?q?fix=EF=BC=9A=E8=A7=A3=E5=86=B3Gamma=20def?= =?UTF-8?q?ault=20params=E8=A1=A8=E6=9C=89=E7=A9=BA=E7=9A=84value=E6=8A=A5?= =?UTF-8?q?=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GardsGammaDefaultParamsServiceImpl.java | 3 +- .../org/jeecg/common/util/GammaFileUtil.java | 39 +++++++++++++++++++ .../modules/controller/GammaController.java | 2 + .../service/impl/GammaServiceImpl.java | 9 +++++ .../jeecg/common/CalculateStationData.java | 1 + 5 files changed, 53 insertions(+), 1 deletion(-) diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsGammaDefaultParamsServiceImpl.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsGammaDefaultParamsServiceImpl.java index 0ff002cb..edefb9bd 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsGammaDefaultParamsServiceImpl.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsGammaDefaultParamsServiceImpl.java @@ -8,6 +8,7 @@ import org.jeecg.modules.service.IGardsGammaDefaultParamsService; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -19,7 +20,7 @@ public class GardsGammaDefaultParamsServiceImpl extends ServiceImpl mapSetting() { Map paramsMap = list().stream() .collect(Collectors.toMap(GardsGammaDefaultParams::getName, - GardsGammaDefaultParams::getValue)); + v->v.getValue() == null ? "" : v.getValue())); return paramsMap; } } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java index 58e7573a..2afce7c5 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java @@ -1515,10 +1515,14 @@ public class GammaFileUtil { try { String phdStr = mapper.writeValueAsString(phd); String mapLinesStr = mapper.writeValueAsString(mapLines); + + //解析获取临时文件信息 + File tmpFile = this.analyzeFile(phd.getFilepath()); String analyseSpectrum = CalValuesHandler.analyseSpectrum(phdStr, mapLinesStr, ""); JSONObject jsonObject = JSONObject.parseObject(analyseSpectrum); String jsonString = jsonObject.toJSONString(); + } catch (JsonProcessingException e) { throw new RuntimeException(e); } @@ -4206,5 +4210,40 @@ public class GammaFileUtil { } return file; } + public File analyzeFile(String path) { + //连接ftp + FTPClient ftpClient = ftpUtil.LoginFTP(); + InputStream inputStream = null; + File file = null; + try { + //被动模式 + ftpClient.enterLocalPassiveMode(); + //设置文件类型--二进制文件 + ftpClient.setFileType(FTP.BINARY_FILE_TYPE); + // + ftpClient.setControlEncoding("UTF-8"); + ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); + inputStream = ftpClient.retrieveFileStream(path); + if (Objects.nonNull(inputStream)){ + file = File.createTempFile("tmp", null); + //将ftp文件的输入流复制给临时文件 + FileUtils.copyInputStreamToFile(inputStream, file); + } + } catch (IOException e) { + throw new RuntimeException(e); + } finally { + try { + if (Objects.nonNull(ftpClient)){ + ftpClient.disconnect(); + } + if (Objects.nonNull(inputStream)){ + inputStream.close(); + } + } catch (IOException e) { + throw new RuntimeException(e); + } + } + return file; + } } 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 b45f634c..5a714eda 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 @@ -2,6 +2,7 @@ package org.jeecg.modules.controller; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import org.apache.poi.hdgf.pointers.Pointer; import org.jeecg.common.api.vo.Result; import org.jeecg.common.base.BaseMap; import org.jeecg.common.constant.GlobalConstants; @@ -19,6 +20,7 @@ import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.List; +import java.util.TreeMap; @RestController @RequestMapping("gamma") 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 25042ab3..c4a10b2d 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 @@ -213,6 +213,7 @@ public class GammaServiceImpl implements IGammaService { @Override public Result gammaByDB(String dbName, Integer sampleId, HttpServletRequest request) { + long l = System.currentTimeMillis(); Result result = new Result(); String userName = JwtUtil.getUserNameByToken(request); Map map = new HashMap<>(); @@ -227,14 +228,22 @@ public class GammaServiceImpl implements IGammaService { } String pathName = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH)); String fileName = sampleFilePath.substring(sampleFilePath.lastIndexOf(StringPool.SLASH)+1); + System.out.println("loadFile之前>>>>"+(System.currentTimeMillis() - l)); + l = System.currentTimeMillis(); boolean flag = gammaFileUtil.loadFile(pathName, fileName, phd, result); + System.out.println("loadFile>>>>"+(System.currentTimeMillis() - l)); if (!flag){ return result; } + l = System.currentTimeMillis(); //声明基础数组信息 gammaFileUtil.SetBaseInfo(phd); + System.out.println("SetBaseInfo>>>>"+(System.currentTimeMillis() - l)); + l = System.currentTimeMillis(); //从数据库中读取相关信息 boolean bRet = gammaFileUtil.getResultFromDB(dbName, userName, sampleId, phd, result); + System.out.println("getResultFromDB>>>>"+(System.currentTimeMillis() - l)); + l = System.currentTimeMillis(); if (!bRet){ return result; } diff --git a/jeecg-module-station-operation/src/main/java/org/jeecg/common/CalculateStationData.java b/jeecg-module-station-operation/src/main/java/org/jeecg/common/CalculateStationData.java index 90caa72a..064dc347 100644 --- a/jeecg-module-station-operation/src/main/java/org/jeecg/common/CalculateStationData.java +++ b/jeecg-module-station-operation/src/main/java/org/jeecg/common/CalculateStationData.java @@ -32,6 +32,7 @@ public class CalculateStationData { try { //文件路径 String filePath = parameterFilePath+ File.separator +"parameter.xml"; + filePath = "F:\\RunSoftware\\ARMD1.0.4\\SystemManager.xml"; //声明一个实体类存储参数信息 RateParam mRateParam = new RateParam(); //创建一个文档解析器工厂 From 7d0fddfc8155aa640513b66aa17ee96bbcba8796 Mon Sep 17 00:00:00 2001 From: xiaoguangbin Date: Sun, 24 Sep 2023 21:53:37 +0800 Subject: [PATCH 04/11] =?UTF-8?q?Revert=20"fix=EF=BC=9A=E8=A7=A3=E5=86=B3G?= =?UTF-8?q?amma=20default=20params=E8=A1=A8=E6=9C=89=E7=A9=BA=E7=9A=84valu?= =?UTF-8?q?e=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit f41a8dad0cecb9a2a96100f0e8c94a0e4ade551b. --- .../GardsGammaDefaultParamsServiceImpl.java | 3 +- .../org/jeecg/common/util/GammaFileUtil.java | 39 ------------------- .../modules/controller/GammaController.java | 2 - .../service/impl/GammaServiceImpl.java | 9 ----- .../jeecg/common/CalculateStationData.java | 1 - 5 files changed, 1 insertion(+), 53 deletions(-) diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsGammaDefaultParamsServiceImpl.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsGammaDefaultParamsServiceImpl.java index edefb9bd..0ff002cb 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsGammaDefaultParamsServiceImpl.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsGammaDefaultParamsServiceImpl.java @@ -8,7 +8,6 @@ import org.jeecg.modules.service.IGardsGammaDefaultParamsService; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -20,7 +19,7 @@ public class GardsGammaDefaultParamsServiceImpl extends ServiceImpl mapSetting() { Map paramsMap = list().stream() .collect(Collectors.toMap(GardsGammaDefaultParams::getName, - v->v.getValue() == null ? "" : v.getValue())); + GardsGammaDefaultParams::getValue)); return paramsMap; } } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java index 2afce7c5..58e7573a 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java @@ -1515,14 +1515,10 @@ public class GammaFileUtil { try { String phdStr = mapper.writeValueAsString(phd); String mapLinesStr = mapper.writeValueAsString(mapLines); - - //解析获取临时文件信息 - File tmpFile = this.analyzeFile(phd.getFilepath()); String analyseSpectrum = CalValuesHandler.analyseSpectrum(phdStr, mapLinesStr, ""); JSONObject jsonObject = JSONObject.parseObject(analyseSpectrum); String jsonString = jsonObject.toJSONString(); - } catch (JsonProcessingException e) { throw new RuntimeException(e); } @@ -4210,40 +4206,5 @@ public class GammaFileUtil { } return file; } - public File analyzeFile(String path) { - //连接ftp - FTPClient ftpClient = ftpUtil.LoginFTP(); - InputStream inputStream = null; - File file = null; - try { - //被动模式 - ftpClient.enterLocalPassiveMode(); - //设置文件类型--二进制文件 - ftpClient.setFileType(FTP.BINARY_FILE_TYPE); - // - ftpClient.setControlEncoding("UTF-8"); - ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); - inputStream = ftpClient.retrieveFileStream(path); - if (Objects.nonNull(inputStream)){ - file = File.createTempFile("tmp", null); - //将ftp文件的输入流复制给临时文件 - FileUtils.copyInputStreamToFile(inputStream, file); - } - } catch (IOException e) { - throw new RuntimeException(e); - } finally { - try { - if (Objects.nonNull(ftpClient)){ - ftpClient.disconnect(); - } - if (Objects.nonNull(inputStream)){ - inputStream.close(); - } - } catch (IOException e) { - throw new RuntimeException(e); - } - } - return file; - } } 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 5a714eda..b45f634c 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 @@ -2,7 +2,6 @@ package org.jeecg.modules.controller; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import org.apache.poi.hdgf.pointers.Pointer; import org.jeecg.common.api.vo.Result; import org.jeecg.common.base.BaseMap; import org.jeecg.common.constant.GlobalConstants; @@ -20,7 +19,6 @@ import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.List; -import java.util.TreeMap; @RestController @RequestMapping("gamma") 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 c4a10b2d..25042ab3 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 @@ -213,7 +213,6 @@ public class GammaServiceImpl implements IGammaService { @Override public Result gammaByDB(String dbName, Integer sampleId, HttpServletRequest request) { - long l = System.currentTimeMillis(); Result result = new Result(); String userName = JwtUtil.getUserNameByToken(request); Map map = new HashMap<>(); @@ -228,22 +227,14 @@ public class GammaServiceImpl implements IGammaService { } String pathName = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH)); String fileName = sampleFilePath.substring(sampleFilePath.lastIndexOf(StringPool.SLASH)+1); - System.out.println("loadFile之前>>>>"+(System.currentTimeMillis() - l)); - l = System.currentTimeMillis(); boolean flag = gammaFileUtil.loadFile(pathName, fileName, phd, result); - System.out.println("loadFile>>>>"+(System.currentTimeMillis() - l)); if (!flag){ return result; } - l = System.currentTimeMillis(); //声明基础数组信息 gammaFileUtil.SetBaseInfo(phd); - System.out.println("SetBaseInfo>>>>"+(System.currentTimeMillis() - l)); - l = System.currentTimeMillis(); //从数据库中读取相关信息 boolean bRet = gammaFileUtil.getResultFromDB(dbName, userName, sampleId, phd, result); - System.out.println("getResultFromDB>>>>"+(System.currentTimeMillis() - l)); - l = System.currentTimeMillis(); if (!bRet){ return result; } diff --git a/jeecg-module-station-operation/src/main/java/org/jeecg/common/CalculateStationData.java b/jeecg-module-station-operation/src/main/java/org/jeecg/common/CalculateStationData.java index 064dc347..90caa72a 100644 --- a/jeecg-module-station-operation/src/main/java/org/jeecg/common/CalculateStationData.java +++ b/jeecg-module-station-operation/src/main/java/org/jeecg/common/CalculateStationData.java @@ -32,7 +32,6 @@ public class CalculateStationData { try { //文件路径 String filePath = parameterFilePath+ File.separator +"parameter.xml"; - filePath = "F:\\RunSoftware\\ARMD1.0.4\\SystemManager.xml"; //声明一个实体类存储参数信息 RateParam mRateParam = new RateParam(); //创建一个文档解析器工厂 From efc9261331eb94596c4bfd304d6099caeec2840d Mon Sep 17 00:00:00 2001 From: xiaoguangbin Date: Sun, 24 Sep 2023 21:54:21 +0800 Subject: [PATCH 05/11] =?UTF-8?q?fix=EF=BC=9A=E8=A7=A3=E5=86=B3Gamma=20def?= =?UTF-8?q?ault=20params=E8=A1=A8=E6=9C=89=E7=A9=BA=E7=9A=84value=E6=8A=A5?= =?UTF-8?q?=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/GardsGammaDefaultParamsServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsGammaDefaultParamsServiceImpl.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsGammaDefaultParamsServiceImpl.java index 0ff002cb..b0ea3e52 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsGammaDefaultParamsServiceImpl.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsGammaDefaultParamsServiceImpl.java @@ -19,7 +19,7 @@ public class GardsGammaDefaultParamsServiceImpl extends ServiceImpl mapSetting() { Map paramsMap = list().stream() .collect(Collectors.toMap(GardsGammaDefaultParams::getName, - GardsGammaDefaultParams::getValue)); + v->v.getValue() == null ? "" : v.getValue())); return paramsMap; } } From 3ce210b557803b506c2700983acb84605c0165c9 Mon Sep 17 00:00:00 2001 From: panbaolin <123456> Date: Mon, 25 Sep 2023 09:26:57 +0800 Subject: [PATCH 06/11] =?UTF-8?q?fix:1.=E4=BF=AE=E6=94=B9B=E8=B0=B1?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E5=86=99=E5=85=A5=E6=96=87=E4=BB=B6bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jeecg/modules/spectrum/ParsingProcessLog.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/ParsingProcessLog.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/ParsingProcessLog.java index 7234d754..258a9464 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/ParsingProcessLog.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/ParsingProcessLog.java @@ -1,17 +1,14 @@ package org.jeecg.modules.spectrum; -import com.google.common.collect.Lists; import lombok.Setter; import org.jeecg.common.constant.StringConstant; import org.jeecg.common.properties.SpectrumPathProperties; import org.jeecg.common.util.DateUtils; import org.jeecg.modules.base.enums.DataType; -import org.jeecg.modules.base.enums.SampleStatus; import org.jeecg.modules.base.enums.SystemType; import org.jeecg.modules.native_jni.struct.BgAnalyseResult; import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct; import org.jeecg.modules.service.BlockConstant; - import java.io.ByteArrayInputStream; import java.nio.charset.StandardCharsets; import java.util.List; @@ -166,12 +163,13 @@ public class ParsingProcessLog { if(fileNotExist){ // Gas谱或Det谱文件找不到异常结束 fileNotExistException(); + }else{ + this.readCalibrationData(); + this.reading_roi_limits(); + this.reading_roi_ratios(); + this.reading_B_G_Efficiency(); + this.NCC_analysis(); } - this.readCalibrationData(); - this.reading_roi_limits(); - this.reading_roi_ratios(); - this.reading_B_G_Efficiency(); - this.NCC_analysis(); if(analysisDataStoreFlag == true){ storeFlag = "error"; From f3406dabb4cb848736d790113814019835dab65c Mon Sep 17 00:00:00 2001 From: qiaoqinzheng Date: Mon, 25 Sep 2023 11:24:42 +0800 Subject: [PATCH 07/11] =?UTF-8?q?SpecSetup=E4=BF=AE=E6=94=B9=E5=AE=9E?= =?UTF-8?q?=E4=BD=93=E7=B1=BB=E5=AD=97=E6=AE=B5=E4=BF=A1=E6=81=AF=20UserTa?= =?UTF-8?q?skUtil=E6=96=B0=E5=A2=9E=E6=9F=A5=E8=AF=A2=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=96=B9=E6=B3=95=20GammaController=E6=96=B0?= =?UTF-8?q?=E5=A2=9EconfigureSave=E6=8E=A5=E5=8F=A3=EF=BC=8C=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0Reprocessing=E6=8E=A5=E5=8F=A3=20ConfigureData?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AD=97=E6=AE=B5=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/entity/vo/ConfigureData.java | 22 ++-- .../jeecg/modules/entity/vo/SpecSetup.java | 4 +- .../java/org/jeecg/common/GammaFileUtil.java | 10 +- .../modules/spectrum/Sample_G_Analysis.java | 4 +- .../org/jeecg/common/util/GammaFileUtil.java | 61 +++++---- .../org/jeecg/common/util/UserTaskUtil.java | 9 ++ .../modules/controller/GammaController.java | 14 +-- .../jeecg/modules/service/IGammaService.java | 7 +- .../service/impl/GammaServiceImpl.java | 119 +++++++----------- .../GardsAnalySettingSpectrumServiceImpl.java | 2 +- 10 files changed, 115 insertions(+), 137 deletions(-) diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/ConfigureData.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/ConfigureData.java index 57795f4f..1ab18f39 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/ConfigureData.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/ConfigureData.java @@ -10,21 +10,19 @@ import java.util.Date; @Data public class ConfigureData implements Serializable { - private Integer sampleId; - private String fileName; - private Double ECutAnalysis_Low; + private Double eCutAnalysis_Low; - private Double ECutAnalysis_High; + private Double eCutAnalysis_High; - private Double EnergyTolerance; + private Double energyTolerance; - private Double PSS_low; + private Double pss_low; - private Double CalibrationPSS_low; + private Double calibrationPSS_low; - private Double CalibrationPSS_high; + private Double calibrationPSS_high; private Double k_back; @@ -32,16 +30,16 @@ public class ConfigureData implements Serializable { private Double k_beta; - private Double BaseImprovePSS; + private Double baseImprovePSS; - private Double RiskLevelK; + private Double riskLevelK; @DateTimeFormat(pattern = "yyyy/MM/dd HH:mm:ss") @JsonFormat(pattern = "yyyy/MM/dd HH:mm:ss", timezone = "GMT+8") - private Date RefTime_act; + private Date refTime_act; @DateTimeFormat(pattern = "yyyy/MM/dd HH:mm:ss") @JsonFormat(pattern = "yyyy/MM/dd HH:mm:ss", timezone = "GMT+8") - private Date RefTime_conc; + private Date refTime_conc; } diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/SpecSetup.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/SpecSetup.java index 60999248..a0af2ca2 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/SpecSetup.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/SpecSetup.java @@ -22,7 +22,7 @@ public class SpecSetup implements Serializable { private double baseImprovePSS; - private double pSS_low; + private double pss_low; private double k_back; @@ -51,7 +51,7 @@ public class SpecSetup implements Serializable { calibrationPSS_high = 10.0; calibrationPSS_low = 5.0; baseImprovePSS = 10.0; - pSS_low = 2.7; + pss_low = 2.7; k_back = 1.25; k_alpha = 2.576; k_beta = 1.645; diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/common/GammaFileUtil.java b/jeecg-module-auto-process/src/main/java/org/jeecg/common/GammaFileUtil.java index 74796de3..0811d8ca 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/common/GammaFileUtil.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/common/GammaFileUtil.java @@ -749,7 +749,7 @@ public class GammaFileUtil { phd.getUsedSetting().setCalibrationPSS_high(analySetting.getCalibrationpssHigh()); phd.getUsedSetting().setCalibrationPSS_low(analySetting.getCalibrationpssLow()); phd.getUsedSetting().setBaseImprovePSS(analySetting.getBaseimprovepss()); - phd.getUsedSetting().setPSS_low(analySetting.getPssLow()); + phd.getUsedSetting().setPss_low(analySetting.getPssLow()); phd.getUsedSetting().setK_back(analySetting.getKBack()); phd.getUsedSetting().setK_alpha(analySetting.getKAlpha()); phd.getUsedSetting().setK_beta(analySetting.getKBeta()); @@ -1481,7 +1481,7 @@ public class GammaFileUtil { phdSetting.setECutAnalysis_Low(configureData.getECutAnalysis_Low()); phdSetting.setECutAnalysis_High(configureData.getECutAnalysis_High()); phdSetting.setEnergyTolerance(configureData.getEnergyTolerance()); - phdSetting.setPSS_low(configureData.getPSS_low()); + phdSetting.setPss_low(configureData.getPss_low()); phdSetting.setBaseImprovePSS(configureData.getBaseImprovePSS()); phdSetting.setK_back(configureData.getK_back()); phdSetting.setK_alpha(configureData.getK_alpha()); @@ -1528,7 +1528,7 @@ public class GammaFileUtil { if(newSets.getECutAnalysis_Low() != oldSets.getECutAnalysis_Low() || newSets.getECutAnalysis_High() != oldSets.getECutAnalysis_High() || newSets.getEnergyTolerance() != oldSets.getEnergyTolerance() - || newSets.getPSS_low() != oldSets.getCalibrationPSS_low() + || newSets.getPss_low() != oldSets.getCalibrationPSS_low() || newSets.getBaseImprovePSS() != oldSets.getBaseImprovePSS() || newSets.getK_back() != oldSets.getK_back() || newSets.getK_alpha() != oldSets.getK_alpha() @@ -2489,7 +2489,7 @@ public class GammaFileUtil { 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("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"); @@ -2642,7 +2642,7 @@ public class GammaFileUtil { 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(" 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"); diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_G_Analysis.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_G_Analysis.java index 340158f1..7be44e7d 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_G_Analysis.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_G_Analysis.java @@ -289,7 +289,7 @@ public class Sample_G_Analysis { infoMap.put("ECutAnalysis_High", middleData.setting_specSetup.getECutAnalysis_High()); infoMap.put("EnergyTolerance", middleData.setting_specSetup.getEnergyTolerance()); infoMap.put("BaseImprovePSS", middleData.setting_specSetup.getBaseImprovePSS()); - infoMap.put("PSS_low", middleData.setting_specSetup.getPSS_low()); + infoMap.put("PSS_low", middleData.setting_specSetup.getPss_low()); infoMap.put("k_back", middleData.setting_specSetup.getK_back()); infoMap.put("k_alpha", middleData.setting_specSetup.getK_alpha()); infoMap.put("k_beta", middleData.setting_specSetup.getK_beta()); @@ -779,7 +779,7 @@ public class Sample_G_Analysis { setting.setK_beta(Double.parseDouble(k_beta)); String PSS_low = mapSetting.get(Setting.PSS_LOW); if (StrUtil.isNotBlank(PSS_low)) - setting.setPSS_low(Double.parseDouble(PSS_low)); + setting.setPss_low(Double.parseDouble(PSS_low)); String RiskLevelK = mapSetting.get(Setting.RISKLEVELK); if (StrUtil.isNotBlank(RiskLevelK)) setting.setRiskLevelK(Double.parseDouble(RiskLevelK)); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java index 58e7573a..bf33643a 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java @@ -1,5 +1,6 @@ package org.jeecg.common.util; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.StringPool; @@ -25,6 +26,7 @@ import org.jeecg.modules.native_jni.CalValuesHandler; import org.jeecg.modules.native_jni.EnergySpectrumHandler; import org.jeecg.modules.native_jni.struct.CalValuesOut; import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @@ -239,7 +241,9 @@ public class GammaFileUtil { } phd.getSetting().setRefTime_conc(DateUtils.parseDate(phd.getCollect().getCollection_start_date() + StringPool.SPACE + phd.getCollect().getCollection_start_time().substring(0, phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss")); phd.getSetting().setRefTime_act(DateUtils.parseDate(phd.getAcq().getAcquisition_start_date() + StringPool.SPACE + phd.getAcq().getAcquisition_start_time().substring(0, phd.getAcq().getAcquisition_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss")); - phd.setUsedSetting(phd.getSetting()); + SpecSetup usedSetting = new SpecSetup(); + BeanUtils.copyProperties(phd.getSetting(), usedSetting); + phd.setUsedSetting(usedSetting); phd.setBAnalyed(false); phd.setAnaly_start_time(DateUtils.formatDate(new Date(), "yyyy/MM/dd HH:mm:ss")); @@ -743,7 +747,7 @@ public class GammaFileUtil { phd.getUsedSetting().setCalibrationPSS_high(analySetting.getCalibrationpssHigh()); phd.getUsedSetting().setCalibrationPSS_low(analySetting.getCalibrationpssLow()); phd.getUsedSetting().setBaseImprovePSS(analySetting.getBaseimprovepss()); - phd.getUsedSetting().setPSS_low(analySetting.getPssLow()); + phd.getUsedSetting().setPss_low(analySetting.getPssLow()); phd.getUsedSetting().setK_back(analySetting.getKBack()); phd.getUsedSetting().setK_alpha(analySetting.getKAlpha()); phd.getUsedSetting().setK_beta(analySetting.getKBeta()); @@ -1470,23 +1474,7 @@ public class GammaFileUtil { return datalist; } - public int AnalyseData(PHDFile phd, ConfigureData configureData, List nuclides, Result result) { - //调用方法判断是否修改了参数 - if (Objects.nonNull(configureData)){ - SpecSetup phdSetting = phd.getSetting(); - phdSetting.setECutAnalysis_Low(configureData.getECutAnalysis_Low()); - phdSetting.setECutAnalysis_High(configureData.getECutAnalysis_High()); - phdSetting.setEnergyTolerance(configureData.getEnergyTolerance()); - phdSetting.setPSS_low(configureData.getPSS_low()); - phdSetting.setBaseImprovePSS(configureData.getBaseImprovePSS()); - phdSetting.setK_back(configureData.getK_back()); - phdSetting.setK_alpha(configureData.getK_alpha()); - phdSetting.setK_beta(configureData.getK_beta()); - phdSetting.setRiskLevelK(configureData.getRiskLevelK()); - phdSetting.setRefTime_act(configureData.getRefTime_act()); - phdSetting.setRefTime_conc(configureData.getRefTime_conc()); - } - + public int AnalyseData(PHDFile phd, List nuclides) { int change = SettingChanged(phd); if(change == 0 && phd.getVPeak().size() > 0) { return change; @@ -1498,10 +1486,6 @@ public class GammaFileUtil { Map nuclideLinesMap = GetNuclideLines(nuclides); NuclidesIdent(phd, nuclideLinesMap); RunQC(phd); - result.error500("Finish three tasks:\n"+ - "\t1.Update efficiencies of all peaks;\n"+ - "\t2.Identify nuclides again;\n"+ - "\t3.Test QC again."); } else { Map nuclideLinesMap = GetNuclideLines(nuclides); AnalyseSpectrum(phd, nuclideLinesMap); @@ -1511,14 +1495,29 @@ public class GammaFileUtil { public boolean AnalyseSpectrum(PHDFile phd, Map mapLines){ System.loadLibrary("GammaAnaly"); + //解析获取临时文件信息 + File tmpFile = analyzeFile(phd.getFilepath(), phd.getFilename()); ObjectMapper mapper = new ObjectMapper(); try { String phdStr = mapper.writeValueAsString(phd); - String mapLinesStr = mapper.writeValueAsString(mapLines); - String analyseSpectrum = CalValuesHandler.analyseSpectrum(phdStr, mapLinesStr, ""); - JSONObject jsonObject = JSONObject.parseObject(analyseSpectrum); - String jsonString = jsonObject.toJSONString(); - + String nuclideLinesMap = mapper.writeValueAsString(mapLines); + String strValue = CalValuesHandler.analyseSpectrum(phdStr, nuclideLinesMap, tmpFile.getAbsolutePath()); + PHDFile phdFile = JSON.parseObject(strValue, PHDFile.class); + phd.setVLc(phdFile.getVLc()); + phd.setVScac(phdFile.getVScac()); + phd.setVBase(phdFile.getVBase()); + phd.setVEnergy(phdFile.getVEnergy()); + phd.setVPeak(phdFile.getVPeak()); + for (PeakInfo peak:phd.getVPeak()) { + if (StringUtils.isBlank(peak.recoilBetaChan)) { + peak.recoilBetaChan = "1"; + } + if (StringUtils.isBlank(peak.recoilDeltaChan)) { + peak.recoilDeltaChan = "1"; + } + } + //重新分析各峰值对应的核素信息 + NuclidesIdent(phd, mapLines); } catch (JsonProcessingException e) { throw new RuntimeException(e); } @@ -1532,7 +1531,7 @@ public class GammaFileUtil { if(newSets.getECutAnalysis_Low() != oldSets.getECutAnalysis_Low() || newSets.getECutAnalysis_High() != oldSets.getECutAnalysis_High() || newSets.getEnergyTolerance() != oldSets.getEnergyTolerance() - || newSets.getPSS_low() != oldSets.getCalibrationPSS_low() + || newSets.getPss_low() != oldSets.getPss_low() || newSets.getBaseImprovePSS() != oldSets.getBaseImprovePSS() || newSets.getK_back() != oldSets.getK_back() || newSets.getK_alpha() != oldSets.getK_alpha() @@ -2493,7 +2492,7 @@ public class GammaFileUtil { 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("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"); @@ -2650,7 +2649,7 @@ public class GammaFileUtil { 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(" 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"); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/UserTaskUtil.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/UserTaskUtil.java index 875ae6a7..c898c3db 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/UserTaskUtil.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/UserTaskUtil.java @@ -77,8 +77,17 @@ public class UserTaskUtil { return flag; } + /** + * 根据用户名获取用户相关权限信息 + * @param userName + * @return + */ public List findRoleCodeByUserName(String userName){ return userTaskService.findRoleCodeByUserName(userName); } + public SysUser findUserByName(String userName) { + return userTaskService.findUserByName(userName); + } + } 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 b45f634c..82b23b0d 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 @@ -53,11 +53,6 @@ public class GammaController { redisTemplate.convertAndSend(GlobalConstants.REDIS_TOPIC_NAME, params);; } - @GetMapping("testFun") - public Result testFun(String fileName,HttpServletRequest request){ - return gammaService.testFun(fileName, request); - } - @GetMapping("gammaByDB") public Result gammaByDB(Integer sampleId, String dbName, HttpServletRequest request){ return gammaService.gammaByDB(dbName, sampleId, request); @@ -84,10 +79,15 @@ public class GammaController { return gammaService.configure(sampleId, fileName); } + @PostMapping("configureSave") + public Result configureSave(@RequestBody ConfigureData configureData) { + return gammaService.configureSave(configureData); + } + @PostMapping("Reprocessing") @ApiOperation(value = "analyze菜单下Reprocessing页面数据", notes = "analyze菜单下Reprocessing页面数据") - public Result Reprocessing(@RequestBody ConfigureData configureData, HttpServletRequest request) { - return gammaService.Reprocessing(configureData, request); + public Result Reprocessing(String fileName, HttpServletRequest request) { + return gammaService.Reprocessing(fileName, request); } @GetMapping("InteractiveTool") 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 2bd327e6..be498b4b 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 @@ -3,6 +3,7 @@ package org.jeecg.modules.service; import org.jeecg.common.api.vo.Result; import org.jeecg.modules.base.bizVo.GammaRLR; import org.jeecg.modules.entity.vo.*; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; @@ -13,8 +14,6 @@ public interface IGammaService{ Result initValue(Integer sampleId, String dbName, HttpServletRequest request); - Result testFun(String fileName, HttpServletRequest request); - Result gammaByDB(String dbName, Integer sampleId, HttpServletRequest request); Result gammaByFile(String fileName, HttpServletRequest request); @@ -25,7 +24,9 @@ public interface IGammaService{ Result configure(Integer sampleId, String fileName); - Result Reprocessing(ConfigureData configureData, HttpServletRequest request); + Result configureSave(ConfigureData configureData); + + Result Reprocessing(String fileName, HttpServletRequest request); Result InteractiveTool(Integer sampleId, String fileName, 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 25042ab3..21cf147e 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 @@ -28,6 +28,7 @@ import org.jeecg.common.system.util.JwtUtil; import org.jeecg.common.util.*; import org.jeecg.modules.base.bizVo.GammaRLR; import org.jeecg.modules.base.entity.configuration.GardsNuclLinesLib; +import org.jeecg.modules.base.entity.postgre.SysUser; import org.jeecg.modules.base.enums.ExportTemplate; import org.jeecg.modules.base.enums.RoleType; import org.jeecg.modules.entity.vo.*; @@ -121,6 +122,7 @@ public class GammaServiceImpl implements IGammaService { @Override public Result initValue(Integer sampleId, String dbName, HttpServletRequest request) { Result result = new Result(); + // String userName = JwtUtil.getUserNameByToken(request); Cache phdCache = localCache.getPHDCache(); PHDFile phd = new PHDFile(); @@ -151,66 +153,6 @@ public class GammaServiceImpl implements IGammaService { return result; } - @Override - public Result testFun(String fileName, HttpServletRequest request) { - Result result = new Result(); - Map map = new HashMap<>(); - Cache phdCache = localCache.getPHDCache(); - PHDFile phd = phdCache.getIfPresent(fileName); - if (Objects.isNull(phd)){ - result.error500("请先选择解析文件!"); - return result; - } - phd.setUserId("1"); - phd.setXmlFilePath(parameterFilePath); - String userName = JwtUtil.getUserNameByToken(request); - //获取当前角色的颜色配置 - Map colorMap = sysUserColorService.initColor(userName); - //查询当前用户关联的核素信息 - List nuclides = new LinkedList<>(); - //从postgreSql中获取当前用户关注的核素信息 如果当前用户没有 则返回管理员的 - nuclides = defaultNuclideSpectrumService.findNuclidesByUserName(userName, phd.getHeader().getSystem_type().toUpperCase()); - if (CollectionUtils.isEmpty(nuclides)){ - nuclides = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase()); - } - Map nuclideLinesMap = gammaFileUtil.GetNuclideLines(nuclides); - //解析获取临时文件信息 - File tmpFile = gammaFileUtil.analyzeFile(StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName, fileName); - ObjectMapper mapper = new ObjectMapper(); - try { - String phdStr = mapper.writeValueAsString(phd); - String mapLines = mapper.writeValueAsString(nuclideLinesMap); - String strValue = CalValuesHandler.analyseSpectrum(phdStr, mapLines, tmpFile.getAbsolutePath()); - PHDFile phdFile = JSON.parseObject(strValue, PHDFile.class); - phd.setVLc(phdFile.getVLc()); - phd.setVScac(phdFile.getVScac()); - phd.setVBase(phdFile.getVBase()); - phd.setVEnergy(phdFile.getVEnergy()); - phd.setVPeak(phdFile.getVPeak()); - for (PeakInfo peak:phd.getVPeak()) { - if (StringUtils.isBlank(peak.recoilBetaChan)) { - peak.recoilBetaChan = "1"; - } - if (StringUtils.isBlank(peak.recoilDeltaChan)) { - peak.recoilDeltaChan = "1"; - } - } - gammaFileUtil.UpdateChart(phd, map, colorMap); - // - gammaFileUtil.NuclidesIdent(phd, nuclideLinesMap); - // 更新 ‘QC Flags’ 状态 - List qcstate = gammaFileUtil.Qcstate(phd); - map.put("QCFlag", qcstate); - phdCache.put(fileName, phd); - localCache.setPHDCache(phdCache); - result.setResult(map); - } catch (JsonProcessingException e) { - throw new RuntimeException(e); - } - result.setSuccess(true); - return result; - } - @Override public Result gammaByDB(String dbName, Integer sampleId, HttpServletRequest request) { Result result = new Result(); @@ -366,7 +308,7 @@ public class GammaServiceImpl implements IGammaService { map.put("edit_ps_low", setup.getECutAnalysis_Low()); map.put("edit_ps_high", setup.getECutAnalysis_High()); map.put("edit_energy", setup.getEnergyTolerance()); - map.put("edit_pss_low", setup.getPSS_low()); + map.put("edit_pss_low", setup.getPss_low()); map.put("edit_cal_low", setup.getCalibrationPSS_low()); map.put("edit_cal_high", setup.getCalibrationPSS_high()); map.put("checkBox_updateCal", setup.isBUpdateCal()); @@ -389,7 +331,7 @@ public class GammaServiceImpl implements IGammaService { } @Override - public Result Reprocessing(ConfigureData configureData, HttpServletRequest request) { + public Result configureSave(ConfigureData configureData) { Result result = new Result(); String fileName = configureData.getFileName(); Cache phdCache = localCache.getPHDCache(); @@ -398,7 +340,41 @@ public class GammaServiceImpl implements IGammaService { result.error500("请先选择解析文件!"); return result; } + SpecSetup phdSetting = phd.getSetting(); + phdSetting.setECutAnalysis_Low(configureData.getECutAnalysis_Low()); + phdSetting.setECutAnalysis_High(configureData.getECutAnalysis_High()); + phdSetting.setEnergyTolerance(configureData.getEnergyTolerance()); + phdSetting.setPss_low(configureData.getPss_low()); + phdSetting.setBaseImprovePSS(configureData.getBaseImprovePSS()); + phdSetting.setK_back(configureData.getK_back()); + phdSetting.setK_alpha(configureData.getK_alpha()); + phdSetting.setK_beta(configureData.getK_beta()); + phdSetting.setRiskLevelK(configureData.getRiskLevelK()); + phdSetting.setRefTime_act(configureData.getRefTime_act()); + phdSetting.setRefTime_conc(configureData.getRefTime_conc()); + phdCache.put(fileName, phd); + localCache.setPHDCache(phdCache); + result.success("保存成功"); + return result; + } + + @Override + public Result Reprocessing(String fileName, HttpServletRequest request) { + Result result = new Result(); String userName = JwtUtil.getUserNameByToken(request); + Cache phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(fileName); + if (Objects.isNull(phd)){ + result.error500("请先选择解析文件!"); + return result; + } + //获取当前用户信息 + SysUser user = userTaskUtil.findUserByName(userName); + if (Objects.nonNull(user)) { + phd.setUserId(user.getId()); + } + //赋值xml文件存放路径 + phd.setXmlFilePath(parameterFilePath); //获取当前角色的颜色配置 Map colorMap = sysUserColorService.initColor(userName); //查询当前用户关联的核素信息 @@ -408,7 +384,8 @@ public class GammaServiceImpl implements IGammaService { if (CollectionUtils.isEmpty(nuclides)){ nuclides = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase()); } - int flag = gammaFileUtil.AnalyseData(phd, configureData, nuclides, result); + //分析文件数据 + int flag = gammaFileUtil.AnalyseData(phd, nuclides); if (flag == 0){ String warning = "The spectrum needn't Analyed. Maybe:\n"+ "1. It has already Analyed.\n"+ @@ -422,21 +399,15 @@ public class GammaServiceImpl implements IGammaService { result.error500(warning); } else { Map map = new HashMap<>(); - phd.getUsedSetting().setECutAnalysis_Low(configureData.getECutAnalysis_Low()); - phd.getUsedSetting().setECutAnalysis_High(configureData.getECutAnalysis_High()); - phd.getUsedSetting().setEnergyTolerance(configureData.getEnergyTolerance()); - phd.getUsedSetting().setPSS_low(configureData.getPSS_low()); - phd.getUsedSetting().setBaseImprovePSS(configureData.getBaseImprovePSS()); - phd.getUsedSetting().setK_back(configureData.getK_back()); - phd.getUsedSetting().setK_alpha(configureData.getK_alpha()); - phd.getUsedSetting().setK_beta(configureData.getK_beta()); - phd.getUsedSetting().setRiskLevelK(configureData.getRiskLevelK()); - phd.getUsedSetting().setRefTime_act(configureData.getRefTime_act()); - phd.getUsedSetting().setRefTime_conc(configureData.getRefTime_conc()); gammaFileUtil.UpdateChart(phd, map, colorMap); + // 更新 ‘QC Flags’ 状态 + List qcstate = gammaFileUtil.Qcstate(phd); + map.put("QCFlag", qcstate); result.setSuccess(true); result.setResult(map); } + phdCache.put(fileName, phd); + localCache.setPHDCache(phdCache); return result; } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GardsAnalySettingSpectrumServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GardsAnalySettingSpectrumServiceImpl.java index 97806509..958653eb 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GardsAnalySettingSpectrumServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GardsAnalySettingSpectrumServiceImpl.java @@ -25,7 +25,7 @@ public class GardsAnalySettingSpectrumServiceImpl extends ServiceImpl Date: Mon, 25 Sep 2023 17:16:30 +0800 Subject: [PATCH 08/11] =?UTF-8?q?GammaController=E5=88=86=E6=9E=90?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E8=8E=B7=E5=8F=96=E8=BF=94=E5=9B=9E=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=96=B9=E5=BC=8F=E4=BF=AE=E6=94=B9=EF=BC=8CtestFun?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=86=85=E5=AE=B9=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jeecg/common/util/GammaFileUtil.java | 296 ++++++++++++++++-- .../modules/controller/GammaController.java | 23 ++ .../jeecg/modules/service/IGammaService.java | 8 + .../service/impl/GammaServiceImpl.java | 246 ++++++++++++++- 4 files changed, 541 insertions(+), 32 deletions(-) diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java index bf33643a..e652eef7 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java @@ -295,8 +295,11 @@ public class GammaFileUtil { File file = File.createTempFile("tmp", null); //将ftp文件的输入流复制给临时文件 FileUtils.copyInputStreamToFile(inputStream, file); + //调用FileUtils的readLines方法获取文件的所有行数据 List readLines = FileUtils.readLines(file, "UTF-8"); + //得到行数据处理后的数据结果 List vData = ReadLcScacInfo(readLines); + //将数据结果赋值给 phdFile的vLc phd.setVLc(vData); } } catch (IOException e) { @@ -336,8 +339,11 @@ public class GammaFileUtil { File file = File.createTempFile("tmp", null); //将ftp文件的输入流复制给临时文件 FileUtils.copyInputStreamToFile(inputStream, file); + //调用FileUtils的readLines方法获取文件的所有行数据 List readLines = FileUtils.readLines(file, "UTF-8"); + //得到行数据处理后的数据结果 List vData = ReadLcScacInfo(readLines); + //将数据结果赋值给 phdFile的vScac phd.setVScac(vData); } } catch (IOException e) { @@ -371,9 +377,12 @@ public class GammaFileUtil { ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); ftpClient.changeWorkingDirectory(pathName); String baselineFileName = "RNAUTO_"+subFileName + ".baseline"; + //获取ftp的文件流数据 inputStream = ftpClient.retrieveFileStream(baselineFileName); if (Objects.nonNull(inputStream)){ + //调用处理BaseCtrl的方法 ReadBaseCtrlInfo(phd, inputStream); + //将phdFile的BaseCtrls的BaseLine部分数据 赋值给 phdFile的vBase phd.setVBase(phd.getBaseCtrls().getBaseline()); } } catch (IOException e) { @@ -394,32 +403,52 @@ public class GammaFileUtil { } public List ReadLcScacInfo(List readLines) { + //声明一个结果集合 List vData = new LinkedList<>(); + //遍历行数据 for (int i=0; i< readLines.size(); i++){ + //读取当前行数据 String line = readLines.get(i); + //判断当前行是否包含# 如果包含则进入 if (line.contains("#")){ + //声明下一行的下标 int j=i+1; + //读取当前行的下一行的数据 line = readLines.get(j); + //将下一行的数据赋给一个 新的行数据 String line1 = line; + //遍历判断 下标不是行数据的最后一行 且 行数据不为空 while (j != readLines.size()-1 && StringUtils.isNotBlank(line) ){ + //行下标+1 j++; + //读取下一行数据 line = readLines.get(j); + //判断下一行数据是否包含# if (!line.contains("#")){ + //不包含#则将当前行数据 拼接到 行数据 line1 += StringPool.SPACE + line; - }else { + }else {//否则结束循环 break; } } + //所有行数据 去掉首位空位符 line1 = line1.trim(); + //行数据根据任意形式空格切割成数组 List strList = Arrays.asList(line1.split("\\s+")); + //如果数据量小于2 跳过本次循环 继续下一行读取 if(strList.size() < 2){ continue; } + //遍历行数据数组 for(int k=1; k> map = new HashMap<>(); + //判断当前行数据是否为空 while (null != (line = reader.readLine())) { + //如果当前行包含# if (line.contains("#")) { + //将当前行数据去掉前后空字符并赋值给标题名称对象 block_name = line.trim(); + //向map中加入当前标题名称 初始化集合信息 map.put(block_name, new LinkedList<>()); continue; } + //根据当前标题名称读取集合数据 List data = map.get(block_name); + //对当前行数据使用任意空格符切割数据 String[] split = line.split("\\s+"); + //遍历数组 for(String str : split) { + //如果当前当前数据不为空 且 数据不匹配任意大小写的nan if (StringUtils.isNotBlank(str) && !str.equalsIgnoreCase("nan")){ + //当前数据转为double 并 存入到集合中 double d = Double.parseDouble(str); data.add(d); } else if (StringUtils.isNotBlank(str) && str.equalsIgnoreCase("nan")) { + //如果当前数据不为空 但 数据匹配任意大小写的nan + //将0.0填充到 double中 data.add(0.0); } } } + //判断map是否含有#AnalyseRange if(map.containsKey("#AnalyseRange")) { + //根据#AnalyseRange获取对应的集合信息 List vTemp = map.get("#AnalyseRange"); + //如果集合大小等于2 if(vTemp.size() == 2) { + //集合中第一个赋值给 phdFile的baseCtrls的rg_low phd.getBaseCtrls().setRg_low(vTemp.get(0).intValue()); + //集合中第二个赋值给 phdFile的baseCtrls的rg_high phd.getBaseCtrls().setRg_high(vTemp.get(1).intValue()); } } + //判断map是否含有#XCtrl if(map.containsKey("#XCtrl")) { + //根据#XCtrl获取对应的集合信息 List vTemp = map.get("#XCtrl"); + //将集合数据 赋值给 phdFile的BaseCtrls的xCtrl phd.getBaseCtrls().setXCtrl(vTemp); } + //判断map是否含有#YCtrl if(map.containsKey("#YCtrl")) { + //根据#YCtrl获取集合信息 List vTemp = map.get("#YCtrl"); + //将集合信息赋值给 phdFile的BaseCtrls的yCtrl phd.getBaseCtrls().setYCtrl(vTemp); } + //判断map是否含有#YSlope if(map.containsKey("#YSlope")) { + //根据#YSlope获取集合信息 List vTemp = map.get("#YSlope"); + //将集合信息赋值给 phdFile的BaseCtrls的ySlope phd.getBaseCtrls().setYSlope(vTemp); } + //判断map是否含有#Baseline if(map.containsKey("#Baseline")) { + //根据#Baseline获取集合数据 List vTemp = map.get("#Baseline"); + //截取集合 下标1到末尾的数据 List list = vTemp.subList(1, vTemp.size()); + //将截取后的数据 赋值给 phdFile的BaseCtrls的Baseline phd.getBaseCtrls().setBaseline(list); } + //判断map是否含有#StepCounts if(map.containsKey("#StepCounts")) { + //根据#StepCounts获取集合数据 List vTemp = map.get("#StepCounts"); + //截取集合 下标1到末尾的数据 List list = vTemp.subList(1, vTemp.size()); + //将截取后的数据 赋值给 phdFile的BaseCtrls phd.getBaseCtrls().setStepCounts(list); } } catch (IOException e) { @@ -783,26 +849,40 @@ public class GammaFileUtil { public List Qcstate(PHDFile phd) { // Collection Time、 Acq Time、 Decay Time、 SampVol、 Be7-FWHM、 Ba140-MDC、 Xe133-MDC List qcState = new LinkedList<>(); + //初始化七个状态颜色为 灰色 for (int i=0;i<7; i++){ qcState.add("GRAY"); } + //判断 phdFile下QcItems大小是否小于等于5 if(phd.getQcItems().size() <= 5) { - this.RunQC(phd); + //执行判断QC状态方法 + RunQC(phd); } + //判断 QcItems的col_time的BPass状态 如果是true 则颜色赋值为BLUE 如果是false 则颜色赋值为 RED qcState.set(0, phd.getQcItems().get("col_time").isBPass()?"BLUE":"RED"); + //判断 QcItems的acq_time的BPass状态 如果是true 则颜色赋值为BLUE 如果是false 则颜色赋值为 RED qcState.set(1, phd.getQcItems().get("acq_time").isBPass()?"BLUE":"RED"); + //判断 QcItems的decay_time的BPass状态 如果是true 则颜色赋值为BLUE 如果是false 则颜色赋值为 RED qcState.set(2, phd.getQcItems().get("decay_time").isBPass()?"BLUE":"RED"); + //判断 QcItems的samp_vol的BPass状态 如果是true 则颜色赋值为BLUE 如果是false 则颜色赋值为 RED qcState.set(3, phd.getQcItems().get("samp_vol").isBPass()?"BLUE":"RED"); - + //判断当前文件系统类型是否匹配 P if(phd.getHeader().getSystem_type().equalsIgnoreCase("P")) { + //如果匹配P 判断 QcItems的Be7-FWHM数据是否为空 if(Objects.nonNull(phd.getQcItems().get("Be7-FWHM"))) { + //不为空 判断 QcItems的Be7-FWHM的BPass状态 如果是true 则颜色赋值为BLUE 如果是false则颜色赋值为RED qcState.set(4, phd.getQcItems().get("Be7-FWHM").isBPass()?"BLUE":"RED"); } + //如果匹配P 判断 QcItems的Ba140-MDC数据是否为空 if(Objects.nonNull(phd.getQcItems().get("Ba140-MDC"))) { + //不为空 判断 QcItems的Ba140-MDC的BPass状态 如果是true 则颜色赋值为BLUE 如果是false则颜色赋值为RED qcState.set(5, phd.getQcItems().get("Ba140-MDC").isBPass()?"BLUE":"RED"); } } else if(phd.getHeader().getSystem_type().equalsIgnoreCase("G")) { + //判断当前文件系统类型是否匹配 G + //如果匹配G 判断 QcItems的Xe133-MDC数据是否为空 if(Objects.nonNull(phd.getQcItems().get("Xe133-MDC"))) { + //不为空 判断 QcItems的Xe133-MDC的BPass状态 如果是true 则颜色赋值为BLUE 如果是false则颜色赋值为RED qcState.set(6, phd.getQcItems().get("Xe133-MDC").isBPass()?"BLUE":"RED"); } } @@ -810,64 +890,99 @@ public class GammaFileUtil { } public void RunQC(PHDFile phd) { + //调用dll库 System.loadLibrary("GammaAnaly"); try { + //获取phdFile的 采集开始时间 Date start = DateUtils.parseDate(phd.getCollect().getCollection_start_date() + StringPool.SPACE + phd.getCollect().getCollection_start_time()); + //获取phdFile的 采集结束时间 Date end = DateUtils.parseDate(phd.getCollect().getCollection_stop_date() + StringPool.SPACE + phd.getCollect().getCollection_stop_time()); + //获取phdFile的 分析开始时间 Date acq = DateUtils.parseDate(phd.getAcq().getAcquisition_start_date() + StringPool.SPACE + phd.getAcq().getAcquisition_start_time()); - + //计算得到采集耗时 double collect_hour = (end.getTime()/1000 - start.getTime()/1000) / 3600.0; + //获取 实际分析时长 double acq_hour = phd.getAcq().getAcquisition_real_time() / 3600.0; + //计算得到衰减耗时 double Decay_hour = (acq.getTime()/1000 - end.getTime()/1000) / 3600.0; - + //声明一个double数据 Double ener_Be7 = 0.0; + //声明一个map用于存储计算数据 Map vMdcInfoMap = new HashMap<>(); + //声明一个数组存储计算数据 List vMdcInfo = new LinkedList<>(); + //声明一个数组存储QcItems数据 Map qcItems = new LinkedHashMap<>(); - if(!this.ReadQCLimit(qcItems, vMdcInfoMap, ener_Be7, phd.getHeader().getSystem_type().toUpperCase())) { + //调用方法 读取文件信息 判断QC数据 + if(!ReadQCLimit(qcItems, vMdcInfoMap, ener_Be7, phd.getHeader().getSystem_type().toUpperCase())) { String WARNING = "Read QC Flags from SystemManager.xml Failed!"; } + //判断map是否为空 if (CollectionUtils.isNotEmpty(vMdcInfoMap)) { + //根据键值按顺序向数组中插入数据 vMdcInfo.add(vMdcInfoMap.get("0")); vMdcInfo.add(vMdcInfoMap.get("1")); vMdcInfo.add(vMdcInfoMap.get("2")); } - + //获取QcItem中col_time数据 QcCheckItem colTime = qcItems.get("col_time"); + //将采集耗时 赋值给 colTime colTime.setValue(collect_hour); + //将数据存入QcItems的map中 qcItems.put("col_time", colTime); - + //获取QcItem中acq_time数据 QcCheckItem acqTime = qcItems.get("acq_time"); + //将实际分析时长 赋值给 acqTime acqTime.setValue(acq_hour); + //将数据存入QcItems的map中 qcItems.put("acq_time", acqTime); - + //获取QcItem中decay_time数据 QcCheckItem decayTime = qcItems.get("decay_time"); + //将衰减耗时 赋值给 decayTime decayTime.setValue(Decay_hour); + //将数据存入QcItems的map中 qcItems.put("decay_time", decayTime); - + //获取QcItem中samp_vol数据 QcCheckItem sampVol = qcItems.get("samp_vol"); + //将phdFile的Collect的air_volume赋值给 sampVol.setValue(phd.getCollect().getAir_volume()); + //将数据存入QcItems的map中 qcItems.put("samp_vol", sampVol); - + //获取QcItem中decay_time数据 QcCheckItem airFlow = qcItems.get("airFlow"); airFlow.setValue(phd.getCollect().getAir_volume() / collect_hour); + //将数据存入QcItems的map中 qcItems.put("airFlow", airFlow); - + //判断phdFile的valid参数是否为true phdFile的vBase集合大小是否等于phdFile的Spec的num_g_channel数据 if(phd.isValid() && phd.getVBase().size() == phd.getSpec().getNum_g_channel()) { + //判断system_type是否匹配P if(phd.getHeader().getSystem_type().equalsIgnoreCase("P")) { + //声明一个energy集合 List energy = new LinkedList<>(); + //集合增加数据 energy.add(ener_Be7); + //调用算法计算 CalValuesOut calValuesOut = CalValuesHandler.calFcnEval(energy, phd.getUsedResoPara().getP()); + //获取计算结果的counts赋值给 fwhm集合 List fwhm = calValuesOut.counts; + //获取QcItems中Be7-FWHM数据 QcCheckItem be7 = qcItems.get("Be7-FWHM"); + //将计算结果的第一个数据赋值给 be7 be7.setValue(fwhm.get(0)); + //将数据存入QcItems的map中 qcItems.put("Be7-FWHM", be7); + //获取QcItems中Ba140-MDC数据 QcCheckItem Ba140 = qcItems.get("Ba140-MDC"); + //调用CalculateMDC得到Ba140的数据 Ba140.setValue(CalculateMDC(phd, vMdcInfo, 1.0)); + //将数据存入QcItems的map中 qcItems.put("Ba140-MDC", Ba140); } else { + //获取QcItems中Xe133-MDC数据 QcCheckItem Xe133 = qcItems.get("Xe133-MDC"); + //调用CalculateMDC得到Xe133的数据 Xe133.setValue(CalculateMDC(phd, vMdcInfo, 1.0)); + //将数据存入QcItems的map中 qcItems.put("Xe133-MDC", Xe133); } } @@ -1191,8 +1306,8 @@ public class GammaFileUtil { if(m_nSChan == 0) { m_vCount.add(0L); } - ChartData shadowEnergyChart = this.Energy_Count(phd, m_vCount, m_nCount, colorMap.get("Color_Spec")); - ChartData shadowChannelChart = this.Channel_Count(m_vCount, m_nCount, colorMap.get("Color_Spec")); + ChartData shadowEnergyChart = Energy_Count(phd, m_vCount, m_nCount, colorMap.get("Color_Spec")); + ChartData shadowChannelChart = Channel_Count(m_vCount, m_nCount, colorMap.get("Color_Spec")); map.put("shadowEnergyChart", shadowEnergyChart); map.put("shadowChannelChart", shadowChannelChart); List allData = AllData(false, phd, m_vCount, m_nCount, colorMap); @@ -1502,12 +1617,135 @@ public class GammaFileUtil { String phdStr = mapper.writeValueAsString(phd); String nuclideLinesMap = mapper.writeValueAsString(mapLines); String strValue = CalValuesHandler.analyseSpectrum(phdStr, nuclideLinesMap, tmpFile.getAbsolutePath()); - PHDFile phdFile = JSON.parseObject(strValue, PHDFile.class); - phd.setVLc(phdFile.getVLc()); - phd.setVScac(phdFile.getVScac()); - phd.setVBase(phdFile.getVBase()); - phd.setVEnergy(phdFile.getVEnergy()); - phd.setVPeak(phdFile.getVPeak()); + Map parseMap = JSON.parseObject(strValue, Map.class); + for (Map.Entry entry:parseMap.entrySet()) { + if (entry.getKey().equalsIgnoreCase("bAnalyed")) { + boolean value = (boolean) entry.getValue(); + phd.setBAnalyed(value); + } + if (entry.getKey().equalsIgnoreCase("mapEnerPara")) { + Map value = (Map) entry.getValue(); + phd.setMapEnerPara(value); + } + if (entry.getKey().equalsIgnoreCase("mapResoPara")) { + Map value = (Map) entry.getValue(); + phd.setMapResoPara(value); + } + if (entry.getKey().equalsIgnoreCase("mapEffiPara")) { + Map value = (Map) entry.getValue(); + phd.setMapEffiPara(value); + } + if (entry.getKey().equalsIgnoreCase("mapTotEPara")) { + Map value = (Map) entry.getValue(); + phd.setMapTotEPara(value); + } + if (entry.getKey().equalsIgnoreCase("para_stepRatio")) { + ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class); + phd.setPara_stepRatio(value); + } + if (entry.getKey().equalsIgnoreCase("para_tail")) { + ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class); + phd.setPara_tail(value); + } + if (entry.getKey().equalsIgnoreCase("para_tailAlpha")) { + ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class); + phd.setPara_tailAlpha(value); + } + if (entry.getKey().equalsIgnoreCase("para_tailRight")) { + ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class); + phd.setPara_tailRight(value); + } + if (entry.getKey().equalsIgnoreCase("para_tailRightAlpha")) { + ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class); + phd.setPara_tailRightAlpha(value); + } + if (entry.getKey().equalsIgnoreCase("newEner")) { + String value = (String) entry.getValue(); + phd.setNewEner(value); + } + if (entry.getKey().equalsIgnoreCase("mapEnerKD")) { + Map value = (Map) entry.getValue(); + phd.setMapEnerKD(value); + } + if (entry.getKey().equalsIgnoreCase("mapResoKD")) { + Map value = (Map) entry.getValue(); + phd.setMapResoKD(value); + } + if (entry.getKey().equalsIgnoreCase("vEnergy")) { + List value = (List) entry.getValue(); + phd.setVEnergy(value); + } + if (entry.getKey().equalsIgnoreCase("vBase")) { + List value = (List) entry.getValue(); + phd.setVBase(value); + } + if (entry.getKey().equalsIgnoreCase("vLc")) { + List value = (List) entry.getValue(); + phd.setVLc(value); + } + if (entry.getKey().equalsIgnoreCase("vScac")) { + List value = (List) entry.getValue(); + phd.setVScac(value); + } + if (entry.getKey().equalsIgnoreCase("vPeak")) { + List value = (List) entry.getValue(); + phd.setVPeak(value); + } + if (entry.getKey().equalsIgnoreCase("baseCtrls")) { + BaseControls value = JSON.parseObject(JSON.toJSONString(entry.getValue()), BaseControls.class); + phd.setBaseCtrls(value); + } + if (entry.getKey().equalsIgnoreCase("usedEner")) { + String value = (String) entry.getValue(); + phd.setUsedEner(value); + } + if (entry.getKey().equalsIgnoreCase("usedEnerKD")) { + GEnergyBlock value = JSON.parseObject(JSON.toJSONString(entry.getValue()), GEnergyBlock.class); + phd.setUsedEnerKD(value); + } + if (entry.getKey().equalsIgnoreCase("usedEnerPara")) { + ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class); + phd.setUsedEnerPara(value); + } + if (entry.getKey().equalsIgnoreCase("usedReso")) { + String value = (String) entry.getValue(); + phd.setUsedReso(value); + } + if (entry.getKey().equalsIgnoreCase("usedResoKD")) { + GResolutionBlock value = JSON.parseObject(JSON.toJSONString(entry.getValue()), GResolutionBlock.class); + phd.setUsedResoKD(value); + } + if (entry.getKey().equalsIgnoreCase("usedResoPara")) { + ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class); + phd.setUsedResoPara(value); + } + if (entry.getKey().equalsIgnoreCase("usedEffi")) { + String value = (String) entry.getValue(); + phd.setUsedEffi(value); + } + if (entry.getKey().equalsIgnoreCase("usedEffiKD")) { + GEfficiencyBlock value = JSON.parseObject(JSON.toJSONString(entry.getValue()), GEfficiencyBlock.class); + phd.setUsedEffiKD(value); + } + if (entry.getKey().equalsIgnoreCase("usedEffiPara")) { + ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class); + phd.setUsedEffiPara(value); + } + if (entry.getKey().equalsIgnoreCase("usedTotE")) { + String value = (String) entry.getValue(); + phd.setUsedTotE(value); + } + if (entry.getKey().equalsIgnoreCase("usedTotEKD")) { + TotaleffBlock value = JSON.parseObject(JSON.toJSONString(entry.getValue()), TotaleffBlock.class); + phd.setUsedTotEKD(value); + } + if (entry.getKey().equalsIgnoreCase("usedTotEPara")) { + ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class); + phd.setUsedTotEPara(value); + } + } + BeanUtils.copyProperties(phd.getSetting(), phd.getUsedSetting()); + for (PeakInfo peak:phd.getVPeak()) { if (StringUtils.isBlank(peak.recoilBetaChan)) { peak.recoilBetaChan = "1"; @@ -1545,7 +1783,9 @@ public class GammaFileUtil { List old_ener = phd.getUsedEnerPara().getP(); List new_ener = phd.getMapEnerPara().get(phd.getNewEner()).getP(); - if(old_ener.size() != new_ener.size()) return 1; + if(old_ener.size() != new_ener.size()) { + return 1; + } for(int i=0; i 1E-6){ return 1; @@ -1554,7 +1794,9 @@ public class GammaFileUtil { List old_reso = phd.getUsedResoPara().getP(); List new_reso = phd.getMapResoPara().get(phd.getNewReso()).getP(); - if(old_reso.size() != new_reso.size()) return 1; + if(old_reso.size() != new_reso.size()) { + return 1; + } for(int i=0; i 1E-6){ return 1; @@ -1563,7 +1805,9 @@ public class GammaFileUtil { List old_effi = phd.getUsedEffiPara().getP(); List new_effi = phd.getMapEffiPara().get(phd.getNewEffi()).getP(); - if(old_effi.size() != new_effi.size()) return -1; + if(old_effi.size() != new_effi.size()) { + return -1; + } for(int i=0; i 1E-6){ return -1; @@ -2384,11 +2628,11 @@ public class GammaFileUtil { public String GetReportContent(PHDFile phd, boolean bLog) { GStoreMiddleProcessData middleData = new GStoreMiddleProcessData(); - this.GetInterMiddlData(phd, "", middleData); + GetInterMiddlData(phd, "", middleData); if(bLog) { - return this.GetLogContent(middleData); + return GetLogContent(middleData); } else { - return this.GetReportContent(middleData); + return GetReportContent(middleData); } } 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 82b23b0d..c7086096 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 @@ -53,6 +53,11 @@ public class GammaController { redisTemplate.convertAndSend(GlobalConstants.REDIS_TOPIC_NAME, params);; } + @GetMapping("testFun") + public Result testFun(String fileName,HttpServletRequest request){ + return gammaService.testFun(fileName, request); + } + @GetMapping("gammaByDB") public Result gammaByDB(Integer sampleId, String dbName, HttpServletRequest request){ return gammaService.gammaByDB(dbName, sampleId, request); @@ -243,6 +248,12 @@ public class GammaController { return gammaService.callDataEnergy(file, sampleFileName, width, currentText); } + @PutMapping("setCurrentEnergy") + @ApiOperation(value = "Energy Calibration页面set to current按钮", notes = "Energy Calibration页面set to current按钮") + public Result setCurrentEnergy(String fileName, String currentName) { + return gammaService.setCurrentEnergy(fileName, currentName); + } + @GetMapping("resolutionCalibration") @ApiOperation(value = "查看Resolution Calibration数据", notes = "查看Resolution Calibration数据") public Result resolutionCalibration(Integer sampleId, String fileName, String currentText, Double width) { @@ -273,6 +284,12 @@ public class GammaController { return gammaService.callDataResolution(file, sampleFileName, width, currentText); } + @PutMapping("setCurrentResolution") + @ApiOperation(value = "Resolution Calibration页面set to current按钮", notes = "Resolution Calibration页面set to current按钮") + public Result setCurrentResolution(String fileName, String currentName) { + return gammaService.setCurrentResolution(fileName, currentName); + } + @GetMapping("EfficiencyCalibration") @ApiOperation(value = "查看Efficiency Calibration数据", notes = "查看Efficiency Calibration数据") public Result EfficiencyCalibration(Integer sampleId, String fileName, String currentText, Double width) { @@ -303,6 +320,12 @@ public class GammaController { return gammaService.callDataEfficiency(file, sampleFileName, width, currentText); } + @PutMapping("setCurrentEfficiency") + @ApiOperation(value = "Efficiency Calibration页面set to current按钮", notes = "Efficiency Calibration页面set to current按钮") + public Result setCurrentEfficiency(String fileName, String currentName) { + return gammaService.setCurrentEfficiency(fileName, currentName); + } + @GetMapping("NuclideLibrary") @ApiOperation(value = "查看Nuclide Library页面数据", notes = "查看Nuclide Library页面数据") public Result NuclideLibrary(Integer sampleId, String fileName, String editEnergy, double err, String libraryName, String nuclideName, HttpServletRequest request) { 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 be498b4b..89058d3a 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 @@ -14,6 +14,8 @@ public interface IGammaService{ Result initValue(Integer sampleId, String dbName, HttpServletRequest request); + Result testFun(String fileName, HttpServletRequest request); + Result gammaByDB(String dbName, Integer sampleId, HttpServletRequest request); Result gammaByFile(String fileName, HttpServletRequest request); @@ -80,6 +82,8 @@ public interface IGammaService{ Result callDataEnergy(MultipartFile file, String sampleFileName, Double width, String currentText); + Result setCurrentEnergy(String fileName, String currentName); + Result resolutionCalibration(Integer sampleId, String fileName, String currentText, Double width); Result changeDataResolution(List m_vCurReso, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, Integer sampleId, String fileName, Double width); @@ -90,6 +94,8 @@ public interface IGammaService{ Result callDataResolution(MultipartFile file, String sampleFileName, Double width, String currentText); + Result setCurrentResolution(String fileName, String currentName); + Result EfficiencyCalibration(Integer sampleId, String fileName, String currentText, Double width); Result changeDataEfficiency(List m_vCurEffi, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, Integer funcId, Integer sampleId, String fileName, Double width); @@ -100,6 +106,8 @@ public interface IGammaService{ Result callDataEfficiency(MultipartFile file, String sampleFileName, Double width, String currentText); + Result setCurrentEfficiency(String fileName, String currentName); + Result NuclideLibrary(Integer sampleId, String fileName, String editEnergy, double err, String libraryName, String nuclideName, HttpServletRequest request); Result configUserLibrary(Integer sampleId, String fileName, 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 21cf147e..2f6cb178 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 @@ -153,12 +153,189 @@ public class GammaServiceImpl implements IGammaService { return result; } + @Override + public Result testFun(String fileName, HttpServletRequest request) { + Result result = new Result(); + Cache phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(fileName); + phd.setUserId("1"); + phd.setXmlFilePath(parameterFilePath); + if (Objects.isNull(phd)){ + result.error500("请先选择解析文件!"); + return result; + } + String userName = JwtUtil.getUserNameByToken(request); + //查询当前用户关联的核素信息 + List nuclides = new LinkedList<>(); + //从postgreSql中获取当前用户关注的核素信息 如果当前用户没有 则返回管理员的 + nuclides = defaultNuclideSpectrumService.findNuclidesByUserName(userName, phd.getHeader().getSystem_type().toUpperCase()); + if (CollectionUtils.isEmpty(nuclides)){ + nuclides = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase()); + } + Map nuclideLinesMap = gammaFileUtil.GetNuclideLines(nuclides); + //解析获取临时文件信息 + + File tmpFile = gammaFileUtil.analyzeFile(StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName, fileName); + ObjectMapper mapper = new ObjectMapper(); + try { + String phdStr = mapper.writeValueAsString(phd); + String mapLines = mapper.writeValueAsString(nuclideLinesMap); + String strValue = CalValuesHandler.analyseSpectrum(phdStr, mapLines, tmpFile.getAbsolutePath()); + Map parseMap = JSON.parseObject(strValue, Map.class); + for (Map.Entry entry:parseMap.entrySet()) { + if (entry.getKey().equalsIgnoreCase("bAnalyed")) { + boolean value = (boolean) entry.getValue(); + phd.setBAnalyed(value); + } + if (entry.getKey().equalsIgnoreCase("mapEnerPara")) { + Map value = (Map) entry.getValue(); + phd.setMapEnerPara(value); + } + if (entry.getKey().equalsIgnoreCase("mapResoPara")) { + Map value = (Map) entry.getValue(); + phd.setMapResoPara(value); + } + if (entry.getKey().equalsIgnoreCase("mapEffiPara")) { + Map value = (Map) entry.getValue(); + phd.setMapEffiPara(value); + } + if (entry.getKey().equalsIgnoreCase("mapTotEPara")) { + Map value = (Map) entry.getValue(); + phd.setMapTotEPara(value); + } + if (entry.getKey().equalsIgnoreCase("para_stepRatio")) { + ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class); + phd.setPara_stepRatio(value); + } + if (entry.getKey().equalsIgnoreCase("para_tail")) { + ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class); + phd.setPara_tail(value); + } + if (entry.getKey().equalsIgnoreCase("para_tailAlpha")) { + ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class); + phd.setPara_tailAlpha(value); + } + if (entry.getKey().equalsIgnoreCase("para_tailRight")) { + ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class); + phd.setPara_tailRight(value); + } + if (entry.getKey().equalsIgnoreCase("para_tailRightAlpha")) { + ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class); + phd.setPara_tailRightAlpha(value); + } + if (entry.getKey().equalsIgnoreCase("newEner")) { + String value = (String) entry.getValue(); + phd.setNewEner(value); + } + if (entry.getKey().equalsIgnoreCase("mapEnerKD")) { + Map value = (Map) entry.getValue(); + phd.setMapEnerKD(value); + } + if (entry.getKey().equalsIgnoreCase("mapResoKD")) { + Map value = (Map) entry.getValue(); + phd.setMapResoKD(value); + } + if (entry.getKey().equalsIgnoreCase("vEnergy")) { + List value = (List) entry.getValue(); + phd.setVEnergy(value); + } + if (entry.getKey().equalsIgnoreCase("vBase")) { + List value = (List) entry.getValue(); + phd.setVBase(value); + } + if (entry.getKey().equalsIgnoreCase("vLc")) { + List value = (List) entry.getValue(); + phd.setVLc(value); + } + if (entry.getKey().equalsIgnoreCase("vScac")) { + List value = (List) entry.getValue(); + phd.setVScac(value); + } + if (entry.getKey().equalsIgnoreCase("vPeak")) { + List value = (List) entry.getValue(); + phd.setVPeak(value); + } + if (entry.getKey().equalsIgnoreCase("baseCtrls")) { + BaseControls value = JSON.parseObject(JSON.toJSONString(entry.getValue()), BaseControls.class); + phd.setBaseCtrls(value); + } + if (entry.getKey().equalsIgnoreCase("usedEner")) { + String value = (String) entry.getValue(); + phd.setUsedEner(value); + } + if (entry.getKey().equalsIgnoreCase("usedEnerKD")) { + GEnergyBlock value = JSON.parseObject(JSON.toJSONString(entry.getValue()), GEnergyBlock.class); + phd.setUsedEnerKD(value); + } + if (entry.getKey().equalsIgnoreCase("usedEnerPara")) { + ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class); + phd.setUsedEnerPara(value); + } + if (entry.getKey().equalsIgnoreCase("usedReso")) { + String value = (String) entry.getValue(); + phd.setUsedReso(value); + } + if (entry.getKey().equalsIgnoreCase("usedResoKD")) { + GResolutionBlock value = JSON.parseObject(JSON.toJSONString(entry.getValue()), GResolutionBlock.class); + phd.setUsedResoKD(value); + } + if (entry.getKey().equalsIgnoreCase("usedResoPara")) { + ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class); + phd.setUsedResoPara(value); + } + if (entry.getKey().equalsIgnoreCase("usedEffi")) { + String value = (String) entry.getValue(); + phd.setUsedEffi(value); + } + if (entry.getKey().equalsIgnoreCase("usedEffiKD")) { + GEfficiencyBlock value = JSON.parseObject(JSON.toJSONString(entry.getValue()), GEfficiencyBlock.class); + phd.setUsedEffiKD(value); + } + if (entry.getKey().equalsIgnoreCase("usedEffiPara")) { + ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class); + phd.setUsedEffiPara(value); + } + if (entry.getKey().equalsIgnoreCase("usedTotE")) { + String value = (String) entry.getValue(); + phd.setUsedTotE(value); + } + if (entry.getKey().equalsIgnoreCase("usedTotEKD")) { + TotaleffBlock value = JSON.parseObject(JSON.toJSONString(entry.getValue()), TotaleffBlock.class); + phd.setUsedTotEKD(value); + } + if (entry.getKey().equalsIgnoreCase("usedTotEPara")) { + ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class); + phd.setUsedTotEPara(value); + } + } + BeanUtils.copyProperties(phd.getSetting(), phd.getUsedSetting()); + + for (PeakInfo peak:phd.getVPeak()) { + if (StringUtils.isBlank(peak.recoilBetaChan)) { + peak.recoilBetaChan = "1"; + } + if (StringUtils.isBlank(peak.recoilDeltaChan)) { + peak.recoilDeltaChan = "1"; + } + } + result.setResult(phd); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + result.setSuccess(true); + return result; + } + @Override public Result gammaByDB(String dbName, Integer sampleId, HttpServletRequest request) { Result result = new Result(); + //通过token获取用户名 String userName = JwtUtil.getUserNameByToken(request); + //声明一个接收最后返回结果的map Map map = new HashMap<>(); + //加载本地缓存信息 Cache phdCache = localCache.getPHDCache(); + //声明phd实体类 PHDFile phd = new PHDFile(); //读取文件内容 //根据sampleId获取sample文件路径 @@ -167,16 +344,21 @@ public class GammaServiceImpl implements IGammaService { result.error500("样品文件不存在!"); return result; } + //切割数据库存储的文件路径获取路径信息 String pathName = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH)); + //切割数据库存储的文件路径获取文件名称 String fileName = sampleFilePath.substring(sampleFilePath.lastIndexOf(StringPool.SLASH)+1); + //调用加载文件的方法 传入文件路径,文件名称,全局变量phd,响应结果result boolean flag = gammaFileUtil.loadFile(pathName, fileName, phd, result); + //如果文件加载失败 返回失败原因 if (!flag){ return result; } - //声明基础数组信息 + //加载phd数据所需的lc,scac,baseline数据 gammaFileUtil.SetBaseInfo(phd); - //从数据库中读取相关信息 + //从数据库中读取phd其他相关信息 boolean bRet = gammaFileUtil.getResultFromDB(dbName, userName, sampleId, phd, result); + //判断数据库信息是否读取正常 if (!bRet){ return result; } @@ -194,7 +376,9 @@ public class GammaServiceImpl implements IGammaService { map.put("live_time", String.format("%.2f", phd.getAcq().getAcquisition_live_time())); double deadTime = (phd.getAcq().getAcquisition_real_time() - phd.getAcq().getAcquisition_live_time()) / phd.getAcq().getAcquisition_real_time(); map.put("dead_time", String.format("%.2f", deadTime*100)); + // 更新页面折线图信息 gammaFileUtil.UpdateChart(phd, map, colorMap); + //将当前加载的phd信息加入到缓存中 文件名称作为缓存信息的key phdCache.put(fileName, phd); localCache.setPHDCache(phdCache); result.setSuccess(true); @@ -352,8 +536,6 @@ public class GammaServiceImpl implements IGammaService { phdSetting.setRiskLevelK(configureData.getRiskLevelK()); phdSetting.setRefTime_act(configureData.getRefTime_act()); phdSetting.setRefTime_conc(configureData.getRefTime_conc()); - phdCache.put(fileName, phd); - localCache.setPHDCache(phdCache); result.success("保存成功"); return result; } @@ -406,8 +588,6 @@ public class GammaServiceImpl implements IGammaService { result.setSuccess(true); result.setResult(map); } - phdCache.put(fileName, phd); - localCache.setPHDCache(phdCache); return result; } @@ -1486,6 +1666,24 @@ public class GammaServiceImpl implements IGammaService { return result; } + @Override + public Result setCurrentEnergy(String fileName, String currentName) { + Result result = new Result(); + Cache phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(fileName); + if (Objects.isNull(phd)){ + result.error500("请先选择解析文件!"); + return result; + } + if (StringUtils.isNotBlank(currentName)) { + phd.setNewEner(currentName); + } + phdCache.put(fileName, phd); + localCache.setPHDCache(phdCache); + result.success("修改成功"); + return result; + } + @Override public Result resolutionCalibration(Integer sampleId, String fileName, String currentText, Double width) { Result result = new Result(); @@ -1720,6 +1918,24 @@ public class GammaServiceImpl implements IGammaService { return result; } + @Override + public Result setCurrentResolution(String fileName, String currentName) { + Result result = new Result(); + Cache phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(fileName); + if (Objects.isNull(phd)){ + result.error500("请先选择解析文件!"); + return result; + } + if (StringUtils.isNotBlank(currentName)) { + phd.setNewReso(currentName); + } + phdCache.put(fileName, phd); + localCache.setPHDCache(phdCache); + result.success("修改成功"); + return result; + } + @Override public Result EfficiencyCalibration(Integer sampleId, String fileName, String currentText, Double width) { Result result = new Result(); @@ -1976,6 +2192,24 @@ public class GammaServiceImpl implements IGammaService { return result; } + @Override + public Result setCurrentEfficiency(String fileName, String currentName) { + Result result = new Result(); + Cache phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(fileName); + if (Objects.isNull(phd)){ + result.error500("请先选择解析文件!"); + return result; + } + if (StringUtils.isNotBlank(currentName)) { + phd.setNewEffi(currentName); + } + phdCache.put(fileName, phd); + localCache.setPHDCache(phdCache); + result.success("修改成功"); + return result; + } + @Override public Result NuclideLibrary(Integer sampleId, String fileName, String editEnergy, double err, String libraryName, String nuclideName, HttpServletRequest request) { Result result = new Result(); From 0ac2c77e27a7c6ddbb30c3bebe0983724b97a027 Mon Sep 17 00:00:00 2001 From: orgin Date: Mon, 25 Sep 2023 17:23:19 +0800 Subject: [PATCH 09/11] =?UTF-8?q?fix:=20gamma=20LC=20SCAC=20Baseline=20?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jeecg/common/util/GammaReportUtil.java | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 jeecg-boot-base-core/src/main/java/org/jeecg/common/util/GammaReportUtil.java diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/GammaReportUtil.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/GammaReportUtil.java new file mode 100644 index 00000000..76d6aba6 --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/GammaReportUtil.java @@ -0,0 +1,90 @@ +package org.jeecg.common.util; + +import org.jeecg.modules.entity.vo.BaseControls; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.PrintWriter; +import java.util.List; + +public class GammaReportUtil { + public static void writeBaseline(BaseControls baseCtrl, String path){ + // 创建文件 + File file = new File(path); + try { + // 创建PrintWriter对象 + PrintWriter out = new PrintWriter(file); + out.println("#AnalyseRange"); + String low = String.valueOf(baseCtrl.getRg_low()); + String high = String.valueOf(baseCtrl.getRg_high()); + out.printf("%" + (low.length() + 15) + "s", low); + out.printf("%" + (high.length() + 15) + "s", high); + + out.println("#XCtrl"); + format(baseCtrl.getXCtrl(), out); + + out.println("#YCtrl"); + format(baseCtrl.getYCtrl(), out); + + out.println("#YSlope"); + format(baseCtrl.getYSlope(), out); + + out.println("#Baseline"); + format(baseCtrl.getBaseline(), out); + + out.println("#StepCounts"); + format(baseCtrl.getStepCounts(), out); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + } + public static void writeSCAC(BaseControls baseCtrl, String path){ + // 创建文件 + File file = new File(path); + try { + // 创建PrintWriter对象 + PrintWriter out = new PrintWriter(file); + out.println("#AnalyseRange"); + String low = String.valueOf(baseCtrl.getRg_low()); + String high = String.valueOf(baseCtrl.getRg_high()); + out.printf("%" + (low.length() + 15) + "s", low); + out.printf("%" + (high.length() + 15) + "s", high); + + out.println("#XCtrl"); + format(baseCtrl.getXCtrl(), out); + + out.println("#YCtrl"); + format(baseCtrl.getYCtrl(), out); + + out.println("#YSlope"); + format(baseCtrl.getYSlope(), out); + + out.println("#Baseline"); + format(baseCtrl.getBaseline(), out); + + out.println("#StepCounts"); + format(baseCtrl.getStepCounts(), out); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + } + + private static void format(List baseline, PrintWriter out) { + // 每行的数量 + int numPerLine = 5; + int nBL = baseline.size(), nGroupBL = nBL / numPerLine * numPerLine; + // 计算每列数据中最长的字符串长度 + int[] columnWidths = new int[baseline.size()]; + for (int i = 0; i < baseline.size(); i++) { + columnWidths[i] = Math.max(columnWidths[i], baseline.get(i).toString().length()); + } + + for(int i = 1; i < nGroupBL; i++) + { + out.printf("%" + (columnWidths[i] + 15) + "s", baseline.get(i-1)); + if(i % numPerLine == 0){ + out.println(""); + } + } + } +} From 2845a41af76491d1215e1d9b25e912bdb0b0b75c Mon Sep 17 00:00:00 2001 From: panbaolin <123456> Date: Mon, 25 Sep 2023 18:44:51 +0800 Subject: [PATCH 10/11] =?UTF-8?q?fix:1.=E4=BF=AE=E6=94=B9B=E8=B0=B1?= =?UTF-8?q?=E5=88=86=E6=9E=90=E5=8A=9F=E8=83=BD=E4=B8=AD=E5=88=86=E6=9E=90?= =?UTF-8?q?=E7=BB=93=E6=9D=9F=E6=97=B6=E9=97=B4=E3=80=81=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E4=BF=A1=E6=81=AF=E6=B2=A1=E6=9C=89=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=E5=AD=98=E5=88=B0=E5=BA=93=E9=87=8C=E9=9D=A2=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/service/GardsAnalysesService.java | 7 ++ .../impl/GardsAnalysesServiceImpl.java | 18 +++++ .../modules/spectrum/ParsingProcessLog.java | 6 +- .../spectrum/S_D_Q_G_SpectrumHandler.java | 8 --- .../modules/spectrum/Sample_B_Analysis.java | 70 +++++++++++-------- .../modules/spectrum/SamplephdSpectrum.java | 7 +- 6 files changed, 73 insertions(+), 43 deletions(-) diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/GardsAnalysesService.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/GardsAnalysesService.java index 312a192b..d70ad140 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/GardsAnalysesService.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/GardsAnalysesService.java @@ -27,4 +27,11 @@ public interface GardsAnalysesService extends IService { public GardsAnalyses create(Integer sampleId, GardsSampleData detSampleData, GardsSampleData gasSampleData, Date beginDate, Date endDate, String logPath, String reportPath); Integer getIdAnalysis(Integer sampleId); + + /** + * 修改分析结束时间 + * @param idAnalysis + * @param endTime + */ + void updateAnalysesEndTime(Integer idAnalysis,Date endTime); } diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsAnalysesServiceImpl.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsAnalysesServiceImpl.java index 59b69f32..ef4ef3ab 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsAnalysesServiceImpl.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsAnalysesServiceImpl.java @@ -13,6 +13,7 @@ import org.jeecg.modules.mapper.GardsAnalysesMapper; import org.jeecg.modules.service.GardsAnalysesService; import org.springframework.stereotype.Service; import java.util.Date; +import java.util.Objects; /** * 存储谱数据分析的基本信息 @@ -66,4 +67,21 @@ public class GardsAnalysesServiceImpl extends ServiceImpl wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(GardsAnalyses::getIdAnalysis,idAnalysis); + final GardsAnalyses gardsAnalyses = this.getOne(wrapper); + if(Objects.nonNull(gardsAnalyses)){ + gardsAnalyses.setAnalysisEnd(endTime); + this.updateById(gardsAnalyses); + } + } } diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/ParsingProcessLog.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/ParsingProcessLog.java index 258a9464..627d3381 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/ParsingProcessLog.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/ParsingProcessLog.java @@ -781,10 +781,10 @@ public class ParsingProcessLog { private void saveLogToFTP(String log){ //保存日志文件到ftp final SpectrumPathProperties properties = spectrumHandler.spectrumServiceQuotes.getSpectrumPathProperties(); - spectrumHandler.logFilePath = spectrumHandler.getFileSavePath(); - spectrumHandler.logFileName = spectrumHandler.mailFile.getName().replace(spectrumHandler.currDataType.getSuffix(),SpectrumHandler.LOG_FILE_SUFFIX); + String logFilePath = properties.getLogPath()+StringConstant.SLASH+spectrumHandler.getFileSavePath(); + String logFileName = spectrumHandler.mailFile.getName().replace(DataType.SAMPLEPHD.getSuffix(),SpectrumHandler.LOG_FILE_SUFFIX); - spectrumHandler.ftpUtil.saveOrAppendFile(properties.getLogPath()+StringConstant.SLASH+spectrumHandler.logFilePath,spectrumHandler.logFileName,new ByteArrayInputStream(log.getBytes(StandardCharsets.UTF_8))); + spectrumHandler.ftpUtil.saveOrAppendFile(logFilePath,logFileName,new ByteArrayInputStream(log.getBytes(StandardCharsets.UTF_8))); } /** diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/S_D_Q_G_SpectrumHandler.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/S_D_Q_G_SpectrumHandler.java index 0fd305ef..6df53c2a 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/S_D_Q_G_SpectrumHandler.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/S_D_Q_G_SpectrumHandler.java @@ -52,14 +52,6 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{ * 基础数据 */ protected GardsSampleData sampleData; - /** - * 日志文件路径 - */ - protected String logFilePath; - /** - * 日志文件名称 - */ - protected String logFileName; /** * 流程日志对象 */ diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_B_Analysis.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_B_Analysis.java index 81b45857..bd7dee08 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_B_Analysis.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_B_Analysis.java @@ -75,6 +75,15 @@ public class Sample_B_Analysis implements BlockConstant { * gas谱PHD文件临时路径 */ private String gasTempFilePath; + /** + * SamplephdSpectrum类->saveFileToFtp()构造的能谱文件ftp保存路径 + * 可根据此路径构造log和arr保存路径 + */ + protected String ftpSavePath; + /** + * SamplephdSpectrum类->updateSpectrumFileName()构造的能谱文件名称 可根据此路径构造log和arr文件名称 + */ + protected String phdFileName; /** * 日志文件路径 */ @@ -111,6 +120,10 @@ public class Sample_B_Analysis implements BlockConstant { * 结束分析时间 */ protected Date endAnalysisTime; + /** + * 分析基础数据 + */ + protected GardsAnalyses analyses; /** * 流程日志对象 @@ -120,30 +133,32 @@ public class Sample_B_Analysis implements BlockConstant { public Sample_B_Analysis() { } - public Sample_B_Analysis(GardsSampleData sampleData, String sampleTempFilePath, SpectrumServiceQuotes spectrumServiceQuotes, - EnergySpectrumStruct sampleStruct, FTPUtils ftpUtil, String logFilePath, String logFileName,ParsingProcessLog parsingProcessLog){ - this.sampleData = sampleData; - this.sampleTempFilePath = sampleTempFilePath; - this.spectrumServiceQuotes = spectrumServiceQuotes; - this.sampleStruct = sampleStruct; - this.ftpUtil = ftpUtil; - this.logFilePath = logFilePath; - this.logFileName = logFileName; - this.parsingProcessLog = parsingProcessLog; + public Sample_B_Analysis(S_D_Q_G_SpectrumHandler spectrumHandler){ + this.sampleData = spectrumHandler.sampleData; + this.sampleTempFilePath = spectrumHandler.mailFile.getAbsolutePath(); + this.spectrumServiceQuotes = spectrumHandler.spectrumServiceQuotes; + this.sampleStruct = spectrumHandler.sourceData; + this.ftpUtil = spectrumHandler.ftpUtil; + this.parsingProcessLog = spectrumHandler.parsingProcessLog; + this.ftpSavePath = spectrumHandler.getFileSavePath(); + this.phdFileName = spectrumHandler.mailFile.getName(); + } /** * 执行解析过程 */ public void start() throws BAnalyseException { + //标记整个分析过程是否分析失败 + boolean analyseFail = false; try{ this.startAnalysisTime = new Date(); //声明分析日志对象 parsingProcessLog.setSample_B_Analysis(this); //查询det、gas数据(sampleId,inputFileName),sample数据在构造函数已经传过来 this.queryPHDFile(); - //构造报告文件存储路径及文件名称,日志文件存储路径及文件名称在原始库存储阶段已存在,已经传过来 - this.structureArrFilePath(); + //构造报告文件存储路径及文件名称、日志文件存储路径及文件名称 + this.structureLogAndArrFilePath(); //下载det和gas谱PHD文件,sample谱PHD文件位置在构造函数已经传过来 this.downloadPHDFile(); //传入sample、det和gas谱PHD文件调用dll进行分析 @@ -154,10 +169,15 @@ public class Sample_B_Analysis implements BlockConstant { Sample_B_Analysis.B_AnalysisReport report = new Sample_B_Analysis.B_AnalysisReport(); report.start(); }catch (Exception e){ + analyseFail = true; e.printStackTrace(); throw new BAnalyseException("Sample Analyse Error at "+DateUtils.formatDate(new Date(),"yyyy-MM-dd HH:mm:ss")); }finally { this.endAnalysisTime = new Date(); + //如果分析成功并且analyses对象不为空 + if(!analyseFail && Objects.nonNull(this.analyses)){ + spectrumServiceQuotes.getAnalysesService().updateAnalysesEndTime(this.analyses.getIdAnalysis(),this.endAnalysisTime); + } //删除下载的det和gas临时文件 this.deleteLocalTemporaryFile(); } @@ -168,7 +188,7 @@ public class Sample_B_Analysis implements BlockConstant { * @throws FileNotExistException */ private void queryPHDFile() throws FileNotExistException { - //查询det和gas能谱文件 + //查询det和gas能谱文 this.detSampleData = spectrumServiceQuotes.getSampleDataService().getSampleIdAndInputFileName(this.sampleStruct.detector_bk_measurement_id, DataTypeAbbr.DETBKPHD.getType()); this.gasSampleData = spectrumServiceQuotes.getSampleDataService().getSampleIdAndInputFileName(this.sampleStruct.gas_bk_measurement_id, DataTypeAbbr.GASBKPHD.getType()); @@ -184,27 +204,19 @@ public class Sample_B_Analysis implements BlockConstant { /** * 创建报告文件路径 */ - private void structureArrFilePath(){ - //处理此文件需要保存到ftp服务的路径 - //measurement_id切割后的字符数组 - String[] arr = this.sampleStruct.measurement_id.split(StringConstant.DASH); - //切割后第一个,元素是年,第二个是月 - final String[] yearMonth = arr[1].split(StringConstant.SLASH); + private void structureLogAndArrFilePath(){ final SpectrumPathProperties properties = this.spectrumServiceQuotes.getSpectrumPathProperties(); + //构造报告文件路径 StringBuilder ftpPath = new StringBuilder(); ftpPath.append(properties.getArrPath()); ftpPath.append(StringConstant.SLASH); - ftpPath.append(properties.getFilePathMap().get(this.sampleStruct.system_type)); - ftpPath.append(StringConstant.SLASH); - ftpPath.append(properties.getFilePathMap().get(this.sampleStruct.data_type)); - ftpPath.append(StringConstant.SLASH); - ftpPath.append(yearMonth[0]); - ftpPath.append(StringConstant.SLASH); - ftpPath.append(yearMonth[1]); + ftpPath.append(this.ftpSavePath); this.arrFilePath = ftpPath.toString(); String arrFileTail = ARR_FILE_NAME_TAIL+ARR_FILE_SUFFIX; - String sourceFileName = this.sampleData.getInputFileName().substring(this.sampleData.getInputFileName().lastIndexOf(StringConstant.SLASH)+1); - this.arrFileName = sourceFileName.replace(DataType.SAMPLEPHD.getSuffix(),arrFileTail); + this.arrFileName = this.phdFileName.replace(DataType.SAMPLEPHD.getSuffix(),arrFileTail); + //构造日志文件路径 + this.logFilePath = properties.getLogPath()+StringConstant.SLASH+this.ftpSavePath; + this.logFileName = this.phdFileName.replace(DataType.SAMPLEPHD.getSuffix(),SpectrumHandler.LOG_FILE_SUFFIX); } /** @@ -271,7 +283,7 @@ public class Sample_B_Analysis implements BlockConstant { final TransactionStatus transactionStatus = spectrumServiceQuotes.getTransactionManager().getTransaction(spectrumServiceQuotes.getTransactionDefinition()); try{ //存储基础数据 - final GardsAnalyses analyses = spectrumServiceQuotes.getAnalysesService().create(this.sampleData.getSampleId(),this.detSampleData, + this.analyses = spectrumServiceQuotes.getAnalysesService().create(this.sampleData.getSampleId(),this.detSampleData, this.gasSampleData,this.startAnalysisTime,this.endAnalysisTime,logFileRelativePath,arrFileRelativePath); //调用原始数据dll获取gas、det谱数据入库,sample已有数据直接入库 //存储sample谱B_Energy和G_Energy块数据 diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SamplephdSpectrum.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SamplephdSpectrum.java index 2f5b6ef1..4b88e7a3 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SamplephdSpectrum.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SamplephdSpectrum.java @@ -75,10 +75,11 @@ public class SamplephdSpectrum extends S_D_Q_G_SpectrumHandler{ */ protected void autoAnalysis() throws Exception { if(this.sourceData.system_type.equals(SystemType.BETA.getType())){ - Sample_B_Analysis bAnalysis = new Sample_B_Analysis(super.sampleData,super.mailFile.getAbsolutePath(), - super.spectrumServiceQuotes,super.sourceData,super.ftpUtil, - super.logFilePath,super.logFileName,super.parsingProcessLog); + Sample_B_Analysis bAnalysis = new Sample_B_Analysis(this); bAnalysis.start(); +// Sample_B_Analysis bAnalysis = new Sample_B_Analysis(super.sampleData,super.mailFile.getAbsolutePath(), +// super.spectrumServiceQuotes,super.sourceData,super.ftpUtil,super.parsingProcessLog); +// bAnalysis.start(); } // if (this.sourceData.system_type.equals(SystemType.GAMMA.getType())) { // Sample_G_Analysis sample_g_analysis = new Sample_G_Analysis(super.sourceData, super.spectrumServiceQuotes, super.sampleData); From fbd353ea39927abac1db0fa7e85ec5de0fa890f2 Mon Sep 17 00:00:00 2001 From: xiaoguangbin Date: Mon, 25 Sep 2023 19:00:37 +0800 Subject: [PATCH 11/11] =?UTF-8?q?fix=EF=BC=9Agamma=20=E7=94=9F=E6=88=90lc?= =?UTF-8?q?=20scac=20baseline=E5=B7=A5=E5=85=B7=E5=84=AA=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jeecg/common/util/GammaReportUtil.java | 57 +++++++++---------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/GammaReportUtil.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/GammaReportUtil.java index 76d6aba6..5b384d97 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/GammaReportUtil.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/GammaReportUtil.java @@ -6,9 +6,10 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.util.List; +import java.util.Objects; public class GammaReportUtil { - public static void writeBaseline(BaseControls baseCtrl, String path){ + public static void writeFile(BaseControls baseCtrl, String path){ // 创建文件 File file = new File(path); try { @@ -19,7 +20,7 @@ public class GammaReportUtil { String high = String.valueOf(baseCtrl.getRg_high()); out.printf("%" + (low.length() + 15) + "s", low); out.printf("%" + (high.length() + 15) + "s", high); - + out.println(""); out.println("#XCtrl"); format(baseCtrl.getXCtrl(), out); @@ -38,53 +39,49 @@ public class GammaReportUtil { e.printStackTrace(); } } - public static void writeSCAC(BaseControls baseCtrl, String path){ + public static void writeFile(List data, String fileType, String path){ // 创建文件 File file = new File(path); try { // 创建PrintWriter对象 PrintWriter out = new PrintWriter(file); - out.println("#AnalyseRange"); - String low = String.valueOf(baseCtrl.getRg_low()); - String high = String.valueOf(baseCtrl.getRg_high()); - out.printf("%" + (low.length() + 15) + "s", low); - out.printf("%" + (high.length() + 15) + "s", high); + out.println("#" + fileType); + out.printf("%" + (String.valueOf(data.size()).length() + 15) + "s", data.size() + "\n"); + format(data, out); - out.println("#XCtrl"); - format(baseCtrl.getXCtrl(), out); - - out.println("#YCtrl"); - format(baseCtrl.getYCtrl(), out); - - out.println("#YSlope"); - format(baseCtrl.getYSlope(), out); - - out.println("#Baseline"); - format(baseCtrl.getBaseline(), out); - - out.println("#StepCounts"); - format(baseCtrl.getStepCounts(), out); } catch (FileNotFoundException e) { e.printStackTrace(); } } - private static void format(List baseline, PrintWriter out) { + private static void format(List data, PrintWriter out) { // 每行的数量 int numPerLine = 5; - int nBL = baseline.size(), nGroupBL = nBL / numPerLine * numPerLine; + int i,n = data.size(), nGroupBL = n / numPerLine * numPerLine; // 计算每列数据中最长的字符串长度 - int[] columnWidths = new int[baseline.size()]; - for (int i = 0; i < baseline.size(); i++) { - columnWidths[i] = Math.max(columnWidths[i], baseline.get(i).toString().length()); + int[] columnWidths = new int[data.size()]; + for (i = 0; i < data.size(); i++) { + String col = Objects.isNull(data.get(i)) ? "" : String.valueOf(data.get(i)); + columnWidths[i] = Math.max(columnWidths[i], col.length()); } - for(int i = 1; i < nGroupBL; i++) + out.printf("%" + (String.valueOf(data.size()).length() + 15) + "s", data.size() + "\n"); + + for(i = 0; i < nGroupBL; i++) { - out.printf("%" + (columnWidths[i] + 15) + "s", baseline.get(i-1)); - if(i % numPerLine == 0){ + String col = Objects.isNull(data.get(i)) ? "nan" : String.valueOf(data.get(i)); + out.printf("%" + (columnWidths[i] + 15) + "s", col); + if((i+1) % numPerLine == 0) { out.println(""); } } + if(i < n) + { + for(; i