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 1f2a8055..9c7155ff 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 @@ -46,6 +46,11 @@ public class SpectrumPathProperties implements Serializable { */ private String failPath; + /** + * 手动放置能谱文件获取路径 + */ + private String filesourcePath; + /** * 能谱文件存储路径以能谱系统类型/能谱类型为key,以存储路径为value */ diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/TaskProperties.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/TaskProperties.java index f8789796..8882bbca 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/TaskProperties.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/TaskProperties.java @@ -23,17 +23,37 @@ public class TaskProperties implements Serializable { /** * 监测数据库邮箱数据变化周期 */ - private Long monitoringMailDataCycle; + private Integer monitoringMailDataCycle; /** * 监测邮箱通信状态周期 */ - private Long monitoringMailCommStatusCycle; + private Integer monitoringMailCommStatusCycle; /** * 获取邮箱邮件线程执行周期 */ - private Long mailThreadExecCycle; + private Integer mailThreadExecCycle; + + /** + * undeal目录文件获取周期 + */ + private Integer undealDirExecCycle; + + /** + * undeal目录单次获取文件数量 + */ + private Integer undealDirReceiveNum; + + /** + * filesource目录文件获取周期 + */ + private Integer filesourceDirExecCycle; + + /** + * filesource目录单次获取文件数量 + */ + private Integer filesourceDirReceiveNum; /** * 邮件附件临时存储路径 diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/MyLogFormatUtil.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/MyLogFormatUtil.java new file mode 100644 index 00000000..ea298212 --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/MyLogFormatUtil.java @@ -0,0 +1,388 @@ +package org.jeecg.common.util; + +import cn.hutool.core.lang.Console; +import com.google.common.collect.Lists; +import lombok.Data; +import org.jeecg.modules.base.bizVo.AttributeItemVo; + +import java.util.*; + +@Data +public class MyLogFormatUtil { + public List energyAttribute; + public List efficiencyAttribute; + public List resolutionAttribute; + public List totalEfficiencyAttribute; + /** + * 标题长度 + */ + public static Integer CONTEXT_TITLE_SIZE = 100; + /** + * 页眉长度 + */ + public static Integer CONTEXT_HEADER_SIZE = 5; + /** + * . + */ + public static String CONTEXT_TITLE_FLAG = "."; + /** + * - + */ + public static String FILE_TITLE_FLAG = "-"; + public static String STRING_END = "\n"; + + /** + * 自动处理 log 开始 + */ + public static final String analyseResultsBegin = "Sample Analyse Beginning at %1"; + /** + * 自动处理 log 开始 + */ + public static final String analyseResultsEnd = "Sample Analyse Successfully at %1"; + /** + * 读取 calibration 开始 + */ + public static final String titleCalibrationIdEnd = "Read calibration finished"; + /** + * 读取 calibration 结束 + */ + public static final String titleCalibration = "Read calibration data"; + + /**************************************** Beta ****************************************/ + + /** + * 获取 det 和 gas 开头 + */ + public static final String BTitleId = "Get DetaId and GasId"; + /** + * 获取 det 和 gas 结束 + */ + public static final String BTitleIdEnd = "Get DetaId and GasId finished"; + + + /**************************************** Gamma ****************************************/ + + + // Reading sample beta energy pairs(sampleID: 478827)..... + public static final String SetSampleBEnergyChannel = "Reading sample beta energy pairs(sampleID: %1)"; + // Reading gamma energy pairs(sampleID: 478660)..... + public static final String SetSampleGEnergyChannel = "Reading sample gamma energy pairs(sampleID: %1)"; + + public static final String SetDetaBEnergyChannel = "Reading DETBK Spectrum beta energy pairs(sampleID: %1)"; + public static final String SetDetaGEnergyChannel = "Reading DETBK Spectrum gamma energy pairs(sampleID: %1)"; + + public static final String SetGasBEnergyChannel = "Reading GASBK Spectrum beta energy pairs(sampleID: %1)"; + public static final String SetGasGEnergyChannel = "Reading GASBK Spectrum gamma energy pairs(sampleID: %1)"; + + public static final String GetMeasurementTime = "Reading mesurement information"; + public static final String GetVolume = "Reading volume data"; + + public static final String SetRoiLimits = "Reading ROI limits"; + public static final String SetRoiRatios = "Reading ROI ratios"; + public static final String SetDetectorEfficiencies = "Reading b-g Efficiency"; + public static final String SetBoundary = "Limits per ROI (SampleID:%1)"; + public static final String SetGrossCounts = "Gross counts per ROI"; + public static final String SetNetCounts = "Net counts and Lc per ROI"; +// public static final String SetConcentrationMdc = "Concentration and MDC per ROI"; + public static final String SetConcentrationMdc = "Concentration and MDC per isotope"; + public static final String TitleNCC = "Starting NCC analysis"; + public static final String TitleNCCEnd = "NCC analysis finished"; + + + public static final String GSetSampleEnergyChannel = "Reading gamma energy pairs(sampleID: %1)"; + public static final String GSetSampleResolutionChannel = "Reading gamma Resolution pairs(sampleID: %1)"; + public static final String GSetSampleEfficiencyChannel = "Reading gamma Efficiency pairs(sampleID: %1)"; + public static final String GSetSampleTotalEfficiencyChannel = "Reading gamma TotalEfficiency pairs(sampleID: %1)"; + public static final String sampleInfo = "Reading sample information"; + public static final String GTitleCalibration = "Starting Calibration"; + public static final String GTitleCalibrationEnd = "Calibration Finished"; + public static final String GTitleSpectrum = "Starting Spectrum Analysis"; + public static final String GTitleSpectrumEnd = "Spectrum Analysis Finished"; + public static final String GGetPROCESSING = "PROCESSING PARAMETERS"; + public static final String GGetCALIBRATION = "CALIBRATION PARAMETERS"; + public static final String GGetPeakSearchResult = "Nuclide Identified"; + public static final String GGetDataQuality = "Starting Data Quality"; + + + public static List getBlock(String title, String sampleId, List attributeItemVo) { + title = title.replace("%1", sampleId); + List context = getBlockContext(attributeItemVo); + context.add(0, title + STRING_END); + return context; + } + + public static void main(String[] args) { + Map data = new LinkedHashMap<>(); + data.put("Collection Start", "2023/09/11 01:20:24"); + data.put("Collection Stop", "2023/09/12 01:12:44"); + data.put("Sampling Time[h]", 23.8722); + data.put("Sample Quantity[m3]", 22825); + data.put("Decay Time[h]", 24.2167); + data.put("Acquisition Start", "2023/09/13 01:25:45"); + data.put("Acquisition Stop", "2023/09/14 01:05:17"); + data.put("Acquisition Time[s]", 85435); + + int keyWidth = 20; + int valueWidth = 25; + + getBlockContext(data); + Console.log(getTitleFormat("title",".")); + Console.log(getHeaderFormat("header",".")); + + + List channels = Arrays.asList("59.541", "88.034", "122.061", "165.857", "391.698", "661.657", "834.838", "898.036", "1115.540", "1173.230", "1332.490", "1836.050"); + List energies = Arrays.asList("0.168", "0.176", "0.174", "0.155", "0.092", "0.059", "0.051", "0.040", "0.040", "0.031", "0.028", "0.022"); + List errors = Arrays.asList("0.003", "0.004", "0.003", "0.003", "0.002", "0.001", "0.001", "0.001", "0.001", "0.001", "0.001", "0.000"); + + List energys = new ArrayList<>(); + AttributeItemVo attributeItemVo = new AttributeItemVo(); + attributeItemVo.setAttribute("Channel"); + attributeItemVo.setContext(channels); + energys.add(attributeItemVo); + attributeItemVo = new AttributeItemVo(); + attributeItemVo.setAttribute("Energy"); + attributeItemVo.setContext(energies); + energys.add(attributeItemVo); + attributeItemVo = new AttributeItemVo(); + attributeItemVo.setAttribute("Error"); + attributeItemVo.setContext(errors); + energys.add(attributeItemVo); + MyLogFormatUtil.getBlock(MyLogFormatUtil.SetSampleGEnergyChannel, "sampleId", energys); + + + // 报告 + List> report = Lists.newLinkedList(); + report.add(channels); + report.add(energies); + report.add(errors); + getBlockVerticalContext(energys); + +// List data = new ArrayList<>(); +// AttributeItem attributeItem = new AttributeItem(); +// attributeItem.setAttribute("channel"); +// attributeItem.setUnit(" "); +// attributeItem.setContext(channels); +// +// AttributeItem attributeItem1 = new AttributeItem(); +// attributeItem1.setAttribute("energies"); +// attributeItem1.setUnit(" dev"); +// attributeItem1.setContext(energies); +// +// AttributeItem attributeItem2 = new AttributeItem(); +// attributeItem2.setAttribute("errors"); +// attributeItem2.setUnit(" "); +// attributeItem2.setContext(errors); +// +// data.add(attributeItem); +// data.add(attributeItem1); +// data.add(attributeItem2); +// setBlock(new GammaArrLog().totalEfficiencyChannel, "abc", data); + } + + /** + * 获取标题格式 + *
例: ....................................... XXX ........................................
+ * @param title + * @param flag + * @return + */ + public static String getTitleFormat(String title, String flag) { + int padding = (CONTEXT_TITLE_SIZE - title.length()) / 2; + return String.format("%" + padding + "s%s%" + padding + "s", flag, title, flag).replace(" ",flag); + } + + /** + * 获取标题格式, 符号默认"." + *
例: ....................................... XXX ........................................
+ * @param title + * @return + */ + public static String getTitleFormat(String title) { + int padding = (CONTEXT_TITLE_SIZE - title.length()) / 2; + return String.format("%" + padding + "s%s%" + padding + "s", CONTEXT_TITLE_FLAG, title, CONTEXT_TITLE_FLAG) + .replace(" ",CONTEXT_TITLE_FLAG); + } + + /** + * 获取页眉 + *
例: XXX.....
+ * @param title 内容 + * @param flag 符号 + * @return + */ + public static String getHeaderFormat(String title, String flag) { + return String.format("%s%" + CONTEXT_HEADER_SIZE + "s", title, flag, "\n").replace(" ",flag); + } + + /** + * 获取页眉, 符号默认"." + *
例: XXX.....
+ * @param title 内容 + * @return + */ + public static String getHeaderFormat(String title) { + return String.format("%s%" + CONTEXT_HEADER_SIZE + "s", title, FILE_TITLE_FLAG, "\n") + .replace(" ", FILE_TITLE_FLAG); + } + +// public void getBlockFormatData(List data) { +// if(data.get(0) instanceof AttributeItemVo){ +// +// } +// if(data.get(0) instanceof List){ +// List> tempData = new LinkedList<>(); +// for(int row = 0; row < data.get(0).size(); row++) { +// List items = new LinkedList<>(); +// tempData.add(items); +// // 获取有多少列数据 +// for(int column = 0; column < data.size(); column++) { +// if(data.get(column).size() > row) { +// items.add(data.get(column).get(row)); +// } +// } +// } +// } +// } + + /** + * 获取内容正文 + * @param data 内容 + * @return + */ + public static List getBlockContext(Map data) { + List result = new LinkedList<>(); + int keyWidth = 0; + int valueWidth = 0; + for (Map.Entry entry : data.entrySet()) { + keyWidth = Math.max(entry.getKey().length(), keyWidth); + valueWidth = Math.max(entry.getValue().toString().length(), valueWidth); + } + for (Map.Entry entry : data.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + String formattedKey = String.format("%-"+ (keyWidth + 4) + "s", key); + String formattedValue = String.format("%-"+ (valueWidth + 4) + "s", value); + System.out.println(formattedKey + " : " + formattedValue); + result.add(formattedKey + " : " + formattedValue); + } + return result; + } + + /** + * 获取内容正文 + * @param data + * @return + */ + public static List getBlockContext(List data) { + List result = new LinkedList<>(); + List> tempData = new LinkedList<>(); + if(data.size() > 0) { + // 初始化数据 + for(int row = 0; row < data.get(0).getContext().size(); row++) { + List items = new LinkedList<>(); + tempData.add(items); + // 获取有多少列数据 + for(int column = 0; column < data.size(); column++) { + if(data.get(column).getContext().size() > row) { + AttributeItemVo item = data.get(column); + items.add(item.getAttribute() + " : " + item.getContext().get(row) + " " + item.getUnit()); + } + } + } + result.addAll(formatData(tempData)); + } + return result; + } + + /** + * 获取竖排数据 + * @param data + * @return + */ + public static List getBlockVerticalContext(List data) { + List result = new LinkedList<>(); + if(data.size() > 0) { + List> tempData = new LinkedList<>(); + // 行 + for(int row = 0; row < data.get(0).getContext().size(); row++) { + List columns = new LinkedList<>(); + tempData.add(columns); + // 获取有多少列数据 + for(int column = 0; column < data.size(); column++) { + AttributeItemVo item = data.get(column); + if(item.getContext().size() > row) { + columns.add(item.getContext().get(row) + " " + item.getUnit()); + } + } + } + result.addAll(formatData(tempData)); + } + return result; + } + + /** + * 格式化数据 + * @param data + * @return + */ + public static List formatData(List> data) { + List result = new LinkedList<>(); + // 计算每列数据中最长的字符串长度 + int[] columnWidths = new int[data.get(0).size()]; + for (List row : data) { + for (int i = 0; i < row.size(); i++) { + columnWidths[i] = Math.max(columnWidths[i], row.get(i).length()); + } + } + + // 构造格式化字符串 + StringBuilder formatBuilder = new StringBuilder(); + for (int i = 0; i < columnWidths.length; i++) { + formatBuilder.append("%-").append(columnWidths[i] + 4).append("s"); + } + String format = formatBuilder.toString(); + // 格式化输出日志 + for (List row : data) { + result.add(String.format(format, row.toArray())); + Console.log(String.format(format, row.toArray())); + } + result.add(STRING_END); + return result; + } + + /** + * 求百分比 + * @param one 被除数 + * @param two 除数 + * @return + */ + public static List getPercent(List one, List two) { + List result = Lists.newLinkedList(); + for (int i = 0; i < one.size(); i++) { + result.add(((Double.parseDouble(one.get(i)) / Double.parseDouble(two.get(i))) * 100) + ""); + } + return result; + } + + /** + * 小数点格式化 + * @param source 原数据 + * @param num 小数点位数 + * @return + */ + public static List getValuePoint(List source, int num) { + List result = Lists.newLinkedList(); + for (String str : source) { + result.add(String.format("%." + num + "f", Double.parseDouble(str))); + } + return result; + } + + public static List getPass(List source) { + List result = Lists.newLinkedList(); + for (String str : source) { + result.add(str.contains("0") ? "Fail" : "Pass"); + } + return result; + } +} diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/bizVo/AttributeItemVo.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/bizVo/AttributeItemVo.java new file mode 100644 index 00000000..f83eb488 --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/bizVo/AttributeItemVo.java @@ -0,0 +1,25 @@ +package org.jeecg.modules.base.bizVo; + +import lombok.Data; + +import java.util.List; + +@Data +public class AttributeItemVo { + private String attribute; + private List context; + private String unit = ""; + + public AttributeItemVo(){ + + } + public AttributeItemVo(String attribute, List context, String unit) { + this.attribute = attribute; + this.context = context; + this.unit = unit; + } + public AttributeItemVo(String attribute, List context) { + this.attribute = attribute; + this.context = context; + } +} diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/FittingBody.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/FittingBody.java index 58d2fb24..202e4da2 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/FittingBody.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/FittingBody.java @@ -18,4 +18,8 @@ public class FittingBody implements Serializable { private Integer count; + private String qcFileName; + + private String tabName; + } diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/AutoProcessManager.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/AutoProcessManager.java index f0185d53..2b4c87fa 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/AutoProcessManager.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/AutoProcessManager.java @@ -61,9 +61,6 @@ public class AutoProcessManager{ monitorThread.setName("mail-server-monitor"); monitorThread.start(); - //调用dll - System.loadLibrary("ReadPHDFile"); - //邮件执行线程管理 final MailExecManager autoProcessThread = new MailExecManager(); autoProcessThread.setName("mail-exec-thread-manage"); 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 new file mode 100644 index 00000000..158662b3 --- /dev/null +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/FileSourceHandleManager.java @@ -0,0 +1,174 @@ +package org.jeecg.modules; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.jeecg.common.properties.TaskProperties; +import org.jeecg.modules.ftp.FTPProperties; +import org.jeecg.modules.ftp.FTPUtils; +import org.jeecg.modules.spectrum.SamplephdSpectrum; +import org.jeecg.modules.spectrum.SpectrumHandler; +import org.jeecg.modules.spectrum.SpectrumServiceQuotes; +import org.springframework.scheduling.concurrent.CustomizableThreadFactory; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.io.ByteArrayInputStream; +import java.io.FileInputStream; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; +import java.util.concurrent.*; +import java.util.stream.Collectors; + +/** + * 解析手动放置PHD文件程序管理器 + */ +@Slf4j +@Component +@RequiredArgsConstructor +public class FileSourceHandleManager { + + /** + * 任务属性 + */ + private final TaskProperties taskProperties; + /** + * 相关Spring组件引用 + */ + private final SpectrumServiceQuotes spectrumServiceQuotes; + + /** + * 开始 + */ + public void start(){ + ParseingFileSourceThreadManager fileSourceThreadManager = new ParseingFileSourceThreadManager(); + fileSourceThreadManager.init(); + fileSourceThreadManager.start(); + } + + /** + * 手动放置PHD文件处理线程管理器 + */ + private class ParseingFileSourceThreadManager extends Thread{ + + private ThreadPoolExecutor poolExecutor; + + public void init(){ + //获取机器可用核心数 + int systemCores = Runtime.getRuntime().availableProcessors(); + int maximumPoolSize = taskProperties.getFilesourceDirReceiveNum() > systemCores?taskProperties.getFilesourceDirReceiveNum():systemCores; + + //初始化线程池 + ThreadFactory threadFactory = new CustomizableThreadFactory("filesource-file-parsing-"); + poolExecutor = new ThreadPoolExecutor(taskProperties.getReceiveNum(),maximumPoolSize,5, TimeUnit.SECONDS, new LinkedBlockingQueue<>(),threadFactory); + } + + @Override + public void run() { + for(;;){ + System.out.println("222222222222222222222222222222222222222222222222222222222222222222222222222222222"); + long start = System.currentTimeMillis(); + FTPUtils ftpUtil = null; + try { + //初始化FTP客户端对象 + final FTPProperties ftpProperties = spectrumServiceQuotes.getFtpProperties(); + ftpUtil = new FTPUtils(ftpProperties.getHost(),ftpProperties.getPort(),ftpProperties.getUserName(), + ftpProperties.getPassword(),ftpProperties.getEncoding(),ftpProperties.getFtpRootPath()); + //手动放置能谱文件获取路径 + String filePath = spectrumServiceQuotes.getSpectrumPathProperties().getFilesourcePath(); + List fileNames = ftpUtil.getFiles(filePath, taskProperties.getFilesourceDirReceiveNum().intValue()); + ftpUtil.close(); + //如果获取到的文件数量大于1,则进行排序保障Sample谱最后执行 + if(fileNames.size() > 1){ + fileNames = fileNames.stream().sorted(Comparator.comparing(String::toString)).collect(Collectors.toList()); + } + if(!CollectionUtils.isEmpty(fileNames)){ + CountDownLatch taskLatch = new CountDownLatch(fileNames.size()); + for(String fileName : fileNames){ + ParseingFileSourceThread parseingFileSourceThread = new ParseingFileSourceThread(); + parseingFileSourceThread.init(fileName,filePath,taskLatch); + poolExecutor.execute(parseingFileSourceThread); + } + taskLatch.await(); + } + }catch (Exception e){ + ftpUtil.close(); + e.printStackTrace(); + } + long end = System.currentTimeMillis(); + long sleepTime = taskProperties.getFilesourceDirExecCycle() - (end-start); + //如果sleepTime > 0 需要睡眠到指定时间,否则继续下次获取邮件 + if(sleepTime > 0){ + try { + //如果本次 + TimeUnit.MILLISECONDS.sleep(sleepTime); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + } + } + /** + * 解析手动放置的能谱文件线程 + */ + private class ParseingFileSourceThread implements Runnable{ + /** + * 能谱文件名称 + */ + private String fileName; + /** + * ftp工具 + */ + private FTPUtils ftpUtil; + /** + * 手动放置能谱文件获取路径 + */ + private String filePath; + /** + * 获取文件内容 + */ + private String fileContent; + + private CountDownLatch taskLatch; + + public void init(String fileName,String filePath,CountDownLatch taskLatch){ + this.fileName = fileName; + this.filePath = filePath; + this.taskLatch = taskLatch; + } + + @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(), + ftpProperties.getPassword(),ftpProperties.getEncoding(),ftpProperties.getFtpRootPath()); + //获取文件内容 + fileContent = this.ftpUtil.getFileContent(filePath, fileName); + //解析文件 + SpectrumHandler spectrumHandler = new SamplephdSpectrum(); + spectrumHandler.init(fileContent,spectrumServiceQuotes,this.ftpUtil); + final boolean matchResult = spectrumHandler.saveEmailToLocal(); + if(matchResult){ + //开始解析 + spectrumHandler.handler(); + } + }catch (Exception e){ + //解析失败会把文件上传到undeal目录 + this.ftpUtil.saveFile(spectrumServiceQuotes.getSpectrumPathProperties().getFailPath(),this.fileName,new ByteArrayInputStream(fileContent.getBytes(StandardCharsets.UTF_8))); + log.error("Parsing the {} file of the undeal directory failed",fileName); + e.printStackTrace(); + }finally { + //解析成功或者失败都会删除源文件 + this.ftpUtil.removeFile(this.filePath,this.fileName); + this.ftpUtil.close(); + taskLatch.countDown(); + } + } + } +} 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 new file mode 100644 index 00000000..d7569021 --- /dev/null +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/UndealHandleManager.java @@ -0,0 +1,164 @@ +package org.jeecg.modules; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.jeecg.common.properties.TaskProperties; +import org.jeecg.modules.ftp.FTPProperties; +import org.jeecg.modules.ftp.FTPUtils; +import org.jeecg.modules.spectrum.SamplephdSpectrum; +import org.jeecg.modules.spectrum.SpectrumHandler; +import org.jeecg.modules.spectrum.SpectrumServiceQuotes; +import org.springframework.scheduling.concurrent.CustomizableThreadFactory; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.util.Comparator; +import java.util.List; +import java.util.concurrent.*; +import java.util.stream.Collectors; + +/** + * 解析失败邮件处理程序管理器 + */ +@Slf4j +@Component +@RequiredArgsConstructor +public class UndealHandleManager { + + /** + * 任务属性 + */ + private final TaskProperties taskProperties; + /** + * 相关Spring组件引用 + */ + private final SpectrumServiceQuotes spectrumServiceQuotes; + + /** + * 开始 + */ + public void start(){ + ParseingFaliFileThreadManager faliFileThreadManager = new ParseingFaliFileThreadManager(); + faliFileThreadManager.init(); + faliFileThreadManager.start(); + } + + /** + * 失败邮件处理线程管理器 + */ + private class ParseingFaliFileThreadManager extends Thread{ + + private ThreadPoolExecutor poolExecutor; + + public void init(){ + //获取机器可用核心数 + int systemCores = Runtime.getRuntime().availableProcessors(); + int maximumPoolSize = taskProperties.getUndealDirReceiveNum() > systemCores?taskProperties.getUndealDirReceiveNum():systemCores; + + //初始化线程池 + ThreadFactory threadFactory = new CustomizableThreadFactory("undeal-file-parsing-"); + poolExecutor = new ThreadPoolExecutor(taskProperties.getUndealDirReceiveNum(),maximumPoolSize,5, TimeUnit.SECONDS, new LinkedBlockingQueue<>(),threadFactory); + } + + @Override + public void run() { + for(;;){ + System.out.println("1111111111111111111111111111111111111111111111111111111111111111111111111111111111"); + long start = System.currentTimeMillis(); + FTPUtils ftpUtil = null; + try { + //初始化FTP客户端对象 + final FTPProperties ftpProperties = spectrumServiceQuotes.getFtpProperties(); + ftpUtil = new FTPUtils(ftpProperties.getHost(),ftpProperties.getPort(),ftpProperties.getUserName(), + ftpProperties.getPassword(),ftpProperties.getEncoding(),ftpProperties.getFtpRootPath()); + //ftp解析失败文件存储路径 + String filePath = spectrumServiceQuotes.getSpectrumPathProperties().getFailPath(); + List fileNames = ftpUtil.getFiles(filePath, taskProperties.getUndealDirReceiveNum().intValue()); + ftpUtil.close(); + //如果获取到的文件数量大于1,则进行排序保障Sample谱最后执行 + if(fileNames.size() > 1){ + fileNames = fileNames.stream().sorted(Comparator.comparing(String::toString)).collect(Collectors.toList()); + } + if(!CollectionUtils.isEmpty(fileNames)){ + CountDownLatch taskLatch = new CountDownLatch(fileNames.size()); + for(String fileName : fileNames){ + ParseingFaliFileThread faliFileThread = new ParseingFaliFileThread(); + faliFileThread.init(fileName,filePath,taskLatch); + poolExecutor.execute(faliFileThread); + } + taskLatch.await(); + } + }catch (Exception e){ + ftpUtil.close(); + e.printStackTrace(); + } + long end = System.currentTimeMillis(); + long sleepTime = taskProperties.getUndealDirExecCycle() - (end-start); + //如果sleepTime > 0 需要睡眠到指定时间,否则继续下次获取邮件 + if(sleepTime > 0){ + try { + //如果本次 + TimeUnit.MILLISECONDS.sleep(sleepTime); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + } + } + + /** + * 解析失败能谱文件线程 + */ + private class ParseingFaliFileThread implements Runnable{ + /** + * 能谱文件名称 + */ + private String fileName; + /** + * ftp工具 + */ + private FTPUtils ftpUtil; + /** + * 失败文件存储路径 + */ + private String filePath; + + private CountDownLatch taskLatch; + + public void init(String fileName,String filePath,CountDownLatch taskLatch){ + this.fileName = fileName; + this.filePath = filePath; + this.taskLatch = taskLatch; + } + + @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(), + ftpProperties.getPassword(),ftpProperties.getEncoding(),ftpProperties.getFtpRootPath()); + //获取文件内容 + final String fileContent = this.ftpUtil.getFileContent(filePath, fileName); + //解析文件 + SpectrumHandler spectrumHandler = new SamplephdSpectrum(); + spectrumHandler.init(fileContent,spectrumServiceQuotes,this.ftpUtil); + final boolean matchResult = spectrumHandler.saveEmailToLocal(); + if(matchResult){ + //开始解析 + spectrumHandler.handler(); + } + }catch (Exception e){ + log.error("The {} file of the undeal directory fails to be parsed again",fileName); + e.printStackTrace(); + }finally { + //解析成功或者失败都会删除源文件 + this.ftpUtil.removeFile(this.filePath,this.fileName); + this.ftpUtil.close(); + this.taskLatch.countDown(); + } + } + } +} 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 39e0c641..aa44cb15 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 @@ -5,11 +5,13 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.net.ftp.*; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; +import org.apache.logging.log4j.util.Strings; + +import java.io.*; import java.nio.charset.StandardCharsets; -import java.util.Objects; +import java.util.*; +import java.util.stream.Collectors; +import java.util.stream.Stream; @Slf4j public class FTPUtils { @@ -59,9 +61,10 @@ public class FTPUtils { this.checkDirectory(ftpFilePath); InputStream inputStream = null; try{ - final FTPFile[] ftpFiles = this.client.listFiles(fileName); + final String formatFileName = new String(fileName.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1); + final FTPFile[] ftpFiles = this.client.listFiles(formatFileName); if(ArrayUtils.isNotEmpty(ftpFiles)){ - inputStream = this.client.retrieveFileStream(fileName); + inputStream = this.client.retrieveFileStream(formatFileName); if(Objects.nonNull(inputStream)){ FileUtil.writeFromStream(inputStream,localPath+File.separator+fileName); return true; @@ -117,14 +120,8 @@ public class FTPUtils { return true; } - public static void main(String[] args) throws IOException { - FTPUtils ftp = new FTPUtils("8.141.87.165",21,"rmsops","cnndc010","utf-8","/"); -// ftp.saveFile("log/Soh/2023/08","GBX68_RMSSOH-20230731_152800.0.log",new ByteArrayInputStream((System.lineSeparator()+"ssssssssssss").getBytes(StandardCharsets.UTF_8))); - ftp.downloadFTPFile("/savefile/Spectrum/Xenon/Sauna/Gasbkphd/2023/09","AUX09_003-20151224_0655_G_FULL_40182.873.PHD","E:\\file"); - } - /** - * 写入文件,若文件或文件目录不存在则自行创建,存在先删除再创建 + * 写入文件,若文件或文件目录不存在则自行创建,存在无操作 * @param filePath 文件路径 * @param fileName 文件名称 * @param inputStream 文件输入流 @@ -135,10 +132,9 @@ public class FTPUtils { final boolean flag = this.checkDirectory(filePath); if(flag){ final FTPFile[] ftpFiles = this.client.listFiles(fileName); - if(ArrayUtils.isNotEmpty(ftpFiles)){ - client.deleteFile(fileName); + if(ArrayUtils.isEmpty(ftpFiles)){ + return client.storeFile(fileName, inputStream); } - return client.storeFile(fileName, inputStream); } }catch (IOException e){ log.error("{}文件创建失败,原因为:{}",filePath+"/"+fileName,e.getMessage()); @@ -190,6 +186,65 @@ public class FTPUtils { return false; } + /** + * 在指定路径下获取指定数量的文件名称列表 + * @param filePath + * @param getNum + * @return + */ + public List getFiles(String filePath,int getNum) throws IOException { + final boolean flag = this.checkDirectory(filePath); + if(flag){ + final FTPFile[] ftpFiles = this.client.listFiles(); + if(ArrayUtils.isNotEmpty(ftpFiles)){ + //最终实际获取数量 + int num = getNum > ftpFiles.length?ftpFiles.length:getNum; + final List fileNames = Arrays.stream(ftpFiles).sorted(Comparator.comparing(FTPFile::getTimestamp)).map(f->f.getName()).limit(num).collect(Collectors.toList()); + return fileNames; + } + } + return Collections.emptyList(); + } + + /** + * 获取文件内容 + * @param filePath 文件路径 + * @param fileName 文件名称 + * @return 返回值,文件内容 + * @throws IOException + */ + public String getFileContent(String filePath,String fileName) throws IOException { + this.checkDirectory(filePath); + final FTPFile[] ftpFiles = this.client.listFiles(fileName); + if(ArrayUtils.isNotEmpty(ftpFiles)){ + InputStream inputStream = this.client.retrieveFileStream(fileName); + if(Objects.nonNull(inputStream)){ + try(BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream,"UTF-8"))){ + StringBuilder fileContent = new StringBuilder(); + String lineContent; + while ((lineContent = reader.readLine()) != null){ + fileContent.append(lineContent); + fileContent.append(System.lineSeparator()); + } + return fileContent.toString(); + }finally { + if(Objects.nonNull(inputStream)){ + inputStream.close(); + // 完成文件传输命令 + this.client.completePendingCommand(); + } + } + } + } + return Strings.EMPTY; + } + +// public static void main(String[] args) throws IOException { +// FTPUtils ftp = new FTPUtils("192.168.17.168",21,"ubuntu","123456","utf-8","/home/ubuntu/ftp"); +// final String fileContent = ftp.getFileContent("/undeal", "CNX22_004-20230731_1436_S_PREL_21593.8.PHD"); +// System.out.println(fileContent); +// } + /** * 删除文件 * @param filePath 文件路径 @@ -198,10 +253,9 @@ public class FTPUtils { */ public boolean removeFile(String filePath,String fileName){ try { - final String rootPath = client.printWorkingDirectory(); - final boolean changeFlag = client.changeWorkingDirectory(rootPath); + final boolean changeFlag = client.changeWorkingDirectory(ftpRootPath); if(!changeFlag){ - log.error("{},根目录切换失败",rootPath); + log.error("{},根目录切换失败",ftpRootPath); return false; } String[] directories = filePath.split("/"); diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/mapper/GardsSampleDataMapper.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/mapper/GardsSampleDataMapper.java index 76c11320..d63a1c0a 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/mapper/GardsSampleDataMapper.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/mapper/GardsSampleDataMapper.java @@ -6,13 +6,15 @@ import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Update; import org.jeecg.modules.base.entity.original.GardsSampleData; +import java.util.List; + public interface GardsSampleDataMapper extends BaseMapper { @Select(value = "select " + "gsd.SAMPLE_ID as sampleId,gsd.input_file_name as inputFileName " + "from ORIGINAL.GARDS_SAMPLE_AUX gsa inner join ORIGINAL.GARDS_SAMPLE_DATA gsd on gsa.sample_id = gsd.sample_id " + "where gsa.measurement_id = #{measurementId} and gsd.data_type=#{dataType}") - public GardsSampleData getSampleIdAndInputFileName(@Param("measurementId") String measurementId,@Param("dataType") String dataType); + public List getSampleIdAndInputFileName(@Param("measurementId") String measurementId, @Param("dataType") String dataType); @Update(value = "UPDATE ORIGINAL.GARDS_SAMPLE_DATA SET STATUS=#{status} WHERE INPUT_FILE_NAME=#{inputFileName}") public int updateStatus(@Param("status") String status,@Param("inputFileName") String inputFileName); diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/native_jni/struct/BgAnalyseResult.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/native_jni/struct/BgAnalyseResult.java index a20be280..8f56f139 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/native_jni/struct/BgAnalyseResult.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/native_jni/struct/BgAnalyseResult.java @@ -46,6 +46,7 @@ public class BgAnalyseResult { public List ROI_con_uncer_err; public List MDC; public List dNidFlag; + public List LC_CTS; /************************** GARDS_ROI_RESULTS end **************************/ @@ -56,6 +57,8 @@ public class BgAnalyseResult { public List s_g_fitting_e_c; public int s_g_fitting_type; public String s_g_fitting_type_def; + public List s_b_fitting_c_e; + public List s_g_fitting_c_e; public List g_b_fitting_e_c; public int g_b_fitting_type; @@ -63,6 +66,8 @@ public class BgAnalyseResult { public List g_g_fitting_e_c; public int g_g_fitting_type; public String g_g_fitting_type_def; + public List g_b_fitting_c_e; + public List g_g_fitting_c_e; public List d_b_fitting_e_c; public int d_b_fitting_type; @@ -70,6 +75,9 @@ public class BgAnalyseResult { public List d_g_fitting_e_c; public int d_g_fitting_type; public String d_g_fitting_type_def; + public List d_b_fitting_c_e; + public List d_g_fitting_c_e; + /************************** GARDS_CALIBRATION end **************************/ /************************** GARDS_ROI_CHANNELS START**************************/ @@ -136,24 +144,31 @@ public class BgAnalyseResult { ", ROI_con_uncer_err=" + ROI_con_uncer_err + ", MDC=" + MDC + ", dNidFlag=" + dNidFlag + + ", LC_CTS=" + LC_CTS + ", s_b_fitting_e_c=" + s_b_fitting_e_c + ", s_b_fitting_type=" + s_b_fitting_type + ", s_b_fitting_type_def='" + s_b_fitting_type_def + '\'' + ", s_g_fitting_e_c=" + s_g_fitting_e_c + ", s_g_fitting_type=" + s_g_fitting_type + ", s_g_fitting_type_def='" + s_g_fitting_type_def + '\'' + + ", s_b_fitting_c_e=" + s_b_fitting_c_e + + ", s_g_fitting_c_e=" + s_g_fitting_c_e + ", g_b_fitting_e_c=" + g_b_fitting_e_c + ", g_b_fitting_type=" + g_b_fitting_type + ", g_b_fitting_type_def='" + g_b_fitting_type_def + '\'' + ", g_g_fitting_e_c=" + g_g_fitting_e_c + ", g_g_fitting_type=" + g_g_fitting_type + ", g_g_fitting_type_def='" + g_g_fitting_type_def + '\'' + + ", g_b_fitting_c_e=" + g_b_fitting_c_e + + ", g_g_fitting_c_e=" + g_g_fitting_c_e + ", d_b_fitting_e_c=" + d_b_fitting_e_c + ", d_b_fitting_type=" + d_b_fitting_type + ", d_b_fitting_type_def='" + d_b_fitting_type_def + '\'' + ", d_g_fitting_e_c=" + d_g_fitting_e_c + ", d_g_fitting_type=" + d_g_fitting_type + ", d_g_fitting_type_def='" + d_g_fitting_type_def + '\'' + + ", d_b_fitting_c_e=" + d_b_fitting_c_e + + ", d_g_fitting_c_e=" + d_g_fitting_c_e + ", S_ROI=" + S_ROI + ", S_ROI_B_Boundary_start=" + S_ROI_B_Boundary_start + ", S_ROI_B_Boundary_stop=" + S_ROI_B_Boundary_stop + diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/GardsCalibrationService.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/GardsCalibrationService.java index 55f51a8b..b3ecfec6 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/GardsCalibrationService.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/GardsCalibrationService.java @@ -15,7 +15,9 @@ public interface GardsCalibrationService extends IService { * 不提交事务,由调用方手动统一提交事务 * @param analyseResult * @param sampleId + * @param gasSampleId + * @param detSampleId * @param anayId */ - public void create(BgAnalyseResult analyseResult, Integer sampleId, Integer anayId); + public void create(BgAnalyseResult analyseResult,Integer sampleId,Integer gasSampleId,Integer detSampleId,Integer anayId); } diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/GardsRoiChannelsService.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/GardsRoiChannelsService.java index 7506daee..4edefd47 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/GardsRoiChannelsService.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/GardsRoiChannelsService.java @@ -14,7 +14,9 @@ public interface GardsRoiChannelsService extends IService { * 不提交事务,由调用方手动统一提交事务 * @param analyseResult * @param sampleId + * @param gasSampleId + * @param detSampleId * @param idAnalysis */ - public void create(BgAnalyseResult analyseResult,Integer sampleId, Integer idAnalysis); + public void create(BgAnalyseResult analyseResult,Integer sampleId,Integer gasSampleId,Integer detSampleId,Integer idAnalysis); } diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/GardsSampleDataService.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/GardsSampleDataService.java index 59d6a559..8fc6d37d 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/GardsSampleDataService.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/GardsSampleDataService.java @@ -12,6 +12,13 @@ public interface GardsSampleDataService extends IService { */ public boolean fileExist(String inputFileName); + /** + * 查询GardsSampleData + * @param inputFileName + * @return + */ + public GardsSampleData findByInputFileName(String inputFileName); + /** * 获取谱文件保存路径 * @param measurementId diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsAnalysesServiceImpl.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsAnalysesServiceImpl.java index 8708f13c..59b69f32 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsAnalysesServiceImpl.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsAnalysesServiceImpl.java @@ -1,6 +1,7 @@ package org.jeecg.modules.service.impl; import cn.hutool.core.util.ObjectUtil; +import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.RequiredArgsConstructor; @@ -57,6 +58,7 @@ public class GardsAnalysesServiceImpl extends ServiceImpl wrapper = new LambdaQueryWrapper<>(); diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsCalibrationServiceImpl.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsCalibrationServiceImpl.java index 7c4d533a..876267f0 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsCalibrationServiceImpl.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsCalibrationServiceImpl.java @@ -23,16 +23,18 @@ public class GardsCalibrationServiceImpl extends ServiceImpl roiChannelsList = Lists.newArrayList(); this.saveSampleRoiChannels(analyseResult,sampleId,idAnalysis,roiChannelsList); - this.saveGasRoiChannels(analyseResult,sampleId,idAnalysis,roiChannelsList); - this.saveDetRoiChannels(analyseResult,sampleId,idAnalysis,roiChannelsList); + this.saveGasRoiChannels(analyseResult,gasSampleId,idAnalysis,roiChannelsList); + this.saveDetRoiChannels(analyseResult,detSampleId,idAnalysis,roiChannelsList); if(!CollectionUtils.isEmpty(roiChannelsList)){ this.saveBatch(roiChannelsList); } diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsRoiResultsServiceImpl.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsRoiResultsServiceImpl.java index e8eeb44f..ebe9afe3 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsRoiResultsServiceImpl.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsRoiResultsServiceImpl.java @@ -8,8 +8,6 @@ import org.jeecg.modules.native_jni.struct.BgAnalyseResult; import org.jeecg.modules.service.GardsRoiResultsService; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; - -import java.awt.geom.Arc2D; import java.util.Date; import java.util.List; @@ -32,6 +30,7 @@ public class GardsRoiResultsServiceImpl extends ServiceImpl list = Lists.newArrayList(); //C++那边没有补0,先加上后续解决后再删除 analyseResult.LC.add(0,0.0D); + for(int i=0;i analyseResult.MDC.get(i)){ -// list.get(i).setNidFlag(1); -// }else { -// list.get(i).setNidFlag(0); -// } -// } - list.get(i).setNidFlag(0); + seriNo = 0; + //从下标3开始,每次加3 + for(int i=3;i queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(GardsSampleData::getInputFileName,inputFileName); - queryWrapper.select(GardsSampleData::getSampleId); + queryWrapper.select(GardsSampleData::getSampleId,GardsSampleData::getInputFileName); final GardsSampleData sampleData = this.getOne(queryWrapper); return Objects.nonNull(sampleData) && StringUtils.isNotBlank(sampleData.getInputFileName()); } + /** + * 查询GardsSampleData + * @param inputFileName + * @return + */ + @Override + public GardsSampleData findByInputFileName(String inputFileName) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(GardsSampleData::getInputFileName,inputFileName); + return this.getOne(queryWrapper); + } + /** * 获取谱文件保存路径 * @param measurementId @@ -38,7 +55,13 @@ public class GardsSampleDataServiceImpl extends ServiceImpl sampleDatas = this.baseMapper.getSampleIdAndInputFileName(measurementId, dataType); + if(!CollectionUtils.isEmpty(sampleDatas)){ + //如果查询出多条则需要根据inputFileName字段降序排序后返回第一个 + final List sortResult = sampleDatas.stream().sorted(Comparator.comparing(GardsSampleData::getInputFileName).reversed()).collect(Collectors.toList()); + return sortResult.get(0); + } + return null; } /** diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/AlertSpectrum.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/AlertSpectrum.java index 6753e34f..bbc8937c 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/AlertSpectrum.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/AlertSpectrum.java @@ -54,7 +54,7 @@ public class AlertSpectrum extends SpectrumHandler{ * 检查规则并处理数据 */ @Override - protected void handler() throws Exception { + public void handler() throws Exception { if(DataType.ALERT_FLOW.getType().equals(super.currDataType.getType()) || DataType.ALERT_TEMP.getType().equals(super.currDataType.getType()) || DataType.ALERT_SYSTEM.getType().equals(super.currDataType.getType()) || 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 60e545d8..19ae7192 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 @@ -2,7 +2,6 @@ package org.jeecg.modules.spectrum; import org.jeecg.modules.base.enums.DataType; -import org.jeecg.modules.base.enums.SampleStatus; /** * 探测器本地谱处理 @@ -25,7 +24,7 @@ public class DetbkphdSpectrum extends S_D_Q_G_SpectrumHandler{ * 检查规则并处理数据 */ @Override - protected void handler() throws Exception { + public void handler() throws Exception { if(DataType.DETBKPHD.getType().equals(super.currDataType.getType())){ try{ //前置检查 @@ -43,8 +42,6 @@ public class DetbkphdSpectrum extends S_D_Q_G_SpectrumHandler{ //把流程日志写入ftp日志文件 super.saveLogToFtp(); }catch (Exception e){ - //修改状态为解析失败 - this.spectrumServiceQuotes.getSampleDataService().updateStatus(SampleStatus.FAIL.getValue(),super.sampleData.getInputFileName()); //处理解析失败的文件,上传到ftp->undeal目录 super.handleParseingFailFile(); throw e; 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 600dd178..0ca37ccc 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,7 +2,6 @@ package org.jeecg.modules.spectrum; import lombok.extern.slf4j.Slf4j; import org.jeecg.modules.base.enums.DataType; -import org.jeecg.modules.base.enums.SampleStatus; /** * 气体谱处理 @@ -26,7 +25,7 @@ public class GasbkphdSpectrum extends S_D_Q_G_SpectrumHandler{ * 检查规则并处理数据 */ @Override - protected void handler() throws Exception { + public void handler() throws Exception { if(DataType.GASBKPHD.getType().equals(super.currDataType.getType())){ try{ //前置检查 @@ -44,8 +43,6 @@ public class GasbkphdSpectrum extends S_D_Q_G_SpectrumHandler{ //把流程日志写入ftp日志文件 super.saveLogToFtp(); }catch (Exception e){ - //修改状态为解析失败 - this.spectrumServiceQuotes.getSampleDataService().updateStatus(SampleStatus.FAIL.getValue(),super.sampleData.getInputFileName()); //处理解析失败的文件,上传到ftp->undeal目录 super.handleParseingFailFile(); throw e; 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 4a946c2a..d54e705c 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 @@ -58,7 +58,7 @@ public class HealthStatusSpectrum extends SpectrumHandler{ * 检查规则并处理数据 */ @Override - protected void handler() throws Exception { + public void handler() throws Exception { if(DataType.SOH.getType().equals(super.currDataType.getType())){ //打印当前处理的能谱类型 super.printCurrDataType(); 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 4b9a24af..54a5efb0 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 @@ -55,7 +55,7 @@ public class MetSpectrum extends SpectrumHandler{ * 检查规则并处理数据 */ @Override - protected void handler() throws Exception { + public void handler() throws Exception { if(DataType.MET.getType().equals(super.currDataType.getType())){ //打印当前处理的能谱类型 super.printCurrDataType(); 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 efc5043e..45c2fac4 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,7 +1,6 @@ package org.jeecg.modules.spectrum; import org.jeecg.modules.base.enums.DataType; -import org.jeecg.modules.base.enums.SampleStatus; /** * QC谱处理 @@ -24,7 +23,7 @@ public class QcphdSpectrum extends S_D_Q_G_SpectrumHandler{ * 检查规则并处理数据 */ @Override - protected void handler() throws Exception { + public void handler() throws Exception { //判断当前邮件内容是否是QC谱 if(DataType.QCPHD.getType().equals(super.currDataType.getType())){ try{ @@ -43,8 +42,6 @@ public class QcphdSpectrum extends S_D_Q_G_SpectrumHandler{ //把流程日志写入ftp日志文件 super.saveLogToFtp(); }catch (Exception e){ - //修改状态为解析失败 - this.spectrumServiceQuotes.getSampleDataService().updateStatus(SampleStatus.FAIL.getValue(),super.sampleData.getInputFileName()); //处理解析失败的文件,上传到ftp->undeal目录 super.handleParseingFailFile(); throw e; 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 9fa42c29..dd98488a 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 @@ -112,8 +112,7 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{ //获取文件保存路径 String fileSavePath = this.getFileSavePath(); final SpectrumPathProperties properties = this.spectrumServiceQuotes.getSpectrumPathProperties(); - fileSavePath = properties.getRootPath()+StringConstant.SLASH+fileSavePath; - super.ftpUtil.saveFile(fileSavePath,this.mailFile.getName(),new FileInputStream(this.mailFile)); + super.ftpUtil.saveFile(properties.getRootPath()+StringConstant.SLASH+fileSavePath,this.mailFile.getName(),new FileInputStream(this.mailFile)); //设置FTP文件保存路径 super.ftpSavePath = fileSavePath+StringConstant.SLASH+this.mailFile.getName(); } @@ -124,17 +123,19 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{ */ private String getFileSavePath(){ //处理此文件需要保存到ftp服务的路径 - final int year = LocalDate.now().getYear(); - final int month = LocalDate.now().getMonth().getValue(); + //measurement_id切割后的字符数组 + String[] arr = this.sourceData.measurement_id.split(StringConstant.DASH); + //切割后第一个,元素是年,第二个是月 + final String[] yearMonth = arr[1].split(StringConstant.SLASH); final SpectrumPathProperties properties = this.spectrumServiceQuotes.getSpectrumPathProperties(); StringBuilder ftpPath = new StringBuilder(); ftpPath.append(properties.getFilePathMap().get(this.sourceData.system_type)); ftpPath.append(StringConstant.SLASH); ftpPath.append(properties.getFilePathMap().get(this.sourceData.data_type)); ftpPath.append(StringConstant.SLASH); - ftpPath.append(year); + ftpPath.append(yearMonth[0]); ftpPath.append(StringConstant.SLASH); - ftpPath.append(month>=10?month:"0"+month); + ftpPath.append(yearMonth[1]); return ftpPath.toString(); } @@ -206,8 +207,9 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{ protected void handlerOriginalData() throws Exception { this.startIntoDatabaseTime = new Date(); //如果数据已经存储,不在重复存储 - final boolean exist = spectrumServiceQuotes.getSampleDataService().fileExist(super.ftpSavePath); - if(exist){ + final GardsSampleData query = spectrumServiceQuotes.getSampleDataService().findByInputFileName(super.ftpSavePath); + if(Objects.nonNull(query)){ + this.sampleData = query; this.endIntoDatabaseTime = new Date(); log.warn("{} file data has been stored",super.mailFile.getName()); return; @@ -268,10 +270,10 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{ 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 = properties.getLogPath()+StringConstant.SLASH+this.getFileSavePath(); + this.logFilePath = this.getFileSavePath(); this.logFileName = super.mailFile.getName().replace(this.currDataType.getSuffix(),LOG_FILE_SUFFIX); - super.ftpUtil.saveOrAppendFile(logFilePath,logFileName,new ByteArrayInputStream(logContent.toString().getBytes(StandardCharsets.UTF_8))); + super.ftpUtil.saveOrAppendFile(properties.getLogPath()+StringConstant.SLASH+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 30e386ee..3714dc9f 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 @@ -145,7 +145,7 @@ public class Sample_B_Analysis implements BlockConstant { */ public void start() throws BAnalyseException { try{ - //修改状态为解析中 + //修改状态为分析中 this.updateStatus(SampleStatus.IN_PROCESS.getValue()); //查询det、gas数据(sampleId,inputFileName),sample数据在构造函数已经传过来 this.queryPHDFile(); @@ -160,9 +160,11 @@ public class Sample_B_Analysis implements BlockConstant { //生成报告 Sample_B_Analysis.B_AnalysisReport report = new Sample_B_Analysis.B_AnalysisReport(); report.start(); - //修改状态为解析成功 + //修改状态为分析成功 this.updateStatus(SampleStatus.COMPLETE.getValue()); }catch (Exception e){ + //修改状态为分析失败 + this.spectrumServiceQuotes.getSampleDataService().updateStatus(SampleStatus.FAIL.getValue(),this.sampleData.getInputFileName()); e.printStackTrace(); throw new BAnalyseException("Sample Analyse Error at "+DateUtils.formatDate(new Date(),"yyyy-MM-dd HH:mm:ss")); }finally { @@ -191,8 +193,7 @@ public class Sample_B_Analysis implements BlockConstant { //如果找不到sample、det、gas谱文件数据则解析失败修改记录状态 if(StringUtils.isEmpty(this.sampleData.getInputFileName()) || Objects.isNull(this.detSampleData) || StringUtils.isEmpty(this.detSampleData.getInputFileName()) || Objects.isNull(this.gasSampleData) || StringUtils.isEmpty(this.gasSampleData.getInputFileName())){ - this.currAnalysesStatus = SampleStatus.FAIL.getValue(); - this.spectrumServiceQuotes.getSampleDataService().updateStatus(this.currAnalysesStatus,this.sampleData.getInputFileName()); + this.spectrumServiceQuotes.getSampleDataService().updateStatus(SampleStatus.FAIL.getValue(),this.sampleData.getInputFileName()); throw new FileNotExistException("gas or det file is no exist or is error.."); } @@ -203,21 +204,21 @@ public class Sample_B_Analysis implements BlockConstant { */ private void structureArrFilePath(){ //处理此文件需要保存到ftp服务的路径 - final int year = LocalDate.now().getYear(); - final int month = LocalDate.now().getMonth().getValue(); + //measurement_id切割后的字符数组 + String[] arr = this.sampleStruct.measurement_id.split(StringConstant.DASH); + //切割后第一个,元素是年,第二个是月 + final String[] yearMonth = arr[1].split(StringConstant.SLASH); final SpectrumPathProperties properties = this.spectrumServiceQuotes.getSpectrumPathProperties(); StringBuilder ftpPath = new StringBuilder(); - ftpPath.append(properties.getRootPath()); - ftpPath.append(StringConstant.SLASH); ftpPath.append(properties.getArrPath()); ftpPath.append(StringConstant.SLASH); ftpPath.append(properties.getFilePathMap().get(this.sampleStruct.system_type)); ftpPath.append(StringConstant.SLASH); ftpPath.append(properties.getFilePathMap().get(this.sampleStruct.data_type)); ftpPath.append(StringConstant.SLASH); - ftpPath.append(year); + ftpPath.append(yearMonth[0]); ftpPath.append(StringConstant.SLASH); - ftpPath.append(month>=10?month:"0"+month); + ftpPath.append(yearMonth[1]); this.arrFilePath = ftpPath.toString(); String arrFileTail = ARR_FILE_NAME_TAIL+ARR_FILE_SUFFIX; String sourceFileName = this.sampleData.getInputFileName().substring(this.sampleData.getInputFileName().lastIndexOf(StringConstant.SLASH)+1); @@ -234,6 +235,7 @@ public class Sample_B_Analysis implements BlockConstant { System.out.println("det:"+this.detTempFilePath); BgAnalyseResult analyseResult = EnergySpectrumHandler.bgAnalyse(this.sampleTempFilePath,this.gasTempFilePath,this.detTempFilePath); + System.out.println(analyseResult); this.endAnalysisTime = new Date(); if(Objects.isNull(analyseResult) || !analyseResult.analyse_flag){ throw new BAnalyseException("THE PHD file cannot be parsed:"+this.sampleTempFilePath+","+this.gasTempFilePath+","+this.detTempFilePath); @@ -249,7 +251,7 @@ public class Sample_B_Analysis implements BlockConstant { boolean flag = false; //下载gas谱PHD文件到本地临时路径 String gasFileName = gasSampleData.getInputFileName().substring(gasSampleData.getInputFileName().lastIndexOf(StringConstant.SLASH) + 1); - String gasFileFTPPath = gasSampleData.getInputFileName().substring(0, gasSampleData.getInputFileName().lastIndexOf(StringConstant.SLASH)); + String gasFileFTPPath = this.spectrumServiceQuotes.getSpectrumPathProperties().getRootPath()+StringConstant.SLASH+gasSampleData.getInputFileName().substring(0, gasSampleData.getInputFileName().lastIndexOf(StringConstant.SLASH)); boolean gasFlag = ftpUtil.downloadFTPFile(gasFileFTPPath,gasFileName,this.spectrumServiceQuotes.getTaskProperties().getTemporaryStoragePath()); if(!gasFlag){ flag = true; @@ -258,7 +260,7 @@ public class Sample_B_Analysis implements BlockConstant { //下载det谱PHD文件到本地临时路径 final String detFileName = detSampleData.getInputFileName().substring(detSampleData.getInputFileName().lastIndexOf(StringConstant.SLASH) + 1); - String detFileFTPPath = detSampleData.getInputFileName().substring(0, detSampleData.getInputFileName().lastIndexOf(StringConstant.SLASH)); + String detFileFTPPath = this.spectrumServiceQuotes.getSpectrumPathProperties().getRootPath()+StringConstant.SLASH+detSampleData.getInputFileName().substring(0, detSampleData.getInputFileName().lastIndexOf(StringConstant.SLASH)); boolean detFlag = ftpUtil.downloadFTPFile(detFileFTPPath,detFileName,this.spectrumServiceQuotes.getTaskProperties().getTemporaryStoragePath()); if(!detFlag){ flag = true; @@ -302,9 +304,9 @@ public class Sample_B_Analysis implements BlockConstant { spectrumServiceQuotes.getGardsCalibrationPairsService().createG_EnergyRecord(gasSampleData.getSampleId(),analyses.getIdAnalysis(),this.gasStruct); //存储gards_calibration表数据sample、det、gas谱B_Energy和G_Energy块数据 - spectrumServiceQuotes.getGardsCalibrationService().create(this.analyseResult,gasSampleData.getSampleId(),analyses.getIdAnalysis()); + spectrumServiceQuotes.getGardsCalibrationService().create(this.analyseResult,sampleData.getSampleId(),gasSampleData.getSampleId(),detSampleData.getSampleId(),analyses.getIdAnalysis()); //gards_roi_channels数据表,存储sample、det、gas谱数据 - spectrumServiceQuotes.getRoiChannelsService().create(this.analyseResult,sampleData.getSampleId(),analyses.getIdAnalysis()); + spectrumServiceQuotes.getRoiChannelsService().create(this.analyseResult,sampleData.getSampleId(),gasSampleData.getSampleId(),detSampleData.getSampleId(),analyses.getIdAnalysis()); //gards_Xe_results数据表XE_131m、XE_133、XE_133m、XE_135数据 spectrumServiceQuotes.getXeResultsService().create(this.analyseResult,sampleData.getSampleId(),analyses.getIdAnalysis()); //gards_ roi_results数据表 @@ -362,6 +364,7 @@ public class Sample_B_Analysis implements BlockConstant { public void start() throws IOException { //获取报告内容 this.getTemplateContent(); + //创建报告临时文件 this.createTmpReportFile(); //处理报告时间 @@ -479,17 +482,16 @@ public class Sample_B_Analysis implements BlockConstant { this.templateContent = this.templateContent.replace("${DET_SampleID}",detSampleData.getSampleId().toString()); this.templateContent = this.templateContent.replace("${GAS_SampleID}",gasSampleData.getSampleId().toString()); } - /** * 处理#SAMPLE CALIBRATION 模块 * 还需和周雨涵确认s_b_fitting_c_e、s_g_fitting_c_e */ private void handleSampleCalibration() throws IOException { String[] betaArr = {CH_Contant+this.calibration(analyseResult.s_b_fitting_type,analyseResult.s_b_fitting_e_c), - E_Contant+this.calibration(analyseResult.s_b_fitting_type,analyseResult.s_b_fitting_e_c)}; + E_Contant+this.calibration(analyseResult.s_b_fitting_type,analyseResult.s_b_fitting_c_e)}; String[] gammaArr = {CH_Contant+this.calibration(analyseResult.s_g_fitting_type,analyseResult.s_g_fitting_e_c), - E_Contant+this.calibration(analyseResult.s_g_fitting_type,analyseResult.s_g_fitting_e_c)}; + E_Contant+this.calibration(analyseResult.s_g_fitting_type,analyseResult.s_g_fitting_c_e)}; this.handleTwoParamFormat("#SAMPLE CALIBRATION",betaArr,gammaArr); } @@ -519,10 +521,10 @@ public class Sample_B_Analysis implements BlockConstant { */ private void handleDetCalibration() throws IOException { String[] betaArr = {CH_Contant+this.calibration(analyseResult.d_b_fitting_type,analyseResult.d_b_fitting_e_c), - E_Contant+this.calibration(analyseResult.d_b_fitting_type,analyseResult.d_b_fitting_e_c)}; + E_Contant+this.calibration(analyseResult.d_b_fitting_type,analyseResult.d_b_fitting_c_e)}; String[] gammaArr = {CH_Contant+this.calibration(analyseResult.d_g_fitting_type,analyseResult.d_g_fitting_e_c), - E_Contant+this.calibration(analyseResult.d_g_fitting_type,analyseResult.d_g_fitting_e_c)}; + E_Contant+this.calibration(analyseResult.d_g_fitting_type,analyseResult.d_g_fitting_c_e)}; this.handleTwoParamFormat("#DET CALIBRATION",betaArr,gammaArr); } @@ -552,10 +554,10 @@ public class Sample_B_Analysis implements BlockConstant { */ private void handleGasCalibration() throws IOException { String[] betaArr = {CH_Contant+this.calibration(analyseResult.g_b_fitting_type,analyseResult.g_b_fitting_e_c), - E_Contant+this.calibration(analyseResult.g_b_fitting_type,analyseResult.g_b_fitting_e_c)}; + E_Contant+this.calibration(analyseResult.g_b_fitting_type,analyseResult.g_b_fitting_c_e)}; String[] gammaArr = {CH_Contant+this.calibration(analyseResult.g_g_fitting_type,analyseResult.g_g_fitting_e_c), - E_Contant+this.calibration(analyseResult.g_g_fitting_type,analyseResult.g_g_fitting_e_c)}; + E_Contant+this.calibration(analyseResult.g_g_fitting_type,analyseResult.g_g_fitting_c_e)}; this.handleTwoParamFormat("#GAS CALIBRATION",betaArr,gammaArr); } @@ -600,7 +602,7 @@ 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()); - List lc = analyseResult.LC.stream().map(v->formatToStr5(v)).collect(Collectors.toList()); + List lc = analyseResult.LC_CTS.stream().map(v->formatToStr5(v)).collect(Collectors.toList()); List netCount = Lists.newArrayList(); String flag = " +/- "; for(int i=0;iundeal目录 super.handleParseingFailFile(); throw e; 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 e9da4c6b..cd2d5aff 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 @@ -53,7 +53,7 @@ public abstract class SpectrumHandler extends Chain{ /** * 初始化参数 */ - protected void init(String mailContent,SpectrumServiceQuotes spectrumServiceQuotes,FTPUtils ftpUtil) throws Exception{ + public void init(String mailContent,SpectrumServiceQuotes spectrumServiceQuotes,FTPUtils ftpUtil) throws Exception{ this.mailContent = mailContent; this.spectrumServiceQuotes = spectrumServiceQuotes; this.ftpUtil = ftpUtil; @@ -75,7 +75,7 @@ public abstract class SpectrumHandler extends Chain{ /** * 检查规则并处理数据 */ - protected abstract void handler() throws Exception; + public abstract void handler() throws Exception; /** * 调用dll解析邮件 @@ -114,7 +114,7 @@ public abstract class SpectrumHandler extends Chain{ /** * 把邮件内容存储到本地 */ - protected boolean saveEmailToLocal(){ + public boolean saveEmailToLocal(){ boolean flag = false; final DataType[] values = DataType.values(); for(DataType value : values){ 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 804d4ded..0d0f5ed5 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 @@ -110,7 +110,7 @@ public class SpectrumParsingActuator implements Runnable{ } } } catch (Exception e) { - log.error(mailContent.toString()); +// log.error(mailContent.toString()); log.error("邮件解析失败,邮件主题为:{},发送时间为:{},接收时间为:{},失败原因为:{}",subject,sendTime,receiveTime,e.getMessage()); e.printStackTrace(); }finally { @@ -121,7 +121,7 @@ public class SpectrumParsingActuator implements Runnable{ e.printStackTrace(); } this.taskLatch.countDown(); - ftpUtil.close(); + this.ftpUtil.close(); } } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/cache/BetaCache.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/cache/BetaCache.java new file mode 100644 index 00000000..be2ac261 --- /dev/null +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/cache/BetaCache.java @@ -0,0 +1,36 @@ +package org.jeecg.common.cache; + +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import org.jeecg.modules.entity.vo.PHDFile; +import org.jeecg.modules.entity.vo.SeriseData; +import org.springframework.stereotype.Component; + +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +@Component +public class BetaCache { + private Cache> betaCache = CacheBuilder.newBuilder() + //设置缓存初始大小,应该合理设置,后续会扩容 + .initialCapacity(10) + //最大值 + .maximumSize(100) + //并发数设置 + .concurrencyLevel(5) + //缓存过期时间,写入后5秒钟过期 + .expireAfterWrite(5, TimeUnit.HOURS) + //统计缓存命中率 + .recordStats() + .build(); + + public Cache> getBetaCache() { + return betaCache; + } + + public void setBetaCache(Cache> betaCache) { + this.betaCache = betaCache; + } + +} 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 7254da77..b65a5efb 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 @@ -2,7 +2,7 @@ package org.jeecg.common.util; 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 org.apache.commons.io.FileUtils; import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPFile; @@ -531,7 +531,7 @@ public class GammaFileUtil { phd.getBaseCtrls().setRg_low(analysis.getSearchStartChannel()); phd.getBaseCtrls().setRg_high(analysis.getSearchEndChannel()); phd.getUsedSetting().setEnergyTolerance(analysis.getSearchThreshold()); - }else { + } else { result.error500("There are 0 records when sample_id is "+sampleId+"!"); return false; } @@ -711,7 +711,7 @@ public class GammaFileUtil { if (CollectionUtils.isNotEmpty(nuclIdeds)){ for (GardsNuclIdedSpectrum nuclIdedSpectrum:nuclIdeds) { String str_key = nuclIdedSpectrum.getNuclideName(); - if(Objects.isNull(phd.getMapNucActMda().get(str_key))) { + if(Objects.nonNull(phd.getMapNucActMda().get(str_key))) { phd.getMapNucActMda().get(str_key).setHalflife(Double.valueOf(nuclIdedSpectrum.getHalflife())); List vEner = phd.getMapNucActMda().get(str_key).getVEnergy(); Double key_ener = Double.valueOf(nuclIdedSpectrum.getKeyEnergy()); @@ -2634,7 +2634,7 @@ public class GammaFileUtil { strBuffer.append(StringPool.SPACE+middleData.peaks_idPeak.get(i)+" "+String.format("%.3f", Double.valueOf(middleData.peaks_Energy.get(i)))+" "+String.format("%.3f", Double.valueOf(middleData.peaks_peakCentroid.get(i)))+ " "+String.format("%.3f", Double.valueOf(middleData.peaks_Fwhm.get(i)))+" "+String.format("%.3f", Double.valueOf(middleData.peaks_Area.get(i)))+ " "+String.format("%.3f", (Double.valueOf(middleData.peaks_areaErr.get(i))/Double.valueOf(middleData.peaks_Area.get(i))*100))+ - " "+String.format("%.3f", Double.valueOf(middleData.peaks_Significance.get(i)))+" "+String.format("%.3f", Double.valueOf(middleData.peaks_Sensitivity.get(i)))+" "+middleData.peaks_Nuclide_name+"\n"); + " "+String.format("%.3f", Double.valueOf(middleData.peaks_Significance.get(i)))+" "+String.format("%.3f", Double.valueOf(middleData.peaks_Sensitivity.get(i)))+" "+middleData.peaks_Nuclide_name.get(i)+"\n"); } strBuffer.append(" \n"); strBuffer.append("#PROCESSING PARAMETERS\n"); @@ -2717,14 +2717,37 @@ public class GammaFileUtil { return data; } - List DoubleLimit_G(List _data) { - NumberFormat numberFormat = new DecimalFormat("0.##########E0"); + public List DoubleLimit_I(List _data) { List rdata = new LinkedList<>(); for(int pos=0;pos<_data.size();pos++) { if(Objects.isNull(_data.get(pos))) { rdata.add("NULL"); } else { - rdata.add(numberFormat.format(_data.get(pos))); + rdata.add(String.valueOf(_data.get(pos).intValue())); + } + } + return rdata; + } + + public List DoubleLimit_G(List _data) { + NumberFormat numberFormat = new DecimalFormat("0.##########E0"); + List rdata = new LinkedList<>(); + for(int pos=0;pos<_data.size();pos++) { + Double value = _data.get(pos); + if (String.valueOf(value).indexOf("e")>0) { + if(Objects.isNull(value)) { + rdata.add("NULL"); + } else { + rdata.add(numberFormat.format(value)); + } + } else { + if (String.format("%.1f", value).indexOf(".0")>0) { + rdata.addAll(DoubleLimit_I(_data)); + break; + } else { + rdata.addAll(DoubleLimit(_data)); + break; + } } } return rdata; @@ -3120,7 +3143,7 @@ public class GammaFileUtil { List dvctLD = new LinkedList<>(); List dvctNuclide_name = new LinkedList<>(); List dvctComments = new LinkedList<>(); - for(int m=0;m 1024){ t_comment = t_comment.substring(0, 1025); } dvctComments.add(t_comment); - - String qsName = ""; - for(int n=0;n svctNUCLIDEFULLNAME = new LinkedList<>(); - List dvctIDPEAK = new LinkedList<>(); - List dvctENERGY = new LinkedList<>(); - List dvctUNCENERGY = new LinkedList<>(); - List dvctABUNDANCE = new LinkedList<>(); - List dvctUNCABUNDANCE = new LinkedList<>(); - List dvctACTIVITY = new LinkedList<>(); - List dvctUNCACTIVITY = new LinkedList<>(); - List dvctEFFIC = new LinkedList<>(); - List dvctUNEFFIC = new LinkedList<>(); - List dvctMDA = new LinkedList<>(); - List dvctKEY_FLAG = new LinkedList<>(); - List dvctCSC_RATIO = new LinkedList<>(); - List dvctCSC_RATIO_ERR = new LinkedList<>(); - List dvctCSC_MOD_FLAG = new LinkedList<>(); - List dvctMDC = new LinkedList<>(); - List dvctCONCENTRATION = new LinkedList<>(); for(Map.Entry itor:fileAnlyse.getMapNucActMda().entrySet()) { + List svctNUCLIDEFULLNAME = new LinkedList<>(); + List dvctIDPEAK = new LinkedList<>(); + List dvctENERGY = new LinkedList<>(); + List dvctUNCENERGY = new LinkedList<>(); + List dvctABUNDANCE = new LinkedList<>(); + List dvctUNCABUNDANCE = new LinkedList<>(); + List dvctACTIVITY = new LinkedList<>(); + List dvctUNCACTIVITY = new LinkedList<>(); + List dvctEFFIC = new LinkedList<>(); + List dvctUNEFFIC = new LinkedList<>(); + List dvctMDA = new LinkedList<>(); + List dvctKEY_FLAG = new LinkedList<>(); + List dvctCSC_RATIO = new LinkedList<>(); + List dvctCSC_RATIO_ERR = new LinkedList<>(); + List dvctCSC_MOD_FLAG = new LinkedList<>(); + List dvctMDC = new LinkedList<>(); + List dvctCONCENTRATION = new LinkedList<>(); int first=itor.getValue().getFullNames().size(); int second=itor.getValue().getVPeakIdx().size(); first = first svctNUCLIDEFULLNAME1 = new LinkedList<>(); - List svctTYPE = new LinkedList<>(); - List dvctHALFLIFE = new LinkedList<>(); - List dvctAVE_ACTIV = new LinkedList<>(); - List dvctAVE_ACTIV_ERR = new LinkedList<>(); - List dvctACTIV_KEY = new LinkedList<>(); - List dvctACTIV_KEY_ERR = new LinkedList<>(); - List dvctMDA1 = new LinkedList<>(); - List dvctMDA_ERR = new LinkedList<>(); - List dvctNID_FLAG = new LinkedList<>(); - List dvctCSC_RATIO1 = new LinkedList<>(); - List dvctCSC_RATIO_ERR1 = new LinkedList<>(); - List dvctCSC_MOD_FLAG1 = new LinkedList<>(); - List dvctMDC1 = new LinkedList<>(); - List dvctCONCENTRATION1 = new LinkedList<>(); - List dvctKey_Energy = new LinkedList<>(); - List dvctKey_Yield = new LinkedList<>(); - if( fileAnlyse.getMapNucActMda().size() != 0) { + List svctNUCLIDEFULLNAME1 = new LinkedList<>(); + List svctTYPE = new LinkedList<>(); + List dvctHALFLIFE = new LinkedList<>(); + List dvctAVE_ACTIV = new LinkedList<>(); + List dvctAVE_ACTIV_ERR = new LinkedList<>(); + List dvctACTIV_KEY = new LinkedList<>(); + List dvctACTIV_KEY_ERR = new LinkedList<>(); + List dvctMDA1 = new LinkedList<>(); + List dvctMDA_ERR = new LinkedList<>(); + List dvctNID_FLAG = new LinkedList<>(); + List dvctCSC_RATIO1 = new LinkedList<>(); + List dvctCSC_RATIO_ERR1 = new LinkedList<>(); + List dvctCSC_MOD_FLAG1 = new LinkedList<>(); + List dvctMDC1 = new LinkedList<>(); + List dvctCONCENTRATION1 = new LinkedList<>(); + List dvctKey_Energy = new LinkedList<>(); + List dvctKey_Yield = new LinkedList<>(); for(Map.Entry itor_v: fileAnlyse.getMapNucActMda().entrySet()) { String nuclideName = itor_v.getKey(); svctNUCLIDEFULLNAME1.add(nuclideName); @@ -3307,7 +3320,6 @@ public class GammaFileUtil { dvctKey_Yield.add(itor_v.getValue().getVYield().get(itor_v.getValue().getCalculateIdx())); } } - middleData.nucl_ided_Nuclidename = svctNUCLIDEFULLNAME1; middleData.nucl_ided_Type= svctTYPE; middleData.nucl_ided_Halflife =DoubleLimit_G(dvctHALFLIFE); @@ -3322,17 +3334,16 @@ public class GammaFileUtil { middleData.nucl_ided_csc_ratio_err =DoubleLimit_G(dvctCSC_RATIO_ERR1); middleData.nucl_ided_csc_mod_flag =DoubleLimit_G(dvctCSC_MOD_FLAG1); middleData.nucl_ided_MDC = dvctMDC1; - middleData.nucl_ided_Concentration = dvctCONCENTRATION; + middleData.nucl_ided_Concentration = dvctCONCENTRATION1; middleData.nucl_ided_Key_Energy = DoubleLimit_G(dvctKey_Energy); middleData.nucl_ided_Key_Yield = DoubleLimit_G(dvctKey_Yield); - } // GARDS_QC_CHECK数据表 - List qvctQC_NAME = new LinkedList<>(); - List dvctQC_VALUE = new LinkedList<>(); - List qvctQC_STANDARD = new LinkedList<>(); - List dvctQC_RESULT = new LinkedList<>(); if( fileAnlyse.getQcItems().size() != 0) { + List qvctQC_NAME = new LinkedList<>(); + List dvctQC_VALUE = new LinkedList<>(); + List qvctQC_STANDARD = new LinkedList<>(); + List dvctQC_RESULT = new LinkedList<>(); for(Map.Entry itor_q:fileAnlyse.getQcItems().entrySet()) { String nuclideName = itor_q.getKey(); qvctQC_NAME.add(nuclideName); @@ -3345,11 +3356,9 @@ public class GammaFileUtil { middleData.QC_CHECK_QC_STANDARD=qvctQC_STANDARD; middleData.QC_CHECK_QC_VALUE=DoubleLimit_G(dvctQC_VALUE); } - //sample info middleData.sample_collection_start = fileAnlyse.getCollect().getCollection_start_date()+StringPool.SPACE+fileAnlyse.getCollect().getCollection_start_time(); middleData.sample_collection_stop = fileAnlyse.getCollect().getCollection_stop_date()+StringPool.SPACE+fileAnlyse.getCollect().getCollection_stop_time(); - if(Objects.nonNull(fileAnlyse.getQcItems().get("col_time"))) { middleData.sample_time = String.format("%.4f", fileAnlyse.getQcItems().get("col_time").getValue()); if(fileAnlyse.getQcItems().get("col_time").getValue()!=0) { @@ -3365,16 +3374,14 @@ public class GammaFileUtil { middleData.sample_quantity = String.format("%.4f", fileAnlyse.getCollect().getAir_volume()); middleData.sample_acquisiton_start = fileAnlyse.getAcq().getAcquisition_start_date()+StringPool.SPACE+fileAnlyse.getAcq().getAcquisition_start_time(); String acquisition_start = middleData.sample_acquisiton_start; - Date dataTime = DateUtils.parseDate(acquisition_start.substring(0, acquisition_start.indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"); - acquisition_start = DateUtils.formatDate(dataTime, "yyyy/MM/dd HH:mm:ss"); - middleData.sample_acquistion_stop = DateUtils.formatDate(new Date((long) (dataTime.getTime()/1000 + fileAnlyse.getAcq().getAcquisition_live_time())), "yyyy/MM/dd HH:mm:ss"); + Date dataTime = DateUtils.parseDate(acquisition_start); + middleData.sample_acquistion_stop = DateUtils.formatDate(new Date((long) (dataTime.getTime()/1000 + fileAnlyse.getAcq().getAcquisition_live_time())) , "yyyy/MM/dd HH:mm:ss"); middleData.sample_acquistion_time = String.format("%.2f", fileAnlyse.getAcq().getAcquisition_real_time()) ; middleData.sample_stationID = fileAnlyse.getHeader().getSite_code(); middleData.sample_detectID = fileAnlyse.getHeader().getDetector_code(); middleData.sample_Geometry = fileAnlyse.getHeader().getSample_geometry(); middleData.sample_Type = fileAnlyse.getHeader().getSystem_type(); middleData.setting_specSetup = fileAnlyse.getUsedSetting(); - middleData.Collection_Station_Comments = fileAnlyse.getOriTotalCmt(); middleData.NDC_Analysis_General_Comments = fileAnlyse.getTotalCmt(); return bRet; diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/PHDFileUtil.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/PHDFileUtil.java index 03d12aca..df02775d 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/PHDFileUtil.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/PHDFileUtil.java @@ -588,11 +588,11 @@ public class PHDFileUtil { String dataType = sourceData.data_type; StringBuffer path = new StringBuffer(); if(systemType.contains("B")) { - path.append(StringPool.SLASH+"Spectrum"); + path.append("Spectrum"); path.append(StringPool.SLASH+"Xenon"); path.append(StringPool.SLASH+"Sauna"); } else if(systemType.contains("G")) { - path.append(StringPool.SLASH+"Spectrum"); + path.append("Spectrum"); path.append(StringPool.SLASH+"Xenon"); path.append(StringPool.SLASH+"Spalax"); } 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 47ef9ffe..22ff4471 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 @@ -192,6 +192,7 @@ public class GammaController { } @PostMapping("saveDataEnergy") + @ApiOperation(value = "保存Energy Calibration数据", notes = "保存Energy Calibration数据") public void saveDataEnergy(@RequestBody ChangeData changeData, HttpServletResponse response) { gammaService.saveDataEnergy(changeData.getM_vCurCentroid(), changeData.getM_vCurEnergy(), changeData.getM_vCurUncert(), response); } @@ -214,6 +215,12 @@ public class GammaController { return gammaService.applyDataResolution(changeData.getM_vCurReso(), changeData.getM_vCurEnergy(), changeData.getM_vCurUncert(), changeData.getM_curParam(), changeData.getCurCalName(), changeData.getSampleId(), changeData.getFileName()); } + @PostMapping("saveDataResolution") + @ApiOperation(value = "保存Resolution Calibration数据", notes = "保存Resolution Calibration数据") + public void saveDataResolution(@RequestBody ChangeData changeData, HttpServletResponse response) { + gammaService.saveDataResolution(changeData.getM_vCurReso(), changeData.getM_vCurEnergy(), changeData.getM_vCurUncert(), response); + } + @GetMapping("EfficiencyCalibration") @ApiOperation(value = "查看Efficiency Calibration数据", notes = "查看Efficiency Calibration数据") public Result EfficiencyCalibration(@RequestParam Integer sampleId, String fileName, String currentText) { @@ -232,6 +239,12 @@ public class GammaController { return gammaService.applyDataEfficiency(changeData.getM_vCurEffi(), changeData.getM_vCurEnergy(), changeData.getM_vCurUncert(), changeData.getM_curParam(), changeData.getCurCalName(), changeData.getSampleId(), changeData.getFileName()); } + @PostMapping("saveDataEfficiency") + @ApiOperation(value = "保存Efficiency Calibration数据", notes = "保存Efficiency Calibration数据") + public void saveDataEfficiency(@RequestBody ChangeData changeData, HttpServletResponse response) { + gammaService.saveDataEfficiency(changeData.getM_vCurEffi(), changeData.getM_vCurEnergy(), changeData.getM_vCurUncert(), changeData.getFuncId(), response); + } + @GetMapping("NuclideLibrary") @ApiOperation(value = "查看Nuclide Library页面数据", notes = "查看Nuclide Library页面数据") public Result NuclideLibrary(Integer sampleId, String fileName, String editEnergy, double err, String libraryName, String nuclideName, HttpServletRequest request) { @@ -274,12 +287,22 @@ public class GammaController { gammaService.viewARR(sampleId, response); } + @GetMapping("exportARR") + public void exportARR(Integer sampleId, HttpServletResponse response) { + gammaService.exportARR(sampleId, response); + } + @GetMapping("viewRRR") @ApiOperation(value = "查看RRR页面数据", notes = "查看RRR页面数据") public Result viewRRR(Integer sampleId, String fileName) { return gammaService.viewRRR(sampleId, fileName); } + @GetMapping("exportRRR") + public void exportRRR(Integer sampleId, String fileName, HttpServletResponse response) { + gammaService.exportRRR(sampleId, fileName, response); + } + @GetMapping("radionuclideActivity") @ApiOperation(value = "查看Radionuclide Activity页面数据", notes = "查看Radionuclide Activity页面数据") public Result radionuclideActivity(Integer sampleId, String fileName) { diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SpectrumAnalysesController.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SpectrumAnalysesController.java index d2c33f2b..5c0f2daf 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SpectrumAnalysesController.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SpectrumAnalysesController.java @@ -179,8 +179,8 @@ public class SpectrumAnalysesController { @PostMapping("fitting") @ApiOperation(value = "公式计算新的曲线", notes = "公式计算新的曲线") - public Result fitting(@RequestBody FittingBody fittingBody) { - return spectrumAnalysisService.fitting(fittingBody.getParamA(), fittingBody.getParamB(), fittingBody.getParamC(), fittingBody.getTempPoints(), fittingBody.getCount()); + public Result fitting(@RequestBody FittingBody fittingBody, HttpServletRequest request) { + return spectrumAnalysisService.fitting(fittingBody.getParamA(), fittingBody.getParamB(), fittingBody.getParamC(), fittingBody.getTempPoints(), fittingBody.getCount(), fittingBody.getQcFileName(), fittingBody.getTabName(), request); } @GetMapping("getGammaGated") diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/BgDataAnlyseResultIn.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/BgDataAnlyseResultIn.java index 51ed7a7d..22128005 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/BgDataAnlyseResultIn.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/BgDataAnlyseResultIn.java @@ -1,6 +1,7 @@ package org.jeecg.modules.entity.vo; import lombok.Data; +import org.jeecg.modules.base.entity.rnman.GardsXeResults; import org.jeecg.modules.entity.GardsCalibrationSpectrum; import org.jeecg.modules.entity.GardsROIChannelsSpectrum; import org.jeecg.modules.entity.GardsROIResultsSpectrum; @@ -177,15 +178,9 @@ public class BgDataAnlyseResultIn implements Serializable { /** * Beta Detector Calibration公式参数 */ - private String param_a_c2e_b_sample; - private String param_b_c2e_b_sample; - private String param_c_c2e_b_sample; - private String param_a_c2e_b_gas; - private String param_b_c2e_b_gas; - private String param_c_c2e_b_gas; - private String param_a_c2e_b_det; - private String param_b_c2e_b_det; - private String param_c_c2e_b_det; + private String param_a_c2e_b; + private String param_b_c2e_b; + private String param_c_c2e_b; private double mdc_Xe135; //MDC XE135 private double mdc_Xe131m; //MDC XE131m @@ -222,6 +217,6 @@ public class BgDataAnlyseResultIn implements Serializable { List roiResultsSpectrumList; - List XeData; + List XeData; } 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 cf7c824c..7666079c 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 @@ -77,12 +77,16 @@ public interface IGammaService{ 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 changeDataEfficiency(List m_vCurEffi, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, Integer funcId, Integer sampleId, String fileName); 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 NuclideLibrary(Integer sampleId, String fileName, String editEnergy, double err, String libraryName, String nuclideName, HttpServletRequest request); Result configUserLibrary(Integer sampleId, String fileName, HttpServletRequest request); @@ -97,8 +101,12 @@ public interface IGammaService{ void viewARR(Integer sampleId, HttpServletResponse response); + void exportARR(Integer sampleId, HttpServletResponse response); + Result viewRRR(Integer sampleId, String fileName); + void exportRRR(Integer sampleId, String fileName, HttpServletResponse response); + Result radionuclideActivity(Integer sampleId, String fileName); void exportRadionuclideActivity(Integer sampleId, String fileName, HttpServletResponse response); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISpectrumAnalysisService.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISpectrumAnalysisService.java index fba99be4..2986776d 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISpectrumAnalysisService.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISpectrumAnalysisService.java @@ -62,7 +62,7 @@ public interface ISpectrumAnalysisService { Result statisticsQueryBtn(Integer detectorId, String detectorName, Integer stationId, String statisticsType, Date startTime, Date endTime); - Result fitting(Double paramA, Double paramB, Double paramC, List tempPointsArray, Integer count); + Result fitting(Double paramA, Double paramB, Double paramC, List tempPointsArray, Integer count, String qcFileName, String tabName, HttpServletRequest request); Result getGammaGated(Integer chartHeight, Integer channelWidth, Integer gammaChannel, Integer sampleId, String qcFileName, 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 83312b08..88738f5e 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 @@ -39,6 +39,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.*; import java.math.BigDecimal; +import java.net.URLEncoder; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; @@ -1280,6 +1281,10 @@ public class GammaServiceImpl implements IGammaService { } OutputStream fos = null; try { + //设置响应类型 + response.setContentType("application/octet-stream"); + //解决中文不能生成文件 + response.setHeader("Content-Disposition", "attachment; fileName=" + URLEncoder.encode("EnergyCalibration.Ent","UTF-8")); fos = response.getOutputStream(); fos.write(strBuffer.toString().getBytes()); } catch (FileNotFoundException e) { @@ -1421,6 +1426,34 @@ public class GammaServiceImpl implements IGammaService { return result; } + @Override + public void saveDataResolution(List m_vCurReso, List m_vCurEnergy, List m_vCurUncert, HttpServletResponse response) { + StringBuffer strBuffer = new StringBuffer(); + strBuffer.append("#g_Resolution").append("\n"); + for (int i=0; i m_vCurEffi, List m_vCurEnergy, List m_vCurUncert, Integer funId, HttpServletResponse response) { + StringBuffer strBuffer = new StringBuffer(); + strBuffer.append("#g_Efficiency").append("\n"); + for (int i=0; i ftpFiles = Arrays.asList(ftpClient.listFiles()); + ftpFiles=ftpFiles.stream().filter(item -> item.getName().equals(fileName)).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(ftpFiles)){ + throw new RuntimeException("ftp下对应的报告文件不存在"); + } + FTPFile ftpFile = ftpFiles.get(0); + if (Objects.nonNull(ftpFile)){ + inputStream = ftpClient.retrieveFileStream(ftpFile.getName()); + //设置响应类型 + response.setContentType("application/octet-stream"); + //解决中文不能生成文件 + response.setHeader("Content-Disposition", "attachment; fileName=" + URLEncoder.encode("ARR.txt","UTF-8")); + outputStream = response.getOutputStream(); + byte[] buffer = new byte[1024]; + int bytesRead; + // 将文件输出流写入到输出流中 + while ((bytesRead = inputStream.read(buffer)) != -1) { + outputStream.write(buffer, 0, bytesRead); + } + } + } catch (IOException e) { + throw new RuntimeException(e); + } finally { + try { + if (Objects.nonNull(ftpClient)){ + ftpClient.disconnect(); + } + if (ObjectUtil.isNotNull(inputStream)){ + inputStream.close(); + } + if (ObjectUtil.isNotNull(outputStream)){ + outputStream.close(); + } + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } + @Override public Result viewRRR(Integer sampleId, String fileName) { Result result = new Result(); @@ -1809,6 +1938,35 @@ public class GammaServiceImpl implements IGammaService { return result; } + @Override + public void exportRRR(Integer sampleId, String fileName, HttpServletResponse response) { + Cache phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(fileName); + if (Objects.isNull(phd)) { + return; + } + String reportContent = gammaFileUtil.GetReportContent(phd, false); + OutputStream fos = null; + try { + //设置响应类型 + response.setContentType("application/octet-stream"); + //解决中文不能生成文件 + response.setHeader("Content-Disposition", "attachment; fileName=" + URLEncoder.encode("RRR.txt","UTF-8")); + fos = response.getOutputStream(); + fos.write(reportContent.getBytes()); + } catch (FileNotFoundException e) { + throw new RuntimeException(e); + } catch (IOException e) { + throw new RuntimeException(e); + } finally { + try { + fos.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } + @Override public Result> radionuclideActivity(Integer sampleId, String fileName) { 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 ef57c2b4..b830ea13 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 @@ -9,12 +9,14 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.StringPool; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.google.common.cache.Cache; import org.apache.commons.io.FileUtils; import org.apache.commons.net.ftp.FTP; import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPFile; import org.jeecg.common.api.QueryRequest; import org.jeecg.common.api.vo.Result; +import org.jeecg.common.cache.BetaCache; import org.jeecg.common.constant.DateConstant; import org.jeecg.common.constant.SymbolConstant; import org.jeecg.common.properties.SpectrumPathProperties; @@ -30,6 +32,7 @@ import org.jeecg.modules.entity.*; import org.jeecg.modules.entity.vo.*; import org.jeecg.modules.mapper.SpectrumAnalysisMapper; import org.jeecg.modules.native_jni.EnergySpectrumHandler; +import org.jeecg.modules.native_jni.struct.BgAnalyseResult; import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct; import org.jeecg.modules.service.*; import org.springframework.beans.factory.annotation.Autowired; @@ -72,6 +75,8 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { @Autowired private PHDFileUtil phdFileUtil; @Autowired + private BetaCache betaCache; + @Autowired private IGardsSampleDataSpectrumService sampleDataSpectrumService; @Autowired private IGardsSampleAuxSpectrumService sampleAuxSpectrumService; @@ -82,16 +87,6 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { @Autowired private IGardsSampleCertLineSpectrumService sampleCertLineSpectrumService; @Autowired - private IGardsCalibrationSpectrumService calibrationSpectrumService; - @Autowired - private IGardsROIChannelsSpectrumService roiChannelsSpectrumService; - @Autowired - private IGardsXeResultsSpectrumService xeResultsSpectrumService; - @Autowired - private IGardsROIResultsSpectrumService roiResultsSpectrumService; - @Autowired - private IGardsCalibrationPairsSpectrumService calibrationPairsSpectrumService; - @Autowired private IGardsCalibrationPairsOrigSpectrumService calibrationPairsOrigSpectrumService; @Autowired private IGardsBgEfficiencyPairsSpectrumService bgEfficiencyPairsSpectrumService; @@ -1347,6 +1342,8 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { Result result = new Result(); Map map = new HashMap<>(); String userName = JwtUtil.getUserNameByToken(request); + Cache> cache = betaCache.getBetaCache(); + Map cacheMap = new HashMap<>(); String qcPath = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; //如果sampleId不为空 if (Objects.nonNull(sampleId)) { @@ -1465,6 +1462,11 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { map.put("min", min); map.put("max", max); map.put("gammaSpectrum", seriseDataList); + + cacheMap.put("Series", oldScatterSeries); + cacheMap.put("fittingPara", fittingParaStr); + cache.put(qcFileName+"-"+userName+"-gamma", cacheMap); + betaCache.setBetaCache(cache); } } } catch (IOException e) { @@ -1491,6 +1493,8 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { Result result = new Result(); Map map = new HashMap<>(); String userName = JwtUtil.getUserNameByToken(request); + Cache> cache = betaCache.getBetaCache(); + Map cacheMap = new HashMap<>(); String qcPath = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; if (Objects.nonNull(sampleId)) { GardsSampleData sampleData = spectrumAnalysisMapper.getSampleData(sampleId); @@ -1611,6 +1615,11 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { fittingParaToUiStr.add(String.valueOf(para)); } map.put("EToC", fittingParaToUiStr); + + cacheMap.put("Series", oldScatterSeries); + cacheMap.put("fittingPara", fittingParaStr); + cache.put(qcFileName+"-"+userName+"-beta", cacheMap); + betaCache.setBetaCache(cache); } } } catch (IOException e) { @@ -2183,8 +2192,11 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } @Override - public Result fitting(Double paramA, Double paramB, Double paramC, List tempPoints, Integer count) { + public Result fitting(Double paramA, Double paramB, Double paramC, List tempPoints, Integer count, String qcFileName, String tabName, HttpServletRequest request) { Result result = new Result(); + String userName = JwtUtil.getUserNameByToken(request); + Cache> cache = betaCache.getBetaCache(); + Map cacheMap = new HashMap<>(); Map map = new HashMap<>(); //加载dll工具库 System.loadLibrary("ReadPHDFile"); @@ -2224,11 +2236,20 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { fittingParaToUiStr.add(String.valueOf(para)); } map.put("EToC", fittingParaToUiStr); - }else { + + cacheMap.put("Series", tempPoints); + cacheMap.put("fittingPara", fittingParaStr); + cache.put(qcFileName+"-"+userName+"-"+tabName, cacheMap); + betaCache.setBetaCache(cache); + } else { List fittingPara = new LinkedList<>(); fittingPara.add(paramA); fittingPara.add(paramB); fittingPara.add(paramC); + List fittingParaStr = new LinkedList<>(); + fittingParaStr.add(String.valueOf(paramA)); + fittingParaStr.add(String.valueOf(paramB)); + fittingParaStr.add(String.valueOf(paramC)); List xs = new LinkedList<>(); for (int i=0; i> cache = betaCache.getBetaCache(); + //根据qc文件名称-用户名-beta的方式获取beta的内容 + Map betaMap = cache.getIfPresent(anlyseResultIn.getQcFileName() + "-" + userName + "-beta"); + List betaList = new LinkedList<>(); + List betaFittingPara = new LinkedList<>(); + if (CollectionUtils.isNotEmpty(betaMap)) { + betaList = (List)betaMap.get("Series"); + betaFittingPara = (List) betaMap.get("fittingPara"); + } + //根据qc文件名称-用户名-gamma的方式获取gamma的内容 + Map gammaMap = cache.getIfPresent(anlyseResultIn.getQcFileName() + "-" + userName + "-gamma"); + List gammaList = new LinkedList<>(); + List gammaFittingPara = new LinkedList<>(); + if (CollectionUtils.isNotEmpty(gammaMap)) { + gammaList = (List)gammaMap.get("Series"); + gammaFittingPara = (List) gammaMap.get("fittingPara"); + } + //获取当前时间作为人工分析开始时间 String beginDate = DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss"); + //获取当前时间作为人工分析结束时间 String endDate = DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss"); //判断当前分析员是否有过排班任务 Integer stationId = spectrumAnalysisMapper.getStationId(anlyseResultIn.getStationName()); + //判断当前分析员是否有过当前台站的排班任务 boolean bAnalysisResultWriteAuthority = userTaskUtil.CheckUserWriteAuthorityForStation(anlyseResultIn.getUserName(), stationId); if ( !bAnalysisResultWriteAuthority ){ result.error500("This user has no right to store the results of the analysis to the database."); return result; } - //处理数据 获取对应的channel/energy值 - getChannelAndEnergy(anlyseResultIn); //获取ROI Limit数据 // getROILimit(anlyseResultIn); //根据sample文件名称模糊查询sampleId @@ -2696,7 +2743,11 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { anlyseResultIn.setQcFilePath(StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName); } - + //处理数据 获取对应的channel/energy值 + getChannelAndEnergy(anlyseResultIn, betaList, gammaList); + //分析文件内容 + Map map = new HashMap<>(); + analyzePHDFile(anlyseResultIn, betaFittingPara, gammaFittingPara, map); //处理文件名称 String sampleFilePathName = phdFileUtil.NameStandardBy(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName()); String gasFilePathName = phdFileUtil.NameStandardBy(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName()); @@ -2784,9 +2835,9 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } //gards_roi_channels数据表 List roiChannelsList = new LinkedList<>(); - getROIChannel(sampleId, idAnalysis, anlyseResultIn.getRoiChannelsSpectrumList(), roiChannelsList); - getROIChannel(gasId, idAnalysis, anlyseResultIn.getRoiChannelsSpectrumList(), roiChannelsList); - getROIChannel(detId, idAnalysis, anlyseResultIn.getRoiChannelsSpectrumList(), roiChannelsList); + getROIChannel(sampleId, idAnalysis, anlyseResultIn.getRoiChannelsSpectrumList(), roiChannelsList, DataTypeAbbr.SAMPLEPHD.getType()); + getROIChannel(gasId, idAnalysis, anlyseResultIn.getRoiChannelsSpectrumList(), roiChannelsList, DataTypeAbbr.GASBKPHD.getType()); + getROIChannel(detId, idAnalysis, anlyseResultIn.getRoiChannelsSpectrumList(), roiChannelsList, DataTypeAbbr.DETBKPHD.getType()); //如果分析过数据 if (Objects.nonNull(isExist)){ //删除gards_roi_channels数据表数据 @@ -2817,7 +2868,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } } //gards_roi_results数据表 - List roiResultsSpectrumList = getROIResult(anlyseResultIn.getRoiResultsSpectrumList(), sampleId, idAnalysis, isExist); + List roiResultsSpectrumList = getROIResult(anlyseResultIn.getRoiResultsSpectrumList(), sampleId, idAnalysis); if(Objects.nonNull(isExist)) { //删除gards_roi_results数据表数据 spectrumAnalysisMapper.deleteROIResults(idAnalysis); @@ -2832,16 +2883,16 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } } //上传本次文件到ftp人工交互存储路径下 - File sampleTmp = phdFileUtil.analyzeFile(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName()); - File gasTmp = phdFileUtil.analyzeFile(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName()); - File detTmp = phdFileUtil.analyzeFile(anlyseResultIn.getDetFilePath(), anlyseResultIn.getDetFileName()); - try { - ftpUtil.saveFile(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePathName.substring(0, sampleFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getSampleFileName(), new FileInputStream(sampleTmp)); - ftpUtil.saveFile(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + gasFilePathName.substring(0, gasFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getGasFileName(), new FileInputStream(gasTmp)); - ftpUtil.saveFile(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + detFilePathName.substring(0, detFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getDetFileName(), new FileInputStream(detTmp)); - } catch (FileNotFoundException e) { - throw new RuntimeException(e); - } +// File sampleTmp = phdFileUtil.analyzeFile(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName()); +// File gasTmp = phdFileUtil.analyzeFile(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName()); +// File detTmp = phdFileUtil.analyzeFile(anlyseResultIn.getDetFilePath(), anlyseResultIn.getDetFileName()); +// try { +// ftpUtil.saveFile(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePathName.substring(0, sampleFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getSampleFileName(), new FileInputStream(sampleTmp)); +// ftpUtil.saveFile(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + gasFilePathName.substring(0, gasFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getGasFileName(), new FileInputStream(gasTmp)); +// ftpUtil.saveFile(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + detFilePathName.substring(0, detFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getDetFileName(), new FileInputStream(detTmp)); +// } catch (FileNotFoundException e) { +// throw new RuntimeException(e); +// } result.setSuccess(true); return result; } @@ -2930,7 +2981,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } - public void getChannelAndEnergy(BgDataAnlyseResultIn anlyseResultIn) { + public void getChannelAndEnergy(BgDataAnlyseResultIn anlyseResultIn, List betaList, List gammaList) { //获取ftp文件路径下临时文件 File sampleTmp = phdFileUtil.analyzeFile(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName()); File gasTmp = phdFileUtil.analyzeFile(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName()); @@ -2944,11 +2995,21 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { if (!anlyseResultIn.isBGammaEnergyValid()){ anlyseResultIn.setG_channel_sample(sourceData.g_centroid_channel); anlyseResultIn.setG_energy_sample(sourceData.g_energy); + } else { + List channels = gammaList.stream().map(SeriseData::getX).collect(Collectors.toList()); + anlyseResultIn.setG_channel_sample(channels); + List energys = gammaList.stream().map(SeriseData::getY).collect(Collectors.toList()); + anlyseResultIn.setG_energy_sample(energys); } //没有点击过Energy Calibration页面下Beta Detector Calibration的fitting按钮 channel/energy数据读取文件 如果点击过数据来源页面 if (!anlyseResultIn.isBGammaEnergyValid()){ anlyseResultIn.setB_channel_sample(sourceData.b_channel); anlyseResultIn.setB_energy_sample(sourceData.b_electron_energy); + } else { + List channels = betaList.stream().map(SeriseData::getX).collect(Collectors.toList()); + anlyseResultIn.setB_channel_sample(channels); + List energys = betaList.stream().map(SeriseData::getY).collect(Collectors.toList()); + anlyseResultIn.setB_energy_sample(energys); } } else {//如果没有勾选Energy Calibration页面下sample Data EnergySpectrumStruct sourceData = EnergySpectrumHandler.getSourceData(sampleTmp.getAbsolutePath()); @@ -2964,10 +3025,20 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { if (!anlyseResultIn.isBGammaEnergyValid()){ anlyseResultIn.setG_channel_gas(sourceData.g_centroid_channel); anlyseResultIn.setG_energy_gas(sourceData.g_energy); + } else { + List channels = gammaList.stream().map(SeriseData::getX).collect(Collectors.toList()); + anlyseResultIn.setG_channel_gas(channels); + List energys = gammaList.stream().map(SeriseData::getY).collect(Collectors.toList()); + anlyseResultIn.setG_energy_gas(energys); } if (!anlyseResultIn.isBGammaEnergyValid()){ anlyseResultIn.setB_channel_gas(sourceData.b_channel); anlyseResultIn.setB_energy_gas(sourceData.b_electron_energy); + } else { + List channels = betaList.stream().map(SeriseData::getX).collect(Collectors.toList()); + anlyseResultIn.setB_channel_gas(channels); + List energys = betaList.stream().map(SeriseData::getY).collect(Collectors.toList()); + anlyseResultIn.setB_energy_gas(energys); } } else { EnergySpectrumStruct sourceData = EnergySpectrumHandler.getSourceData(gasTmp.getAbsolutePath()); @@ -2983,10 +3054,20 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { if (!anlyseResultIn.isBGammaEnergyValid()){ anlyseResultIn.setG_channel_det(sourceData.g_centroid_channel); anlyseResultIn.setG_energy_det(sourceData.g_energy); + } else { + List channels = gammaList.stream().map(SeriseData::getX).collect(Collectors.toList()); + anlyseResultIn.setG_channel_det(channels); + List energys = gammaList.stream().map(SeriseData::getY).collect(Collectors.toList()); + anlyseResultIn.setG_energy_det(energys); } if (!anlyseResultIn.isBGammaEnergyValid()){ anlyseResultIn.setB_channel_det(sourceData.b_channel); anlyseResultIn.setB_energy_det(sourceData.b_electron_energy); + } else { + List channels = betaList.stream().map(SeriseData::getX).collect(Collectors.toList()); + anlyseResultIn.setB_channel_det(channels); + List energys = betaList.stream().map(SeriseData::getY).collect(Collectors.toList()); + anlyseResultIn.setB_energy_det(energys); } } else { EnergySpectrumStruct sourceData = EnergySpectrumHandler.getSourceData(detTmp.getAbsolutePath()); @@ -2998,6 +3079,203 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } } + public void analyzePHDFile(BgDataAnlyseResultIn anlyseResultIn,List betaFittingPara, List gammaFittingPara, Map map) { + //根据文件路径 文件名称获取对应的临时文件 + File sampleTmp = phdFileUtil.analyzeFile(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName()); + File gasTmp = phdFileUtil.analyzeFile(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName()); + File detTmp = phdFileUtil.analyzeFile(anlyseResultIn.getDetFilePath(), anlyseResultIn.getDetFileName()); + //加载dll工具库 + System.loadLibrary("ReadPHDFile"); + //调用动态库解析文件 + + //Gamma Energy Calibration页面 如果点击过fitting使BGammaEnergyValid并且有勾选 + //如果三个sampleData,GasData,DetData数据都是被勾选状态 则需要传递新的参数重新分析 否则不需要改变数据分析当前文件内容 + BgAnalyseResult bgAnalyseResult = null; + if (anlyseResultIn.isCheckSample() && anlyseResultIn.isCheckGas() && anlyseResultIn.isCheckDet()) { + bgAnalyseResult = EnergySpectrumHandler.bgAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath()); + } else { + bgAnalyseResult = EnergySpectrumHandler.bgAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath()); + } + List xeResultsSpectrumList = new LinkedList<>(); + GardsXeResults xe131m = new GardsXeResults(); + xe131m.setNuclideName(XeNuclideName.XE_131m.getType()); + xe131m.setConc(bgAnalyseResult.Xe131m_con); + xe131m.setConcErr(bgAnalyseResult.Xe131m_uncer); + xe131m.setLc(bgAnalyseResult.LC_Xe131m); + xe131m.setMdc(bgAnalyseResult.MDC_Xe131m); + xe131m.setNidFlag(anlyseResultIn.getXe131mFlag()); + xeResultsSpectrumList.add(xe131m); + GardsXeResults xe133 = new GardsXeResults(); + xe133.setNuclideName(XeNuclideName.XE_133.getType()); + xe133.setConc(bgAnalyseResult.Xe133_con); + xe133.setConcErr(bgAnalyseResult.Xe133_uncer); + xe133.setLc(bgAnalyseResult.LC_Xe133); + xe133.setMdc(bgAnalyseResult.MDC_Xe133); + xe133.setNidFlag(anlyseResultIn.getXe133Flag()); + xeResultsSpectrumList.add(xe133); + GardsXeResults xe133m = new GardsXeResults(); + xe133m.setNuclideName(XeNuclideName.XE_133m.getType()); + xe133m.setConc(bgAnalyseResult.Xe133m_con); + xe133m.setConcErr(bgAnalyseResult.Xe133m_uncer); + xe133m.setLc(bgAnalyseResult.LC_Xe133m); + xe133m.setMdc(bgAnalyseResult.MDC_Xe133m); + xe133m.setNidFlag(anlyseResultIn.getXe133mFlag()); + xeResultsSpectrumList.add(xe133m); + GardsXeResults xe135 = new GardsXeResults(); + xe135.setNuclideName(XeNuclideName.XE_135.getType()); + xe135.setConc(bgAnalyseResult.Xe135_con); + xe135.setConcErr(bgAnalyseResult.Xe135_uncer); + xe135.setLc(bgAnalyseResult.LC_Xe135); + xe135.setMdc(bgAnalyseResult.MDC_Xe135); + xe135.setNidFlag(anlyseResultIn.getXe135Flag()); + xeResultsSpectrumList.add(xe135); + anlyseResultIn.setXeData(xeResultsSpectrumList); + + List gammaCalibrationSpectrumList = new LinkedList<>(); + if (anlyseResultIn.isBGammaEnergyValid()) { + GardsCalibrationSpectrum gammaCalibrationS = new GardsCalibrationSpectrum(); + gammaCalibrationS.setDataType(DataTypeAbbr.SAMPLEPHD.getType()); + gammaCalibrationS.setCoeff1(Double.valueOf(gammaFittingPara.get(0))); + gammaCalibrationS.setCoeff2(Double.valueOf(gammaFittingPara.get(1))); + gammaCalibrationS.setCoeff3(Double.valueOf(gammaFittingPara.get(2))); + gammaCalibrationSpectrumList.add(gammaCalibrationS); + GardsCalibrationSpectrum gammaCalibrationG = new GardsCalibrationSpectrum(); + gammaCalibrationG.setDataType(DataTypeAbbr.GASBKPHD.getType()); + gammaCalibrationG.setCoeff1(Double.valueOf(gammaFittingPara.get(0))); + gammaCalibrationG.setCoeff2(Double.valueOf(gammaFittingPara.get(1))); + gammaCalibrationG.setCoeff3(Double.valueOf(gammaFittingPara.get(2))); + gammaCalibrationSpectrumList.add(gammaCalibrationG); + GardsCalibrationSpectrum gammaCalibrationD = new GardsCalibrationSpectrum(); + gammaCalibrationD.setDataType(DataTypeAbbr.DETBKPHD.getType()); + gammaCalibrationD.setCoeff1(Double.valueOf(gammaFittingPara.get(0))); + gammaCalibrationD.setCoeff2(Double.valueOf(gammaFittingPara.get(1))); + gammaCalibrationD.setCoeff3(Double.valueOf(gammaFittingPara.get(2))); + gammaCalibrationSpectrumList.add(gammaCalibrationD); + anlyseResultIn.setGammaCalibrationSpectrumList(gammaCalibrationSpectrumList); + } else { + GardsCalibrationSpectrum gammaCalibrationS = new GardsCalibrationSpectrum(); + gammaCalibrationS.setDataType(DataTypeAbbr.SAMPLEPHD.getType()); + gammaCalibrationS.setCoeff1(bgAnalyseResult.s_g_fitting_c_e.get(0)); + gammaCalibrationS.setCoeff2(bgAnalyseResult.s_g_fitting_c_e.get(1)); + gammaCalibrationS.setCoeff3(bgAnalyseResult.s_g_fitting_c_e.get(2)); + gammaCalibrationSpectrumList.add(gammaCalibrationS); + GardsCalibrationSpectrum gammaCalibrationG = new GardsCalibrationSpectrum(); + gammaCalibrationG.setDataType(DataTypeAbbr.GASBKPHD.getType()); + gammaCalibrationG.setCoeff1(bgAnalyseResult.g_g_fitting_c_e.get(0)); + gammaCalibrationG.setCoeff2(bgAnalyseResult.g_g_fitting_c_e.get(1)); + gammaCalibrationG.setCoeff3(bgAnalyseResult.g_g_fitting_c_e.get(2)); + gammaCalibrationSpectrumList.add(gammaCalibrationG); + GardsCalibrationSpectrum gammaCalibrationD = new GardsCalibrationSpectrum(); + gammaCalibrationD.setDataType(DataTypeAbbr.DETBKPHD.getType()); + gammaCalibrationD.setCoeff1(bgAnalyseResult.d_g_fitting_c_e.get(0)); + gammaCalibrationD.setCoeff2(bgAnalyseResult.d_g_fitting_c_e.get(1)); + gammaCalibrationD.setCoeff3(bgAnalyseResult.d_g_fitting_c_e.get(2)); + gammaCalibrationSpectrumList.add(gammaCalibrationD); + anlyseResultIn.setGammaCalibrationSpectrumList(gammaCalibrationSpectrumList); + } + + + List betaCalibrationSpectrumList = new LinkedList<>(); + if (anlyseResultIn.isBBetaEnergyValid()) { + GardsCalibrationSpectrum betaCalibrationS = new GardsCalibrationSpectrum(); + betaCalibrationS.setDataType(DataTypeAbbr.SAMPLEPHD.getType()); + betaCalibrationS.setCoeff1(Double.valueOf(betaFittingPara.get(0))); + betaCalibrationS.setCoeff2(Double.valueOf(betaFittingPara.get(1))); + betaCalibrationS.setCoeff3(Double.valueOf(betaFittingPara.get(2))); + betaCalibrationSpectrumList.add(betaCalibrationS); + GardsCalibrationSpectrum betaCalibrationG = new GardsCalibrationSpectrum(); + betaCalibrationG.setDataType(DataTypeAbbr.GASBKPHD.getType()); + betaCalibrationG.setCoeff1(Double.valueOf(betaFittingPara.get(0))); + betaCalibrationG.setCoeff2(Double.valueOf(betaFittingPara.get(1))); + betaCalibrationG.setCoeff3(Double.valueOf(betaFittingPara.get(2))); + betaCalibrationSpectrumList.add(betaCalibrationG); + GardsCalibrationSpectrum betaCalibrationD = new GardsCalibrationSpectrum(); + betaCalibrationD.setDataType(DataTypeAbbr.DETBKPHD.getType()); + betaCalibrationD.setCoeff1(Double.valueOf(betaFittingPara.get(0))); + betaCalibrationD.setCoeff2(Double.valueOf(betaFittingPara.get(1))); + betaCalibrationD.setCoeff3(Double.valueOf(betaFittingPara.get(2))); + betaCalibrationSpectrumList.add(betaCalibrationD); + } else { + GardsCalibrationSpectrum betaCalibrationS = new GardsCalibrationSpectrum(); + betaCalibrationS.setDataType(DataTypeAbbr.SAMPLEPHD.getType()); + betaCalibrationS.setCoeff1(bgAnalyseResult.s_b_fitting_c_e.get(0)); + betaCalibrationS.setCoeff2(bgAnalyseResult.s_b_fitting_c_e.get(1)); + betaCalibrationS.setCoeff3(bgAnalyseResult.s_b_fitting_c_e.get(2)); + betaCalibrationSpectrumList.add(betaCalibrationS); + GardsCalibrationSpectrum betaCalibrationG = new GardsCalibrationSpectrum(); + betaCalibrationG.setDataType(DataTypeAbbr.GASBKPHD.getType()); + betaCalibrationG.setCoeff1(bgAnalyseResult.g_b_fitting_c_e.get(0)); + betaCalibrationG.setCoeff2(bgAnalyseResult.g_b_fitting_c_e.get(1)); + betaCalibrationG.setCoeff3(bgAnalyseResult.g_b_fitting_c_e.get(2)); + betaCalibrationSpectrumList.add(betaCalibrationG); + GardsCalibrationSpectrum betaCalibrationD = new GardsCalibrationSpectrum(); + betaCalibrationD.setDataType(DataTypeAbbr.DETBKPHD.getType()); + betaCalibrationD.setCoeff1(bgAnalyseResult.d_b_fitting_c_e.get(0)); + betaCalibrationD.setCoeff2(bgAnalyseResult.d_b_fitting_c_e.get(1)); + betaCalibrationD.setCoeff3(bgAnalyseResult.d_b_fitting_c_e.get(2)); + betaCalibrationSpectrumList.add(betaCalibrationD); + } + + anlyseResultIn.setBetaCalibrationSpectrumList(betaCalibrationSpectrumList); + List roiChannelsSpectrumList = new LinkedList<>(); + for (int i=0; i roiResultsSpectrumList = new LinkedList<>(); + for (int i=0; ibgAnalyseResult.MDC.get(i)) { + roiResults.setNidFlag(1); + } else { + roiResults.setNidFlag(0); + } + roiResultsSpectrumList.add(roiResults); + } + anlyseResultIn.setRoiResultsSpectrumList(roiResultsSpectrumList); + } + public List getCalibrationPairs(BgDataAnlyseResultIn anlyseResultIn, Integer sampleId, Integer gasId, Integer detId, Integer idAnalysis) { List calibrationPairsList = new LinkedList<>(); for (int i=0; i< anlyseResultIn.getB_channel_sample().size(); i++){ @@ -3152,10 +3430,13 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { calibrationB.setFunctionDef(FittingType.POLY2.getDescription()); calibrationB.setStartOfRange(0); calibrationB.setEndOfRange(1); - calibrationB.setCoeff1(Double.valueOf(anlyseResultIn.getParam_a_c2e_b_sample())); - calibrationB.setCoeff2(Double.valueOf(anlyseResultIn.getParam_b_c2e_b_sample())); - calibrationB.setCoeff3(Double.valueOf(anlyseResultIn.getParam_c_c2e_b_sample())); + List betaCollect = anlyseResultIn.getBetaCalibrationSpectrumList().stream().filter(item -> item.getDataType().equals(DataTypeAbbr.SAMPLEPHD.getType())).collect(Collectors.toList()); + GardsCalibrationSpectrum betaCalibrationSpectrum = betaCollect.get(0); + calibrationB.setCoeff1(Double.valueOf(betaCalibrationSpectrum.getCoeff1())); + calibrationB.setCoeff2(Double.valueOf(betaCalibrationSpectrum.getCoeff2())); + calibrationB.setCoeff3(Double.valueOf(betaCalibrationSpectrum.getCoeff3())); calibrationSpectrumList.add(calibrationB); + GardsCalibration calibrationG = new GardsCalibration(); calibrationG.setSampleId(sampleId); calibrationG.setIdAnalysis(idAnalysis); @@ -3165,13 +3446,16 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { calibrationG.setFunctionDef(FittingType.POLY2.getDescription()); calibrationG.setStartOfRange(0); calibrationG.setEndOfRange(1); - calibrationG.setCoeff1(Double.valueOf(anlyseResultIn.getParam_a_c2e_g_sample())); - calibrationG.setCoeff2(Double.valueOf(anlyseResultIn.getParam_b_c2e_g_sample())); - calibrationG.setCoeff3(Double.valueOf(anlyseResultIn.getParam_c_c2e_g_sample())); + List gammaCollect = anlyseResultIn.getGammaCalibrationSpectrumList().stream().filter(item -> item.getDataType().equals(DataTypeAbbr.SAMPLEPHD.getType())).collect(Collectors.toList()); + GardsCalibrationSpectrum gammaCalibrationSpectrum = gammaCollect.get(0); + calibrationG.setCoeff1(Double.valueOf(gammaCalibrationSpectrum.getCoeff1())); + calibrationG.setCoeff2(Double.valueOf(gammaCalibrationSpectrum.getCoeff2())); + calibrationG.setCoeff3(Double.valueOf(gammaCalibrationSpectrum.getCoeff3())); calibrationSpectrumList.add(calibrationG); } if (Objects.nonNull(gasId)) { + //gas文件 Beta部分 GardsCalibration calibrationB = new GardsCalibration(); calibrationB.setSampleId(gasId); calibrationB.setIdAnalysis(idAnalysis); @@ -3181,10 +3465,13 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { calibrationB.setFunctionDef(FittingType.POLY2.getDescription()); calibrationB.setStartOfRange(0); calibrationB.setEndOfRange(1); - calibrationB.setCoeff1(Double.valueOf(anlyseResultIn.getParam_a_c2e_b_gas())); - calibrationB.setCoeff2(Double.valueOf(anlyseResultIn.getParam_b_c2e_b_gas())); - calibrationB.setCoeff3(Double.valueOf(anlyseResultIn.getParam_c_c2e_b_gas())); + List betaCollect = anlyseResultIn.getBetaCalibrationSpectrumList().stream().filter(item -> item.getDataType().equals(DataTypeAbbr.GASBKPHD.getType())).collect(Collectors.toList()); + GardsCalibrationSpectrum betaCalibrationSpectrum = betaCollect.get(0); + calibrationB.setCoeff1(Double.valueOf(betaCalibrationSpectrum.getCoeff1())); + calibrationB.setCoeff2(Double.valueOf(betaCalibrationSpectrum.getCoeff2())); + calibrationB.setCoeff3(Double.valueOf(betaCalibrationSpectrum.getCoeff3())); calibrationSpectrumList.add(calibrationB); + //gas文件 gamma部分 GardsCalibration calibrationG = new GardsCalibration(); calibrationG.setSampleId(gasId); calibrationG.setIdAnalysis(idAnalysis); @@ -3194,9 +3481,11 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { calibrationG.setFunctionDef(FittingType.POLY2.getDescription()); calibrationG.setStartOfRange(0); calibrationG.setEndOfRange(1); - calibrationG.setCoeff1(Double.valueOf(anlyseResultIn.getParam_a_c2e_g_gas())); - calibrationG.setCoeff2(Double.valueOf(anlyseResultIn.getParam_b_c2e_g_gas())); - calibrationG.setCoeff3(Double.valueOf(anlyseResultIn.getParam_c_c2e_g_gas())); + List gammaCollect = anlyseResultIn.getGammaCalibrationSpectrumList().stream().filter(item -> item.getDataType().equals(DataTypeAbbr.GASBKPHD.getType())).collect(Collectors.toList()); + GardsCalibrationSpectrum gammaCalibrationSpectrum = gammaCollect.get(0); + calibrationG.setCoeff1(Double.valueOf(gammaCalibrationSpectrum.getCoeff1())); + calibrationG.setCoeff2(Double.valueOf(gammaCalibrationSpectrum.getCoeff2())); + calibrationG.setCoeff3(Double.valueOf(gammaCalibrationSpectrum.getCoeff3())); calibrationSpectrumList.add(calibrationG); } @@ -3210,9 +3499,11 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { calibrationB.setFunctionDef(FittingType.POLY2.getDescription()); calibrationB.setStartOfRange(0); calibrationB.setEndOfRange(1); - calibrationB.setCoeff1(Double.valueOf(anlyseResultIn.getParam_a_c2e_b_det())); - calibrationB.setCoeff2(Double.valueOf(anlyseResultIn.getParam_b_c2e_b_det())); - calibrationB.setCoeff3(Double.valueOf(anlyseResultIn.getParam_c_c2e_b_det())); + List betaCollect = anlyseResultIn.getBetaCalibrationSpectrumList().stream().filter(item -> item.getDataType().equals(DataTypeAbbr.DETBKPHD.getType())).collect(Collectors.toList()); + GardsCalibrationSpectrum betaCalibrationSpectrum = betaCollect.get(0); + calibrationB.setCoeff1(Double.valueOf(betaCalibrationSpectrum.getCoeff1())); + calibrationB.setCoeff2(Double.valueOf(betaCalibrationSpectrum.getCoeff2())); + calibrationB.setCoeff3(Double.valueOf(betaCalibrationSpectrum.getCoeff3())); calibrationSpectrumList.add(calibrationB); GardsCalibration calibrationG = new GardsCalibration(); calibrationG.setSampleId(detId); @@ -3223,15 +3514,18 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { calibrationG.setFunctionDef(FittingType.POLY2.getDescription()); calibrationG.setStartOfRange(0); calibrationG.setEndOfRange(1); - calibrationG.setCoeff1(Double.valueOf(anlyseResultIn.getParam_a_c2e_g_det())); - calibrationG.setCoeff2(Double.valueOf(anlyseResultIn.getParam_b_c2e_g_det())); - calibrationG.setCoeff3(Double.valueOf(anlyseResultIn.getParam_c_c2e_g_det())); + List gammaCollect = anlyseResultIn.getGammaCalibrationSpectrumList().stream().filter(item -> item.getDataType().equals(DataTypeAbbr.DETBKPHD.getType())).collect(Collectors.toList()); + GardsCalibrationSpectrum gammaCalibrationSpectrum = gammaCollect.get(0); + calibrationG.setCoeff1(Double.valueOf(gammaCalibrationSpectrum.getCoeff1())); + calibrationG.setCoeff2(Double.valueOf(gammaCalibrationSpectrum.getCoeff2())); + calibrationG.setCoeff3(Double.valueOf(gammaCalibrationSpectrum.getCoeff3())); calibrationSpectrumList.add(calibrationG); } return calibrationSpectrumList; } - public void getROIChannel(Integer sampleId, Integer idAnalysis, List roiChannelsSpectrumList, List roiChannelsList) { + public void getROIChannel(Integer sampleId, Integer idAnalysis, List roiChannelsSpectrumList, List roiChannelsList, String dataType) { + roiChannelsSpectrumList = roiChannelsSpectrumList.stream().filter(item-> item.getDataType().equals(dataType)).collect(Collectors.toList()); for (int i=0; i getXeResults(BgDataAnlyseResultIn anlyseResultIn, Integer sampleId, Integer idAnalysis) { - List xeResultsList = new LinkedList<>(); - //Xe131m - GardsXeResults xe131m = new GardsXeResults(); - xe131m.setSampleId(sampleId); - xe131m.setIdAnalysis(idAnalysis); - xe131m.setNuclideName(XeNuclideName.XE_131m.getType()); - xe131m.setConc(anlyseResultIn.getXe131m_con()); - xe131m.setConcErr(anlyseResultIn.getXe131m_uncer()); - xe131m.setMdc(anlyseResultIn.getMdc_Xe131m()); - xe131m.setLc(anlyseResultIn.getLc_Xe131m()); - xe131m.setNidFlag(anlyseResultIn.getXe131mFlag()); - xeResultsList.add(xe131m); - //Xe133 - GardsXeResults xe133 = new GardsXeResults(); - xe133.setSampleId(sampleId); - xe133.setIdAnalysis(idAnalysis); - xe133.setNuclideName(XeNuclideName.XE_133.getType()); - xe133.setConc(anlyseResultIn.getXe133_con()); - xe133.setConcErr(anlyseResultIn.getXe133_uncer()); - xe133.setMdc(anlyseResultIn.getMdc_Xe133()); - xe133.setLc(anlyseResultIn.getLc_Xe133()); - xe133.setNidFlag(anlyseResultIn.getXe133Flag()); - xeResultsList.add(xe133); - //Xe133m - GardsXeResults xe133m = new GardsXeResults(); - xe133m.setSampleId(sampleId); - xe133m.setIdAnalysis(idAnalysis); - xe133m.setNuclideName(XeNuclideName.XE_133m.getType()); - xe133m.setConc(anlyseResultIn.getXe133m_con()); - xe133m.setConcErr(anlyseResultIn.getXe133m_uncer()); - xe133m.setMdc(anlyseResultIn.getMdc_Xe133m()); - xe133m.setLc(anlyseResultIn.getLc_Xe133m()); - xe133m.setNidFlag(anlyseResultIn.getXe133mFlag()); - xeResultsList.add(xe133m); - //Xe135 - GardsXeResults xe135 = new GardsXeResults(); - xe135.setSampleId(sampleId); - xe135.setIdAnalysis(idAnalysis); - xe135.setNuclideName(XeNuclideName.XE_135.getType()); - xe135.setConc(anlyseResultIn.getXe135_con()); - xe135.setConcErr(anlyseResultIn.getXe135_uncer()); - xe135.setMdc(anlyseResultIn.getMdc_Xe135()); - xe135.setLc(anlyseResultIn.getLc_Xe135()); - xe135.setNidFlag(anlyseResultIn.getXe135Flag()); - xeResultsList.add(xe135); + List xeResultsList = anlyseResultIn.getXeData(); + for (GardsXeResults xeResults:xeResultsList) { + xeResults.setIdAnalysis(idAnalysis); + xeResults.setSampleId(sampleId); + } return xeResultsList; } @@ -3463,7 +3717,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { return readLines; } - public List getROIResult(List roiResultsSpectrumList, Integer sampleId, Integer idAnalysis, Integer isExist) { + public List getROIResult(List roiResultsSpectrumList, Integer sampleId, Integer idAnalysis) { List roiResultsList = new LinkedList<>(); for (int i=0; i