diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/SpectrumPathProperties.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/SpectrumPathProperties.java index 8034a1b3..1f2a8055 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/SpectrumPathProperties.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/SpectrumPathProperties.java @@ -39,7 +39,12 @@ public class SpectrumPathProperties implements Serializable { /** * 用户上传文件路径 */ - private String uploadPath; + private String uploadPath;; + + /** + * 能谱解析失败文件存储路径 + */ + private String failPath; /** * 能谱文件存储路径以能谱系统类型/能谱类型为key,以存储路径为value diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/entity/postgre/SysUserColor.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/entity/postgre/SysUserColor.java new file mode 100644 index 00000000..7a42ea99 --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/entity/postgre/SysUserColor.java @@ -0,0 +1,75 @@ +package org.jeecg.modules.base.entity.postgre; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +@Data +@TableName(value = "sys_user_color") +public class SysUserColor implements Serializable { + + /** + * id + */ + @TableId(value = "id", type = IdType.ASSIGN_ID) + private String id; + + /** + * 原谱曲线颜色 + */ + @TableField(value = "color_spec") + private String colorSpec; + + /** + * 拟合峰曲线颜色 + */ + @TableField(value = "color_peak") + private String colorPeak; + + /** + * LC曲线颜色 + */ + @TableField(value = "color_lc") + private String colorLc; + + /** + * BaseLine曲线颜色 + */ + @TableField(value = "color_base") + private String colorBase; + + /** + * Scac曲线颜色 + */ + @TableField(value = "color_scac") + private String colorScac; + + /** + * 比较谱曲线颜色 + */ + @TableField(value = "color_compare") + private String colorCompare; + + /** + * 拟合基线颜色 + */ + @TableField(value = "color_fitbase") + private String colorFitbase; + + /** + * 两谱和曲线颜色 + */ + @TableField(value = "color_strip") + private String colorStrip; + + /** + * 创建人 + */ + @TableField(value = "create_by") + private String createBy; + +} diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/ftp/FTPUtils.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/ftp/FTPUtils.java index 05ab760a..39e0c641 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/ftp/FTPUtils.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/ftp/FTPUtils.java @@ -124,13 +124,46 @@ public class FTPUtils { } /** - * 写入文件,若文件或文件目录不存在则自行创建 + * 写入文件,若文件或文件目录不存在则自行创建,存在先删除再创建 * @param filePath 文件路径 * @param fileName 文件名称 * @param inputStream 文件输入流 * @return 返回值true/false */ public boolean saveFile(String filePath,String fileName,InputStream inputStream){ + try{ + final boolean flag = this.checkDirectory(filePath); + if(flag){ + final FTPFile[] ftpFiles = this.client.listFiles(fileName); + if(ArrayUtils.isNotEmpty(ftpFiles)){ + client.deleteFile(fileName); + } + return client.storeFile(fileName, inputStream); + } + }catch (IOException e){ + log.error("{}文件创建失败,原因为:{}",filePath+"/"+fileName,e.getMessage()); + e.printStackTrace(); + return false; + }finally { + if(null != inputStream){ + try { + inputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return false; + } + + /** + * 写入文件,若文件或文件目录不存在则自行创建,存在则追加内容 + * @param filePath 文件路径 + * @param fileName 文件名称 + * @param inputStream 文件输入流 + * @return 返回值true/false + */ + public boolean saveOrAppendFile(String filePath,String fileName,InputStream inputStream){ try{ final boolean flag = this.checkDirectory(filePath); if(flag){ diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/native_jni/struct/EnergySpectrumStruct.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/native_jni/struct/EnergySpectrumStruct.java index 0bd0b2b7..63eb8f90 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/native_jni/struct/EnergySpectrumStruct.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/native_jni/struct/EnergySpectrumStruct.java @@ -426,7 +426,7 @@ public class EnergySpectrumStruct { /** * γ-energy (keV) */ - public List t_g_energy; + public List t_g_energy; /** * total efficiency (counts/photon emitted) */ @@ -551,4 +551,4 @@ public class EnergySpectrumStruct { ", t_record_count=" + t_record_count + '}'; } -} \ No newline at end of file +} diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/TotalEffBlockServiceImpl.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/TotalEffBlockServiceImpl.java index 01137a5d..293ed4da 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/TotalEffBlockServiceImpl.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/TotalEffBlockServiceImpl.java @@ -30,7 +30,7 @@ public class TotalEffBlockServiceImpl extends ServiceImplundeal目录 + super.handleParseingFailFile(); + throw e; + }finally { + //删除本地临时文件 + super.deleteLocalTemporaryFile(); + } }else{ super.next.handler(); } 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 64ee0e99..600dd178 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,7 @@ package org.jeecg.modules.spectrum; import lombok.extern.slf4j.Slf4j; import org.jeecg.modules.base.enums.DataType; +import org.jeecg.modules.base.enums.SampleStatus; /** * 气体谱处理 @@ -16,7 +17,7 @@ public class GasbkphdSpectrum extends S_D_Q_G_SpectrumHandler{ protected void setChina() { SpectrumHandler spectrumHandler = new MetSpectrum(); spectrumHandler.initNext(super.spectrumServiceQuotes,super.mailFile, - super.currDataType,super.message,super.emailProperties,super.ftpUtil,super.mailContent); + super.currDataType,super.ftpUtil,super.mailContent); spectrumHandler.setPrevious(this); super.setNext(spectrumHandler); } @@ -27,24 +28,31 @@ public class GasbkphdSpectrum extends S_D_Q_G_SpectrumHandler{ @Override protected void handler() throws Exception { if(DataType.GASBKPHD.getType().equals(super.currDataType.getType())){ - //前置检查 - this.preCheck(); - //打印当前处理的能谱类型 - super.printCurrDataType(); - //解析邮件内容 - super.parseingEmail(); - //读取邮件内容标签 - super.readFileLabel(); - //保存PHD文件到ftp - super.saveFileToFtp(); - //结构体数据入库 - super.handlerOriginalData(); - //保存email日志 - super.saveEmailLog(); - //删除本地临时文件 - super.deleteLocalTemporaryFile(); - //把流程日志写入ftp日志文件 - super.saveLogToFtp(); + try{ + //前置检查 + this.preCheck(); + //打印当前处理的能谱类型 + super.printCurrDataType(); + //解析邮件内容 + super.parseingEmail(); + //读取邮件内容标签 + super.readFileLabel(); + //保存PHD文件到ftp + super.saveFileToFtp(); + //结构体数据入库 + super.handlerOriginalData(); + //把流程日志写入ftp日志文件 + super.saveLogToFtp(); + }catch (Exception e){ + //修改状态为解析失败 + this.spectrumServiceQuotes.getSampleDataService().updateStatus(SampleStatus.FAIL.getValue(),super.sampleData.getInputFileName()); + //处理解析失败的文件,上传到ftp->undeal目录 + super.handleParseingFailFile(); + throw e; + }finally { + //删除本地临时文件 + super.deleteLocalTemporaryFile(); + } }else{ super.next.handler(); } diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/HealthStatusSpectrum.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/HealthStatusSpectrum.java index 092deb36..4a946c2a 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/HealthStatusSpectrum.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/HealthStatusSpectrum.java @@ -68,8 +68,6 @@ public class HealthStatusSpectrum extends SpectrumHandler{ this.saveFileToFtp(); //结构体数据入库 this.handlerOriginalData(); - //保存email日志 - super.saveEmailLog(); //删除本地临时文件 super.deleteLocalTemporaryFile(); //把流程日志写入ftp日志文件 diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/MetSpectrum.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/MetSpectrum.java index e79a08da..4b9a24af 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/MetSpectrum.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/MetSpectrum.java @@ -46,7 +46,7 @@ public class MetSpectrum extends SpectrumHandler{ protected void setChina() { SpectrumHandler spectrumHandler = new AlertSpectrum(); spectrumHandler.initNext(super.spectrumServiceQuotes,super.mailFile, - super.currDataType,super.message,super.emailProperties,super.ftpUtil,super.mailContent); + super.currDataType,super.ftpUtil,super.mailContent); spectrumHandler.setPrevious(this); super.setNext(spectrumHandler); } @@ -65,8 +65,6 @@ public class MetSpectrum extends SpectrumHandler{ this.saveFileToFtp(); //结构体数据入库 this.handlerOriginalData(); - //保存email日志 - super.saveEmailLog(); //删除本地临时文件 super.deleteLocalTemporaryFile(); //把流程日志写入ftp日志文件 diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/QcphdSpectrum.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/QcphdSpectrum.java index 15593951..efc5043e 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/QcphdSpectrum.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/QcphdSpectrum.java @@ -1,6 +1,7 @@ package org.jeecg.modules.spectrum; import org.jeecg.modules.base.enums.DataType; +import org.jeecg.modules.base.enums.SampleStatus; /** * QC谱处理 @@ -14,7 +15,7 @@ public class QcphdSpectrum extends S_D_Q_G_SpectrumHandler{ protected void setChina() { SpectrumHandler spectrumHandler = new GasbkphdSpectrum(); spectrumHandler.initNext(super.spectrumServiceQuotes,super.mailFile, - super.currDataType,super.message,super.emailProperties,super.ftpUtil,super.mailContent); + super.currDataType,super.ftpUtil,super.mailContent); spectrumHandler.setPrevious(this); super.setNext(spectrumHandler); } @@ -26,24 +27,31 @@ public class QcphdSpectrum extends S_D_Q_G_SpectrumHandler{ protected void handler() throws Exception { //判断当前邮件内容是否是QC谱 if(DataType.QCPHD.getType().equals(super.currDataType.getType())){ - //前置检查 - this.preCheck(); - //打印当前处理的能谱类型 - super.printCurrDataType(); - //解析邮件内容 - super.parseingEmail(); - //读取邮件内容标签 - super.readFileLabel(); - //保存PHD文件到ftp - super.saveFileToFtp(); - //结构体数据入库 - super.handlerOriginalData(); - //保存email日志 - super.saveEmailLog(); - //删除本地临时文件 - super.deleteLocalTemporaryFile(); - //把流程日志写入ftp日志文件 - super.saveLogToFtp(); + try{ + //前置检查 + this.preCheck(); + //打印当前处理的能谱类型 + super.printCurrDataType(); + //解析邮件内容 + super.parseingEmail(); + //读取邮件内容标签 + super.readFileLabel(); + //保存PHD文件到ftp + super.saveFileToFtp(); + //结构体数据入库 + super.handlerOriginalData(); + //把流程日志写入ftp日志文件 + super.saveLogToFtp(); + }catch (Exception e){ + //修改状态为解析失败 + this.spectrumServiceQuotes.getSampleDataService().updateStatus(SampleStatus.FAIL.getValue(),super.sampleData.getInputFileName()); + //处理解析失败的文件,上传到ftp->undeal目录 + super.handleParseingFailFile(); + throw e; + }finally { + //删除本地临时文件 + super.deleteLocalTemporaryFile(); + } }else{ super.next.handler(); } 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 8ec056d0..9fa42c29 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 @@ -1,6 +1,7 @@ package org.jeecg.modules.spectrum; import cn.hutool.core.io.FileUtil; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.util.Strings; @@ -35,6 +36,7 @@ import java.util.Objects; /** * 样品谱(Samplephd)、探测器本地谱(Detbkphd)、QC谱(Qcphd)、气体谱(Gasbkphd) */ +@Slf4j public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{ /** @@ -202,11 +204,14 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{ */ @Override protected void handlerOriginalData() throws Exception { + this.startIntoDatabaseTime = new Date(); + //如果数据已经存储,不在重复存储 final boolean exist = spectrumServiceQuotes.getSampleDataService().fileExist(super.ftpSavePath); if(exist){ - throw new FileRepeatException("file repeat"); + this.endIntoDatabaseTime = new Date(); + log.warn("{} file data has been stored",super.mailFile.getName()); + return; } - this.startIntoDatabaseTime = new Date(); DataSourceSwitcher.switchToOracle(); final TransactionStatus transactionStatus = spectrumServiceQuotes.getTransactionManager().getTransaction(spectrumServiceQuotes.getTransactionDefinition()); try{ @@ -266,7 +271,7 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{ this.logFilePath = properties.getLogPath()+StringConstant.SLASH+this.getFileSavePath(); this.logFileName = super.mailFile.getName().replace(this.currDataType.getSuffix(),LOG_FILE_SUFFIX); - super.ftpUtil.saveFile(logFilePath,logFileName,new ByteArrayInputStream(logContent.toString().getBytes(StandardCharsets.UTF_8))); + super.ftpUtil.saveOrAppendFile(logFilePath,logFileName,new ByteArrayInputStream(logContent.toString().getBytes(StandardCharsets.UTF_8))); } /** 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 e3d6f712..30e386ee 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 @@ -3,6 +3,7 @@ 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; @@ -36,6 +37,7 @@ import java.util.stream.Collectors; /** * B谱分析过程 */ +@Slf4j public class Sample_B_Analysis implements BlockConstant { /** @@ -141,8 +143,8 @@ public class Sample_B_Analysis implements BlockConstant { /** * 执行解析过程 */ - public void start(){ - try { + public void start() throws BAnalyseException { + try{ //修改状态为解析中 this.updateStatus(SampleStatus.IN_PROCESS.getValue()); //查询det、gas数据(sampleId,inputFileName),sample数据在构造函数已经传过来 @@ -158,15 +160,19 @@ public class Sample_B_Analysis implements BlockConstant { //生成报告 Sample_B_Analysis.B_AnalysisReport report = new Sample_B_Analysis.B_AnalysisReport(); report.start(); - //删除下载的det和gas临时文件 - this.deleteLocalTemporaryFile(); + //修改状态为解析成功 + this.updateStatus(SampleStatus.COMPLETE.getValue()); }catch (Exception e){ e.printStackTrace(); + throw new BAnalyseException("Sample Analyse Error at "+DateUtils.formatDate(new Date(),"yyyy-MM-dd HH:mm:ss")); + }finally { + //删除下载的det和gas临时文件 + this.deleteLocalTemporaryFile(); } } /** - * 修改状态为解析中 + * 修改状态 * @param analysesStatus */ private void updateStatus(String analysesStatus){ @@ -270,6 +276,12 @@ public class Sample_B_Analysis implements BlockConstant { private void storageDataToDatabase(){ String logFileRelativePath = this.logFilePath+StringConstant.SLASH+this.logFileName; String arrFileRelativePath = this.arrFilePath+StringConstant.SLASH+this.arrFileName; + //如果数据已经存储,不在重复存储 + final Integer idAnalysis = spectrumServiceQuotes.getAnalysesService().getIdAnalysis(this.sampleData.getSampleId()); + if(Objects.nonNull(idAnalysis)){ + log.warn("{} file analysis data has been stored",new File(this.sampleTempFilePath).getName()); + return; + } DataSourceSwitcher.switchToOracle(); final TransactionStatus transactionStatus = spectrumServiceQuotes.getTransactionManager().getTransaction(spectrumServiceQuotes.getTransactionDefinition()); try{ @@ -312,14 +324,17 @@ public class Sample_B_Analysis implements BlockConstant { * 删除下载的det和gas临时文件 */ private void deleteLocalTemporaryFile(){ - File detFile = new File(this.detTempFilePath); - if(detFile.exists() && detFile.isFile()){ - detFile.delete(); + if(StringUtils.isNotBlank(this.detTempFilePath)){ + File detFile = new File(this.detTempFilePath); + if(detFile.exists() && detFile.isFile()){ + detFile.delete(); + } } - - File gasFile = new File(this.gasTempFilePath); - if(gasFile.exists() && gasFile.isFile()){ - gasFile.delete(); + if(StringUtils.isNotBlank(this.gasTempFilePath)){ + File gasFile = new File(this.gasTempFilePath); + if(gasFile.exists() && gasFile.isFile()){ + gasFile.delete(); + } } } 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 bd021eab..94699301 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,6 +1,7 @@ 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; /** @@ -15,7 +16,7 @@ public class SamplephdSpectrum extends S_D_Q_G_SpectrumHandler{ protected void setChina() { SpectrumHandler spectrumHandler = new DetbkphdSpectrum(); spectrumHandler.initNext(super.spectrumServiceQuotes,super.mailFile, - super.currDataType,super.message,super.emailProperties,super.ftpUtil,super.mailContent); + super.currDataType,super.ftpUtil,super.mailContent); spectrumHandler.setPrevious(this); super.setNext(spectrumHandler); } @@ -26,26 +27,33 @@ public class SamplephdSpectrum extends S_D_Q_G_SpectrumHandler{ @Override protected void handler() throws Exception { if(DataType.SAMPLEPHD.getType().equals(super.currDataType.getType())){ - //前置检查 - this.preCheck(); - //打印当前处理的能谱类型 - super.printCurrDataType(); - //解析邮件内容 - super.parseingEmail(); - //读取邮件内容标签 - super.readFileLabel(); - //保存PHD文件到ftp - super.saveFileToFtp(); - //结构体数据入库 - super.handlerOriginalData(); - //保存email日志 - super.saveEmailLog(); - //把原始库流程日志写入ftp日志文件 - super.saveLogToFtp(); - //进行B、G(P)谱分析 - this.autoAnalysis(); - //删除本地临时文件 - super.deleteLocalTemporaryFile(); + try{ + //前置检查 + this.preCheck(); + //打印当前处理的能谱类型 + super.printCurrDataType(); + //解析邮件内容 + super.parseingEmail(); + //读取邮件内容标签 + super.readFileLabel(); + //保存PHD文件到ftp + super.saveFileToFtp(); + //结构体数据入库 + super.handlerOriginalData(); + //把原始库流程日志写入ftp日志文件 + super.saveLogToFtp(); + //进行B、G(P)谱分析 + this.autoAnalysis(); + }catch (Exception e){ + //修改状态为解析失败 + this.spectrumServiceQuotes.getSampleDataService().updateStatus(SampleStatus.FAIL.getValue(),super.sampleData.getInputFileName()); + //处理解析失败的文件,上传到ftp->undeal目录 + super.handleParseingFailFile(); + throw e; + }finally { + //删除本地临时文件 + super.deleteLocalTemporaryFile(); + } }else{ super.next.handler(); } 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 148e5fc3..e9da4c6b 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 @@ -4,11 +4,9 @@ import cn.hutool.core.io.FileUtil; import com.google.common.collect.Lists; import lombok.extern.slf4j.Slf4j; import org.jeecg.modules.base.enums.DataType; -import org.jeecg.modules.email.EmailProperties; -import org.jeecg.modules.exception.PHD_ReadException; import org.jeecg.modules.ftp.FTPUtils; -import javax.mail.Message; import java.io.File; +import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.List; import java.util.Objects; @@ -22,14 +20,6 @@ public abstract class SpectrumHandler extends Chain{ private final static String DATA_TYPE_PREFIX = "DATA_TYPE "; protected final static String LOG_FILE_SUFFIX = ".log"; - /** - * 当前邮件信息 - */ - protected Message message; - /** - * 邮件属性 - */ - protected EmailProperties emailProperties; /** * 处理能谱数据相关Service引用 */ @@ -63,12 +53,9 @@ public abstract class SpectrumHandler extends Chain{ /** * 初始化参数 */ - protected void init(String mailContent,SpectrumServiceQuotes spectrumServiceQuotes,Message message, - EmailProperties emailProperties,FTPUtils ftpUtil) throws Exception{ + protected void init(String mailContent,SpectrumServiceQuotes spectrumServiceQuotes,FTPUtils ftpUtil) throws Exception{ this.mailContent = mailContent; this.spectrumServiceQuotes = spectrumServiceQuotes; - this.message = message; - this.emailProperties = emailProperties; this.ftpUtil = ftpUtil; } @@ -76,12 +63,10 @@ public abstract class SpectrumHandler extends Chain{ * 初始化参数 */ protected void initNext(SpectrumServiceQuotes spectrumServiceQuotes,File mailFile,DataType currDataType, - Message message,EmailProperties emailProperties,FTPUtils ftpUtil,String mailContent){ + FTPUtils ftpUtil,String mailContent){ this.spectrumServiceQuotes = spectrumServiceQuotes; this.mailFile = mailFile; this.currDataType = currDataType; - this.message = message; - this.emailProperties = emailProperties; this.ftpUtil = ftpUtil; this.mailContent = mailContent; this.setChina(); @@ -153,11 +138,11 @@ public abstract class SpectrumHandler extends Chain{ } /** - * 保存邮件日志到PG数据库 - * @throws Exception + * 处理解析失败的文件,上传到ftp->undeal目录 + * @throws FileNotFoundException */ - protected void saveEmailLog() throws Exception { - this.spectrumServiceQuotes.getMailLogService().create(this.message,this.emailProperties); + protected void handleParseingFailFile() throws FileNotFoundException { + this.ftpUtil.saveFile(spectrumServiceQuotes.getSpectrumPathProperties().getFailPath(),this.mailFile.getName(),new FileInputStream(this.mailFile)); } /** diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SpectrumParsingActuator.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SpectrumParsingActuator.java index f4485823..804d4ded 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SpectrumParsingActuator.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SpectrumParsingActuator.java @@ -1,6 +1,5 @@ package org.jeecg.modules.spectrum; -import cn.hutool.core.io.FileUtil; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.jeecg.common.constant.StringConstant; @@ -10,8 +9,8 @@ import org.jeecg.common.util.DateUtils; import org.jeecg.modules.email.EmailProperties; import org.jeecg.modules.ftp.FTPProperties; import org.jeecg.modules.ftp.FTPUtils; - import javax.mail.Message; +import javax.mail.MessagingException; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeUtility; import java.util.Date; @@ -99,22 +98,28 @@ public class SpectrumParsingActuator implements Runnable{ //判断是否是IMS2.0协议文件 if(checkMailContent(mailContent,subject)){ SpectrumHandler spectrumHandler = new SamplephdSpectrum(); - spectrumHandler.init(mailContent.toString(),spectrumServiceQuotes,message,emailProperties,ftpUtil); + spectrumHandler.init(mailContent.toString(),spectrumServiceQuotes,ftpUtil); final boolean matchResult = spectrumHandler.saveEmailToLocal(); if(matchResult){ + //保存邮件解析日志到PG数据库 + this.spectrumServiceQuotes.getMailLogService().create(message,emailProperties); + //开始解析 spectrumHandler.handler(); }else{ log.warn("此邮件{}匹配失败,不在气象谱、警告谱、健康状态谱、样品谱、探测器本地谱、QC谱、气体谱之列",subject); } } - //删除邮箱中已处理过的邮件 - emailServiceManager.removeMail(message); } catch (Exception e) { log.error(mailContent.toString()); log.error("邮件解析失败,邮件主题为:{},发送时间为:{},接收时间为:{},失败原因为:{}",subject,sendTime,receiveTime,e.getMessage()); - this.handleErrorLog(e); e.printStackTrace(); }finally { + //删除邮箱中已处理过的邮件 + try { + emailServiceManager.removeMail(message); + } catch (MessagingException e) { + e.printStackTrace(); + } this.taskLatch.countDown(); ftpUtil.close(); } @@ -181,13 +186,4 @@ public class SpectrumParsingActuator implements Runnable{ fileName.append(SAVE_EML_SUFFIX); ftpUtil.saveFile(spectrumPathProperties.getEmlPath(),fileName.toString(),message.getInputStream()); } - - /** - * 处理解析报错日志 - * @param e - */ - private void handleErrorLog(Exception e){ - StringBuilder logContent = new StringBuilder(); - - } } 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 da536368..7254da77 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 @@ -1175,7 +1175,7 @@ public class GammaFileUtil { } } - public void UpdateChart(PHDFile phd, Map map){ + public void UpdateChart(PHDFile phd, Map map, Map colorMap){ List m_vCount = new LinkedList<>(); long m_nCount = phd.getSpec().getNum_g_channel(); long m_nSChan = phd.getSpec().getBegin_channel(); @@ -1191,11 +1191,11 @@ public class GammaFileUtil { if(m_nSChan == 0) { m_vCount.add(0L); } - ChartData shadowEnergyChart = this.Energy_Count(phd, m_vCount, m_nCount); - ChartData shadowChannelChart = this.Channel_Count(m_vCount, m_nCount); + 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")); map.put("shadowEnergyChart", shadowEnergyChart); map.put("shadowChannelChart", shadowChannelChart); - List allData = AllData(false, phd, m_vCount, m_nCount); + List allData = AllData(false, phd, m_vCount, m_nCount, colorMap); map.put("allData", allData); List shapeEnergyData = Energy_BaseCP(phd); map.put("shapeEnergyData", shapeEnergyData); @@ -1203,7 +1203,7 @@ public class GammaFileUtil { map.put("shapeChannelData", shapeChannelData); } - public ChartData Energy_Count(PHDFile phd, List m_vCount, long m_nCount){ + public ChartData Energy_Count(PHDFile phd, List m_vCount, long m_nCount, String color){ int start = 0; long end = -1; //Energy @@ -1223,12 +1223,12 @@ public class GammaFileUtil { } data1.setName("Energy"); data1.setGroup("energy"); - data1.setColor("255,255,0"); + data1.setColor(color); } return data1; } - public ChartData Channel_Count(List m_vCount, long m_nCount){ + public ChartData Channel_Count(List m_vCount, long m_nCount, String color){ int start = 1; long end = -1; ChartData data1 = new ChartData(); @@ -1247,12 +1247,12 @@ public class GammaFileUtil { } data1.setName("Count"); data1.setGroup("channel"); - data1.setColor("255,255,0"); + data1.setColor(color); } return data1; } - public List Lc_Scac_base(boolean showLc, PHDFile phd, long m_nCount){ + public List Lc_Scac_base(boolean showLc, PHDFile phd, long m_nCount, Map colorMap){ List datalist = new LinkedList<>(); int start = 0; long end = -1; @@ -1306,26 +1306,26 @@ public class GammaFileUtil { // 颜色:原谱:0;峰:1;Lc:2;BaseLine:3;Scac:4;比较谱:5; data2.setGroup("channel"); data2.setName("Lc"); - data2.setColor("255,0,0"); + data2.setColor(colorMap.get("Color_Lc")); data2.setShow(showLc); data3.setGroup("channel"); data3.setName("Scac"); - data3.setColor("244,112,247"); + data3.setColor(colorMap.get("Color_Scac")); data3.setShow(showLc); data4.setGroup("channel"); data4.setName("BaseLine"); - data4.setColor("0,246,255"); + data4.setColor(colorMap.get("Color_Base")); data6.setGroup("energy"); data6.setName("Lc"); - data6.setColor("255,0,0"); + data6.setColor(colorMap.get("Color_Lc")); data6.setShow(showLc); data7.setGroup("energy"); data7.setName("Scac"); - data7.setColor("244,112,247"); + data7.setColor(colorMap.get("Color_Scac")); data7.setShow(showLc); data8.setGroup("energy"); data8.setName("BaseLine"); - data8.setColor("0,246,255"); + data8.setColor(colorMap.get("Color_Base")); data2.setType("Line"); data3.setType("Line"); data4.setType("Line"); @@ -1342,15 +1342,15 @@ public class GammaFileUtil { return datalist; } - public List Channel_Peak(PHDFile phd, long m_nCount){ - return PeakSet(phd.getVPeak(), phd.getVBase(), m_nCount, null, false); + public List Channel_Peak(PHDFile phd, long m_nCount, String color){ + return PeakSet(phd.getVPeak(), phd.getVBase(), color, m_nCount, null, false); } - public List Energy_Peak(PHDFile phd, long m_nCount){ - return PeakSet(phd.getVPeak(), phd.getVBase(), m_nCount, phd.getUsedEnerPara().getP(), true); + public List Energy_Peak(PHDFile phd, long m_nCount, String color){ + return PeakSet(phd.getVPeak(), phd.getVBase(), color, m_nCount, phd.getUsedEnerPara().getP(), true); } - public List PeakSet(List vPeak, List vBase, long m_nCount, List p, boolean bEnergy){ + public List PeakSet(List vPeak, List vBase, String color, long m_nCount, List p, boolean bEnergy){ System.loadLibrary("GammaAnaly"); List datalist = new LinkedList<>(); int peakNum = vPeak.size(); @@ -1386,7 +1386,7 @@ public class GammaFileUtil { PeakInfo peak = vPeak.get(i); ChartData cData = new ChartData(); - cData.setColor("255,127,39"); + cData.setColor(color); cData.setName("Peak"); List regChan = new LinkedList<>(); @@ -1464,13 +1464,13 @@ public class GammaFileUtil { return shapes; } - public List AllData(boolean showLc, PHDFile phd, List m_vCount, long m_nCount){ + public List AllData(boolean showLc, PHDFile phd, List m_vCount, long m_nCount, Map colorMap){ List datalist = new LinkedList<>(); - datalist.add(Channel_Count(m_vCount, m_nCount)); - datalist.add(Energy_Count(phd, m_vCount, m_nCount)); - datalist.addAll(Lc_Scac_base(showLc, phd, m_nCount)); - datalist.addAll(Channel_Peak(phd, m_nCount)); - datalist.addAll(Energy_Peak(phd, m_nCount)); + datalist.add(Channel_Count(m_vCount, m_nCount, colorMap.get("Color_Spec"))); + datalist.add(Energy_Count(phd, m_vCount, m_nCount, colorMap.get("Color_Spec"))); + datalist.addAll(Lc_Scac_base(showLc, phd, m_nCount, colorMap)); + datalist.addAll(Channel_Peak(phd, m_nCount, colorMap.get("Color_Peak"))); + datalist.addAll(Energy_Peak(phd, m_nCount, colorMap.get("Color_Peak"))); return datalist; } @@ -1864,7 +1864,7 @@ public class GammaFileUtil { return mapLines; } - public ChartData Channel_BaseLine(PHDFile phd, long m_nCount) { + public ChartData Channel_BaseLine(PHDFile phd, long m_nCount, String color) { ChartData cData = new ChartData(); int start =0; long end = -1; @@ -1884,7 +1884,7 @@ public class GammaFileUtil { } cData.setGroup("channel"); cData.setName("BaseLine"); - cData.setColor("0,246,255"); + cData.setColor(color); cData.setType("Line"); } return cData; @@ -2038,7 +2038,7 @@ public class GammaFileUtil { if(CollectionUtils.isNotEmpty(m_curParam.getP())) { // 拟合曲线 ChartData lData = new ChartData(); - lData.setColor("255, 255, 0"); + lData.setColor("rgb(255, 255, 0)"); lData.setType("Line"); List vChan = new LinkedList<>(); @@ -2102,7 +2102,7 @@ public class GammaFileUtil { if(CollectionUtils.isNotEmpty(m_curParam.getP())) { // 拟合曲线 ChartData lData = new ChartData(); - lData.setColor("255, 255, 0"); + lData.setColor("rgb(255, 255, 0)"); lData.setType("Line"); List vChan = new LinkedList<>(); @@ -2235,7 +2235,7 @@ public class GammaFileUtil { if(CollectionUtils.isNotEmpty(m_curParam.getP())) { // 拟合曲线 ChartData lData = new ChartData(); - lData.setColor("255, 255, 0"); + lData.setColor("rgb(255, 255, 0)"); lData.setType("Line"); List vChan = new LinkedList<>(); @@ -3637,13 +3637,13 @@ public class GammaFileUtil { return nuclideList; } - public void InitTable(String name, Map map, PHDFile phd){ + public void InitTable(String name, Map map, PHDFile phd, Map colorMap){ InitNuclideInfo(name, map); long span = phd.getSpec().getG_energy_span(); List nuclideTableList = spectrumAnalysisMapper.getNuclideTable(name, span); if (CollectionUtils.isNotEmpty(nuclideTableList)){ map.put("table", nuclideTableList); - InitChart(nuclideTableList, phd, map); + InitChart(nuclideTableList, phd, map, colorMap); } } @@ -3679,13 +3679,13 @@ public class GammaFileUtil { } } - public void InitChart(List nuclideTableList, PHDFile phd, Map map){ + public void InitChart(List nuclideTableList, PHDFile phd, Map map, Map colorMap){ List> chartList = new LinkedList<>(); for (int i=0; i < nuclideTableList.size(); i++){ Map chartMap = new HashMap<>(); GardsNuclLinesLib item = nuclideTableList.get(i); double energy = item.getEnergy(); - List chartData = Energy_Count_Base(energy, 30, phd); + List chartData = Energy_Count_Base(energy, 30, phd, colorMap); String title = "Line" + (i+1); String bottom = "Abundance:" + item.getYield(); String selPos = energy+""; @@ -3700,7 +3700,7 @@ public class GammaFileUtil { map.put("chart", chartList); } - public List Energy_Count_Base(double energy, int chanNum, PHDFile phd) { + public List Energy_Count_Base(double energy, int chanNum, PHDFile phd, Map colorMap) { List datalist = new LinkedList<>(); int channel = GetChannelByEnergy(energy, 0, phd); int start = channel-chanNum/2, end = channel+chanNum/2; @@ -3711,12 +3711,12 @@ public class GammaFileUtil { end = (int) phd.getSpec().getNum_g_channel(); start = end - chanNum; } - datalist.add(Energy_CountCahrt(start, end, phd)); - datalist.add(Energy_BaseLine(start, end, phd)); + datalist.add(Energy_CountChart(start, end, phd, colorMap.get("Color_Spec"))); + datalist.add(Energy_BaseLine(start, end, phd, colorMap.get("Color_Base"))); return datalist; } - public ChartData Energy_CountCahrt(int start, int end, PHDFile phd) { + public ChartData Energy_CountChart(int start, int end, PHDFile phd, String color) { ChartData data1 = new ChartData(); if(phd.getSpec().getNum_g_channel() > 1 && phd.getVEnergy().size() == phd.getSpec().getNum_g_channel()) { if(start < 1){ @@ -3734,12 +3734,12 @@ public class GammaFileUtil { } data1.setName("Energy"); data1.setGroup("energy"); - data1.setColor("255,255,0"); // 颜色:原谱:0;峰:1;Lc:2;BaseLine:3;Scac:4;比较谱:5; + data1.setColor(color); // 颜色:原谱:0;峰:1;Lc:2;BaseLine:3;Scac:4;比较谱:5; } return data1; } - public ChartData Energy_BaseLine(int start, int end, PHDFile phd) { + public ChartData Energy_BaseLine(int start, int end, PHDFile phd, String color) { ChartData cData = new ChartData(); if(phd.getSpec().getNum_g_channel() > 1 && phd.getVEnergy().size() == phd.getSpec().getNum_g_channel() && phd.getVBase().size() == phd.getSpec().getNum_g_channel()) { if(start < 1){ @@ -3757,7 +3757,7 @@ public class GammaFileUtil { } cData.setGroup("energy"); cData.setName("BaseLine"); - cData.setColor("0,246,255"); + cData.setColor(color); cData.setType("Line"); } return cData; 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 e2141efc..5cfdee78 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 @@ -49,8 +49,8 @@ public class GammaController { } @GetMapping("gammaByDB") - public Result gammaByDB(@RequestParam Integer sampleId, @RequestParam String dbName){ - return gammaService.gammaByDB(dbName, sampleId); + public Result gammaByDB(@RequestParam Integer sampleId, @RequestParam String dbName, HttpServletRequest request){ + return gammaService.gammaByDB(dbName, sampleId, request); } @GetMapping("gammaByFile") @@ -73,8 +73,8 @@ public class GammaController { @GetMapping("InteractiveTool") @ApiOperation(value = "analyze菜单下InteractiveTool页面数据", notes = "analyze菜单下InteractiveTool页面数据") - public Result InteractiveTool(@RequestParam Integer sampleId, @RequestParam String fileName) { - return gammaService.InteractiveTool(sampleId, fileName); + public Result InteractiveTool(@RequestParam Integer sampleId, @RequestParam String fileName, HttpServletRequest request) { + return gammaService.InteractiveTool(sampleId, fileName, request); } @GetMapping("insertPeak") @@ -85,20 +85,20 @@ public class GammaController { @PostMapping("acceptResults") @ApiOperation(value = "InteractiveTool页面Insert页面save", notes = "InteractiveTool页面Insert页面save") - public Result acceptResults(@RequestBody AcceptInfo acceptInfo) { - return gammaService.acceptResults(acceptInfo.getFileName(), acceptInfo.isAccept(), acceptInfo.getOldPeak()); + public Result acceptResults(@RequestBody AcceptInfo acceptInfo, HttpServletRequest request) { + return gammaService.acceptResults(acceptInfo.getFileName(), acceptInfo.isAccept(), acceptInfo.getOldPeak(), request); } @GetMapping("deletePeak") @ApiOperation(value = "InteractiveTool页面delete按钮", notes = "InteractiveTool页面delete按钮") - public Result deletePeak(String fileName, int curRow) { - return gammaService.deletePeak(fileName, curRow); + public Result deletePeak(String fileName, int curRow, HttpServletRequest request) { + return gammaService.deletePeak(fileName, curRow, request); } @GetMapping("getSelPosNuclide") @ApiOperation(value = "InteractiveTool页面选择channel加载对应核素信息接口", notes = "InteractiveTool页面选择channel加载对应核素信息接口") - public Result getSelPosNuclide(Integer sampleId, String fileName, int channel, String nuclides, HttpServletRequest request) { - return gammaService.getSelPosNuclide(sampleId, fileName, channel, nuclides, request); + public Result getSelPosNuclide(Integer sampleId, String fileName, int channel, HttpServletRequest request) { + return gammaService.getSelPosNuclide(sampleId, fileName, channel, request); } @PostMapping("addNuclide") @@ -145,8 +145,8 @@ public class GammaController { @GetMapping("changeNuclide") @ApiOperation(value = "Nuclide Review页面切换nuclide数据", notes = "Nuclide Review页面切换nuclide数据") - public Result changeNuclide(Integer sampleId, String fileName, String nuclideName) { - return gammaService.changeNuclide(sampleId, fileName, nuclideName); + public Result changeNuclide(Integer sampleId, String fileName, String nuclideName, HttpServletRequest request) { + return gammaService.changeNuclide(sampleId, fileName, nuclideName, request); } @GetMapping("searchNuclide") @@ -349,6 +349,24 @@ public class GammaController { return gammaService.viewGammaviewerLog(sampleId, fileName); } + @GetMapping("clickPeakInformation") + @ApiOperation(value = "gamma主页面点击peakInformation返回信息接口", notes = "gamma主页面点击peakInformation返回信息接口") + public Result clickPeakInformation(String fileName, int index) { + return gammaService.clickPeakInformation(fileName, index); + } + + @GetMapping("viewColorConfig") + @ApiOperation(value = "查看颜色配置信息", notes = "查看颜色配置信息") + public Result viewColorConfig(HttpServletRequest request) { + return gammaService.viewColorConfig(request); + } + + @PutMapping("updateColorConfig") + @ApiOperation(value = "修改颜色配置信息", notes = "修改颜色配置信息") + public Result updateColorConfig(@RequestBody ColorInfo colorInfo, HttpServletRequest request) { + return gammaService.updateColorConfig(colorInfo, request); + } + @GetMapping("saveToDB") @ApiOperation(value = "Save To DB按钮", notes = "Save To DB按钮") public Result saveToDB(String fileName, String userName) { diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/ColorInfo.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/ColorInfo.java new file mode 100644 index 00000000..f60183cf --- /dev/null +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/ColorInfo.java @@ -0,0 +1,27 @@ +package org.jeecg.modules.entity.vo; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class ColorInfo implements Serializable { + + private String colorSpec; + + private String colorPeak; + + private String colorLc; + + private String colorBase; + + private String colorScac; + + private String colorCompare; + + private String colorFitbase; + + private String colorStrip; + + +} diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/SpectrumAnalysisMapper.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/SpectrumAnalysisMapper.java index 04819932..a9306dde 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/SpectrumAnalysisMapper.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/SpectrumAnalysisMapper.java @@ -146,6 +146,8 @@ public interface SpectrumAnalysisMapper { void deleteROIResults(Integer idAnalysis); + void insertROIResults(List roiResultsSpectrumList); + String getIdAnalysisByIdAnalyst(@Param(value = "sampleId") String sampleId, @Param(value = "userName") String userName); void deletePeaks(Integer idAnalysis); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/SysUserColorMapper.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/SysUserColorMapper.java new file mode 100644 index 00000000..3613c0d2 --- /dev/null +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/SysUserColorMapper.java @@ -0,0 +1,7 @@ +package org.jeecg.modules.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.jeecg.modules.base.entity.postgre.SysUserColor; + +public interface SysUserColorMapper extends BaseMapper { +} diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/xml/SpectrumAnalysisMapper.xml b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/xml/SpectrumAnalysisMapper.xml index 7276fa95..458b6737 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/xml/SpectrumAnalysisMapper.xml +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/xml/SpectrumAnalysisMapper.xml @@ -931,6 +931,42 @@ DELETE FROM RNMAN.GARDS_ROI_RESULTS WHERE IDANALYSIS=#{idAnalysis} + + + INSERT INTO + RNMAN.GARDS_ROI_RESULTS(SAMPLE_ID, + IDANALYSIS, + ROI, + LC, + S_GROSS, + G_GROSS, + B_GROSS, + S_NET, + G_NET, + NET, + NET_ERR, + CONC, + CONC_ERR, + MDC, + NID_FLAG) + VALUES(#{roiResultsSpectrum.sampleId}, + #{roiResultsSpectrum.idAnalysis}, + #{roiResultsSpectrum.roi}, + #{roiResultsSpectrum.lc}, + #{roiResultsSpectrum.sGross}, + #{roiResultsSpectrum.gGross}, + #{roiResultsSpectrum.bGross}, + #{roiResultsSpectrum.sNet}, + #{roiResultsSpectrum.gNet}, + #{roiResultsSpectrum.net}, + #{roiResultsSpectrum.netErr}, + #{roiResultsSpectrum.conc}, + #{roiResultsSpectrum.concErr}, + #{roiResultsSpectrum.mdc}, + #{roiResultsSpectrum.nidFlag}) + + + 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 2e9cf877..6f29787f 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); - Result gammaByDB(String dbName, Integer sampleId); + Result gammaByDB(String dbName, Integer sampleId, HttpServletRequest request); Result gammaByFile(String fileName, HttpServletRequest request); @@ -21,15 +21,15 @@ public interface IGammaService{ Result Reprocessing(ConfigureData configureData, HttpServletRequest request); - Result InteractiveTool(Integer sampleId, String fileName); + Result InteractiveTool(Integer sampleId, String fileName, HttpServletRequest request); Result insertPeak(Integer sampleId, String fileName, Integer curChan); - Result acceptResults(String fileName, boolean accept, List oldPeak); + Result acceptResults(String fileName, boolean accept, List oldPeak, HttpServletRequest request); - Result deletePeak(String fileName, int curRow); + Result deletePeak(String fileName, int curRow, HttpServletRequest request); - Result getSelPosNuclide(Integer sampleId, String fileName, int channel, String nuclides, HttpServletRequest request); + Result getSelPosNuclide(Integer sampleId, String fileName, int channel, HttpServletRequest request); Result addNuclide(Integer curRow, String nuclideName, String fileName, List list_identify, HttpServletRequest request); @@ -45,7 +45,7 @@ public interface IGammaService{ Result nuclideReview(Integer sampleId, String fileName, Double channel, HttpServletRequest request); - Result changeNuclide(Integer sampleId, String fileName, String nuclideName); + Result changeNuclide(Integer sampleId, String fileName, String nuclideName, HttpServletRequest request); Result searchNuclide(Integer sampleId, String fileName, Double energy, Double tolerance, HttpServletRequest request); @@ -114,6 +114,12 @@ public interface IGammaService{ Result viewGammaviewerLog(Integer sampleId, String fileName); + Result clickPeakInformation(String fileName, int index); + + Result viewColorConfig(HttpServletRequest request); + + Result updateColorConfig(ColorInfo colorInfo, HttpServletRequest request); + Result saveToDB(String fileName, String userName); } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISysUserColorService.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISysUserColorService.java new file mode 100644 index 00000000..5c763476 --- /dev/null +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISysUserColorService.java @@ -0,0 +1,15 @@ +package org.jeecg.modules.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import org.jeecg.modules.base.entity.postgre.SysUserColor; +import org.jeecg.modules.entity.vo.ColorInfo; + +import java.util.Map; + +public interface ISysUserColorService extends IService { + + Map initColor(String userName); + + Map updateColor(ColorInfo colorInfo, String userName); + +} 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 2f30040b..613d9e3b 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 @@ -5,18 +5,16 @@ import cn.hutool.core.collection.ListUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.io.FileUtil; import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ReUtil; 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 com.baomidou.mybatisplus.core.toolkit.StringUtils; +import org.apache.commons.lang3.StringUtils; import com.google.common.cache.Cache; import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPFile; -import org.jeecg.common.Excel.ExportExcel; import org.jeecg.common.api.vo.Result; import org.jeecg.common.cache.LocalCache; import org.jeecg.common.constant.DateConstant; @@ -32,11 +30,8 @@ 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.jeecgframework.poi.excel.ExcelExportUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.core.io.DefaultResourceLoader; -import org.springframework.core.io.Resource; import org.springframework.stereotype.Service; import javax.servlet.ServletOutputStream; @@ -73,6 +68,8 @@ public class GammaServiceImpl implements IGammaService { @Autowired private ISysDefaultNuclideSpectrumService defaultNuclideSpectrumService; @Autowired + private ISysUserColorService sysUserColorService; + @Autowired private SpectrumAnalysisMapper spectrumAnalysisMapper; @Autowired private SpectrumPathProperties spectrumPathProperties; @@ -146,8 +143,9 @@ public class GammaServiceImpl implements IGammaService { } @Override - public Result gammaByDB(String dbName, Integer sampleId) { + public Result gammaByDB(String dbName, Integer sampleId, HttpServletRequest request) { Result result = new Result(); + String userName = JwtUtil.getUserNameByToken(request); Map map = new HashMap<>(); Cache phdCache = localCache.getPHDCache(); PHDFile phd = new PHDFile(); @@ -171,6 +169,8 @@ public class GammaServiceImpl implements IGammaService { if (!bRet){ return result; } + //获取当前角色配置的颜色信息 + Map colorMap = sysUserColorService.initColor(userName); // 更新 ‘QC Flags’ 状态 List qcstate = gammaFileUtil.Qcstate(phd); map.put("QCFlag", qcstate); @@ -183,7 +183,7 @@ 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); + gammaFileUtil.UpdateChart(phd, map, colorMap); phdCache.put(fileName, phd); localCache.setPHDCache(phdCache); result.setSuccess(true); @@ -194,13 +194,16 @@ public class GammaServiceImpl implements IGammaService { @Override public Result gammaByFile(String fileName, HttpServletRequest request) { Result result = new Result(); + String userName = JwtUtil.getUserNameByToken(request); Map map = new HashMap<>(); Cache phdCache = localCache.getPHDCache(); //上传文件路径 - String path = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + JwtUtil.getUserNameByToken(request); + String path = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; PHDFile phd = new PHDFile(); //加载文件内容 gammaFileUtil.loadFile(path, fileName, phd, result); + //获取当前角色的颜色配置 + Map colorMap = sysUserColorService.initColor(userName); // 更新 ‘QC Flags’ 状态 List qcstate = gammaFileUtil.Qcstate(phd); map.put("QCFlag", qcstate); @@ -213,7 +216,7 @@ 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); + gammaFileUtil.UpdateChart(phd, map, colorMap); phdCache.put(fileName, phd); localCache.setPHDCache(phdCache); result.setSuccess(true); @@ -269,6 +272,8 @@ public class GammaServiceImpl implements IGammaService { return result; } String userName = JwtUtil.getUserNameByToken(request); + //获取当前角色的颜色配置 + Map colorMap = sysUserColorService.initColor(userName); //查询当前用户关联的核素信息 List nuclides = new LinkedList<>(); //从postgreSql中获取当前用户关注的核素信息 如果当前用户没有 则返回管理员的 @@ -290,7 +295,7 @@ public class GammaServiceImpl implements IGammaService { phd.getUsedSetting().setRiskLevelK(configureData.getRiskLevelK()); phd.getUsedSetting().setRefTime_act(configureData.getRefTime_act()); phd.getUsedSetting().setRefTime_conc(configureData.getRefTime_conc()); - gammaFileUtil.UpdateChart(phd, map); + gammaFileUtil.UpdateChart(phd, map, colorMap); result.setSuccess(true); result.setResult(map); }else { @@ -303,8 +308,9 @@ public class GammaServiceImpl implements IGammaService { } @Override - public Result InteractiveTool(Integer sampleId, String fileName) { + public Result InteractiveTool(Integer sampleId, String fileName, HttpServletRequest request) { Result result = new Result(); + String userName = JwtUtil.getUserNameByToken(request); Map map = new HashMap<>(); Cache phdCache = localCache.getPHDCache(); PHDFile phd = phdCache.getIfPresent(fileName); @@ -312,6 +318,7 @@ public class GammaServiceImpl implements IGammaService { result.error500("请先选择解析文件!"); return result; } + Map colorMap = sysUserColorService.initColor(userName); //表单 List vPeak = gammaFileUtil.InitPeakTable(phd.getVPeak()); map.put("table", vPeak); @@ -330,9 +337,9 @@ public class GammaServiceImpl implements IGammaService { if(m_nSChan == 0) { m_vCount.add(0L); } - ChartData channelCountChart = gammaFileUtil.Channel_Count(m_vCount, m_nCount); - ChartData channelBaseLineChart = gammaFileUtil.Channel_BaseLine(phd, m_nCount); - List channelPeakChart = gammaFileUtil.Channel_Peak(phd, m_nCount); + ChartData channelCountChart = gammaFileUtil.Channel_Count(m_vCount, m_nCount, colorMap.get("Color_Spec")); + ChartData channelBaseLineChart = gammaFileUtil.Channel_BaseLine(phd, m_nCount, colorMap.get("Color_Base")); + List channelPeakChart = gammaFileUtil.Channel_Peak(phd, m_nCount, colorMap.get("Color_Peak")); List channelBaseCPChart = gammaFileUtil.Channel_BaseCP(phd); map.put("channelCountChart", channelCountChart); map.put("channelBaseLineChart", channelBaseLineChart); @@ -485,8 +492,9 @@ public class GammaServiceImpl implements IGammaService { } @Override - public Result acceptResults(String fileName, boolean accept, List oldPeak) { + public Result acceptResults(String fileName, boolean accept, List oldPeak, HttpServletRequest request) { Result result = new Result(); + String userName = JwtUtil.getUserNameByToken(request); Cache phdCache = localCache.getPHDCache(); PHDFile phd = phdCache.getIfPresent(fileName); if (Objects.isNull(phd)){ @@ -496,7 +504,8 @@ public class GammaServiceImpl implements IGammaService { List m_vCount = new LinkedList<>(); long m_nCount = phd.getSpec().getNum_g_channel(); long m_nSChan = phd.getSpec().getBegin_channel(); - + //获取当前角色的颜色配置 + Map colorMap = sysUserColorService.initColor(userName); // 确保绘制曲线时所有谱都是从1道开始 int i = 0; if(m_nSChan == 0){ @@ -516,19 +525,19 @@ public class GammaServiceImpl implements IGammaService { List vPeak = gammaFileUtil.InitPeakTable(phd.getVPeak()); map.put("table", vPeak); - List channelPeak = gammaFileUtil.Channel_Peak(phd, m_nCount); + List channelPeak = gammaFileUtil.Channel_Peak(phd, m_nCount, colorMap.get("Color_Peak")); map.put("channelPeakChart", channelPeak); - ChartData channelBaseLine = gammaFileUtil.Channel_BaseLine(phd, m_nCount); + ChartData channelBaseLine = gammaFileUtil.Channel_BaseLine(phd, m_nCount, colorMap.get("Color_Base")); map.put("channelBaseLineChart", channelBaseLine); List differance = gammaFileUtil.Differance(phd, phd.getVPeak(), m_vCount, m_nCount); map.put("barChart", differance); - gammaFileUtil.UpdateChart(phd, map); + gammaFileUtil.UpdateChart(phd, map, colorMap); } else {//如果不保留 根据下标移除对应的vPeak数据 if (CollectionUtils.isNotEmpty(oldPeak)) { phd.getVPeak().clear(); phd.setVPeak(oldPeak); map.put("table", phd.getVPeak()); - List channelPeak = gammaFileUtil.Channel_Peak(phd, m_nCount); + List channelPeak = gammaFileUtil.Channel_Peak(phd, m_nCount, colorMap.get("Color_Peak")); map.put("channelPeakChart", channelPeak); } } @@ -538,14 +547,16 @@ public class GammaServiceImpl implements IGammaService { } @Override - public Result deletePeak(String fileName, int curRow) { + public Result deletePeak(String fileName, int curRow, 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; } + Map colorMap = sysUserColorService.initColor(userName); long m_nCount = phd.getSpec().getNum_g_channel(); HashMap map = new HashMap<>(); int peakNum = phd.getVPeak().size(); @@ -563,9 +574,9 @@ public class GammaServiceImpl implements IGammaService { } List vPeak = gammaFileUtil.InitPeakTable(phd.getVPeak()); map.put("table", vPeak); - List channelPeak = gammaFileUtil.Channel_Peak(phd, m_nCount); + List channelPeak = gammaFileUtil.Channel_Peak(phd, m_nCount, colorMap.get("Color_Peak")); map.put("channelPeakChart", channelPeak); - gammaFileUtil.UpdateChart(phd, map); + gammaFileUtil.UpdateChart(phd, map, colorMap); } result.setSuccess(true); result.setResult(map); @@ -573,9 +584,9 @@ public class GammaServiceImpl implements IGammaService { } @Override - public Result getSelPosNuclide(Integer sampleId, String fileName, int channel, String nuclides, HttpServletRequest request) { + public Result getSelPosNuclide(Integer sampleId, String fileName, int channel, HttpServletRequest request) { Result result = new Result(); - Map> map = new HashMap<>(); + Map map = new HashMap<>(); String userName = JwtUtil.getUserNameByToken(request); Cache phdCache = localCache.getPHDCache(); PHDFile phd = phdCache.getIfPresent(fileName); @@ -598,11 +609,10 @@ public class GammaServiceImpl implements IGammaService { double min = phd.getVPeak().get(index).energy - phd.getSetting().getEnergyTolerance(); double max = phd.getVPeak().get(index).energy + phd.getSetting().getEnergyTolerance(); List list_possible = spectrumAnalysisMapper.getPossibleNuclide(userLib, min, max); + //用户当前已选中的核素名称 + List list_identify = phd.getVPeak().get(index).nuclides; - List list_identify = new LinkedList<>(); - List identify = Arrays.asList(nuclides.split(";")); - list_identify.addAll(identify); - + map.put("index", index); map.put("possible", list_possible); map.put("identify", list_identify); result.setSuccess(true); @@ -779,6 +789,7 @@ public class GammaServiceImpl implements IGammaService { result.error500("请先选择解析文件!"); return result; } + Map colorMap = sysUserColorService.initColor(userName); double value = gammaFileUtil.GetEnergyByFloatChan(phd, channel.intValue()); BigDecimal bigDecimal = BigDecimal.valueOf(value); bigDecimal = bigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP); @@ -794,7 +805,7 @@ public class GammaServiceImpl implements IGammaService { if(CollectionUtils.isNotEmpty(nuclideList)) { map.put("list", nuclideList); String name = nuclideList.get(0); - gammaFileUtil.InitTable(name, map, phd); + gammaFileUtil.InitTable(name, map, phd, colorMap); } else { map.put("list", nuclideList); map.put("chart", new LinkedList<>()); @@ -810,8 +821,9 @@ public class GammaServiceImpl implements IGammaService { } @Override - public Result changeNuclide(Integer sampleId, String fileName, String nuclideName) { + public Result changeNuclide(Integer sampleId, String fileName, String nuclideName, HttpServletRequest request) { Result result = new Result(); + String userName = JwtUtil.getUserNameByToken(request); Map map = new HashMap<>(); Cache phdCache = localCache.getPHDCache(); PHDFile phd = phdCache.getIfPresent(fileName); @@ -819,7 +831,8 @@ public class GammaServiceImpl implements IGammaService { result.error500("请先选择解析文件!"); return result; } - gammaFileUtil.InitTable(nuclideName, map, phd); + Map colorMap = sysUserColorService.initColor(userName); + gammaFileUtil.InitTable(nuclideName, map, phd, colorMap); result.setSuccess(true); result.setResult(map); return result; @@ -836,6 +849,7 @@ public class GammaServiceImpl implements IGammaService { result.error500("请先选择解析文件!"); return result; } + Map colorMap = sysUserColorService.initColor(userName); BigDecimal bigDecimal = BigDecimal.valueOf(energy); bigDecimal = bigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP); map.put("energy", bigDecimal); @@ -850,7 +864,7 @@ public class GammaServiceImpl implements IGammaService { if(CollectionUtils.isNotEmpty(nuclideList)) { map.put("list", nuclideList); String name = nuclideList.get(0); - gammaFileUtil.InitTable(name, map, phd); + gammaFileUtil.InitTable(name, map, phd, colorMap); } else { map.put("list", nuclideList); map.put("chart", new LinkedList<>()); @@ -1616,15 +1630,7 @@ public class GammaServiceImpl implements IGammaService { tablePeak.setAreaErr(peak.area>0?String.format("%.3f",(peak.areaErr/peak.area)*100):"0"); tablePeak.setSignificant(String.format("%.3f", peak.significance)); tablePeak.setSensitivity(String.format("%.3f", peak.sensitivity)); - List nuclides = peak.nuclides; - String nuclide = ""; - if (CollectionUtils.isNotEmpty(nuclides)){ - for (String name:nuclides) { - nuclide+=name+StringPool.COMMA; - } - nuclide = nuclide.substring(0, nuclide.length()-1); - } - tablePeak.setIndentify(nuclide); + tablePeak.setIndentify(StringUtils.join(peak.nuclides, ";")); tablePeaks.add(tablePeak); } } @@ -2226,6 +2232,50 @@ public class GammaServiceImpl implements IGammaService { return result; } + @Override + public Result clickPeakInformation(String fileName, int index) { + Result result = new Result(); + Cache phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(fileName); + if (Objects.isNull(phd)){ + result.error500("请先选择解析文件!"); + return result; + } + int size = phd.getVPeak().size(); + //vPeak的数组大小大于0 当前下标在范围内 + if (size>0 && index=0) { + PeakInfo peak = phd.getVPeak().get(index); + String message = "Peak:"+String.format("%.2f", peak.peakCentroid)+" = "+String.format("%.2f", peak.energy)+" keV\n" + + "FWHM:"+String.format("%.2f", peak.fwhmc)+" keV\n" + + "Net Area:"+String.format("%.2f", peak.area)+"\n" + + "BaseLine:"+String.format("%.2f", phd.getVBase().get((int) Math.round(peak.peakCentroid)))+"\n" + + "NID:"+ StringUtils.join(peak.nuclides, ";"); + result.setSuccess(true); + result.setResult(message); + } + return result; + } + + @Override + public Result viewColorConfig(HttpServletRequest request) { + Result result = new Result(); + String userName = JwtUtil.getUserNameByToken(request); + Map colorMap = sysUserColorService.initColor(userName); + result.setSuccess(true); + result.setResult(colorMap); + return result; + } + + @Override + public Result updateColorConfig(ColorInfo colorInfo, HttpServletRequest request) { + Result result = new Result(); + String userName = JwtUtil.getUserNameByToken(request); + Map colorMap = sysUserColorService.updateColor(colorInfo, userName); + result.setSuccess(true); + result.setResult(colorMap); + return result; + } + @Override public Result saveToDB(String fileName, String userName) { Result result = new Result(); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java index b6dcd54b..a75eca23 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java @@ -253,7 +253,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { result.error500("ftp文件查询失败"); return result; } - String sampleFileName = fileName; + String sampleFileName = matchFileName; String sampleSystemType = fileData.get("sampleSystemType"); if (sampleSystemType.equals(SystemType.BETA.getType())) { //加载并获取当前路径下所有的文件名称并进行名称格式化 仅需要格式化和sample文件同一个台站 名称格式化为最终名称 @@ -2532,10 +2532,13 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { Double mdc = xeData.getMdc(); if (conc < 0){ xeData.setColor("red"); + xeData.setNidFlag(0); } else if (0 mdc) { xeData.setColor("green"); + xeData.setNidFlag(1); } } map.put("XeData", xeDataList); @@ -2603,10 +2606,13 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { Double mdc = xeData.getMdc(); if (conc < 0){ xeData.setColor("red"); + xeData.setNidFlag(0); } else if (0 mdc) { xeData.setColor("green"); + xeData.setNidFlag(1); } } map.put("XeData", xeDataList); @@ -2623,6 +2629,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { @Override public Result saveToDB(BgDataAnlyseResultIn anlyseResultIn) { Result result = new Result(); + Map map = new HashMap<>(); String beginDate = DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss"); String endDate = DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss"); //判断当前分析员是否有过排班任务 @@ -2636,29 +2643,35 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { getChannelAndEnergy(anlyseResultIn); //获取ROI Limit数据 // getROILimit(anlyseResultIn); - //计算得到各文件的边界值 - BgBoundary sampleBoundary = phdFileUtil.CalBoundary(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName()); - BgBoundary gasBoundary = phdFileUtil.CalBoundary(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName()); - BgBoundary detBoundary = phdFileUtil.CalBoundary(anlyseResultIn.getDetFilePath(), anlyseResultIn.getDetFileName()); //处理文件名称 String sampleFilePathName = phdFileUtil.NameStandardBy(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName()); String gasFilePathName = phdFileUtil.NameStandardBy(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName()); String detFilePathName = phdFileUtil.NameStandardBy(anlyseResultIn.getDetFilePath(), anlyseResultIn.getDetFileName()); //判断文件是否存储过 如果没有则解析文件并进行存储 if ( !OriginalDataStore(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName(), gasFilePathName, anlyseResultIn.getUserName()) ){ - result.error500("file save failed"); + result.error500("gasFile save failed"); return result; } if ( !OriginalDataStore(anlyseResultIn.getDetFilePath(), anlyseResultIn.getGasFileName(), detFilePathName, anlyseResultIn.getUserName()) ){ - result.error500("file save failed"); + result.error500("detFile save failed"); return result; } if ( !OriginalDataStore(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName(), sampleFilePathName, anlyseResultIn.getUserName()) ){ - result.error500("file save failed"); + result.error500("sampleFile save failed"); return result; } //判断当前分析员是否有过历史分析当前文件 Integer isExist = spectrumAnalysisMapper.SampleIsExist(sampleFilePathName, anlyseResultIn.getUserName()); + //获取sample,gas,det对应的临时文件 + File sampleTmp = phdFileUtil.analyzeFile(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName()); + File gasTmp = phdFileUtil.analyzeFile(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName()); + File detTmp = phdFileUtil.analyzeFile(anlyseResultIn.getDetFilePath(), anlyseResultIn.getDetFileName()); + if (Objects.isNull(sampleTmp) || Objects.isNull(gasTmp) || Objects.isNull(detTmp)) { + result.error500("ftp文件获取失败!"); + return result; + } + //解析文件内容获取对应数据 + BgDataAnlyseResultIn resultIn = phdFileUtil.analyzeSpectrum(sampleTmp, gasTmp, detTmp, map); //根据文件名称查询对应的sampleId--- sampleFile gasFile detFile Integer sampleId = spectrumAnalysisMapper.getSampleId(sampleFilePathName); Integer gasId = spectrumAnalysisMapper.getSampleId(gasFilePathName); @@ -2678,79 +2691,88 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { gardsAnalyses.setUsedgasphdId(gasId); gardsAnalyses.setUseddetphdId(detId); gardsAnalyses.setAnalyst(anlyseResultIn.getUserName()); + map.put("gardsAnalyses", gardsAnalyses); if (Objects.nonNull(isExist)){ - spectrumAnalysisMapper.updateGardsAnalyses(gardsAnalyses); + //spectrumAnalysisMapper.updateGardsAnalyses(gardsAnalyses); }else {//如果没有分析过就新增--GARDS_ANALYSES - spectrumAnalysisMapper.insertGardsAnalyses(gardsAnalyses); + //spectrumAnalysisMapper.insertGardsAnalyses(gardsAnalyses); } //查询analysisId根据sampleId 分析员名称--GARDS_ANALYSES GardsAnalysesSpectrum analysis = spectrumAnalysisMapper.getAnalysis("RNMAN.GARDS_ANALYSES", sampleId); Integer idAnalysis = analysis.getIdAnalysis(); //获取sample,gas,det三个文件分别对应的beta,gamma数据集合 List calibrationPairsList = getCalibrationPairs(anlyseResultIn, sampleId, gasId, detId, idAnalysis); + map.put("calibrationPairsList", calibrationPairsList); //如果分析过--删除GARDS_CALIBRATION_PAIRS表数据 新增GARDS_CALIBRATION_PAIRS表数据 if (Objects.nonNull(isExist)){ //根据idAnalysis删除GARDS_CALIBRATION_PAIRS表数据 - spectrumAnalysisMapper.deleteCalibrationPairs(idAnalysis); + //spectrumAnalysisMapper.deleteCalibrationPairs(idAnalysis); //新增GARDS_CALIBRATION_PAIRS表数据 - spectrumAnalysisMapper.insertCalibrationPairs(calibrationPairsList); + //spectrumAnalysisMapper.insertCalibrationPairs(calibrationPairsList); }else {//如果没有分析过--新增GARDS_CALIBRATION_PAIRS表数据 //新增GARDS_CALIBRATION_PAIRS表数据 - spectrumAnalysisMapper.insertCalibrationPairs(calibrationPairsList); + //spectrumAnalysisMapper.insertCalibrationPairs(calibrationPairsList); } //gards_calibration 数据表 List calibrationList = getCalibration(anlyseResultIn, sampleId, gasId, detId, idAnalysis); + map.put("calibrationList", calibrationList); //判断是否分析过 if (Objects.nonNull(isExist)) { //删除Gards_Calibration表数据 - spectrumAnalysisMapper.deleteCalibration(idAnalysis); + //spectrumAnalysisMapper.deleteCalibration(idAnalysis); //新增数据 - spectrumAnalysisMapper.insertCalibration(calibrationList); + //spectrumAnalysisMapper.insertCalibration(calibrationList); } else { //新增数据 - spectrumAnalysisMapper.insertCalibration(calibrationList); + //spectrumAnalysisMapper.insertCalibration(calibrationList); } //gards_roi_channels数据表 List roiChannelsList = new LinkedList<>(); - getROIChannel(sampleId, idAnalysis, sampleBoundary, roiChannelsList); - getROIChannel(gasId, idAnalysis, gasBoundary, roiChannelsList); - getROIChannel(detId, idAnalysis, detBoundary, roiChannelsList); + List roiChannelsSpectrumList = (List) map.get("roiChannelsSpectrumList"); + getROIChannel(sampleId, idAnalysis, roiChannelsSpectrumList, roiChannelsList); + getROIChannel(gasId, idAnalysis, roiChannelsSpectrumList, roiChannelsList); + getROIChannel(detId, idAnalysis, roiChannelsSpectrumList, roiChannelsList); + map.put("roiChannelsList", roiChannelsList); //如果分析过数据 if (Objects.nonNull(isExist)){ //删除gards_roi_channels数据表数据 - spectrumAnalysisMapper.deleteROIChannels(idAnalysis); + //spectrumAnalysisMapper.deleteROIChannels(idAnalysis); //新增gards_roi_channels数据表数据 - spectrumAnalysisMapper.insertROIChannels(roiChannelsList); + //spectrumAnalysisMapper.insertROIChannels(roiChannelsList); }else {//没有分析过 //新增gards_roi_channels数据表数据 - spectrumAnalysisMapper.insertROIChannels(roiChannelsList); + //spectrumAnalysisMapper.insertROIChannels(roiChannelsList); } //gards_Xe_results数据表 List xeResults = getXeResults(anlyseResultIn, sampleId, idAnalysis); + map.put("xeResults", xeResults); if(Objects.nonNull(isExist)) { //删除gards_Xe_results数据表数据 - spectrumAnalysisMapper.deleteXeResult(idAnalysis); + //spectrumAnalysisMapper.deleteXeResult(idAnalysis); //新增gards_Xe_results数据表数据 - spectrumAnalysisMapper.insertXeResult(xeResults); + //spectrumAnalysisMapper.insertXeResult(xeResults); } else { //新增gards_Xe_results数据表数据 - spectrumAnalysisMapper.insertXeResult(xeResults); + //spectrumAnalysisMapper.insertXeResult(xeResults); } //gards_roi_results数据表 List roiResultsSpectrumList = getROIResult(anlyseResultIn, sampleId, idAnalysis, isExist); + map.put("roiResultsSpectrumList", roiResultsSpectrumList); if(Objects.nonNull(isExist)) { //删除gards_roi_results数据表数据 - spectrumAnalysisMapper.deleteROIResults(idAnalysis); + //spectrumAnalysisMapper.deleteROIResults(idAnalysis); //新增gards_roi_results数据表数据 - + //spectrumAnalysisMapper.insertROIResults(roiResultsSpectrumList); } else { //新增gards_roi_results数据表数据 - + //spectrumAnalysisMapper.insertROIResults(roiResultsSpectrumList); } + result.setSuccess(true); + result.setResult(map); return result; } - public void getChannelAndEnergy(BgDataAnlyseResultIn anlyseResultIn){ + public void getChannelAndEnergy(BgDataAnlyseResultIn anlyseResultIn) { //获取ftp文件路径下临时文件 File sampleTmp = phdFileUtil.analyzeFile(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName()); File gasTmp = phdFileUtil.analyzeFile(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName()); @@ -2958,7 +2980,6 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { uncertaintyList.add(String.valueOf(uncertainty.get(pos))); } } - } public List getCalibration(BgDataAnlyseResultIn anlyseResultIn, Integer sampleId, Integer gasId, Integer detId, Integer idAnalysis) { @@ -3052,16 +3073,16 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { return calibrationSpectrumList; } - public void getROIChannel(Integer sampleId, Integer idAnalysis, BgBoundary bgBoundary, List roiChannelsList) { - for (int i=0; i roiChannelsSpectrumList, List roiChannelsList) { + for (int i=0; i readLines = getFileBlockList(file); - //根据新的文件路径名称查询数据是否存在 - Integer isExist = spectrumAnalysisMapper.SampleIsExist(filePathName, userName); - //如果数据已经存入过数据库 则 修改状态后返回 - if (Objects.nonNull(isExist)){ - //如果文件已经存入过数据库则修改状态 - spectrumAnalysisMapper.updateAnalysesStatus(filePathName); - return true; - } //查询台站id Integer stationId = spectrumAnalysisMapper.getStationId(sourceData.site_code); Integer detectorId = spectrumAnalysisMapper.getDetectorId(sourceData.detector_code); @@ -3237,35 +3258,28 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { public List getROIResult(BgDataAnlyseResultIn anlyseResultIn, Integer sampleId, Integer idAnalysis, Integer isExist) { List roiResultsSpectrumList = new LinkedList<>(); - //第一种 直接从数据库获取的 并没有进行过改变 - if (Objects.nonNull(isExist) && !anlyseResultIn.isBProcessed()) { - for (int i=0; ianlyseResultIn.getMDC().get(i)) { - roiResults.setNidFlag(1); - } else { - roiResults.setNidFlag(0); - } - roiResultsSpectrumList.add(roiResults); + for (int i=0; ianlyseResultIn.getMDC().get(i)) { + roiResults.setNidFlag(1); + } else { + roiResults.setNidFlag(0); } - } else if (Objects.nonNull(isExist) && anlyseResultIn.isBProcessed()) {//第二种 从数据库获取的但是进行过改变 - - } else if (Objects.isNull(isExist) && anlyseResultIn.isBProcessed()) {//第三种 文件加载的数据 - + roiResultsSpectrumList.add(roiResults); } return roiResultsSpectrumList; } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SysUserColorServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SysUserColorServiceImpl.java new file mode 100644 index 00000000..0a3da6d2 --- /dev/null +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SysUserColorServiceImpl.java @@ -0,0 +1,85 @@ +package org.jeecg.modules.service.impl; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.IdWorker; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.jeecg.modules.base.entity.postgre.SysUserColor; +import org.jeecg.modules.entity.vo.ColorInfo; +import org.jeecg.modules.mapper.SysUserColorMapper; +import org.jeecg.modules.service.ISysUserColorService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +@Service("sysUserColorService") +@DS("master") +public class SysUserColorServiceImpl extends ServiceImpl implements ISysUserColorService { + + @Override + @Transactional(propagation = Propagation.REQUIRES_NEW) + public Map initColor(String userName) { + Map map = new HashMap<>(); + //查询数据库是否存在当前用户名的颜色数据 如果存在返回查询结果 如果不存在初始化当前用户的颜色信息 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(SysUserColor::getCreateBy, userName); + SysUserColor userColor = this.baseMapper.selectOne(queryWrapper); + if (Objects.isNull(userColor)) { + userColor = new SysUserColor(); + userColor.setId(String.valueOf(IdWorker.getId())); + userColor.setColorSpec("yellow"); + userColor.setColorPeak("rgb(255, 127, 39)"); + userColor.setColorLc("red"); + userColor.setColorBase("rgb(0, 246, 255)"); + userColor.setColorScac("rgb(244, 112, 247)"); + userColor.setColorCompare("green"); + userColor.setColorFitbase("white"); + userColor.setColorStrip("blue"); + userColor.setCreateBy(userName); + this.baseMapper.insert(userColor); + } + map.put("Color_Spec", userColor.getColorSpec()); + map.put("Color_Peak", userColor.getColorPeak()); + map.put("Color_Lc", userColor.getColorLc()); + map.put("Color_Base", userColor.getColorBase()); + map.put("Color_Scac", userColor.getColorScac()); + map.put("Color_Compare", userColor.getColorCompare()); + map.put("Color_Fitbase", userColor.getColorFitbase()); + map.put("Color_Strip", userColor.getColorStrip()); + return map; + } + + @Override + @Transactional(propagation = Propagation.REQUIRES_NEW) + public Map updateColor(ColorInfo colorInfo, String userName) { + Map map = new HashMap<>(); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(SysUserColor::getCreateBy, userName); + SysUserColor userColor = this.baseMapper.selectOne(queryWrapper); + if (Objects.nonNull(userColor)) { + userColor.setColorSpec(colorInfo.getColorSpec()); + userColor.setColorPeak(colorInfo.getColorPeak()); + userColor.setColorLc(colorInfo.getColorLc()); + userColor.setColorBase(colorInfo.getColorBase()); + userColor.setColorScac(colorInfo.getColorScac()); + userColor.setColorCompare(colorInfo.getColorCompare()); + userColor.setColorFitbase(colorInfo.getColorFitbase()); + userColor.setColorStrip(colorInfo.getColorStrip()); + this.baseMapper.updateById(userColor); + } + map.put("Color_Spec", userColor.getColorSpec()); + map.put("Color_Peak", userColor.getColorPeak()); + map.put("Color_Lc", userColor.getColorLc()); + map.put("Color_Base", userColor.getColorBase()); + map.put("Color_Scac", userColor.getColorScac()); + map.put("Color_Compare", userColor.getColorCompare()); + map.put("Color_Fitbase", userColor.getColorFitbase()); + map.put("Color_Strip", userColor.getColorStrip()); + return map; + } + +}