diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/SpectrumPathProperties.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/SpectrumPathProperties.java index 1f2a8055..9c7155ff 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/SpectrumPathProperties.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/SpectrumPathProperties.java @@ -46,6 +46,11 @@ public class SpectrumPathProperties implements Serializable { */ private String failPath; + /** + * 手动放置能谱文件获取路径 + */ + private String filesourcePath; + /** * 能谱文件存储路径以能谱系统类型/能谱类型为key,以存储路径为value */ diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/TaskProperties.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/TaskProperties.java index f8789796..8882bbca 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/TaskProperties.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/TaskProperties.java @@ -23,17 +23,37 @@ public class TaskProperties implements Serializable { /** * 监测数据库邮箱数据变化周期 */ - private Long monitoringMailDataCycle; + private Integer monitoringMailDataCycle; /** * 监测邮箱通信状态周期 */ - private Long monitoringMailCommStatusCycle; + private Integer monitoringMailCommStatusCycle; /** * 获取邮箱邮件线程执行周期 */ - private Long mailThreadExecCycle; + private Integer mailThreadExecCycle; + + /** + * undeal目录文件获取周期 + */ + private Integer undealDirExecCycle; + + /** + * undeal目录单次获取文件数量 + */ + private Integer undealDirReceiveNum; + + /** + * filesource目录文件获取周期 + */ + private Integer filesourceDirExecCycle; + + /** + * filesource目录单次获取文件数量 + */ + private Integer filesourceDirReceiveNum; /** * 邮件附件临时存储路径 diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/AutoProcessManager.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/AutoProcessManager.java index f0185d53..2b4c87fa 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/AutoProcessManager.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/AutoProcessManager.java @@ -61,9 +61,6 @@ public class AutoProcessManager{ monitorThread.setName("mail-server-monitor"); monitorThread.start(); - //调用dll - System.loadLibrary("ReadPHDFile"); - //邮件执行线程管理 final MailExecManager autoProcessThread = new MailExecManager(); autoProcessThread.setName("mail-exec-thread-manage"); diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/FileSourceHandleManager.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/FileSourceHandleManager.java new file mode 100644 index 00000000..158662b3 --- /dev/null +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/FileSourceHandleManager.java @@ -0,0 +1,174 @@ +package org.jeecg.modules; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.jeecg.common.properties.TaskProperties; +import org.jeecg.modules.ftp.FTPProperties; +import org.jeecg.modules.ftp.FTPUtils; +import org.jeecg.modules.spectrum.SamplephdSpectrum; +import org.jeecg.modules.spectrum.SpectrumHandler; +import org.jeecg.modules.spectrum.SpectrumServiceQuotes; +import org.springframework.scheduling.concurrent.CustomizableThreadFactory; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.io.ByteArrayInputStream; +import java.io.FileInputStream; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; +import java.util.concurrent.*; +import java.util.stream.Collectors; + +/** + * 解析手动放置PHD文件程序管理器 + */ +@Slf4j +@Component +@RequiredArgsConstructor +public class FileSourceHandleManager { + + /** + * 任务属性 + */ + private final TaskProperties taskProperties; + /** + * 相关Spring组件引用 + */ + private final SpectrumServiceQuotes spectrumServiceQuotes; + + /** + * 开始 + */ + public void start(){ + ParseingFileSourceThreadManager fileSourceThreadManager = new ParseingFileSourceThreadManager(); + fileSourceThreadManager.init(); + fileSourceThreadManager.start(); + } + + /** + * 手动放置PHD文件处理线程管理器 + */ + private class ParseingFileSourceThreadManager extends Thread{ + + private ThreadPoolExecutor poolExecutor; + + public void init(){ + //获取机器可用核心数 + int systemCores = Runtime.getRuntime().availableProcessors(); + int maximumPoolSize = taskProperties.getFilesourceDirReceiveNum() > systemCores?taskProperties.getFilesourceDirReceiveNum():systemCores; + + //初始化线程池 + ThreadFactory threadFactory = new CustomizableThreadFactory("filesource-file-parsing-"); + poolExecutor = new ThreadPoolExecutor(taskProperties.getReceiveNum(),maximumPoolSize,5, TimeUnit.SECONDS, new LinkedBlockingQueue<>(),threadFactory); + } + + @Override + public void run() { + for(;;){ + System.out.println("222222222222222222222222222222222222222222222222222222222222222222222222222222222"); + long start = System.currentTimeMillis(); + FTPUtils ftpUtil = null; + try { + //初始化FTP客户端对象 + final FTPProperties ftpProperties = spectrumServiceQuotes.getFtpProperties(); + ftpUtil = new FTPUtils(ftpProperties.getHost(),ftpProperties.getPort(),ftpProperties.getUserName(), + ftpProperties.getPassword(),ftpProperties.getEncoding(),ftpProperties.getFtpRootPath()); + //手动放置能谱文件获取路径 + String filePath = spectrumServiceQuotes.getSpectrumPathProperties().getFilesourcePath(); + List fileNames = ftpUtil.getFiles(filePath, taskProperties.getFilesourceDirReceiveNum().intValue()); + ftpUtil.close(); + //如果获取到的文件数量大于1,则进行排序保障Sample谱最后执行 + if(fileNames.size() > 1){ + fileNames = fileNames.stream().sorted(Comparator.comparing(String::toString)).collect(Collectors.toList()); + } + if(!CollectionUtils.isEmpty(fileNames)){ + CountDownLatch taskLatch = new CountDownLatch(fileNames.size()); + for(String fileName : fileNames){ + ParseingFileSourceThread parseingFileSourceThread = new ParseingFileSourceThread(); + parseingFileSourceThread.init(fileName,filePath,taskLatch); + poolExecutor.execute(parseingFileSourceThread); + } + taskLatch.await(); + } + }catch (Exception e){ + ftpUtil.close(); + e.printStackTrace(); + } + long end = System.currentTimeMillis(); + long sleepTime = taskProperties.getFilesourceDirExecCycle() - (end-start); + //如果sleepTime > 0 需要睡眠到指定时间,否则继续下次获取邮件 + if(sleepTime > 0){ + try { + //如果本次 + TimeUnit.MILLISECONDS.sleep(sleepTime); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + } + } + /** + * 解析手动放置的能谱文件线程 + */ + private class ParseingFileSourceThread implements Runnable{ + /** + * 能谱文件名称 + */ + private String fileName; + /** + * ftp工具 + */ + private FTPUtils ftpUtil; + /** + * 手动放置能谱文件获取路径 + */ + private String filePath; + /** + * 获取文件内容 + */ + private String fileContent; + + private CountDownLatch taskLatch; + + public void init(String fileName,String filePath,CountDownLatch taskLatch){ + this.fileName = fileName; + this.filePath = filePath; + this.taskLatch = taskLatch; + } + + @Override + public void run() { + try { + System.out.println("4444444444444444444444444444444444444444444444444444444444444444444444444444444444"); + //初始化FTP客户端对象 + final FTPProperties ftpProperties = spectrumServiceQuotes.getFtpProperties(); + this.ftpUtil = new FTPUtils(ftpProperties.getHost(),ftpProperties.getPort(),ftpProperties.getUserName(), + ftpProperties.getPassword(),ftpProperties.getEncoding(),ftpProperties.getFtpRootPath()); + //获取文件内容 + fileContent = this.ftpUtil.getFileContent(filePath, fileName); + //解析文件 + SpectrumHandler spectrumHandler = new SamplephdSpectrum(); + spectrumHandler.init(fileContent,spectrumServiceQuotes,this.ftpUtil); + final boolean matchResult = spectrumHandler.saveEmailToLocal(); + if(matchResult){ + //开始解析 + spectrumHandler.handler(); + } + }catch (Exception e){ + //解析失败会把文件上传到undeal目录 + this.ftpUtil.saveFile(spectrumServiceQuotes.getSpectrumPathProperties().getFailPath(),this.fileName,new ByteArrayInputStream(fileContent.getBytes(StandardCharsets.UTF_8))); + log.error("Parsing the {} file of the undeal directory failed",fileName); + e.printStackTrace(); + }finally { + //解析成功或者失败都会删除源文件 + this.ftpUtil.removeFile(this.filePath,this.fileName); + this.ftpUtil.close(); + taskLatch.countDown(); + } + } + } +} diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/UndealHandleManager.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/UndealHandleManager.java new file mode 100644 index 00000000..d7569021 --- /dev/null +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/UndealHandleManager.java @@ -0,0 +1,164 @@ +package org.jeecg.modules; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.jeecg.common.properties.TaskProperties; +import org.jeecg.modules.ftp.FTPProperties; +import org.jeecg.modules.ftp.FTPUtils; +import org.jeecg.modules.spectrum.SamplephdSpectrum; +import org.jeecg.modules.spectrum.SpectrumHandler; +import org.jeecg.modules.spectrum.SpectrumServiceQuotes; +import org.springframework.scheduling.concurrent.CustomizableThreadFactory; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.util.Comparator; +import java.util.List; +import java.util.concurrent.*; +import java.util.stream.Collectors; + +/** + * 解析失败邮件处理程序管理器 + */ +@Slf4j +@Component +@RequiredArgsConstructor +public class UndealHandleManager { + + /** + * 任务属性 + */ + private final TaskProperties taskProperties; + /** + * 相关Spring组件引用 + */ + private final SpectrumServiceQuotes spectrumServiceQuotes; + + /** + * 开始 + */ + public void start(){ + ParseingFaliFileThreadManager faliFileThreadManager = new ParseingFaliFileThreadManager(); + faliFileThreadManager.init(); + faliFileThreadManager.start(); + } + + /** + * 失败邮件处理线程管理器 + */ + private class ParseingFaliFileThreadManager extends Thread{ + + private ThreadPoolExecutor poolExecutor; + + public void init(){ + //获取机器可用核心数 + int systemCores = Runtime.getRuntime().availableProcessors(); + int maximumPoolSize = taskProperties.getUndealDirReceiveNum() > systemCores?taskProperties.getUndealDirReceiveNum():systemCores; + + //初始化线程池 + ThreadFactory threadFactory = new CustomizableThreadFactory("undeal-file-parsing-"); + poolExecutor = new ThreadPoolExecutor(taskProperties.getUndealDirReceiveNum(),maximumPoolSize,5, TimeUnit.SECONDS, new LinkedBlockingQueue<>(),threadFactory); + } + + @Override + public void run() { + for(;;){ + System.out.println("1111111111111111111111111111111111111111111111111111111111111111111111111111111111"); + long start = System.currentTimeMillis(); + FTPUtils ftpUtil = null; + try { + //初始化FTP客户端对象 + final FTPProperties ftpProperties = spectrumServiceQuotes.getFtpProperties(); + ftpUtil = new FTPUtils(ftpProperties.getHost(),ftpProperties.getPort(),ftpProperties.getUserName(), + ftpProperties.getPassword(),ftpProperties.getEncoding(),ftpProperties.getFtpRootPath()); + //ftp解析失败文件存储路径 + String filePath = spectrumServiceQuotes.getSpectrumPathProperties().getFailPath(); + List fileNames = ftpUtil.getFiles(filePath, taskProperties.getUndealDirReceiveNum().intValue()); + ftpUtil.close(); + //如果获取到的文件数量大于1,则进行排序保障Sample谱最后执行 + if(fileNames.size() > 1){ + fileNames = fileNames.stream().sorted(Comparator.comparing(String::toString)).collect(Collectors.toList()); + } + if(!CollectionUtils.isEmpty(fileNames)){ + CountDownLatch taskLatch = new CountDownLatch(fileNames.size()); + for(String fileName : fileNames){ + ParseingFaliFileThread faliFileThread = new ParseingFaliFileThread(); + faliFileThread.init(fileName,filePath,taskLatch); + poolExecutor.execute(faliFileThread); + } + taskLatch.await(); + } + }catch (Exception e){ + ftpUtil.close(); + e.printStackTrace(); + } + long end = System.currentTimeMillis(); + long sleepTime = taskProperties.getUndealDirExecCycle() - (end-start); + //如果sleepTime > 0 需要睡眠到指定时间,否则继续下次获取邮件 + if(sleepTime > 0){ + try { + //如果本次 + TimeUnit.MILLISECONDS.sleep(sleepTime); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + } + } + + /** + * 解析失败能谱文件线程 + */ + private class ParseingFaliFileThread implements Runnable{ + /** + * 能谱文件名称 + */ + private String fileName; + /** + * ftp工具 + */ + private FTPUtils ftpUtil; + /** + * 失败文件存储路径 + */ + private String filePath; + + private CountDownLatch taskLatch; + + public void init(String fileName,String filePath,CountDownLatch taskLatch){ + this.fileName = fileName; + this.filePath = filePath; + this.taskLatch = taskLatch; + } + + @Override + public void run() { + try { + System.out.println("33333333333333333333333333333333333333333333333333333333333333333333333333333333333"); + //初始化FTP客户端对象 + final FTPProperties ftpProperties = spectrumServiceQuotes.getFtpProperties(); + this.ftpUtil = new FTPUtils(ftpProperties.getHost(),ftpProperties.getPort(),ftpProperties.getUserName(), + ftpProperties.getPassword(),ftpProperties.getEncoding(),ftpProperties.getFtpRootPath()); + //获取文件内容 + final String fileContent = this.ftpUtil.getFileContent(filePath, fileName); + //解析文件 + SpectrumHandler spectrumHandler = new SamplephdSpectrum(); + spectrumHandler.init(fileContent,spectrumServiceQuotes,this.ftpUtil); + final boolean matchResult = spectrumHandler.saveEmailToLocal(); + if(matchResult){ + //开始解析 + spectrumHandler.handler(); + } + }catch (Exception e){ + log.error("The {} file of the undeal directory fails to be parsed again",fileName); + e.printStackTrace(); + }finally { + //解析成功或者失败都会删除源文件 + this.ftpUtil.removeFile(this.filePath,this.fileName); + this.ftpUtil.close(); + this.taskLatch.countDown(); + } + } + } +} diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/ftp/FTPUtils.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/ftp/FTPUtils.java index 39e0c641..aa44cb15 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/ftp/FTPUtils.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/ftp/FTPUtils.java @@ -5,11 +5,13 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.net.ftp.*; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; +import org.apache.logging.log4j.util.Strings; + +import java.io.*; import java.nio.charset.StandardCharsets; -import java.util.Objects; +import java.util.*; +import java.util.stream.Collectors; +import java.util.stream.Stream; @Slf4j public class FTPUtils { @@ -59,9 +61,10 @@ public class FTPUtils { this.checkDirectory(ftpFilePath); InputStream inputStream = null; try{ - final FTPFile[] ftpFiles = this.client.listFiles(fileName); + final String formatFileName = new String(fileName.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1); + final FTPFile[] ftpFiles = this.client.listFiles(formatFileName); if(ArrayUtils.isNotEmpty(ftpFiles)){ - inputStream = this.client.retrieveFileStream(fileName); + inputStream = this.client.retrieveFileStream(formatFileName); if(Objects.nonNull(inputStream)){ FileUtil.writeFromStream(inputStream,localPath+File.separator+fileName); return true; @@ -117,14 +120,8 @@ public class FTPUtils { return true; } - public static void main(String[] args) throws IOException { - FTPUtils ftp = new FTPUtils("8.141.87.165",21,"rmsops","cnndc010","utf-8","/"); -// ftp.saveFile("log/Soh/2023/08","GBX68_RMSSOH-20230731_152800.0.log",new ByteArrayInputStream((System.lineSeparator()+"ssssssssssss").getBytes(StandardCharsets.UTF_8))); - ftp.downloadFTPFile("/savefile/Spectrum/Xenon/Sauna/Gasbkphd/2023/09","AUX09_003-20151224_0655_G_FULL_40182.873.PHD","E:\\file"); - } - /** - * 写入文件,若文件或文件目录不存在则自行创建,存在先删除再创建 + * 写入文件,若文件或文件目录不存在则自行创建,存在无操作 * @param filePath 文件路径 * @param fileName 文件名称 * @param inputStream 文件输入流 @@ -135,10 +132,9 @@ public class FTPUtils { final boolean flag = this.checkDirectory(filePath); if(flag){ final FTPFile[] ftpFiles = this.client.listFiles(fileName); - if(ArrayUtils.isNotEmpty(ftpFiles)){ - client.deleteFile(fileName); + if(ArrayUtils.isEmpty(ftpFiles)){ + return client.storeFile(fileName, inputStream); } - return client.storeFile(fileName, inputStream); } }catch (IOException e){ log.error("{}文件创建失败,原因为:{}",filePath+"/"+fileName,e.getMessage()); @@ -190,6 +186,65 @@ public class FTPUtils { return false; } + /** + * 在指定路径下获取指定数量的文件名称列表 + * @param filePath + * @param getNum + * @return + */ + public List getFiles(String filePath,int getNum) throws IOException { + final boolean flag = this.checkDirectory(filePath); + if(flag){ + final FTPFile[] ftpFiles = this.client.listFiles(); + if(ArrayUtils.isNotEmpty(ftpFiles)){ + //最终实际获取数量 + int num = getNum > ftpFiles.length?ftpFiles.length:getNum; + final List fileNames = Arrays.stream(ftpFiles).sorted(Comparator.comparing(FTPFile::getTimestamp)).map(f->f.getName()).limit(num).collect(Collectors.toList()); + return fileNames; + } + } + return Collections.emptyList(); + } + + /** + * 获取文件内容 + * @param filePath 文件路径 + * @param fileName 文件名称 + * @return 返回值,文件内容 + * @throws IOException + */ + public String getFileContent(String filePath,String fileName) throws IOException { + this.checkDirectory(filePath); + final FTPFile[] ftpFiles = this.client.listFiles(fileName); + if(ArrayUtils.isNotEmpty(ftpFiles)){ + InputStream inputStream = this.client.retrieveFileStream(fileName); + if(Objects.nonNull(inputStream)){ + try(BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream,"UTF-8"))){ + StringBuilder fileContent = new StringBuilder(); + String lineContent; + while ((lineContent = reader.readLine()) != null){ + fileContent.append(lineContent); + fileContent.append(System.lineSeparator()); + } + return fileContent.toString(); + }finally { + if(Objects.nonNull(inputStream)){ + inputStream.close(); + // 完成文件传输命令 + this.client.completePendingCommand(); + } + } + } + } + return Strings.EMPTY; + } + +// public static void main(String[] args) throws IOException { +// FTPUtils ftp = new FTPUtils("192.168.17.168",21,"ubuntu","123456","utf-8","/home/ubuntu/ftp"); +// final String fileContent = ftp.getFileContent("/undeal", "CNX22_004-20230731_1436_S_PREL_21593.8.PHD"); +// System.out.println(fileContent); +// } + /** * 删除文件 * @param filePath 文件路径 @@ -198,10 +253,9 @@ public class FTPUtils { */ public boolean removeFile(String filePath,String fileName){ try { - final String rootPath = client.printWorkingDirectory(); - final boolean changeFlag = client.changeWorkingDirectory(rootPath); + final boolean changeFlag = client.changeWorkingDirectory(ftpRootPath); if(!changeFlag){ - log.error("{},根目录切换失败",rootPath); + log.error("{},根目录切换失败",ftpRootPath); return false; } String[] directories = filePath.split("/"); diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/mapper/GardsSampleDataMapper.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/mapper/GardsSampleDataMapper.java index 76c11320..d63a1c0a 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/mapper/GardsSampleDataMapper.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/mapper/GardsSampleDataMapper.java @@ -6,13 +6,15 @@ import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Update; import org.jeecg.modules.base.entity.original.GardsSampleData; +import java.util.List; + public interface GardsSampleDataMapper extends BaseMapper { @Select(value = "select " + "gsd.SAMPLE_ID as sampleId,gsd.input_file_name as inputFileName " + "from ORIGINAL.GARDS_SAMPLE_AUX gsa inner join ORIGINAL.GARDS_SAMPLE_DATA gsd on gsa.sample_id = gsd.sample_id " + "where gsa.measurement_id = #{measurementId} and gsd.data_type=#{dataType}") - public GardsSampleData getSampleIdAndInputFileName(@Param("measurementId") String measurementId,@Param("dataType") String dataType); + public List getSampleIdAndInputFileName(@Param("measurementId") String measurementId, @Param("dataType") String dataType); @Update(value = "UPDATE ORIGINAL.GARDS_SAMPLE_DATA SET STATUS=#{status} WHERE INPUT_FILE_NAME=#{inputFileName}") public int updateStatus(@Param("status") String status,@Param("inputFileName") String inputFileName); diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/native_jni/struct/BgAnalyseResult.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/native_jni/struct/BgAnalyseResult.java index a20be280..8f56f139 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/native_jni/struct/BgAnalyseResult.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/native_jni/struct/BgAnalyseResult.java @@ -46,6 +46,7 @@ public class BgAnalyseResult { public List ROI_con_uncer_err; public List MDC; public List dNidFlag; + public List LC_CTS; /************************** GARDS_ROI_RESULTS end **************************/ @@ -56,6 +57,8 @@ public class BgAnalyseResult { public List s_g_fitting_e_c; public int s_g_fitting_type; public String s_g_fitting_type_def; + public List s_b_fitting_c_e; + public List s_g_fitting_c_e; public List g_b_fitting_e_c; public int g_b_fitting_type; @@ -63,6 +66,8 @@ public class BgAnalyseResult { public List g_g_fitting_e_c; public int g_g_fitting_type; public String g_g_fitting_type_def; + public List g_b_fitting_c_e; + public List g_g_fitting_c_e; public List d_b_fitting_e_c; public int d_b_fitting_type; @@ -70,6 +75,9 @@ public class BgAnalyseResult { public List d_g_fitting_e_c; public int d_g_fitting_type; public String d_g_fitting_type_def; + public List d_b_fitting_c_e; + public List d_g_fitting_c_e; + /************************** GARDS_CALIBRATION end **************************/ /************************** GARDS_ROI_CHANNELS START**************************/ @@ -136,24 +144,31 @@ public class BgAnalyseResult { ", ROI_con_uncer_err=" + ROI_con_uncer_err + ", MDC=" + MDC + ", dNidFlag=" + dNidFlag + + ", LC_CTS=" + LC_CTS + ", s_b_fitting_e_c=" + s_b_fitting_e_c + ", s_b_fitting_type=" + s_b_fitting_type + ", s_b_fitting_type_def='" + s_b_fitting_type_def + '\'' + ", s_g_fitting_e_c=" + s_g_fitting_e_c + ", s_g_fitting_type=" + s_g_fitting_type + ", s_g_fitting_type_def='" + s_g_fitting_type_def + '\'' + + ", s_b_fitting_c_e=" + s_b_fitting_c_e + + ", s_g_fitting_c_e=" + s_g_fitting_c_e + ", g_b_fitting_e_c=" + g_b_fitting_e_c + ", g_b_fitting_type=" + g_b_fitting_type + ", g_b_fitting_type_def='" + g_b_fitting_type_def + '\'' + ", g_g_fitting_e_c=" + g_g_fitting_e_c + ", g_g_fitting_type=" + g_g_fitting_type + ", g_g_fitting_type_def='" + g_g_fitting_type_def + '\'' + + ", g_b_fitting_c_e=" + g_b_fitting_c_e + + ", g_g_fitting_c_e=" + g_g_fitting_c_e + ", d_b_fitting_e_c=" + d_b_fitting_e_c + ", d_b_fitting_type=" + d_b_fitting_type + ", d_b_fitting_type_def='" + d_b_fitting_type_def + '\'' + ", d_g_fitting_e_c=" + d_g_fitting_e_c + ", d_g_fitting_type=" + d_g_fitting_type + ", d_g_fitting_type_def='" + d_g_fitting_type_def + '\'' + + ", d_b_fitting_c_e=" + d_b_fitting_c_e + + ", d_g_fitting_c_e=" + d_g_fitting_c_e + ", S_ROI=" + S_ROI + ", S_ROI_B_Boundary_start=" + S_ROI_B_Boundary_start + ", S_ROI_B_Boundary_stop=" + S_ROI_B_Boundary_stop + diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/GardsCalibrationService.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/GardsCalibrationService.java index 55f51a8b..b3ecfec6 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/GardsCalibrationService.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/GardsCalibrationService.java @@ -15,7 +15,9 @@ public interface GardsCalibrationService extends IService { * 不提交事务,由调用方手动统一提交事务 * @param analyseResult * @param sampleId + * @param gasSampleId + * @param detSampleId * @param anayId */ - public void create(BgAnalyseResult analyseResult, Integer sampleId, Integer anayId); + public void create(BgAnalyseResult analyseResult,Integer sampleId,Integer gasSampleId,Integer detSampleId,Integer anayId); } diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/GardsRoiChannelsService.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/GardsRoiChannelsService.java index 7506daee..4edefd47 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/GardsRoiChannelsService.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/GardsRoiChannelsService.java @@ -14,7 +14,9 @@ public interface GardsRoiChannelsService extends IService { * 不提交事务,由调用方手动统一提交事务 * @param analyseResult * @param sampleId + * @param gasSampleId + * @param detSampleId * @param idAnalysis */ - public void create(BgAnalyseResult analyseResult,Integer sampleId, Integer idAnalysis); + public void create(BgAnalyseResult analyseResult,Integer sampleId,Integer gasSampleId,Integer detSampleId,Integer idAnalysis); } diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/GardsSampleDataService.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/GardsSampleDataService.java index 59d6a559..8fc6d37d 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/GardsSampleDataService.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/GardsSampleDataService.java @@ -12,6 +12,13 @@ public interface GardsSampleDataService extends IService { */ public boolean fileExist(String inputFileName); + /** + * 查询GardsSampleData + * @param inputFileName + * @return + */ + public GardsSampleData findByInputFileName(String inputFileName); + /** * 获取谱文件保存路径 * @param measurementId diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsAnalysesServiceImpl.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsAnalysesServiceImpl.java index 8708f13c..59b69f32 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsAnalysesServiceImpl.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsAnalysesServiceImpl.java @@ -1,6 +1,7 @@ package org.jeecg.modules.service.impl; import cn.hutool.core.util.ObjectUtil; +import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.RequiredArgsConstructor; @@ -57,6 +58,7 @@ public class GardsAnalysesServiceImpl extends ServiceImpl wrapper = new LambdaQueryWrapper<>(); diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsCalibrationServiceImpl.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsCalibrationServiceImpl.java index 7c4d533a..876267f0 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsCalibrationServiceImpl.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsCalibrationServiceImpl.java @@ -23,16 +23,18 @@ public class GardsCalibrationServiceImpl extends ServiceImpl roiChannelsList = Lists.newArrayList(); this.saveSampleRoiChannels(analyseResult,sampleId,idAnalysis,roiChannelsList); - this.saveGasRoiChannels(analyseResult,sampleId,idAnalysis,roiChannelsList); - this.saveDetRoiChannels(analyseResult,sampleId,idAnalysis,roiChannelsList); + this.saveGasRoiChannels(analyseResult,gasSampleId,idAnalysis,roiChannelsList); + this.saveDetRoiChannels(analyseResult,detSampleId,idAnalysis,roiChannelsList); if(!CollectionUtils.isEmpty(roiChannelsList)){ this.saveBatch(roiChannelsList); } diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsRoiResultsServiceImpl.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsRoiResultsServiceImpl.java index e8eeb44f..ebe9afe3 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsRoiResultsServiceImpl.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsRoiResultsServiceImpl.java @@ -8,8 +8,6 @@ import org.jeecg.modules.native_jni.struct.BgAnalyseResult; import org.jeecg.modules.service.GardsRoiResultsService; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; - -import java.awt.geom.Arc2D; import java.util.Date; import java.util.List; @@ -32,6 +30,7 @@ public class GardsRoiResultsServiceImpl extends ServiceImpl list = Lists.newArrayList(); //C++那边没有补0,先加上后续解决后再删除 analyseResult.LC.add(0,0.0D); + for(int i=0;i analyseResult.MDC.get(i)){ -// list.get(i).setNidFlag(1); -// }else { -// list.get(i).setNidFlag(0); -// } -// } - list.get(i).setNidFlag(0); + seriNo = 0; + //从下标3开始,每次加3 + for(int i=3;i queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(GardsSampleData::getInputFileName,inputFileName); - queryWrapper.select(GardsSampleData::getSampleId); + queryWrapper.select(GardsSampleData::getSampleId,GardsSampleData::getInputFileName); final GardsSampleData sampleData = this.getOne(queryWrapper); return Objects.nonNull(sampleData) && StringUtils.isNotBlank(sampleData.getInputFileName()); } + /** + * 查询GardsSampleData + * @param inputFileName + * @return + */ + @Override + public GardsSampleData findByInputFileName(String inputFileName) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(GardsSampleData::getInputFileName,inputFileName); + return this.getOne(queryWrapper); + } + /** * 获取谱文件保存路径 * @param measurementId @@ -38,7 +55,13 @@ public class GardsSampleDataServiceImpl extends ServiceImpl sampleDatas = this.baseMapper.getSampleIdAndInputFileName(measurementId, dataType); + if(!CollectionUtils.isEmpty(sampleDatas)){ + //如果查询出多条则需要根据inputFileName字段降序排序后返回第一个 + final List sortResult = sampleDatas.stream().sorted(Comparator.comparing(GardsSampleData::getInputFileName).reversed()).collect(Collectors.toList()); + return sortResult.get(0); + } + return null; } /** diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/AlertSpectrum.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/AlertSpectrum.java index 6753e34f..bbc8937c 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/AlertSpectrum.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/AlertSpectrum.java @@ -54,7 +54,7 @@ public class AlertSpectrum extends SpectrumHandler{ * 检查规则并处理数据 */ @Override - protected void handler() throws Exception { + public void handler() throws Exception { if(DataType.ALERT_FLOW.getType().equals(super.currDataType.getType()) || DataType.ALERT_TEMP.getType().equals(super.currDataType.getType()) || DataType.ALERT_SYSTEM.getType().equals(super.currDataType.getType()) || diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/DetbkphdSpectrum.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/DetbkphdSpectrum.java index 60e545d8..19ae7192 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/DetbkphdSpectrum.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/DetbkphdSpectrum.java @@ -2,7 +2,6 @@ package org.jeecg.modules.spectrum; import org.jeecg.modules.base.enums.DataType; -import org.jeecg.modules.base.enums.SampleStatus; /** * 探测器本地谱处理 @@ -25,7 +24,7 @@ public class DetbkphdSpectrum extends S_D_Q_G_SpectrumHandler{ * 检查规则并处理数据 */ @Override - protected void handler() throws Exception { + public void handler() throws Exception { if(DataType.DETBKPHD.getType().equals(super.currDataType.getType())){ try{ //前置检查 @@ -43,8 +42,6 @@ public class DetbkphdSpectrum extends S_D_Q_G_SpectrumHandler{ //把流程日志写入ftp日志文件 super.saveLogToFtp(); }catch (Exception e){ - //修改状态为解析失败 - this.spectrumServiceQuotes.getSampleDataService().updateStatus(SampleStatus.FAIL.getValue(),super.sampleData.getInputFileName()); //处理解析失败的文件,上传到ftp->undeal目录 super.handleParseingFailFile(); throw e; diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/GasbkphdSpectrum.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/GasbkphdSpectrum.java index 600dd178..0ca37ccc 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/GasbkphdSpectrum.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/GasbkphdSpectrum.java @@ -2,7 +2,6 @@ package org.jeecg.modules.spectrum; import lombok.extern.slf4j.Slf4j; import org.jeecg.modules.base.enums.DataType; -import org.jeecg.modules.base.enums.SampleStatus; /** * 气体谱处理 @@ -26,7 +25,7 @@ public class GasbkphdSpectrum extends S_D_Q_G_SpectrumHandler{ * 检查规则并处理数据 */ @Override - protected void handler() throws Exception { + public void handler() throws Exception { if(DataType.GASBKPHD.getType().equals(super.currDataType.getType())){ try{ //前置检查 @@ -44,8 +43,6 @@ public class GasbkphdSpectrum extends S_D_Q_G_SpectrumHandler{ //把流程日志写入ftp日志文件 super.saveLogToFtp(); }catch (Exception e){ - //修改状态为解析失败 - this.spectrumServiceQuotes.getSampleDataService().updateStatus(SampleStatus.FAIL.getValue(),super.sampleData.getInputFileName()); //处理解析失败的文件,上传到ftp->undeal目录 super.handleParseingFailFile(); throw e; diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/HealthStatusSpectrum.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/HealthStatusSpectrum.java index 4a946c2a..d54e705c 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/HealthStatusSpectrum.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/HealthStatusSpectrum.java @@ -58,7 +58,7 @@ public class HealthStatusSpectrum extends SpectrumHandler{ * 检查规则并处理数据 */ @Override - protected void handler() throws Exception { + public void handler() throws Exception { if(DataType.SOH.getType().equals(super.currDataType.getType())){ //打印当前处理的能谱类型 super.printCurrDataType(); diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/MetSpectrum.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/MetSpectrum.java index 4b9a24af..54a5efb0 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/MetSpectrum.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/MetSpectrum.java @@ -55,7 +55,7 @@ public class MetSpectrum extends SpectrumHandler{ * 检查规则并处理数据 */ @Override - protected void handler() throws Exception { + public void handler() throws Exception { if(DataType.MET.getType().equals(super.currDataType.getType())){ //打印当前处理的能谱类型 super.printCurrDataType(); diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/QcphdSpectrum.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/QcphdSpectrum.java index efc5043e..45c2fac4 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/QcphdSpectrum.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/QcphdSpectrum.java @@ -1,7 +1,6 @@ package org.jeecg.modules.spectrum; import org.jeecg.modules.base.enums.DataType; -import org.jeecg.modules.base.enums.SampleStatus; /** * QC谱处理 @@ -24,7 +23,7 @@ public class QcphdSpectrum extends S_D_Q_G_SpectrumHandler{ * 检查规则并处理数据 */ @Override - protected void handler() throws Exception { + public void handler() throws Exception { //判断当前邮件内容是否是QC谱 if(DataType.QCPHD.getType().equals(super.currDataType.getType())){ try{ @@ -43,8 +42,6 @@ public class QcphdSpectrum extends S_D_Q_G_SpectrumHandler{ //把流程日志写入ftp日志文件 super.saveLogToFtp(); }catch (Exception e){ - //修改状态为解析失败 - this.spectrumServiceQuotes.getSampleDataService().updateStatus(SampleStatus.FAIL.getValue(),super.sampleData.getInputFileName()); //处理解析失败的文件,上传到ftp->undeal目录 super.handleParseingFailFile(); throw e; diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/S_D_Q_G_SpectrumHandler.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/S_D_Q_G_SpectrumHandler.java index 9fa42c29..dd98488a 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/S_D_Q_G_SpectrumHandler.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/S_D_Q_G_SpectrumHandler.java @@ -112,8 +112,7 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{ //获取文件保存路径 String fileSavePath = this.getFileSavePath(); final SpectrumPathProperties properties = this.spectrumServiceQuotes.getSpectrumPathProperties(); - fileSavePath = properties.getRootPath()+StringConstant.SLASH+fileSavePath; - super.ftpUtil.saveFile(fileSavePath,this.mailFile.getName(),new FileInputStream(this.mailFile)); + super.ftpUtil.saveFile(properties.getRootPath()+StringConstant.SLASH+fileSavePath,this.mailFile.getName(),new FileInputStream(this.mailFile)); //设置FTP文件保存路径 super.ftpSavePath = fileSavePath+StringConstant.SLASH+this.mailFile.getName(); } @@ -124,17 +123,19 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{ */ private String getFileSavePath(){ //处理此文件需要保存到ftp服务的路径 - final int year = LocalDate.now().getYear(); - final int month = LocalDate.now().getMonth().getValue(); + //measurement_id切割后的字符数组 + String[] arr = this.sourceData.measurement_id.split(StringConstant.DASH); + //切割后第一个,元素是年,第二个是月 + final String[] yearMonth = arr[1].split(StringConstant.SLASH); final SpectrumPathProperties properties = this.spectrumServiceQuotes.getSpectrumPathProperties(); StringBuilder ftpPath = new StringBuilder(); ftpPath.append(properties.getFilePathMap().get(this.sourceData.system_type)); ftpPath.append(StringConstant.SLASH); ftpPath.append(properties.getFilePathMap().get(this.sourceData.data_type)); ftpPath.append(StringConstant.SLASH); - ftpPath.append(year); + ftpPath.append(yearMonth[0]); ftpPath.append(StringConstant.SLASH); - ftpPath.append(month>=10?month:"0"+month); + ftpPath.append(yearMonth[1]); return ftpPath.toString(); } @@ -206,8 +207,9 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{ protected void handlerOriginalData() throws Exception { this.startIntoDatabaseTime = new Date(); //如果数据已经存储,不在重复存储 - final boolean exist = spectrumServiceQuotes.getSampleDataService().fileExist(super.ftpSavePath); - if(exist){ + final GardsSampleData query = spectrumServiceQuotes.getSampleDataService().findByInputFileName(super.ftpSavePath); + if(Objects.nonNull(query)){ + this.sampleData = query; this.endIntoDatabaseTime = new Date(); log.warn("{} file data has been stored",super.mailFile.getName()); return; @@ -268,10 +270,10 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{ logContent.append("------------------- ").append("Write Data into Database Successfully at ").append(DateUtils.formatDate(this.endIntoDatabaseTime,"yyyy-MM-dd HH:mm:ss")).append(" --------------------"); //保存日志文件到ftp final SpectrumPathProperties properties = this.spectrumServiceQuotes.getSpectrumPathProperties(); - this.logFilePath = properties.getLogPath()+StringConstant.SLASH+this.getFileSavePath(); + this.logFilePath = this.getFileSavePath(); this.logFileName = super.mailFile.getName().replace(this.currDataType.getSuffix(),LOG_FILE_SUFFIX); - super.ftpUtil.saveOrAppendFile(logFilePath,logFileName,new ByteArrayInputStream(logContent.toString().getBytes(StandardCharsets.UTF_8))); + super.ftpUtil.saveOrAppendFile(properties.getLogPath()+StringConstant.SLASH+logFilePath,logFileName,new ByteArrayInputStream(logContent.toString().getBytes(StandardCharsets.UTF_8))); } /** diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_B_Analysis.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_B_Analysis.java index 30e386ee..3714dc9f 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_B_Analysis.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_B_Analysis.java @@ -145,7 +145,7 @@ public class Sample_B_Analysis implements BlockConstant { */ public void start() throws BAnalyseException { try{ - //修改状态为解析中 + //修改状态为分析中 this.updateStatus(SampleStatus.IN_PROCESS.getValue()); //查询det、gas数据(sampleId,inputFileName),sample数据在构造函数已经传过来 this.queryPHDFile(); @@ -160,9 +160,11 @@ public class Sample_B_Analysis implements BlockConstant { //生成报告 Sample_B_Analysis.B_AnalysisReport report = new Sample_B_Analysis.B_AnalysisReport(); report.start(); - //修改状态为解析成功 + //修改状态为分析成功 this.updateStatus(SampleStatus.COMPLETE.getValue()); }catch (Exception e){ + //修改状态为分析失败 + this.spectrumServiceQuotes.getSampleDataService().updateStatus(SampleStatus.FAIL.getValue(),this.sampleData.getInputFileName()); e.printStackTrace(); throw new BAnalyseException("Sample Analyse Error at "+DateUtils.formatDate(new Date(),"yyyy-MM-dd HH:mm:ss")); }finally { @@ -191,8 +193,7 @@ public class Sample_B_Analysis implements BlockConstant { //如果找不到sample、det、gas谱文件数据则解析失败修改记录状态 if(StringUtils.isEmpty(this.sampleData.getInputFileName()) || Objects.isNull(this.detSampleData) || StringUtils.isEmpty(this.detSampleData.getInputFileName()) || Objects.isNull(this.gasSampleData) || StringUtils.isEmpty(this.gasSampleData.getInputFileName())){ - this.currAnalysesStatus = SampleStatus.FAIL.getValue(); - this.spectrumServiceQuotes.getSampleDataService().updateStatus(this.currAnalysesStatus,this.sampleData.getInputFileName()); + this.spectrumServiceQuotes.getSampleDataService().updateStatus(SampleStatus.FAIL.getValue(),this.sampleData.getInputFileName()); throw new FileNotExistException("gas or det file is no exist or is error.."); } @@ -203,21 +204,21 @@ public class Sample_B_Analysis implements BlockConstant { */ private void structureArrFilePath(){ //处理此文件需要保存到ftp服务的路径 - final int year = LocalDate.now().getYear(); - final int month = LocalDate.now().getMonth().getValue(); + //measurement_id切割后的字符数组 + String[] arr = this.sampleStruct.measurement_id.split(StringConstant.DASH); + //切割后第一个,元素是年,第二个是月 + final String[] yearMonth = arr[1].split(StringConstant.SLASH); final SpectrumPathProperties properties = this.spectrumServiceQuotes.getSpectrumPathProperties(); StringBuilder ftpPath = new StringBuilder(); - ftpPath.append(properties.getRootPath()); - ftpPath.append(StringConstant.SLASH); ftpPath.append(properties.getArrPath()); ftpPath.append(StringConstant.SLASH); ftpPath.append(properties.getFilePathMap().get(this.sampleStruct.system_type)); ftpPath.append(StringConstant.SLASH); ftpPath.append(properties.getFilePathMap().get(this.sampleStruct.data_type)); ftpPath.append(StringConstant.SLASH); - ftpPath.append(year); + ftpPath.append(yearMonth[0]); ftpPath.append(StringConstant.SLASH); - ftpPath.append(month>=10?month:"0"+month); + ftpPath.append(yearMonth[1]); this.arrFilePath = ftpPath.toString(); String arrFileTail = ARR_FILE_NAME_TAIL+ARR_FILE_SUFFIX; String sourceFileName = this.sampleData.getInputFileName().substring(this.sampleData.getInputFileName().lastIndexOf(StringConstant.SLASH)+1); @@ -234,6 +235,7 @@ public class Sample_B_Analysis implements BlockConstant { System.out.println("det:"+this.detTempFilePath); BgAnalyseResult analyseResult = EnergySpectrumHandler.bgAnalyse(this.sampleTempFilePath,this.gasTempFilePath,this.detTempFilePath); + System.out.println(analyseResult); this.endAnalysisTime = new Date(); if(Objects.isNull(analyseResult) || !analyseResult.analyse_flag){ throw new BAnalyseException("THE PHD file cannot be parsed:"+this.sampleTempFilePath+","+this.gasTempFilePath+","+this.detTempFilePath); @@ -249,7 +251,7 @@ public class Sample_B_Analysis implements BlockConstant { boolean flag = false; //下载gas谱PHD文件到本地临时路径 String gasFileName = gasSampleData.getInputFileName().substring(gasSampleData.getInputFileName().lastIndexOf(StringConstant.SLASH) + 1); - String gasFileFTPPath = gasSampleData.getInputFileName().substring(0, gasSampleData.getInputFileName().lastIndexOf(StringConstant.SLASH)); + String gasFileFTPPath = this.spectrumServiceQuotes.getSpectrumPathProperties().getRootPath()+StringConstant.SLASH+gasSampleData.getInputFileName().substring(0, gasSampleData.getInputFileName().lastIndexOf(StringConstant.SLASH)); boolean gasFlag = ftpUtil.downloadFTPFile(gasFileFTPPath,gasFileName,this.spectrumServiceQuotes.getTaskProperties().getTemporaryStoragePath()); if(!gasFlag){ flag = true; @@ -258,7 +260,7 @@ public class Sample_B_Analysis implements BlockConstant { //下载det谱PHD文件到本地临时路径 final String detFileName = detSampleData.getInputFileName().substring(detSampleData.getInputFileName().lastIndexOf(StringConstant.SLASH) + 1); - String detFileFTPPath = detSampleData.getInputFileName().substring(0, detSampleData.getInputFileName().lastIndexOf(StringConstant.SLASH)); + String detFileFTPPath = this.spectrumServiceQuotes.getSpectrumPathProperties().getRootPath()+StringConstant.SLASH+detSampleData.getInputFileName().substring(0, detSampleData.getInputFileName().lastIndexOf(StringConstant.SLASH)); boolean detFlag = ftpUtil.downloadFTPFile(detFileFTPPath,detFileName,this.spectrumServiceQuotes.getTaskProperties().getTemporaryStoragePath()); if(!detFlag){ flag = true; @@ -302,9 +304,9 @@ public class Sample_B_Analysis implements BlockConstant { spectrumServiceQuotes.getGardsCalibrationPairsService().createG_EnergyRecord(gasSampleData.getSampleId(),analyses.getIdAnalysis(),this.gasStruct); //存储gards_calibration表数据sample、det、gas谱B_Energy和G_Energy块数据 - spectrumServiceQuotes.getGardsCalibrationService().create(this.analyseResult,gasSampleData.getSampleId(),analyses.getIdAnalysis()); + spectrumServiceQuotes.getGardsCalibrationService().create(this.analyseResult,sampleData.getSampleId(),gasSampleData.getSampleId(),detSampleData.getSampleId(),analyses.getIdAnalysis()); //gards_roi_channels数据表,存储sample、det、gas谱数据 - spectrumServiceQuotes.getRoiChannelsService().create(this.analyseResult,sampleData.getSampleId(),analyses.getIdAnalysis()); + spectrumServiceQuotes.getRoiChannelsService().create(this.analyseResult,sampleData.getSampleId(),gasSampleData.getSampleId(),detSampleData.getSampleId(),analyses.getIdAnalysis()); //gards_Xe_results数据表XE_131m、XE_133、XE_133m、XE_135数据 spectrumServiceQuotes.getXeResultsService().create(this.analyseResult,sampleData.getSampleId(),analyses.getIdAnalysis()); //gards_ roi_results数据表 @@ -362,6 +364,7 @@ public class Sample_B_Analysis implements BlockConstant { public void start() throws IOException { //获取报告内容 this.getTemplateContent(); + //创建报告临时文件 this.createTmpReportFile(); //处理报告时间 @@ -479,17 +482,16 @@ public class Sample_B_Analysis implements BlockConstant { this.templateContent = this.templateContent.replace("${DET_SampleID}",detSampleData.getSampleId().toString()); this.templateContent = this.templateContent.replace("${GAS_SampleID}",gasSampleData.getSampleId().toString()); } - /** * 处理#SAMPLE CALIBRATION 模块 * 还需和周雨涵确认s_b_fitting_c_e、s_g_fitting_c_e */ private void handleSampleCalibration() throws IOException { String[] betaArr = {CH_Contant+this.calibration(analyseResult.s_b_fitting_type,analyseResult.s_b_fitting_e_c), - E_Contant+this.calibration(analyseResult.s_b_fitting_type,analyseResult.s_b_fitting_e_c)}; + E_Contant+this.calibration(analyseResult.s_b_fitting_type,analyseResult.s_b_fitting_c_e)}; String[] gammaArr = {CH_Contant+this.calibration(analyseResult.s_g_fitting_type,analyseResult.s_g_fitting_e_c), - E_Contant+this.calibration(analyseResult.s_g_fitting_type,analyseResult.s_g_fitting_e_c)}; + E_Contant+this.calibration(analyseResult.s_g_fitting_type,analyseResult.s_g_fitting_c_e)}; this.handleTwoParamFormat("#SAMPLE CALIBRATION",betaArr,gammaArr); } @@ -519,10 +521,10 @@ public class Sample_B_Analysis implements BlockConstant { */ private void handleDetCalibration() throws IOException { String[] betaArr = {CH_Contant+this.calibration(analyseResult.d_b_fitting_type,analyseResult.d_b_fitting_e_c), - E_Contant+this.calibration(analyseResult.d_b_fitting_type,analyseResult.d_b_fitting_e_c)}; + E_Contant+this.calibration(analyseResult.d_b_fitting_type,analyseResult.d_b_fitting_c_e)}; String[] gammaArr = {CH_Contant+this.calibration(analyseResult.d_g_fitting_type,analyseResult.d_g_fitting_e_c), - E_Contant+this.calibration(analyseResult.d_g_fitting_type,analyseResult.d_g_fitting_e_c)}; + E_Contant+this.calibration(analyseResult.d_g_fitting_type,analyseResult.d_g_fitting_c_e)}; this.handleTwoParamFormat("#DET CALIBRATION",betaArr,gammaArr); } @@ -552,10 +554,10 @@ public class Sample_B_Analysis implements BlockConstant { */ private void handleGasCalibration() throws IOException { String[] betaArr = {CH_Contant+this.calibration(analyseResult.g_b_fitting_type,analyseResult.g_b_fitting_e_c), - E_Contant+this.calibration(analyseResult.g_b_fitting_type,analyseResult.g_b_fitting_e_c)}; + E_Contant+this.calibration(analyseResult.g_b_fitting_type,analyseResult.g_b_fitting_c_e)}; String[] gammaArr = {CH_Contant+this.calibration(analyseResult.g_g_fitting_type,analyseResult.g_g_fitting_e_c), - E_Contant+this.calibration(analyseResult.g_g_fitting_type,analyseResult.g_g_fitting_e_c)}; + E_Contant+this.calibration(analyseResult.g_g_fitting_type,analyseResult.g_g_fitting_c_e)}; this.handleTwoParamFormat("#GAS CALIBRATION",betaArr,gammaArr); } @@ -600,7 +602,7 @@ public class Sample_B_Analysis implements BlockConstant { List roi_net_count_err = analyseResult.ROI_net_coutns_err; List roi = analyseResult.ROI.stream().map(Object::toString).collect(Collectors.toList()); - List lc = analyseResult.LC.stream().map(v->formatToStr5(v)).collect(Collectors.toList()); + List lc = analyseResult.LC_CTS.stream().map(v->formatToStr5(v)).collect(Collectors.toList()); List netCount = Lists.newArrayList(); String flag = " +/- "; for(int i=0;iundeal目录 super.handleParseingFailFile(); throw e; diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SpectrumHandler.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SpectrumHandler.java index e9da4c6b..cd2d5aff 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SpectrumHandler.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SpectrumHandler.java @@ -53,7 +53,7 @@ public abstract class SpectrumHandler extends Chain{ /** * 初始化参数 */ - protected void init(String mailContent,SpectrumServiceQuotes spectrumServiceQuotes,FTPUtils ftpUtil) throws Exception{ + public void init(String mailContent,SpectrumServiceQuotes spectrumServiceQuotes,FTPUtils ftpUtil) throws Exception{ this.mailContent = mailContent; this.spectrumServiceQuotes = spectrumServiceQuotes; this.ftpUtil = ftpUtil; @@ -75,7 +75,7 @@ public abstract class SpectrumHandler extends Chain{ /** * 检查规则并处理数据 */ - protected abstract void handler() throws Exception; + public abstract void handler() throws Exception; /** * 调用dll解析邮件 @@ -114,7 +114,7 @@ public abstract class SpectrumHandler extends Chain{ /** * 把邮件内容存储到本地 */ - protected boolean saveEmailToLocal(){ + public boolean saveEmailToLocal(){ boolean flag = false; final DataType[] values = DataType.values(); for(DataType value : values){ diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SpectrumParsingActuator.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SpectrumParsingActuator.java index 804d4ded..0d0f5ed5 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SpectrumParsingActuator.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SpectrumParsingActuator.java @@ -110,7 +110,7 @@ public class SpectrumParsingActuator implements Runnable{ } } } catch (Exception e) { - log.error(mailContent.toString()); +// log.error(mailContent.toString()); log.error("邮件解析失败,邮件主题为:{},发送时间为:{},接收时间为:{},失败原因为:{}",subject,sendTime,receiveTime,e.getMessage()); e.printStackTrace(); }finally { @@ -121,7 +121,7 @@ public class SpectrumParsingActuator implements Runnable{ e.printStackTrace(); } this.taskLatch.countDown(); - ftpUtil.close(); + this.ftpUtil.close(); } } diff --git a/jeecg-server-cloud/jeecg-auto-process-start/src/main/java/org/jeecg/JeecgAutoProcessApplication.java b/jeecg-server-cloud/jeecg-auto-process-start/src/main/java/org/jeecg/JeecgAutoProcessApplication.java index c6c9daa7..e0bb17f5 100644 --- a/jeecg-server-cloud/jeecg-auto-process-start/src/main/java/org/jeecg/JeecgAutoProcessApplication.java +++ b/jeecg-server-cloud/jeecg-auto-process-start/src/main/java/org/jeecg/JeecgAutoProcessApplication.java @@ -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(); } } \ No newline at end of file