Merge remote-tracking branch 'origin/station' into station

# Conflicts:
#	jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java
This commit is contained in:
nieziyan 2023-09-18 20:07:52 +08:00
commit b4178e071a
41 changed files with 1667 additions and 293 deletions

View File

@ -46,6 +46,11 @@ public class SpectrumPathProperties implements Serializable {
*/
private String failPath;
/**
* 手动放置能谱文件获取路径
*/
private String filesourcePath;
/**
* 能谱文件存储路径以能谱系统类型/能谱类型为key以存储路径为value
*/

View File

@ -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;
/**
* 邮件附件临时存储路径

View File

@ -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<String> energyAttribute;
public List<String> efficiencyAttribute;
public List<String> resolutionAttribute;
public List<String> 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<String> getBlock(String title, String sampleId, List<AttributeItemVo> attributeItemVo) {
title = title.replace("%1", sampleId);
List<String> context = getBlockContext(attributeItemVo);
context.add(0, title + STRING_END);
return context;
}
public static void main(String[] args) {
Map<String, Object> 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<String> 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<String> 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<String> 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<AttributeItemVo> 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<List<String>> report = Lists.newLinkedList();
report.add(channels);
report.add(energies);
report.add(errors);
getBlockVerticalContext(energys);
// List<AttributeItem> 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);
}
/**
* 获取标题格式
* <blockquote> ....................................... XXX ........................................ </blockquote>
* @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);
}
/**
* 获取标题格式, 符号默认"."
* <blockquote> ....................................... XXX ........................................ </blockquote>
* @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);
}
/**
* 获取页眉
* <blockquote> XXX..... </blockquote>
* @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);
}
/**
* 获取页眉, 符号默认"."
* <blockquote> XXX..... </blockquote>
* @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<Object> data) {
// if(data.get(0) instanceof AttributeItemVo){
//
// }
// if(data.get(0) instanceof List){
// List<List<String>> tempData = new LinkedList<>();
// for(int row = 0; row < data.get(0).size(); row++) {
// List<String> 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<String> getBlockContext(Map<String, Object> data) {
List<String> result = new LinkedList<>();
int keyWidth = 0;
int valueWidth = 0;
for (Map.Entry<String, Object> entry : data.entrySet()) {
keyWidth = Math.max(entry.getKey().length(), keyWidth);
valueWidth = Math.max(entry.getValue().toString().length(), valueWidth);
}
for (Map.Entry<String, Object> 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<String> getBlockContext(List<AttributeItemVo> data) {
List<String> result = new LinkedList<>();
List<List<String>> tempData = new LinkedList<>();
if(data.size() > 0) {
// 初始化数据
for(int row = 0; row < data.get(0).getContext().size(); row++) {
List<String> 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<String> getBlockVerticalContext(List<AttributeItemVo> data) {
List<String> result = new LinkedList<>();
if(data.size() > 0) {
List<List<String>> tempData = new LinkedList<>();
//
for(int row = 0; row < data.get(0).getContext().size(); row++) {
List<String> 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<String> formatData(List<List<String>> data) {
List<String> result = new LinkedList<>();
// 计算每列数据中最长的字符串长度
int[] columnWidths = new int[data.get(0).size()];
for (List<String> 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<String> 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<String> getPercent(List<String> one, List<String> two) {
List<String> 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<String> getValuePoint(List<String> source, int num) {
List<String> result = Lists.newLinkedList();
for (String str : source) {
result.add(String.format("%." + num + "f", Double.parseDouble(str)));
}
return result;
}
public static List<String> getPass(List<String> source) {
List<String> result = Lists.newLinkedList();
for (String str : source) {
result.add(str.contains("0") ? "Fail" : "Pass");
}
return result;
}
}

View File

@ -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<String> context;
private String unit = "";
public AttributeItemVo(){
}
public AttributeItemVo(String attribute, List<String> context, String unit) {
this.attribute = attribute;
this.context = context;
this.unit = unit;
}
public AttributeItemVo(String attribute, List<String> context) {
this.attribute = attribute;
this.context = context;
}
}

View File

@ -18,4 +18,8 @@ public class FittingBody implements Serializable {
private Integer count;
private String qcFileName;
private String tabName;
}

View File

@ -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");

View File

@ -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<String> 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();
}
}
}
}

View File

@ -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<String> 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();
}
}
}
}

View File

@ -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<String> 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<String> 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("/");

View File

@ -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<GardsSampleData> {
@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<GardsSampleData> 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);

View File

@ -46,6 +46,7 @@ public class BgAnalyseResult {
public List<Double> ROI_con_uncer_err;
public List<Double> MDC;
public List<Integer> dNidFlag;
public List<Double> LC_CTS;
/************************** GARDS_ROI_RESULTS end **************************/
@ -56,6 +57,8 @@ public class BgAnalyseResult {
public List<Double> s_g_fitting_e_c;
public int s_g_fitting_type;
public String s_g_fitting_type_def;
public List<Double> s_b_fitting_c_e;
public List<Double> s_g_fitting_c_e;
public List<Double> g_b_fitting_e_c;
public int g_b_fitting_type;
@ -63,6 +66,8 @@ public class BgAnalyseResult {
public List<Double> g_g_fitting_e_c;
public int g_g_fitting_type;
public String g_g_fitting_type_def;
public List<Double> g_b_fitting_c_e;
public List<Double> g_g_fitting_c_e;
public List<Double> d_b_fitting_e_c;
public int d_b_fitting_type;
@ -70,6 +75,9 @@ public class BgAnalyseResult {
public List<Double> d_g_fitting_e_c;
public int d_g_fitting_type;
public String d_g_fitting_type_def;
public List<Double> d_b_fitting_c_e;
public List<Double> 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 +

View File

@ -15,7 +15,9 @@ public interface GardsCalibrationService extends IService<GardsCalibration> {
* 不提交事务由调用方手动统一提交事务
* @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);
}

View File

@ -14,7 +14,9 @@ public interface GardsRoiChannelsService extends IService<GardsRoiChannels> {
* 不提交事务由调用方手动统一提交事务
* @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);
}

View File

@ -12,6 +12,13 @@ public interface GardsSampleDataService extends IService<GardsSampleData> {
*/
public boolean fileExist(String inputFileName);
/**
* 查询GardsSampleData
* @param inputFileName
* @return
*/
public GardsSampleData findByInputFileName(String inputFileName);
/**
* 获取谱文件保存路径
* @param measurementId

View File

@ -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<GardsAnalysesMapper, G
return analyses;
}
@DS(value = "ora")
@Override
public Integer getIdAnalysis(Integer sampleId) {
LambdaQueryWrapper<GardsAnalyses> wrapper = new LambdaQueryWrapper<>();

View File

@ -23,16 +23,18 @@ public class GardsCalibrationServiceImpl extends ServiceImpl<GardsCalibrationMap
* 不提交事务由调用方手动统一提交事务
* @param analyseResult
* @param sampleId
* @param gasSampleId
* @param detSampleId
* @param anayId
*/
@Override
public void create(BgAnalyseResult analyseResult, Integer sampleId, Integer anayId){
public void create(BgAnalyseResult analyseResult,Integer sampleId,Integer gasSampleId,Integer detSampleId,Integer anayId){
this.saveSampleB_EnergyRecord(analyseResult,sampleId,anayId);
this.saveSampleG_EnergyRecord(analyseResult,sampleId,anayId);
this.saveGasB_EnergyRecord(analyseResult,sampleId,anayId);
this.saveGasG_EnergyRecord(analyseResult,sampleId,anayId);
this.saveDetB_EnergyRecord(analyseResult,sampleId,anayId);
this.saveDetG_EnergyRecord(analyseResult,sampleId,anayId);
this.saveGasB_EnergyRecord(analyseResult,gasSampleId,anayId);
this.saveGasG_EnergyRecord(analyseResult,gasSampleId,anayId);
this.saveDetB_EnergyRecord(analyseResult,detSampleId,anayId);
this.saveDetG_EnergyRecord(analyseResult,detSampleId,anayId);
}
/**

View File

@ -23,14 +23,16 @@ public class GardsRoiChannelsServiceImpl extends ServiceImpl<GardsRoiChannelsMap
* 不提交事务由调用方手动统一提交事务
* @param analyseResult
* @param sampleId
* @param gasSampleId
* @param detSampleId
* @param idAnalysis
*/
@Override
public void create(BgAnalyseResult analyseResult,Integer sampleId, Integer idAnalysis) {
public void create(BgAnalyseResult analyseResult,Integer sampleId,Integer gasSampleId,Integer detSampleId,Integer idAnalysis) {
List<GardsRoiChannels> 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);
}

View File

@ -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<GardsRoiResultsMappe
List<GardsRoiResults> list = Lists.newArrayList();
//C++那边没有补0先加上后续解决后再删除
analyseResult.LC.add(0,0.0D);
for(int i=0;i<analyseResult.ROI.size();i++){
GardsRoiResults roiResults = new GardsRoiResults();
roiResults.setSampleId(sampleId);
@ -40,36 +39,41 @@ public class GardsRoiResultsServiceImpl extends ServiceImpl<GardsRoiResultsMappe
roiResults.setSGross(analyseResult.s_roi_cts.get(i));
roiResults.setGGross(analyseResult.g_roi_cts.get(i));
roiResults.setBGross(analyseResult.d_roi_cts.get(i));
roiResults.setSNet(analyseResult.s_deduct_d_cts.get(i));
roiResults.setGNet(analyseResult.g_deduct_d_cts.get(i));
roiResults.setSNet(0D);
roiResults.setGNet(0D);
roiResults.setNet(analyseResult.ROI_net_coutns.get(i));
roiResults.setNetErr(analyseResult.ROI_net_coutns_err.get(i));
roiResults.setConc(analyseResult.ROI_con_uncer.get(i));
roiResults.setConcErr(analyseResult.ROI_con_uncer_err.get(i));
roiResults.setLc(analyseResult.LC.get(i));
roiResults.setLc(0D);
roiResults.setMdc(0D);
roiResults.setNidFlag(0);
roiResults.setNidFlag(analyseResult.dNidFlag.get(i));
roiResults.setModdate(new Date());
list.add(roiResults);
}
//从下班1开始第一条记录MDC值固定为0
// for(int i=1;i<analyseResult.MDC.size();i++){
// list.get(i).setMdc(0D);
// }
int seriNo = 0;
//从下标3开始每次加3
for(int i=3;i<analyseResult.s_deduct_d_cts.size();i+=3){
list.get(seriNo).setSNet(analyseResult.s_deduct_d_cts.get(i));
seriNo++;
}
//如果CONC大于MDC则NID_FLAG值为1否则为0
//感兴趣区识别标示1识别到0未识别到
for(int i=0;i<analyseResult.MDC.size();i++){
// if(i < analyseResult.ROI_con_uncer.size()){
// if(analyseResult.ROI_con_uncer.get(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<analyseResult.g_deduct_d_cts.size();i+=3){
list.get(seriNo).setGNet(analyseResult.g_deduct_d_cts.get(i));
}
//从下标1开始第一条记录LC值固定为0
for(int i=1;i<analyseResult.LC.size();i++){
list.get(i).setLc(analyseResult.LC.get(i));
}
//从下标1开始第一条记录MDC值固定为0
for(int i=1;i<analyseResult.MDC.size();i++){
list.get(i).setMdc(analyseResult.MDC.get(i));
}
if(!CollectionUtils.isEmpty(list)){

View File

@ -9,7 +9,12 @@ import org.jeecg.modules.mapper.GardsSampleDataMapper;
import org.jeecg.modules.service.GardsSampleDataService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@DS("ora")
@Service
@ -25,11 +30,23 @@ public class GardsSampleDataServiceImpl extends ServiceImpl<GardsSampleDataMappe
public boolean fileExist(String inputFileName) {
LambdaQueryWrapper<GardsSampleData> 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<GardsSampleData> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(GardsSampleData::getInputFileName,inputFileName);
return this.getOne(queryWrapper);
}
/**
* 获取谱文件保存路径
* @param measurementId
@ -38,7 +55,13 @@ public class GardsSampleDataServiceImpl extends ServiceImpl<GardsSampleDataMappe
*/
@Override
public GardsSampleData getSampleIdAndInputFileName(String measurementId, String dataType) {
return this.baseMapper.getSampleIdAndInputFileName(measurementId, dataType);
final List<GardsSampleData> sampleDatas = this.baseMapper.getSampleIdAndInputFileName(measurementId, dataType);
if(!CollectionUtils.isEmpty(sampleDatas)){
//如果查询出多条则需要根据inputFileName字段降序排序后返回第一个
final List<GardsSampleData> sortResult = sampleDatas.stream().sorted(Comparator.comparing(GardsSampleData::getInputFileName).reversed()).collect(Collectors.toList());
return sortResult.get(0);
}
return null;
}
/**

View File

@ -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()) ||

View File

@ -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;

View File

@ -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;

View File

@ -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();

View File

@ -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();

View File

@ -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;

View File

@ -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)));
}
/**

View File

@ -145,7 +145,7 @@ public class Sample_B_Analysis implements BlockConstant {
*/
public void start() throws BAnalyseException {
try{
//修改状态为析中
//修改状态为析中
this.updateStatus(SampleStatus.IN_PROCESS.getValue());
//查询detgas数据sampleId,inputFileNamesample数据在构造函数已经传过来
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 {
//如果找不到sampledetgas谱文件数据则解析失败修改记录状态
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表数据sampledetgas谱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数据表存储sampledetgas谱数据
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_131mXE_133XE_133mXE_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_es_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<Double> roi_net_count_err = analyseResult.ROI_net_coutns_err;
List<String> roi = analyseResult.ROI.stream().map(Object::toString).collect(Collectors.toList());
List<String> lc = analyseResult.LC.stream().map(v->formatToStr5(v)).collect(Collectors.toList());
List<String> lc = analyseResult.LC_CTS.stream().map(v->formatToStr5(v)).collect(Collectors.toList());
List<String> netCount = Lists.newArrayList();
String flag = " +/- ";
for(int i=0;i<roi.size();i++){
@ -661,7 +663,7 @@ public class Sample_B_Analysis implements BlockConstant {
* 保存报告到ftp
*/
private void saveReportToFtp() throws FileNotFoundException {
ftpUtil.saveFile(arrFilePath,arrFileName,new FileInputStream(this.reportTmpFile));
ftpUtil.saveFile(spectrumServiceQuotes.getSpectrumPathProperties().getRootPath()+StringConstant.SLASH+arrFilePath,arrFileName,new FileInputStream(this.reportTmpFile));
this.reportTmpFile.delete();
}

View File

@ -25,7 +25,7 @@ public class SamplephdSpectrum extends S_D_Q_G_SpectrumHandler{
* 检查规则并处理数据
*/
@Override
protected void handler() throws Exception {
public void handler() throws Exception {
if(DataType.SAMPLEPHD.getType().equals(super.currDataType.getType())){
try{
//前置检查
@ -45,8 +45,6 @@ public class SamplephdSpectrum extends S_D_Q_G_SpectrumHandler{
//进行BG(P)谱分析
this.autoAnalysis();
}catch (Exception e){
//修改状态为解析失败
this.spectrumServiceQuotes.getSampleDataService().updateStatus(SampleStatus.FAIL.getValue(),super.sampleData.getInputFileName());
//处理解析失败的文件上传到ftp->undeal目录
super.handleParseingFailFile();
throw e;

View File

@ -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){

View File

@ -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();
}
}

View File

@ -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<String, Map<String, Object>> betaCache = CacheBuilder.newBuilder()
//设置缓存初始大小应该合理设置后续会扩容
.initialCapacity(10)
//最大值
.maximumSize(100)
//并发数设置
.concurrencyLevel(5)
//缓存过期时间写入后5秒钟过期
.expireAfterWrite(5, TimeUnit.HOURS)
//统计缓存命中率
.recordStats()
.build();
public Cache<String, Map<String, Object>> getBetaCache() {
return betaCache;
}
public void setBetaCache(Cache<String, Map<String, Object>> betaCache) {
this.betaCache = betaCache;
}
}

View File

@ -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<Double> 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<String> DoubleLimit_G(List<Double> _data) {
NumberFormat numberFormat = new DecimalFormat("0.##########E0");
public List<String> DoubleLimit_I(List<Double> _data) {
List<String> 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<String> DoubleLimit_G(List<Double> _data) {
NumberFormat numberFormat = new DecimalFormat("0.##########E0");
List<String> 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<Double> dvctLD = new LinkedList<>();
List<String> dvctNuclide_name = new LinkedList<>();
List<String> dvctComments = new LinkedList<>();
for(int m=0;m<fileAnlyse.getVPeak().size();m++) {
for(int m=0; m<fileAnlyse.getVPeak().size(); m++) {
dvctIDPEAK.add(Double.valueOf(m+1));
dvctCENTROIDCHANNEL.add(fileAnlyse.getVPeak().get(m).peakCentroid);
dvctENERGY.add(fileAnlyse.getVPeak().get(m).energy);
@ -3148,21 +3171,14 @@ public class GammaFileUtil {
dvctMEANBACKCOUNT.add(fileAnlyse.getVPeak().get(m).meanBackCount);
dvctLC.add(fileAnlyse.getVPeak().get(m).lc);
dvctLD.add(fileAnlyse.getVPeak().get(m).ld);
String t_comment = fileAnlyse.getVPeak().get(m).comments==null?"":fileAnlyse.getVPeak().get(m).comments.replace("\'", "\'\'").trim();
if(t_comment.length() > 1024){
t_comment = t_comment.substring(0, 1025);
}
dvctComments.add(t_comment);
String qsName = "";
for(int n=0;n<fileAnlyse.getVPeak().get(m).nuclides.size();n++) {
qsName = qsName+fileAnlyse.getVPeak().get(m).nuclides.get(n)+";";
}
dvctNuclide_name.add(qsName);
dvctNuclide_name.add(StringUtils.join(fileAnlyse.getVPeak().get(m).nuclides, ";"));
}
middleData.peaks_idPeak =DoubleLimit_G(dvctIDPEAK);
middleData.peaks_idPeak =DoubleLimit_I(dvctIDPEAK);
middleData.peaks_peakCentroid =DoubleLimit_G(dvctCENTROIDCHANNEL);
middleData.peaks_uncpeakCentroid =DoubleLimit_G(dvctUNCCENTROIDCHANNEL);
middleData.peaks_Energy =DoubleLimit_G(dvctENERGY);
@ -3192,28 +3208,27 @@ public class GammaFileUtil {
middleData.peaks_Ld =DoubleLimit_G(dvctLD);
middleData.peaks_comments = dvctComments;
middleData.peaks_Nuclide_name = dvctNuclide_name;
}
// gards_ nucl_lines_ided数据表
GStoreMiddleProcessDataNuclLinesIded nucl_lines_ided_data = new GStoreMiddleProcessDataNuclLinesIded();
List<String> svctNUCLIDEFULLNAME = new LinkedList<>();
List<Double> dvctIDPEAK = new LinkedList<>();
List<Double> dvctENERGY = new LinkedList<>();
List<Double> dvctUNCENERGY = new LinkedList<>();
List<Double> dvctABUNDANCE = new LinkedList<>();
List<Double> dvctUNCABUNDANCE = new LinkedList<>();
List<String> dvctACTIVITY = new LinkedList<>();
List<Double> dvctUNCACTIVITY = new LinkedList<>();
List<Double> dvctEFFIC = new LinkedList<>();
List<Double> dvctUNEFFIC = new LinkedList<>();
List<String> dvctMDA = new LinkedList<>();
List<Double> dvctKEY_FLAG = new LinkedList<>();
List<Double> dvctCSC_RATIO = new LinkedList<>();
List<Double> dvctCSC_RATIO_ERR = new LinkedList<>();
List<Double> dvctCSC_MOD_FLAG = new LinkedList<>();
List<String> dvctMDC = new LinkedList<>();
List<String> dvctCONCENTRATION = new LinkedList<>();
for(Map.Entry<String, NuclideActMda> itor:fileAnlyse.getMapNucActMda().entrySet()) {
List<String> svctNUCLIDEFULLNAME = new LinkedList<>();
List<Double> dvctIDPEAK = new LinkedList<>();
List<Double> dvctENERGY = new LinkedList<>();
List<Double> dvctUNCENERGY = new LinkedList<>();
List<Double> dvctABUNDANCE = new LinkedList<>();
List<Double> dvctUNCABUNDANCE = new LinkedList<>();
List<String> dvctACTIVITY = new LinkedList<>();
List<Double> dvctUNCACTIVITY = new LinkedList<>();
List<Double> dvctEFFIC = new LinkedList<>();
List<Double> dvctUNEFFIC = new LinkedList<>();
List<String> dvctMDA = new LinkedList<>();
List<Double> dvctKEY_FLAG = new LinkedList<>();
List<Double> dvctCSC_RATIO = new LinkedList<>();
List<Double> dvctCSC_RATIO_ERR = new LinkedList<>();
List<Double> dvctCSC_MOD_FLAG = new LinkedList<>();
List<String> dvctMDC = new LinkedList<>();
List<String> dvctCONCENTRATION = new LinkedList<>();
int first=itor.getValue().getFullNames().size();
int second=itor.getValue().getVPeakIdx().size();
first = first<second?first:second;
@ -3225,7 +3240,6 @@ public class GammaFileUtil {
first = first<second?first:second;
second = itor.getValue().getVUncertY().size();
first = first<second?first:second;
for(int m=0;m<first;m++) {
svctNUCLIDEFULLNAME.add( itor.getValue().getFullNames().get(m).replace("\'", "\'\'") );
dvctIDPEAK.add(itor.getValue().getVPeakIdx().get(m).doubleValue());
@ -3251,7 +3265,7 @@ public class GammaFileUtil {
dvctCONCENTRATION.add(numberFormat.format(itor.getValue().getConcentration()));
}
nucl_lines_ided_data.nuclideFullname = svctNUCLIDEFULLNAME;
nucl_lines_ided_data.idPeak =DoubleLimit_G(dvctIDPEAK);
nucl_lines_ided_data.idPeak =DoubleLimit_I(dvctIDPEAK);
nucl_lines_ided_data.Energy =DoubleLimit_G(dvctENERGY);
nucl_lines_ided_data.uncEnergy =DoubleLimit_G(dvctUNCENERGY);
nucl_lines_ided_data.Abundance =DoubleLimit_G(dvctABUNDANCE);
@ -3270,25 +3284,24 @@ public class GammaFileUtil {
middleData.getNucl_lines_ided_data().put(itor.getKey(), nucl_lines_ided_data);
}
// gards_ nucl_ided数据表
List<String> svctNUCLIDEFULLNAME1 = new LinkedList<>();
List<String> svctTYPE = new LinkedList<>();
List<Double> dvctHALFLIFE = new LinkedList<>();
List<String> dvctAVE_ACTIV = new LinkedList<>();
List<Double> dvctAVE_ACTIV_ERR = new LinkedList<>();
List<Double> dvctACTIV_KEY = new LinkedList<>();
List<Double> dvctACTIV_KEY_ERR = new LinkedList<>();
List<String> dvctMDA1 = new LinkedList<>();
List<Double> dvctMDA_ERR = new LinkedList<>();
List<Double> dvctNID_FLAG = new LinkedList<>();
List<Double> dvctCSC_RATIO1 = new LinkedList<>();
List<Double> dvctCSC_RATIO_ERR1 = new LinkedList<>();
List<Double> dvctCSC_MOD_FLAG1 = new LinkedList<>();
List<String> dvctMDC1 = new LinkedList<>();
List<String> dvctCONCENTRATION1 = new LinkedList<>();
List<Double> dvctKey_Energy = new LinkedList<>();
List<Double> dvctKey_Yield = new LinkedList<>();
if( fileAnlyse.getMapNucActMda().size() != 0) {
List<String> svctNUCLIDEFULLNAME1 = new LinkedList<>();
List<String> svctTYPE = new LinkedList<>();
List<Double> dvctHALFLIFE = new LinkedList<>();
List<String> dvctAVE_ACTIV = new LinkedList<>();
List<Double> dvctAVE_ACTIV_ERR = new LinkedList<>();
List<Double> dvctACTIV_KEY = new LinkedList<>();
List<Double> dvctACTIV_KEY_ERR = new LinkedList<>();
List<String> dvctMDA1 = new LinkedList<>();
List<Double> dvctMDA_ERR = new LinkedList<>();
List<Double> dvctNID_FLAG = new LinkedList<>();
List<Double> dvctCSC_RATIO1 = new LinkedList<>();
List<Double> dvctCSC_RATIO_ERR1 = new LinkedList<>();
List<Double> dvctCSC_MOD_FLAG1 = new LinkedList<>();
List<String> dvctMDC1 = new LinkedList<>();
List<String> dvctCONCENTRATION1 = new LinkedList<>();
List<Double> dvctKey_Energy = new LinkedList<>();
List<Double> dvctKey_Yield = new LinkedList<>();
for(Map.Entry<String, NuclideActMda> 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<String> qvctQC_NAME = new LinkedList<>();
List<Double> dvctQC_VALUE = new LinkedList<>();
List<String> qvctQC_STANDARD = new LinkedList<>();
List<Double> dvctQC_RESULT = new LinkedList<>();
if( fileAnlyse.getQcItems().size() != 0) {
List<String> qvctQC_NAME = new LinkedList<>();
List<Double> dvctQC_VALUE = new LinkedList<>();
List<String> qvctQC_STANDARD = new LinkedList<>();
List<Double> dvctQC_RESULT = new LinkedList<>();
for(Map.Entry<String, QcCheckItem> 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;

View File

@ -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");
}

View File

@ -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) {

View File

@ -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")

View File

@ -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<GardsROIResultsSpectrum> roiResultsSpectrumList;
List<GardsXeResultsSpectrum> XeData;
List<GardsXeResults> XeData;
}

View File

@ -77,12 +77,16 @@ public interface IGammaService{
Result applyDataResolution(List<Double> m_vCurReso, List<Double> m_vCurEnergy, List<Double> m_vCurUncert, ParameterInfo m_curParam, String curCalName, Integer sampleId, String fileName);
void saveDataResolution(List<Double> m_vCurReso, List<Double> m_vCurEnergy, List<Double> m_vCurUncert, HttpServletResponse response);
Result EfficiencyCalibration(Integer sampleId, String fileName, String currentText);
Result changeDataEfficiency(List<Double> m_vCurEffi, List<Double> m_vCurEnergy, List<Double> m_vCurUncert, ParameterInfo m_curParam, Integer funcId, Integer sampleId, String fileName);
Result applyDataEfficiency(List<Double> m_vCurEffi, List<Double> m_vCurEnergy, List<Double> m_vCurUncert, ParameterInfo m_curParam, String curCalName, Integer sampleId, String fileName);
void saveDataEfficiency(List<Double> m_vCurEffi, List<Double> m_vCurEnergy, List<Double> 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);

View File

@ -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<SeriseData> tempPointsArray, Integer count);
Result fitting(Double paramA, Double paramB, Double paramC, List<SeriseData> tempPointsArray, Integer count, String qcFileName, String tabName, HttpServletRequest request);
Result getGammaGated(Integer chartHeight, Integer channelWidth, Integer gammaChannel, Integer sampleId, String qcFileName, HttpServletRequest request);

View File

@ -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<Double> m_vCurReso, List<Double> m_vCurEnergy, List<Double> m_vCurUncert, HttpServletResponse response) {
StringBuffer strBuffer = new StringBuffer();
strBuffer.append("#g_Resolution").append("\n");
for (int i=0; i<m_vCurReso.size(); i++) {
strBuffer.append(m_vCurEnergy.get(i)).append(" ").append(m_vCurReso.get(i)).append(" ").append(m_vCurUncert.get(i)).append("\n");
}
OutputStream fos = null;
try {
//设置响应类型
response.setContentType("application/octet-stream");
//解决中文不能生成文件
response.setHeader("Content-Disposition", "attachment; fileName=" + URLEncoder.encode("ResolutionCalibration.Ent","UTF-8"));
fos = response.getOutputStream();
fos.write(strBuffer.toString().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 EfficiencyCalibration(Integer sampleId, String fileName, String currentText) {
Result result = new Result();
@ -1557,6 +1590,35 @@ public class GammaServiceImpl implements IGammaService {
return result;
}
@Override
public void saveDataEfficiency(List<Double> m_vCurEffi, List<Double> m_vCurEnergy, List<Double> m_vCurUncert, Integer funId, HttpServletResponse response) {
StringBuffer strBuffer = new StringBuffer();
strBuffer.append("#g_Efficiency").append("\n");
for (int i=0; i<m_vCurEffi.size(); i++) {
strBuffer.append(m_vCurEnergy.get(i)).append(" ").append(m_vCurEffi.get(i)).append(" ").append(m_vCurUncert.get(i)).append("\n");
}
strBuffer.append("FitType = ").append(funId);
OutputStream fos = null;
try {
//设置响应类型
response.setContentType("application/octet-stream");
//解决中文不能生成文件
response.setHeader("Content-Disposition", "attachment; fileName=" + URLEncoder.encode("EfficiencyCalibration.Eft","UTF-8"));
fos = response.getOutputStream();
fos.write(strBuffer.toString().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 NuclideLibrary(Integer sampleId, String fileName, String editEnergy, double err, String libraryName, String nuclideName, HttpServletRequest request) {
Result result = new Result();
@ -1794,6 +1856,73 @@ public class GammaServiceImpl implements IGammaService {
}
}
@Override
public void exportARR(Integer sampleId, HttpServletResponse response) {
if(Objects.isNull(sampleId)) {
String waring = "The file isn't existed.";
}
//获取自动处理生成的报告地址
String reportPath = spectrumAnalysisMapper.viewARR(sampleId);
if(StringUtils.isBlank(reportPath.trim())) {
String waring = "The file isn't existed.";
}
String pathName = reportPath.substring(0, reportPath.lastIndexOf(StringPool.SLASH));
String fileName = reportPath.substring(reportPath.lastIndexOf(StringPool.SLASH)+1)+".txt";
//连接ftp
FTPClient ftpClient = ftpUtil.LoginFTP();
if (Objects.isNull(ftpClient)){
throw new RuntimeException("ftp连接失败");
}
InputStream inputStream = null;
ServletOutputStream outputStream = null;
try {
//切换被动模式
ftpClient.enterLocalPassiveMode();
ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
// 设置编码当文件中存在中文且上传后文件乱码时可使用此配置项
ftpClient.setControlEncoding("UTF-8");
ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
pathName=StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + pathName;
ftpClient.changeWorkingDirectory(pathName);
List<FTPFile> 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<String, PHDFile> 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<Map<String, Object>> radionuclideActivity(Integer sampleId, String fileName) {
Result<Map<String, Object>> result = new Result();

View File

@ -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<String, Object> map = new HashMap<>();
String userName = JwtUtil.getUserNameByToken(request);
Cache<String, Map<String, Object>> cache = betaCache.getBetaCache();
Map<String, Object> 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<String, Object> map = new HashMap<>();
String userName = JwtUtil.getUserNameByToken(request);
Cache<String, Map<String, Object>> cache = betaCache.getBetaCache();
Map<String, Object> 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<SeriseData> tempPoints, Integer count) {
public Result fitting(Double paramA, Double paramB, Double paramC, List<SeriseData> tempPoints, Integer count, String qcFileName, String tabName, HttpServletRequest request) {
Result result = new Result();
String userName = JwtUtil.getUserNameByToken(request);
Cache<String, Map<String, Object>> cache = betaCache.getBetaCache();
Map<String, Object> cacheMap = new HashMap<>();
Map<String, Object> 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<Double> fittingPara = new LinkedList<>();
fittingPara.add(paramA);
fittingPara.add(paramB);
fittingPara.add(paramC);
List<String> fittingParaStr = new LinkedList<>();
fittingParaStr.add(String.valueOf(paramA));
fittingParaStr.add(String.valueOf(paramB));
fittingParaStr.add(String.valueOf(paramC));
List<Double> xs = new LinkedList<>();
for (int i=0; i<tempPoints.size(); i++){
xs.add(tempPoints.get(i).getX());
@ -2272,6 +2293,11 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
fittingParaToUiStr.add(String.valueOf(para));
}
map.put("EToC", fittingParaToUiStr);
cacheMap.put("Series", seriseDataList);
cacheMap.put("fittingPara", fittingParaStr);
cache.put(qcFileName+"-"+userName+"-"+tabName, cacheMap);
betaCache.setBetaCache(cache);
}
result.setSuccess(true);
result.setResult(map);
@ -2650,19 +2676,40 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
@Transactional
public Result saveToDB(BgDataAnlyseResultIn anlyseResultIn, HttpServletRequest request) {
Result result = new Result();
//根据请求体获取用户名
String userName = JwtUtil.getUserNameByToken(request);
//用户名赋值到 分析员
anlyseResultIn.setUserName(userName);
//从本地缓存获取beta gamma的数组
Cache<String, Map<String, Object>> cache = betaCache.getBetaCache();
//根据qc文件名称-用户名-beta的方式获取beta的内容
Map<String, Object> betaMap = cache.getIfPresent(anlyseResultIn.getQcFileName() + "-" + userName + "-beta");
List<SeriseData> betaList = new LinkedList<>();
List<String> betaFittingPara = new LinkedList<>();
if (CollectionUtils.isNotEmpty(betaMap)) {
betaList = (List<SeriseData>)betaMap.get("Series");
betaFittingPara = (List<String>) betaMap.get("fittingPara");
}
//根据qc文件名称-用户名-gamma的方式获取gamma的内容
Map<String, Object> gammaMap = cache.getIfPresent(anlyseResultIn.getQcFileName() + "-" + userName + "-gamma");
List<SeriseData> gammaList = new LinkedList<>();
List<String> gammaFittingPara = new LinkedList<>();
if (CollectionUtils.isNotEmpty(gammaMap)) {
gammaList = (List<SeriseData>)gammaMap.get("Series");
gammaFittingPara = (List<String>) 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<String, Object> 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<GardsRoiChannels> 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<GardsRoiResults> roiResultsSpectrumList = getROIResult(anlyseResultIn.getRoiResultsSpectrumList(), sampleId, idAnalysis, isExist);
List<GardsRoiResults> 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<SeriseData> betaList, List<SeriseData> 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<Double> channels = gammaList.stream().map(SeriseData::getX).collect(Collectors.toList());
anlyseResultIn.setG_channel_sample(channels);
List<Double> 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<Double> channels = betaList.stream().map(SeriseData::getX).collect(Collectors.toList());
anlyseResultIn.setB_channel_sample(channels);
List<Double> 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<Double> channels = gammaList.stream().map(SeriseData::getX).collect(Collectors.toList());
anlyseResultIn.setG_channel_gas(channels);
List<Double> 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<Double> channels = betaList.stream().map(SeriseData::getX).collect(Collectors.toList());
anlyseResultIn.setB_channel_gas(channels);
List<Double> 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<Double> channels = gammaList.stream().map(SeriseData::getX).collect(Collectors.toList());
anlyseResultIn.setG_channel_det(channels);
List<Double> 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<Double> channels = betaList.stream().map(SeriseData::getX).collect(Collectors.toList());
anlyseResultIn.setB_channel_det(channels);
List<Double> 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<String> betaFittingPara, List<String> gammaFittingPara, Map<String, Object> 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<GardsXeResults> 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<GardsCalibrationSpectrum> 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<GardsCalibrationSpectrum> 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<GardsROIChannelsSpectrum> roiChannelsSpectrumList = new LinkedList<>();
for (int i=0; i<bgAnalyseResult.S_ROI_B_Boundary_start.size(); i++) {
GardsROIChannelsSpectrum roiChannels = new GardsROIChannelsSpectrum();
roiChannels.setDataType(DataTypeAbbr.SAMPLEPHD.getType());
roiChannels.setRoi(i+1);
roiChannels.setBChanStart(bgAnalyseResult.S_ROI_B_Boundary_start.get(i));
roiChannels.setBChanStop(bgAnalyseResult.S_ROI_B_Boundary_stop.get(i));
roiChannels.setGChanStart(bgAnalyseResult.S_ROI_G_Boundary_start.get(i));
roiChannels.setGChanStop(bgAnalyseResult.S_ROI_G_Boundary_stop.get(i));
roiChannelsSpectrumList.add(roiChannels);
}
for (int i=0; i<bgAnalyseResult.G_ROI_B_Boundary_start.size(); i++) {
GardsROIChannelsSpectrum roiChannels = new GardsROIChannelsSpectrum();
roiChannels.setDataType(DataTypeAbbr.GASBKPHD.getType());
roiChannels.setRoi(i+1);
roiChannels.setBChanStart(bgAnalyseResult.G_ROI_B_Boundary_start.get(i));
roiChannels.setBChanStop(bgAnalyseResult.G_ROI_B_Boundary_stop.get(i));
roiChannels.setGChanStart(bgAnalyseResult.G_ROI_G_Boundary_start.get(i));
roiChannels.setGChanStop(bgAnalyseResult.G_ROI_G_Boundary_stop.get(i));
roiChannelsSpectrumList.add(roiChannels);
}
for (int i=0; i<bgAnalyseResult.D_ROI_B_Boundary_start.size(); i++) {
GardsROIChannelsSpectrum roiChannels = new GardsROIChannelsSpectrum();
roiChannels.setDataType(DataTypeAbbr.DETBKPHD.getType());
roiChannels.setRoi(i+1);
roiChannels.setBChanStart(bgAnalyseResult.D_ROI_B_Boundary_start.get(i));
roiChannels.setBChanStop(bgAnalyseResult.D_ROI_B_Boundary_stop.get(i));
roiChannels.setGChanStart(bgAnalyseResult.D_ROI_G_Boundary_start.get(i));
roiChannels.setGChanStop(bgAnalyseResult.D_ROI_G_Boundary_stop.get(i));
roiChannelsSpectrumList.add(roiChannels);
}
anlyseResultIn.setRoiChannelsSpectrumList(roiChannelsSpectrumList);
bgAnalyseResult.LC.add(0, 0.0);
bgAnalyseResult.MDC.add(0, 0.0);
List<GardsROIResultsSpectrum> roiResultsSpectrumList = new LinkedList<>();
for (int i=0; i<bgAnalyseResult.s_roi_cts.size(); i++) {
GardsROIResultsSpectrum roiResults = new GardsROIResultsSpectrum();
roiResults.setRoi(i+1);
roiResults.setLc(bgAnalyseResult.LC.get(i));
roiResults.setSGross(bgAnalyseResult.s_roi_cts.get(i));
roiResults.setGGross(bgAnalyseResult.g_roi_cts.get(i));
roiResults.setBGross(bgAnalyseResult.d_roi_cts.get(i));
roiResults.setSNet(bgAnalyseResult.s_deduct_d_cts.get((i+1)*3));
roiResults.setGNet(bgAnalyseResult.g_deduct_d_cts.get((i+1)*3));
roiResults.setNet(bgAnalyseResult.ROI_net_coutns.get(i));
roiResults.setNetErr(bgAnalyseResult.ROI_net_coutns_err.get(i));
roiResults.setConc(bgAnalyseResult.ROI_con_uncer.get(i));
roiResults.setConcErr(bgAnalyseResult.ROI_con_uncer_err.get(i));
roiResults.setMdc(bgAnalyseResult.MDC.get(i));
if(bgAnalyseResult.ROI_con_uncer.get(i)>bgAnalyseResult.MDC.get(i)) {
roiResults.setNidFlag(1);
} else {
roiResults.setNidFlag(0);
}
roiResultsSpectrumList.add(roiResults);
}
anlyseResultIn.setRoiResultsSpectrumList(roiResultsSpectrumList);
}
public List<GardsCalibrationPairs> getCalibrationPairs(BgDataAnlyseResultIn anlyseResultIn, Integer sampleId, Integer gasId, Integer detId, Integer idAnalysis) {
List<GardsCalibrationPairs> 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<GardsCalibrationSpectrum> 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<GardsCalibrationSpectrum> 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<GardsCalibrationSpectrum> 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<GardsCalibrationSpectrum> 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<GardsCalibrationSpectrum> 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<GardsCalibrationSpectrum> 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<GardsROIChannelsSpectrum> roiChannelsSpectrumList, List<GardsRoiChannels> roiChannelsList) {
public void getROIChannel(Integer sampleId, Integer idAnalysis, List<GardsROIChannelsSpectrum> roiChannelsSpectrumList, List<GardsRoiChannels> roiChannelsList, String dataType) {
roiChannelsSpectrumList = roiChannelsSpectrumList.stream().filter(item-> item.getDataType().equals(dataType)).collect(Collectors.toList());
for (int i=0; i<roiChannelsSpectrumList.size(); i++){
GardsRoiChannels roiChannels = new GardsRoiChannels();
roiChannels.setSampleId(sampleId);
@ -3295,51 +3589,11 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
}
public List<GardsXeResults> getXeResults(BgDataAnlyseResultIn anlyseResultIn, Integer sampleId, Integer idAnalysis) {
List<GardsXeResults> 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<GardsXeResults> 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<GardsRoiResults> getROIResult(List<GardsROIResultsSpectrum> roiResultsSpectrumList, Integer sampleId, Integer idAnalysis, Integer isExist) {
public List<GardsRoiResults> getROIResult(List<GardsROIResultsSpectrum> roiResultsSpectrumList, Integer sampleId, Integer idAnalysis) {
List<GardsRoiResults> roiResultsList = new LinkedList<>();
for (int i=0; i<roiResultsSpectrumList.size(); i++) {
GardsRoiResults roiResults = new GardsRoiResults();

View File

@ -4,6 +4,8 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.AutoProcessManager;
import org.jeecg.modules.FileSourceHandleManager;
import org.jeecg.modules.UndealHandleManager;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@ -27,6 +29,8 @@ import java.net.UnknownHostException;
public class JeecgAutoProcessApplication extends SpringBootServletInitializer implements CommandLineRunner {
private final AutoProcessManager autoProcessManager;
private final UndealHandleManager undealHandleManager;
private final FileSourceHandleManager fileSourceHandleManager;
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
@ -49,6 +53,10 @@ public class JeecgAutoProcessApplication extends SpringBootServletInitializer im
@Override
public void run(String... args) throws Exception {
//调用dll
System.loadLibrary("ReadPHDFile");
autoProcessManager.start();
undealHandleManager.start();
fileSourceHandleManager.start();
}
}