From 89d24abd351d3be272a40e6cbf68e501b004b672 Mon Sep 17 00:00:00 2001 From: panbaolin <123456> Date: Wed, 20 Sep 2023 14:42:25 +0800 Subject: [PATCH 1/5] =?UTF-8?q?fix:1.=E4=BF=AE=E6=94=B9=E4=BB=8Efilesource?= =?UTF-8?q?=E8=B7=91=E6=96=87=E4=BB=B6=E7=94=9F=E6=88=90=E6=8A=A5=E5=91=8A?= =?UTF-8?q?=E6=98=AF=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 --- .../modules/FileSourceHandleManager.java | 2 - .../jeecg/modules/UndealHandleManager.java | 2 - .../modules/spectrum/DetbkphdSpectrum.java | 8 +- .../modules/spectrum/GasbkphdSpectrum.java | 8 +- .../modules/spectrum/ParsingProcessLog.java | 233 ++++++++++++++++++ .../jeecg/modules/spectrum/QcphdSpectrum.java | 8 +- .../spectrum/S_D_Q_G_SpectrumHandler.java | 88 +++---- .../modules/spectrum/Sample_B_Analysis.java | 15 +- .../modules/spectrum/SamplephdSpectrum.java | 9 +- .../modules/spectrum/SpectrumHandler.java | 2 +- .../jeecg/JeecgAutoProcessApplication.java | 2 +- 11 files changed, 304 insertions(+), 73 deletions(-) create mode 100644 jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/ParsingProcessLog.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 158662b3..16f76716 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 @@ -68,7 +68,6 @@ public class FileSourceHandleManager { @Override public void run() { for(;;){ - System.out.println("222222222222222222222222222222222222222222222222222222222222222222222222222222222"); long start = System.currentTimeMillis(); FTPUtils ftpUtil = null; try { @@ -143,7 +142,6 @@ public class FileSourceHandleManager { @Override public void run() { try { - System.out.println("4444444444444444444444444444444444444444444444444444444444444444444444444444444444"); //初始化FTP客户端对象 final FTPProperties ftpProperties = spectrumServiceQuotes.getFtpProperties(); this.ftpUtil = new FTPUtils(ftpProperties.getHost(),ftpProperties.getPort(),ftpProperties.getUserName(), diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/UndealHandleManager.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/UndealHandleManager.java index d7569021..e68feef1 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/UndealHandleManager.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/UndealHandleManager.java @@ -63,7 +63,6 @@ public class UndealHandleManager { @Override public void run() { for(;;){ - System.out.println("1111111111111111111111111111111111111111111111111111111111111111111111111111111111"); long start = System.currentTimeMillis(); FTPUtils ftpUtil = null; try { @@ -135,7 +134,6 @@ public class UndealHandleManager { @Override public void run() { try { - System.out.println("33333333333333333333333333333333333333333333333333333333333333333333333333333333333"); //初始化FTP客户端对象 final FTPProperties ftpProperties = spectrumServiceQuotes.getFtpProperties(); this.ftpUtil = new FTPUtils(ftpProperties.getHost(),ftpProperties.getPort(),ftpProperties.getUserName(), diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/DetbkphdSpectrum.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/DetbkphdSpectrum.java index 19ae7192..f449df81 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/DetbkphdSpectrum.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/DetbkphdSpectrum.java @@ -39,13 +39,17 @@ public class DetbkphdSpectrum extends S_D_Q_G_SpectrumHandler{ super.saveFileToFtp(); //结构体数据入库 super.handlerOriginalData(); - //把流程日志写入ftp日志文件 - super.saveLogToFtp(); + //处理流程日志 + super.handleProcessLog(); }catch (Exception e){ + //异常结束日志 + super.exceptionEndLog(e); //处理解析失败的文件,上传到ftp->undeal目录 super.handleParseingFailFile(); throw e; }finally { + //结束流程日志 + super.storageProcessLogEnd(); //删除本地临时文件 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 0ca37ccc..e975fc03 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 @@ -40,13 +40,17 @@ public class GasbkphdSpectrum extends S_D_Q_G_SpectrumHandler{ super.saveFileToFtp(); //结构体数据入库 super.handlerOriginalData(); - //把流程日志写入ftp日志文件 - super.saveLogToFtp(); + //处理流程日志 + super.handleProcessLog(); }catch (Exception e){ + //异常结束日志 + super.exceptionEndLog(e); //处理解析失败的文件,上传到ftp->undeal目录 super.handleParseingFailFile(); throw e; }finally { + //结束流程日志 + super.storageProcessLogEnd(); //删除本地临时文件 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 new file mode 100644 index 00000000..3ba08fe8 --- /dev/null +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/ParsingProcessLog.java @@ -0,0 +1,233 @@ +package org.jeecg.modules.spectrum; + +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.SampleStatus; +import java.io.ByteArrayInputStream; +import java.nio.charset.StandardCharsets; + +/** + * B谱邮件解析流程日志 + */ +public class ParsingProcessLog { + + /** + * 日志内容 + */ + private StringBuilder log = new StringBuilder(); + /** + * 日志存储结束标记 + */ + private boolean logStoreEndFlag = false; + /** + * 日志分析结束标记 + */ + private boolean logAnalyseEndFlag = false; + /** + * 能谱处理父类 + */ + @Setter + private S_D_Q_G_SpectrumHandler spectrumHandler; + /** + * 能谱分析类 + */ + @Setter + private Sample_B_Analysis sample_B_Analysis; + /** + * 解析过程日志对象 + */ + private StorageProcessLog processLog; + + /** + * 存储过程日志处理 + */ + 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 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"; + private static final String DETECTOR_ID = "Detector ID:%s"; + private static final String STATION_ID = "Station ID:%s"; + private static final String SAMPLE_ID = "Sample ID:%s"; + private static final String INSTANCE_STATUS = "Instance status successfully set to:%s....."; + private static final String WRITE_INTO_SUCCESS = "%s Write Data into Database Successfully at %s %s"; + private static final String FILE_REPEAT = "File: %s repeat"; + private static final String WRITE_INTO_ERROR = "%s Write Data into Database Error at %s %s"; + + /** + * 开始处理存储过程日志 + */ + private void start(){ + //获取数据源属性 + 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)); + } + + /** + * 文件重复结束日志 + */ + 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)); + } + + /** + * 正常结束 + */ + 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)); + } + } + + /** + * 分析过程日志 + */ + 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 void start(){ + final String anlyseResultsBegin = "%s Sample Analyse Beginning at %s %s"; + 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)); + } + + private void setDetAndGasIdLog(){ + final String titleId = "%s Get DetaId and GasId %s"; + log.append(titleFormat(titleId,40,StringConstant.DOT,StringConstant.DOT)); + + } + } + + /** + * 开始存储流程日志 + * @return + */ + protected void storageProcessLogStart(){ + this.processLog = new StorageProcessLog(); + this.processLog.start(); + } + + /** + * 结束存储流程日志 + */ + protected void storageProcessLogEnd(){ + if(this.logStoreEndFlag == false){ + this.processLog.end(); + this.logStoreEndFlag = true; + this.saveLogToFTP(); + } + } + + /** + * 文件重复异常结束存储流程日志 + */ + protected void endOfFileRepeat(){ + if(this.logStoreEndFlag == false){ + this.processLog.endOfFileRepeat(); + this.logStoreEndFlag = true; + this.saveLogToFTP(); + } + } + + /** + * 保存日志到ftp + */ + private void saveLogToFTP(){ + //保存日志文件到ftp + final SpectrumPathProperties properties = spectrumHandler.spectrumServiceQuotes.getSpectrumPathProperties(); + spectrumHandler.logFilePath = spectrumHandler.getFileSavePath(); + spectrumHandler.logFileName = spectrumHandler.mailFile.getName().replace(spectrumHandler.currDataType.getSuffix(),SpectrumHandler.LOG_FILE_SUFFIX); + + spectrumHandler.ftpUtil.saveOrAppendFile(properties.getLogPath()+StringConstant.SLASH+spectrumHandler.logFilePath,spectrumHandler.logFileName,new ByteArrayInputStream(log.toString().getBytes(StandardCharsets.UTF_8))); + } + + public static void main(String[] args) { + ParsingProcessLog s = new ParsingProcessLog(); + s.storageProcessLogStart(); + s.endOfFileRepeat(); + System.out.println(s.log.toString()); + } + + /** + * 行日志格式化 + * @param source 需要格式化的字符串 + * @param symbolNum 格式化的符号数量 + * @param args 格式化替换参数数组 + * @return + */ + private String titleFormat(String source, Integer symbolNum, String... args){ + StringBuilder firstParam = new StringBuilder(); + for (int i=0;iundeal目录 super.handleParseingFailFile(); throw e; }finally { + //结束流程日志 + super.storageProcessLogEnd(); //删除本地临时文件 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 dd98488a..6471f1fc 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 @@ -7,7 +7,6 @@ import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.util.Strings; import org.jeecg.common.constant.StringConstant; import org.jeecg.common.properties.SpectrumPathProperties; -import org.jeecg.common.util.DateUtils; import org.jeecg.modules.base.entity.original.GardsSampleData; import org.jeecg.modules.base.enums.DataType; import org.jeecg.modules.config.datasource.DataSourceSwitcher; @@ -20,15 +19,12 @@ import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct; import org.jeecg.modules.service.ISpectrumBlockService; import org.springframework.boot.system.ApplicationHome; import org.springframework.transaction.TransactionStatus; - import java.io.*; import java.math.BigDecimal; import java.math.RoundingMode; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.time.LocalDate; import java.util.Date; import java.util.List; import java.util.Objects; @@ -46,11 +42,11 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{ /** * 开始存库时间 */ - private Date startIntoDatabaseTime = null; + protected Date startIntoDatabaseTime = null; /** * 结束存库时间 */ - private Date endIntoDatabaseTime = null; + protected Date endIntoDatabaseTime = null; /** * 基础数据 */ @@ -63,6 +59,10 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{ * 日志文件名称 */ protected String logFileName; + /** + * 流程日志对象 + */ + protected ParsingProcessLog parsingProcessLog; /** * 前置检查 @@ -121,7 +121,7 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{ * 获取文件保存路径 * @return */ - private String getFileSavePath(){ + protected String getFileSavePath(){ //处理此文件需要保存到ftp服务的路径 //measurement_id切割后的字符数组 String[] arr = this.sourceData.measurement_id.split(StringConstant.DASH); @@ -211,8 +211,7 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{ if(Objects.nonNull(query)){ this.sampleData = query; this.endIntoDatabaseTime = new Date(); - log.warn("{} file data has been stored",super.mailFile.getName()); - return; + throw new FileRepeatException("file repeat"); } DataSourceSwitcher.switchToOracle(); final TransactionStatus transactionStatus = spectrumServiceQuotes.getTransactionManager().getTransaction(spectrumServiceQuotes.getTransactionDefinition()); @@ -238,49 +237,11 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{ } } - /** - * 把流程日志写入ftp日志文件 - * @throws Exception - */ - @Override - protected void saveLogToFtp() throws FileNotFoundException { - //获取数据源属性 - final String oraUsername = spectrumServiceQuotes.getOraDataSourceProperties().getUsername(); - final String oraUrl = spectrumServiceQuotes.getOraDataSourceProperties().getUrl(); - //组装日志文件内容 - StringBuilder logContent = new StringBuilder(); - logContent.append("-------------------------- Write Data into Database at ").append(DateUtils.formatDate(this.startIntoDatabaseTime,"yyyy-MM-dd HH:mm:ss")).append(" ---------------------------"); - logContent.append(System.lineSeparator()).append(System.lineSeparator()); - logContent.append("ApplicationPath:").append(this.getProjectAbsolutePath()).append(",").append("ApplicationName:").append(this.getProjectName()).append(",started by RNAUTO at ").append(this.startIntoDatabaseTime); - logContent.append(System.lineSeparator()).append(System.lineSeparator()); - logContent.append("Successfully connected to database,source:").append(oraUrl.substring(oraUrl.lastIndexOf(":")+1)).append(",user=").append(oraUsername); - logContent.append(System.lineSeparator()).append(System.lineSeparator()); - logContent.append("SourceFile:").append(super.mailFile.getAbsolutePath()); - logContent.append(System.lineSeparator()); - logContent.append("StandardFile:").append(spectrumServiceQuotes.getFtpProperties().getFtpRootPath()).append(StringConstant.SLASH).append(super.ftpSavePath); - logContent.append(System.lineSeparator()).append(System.lineSeparator()); - logContent.append("Detector ID:").append(this.sampleData.getDetectorId()); - logContent.append(System.lineSeparator()); - logContent.append("Station ID:").append(this.sampleData.getStationId()); - logContent.append(System.lineSeparator()); - logContent.append("Sample ID:").append(this.sampleData.getSampleId()); - logContent.append(System.lineSeparator()).append(System.lineSeparator()); - logContent.append("Instance status successfully set to:").append(this.sampleData.getStatus()).append("....."); - logContent.append(System.lineSeparator()).append(System.lineSeparator()); - logContent.append("------------------- ").append("Write Data into Database Successfully at ").append(DateUtils.formatDate(this.endIntoDatabaseTime,"yyyy-MM-dd HH:mm:ss")).append(" --------------------"); - //保存日志文件到ftp - final SpectrumPathProperties properties = this.spectrumServiceQuotes.getSpectrumPathProperties(); - this.logFilePath = this.getFileSavePath(); - this.logFileName = super.mailFile.getName().replace(this.currDataType.getSuffix(),LOG_FILE_SUFFIX); - - super.ftpUtil.saveOrAppendFile(properties.getLogPath()+StringConstant.SLASH+logFilePath,logFileName,new ByteArrayInputStream(logContent.toString().getBytes(StandardCharsets.UTF_8))); - } - /** * 获取项目绝对路径 * @return */ - private String getProjectAbsolutePath(){ + protected String getProjectAbsolutePath(){ ApplicationHome applicationHome = new ApplicationHome(); return applicationHome.getDir().getAbsolutePath(); } @@ -289,7 +250,7 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{ * 获取项目名称 * @return */ - private String getProjectName(){ + protected String getProjectName(){ ApplicationHome applicationHome = new ApplicationHome(); File[] files = applicationHome.getDir().listFiles(new FileFilter() { @Override @@ -307,4 +268,33 @@ 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 3714dc9f..f4aed486 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 @@ -2,10 +2,8 @@ package org.jeecg.modules.spectrum; import cn.hutool.core.io.FileUtil; import com.google.common.collect.Lists; -import io.swagger.models.auth.In; import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.FileUtils; -import org.apache.commons.lang3.RandomUtils; import org.apache.commons.lang3.StringUtils; import org.jeecg.common.constant.StringConstant; import org.jeecg.common.properties.SpectrumPathProperties; @@ -27,10 +25,7 @@ import org.jeecg.modules.service.BlockConstant; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.transaction.TransactionStatus; - import java.io.*; -import java.nio.file.Files; -import java.time.LocalDate; import java.util.*; import java.util.stream.Collectors; @@ -120,11 +115,11 @@ public class Sample_B_Analysis implements BlockConstant { /** * 开始分析时间 */ - private Date startAnalysisTime; + protected Date startAnalysisTime; /** * 结束分析时间 */ - private Date endAnalysisTime; + protected Date endAnalysisTime; public Sample_B_Analysis() { } @@ -270,6 +265,8 @@ public class Sample_B_Analysis implements BlockConstant { if(flag){ 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()); } /** @@ -295,11 +292,9 @@ public class Sample_B_Analysis implements BlockConstant { spectrumServiceQuotes.getGardsCalibrationPairsService().createB_EnergyRecord(sampleData.getSampleId(),analyses.getIdAnalysis(),this.sampleStruct); spectrumServiceQuotes.getGardsCalibrationPairsService().createG_EnergyRecord(sampleData.getSampleId(),analyses.getIdAnalysis(),this.sampleStruct); //存储det谱B_Energy和G_Energy块数据 - this.detStruct = EnergySpectrumHandler.getSourceData(detSampleData.getInputFileName()); spectrumServiceQuotes.getGardsCalibrationPairsService().createB_EnergyRecord(detSampleData.getSampleId(),analyses.getIdAnalysis(),this.detStruct); spectrumServiceQuotes.getGardsCalibrationPairsService().createG_EnergyRecord(detSampleData.getSampleId(),analyses.getIdAnalysis(),this.detStruct); //存储gas谱B_Energy和G_Energy块数据 - this.gasStruct = EnergySpectrumHandler.getSourceData(gasSampleData.getInputFileName()); spectrumServiceQuotes.getGardsCalibrationPairsService().createB_EnergyRecord(gasSampleData.getSampleId(),analyses.getIdAnalysis(),this.gasStruct); spectrumServiceQuotes.getGardsCalibrationPairsService().createG_EnergyRecord(gasSampleData.getSampleId(),analyses.getIdAnalysis(),this.gasStruct); @@ -602,6 +597,8 @@ public class Sample_B_Analysis implements BlockConstant { List roi_net_count_err = analyseResult.ROI_net_coutns_err; 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 netCount = Lists.newArrayList(); String flag = " +/- "; 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 b9ab6712..6c600139 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 @@ -1,7 +1,6 @@ package org.jeecg.modules.spectrum; import org.jeecg.modules.base.enums.DataType; -import org.jeecg.modules.base.enums.SampleStatus; import org.jeecg.modules.base.enums.SystemType; /** @@ -40,15 +39,19 @@ public class SamplephdSpectrum extends S_D_Q_G_SpectrumHandler{ super.saveFileToFtp(); //结构体数据入库 super.handlerOriginalData(); - //把原始库流程日志写入ftp日志文件 - super.saveLogToFtp(); + //处理流程日志 + super.handleProcessLog(); //进行B、G(P)谱分析 this.autoAnalysis(); }catch (Exception e){ + //异常结束日志 + super.exceptionEndLog(e); //处理解析失败的文件,上传到ftp->undeal目录 super.handleParseingFailFile(); throw e; }finally { + //结束流程日志 + super.storageProcessLogEnd(); //删除本地临时文件 super.deleteLocalTemporaryFile(); } diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SpectrumHandler.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SpectrumHandler.java index cd2d5aff..16d767fb 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SpectrumHandler.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SpectrumHandler.java @@ -100,7 +100,7 @@ public abstract class SpectrumHandler extends Chain{ /** * 把流程日志写入ftp日志文件 */ - protected abstract void saveLogToFtp() throws FileNotFoundException; + protected void saveLogToFtp() throws FileNotFoundException{}; /** * 打印当前能谱类型 diff --git a/jeecg-server-cloud/jeecg-auto-process-start/src/main/java/org/jeecg/JeecgAutoProcessApplication.java b/jeecg-server-cloud/jeecg-auto-process-start/src/main/java/org/jeecg/JeecgAutoProcessApplication.java index e0bb17f5..7150d3ec 100644 --- a/jeecg-server-cloud/jeecg-auto-process-start/src/main/java/org/jeecg/JeecgAutoProcessApplication.java +++ b/jeecg-server-cloud/jeecg-auto-process-start/src/main/java/org/jeecg/JeecgAutoProcessApplication.java @@ -55,7 +55,7 @@ public class JeecgAutoProcessApplication extends SpringBootServletInitializer im public void run(String... args) throws Exception { //调用dll System.loadLibrary("ReadPHDFile"); - autoProcessManager.start(); +// autoProcessManager.start(); undealHandleManager.start(); fileSourceHandleManager.start(); } From 59d063d41533367cb4fd031370a9e6fa4ff6e2fc Mon Sep 17 00:00:00 2001 From: qiaoqinzheng Date: Wed, 20 Sep 2023 16:21:48 +0800 Subject: [PATCH 2/5] =?UTF-8?q?GammaController=E5=8A=9F=E8=83=BDEnergy=20C?= =?UTF-8?q?alibration,Resolution=20Calibration,=20Efficiency=20Calibration?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E6=96=B0=E5=A2=9Ewidth=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E8=AE=A1=E7=AE=97=20GammaController=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=AF=BC=E5=85=A5=E6=9C=AC=E5=9C=B0=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=B4=E6=97=B6=E5=8A=A0=E8=BD=BDEnergy=20Calibration,Resolu?= =?UTF-8?q?tion=20Calibration,=20Efficiency=20Calibration=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jeecg/common/util/GammaFileUtil.java | 154 +++++++-- .../modules/controller/GammaController.java | 49 ++- .../jeecg/modules/entity/vo/ChangeData.java | 3 +- .../jeecg/modules/service/IGammaService.java | 24 +- .../service/impl/GammaServiceImpl.java | 312 ++++++++++++++++-- 5 files changed, 464 insertions(+), 78 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 18febbd2..8bfcbb30 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 @@ -1502,9 +1502,9 @@ public class GammaFileUtil { NuclidesIdent(phd, nuclideLinesMap); RunQC(phd); String Warning = "Finish three tasks:\n"+ - "\t1.Update efficiencies of all peaks;\n"+ - "\t2.Identify nuclides again;\n"+ - "\t3.Test QC again."; + "\t1.Update efficiencies of all peaks;\n"+ + "\t2.Identify nuclides again;\n"+ + "\t3.Test QC again."; } else { if(bSingle) { // AnalyseFlowChart flow_dlg(this); @@ -2028,7 +2028,7 @@ public class GammaFileUtil { return equation; } - public void UpdateChartEnergy(List m_vCurEnergy, ParameterInfo m_curParam, List m_vCurCentroid, PHDFile phd, Map map) { + public void UpdateChartEnergy(List m_vCurEnergy, ParameterInfo m_curParam, List m_vCurCentroid, PHDFile phd, Double width, Map map) { System.loadLibrary("GammaAnaly"); int num = m_vCurEnergy.size(); if(num < 1){ @@ -2044,7 +2044,7 @@ public class GammaFileUtil { List vChan = new LinkedList<>(); double MaxChan = Double.valueOf(phd.getSpec().getNum_g_channel()); double d = 1; - double dStep = MaxChan / 30 * 2; + double dStep = MaxChan / width * 2; while(d < MaxChan) { vChan.add(d); d+= dStep; @@ -2093,7 +2093,7 @@ public class GammaFileUtil { return equation; } - public void UpdateChartResolution(List m_vCurEnergy, ParameterInfo m_curParam, List m_vCurReso, PHDFile phd, Map map) { + public void UpdateChartResolution(List m_vCurEnergy, ParameterInfo m_curParam, List m_vCurReso, PHDFile phd, Double width, Map map) { System.loadLibrary("GammaAnaly"); int num = m_vCurEnergy.size(); if(num < 1) return; @@ -2111,7 +2111,7 @@ public class GammaFileUtil { List vEner = CalValuesHandler.calFcnEval(vChan, phd.getUsedEnerPara().getP()).counts; double d = vEner.get(0), maxE = vEner.get(1); - double dStep = maxE / 30 * 2; + double dStep = maxE / width * 2; vEner.remove(vEner.size()-1); while(d < maxE) { @@ -2226,7 +2226,7 @@ public class GammaFileUtil { return equation; } - public void UpdateChartEfficiency(List m_vCurEnergy, ParameterInfo m_curParam, List m_vCurEffi, PHDFile phd, Map map) { + public void UpdateChartEfficiency(List m_vCurEnergy, ParameterInfo m_curParam, List m_vCurEffi, PHDFile phd, Double width, Map map) { System.loadLibrary("GammaAnaly"); int num = m_vCurEnergy.size(); if(num < 1) return; @@ -2245,7 +2245,7 @@ public class GammaFileUtil { List vEner = CalValuesHandler.calFcnEval(vChan, phd.getUsedEnerPara().getP()).counts; double d = vEner.get(0); double maxE = vEner.get(1); - double dStep = maxE / 30 * 2; + double dStep = maxE / width * 2; vEner.remove(vEner.size()-1); while(d < maxE) { @@ -3510,7 +3510,7 @@ public class GammaFileUtil { // #Acquisition spectrum.append("#Acquisition\r\n"); spectrum.append(phd.getAcq().getAcquisition_start_date()+StringPool.SPACE+phd.getAcq().getAcquisition_start_time()+ - StringPool.SPACE+RightFill(String.format("%.2f", phd.getAcq().getAcquisition_real_time()), 14)+ + StringPool.SPACE+RightFill(String.format("%.2f", phd.getAcq().getAcquisition_real_time()), 14)+ StringPool.SPACE+RightFill(String.format("%.2f", phd.getAcq().getAcquisition_live_time()), 14)+"\r\n"); // #Processing @@ -3536,15 +3536,15 @@ public class GammaFileUtil { int fieldWidth = 12; for(int i=0; i loadCompareData(String compareFileName, String userName, long m_nCount, Result result) { + List m_vecCompare = new LinkedList<>(); + String compareFilePath = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; + //连接ftp + FTPClient ftpClient = ftpUtil.LoginFTP(); + if (Objects.isNull(ftpClient)){ + result.error500("ftp连接失败"); + return m_vecCompare; + } + InputStream inputStream = null; + //加载dll工具库 + System.loadLibrary("ReadPHDFile"); + try { + //切换被动模式 + ftpClient.enterLocalPassiveMode(); + ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); + // 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项 + ftpClient.setControlEncoding("UTF-8"); + ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); + ftpClient.changeWorkingDirectory(compareFilePath); + List ftpFiles = Arrays.asList(ftpClient.listFiles()); + ftpFiles = ftpFiles.stream().filter(item -> item.getName().equals(compareFileName)).collect(Collectors.toList()); + if (ftpFiles.size() == 0) { + result.error500("ftp获取文件数据失败"); + return m_vecCompare; + } + FTPFile ftpFile = ftpFiles.get(0); + if (Objects.nonNull(ftpFile)) { + inputStream = ftpClient.retrieveFileStream(ftpFile.getName()); + //声明一个临时文件 + File file = File.createTempFile("tmp", null); + //将ftp文件的输入流复制给临时文件 + FileUtils.copyInputStreamToFile(inputStream, file); + //读取文件信息 + EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(file.getAbsolutePath()); + //判断当前用来进行比较的文件的#g_Spectrum数量是否与原文件的大小一致 + if (struct.num_g_channel != m_nCount) { + result.error500("We can't compare two Spectrum files if their number of Counts are different!"); + return m_vecCompare; + } + m_vecCompare = struct.g_counts; + if (struct.g_begin_channel == 0) { + m_vecCompare.add(0L); + m_vecCompare.remove(0); + } + } + }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 m_vecCompare; + } + + public List CompareData(List m_vecCompare, long m_nCount, Map colorMap, List vEnergy){ + List datalist = new LinkedList<>(); + int size = m_vecCompare.size(); + if(size == m_nCount) { + ChartData data1 = new ChartData(); + data1.setName("Compare"); + data1.setGroup("channel"); + data1.setColor(colorMap.get("Color_Compare")); + // Compare two Spectrum in Channel + for(int i=0; i KorSumInput(CoeffData coeffData); - Result energyCalibration(Integer sampleId, String fileName, String currentText); + Result energyCalibration(Integer sampleId, String fileName, String currentText, Double width); - Result changeDataEnergy(List m_vCurCentroid, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, Integer sampleId, String fileName); + Result changeDataEnergy(List m_vCurCentroid, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, Integer sampleId, String fileName, Double width); Result applyDataEnergy(List m_vCurCentroid, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, String curCalName, Integer sampleId, String fileName); void saveDataEnergy(List m_vCurCentroid, List m_vCurEnergy, List m_vCurUncert, HttpServletResponse response); - Result resolutionCalibration(Integer sampleId, String fileName, String currentText); + Result callDataEnergy(MultipartFile file, String sampleFileName, Double width, String currentText); - Result changeDataResolution(List m_vCurReso, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, Integer sampleId, String fileName); + 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); Result applyDataResolution(List m_vCurReso, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, String curCalName, Integer sampleId, String fileName); void saveDataResolution(List m_vCurReso, List m_vCurEnergy, List m_vCurUncert, HttpServletResponse response); - Result EfficiencyCalibration(Integer sampleId, String fileName, String currentText); + Result callDataResolution(MultipartFile file, String sampleFileName, Double width, String currentText); - Result changeDataEfficiency(List m_vCurEffi, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, Integer funcId, Integer sampleId, String fileName); + 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); Result applyDataEfficiency(List m_vCurEffi, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, String curCalName, Integer sampleId, String fileName); void saveDataEfficiency(List m_vCurEffi, List m_vCurEnergy, List m_vCurUncert, Integer funId, HttpServletResponse response); + Result callDataEfficiency(MultipartFile file, String sampleFileName, Double width, String currentText); + Result NuclideLibrary(Integer sampleId, String fileName, String editEnergy, double err, String libraryName, String nuclideName, HttpServletRequest request); Result configUserLibrary(Integer sampleId, String fileName, HttpServletRequest request); @@ -136,6 +144,6 @@ public interface IGammaService{ Result updateColorConfig(ColorInfo colorInfo, HttpServletRequest request); - Result saveToDB(String fileName, String userName); + Result saveToDB(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 06107427..ff1cc027 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 @@ -11,6 +11,7 @@ import cn.hutool.core.util.StrUtil; import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.StringPool; +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; @@ -34,6 +35,7 @@ import org.jeecg.modules.service.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; @@ -225,6 +227,27 @@ public class GammaServiceImpl implements IGammaService { return result; } + @Override + public Result Compare(String fileName, String compareFileName, HttpServletRequest request) { + Result result = new Result(); + String userName = JwtUtil.getUserNameByToken(request); + //获取当前角色配置的颜色信息 + Map colorMap = sysUserColorService.initColor(userName); + //获取缓存的phd数据 + Cache phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(fileName); + long m_nCount = phd.getSpec().getNum_g_channel(); + List vEnergy = phd.getVEnergy(); + //获取Compare数据 + List m_vecCompare = gammaFileUtil.loadCompareData(compareFileName, userName, m_nCount, result); + if (CollectionUtils.isNotEmpty(m_vecCompare)) { + List chartDataList = gammaFileUtil.CompareData(m_vecCompare, m_nCount, colorMap, vEnergy); + result.setSuccess(true); + result.setResult(chartDataList); + } + return result; + } + @Override public Result configure(Integer sampleId, String fileName) { Result result = new Result(); @@ -301,8 +324,8 @@ public class GammaServiceImpl implements IGammaService { 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."; + "1. It has already Analyed.\n"+ + "2. You didn't change any setting or calibration."; result.error500(warning); } return result; @@ -1138,7 +1161,7 @@ public class GammaServiceImpl implements IGammaService { } @Override - public Result energyCalibration(Integer sampleId, String fileName, String currentText) { + public Result energyCalibration(Integer sampleId, String fileName, String currentText, Double width) { Result result = new Result(); Map map = new HashMap<>(); System.loadLibrary("GammaAnaly"); @@ -1181,7 +1204,7 @@ public class GammaServiceImpl implements IGammaService { map.put("table", energyDataList); String equation = gammaFileUtil.UpdateEquationEnergy(m_curParam); map.put("equation", equation); - gammaFileUtil.UpdateChartEnergy(m_vCurEnergy, m_curParam, m_vCurCentroid, phd, map); + gammaFileUtil.UpdateChartEnergy(m_vCurEnergy, m_curParam, m_vCurCentroid, phd, width, map); map.put("rg_low", phd.getBaseCtrls().getRg_low()); map.put("rg_high", phd.getBaseCtrls().getRg_high()); } @@ -1191,7 +1214,7 @@ public class GammaServiceImpl implements IGammaService { } @Override - public Result changeDataEnergy(List m_vCurCentroid, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, Integer sampleId, String fileName) { + public Result changeDataEnergy(List m_vCurCentroid, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, Integer sampleId, String fileName, Double width) { Result result = new Result(); Map map = new HashMap<>(); Cache phdCache = localCache.getPHDCache(); @@ -1200,13 +1223,13 @@ public class GammaServiceImpl implements IGammaService { result.error500("请先选择解析文件!"); return result; } - DataChangeEnergy(m_vCurCentroid, m_vCurEnergy, m_vCurUncert, m_curParam, phd, map); + DataChangeEnergy(m_vCurCentroid, m_vCurEnergy, m_vCurUncert, m_curParam, phd, width, map); result.setSuccess(true); result.setResult(map); return result; } - private void DataChangeEnergy(List m_vCurCentroid, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, PHDFile phd, Map map) { + private void DataChangeEnergy(List m_vCurCentroid, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, PHDFile phd, Double width, Map map) { System.loadLibrary("GammaAnaly"); if(m_vCurEnergy.size() < 1) { return; @@ -1249,7 +1272,7 @@ public class GammaServiceImpl implements IGammaService { map.put("table", energyDataList); String equation = gammaFileUtil.UpdateEquationEnergy(m_curParam); map.put("equation", equation); - gammaFileUtil.UpdateChartEnergy(m_vCurEnergy, m_curParam, m_vCurCentroid, phd, map); + gammaFileUtil.UpdateChartEnergy(m_vCurEnergy, m_curParam, m_vCurCentroid, phd, width, map); } @Override @@ -1283,7 +1306,7 @@ public class GammaServiceImpl implements IGammaService { StringBuffer strBuffer = new StringBuffer(); strBuffer.append("#g_Energy").append("\n"); for (int i=0; i phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(sampleFileName); + if (Objects.nonNull(file)) { + String fileName = file.getOriginalFilename(); + //从最后一个。切割文件名称 获取文件名称后缀 + String fileSuffix = fileName.substring(fileName.lastIndexOf(StringPool.DOT)); + if (fileSuffix.equalsIgnoreCase(".ent")) { + Map map = new HashMap<>(); + List m_vCurCentroid = new LinkedList<>(); + List m_vCurEnergy = new LinkedList<>(); + List m_vCurUncert = new LinkedList<>(); + try { + //创建临时文件 + File tmpFile = File.createTempFile("tmp", null); + //复制上传文件的输入流到临时文件 + FileUtils.copyInputStreamToFile(file.getInputStream() ,tmpFile); + //读取文件所有行 + List readLines = FileUtils.readLines(tmpFile, "UTF-8"); + //遍历文件行数据 + for (int i=0; i values = Arrays.asList(content.split("\t\t")); + m_vCurEnergy.add(Double.valueOf(values.get(0))); + m_vCurCentroid.add(Double.valueOf(values.get(1))); + m_vCurUncert.add(Double.valueOf(values.get(2))); + } + } + } + map.put("uncert", m_vCurUncert); + ParameterInfo m_curParam = new ParameterInfo(); + if (StringUtils.isNotBlank(currentText)) { + m_curParam = phd.getMapEnerPara().get(currentText); + } + map.put("param", m_curParam); + int num = m_vCurEnergy.size(); + if(num < 1){ + return result; + } + List vFit = CalValuesHandler.calFcnEval(m_vCurCentroid, m_curParam.getP()).counts; + List energyDataList = new LinkedList<>(); + for(int i=0; i map = new HashMap<>(); System.loadLibrary("GammaAnaly"); @@ -1350,7 +1447,7 @@ public class GammaServiceImpl implements IGammaService { map.put("table", resolutionDataList); String equation = gammaFileUtil.UpdateEquationResolution(m_curParam); map.put("equation", equation); - gammaFileUtil.UpdateChartResolution(m_vCurEnergy, m_curParam, m_vCurReso, phd, map); + gammaFileUtil.UpdateChartResolution(m_vCurEnergy, m_curParam, m_vCurReso, phd, width, map); map.put("ECutAnalysis_Low", phd.getSetting().getECutAnalysis_Low()); map.put("G_energy_span", phd.getSpec().getG_energy_span()); } @@ -1360,7 +1457,7 @@ public class GammaServiceImpl implements IGammaService { } @Override - public Result changeDataResolution(List m_vCurReso, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, Integer sampleId, String fileName) { + public Result changeDataResolution(List m_vCurReso, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, Integer sampleId, String fileName, Double width) { Result result = new Result(); Map map = new HashMap<>(); System.loadLibrary("GammaAnaly"); @@ -1370,13 +1467,13 @@ public class GammaServiceImpl implements IGammaService { result.error500("请先选择解析文件!"); return result; } - DataChangeResolution(m_vCurReso, m_vCurEnergy, m_vCurUncert, m_curParam, phd, map); + DataChangeResolution(m_vCurReso, m_vCurEnergy, m_vCurUncert, m_curParam, phd, width, map); result.setSuccess(true); result.setResult(map); return result; } - public void DataChangeResolution(List m_vCurReso, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, PHDFile phd, Map map) { + public void DataChangeResolution(List m_vCurReso, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, PHDFile phd, Double width, Map map) { System.loadLibrary("GammaAnaly"); m_curParam.setP(CalValuesHandler.calFitPara("Cal_Resolution", 4, m_vCurEnergy, m_vCurReso, m_vCurUncert)); map.put("uncert", m_vCurUncert); @@ -1408,7 +1505,7 @@ public class GammaServiceImpl implements IGammaService { map.put("table", resolutionDataList); String equation = gammaFileUtil.UpdateEquationResolution(m_curParam); map.put("equation", equation); - gammaFileUtil.UpdateChartResolution(m_vCurEnergy, m_curParam, m_vCurReso, phd, map); + gammaFileUtil.UpdateChartResolution(m_vCurEnergy, m_curParam, m_vCurReso, phd, width, map); } @Override @@ -1442,7 +1539,7 @@ public class GammaServiceImpl implements IGammaService { StringBuffer strBuffer = new StringBuffer(); strBuffer.append("#g_Resolution").append("\n"); for (int i=0; i phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(sampleFileName); + if (Objects.nonNull(file)) { + String fileName = file.getOriginalFilename(); + //从最后一个。切割文件名称 获取文件名称后缀 + String fileSuffix = fileName.substring(fileName.lastIndexOf(StringPool.DOT)); + if (fileSuffix.equalsIgnoreCase(".ent")) { + Map map = new HashMap<>(); + List m_vCurReso = new LinkedList<>(); + List m_vCurEnergy = new LinkedList<>(); + List m_vCurUncert = new LinkedList<>(); + try { + //创建临时文件 + File tmpFile = File.createTempFile("tmp", null); + //复制上传文件的输入流到临时文件 + FileUtils.copyInputStreamToFile(file.getInputStream() ,tmpFile); + //读取文件所有行 + List readLines = FileUtils.readLines(tmpFile, "UTF-8"); + //遍历文件行数据 + for (int i=0; i values = Arrays.asList(content.split("\t\t")); + m_vCurEnergy.add(Double.valueOf(values.get(0))); + m_vCurReso.add(Double.valueOf(values.get(1))); + m_vCurUncert.add(Double.valueOf(values.get(2))); + } + } + } + map.put("uncert", m_vCurUncert); + ParameterInfo m_curParam = new ParameterInfo(); + if (StringUtils.isNotBlank(currentText)) { + m_curParam = phd.getMapResoPara().get(currentText); + } + map.put("param", m_curParam); + int num = m_vCurEnergy.size(); + if(num < 1){ + return result; + } + List vFit = CalValuesHandler.calFcnEval(m_vCurEnergy, m_curParam.getP()).counts; + List resolutionDataList = new LinkedList<>(); + for(int i=0; i map = new HashMap<>(); List m_vFuncName = new LinkedList<>(); @@ -1518,7 +1689,7 @@ public class GammaServiceImpl implements IGammaService { map.put("table", efficiencyDataList); String equation = gammaFileUtil.UpdateEquationEfficiency(m_vCurEnergy, m_curParam); map.put("equation", equation); - gammaFileUtil.UpdateChartEfficiency(m_vCurEnergy, m_curParam, m_vCurEffi, phd, map); + gammaFileUtil.UpdateChartEfficiency(m_vCurEnergy, m_curParam, m_vCurEffi, phd, width, map); map.put("ECutAnalysis_Low", phd.getSetting().getECutAnalysis_Low()); map.put("G_energy_span", phd.getSpec().getG_energy_span()); } @@ -1528,7 +1699,7 @@ public class GammaServiceImpl implements IGammaService { } @Override - public Result changeDataEfficiency(List m_vCurEffi, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, Integer funcId, Integer sampleId, String fileName) { + public Result changeDataEfficiency(List m_vCurEffi, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, Integer funcId, Integer sampleId, String fileName, Double width) { Result result = new Result(); Map map = new HashMap<>(); System.loadLibrary("GammaAnaly"); @@ -1538,13 +1709,13 @@ public class GammaServiceImpl implements IGammaService { result.error500("请先选择解析文件!"); return result; } - DataChangeEfficiency(m_vCurEffi, m_vCurEnergy, m_vCurUncert, m_curParam, funcId, phd, map); + DataChangeEfficiency(m_vCurEffi, m_vCurEnergy, m_vCurUncert, m_curParam, funcId, phd, width, map); result.setSuccess(true); result.setResult(map); return result; } - public void DataChangeEfficiency(List m_vCurEffi, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, Integer funcId, PHDFile phd, Map map) { + public void DataChangeEfficiency(List m_vCurEffi, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, Integer funcId, PHDFile phd, Double width, Map map) { System.loadLibrary("GammaAnaly"); m_curParam.setP(CalValuesHandler.calFitPara("Cal_Efficiency", funcId, m_vCurEnergy, m_vCurEffi, m_vCurUncert)); map.put("uncert", m_vCurUncert); @@ -1562,8 +1733,7 @@ public class GammaServiceImpl implements IGammaService { efficiencyData.setDelta(String.format("%.3f", delta)); efficiencyDataList.add(efficiencyData); } - } - else { + } else { for(int i=0; i map = new HashMap<>(); + List m_vCurEffi = new LinkedList<>(); + List m_vCurEnergy = new LinkedList<>(); + List m_vCurUncert = new LinkedList<>(); + Double m_nFunId = 1.0; + try { + //创建临时文件 + File tmpFile = File.createTempFile("tmp", null); + //复制上传文件的输入流到临时文件 + FileUtils.copyInputStreamToFile(file.getInputStream() ,tmpFile); + //读取文件所有行 + List readLines = FileUtils.readLines(tmpFile, "UTF-8"); + //遍历文件行数据 + for (int i=0; i values = Arrays.asList(content.split("\t\t")); + m_vCurEnergy.add(Double.valueOf(values.get(0))); + m_vCurEffi.add(Double.valueOf(values.get(1))); + m_vCurUncert.add(Double.valueOf(values.get(2))); + } + if (content.contains("FitType")) { + List values = Arrays.asList(content.split("=")); + if (values.size() == 2) { + m_nFunId = Double.valueOf(values.get(1)); + } + } + } + } + } + map.put("uncert", m_vCurUncert); + ParameterInfo m_curParam = new ParameterInfo(); + if (StringUtils.isNotBlank(currentText)) { + m_curParam = phd.getMapEffiPara().get(currentText); + } + if (m_curParam.getP().size()>0){ + m_curParam.getP().set(0, m_nFunId); + } else { + m_curParam.getP().add(m_nFunId); + } + map.put("param", m_curParam); + int num = m_vCurEnergy.size(); + if(num < 1){ + return result; + } + List vFit = CalValuesHandler.calFcnEval(m_vCurEnergy, m_curParam.getP()).counts; + List efficiencyDataList = new LinkedList<>(); + for(int i=0; i phdCache = localCache.getPHDCache(); From 5e5474eb2f679fc88fcb8e504456261587c4d090 Mon Sep 17 00:00:00 2001 From: qiaoqinzheng Date: Wed, 20 Sep 2023 16:29:31 +0800 Subject: [PATCH 3/5] =?UTF-8?q?Energy,Resolution,Efficiency=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E7=9A=84call=E5=A2=9E=E5=8A=A0=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/GammaServiceImpl.java | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) 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 ff1cc027..14eaa6f9 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 @@ -1356,13 +1356,14 @@ public class GammaServiceImpl implements IGammaService { if (line.contains("#g_Energy") || line.contains("#Energy")) { for (int j=i+1; j values = Arrays.asList(content.split("\t\t")); + if (Double.valueOf(values.get(1))>0) { + m_vCurEnergy.add(Double.valueOf(values.get(0))); + m_vCurCentroid.add(Double.valueOf(values.get(1))); + m_vCurUncert.add(Double.valueOf(values.get(2))); + } } - List values = Arrays.asList(content.split("\t\t")); - m_vCurEnergy.add(Double.valueOf(values.get(0))); - m_vCurCentroid.add(Double.valueOf(values.get(1))); - m_vCurUncert.add(Double.valueOf(values.get(2))); } } } @@ -1589,13 +1590,14 @@ public class GammaServiceImpl implements IGammaService { if (line.contains("#g_Resolution") || line.contains("#Resolution")) { for (int j=i+1; j values = Arrays.asList(content.split("\t\t")); + if (Double.valueOf(values.get(0))>0) { + m_vCurEnergy.add(Double.valueOf(values.get(0))); + m_vCurReso.add(Double.valueOf(values.get(1))); + m_vCurUncert.add(Double.valueOf(values.get(2))); + } } - List values = Arrays.asList(content.split("\t\t")); - m_vCurEnergy.add(Double.valueOf(values.get(0))); - m_vCurReso.add(Double.valueOf(values.get(1))); - m_vCurUncert.add(Double.valueOf(values.get(2))); } } } @@ -1835,14 +1837,16 @@ public class GammaServiceImpl implements IGammaService { String content = readLines.get(j); if (!content.contains("#") && !content.contains("FitType")) { List values = Arrays.asList(content.split("\t\t")); - m_vCurEnergy.add(Double.valueOf(values.get(0))); - m_vCurEffi.add(Double.valueOf(values.get(1))); - m_vCurUncert.add(Double.valueOf(values.get(2))); + if (Double.valueOf(values.get(0))>0) { + m_vCurEnergy.add(Double.valueOf(values.get(0))); + m_vCurEffi.add(Double.valueOf(values.get(1))); + m_vCurUncert.add(Double.valueOf(values.get(2))); + } } if (content.contains("FitType")) { List values = Arrays.asList(content.split("=")); if (values.size() == 2) { - m_nFunId = Double.valueOf(values.get(1)); + m_nFunId = Double.valueOf(values.get(1).trim()); } } } From bec2a892a1839ca8dbd194d01bb49f050d720c31 Mon Sep 17 00:00:00 2001 From: qiaoqinzheng Date: Wed, 20 Sep 2023 17:13:23 +0800 Subject: [PATCH 4/5] =?UTF-8?q?GammaFileUtil=E4=BF=AE=E6=94=B9=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=86=85=E5=AE=B9=E8=8E=B7=E5=8F=96=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20NameStandUtil=E4=BF=AE=E6=94=B9=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E8=B7=AF=E5=BE=84=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20=E4=BF=AE=E6=94=B9Gamma=E6=A8=A1=E5=9D=97saveToDB=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jeecg/common/util/GammaFileUtil.java | 4 +-- .../org/jeecg/common/util/NameStandUtil.java | 27 +++++++++---------- .../service/impl/GammaServiceImpl.java | 11 +++++--- .../GardsSampleDataSpectrumServiceImpl.java | 2 +- ...sSampleDescriptionSpectrumServiceImpl.java | 22 +++++++-------- 5 files changed, 34 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 8bfcbb30..7c735c30 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 @@ -56,7 +56,7 @@ public class GammaFileUtil { @Autowired private NameStandUtil nameStandUtil; - public boolean loadFile(String pathName, String fileName, PHDFile phd, Result result){ + public boolean loadFile(String pathName, String fileName, PHDFile phd, Result result) { phd.setFilepath(pathName); phd.setFilename(fileName); //连接ftp @@ -2804,7 +2804,7 @@ public class GammaFileUtil { String subDirSavePath = ""; subDirSavePath+=nameStandUtil.GetSysTemSubdir(fileAnlyse.getHeader().getSystem_type()); subDirSavePath+=nameStandUtil.GetDateTypeSubdir(dataType); - Map fileNames = nameStandUtil.NameStandard(subDirSavePath, fileAnlyse); + Map fileNames = nameStandUtil.NameStandard(fileAnlyse); String lcName = fileNames.get("lc"); String scacName = fileNames.get("scac"); String baselineName = fileNames.get("baseline"); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/NameStandUtil.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/NameStandUtil.java index 711c2320..12d7c03a 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/NameStandUtil.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/NameStandUtil.java @@ -20,15 +20,15 @@ public class NameStandUtil { public String GetSysTemSubdir(String systemType) { StringBuffer path = new StringBuffer(); if(systemType.contains(SystemType.BETA.getType())) { - path.append(StringPool.SLASH+"Spectrum"); + path.append("Spectrum"); path.append(StringPool.SLASH+"Xenon"); path.append(StringPool.SLASH+"Sauna"); } else if(systemType.contains(SystemType.GAMMA.getType())) { - path.append(StringPool.SLASH+"Spectrum"); + path.append("Spectrum"); path.append(StringPool.SLASH+"Xenon"); path.append(StringPool.SLASH+"Spalax"); } else if(systemType.contains(SystemType.PARTICULATE.getType())) { - path.append(StringPool.SLASH+"Spectrum"); + path.append("Spectrum"); path.append(StringPool.SLASH+"Particulates"); } return path.toString(); @@ -78,9 +78,9 @@ public class NameStandUtil { return path.toString(); } - public Map NameStandard(String path, PHDFile fileAnlyse) { + public Map NameStandard(PHDFile fileAnlyse) { String suffix = GetSuffix(fileAnlyse.getMsgInfo().getData_type(),fileAnlyse.getHeader().getSystem_type(),fileAnlyse.getHeader().getSpectrum_quantity(),String.valueOf(fileAnlyse.getAcq().getAcquisition_live_time())); - Map fileNames = NameStandardByName(path, fileAnlyse.getFilename(), fileAnlyse.getHeader().getMeasurement_id(),suffix); + Map fileNames = NameStandardByName(fileAnlyse.getFilename(), fileAnlyse.getHeader().getMeasurement_id(),suffix); return fileNames; } @@ -117,13 +117,12 @@ public class NameStandUtil { return rData; } - public Map NameStandardByName(String path, String fileName, String dateTimeFormat, String suffix) { + public Map NameStandardByName(String fileName, String dateTimeFormat, String suffix) { Map map = new HashMap<>(); String StandardFileName=""; String measurementName = GetFileNameFromDateTime(dateTimeFormat, suffix); - String fileDir = path + StringPool.SLASH; if(measurementName != fileName) { - StandardFileName = fileDir+measurementName; + StandardFileName = measurementName; } String fileSuffix = "PHD"; @@ -133,11 +132,11 @@ public class NameStandUtil { String m_logfileName = StandardFileName; String m_reportFileName = StandardFileName; - m_lcFileName.replace(fileSuffix,"lc"); - m_baseLineFileName.replace(fileSuffix,"baseline"); - m_scacFileName.replace(fileSuffix,"scac"); - m_logfileName.replace(fileSuffix,"log"); - m_reportFileName.replace("."+fileSuffix,"_rpt"); + m_lcFileName = m_lcFileName.replace(fileSuffix,"lc"); + m_baseLineFileName = m_baseLineFileName.replace(fileSuffix,"baseline"); + m_scacFileName = m_scacFileName.replace(fileSuffix,"scac"); + m_logfileName = m_logfileName.replace(fileSuffix,"log"); + m_reportFileName = m_reportFileName.replace("."+fileSuffix,"_rpt"); String m_saveFileName = StandardFileName; @@ -189,7 +188,7 @@ public class NameStandUtil { //添加文件名日期 List dateSub = GetSubDirByFileName(saveFileName); for(int pos=0;pos phdCache = localCache.getPHDCache(); PHDFile phd = phdCache.getIfPresent(fileName); + if (Objects.isNull(phd)) { + result.error500("请先解析文件!"); + return result; + } //查看分析员是否有权限操作当前台站信息 //判断当前分析员是否有过排班任务 Integer stationId = spectrumAnalysisMapper.getStationId(phd.getHeader().getSite_code()); @@ -2837,8 +2842,7 @@ public class GammaServiceImpl implements IGammaService { phd.setStatus(sampleData.getStatus()); } else { //如果sampleData为空 存储数据 - needUploadSpec = SaveSampleToDB(phd, middleData.analyses_save_filePath); - bRet = needUploadSpec; + bRet = SaveSampleToDB(phd, middleData.analyses_save_filePath); } if(!bRet) { result.error500("The Database hasn't this Spectrum("+phd.getFilename()+") and Insert it to Database failed."); @@ -2931,6 +2935,7 @@ public class GammaServiceImpl implements IGammaService { return result; } + @Transactional public boolean SaveSampleToDB(PHDFile phd, String input_file_name) { boolean bRet = true; String sit_det_code = phd.getHeader().getSite_code(); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GardsSampleDataSpectrumServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GardsSampleDataSpectrumServiceImpl.java index ed27c1d7..b1303bb6 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GardsSampleDataSpectrumServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GardsSampleDataSpectrumServiceImpl.java @@ -113,7 +113,7 @@ public class GardsSampleDataSpectrumServiceImpl extends ServiceImpl 1024){ - t_cmt = t_cmt.substring(0, 1024); - } - GardsSampleDescription sampleDescription = new GardsSampleDescription(); - sampleDescription.setSampleId(sampleId); - sampleDescription.setDescription(t_cmt); - int insert = this.baseMapper.insert(sampleDescription); - if (insert>0) { - bRet = true; - } + String t_cmt = StringUtils.isNotBlank(phd.getOriTotalCmt())?phd.getOriTotalCmt():""; + if(t_cmt.length() > 1024){ + t_cmt = t_cmt.substring(0, 1024); + } + GardsSampleDescription sampleDescription = new GardsSampleDescription(); + sampleDescription.setSampleId(sampleId); + sampleDescription.setDescription(t_cmt); + int insert = this.baseMapper.insert(sampleDescription); + if (insert>0) { + bRet = true; } return bRet; } From 9bf98b819c3e56bd9dcee0bd92504470147e1859 Mon Sep 17 00:00:00 2001 From: qiaoqinzheng Date: Wed, 20 Sep 2023 19:13:44 +0800 Subject: [PATCH 5/5] =?UTF-8?q?NameStandUtil=E7=A7=BB=E5=8A=A8=E5=88=B0?= =?UTF-8?q?=E5=85=AC=E7=94=A8=E5=B7=A5=E5=85=B7=E7=B1=BB=E4=B8=AD=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9Gamma=E6=A8=A1=E5=9D=97=E4=B8=8BSaveToDB?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jeecg/common/util/NameStandUtil.java | 0 .../org/jeecg/common/util/GammaFileUtil.java | 35 ++++++- .../modules/controller/GammaController.java | 5 + .../jeecg/modules/service/IGammaService.java | 2 + ...dsCalibrationPairsOrigSpectrumService.java | 2 +- .../IGardsSampleAuxSpectrumService.java | 2 +- .../IGardsSampleCertLineSpectrumService.java | 2 +- .../IGardsSampleCertSpectrumService.java | 2 +- .../IGardsSampleDataSpectrumService.java | 2 +- .../IGardsSpectrumSpectrumService.java | 2 +- ...dsTotalEfficiencyPairsSpectrumService.java | 2 +- .../service/impl/GammaServiceImpl.java | 91 +++++++++-------- ...librationPairsOrigSpectrumServiceImpl.java | 98 ++++++++++--------- .../GardsSampleAuxSpectrumServiceImpl.java | 8 +- ...ardsSampleCertLineSpectrumServiceImpl.java | 42 ++++---- .../GardsSampleCertSpectrumServiceImpl.java | 30 +++--- .../GardsSampleDataSpectrumServiceImpl.java | 8 +- .../GardsSpectrumSpectrumServiceImpl.java | 11 +-- ...talEfficiencyPairsSpectrumServiceImpl.java | 8 +- 19 files changed, 197 insertions(+), 155 deletions(-) rename {jeecg-module-spectrum-analysis => jeecg-boot-base-core}/src/main/java/org/jeecg/common/util/NameStandUtil.java (100%) diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/NameStandUtil.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/NameStandUtil.java similarity index 100% rename from jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/NameStandUtil.java rename to jeecg-boot-base-core/src/main/java/org/jeecg/common/util/NameStandUtil.java 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 7c735c30..ffd95e03 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 @@ -4111,7 +4111,6 @@ public class GammaFileUtil { data1.getPointlist().add(seriseData); } datalist.add(data1); - if(vEnergy.size() == size) { ChartData data2 = new ChartData(); data2.setName("Compare"); @@ -4130,4 +4129,38 @@ public class GammaFileUtil { return datalist; } + public List StripData(List m_vecCompare, List m_vCount, long m_nCount, Map colorMap, List vEnergy, Double ratioRate) { + List datalist = new LinkedList<>(); + int size = m_vecCompare.size(); + if(size == m_nCount) { + ChartData data1 = new ChartData(); + data1.setName("Compare"); + data1.setGroup("channel"); + data1.setColor(colorMap.get("Color_Strip")); + // type: 1 Add a Spectrum in Channel; -1 Cut a Spectrum in Channel + for(int i=0; i readLines); - boolean saveCalibrationPairsOrigGamma(PHDFile phd, Integer sampleId); + Integer saveCalibrationPairsOrigGamma(PHDFile phd, Integer sampleId); } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGardsSampleAuxSpectrumService.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGardsSampleAuxSpectrumService.java index 70736435..b8f6ceaa 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGardsSampleAuxSpectrumService.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGardsSampleAuxSpectrumService.java @@ -11,6 +11,6 @@ public interface IGardsSampleAuxSpectrumService extends IService Integer saveSampleAux(EnergySpectrumStruct sourceData, Integer sampleId, List readLines); - boolean saveSampleAuxGamma(PHDFile phd, Integer sampleId); + Integer saveSampleAuxGamma(PHDFile phd, Integer sampleId); } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGardsSampleCertLineSpectrumService.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGardsSampleCertLineSpectrumService.java index dc95a908..0e6bb4d3 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGardsSampleCertLineSpectrumService.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGardsSampleCertLineSpectrumService.java @@ -9,6 +9,6 @@ public interface IGardsSampleCertLineSpectrumService extends IService readLines); - boolean saveSampleDataGamma(PHDFile phd, String input_file_name, Integer station_id, Integer detect_id); + Integer saveSampleDataGamma(PHDFile phd, String input_file_name, Integer station_id, Integer detect_id); } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGardsSpectrumSpectrumService.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGardsSpectrumSpectrumService.java index 8dbb73b5..19bebe04 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGardsSpectrumSpectrumService.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGardsSpectrumSpectrumService.java @@ -11,6 +11,6 @@ public interface IGardsSpectrumSpectrumService extends IService { Integer saveSpectrum(EnergySpectrumStruct sourceData, Integer sampleId, List readLines, String filePathName); - boolean saveSpectrumGamma(PHDFile phd, Integer sampleId, String input_file_name); + Integer saveSpectrumGamma(PHDFile phd, Integer sampleId, String input_file_name); } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGardsTotalEfficiencyPairsSpectrumService.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGardsTotalEfficiencyPairsSpectrumService.java index 2ba2fd2a..e7a25613 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGardsTotalEfficiencyPairsSpectrumService.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGardsTotalEfficiencyPairsSpectrumService.java @@ -9,6 +9,6 @@ public interface IGardsTotalEfficiencyPairsSpectrumService extends IService colorMap = sysUserColorService.initColor(userName); + //获取缓存的phd数据 + Cache phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(fileName); + long m_nCount = phd.getSpec().getNum_g_channel(); + List vEnergy = phd.getVEnergy(); + long m_nSChan = phd.getSpec().getBegin_channel(); + List m_vCount = new LinkedList<>(); + // 确保绘制曲线时所有谱都是从1道开始 + int i = 0; + if(m_nSChan == 0) { + i = 1; + } + for(; i m_vecCompare = gammaFileUtil.loadCompareData(stripFileName, userName, m_nCount, result); + if (CollectionUtils.isNotEmpty(m_vecCompare)) { + List chartDataList = gammaFileUtil.StripData(m_vecCompare, m_vCount, m_nCount, colorMap, vEnergy, ratioRate); + result.setSuccess(true); + result.setResult(chartDataList); + } + return result; + } + @Override public Result configure(Integer sampleId, String fileName) { Result result = new Result(); @@ -2842,7 +2876,7 @@ public class GammaServiceImpl implements IGammaService { phd.setStatus(sampleData.getStatus()); } else { //如果sampleData为空 存储数据 - bRet = SaveSampleToDB(phd, middleData.analyses_save_filePath); + SaveSampleToDB(phd, middleData.analyses_save_filePath); } if(!bRet) { result.error500("The Database hasn't this Spectrum("+phd.getFilename()+") and Insert it to Database failed."); @@ -2936,8 +2970,7 @@ public class GammaServiceImpl implements IGammaService { } @Transactional - public boolean SaveSampleToDB(PHDFile phd, String input_file_name) { - boolean bRet = true; + public void SaveSampleToDB(PHDFile phd, String input_file_name) { String sit_det_code = phd.getHeader().getSite_code(); String detect_code = phd.getHeader().getDetector_code(); // 查询 station_id 和 detect_id @@ -2948,54 +2981,26 @@ public class GammaServiceImpl implements IGammaService { // 查询新增后的 sample_id 的值赋给变量 DECLARESAMPLEID Integer sampleId = spectrumAnalysisMapper.getSampleId(input_file_name); // ORIGINAL.GARDS_SAMPLE_AUX 表数据 - bRet = sampleAuxSpectrumService.saveSampleAuxGamma(phd, sampleId); - if (!bRet) { - String Warning = "Save "+phd.getFilename()+" to original DB failed."; - return bRet; - } + sampleAuxSpectrumService.saveSampleAuxGamma(phd, sampleId); // ORIGINAL.gards_sample_description 数据表 - bRet = sampleDescriptionSpectrumService.saveSampleDescriptionGamma(phd, sampleId); - if (!bRet) { - String Warning = "Save "+phd.getFilename()+" to original DB failed."; - return bRet; - } + sampleDescriptionSpectrumService.saveSampleDescriptionGamma(phd, sampleId); // ORIGINAL.GARDS_SAMPLE_CERT 和 ORIGINAL.GARDS_SAMPLE_CERT_LINE 数据表 if(phd.getCertificate().getRecord_count() > 0) { - bRet = sampleCertSpectrumService.saveSampleCertGamma(phd, sampleId); - if (!bRet) { - String Warning = "Save "+phd.getFilename()+" to original DB failed."; - return bRet; - } - bRet = sampleCertLineSpectrumService.saveSampleCertLineGamma(phd, sampleId); - if (!bRet) { - String Warning = "Save "+phd.getFilename()+" to original DB failed."; - return bRet; - } + sampleCertSpectrumService.saveSampleCertGamma(phd, sampleId); + sampleCertLineSpectrumService.saveSampleCertLineGamma(phd, sampleId); } //gards_ calibration_pairs_orig数据表 - bRet = calibrationPairsOrigSpectrumService.saveCalibrationPairsOrigGamma(phd, sampleId); - if (!bRet) { - String Warning = "Save "+phd.getFilename()+" to original DB failed."; - return bRet; - } + calibrationPairsOrigSpectrumService.saveCalibrationPairsOrigGamma(phd, sampleId); // gards_total_efficiency _pairs数据表(IDC没有) - bRet = totalEfficiencyPairsSpectrumService.saveTotalEfficiencyPairsGamma(phd, sampleId); - if (!bRet) { - String Warning = "Save "+phd.getFilename()+" to original DB failed."; - return bRet; - } + totalEfficiencyPairsSpectrumService.saveTotalEfficiencyPairsGamma(phd, sampleId); //gards_spectrum数据表 - bRet = spectrumService.saveSpectrumGamma(phd, sampleId, input_file_name); - if(bRet) { - GardsSampleDataSpectrum samplData = spectrumAnalysisMapper.findSampleByFilePath(input_file_name); - if(Objects.nonNull(samplData)) { - phd.setId_sample(samplData.getSampleId().toString()); - phd.setStatus(samplData.getStatus()); - } - } else { - String Warning = "Save "+phd.getFilename()+" to original DB failed."; + spectrumService.saveSpectrumGamma(phd, sampleId, input_file_name); + //根据文件名称获取sample基础数据信息 + GardsSampleDataSpectrum samplData = spectrumAnalysisMapper.findSampleByFilePath(input_file_name); + if(Objects.nonNull(samplData)) { + phd.setId_sample(samplData.getSampleId().toString()); + phd.setStatus(samplData.getStatus()); } - return bRet; } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GardsCalibrationPairsOrigSpectrumServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GardsCalibrationPairsOrigSpectrumServiceImpl.java index 3872d4e1..e1a61e64 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GardsCalibrationPairsOrigSpectrumServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GardsCalibrationPairsOrigSpectrumServiceImpl.java @@ -20,6 +20,7 @@ import org.springframework.transaction.annotation.Transactional; import java.util.LinkedList; import java.util.List; +import java.util.Objects; @Service("gardsCalibrationPairsOrigSpectrumService") @DS("ora") @@ -109,61 +110,66 @@ public class GardsCalibrationPairsOrigSpectrumServiceImpl extends ServiceImpl calibrationPairsOrigList = new LinkedList<>(); - int t_size = phd.getMapEnerKD().get(CalName.CalPHD.getType()).getG_energy().size(); - if(t_size > 0) { - GEnergyBlock g_ener = phd.getMapEnerKD().get(CalName.CalPHD.getType()); - for (int i=0; i 0) { + GEnergyBlock g_ener = phd.getMapEnerKD().get(CalName.CalPHD.getType()); + for (int i=0; i 0) { - GResolutionBlock g_reso = phd.getMapResoKD().get(CalName.CalPHD.getType()); - for (int i=0; i 0) { + GResolutionBlock g_reso = phd.getMapResoKD().get(CalName.CalPHD.getType()); + for (int i=0; i 0) { - GEfficiencyBlock g_effi = phd.getMapEffiKD().get(CalName.CalPHD.getType()); - for (int i=0; i 0) { + GEfficiencyBlock g_effi = phd.getMapEffiKD().get(CalName.CalPHD.getType()); + for (int i=0; i0) { - bRet = true; - } - return bRet; + return insert; } } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GardsSampleCertLineSpectrumServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GardsSampleCertLineSpectrumServiceImpl.java index 6fdf0e07..76a0b2c6 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GardsSampleCertLineSpectrumServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GardsSampleCertLineSpectrumServiceImpl.java @@ -13,6 +13,7 @@ import org.springframework.transaction.annotation.Transactional; import java.util.LinkedList; import java.util.List; +import java.util.Objects; @Service("gardsSampleCertLineSpectrumService") @DS("ora") @@ -45,28 +46,29 @@ public class GardsSampleCertLineSpectrumServiceImpl extends ServiceImpl sampleCertLineList = new LinkedList<>(); - for (int i=0; i0) { - bRet = true; + public Integer saveSampleCertGamma(PHDFile phd, Integer sampleId) { + int insert = 0; + if (Objects.nonNull(phd.getCertificate())) { + String assay_date = phd.getCertificate().getAssay_date() + " " + phd.getCertificate().getAssay_time(); + try { + GardsSampleCert sampleCert = new GardsSampleCert(); + sampleCert.setSampleId(sampleId); + sampleCert.setQuantity(phd.getCertificate().getTotal_source_activity()); + sampleCert.setAssayDate(DateUtils.parseDate(assay_date)); + sampleCert.setUnit(phd.getCertificate().getUnits_activity()); + insert = this.baseMapper.insert(sampleCert); + } catch (ParseException e) { + throw new RuntimeException(e); } - } catch (ParseException e) { - throw new RuntimeException(e); } - return bRet; + return insert; } } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GardsSampleDataSpectrumServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GardsSampleDataSpectrumServiceImpl.java index b1303bb6..b63b90ca 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GardsSampleDataSpectrumServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GardsSampleDataSpectrumServiceImpl.java @@ -96,8 +96,7 @@ public class GardsSampleDataSpectrumServiceImpl extends ServiceImpl 0) { - bRet = true; - } - return bRet; + return insert; } } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GardsSpectrumSpectrumServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GardsSpectrumSpectrumServiceImpl.java index 8b4e43ab..23b6f4ed 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GardsSpectrumSpectrumServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GardsSpectrumSpectrumServiceImpl.java @@ -55,8 +55,8 @@ public class GardsSpectrumSpectrumServiceImpl extends ServiceImpl 0) { GSpectrumBlock g_spec = phd.getSpec(); @@ -67,12 +67,9 @@ public class GardsSpectrumSpectrumServiceImpl extends ServiceImpl0) { - bRet = true; - } + insert = this.baseMapper.insert(spectrum); } - return bRet; + return insert; } } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GardsTotalEfficiencyPairsSpectrumServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GardsTotalEfficiencyPairsSpectrumServiceImpl.java index 9225ffa4..ab1ec118 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GardsTotalEfficiencyPairsSpectrumServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GardsTotalEfficiencyPairsSpectrumServiceImpl.java @@ -15,6 +15,7 @@ import org.springframework.transaction.annotation.Transactional; import java.util.LinkedList; import java.util.List; +import java.util.Objects; @Service("gardsTotalEfficiencyPairsSpectrumService") @DS("ora") @@ -40,10 +41,9 @@ public class GardsTotalEfficiencyPairsSpectrumServiceImpl extends ServiceImpl totalEfficiencyPairsList = new LinkedList<>(); - int t_size = phd.getMapTotEKD().get(CalName.CalPHD.getType()).getG_energy().size(); + int t_size = Objects.nonNull(phd.getMapTotEKD().get(CalName.CalPHD.getType()).getG_energy())?phd.getMapTotEKD().get(CalName.CalPHD.getType()).getG_energy().size():0; if(t_size > 0) { TotaleffBlock g_tote = phd.getMapTotEKD().get(CalName.CalPHD.getType()); for (int i=0; i