fix:1.完成重新执行undeal文件夹里PHD文件功能2.完成重新执行filesource文件夹PHD文件功能
This commit is contained in:
parent
79e05be0e0
commit
cf39240cf0
|
@ -46,6 +46,11 @@ public class SpectrumPathProperties implements Serializable {
|
|||
*/
|
||||
private String failPath;
|
||||
|
||||
/**
|
||||
* 手动放置能谱文件获取路径
|
||||
*/
|
||||
private String filesourcePath;
|
||||
|
||||
/**
|
||||
* 能谱文件存储路径以能谱系统类型/能谱类型为key,以存储路径为value
|
||||
*/
|
||||
|
|
|
@ -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;
|
||||
|
||||
/**
|
||||
* 邮件附件临时存储路径
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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("/");
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 +
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<>();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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)){
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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()) ||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -145,7 +145,7 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
*/
|
||||
public void start() throws BAnalyseException {
|
||||
try{
|
||||
//修改状态为解析中
|
||||
//修改状态为分析中
|
||||
this.updateStatus(SampleStatus.IN_PROCESS.getValue());
|
||||
//查询det、gas数据(sampleId,inputFileName),sample数据在构造函数已经传过来
|
||||
this.queryPHDFile();
|
||||
|
@ -160,9 +160,11 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
//生成报告
|
||||
Sample_B_Analysis.B_AnalysisReport report = new Sample_B_Analysis.B_AnalysisReport();
|
||||
report.start();
|
||||
//修改状态为解析成功
|
||||
//修改状态为分析成功
|
||||
this.updateStatus(SampleStatus.COMPLETE.getValue());
|
||||
}catch (Exception e){
|
||||
//修改状态为分析失败
|
||||
this.spectrumServiceQuotes.getSampleDataService().updateStatus(SampleStatus.FAIL.getValue(),this.sampleData.getInputFileName());
|
||||
e.printStackTrace();
|
||||
throw new BAnalyseException("Sample Analyse Error at "+DateUtils.formatDate(new Date(),"yyyy-MM-dd HH:mm:ss"));
|
||||
}finally {
|
||||
|
@ -191,8 +193,7 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
|
||||
//如果找不到sample、det、gas谱文件数据则解析失败修改记录状态
|
||||
if(StringUtils.isEmpty(this.sampleData.getInputFileName()) || Objects.isNull(this.detSampleData) || StringUtils.isEmpty(this.detSampleData.getInputFileName()) || Objects.isNull(this.gasSampleData) || StringUtils.isEmpty(this.gasSampleData.getInputFileName())){
|
||||
this.currAnalysesStatus = SampleStatus.FAIL.getValue();
|
||||
this.spectrumServiceQuotes.getSampleDataService().updateStatus(this.currAnalysesStatus,this.sampleData.getInputFileName());
|
||||
this.spectrumServiceQuotes.getSampleDataService().updateStatus(SampleStatus.FAIL.getValue(),this.sampleData.getInputFileName());
|
||||
|
||||
throw new FileNotExistException("gas or det file is no exist or is error..");
|
||||
}
|
||||
|
@ -203,21 +204,21 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
*/
|
||||
private void structureArrFilePath(){
|
||||
//处理此文件需要保存到ftp服务的路径
|
||||
final int year = LocalDate.now().getYear();
|
||||
final int month = LocalDate.now().getMonth().getValue();
|
||||
//measurement_id切割后的字符数组
|
||||
String[] arr = this.sampleStruct.measurement_id.split(StringConstant.DASH);
|
||||
//切割后第一个,元素是年,第二个是月
|
||||
final String[] yearMonth = arr[1].split(StringConstant.SLASH);
|
||||
final SpectrumPathProperties properties = this.spectrumServiceQuotes.getSpectrumPathProperties();
|
||||
StringBuilder ftpPath = new StringBuilder();
|
||||
ftpPath.append(properties.getRootPath());
|
||||
ftpPath.append(StringConstant.SLASH);
|
||||
ftpPath.append(properties.getArrPath());
|
||||
ftpPath.append(StringConstant.SLASH);
|
||||
ftpPath.append(properties.getFilePathMap().get(this.sampleStruct.system_type));
|
||||
ftpPath.append(StringConstant.SLASH);
|
||||
ftpPath.append(properties.getFilePathMap().get(this.sampleStruct.data_type));
|
||||
ftpPath.append(StringConstant.SLASH);
|
||||
ftpPath.append(year);
|
||||
ftpPath.append(yearMonth[0]);
|
||||
ftpPath.append(StringConstant.SLASH);
|
||||
ftpPath.append(month>=10?month:"0"+month);
|
||||
ftpPath.append(yearMonth[1]);
|
||||
this.arrFilePath = ftpPath.toString();
|
||||
String arrFileTail = ARR_FILE_NAME_TAIL+ARR_FILE_SUFFIX;
|
||||
String sourceFileName = this.sampleData.getInputFileName().substring(this.sampleData.getInputFileName().lastIndexOf(StringConstant.SLASH)+1);
|
||||
|
@ -234,6 +235,7 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
System.out.println("det:"+this.detTempFilePath);
|
||||
|
||||
BgAnalyseResult analyseResult = EnergySpectrumHandler.bgAnalyse(this.sampleTempFilePath,this.gasTempFilePath,this.detTempFilePath);
|
||||
System.out.println(analyseResult);
|
||||
this.endAnalysisTime = new Date();
|
||||
if(Objects.isNull(analyseResult) || !analyseResult.analyse_flag){
|
||||
throw new BAnalyseException("THE PHD file cannot be parsed:"+this.sampleTempFilePath+","+this.gasTempFilePath+","+this.detTempFilePath);
|
||||
|
@ -249,7 +251,7 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
boolean flag = false;
|
||||
//下载gas谱PHD文件到本地临时路径
|
||||
String gasFileName = gasSampleData.getInputFileName().substring(gasSampleData.getInputFileName().lastIndexOf(StringConstant.SLASH) + 1);
|
||||
String gasFileFTPPath = gasSampleData.getInputFileName().substring(0, gasSampleData.getInputFileName().lastIndexOf(StringConstant.SLASH));
|
||||
String gasFileFTPPath = this.spectrumServiceQuotes.getSpectrumPathProperties().getRootPath()+StringConstant.SLASH+gasSampleData.getInputFileName().substring(0, gasSampleData.getInputFileName().lastIndexOf(StringConstant.SLASH));
|
||||
boolean gasFlag = ftpUtil.downloadFTPFile(gasFileFTPPath,gasFileName,this.spectrumServiceQuotes.getTaskProperties().getTemporaryStoragePath());
|
||||
if(!gasFlag){
|
||||
flag = true;
|
||||
|
@ -258,7 +260,7 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
|
||||
//下载det谱PHD文件到本地临时路径
|
||||
final String detFileName = detSampleData.getInputFileName().substring(detSampleData.getInputFileName().lastIndexOf(StringConstant.SLASH) + 1);
|
||||
String detFileFTPPath = detSampleData.getInputFileName().substring(0, detSampleData.getInputFileName().lastIndexOf(StringConstant.SLASH));
|
||||
String detFileFTPPath = this.spectrumServiceQuotes.getSpectrumPathProperties().getRootPath()+StringConstant.SLASH+detSampleData.getInputFileName().substring(0, detSampleData.getInputFileName().lastIndexOf(StringConstant.SLASH));
|
||||
boolean detFlag = ftpUtil.downloadFTPFile(detFileFTPPath,detFileName,this.spectrumServiceQuotes.getTaskProperties().getTemporaryStoragePath());
|
||||
if(!detFlag){
|
||||
flag = true;
|
||||
|
@ -302,9 +304,9 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
spectrumServiceQuotes.getGardsCalibrationPairsService().createG_EnergyRecord(gasSampleData.getSampleId(),analyses.getIdAnalysis(),this.gasStruct);
|
||||
|
||||
//存储gards_calibration表数据sample、det、gas谱B_Energy和G_Energy块数据
|
||||
spectrumServiceQuotes.getGardsCalibrationService().create(this.analyseResult,gasSampleData.getSampleId(),analyses.getIdAnalysis());
|
||||
spectrumServiceQuotes.getGardsCalibrationService().create(this.analyseResult,sampleData.getSampleId(),gasSampleData.getSampleId(),detSampleData.getSampleId(),analyses.getIdAnalysis());
|
||||
//gards_roi_channels数据表,存储sample、det、gas谱数据
|
||||
spectrumServiceQuotes.getRoiChannelsService().create(this.analyseResult,sampleData.getSampleId(),analyses.getIdAnalysis());
|
||||
spectrumServiceQuotes.getRoiChannelsService().create(this.analyseResult,sampleData.getSampleId(),gasSampleData.getSampleId(),detSampleData.getSampleId(),analyses.getIdAnalysis());
|
||||
//gards_Xe_results数据表XE_131m、XE_133、XE_133m、XE_135数据
|
||||
spectrumServiceQuotes.getXeResultsService().create(this.analyseResult,sampleData.getSampleId(),analyses.getIdAnalysis());
|
||||
//gards_ roi_results数据表
|
||||
|
@ -362,6 +364,7 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
public void start() throws IOException {
|
||||
//获取报告内容
|
||||
this.getTemplateContent();
|
||||
|
||||
//创建报告临时文件
|
||||
this.createTmpReportFile();
|
||||
//处理报告时间
|
||||
|
@ -479,17 +482,16 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
this.templateContent = this.templateContent.replace("${DET_SampleID}",detSampleData.getSampleId().toString());
|
||||
this.templateContent = this.templateContent.replace("${GAS_SampleID}",gasSampleData.getSampleId().toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理#SAMPLE CALIBRATION 模块
|
||||
* 还需和周雨涵确认s_b_fitting_c_e、s_g_fitting_c_e
|
||||
*/
|
||||
private void handleSampleCalibration() throws IOException {
|
||||
String[] betaArr = {CH_Contant+this.calibration(analyseResult.s_b_fitting_type,analyseResult.s_b_fitting_e_c),
|
||||
E_Contant+this.calibration(analyseResult.s_b_fitting_type,analyseResult.s_b_fitting_e_c)};
|
||||
E_Contant+this.calibration(analyseResult.s_b_fitting_type,analyseResult.s_b_fitting_c_e)};
|
||||
|
||||
String[] gammaArr = {CH_Contant+this.calibration(analyseResult.s_g_fitting_type,analyseResult.s_g_fitting_e_c),
|
||||
E_Contant+this.calibration(analyseResult.s_g_fitting_type,analyseResult.s_g_fitting_e_c)};
|
||||
E_Contant+this.calibration(analyseResult.s_g_fitting_type,analyseResult.s_g_fitting_c_e)};
|
||||
|
||||
this.handleTwoParamFormat("#SAMPLE CALIBRATION",betaArr,gammaArr);
|
||||
}
|
||||
|
@ -519,10 +521,10 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
*/
|
||||
private void handleDetCalibration() throws IOException {
|
||||
String[] betaArr = {CH_Contant+this.calibration(analyseResult.d_b_fitting_type,analyseResult.d_b_fitting_e_c),
|
||||
E_Contant+this.calibration(analyseResult.d_b_fitting_type,analyseResult.d_b_fitting_e_c)};
|
||||
E_Contant+this.calibration(analyseResult.d_b_fitting_type,analyseResult.d_b_fitting_c_e)};
|
||||
|
||||
String[] gammaArr = {CH_Contant+this.calibration(analyseResult.d_g_fitting_type,analyseResult.d_g_fitting_e_c),
|
||||
E_Contant+this.calibration(analyseResult.d_g_fitting_type,analyseResult.d_g_fitting_e_c)};
|
||||
E_Contant+this.calibration(analyseResult.d_g_fitting_type,analyseResult.d_g_fitting_c_e)};
|
||||
|
||||
this.handleTwoParamFormat("#DET CALIBRATION",betaArr,gammaArr);
|
||||
}
|
||||
|
@ -552,10 +554,10 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
*/
|
||||
private void handleGasCalibration() throws IOException {
|
||||
String[] betaArr = {CH_Contant+this.calibration(analyseResult.g_b_fitting_type,analyseResult.g_b_fitting_e_c),
|
||||
E_Contant+this.calibration(analyseResult.g_b_fitting_type,analyseResult.g_b_fitting_e_c)};
|
||||
E_Contant+this.calibration(analyseResult.g_b_fitting_type,analyseResult.g_b_fitting_c_e)};
|
||||
|
||||
String[] gammaArr = {CH_Contant+this.calibration(analyseResult.g_g_fitting_type,analyseResult.g_g_fitting_e_c),
|
||||
E_Contant+this.calibration(analyseResult.g_g_fitting_type,analyseResult.g_g_fitting_e_c)};
|
||||
E_Contant+this.calibration(analyseResult.g_g_fitting_type,analyseResult.g_g_fitting_c_e)};
|
||||
|
||||
this.handleTwoParamFormat("#GAS CALIBRATION",betaArr,gammaArr);
|
||||
}
|
||||
|
@ -600,7 +602,7 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
List<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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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{
|
|||
//进行B、G(P)谱分析
|
||||
this.autoAnalysis();
|
||||
}catch (Exception e){
|
||||
//修改状态为解析失败
|
||||
this.spectrumServiceQuotes.getSampleDataService().updateStatus(SampleStatus.FAIL.getValue(),super.sampleData.getInputFileName());
|
||||
//处理解析失败的文件,上传到ftp->undeal目录
|
||||
super.handleParseingFailFile();
|
||||
throw e;
|
||||
|
|
|
@ -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){
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user