fix:1.修改从filesource跑文件生成报告是报错问题
This commit is contained in:
parent
f20fdb4271
commit
89d24abd35
jeecg-module-auto-process/src/main/java/org/jeecg/modules
jeecg-server-cloud/jeecg-auto-process-start/src/main/java/org/jeecg
|
@ -68,7 +68,6 @@ public class FileSourceHandleManager {
|
|||
@Override
|
||||
public void run() {
|
||||
for(;;){
|
||||
System.out.println("222222222222222222222222222222222222222222222222222222222222222222222222222222222");
|
||||
long start = System.currentTimeMillis();
|
||||
FTPUtils ftpUtil = null;
|
||||
try {
|
||||
|
@ -143,7 +142,6 @@ public class FileSourceHandleManager {
|
|||
@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(),
|
||||
|
|
|
@ -63,7 +63,6 @@ public class UndealHandleManager {
|
|||
@Override
|
||||
public void run() {
|
||||
for(;;){
|
||||
System.out.println("1111111111111111111111111111111111111111111111111111111111111111111111111111111111");
|
||||
long start = System.currentTimeMillis();
|
||||
FTPUtils ftpUtil = null;
|
||||
try {
|
||||
|
@ -135,7 +134,6 @@ public class UndealHandleManager {
|
|||
@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(),
|
||||
|
|
|
@ -39,13 +39,17 @@ public class DetbkphdSpectrum extends S_D_Q_G_SpectrumHandler{
|
|||
super.saveFileToFtp();
|
||||
//结构体数据入库
|
||||
super.handlerOriginalData();
|
||||
//把流程日志写入ftp日志文件
|
||||
super.saveLogToFtp();
|
||||
//处理流程日志
|
||||
super.handleProcessLog();
|
||||
}catch (Exception e){
|
||||
//异常结束日志
|
||||
super.exceptionEndLog(e);
|
||||
//处理解析失败的文件,上传到ftp->undeal目录
|
||||
super.handleParseingFailFile();
|
||||
throw e;
|
||||
}finally {
|
||||
//结束流程日志
|
||||
super.storageProcessLogEnd();
|
||||
//删除本地临时文件
|
||||
super.deleteLocalTemporaryFile();
|
||||
}
|
||||
|
|
|
@ -40,13 +40,17 @@ public class GasbkphdSpectrum extends S_D_Q_G_SpectrumHandler{
|
|||
super.saveFileToFtp();
|
||||
//结构体数据入库
|
||||
super.handlerOriginalData();
|
||||
//把流程日志写入ftp日志文件
|
||||
super.saveLogToFtp();
|
||||
//处理流程日志
|
||||
super.handleProcessLog();
|
||||
}catch (Exception e){
|
||||
//异常结束日志
|
||||
super.exceptionEndLog(e);
|
||||
//处理解析失败的文件,上传到ftp->undeal目录
|
||||
super.handleParseingFailFile();
|
||||
throw e;
|
||||
}finally {
|
||||
//结束流程日志
|
||||
super.storageProcessLogEnd();
|
||||
//删除本地临时文件
|
||||
super.deleteLocalTemporaryFile();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,233 @@
|
|||
package org.jeecg.modules.spectrum;
|
||||
|
||||
import lombok.Setter;
|
||||
import org.jeecg.common.constant.StringConstant;
|
||||
import org.jeecg.common.properties.SpectrumPathProperties;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.jeecg.modules.base.enums.SampleStatus;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* B谱邮件解析流程日志
|
||||
*/
|
||||
public class ParsingProcessLog {
|
||||
|
||||
/**
|
||||
* 日志内容
|
||||
*/
|
||||
private StringBuilder log = new StringBuilder();
|
||||
/**
|
||||
* 日志存储结束标记
|
||||
*/
|
||||
private boolean logStoreEndFlag = false;
|
||||
/**
|
||||
* 日志分析结束标记
|
||||
*/
|
||||
private boolean logAnalyseEndFlag = false;
|
||||
/**
|
||||
* 能谱处理父类
|
||||
*/
|
||||
@Setter
|
||||
private S_D_Q_G_SpectrumHandler spectrumHandler;
|
||||
/**
|
||||
* 能谱分析类
|
||||
*/
|
||||
@Setter
|
||||
private Sample_B_Analysis sample_B_Analysis;
|
||||
/**
|
||||
* 解析过程日志对象
|
||||
*/
|
||||
private StorageProcessLog processLog;
|
||||
|
||||
/**
|
||||
* 存储过程日志处理
|
||||
*/
|
||||
protected class StorageProcessLog{
|
||||
|
||||
private static final String WRITE_INTO_START = "%s Write Data into Database at %s %s";
|
||||
private static final String APPLICATION_PATH = "ApplicationPath:%s,ApplicationName:%s,started by RNAUTO at %s";
|
||||
private static final String DATABASE_CONNECTED = "Successfully connected to database,source:%s,user=%s";
|
||||
private static final String SOURCE_FILE = "SourceFile:%s";
|
||||
private static final String STANDARD_FILE = "StandardFile:%s";
|
||||
private static final String DETECTOR_ID = "Detector ID:%s";
|
||||
private static final String STATION_ID = "Station ID:%s";
|
||||
private static final String SAMPLE_ID = "Sample ID:%s";
|
||||
private static final String INSTANCE_STATUS = "Instance status successfully set to:%s.....";
|
||||
private static final String WRITE_INTO_SUCCESS = "%s Write Data into Database Successfully at %s %s";
|
||||
private static final String FILE_REPEAT = "File: %s repeat";
|
||||
private static final String WRITE_INTO_ERROR = "%s Write Data into Database Error at %s %s";
|
||||
|
||||
/**
|
||||
* 开始处理存储过程日志
|
||||
*/
|
||||
private void start(){
|
||||
//获取数据源属性
|
||||
final String oraUsername = spectrumHandler.spectrumServiceQuotes.getOraDataSourceProperties().getUsername();
|
||||
final String oraUrl = spectrumHandler.spectrumServiceQuotes.getOraDataSourceProperties().getUrl();
|
||||
final String startIntoDatabaseTime = DateUtils.formatDate(spectrumHandler.startIntoDatabaseTime, "yyyy-MM-dd HH:mm:ss");
|
||||
final String standardFile = spectrumHandler.spectrumServiceQuotes.getFtpProperties().getFtpRootPath() + StringConstant.SLASH + spectrumHandler.ftpSavePath;
|
||||
log.append(titleFormat(WRITE_INTO_START,26, StringConstant.DASH,startIntoDatabaseTime,StringConstant.DASH));
|
||||
log.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
log.append(rowFormat(APPLICATION_PATH,spectrumHandler.getProjectAbsolutePath(),spectrumHandler.getProjectName(),startIntoDatabaseTime));
|
||||
log.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
log.append(rowFormat(DATABASE_CONNECTED,oraUrl.substring(oraUrl.lastIndexOf(":")+1),oraUsername));
|
||||
log.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
log.append(rowFormat(SOURCE_FILE,spectrumHandler.mailFile.getAbsolutePath()));
|
||||
log.append(System.lineSeparator());
|
||||
log.append(rowFormat(STANDARD_FILE,standardFile));
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件重复结束日志
|
||||
*/
|
||||
private void endOfFileRepeat(){
|
||||
final String endIntoDatabaseTime = DateUtils.formatDate(spectrumHandler.endIntoDatabaseTime, "yyyy-MM-dd HH:mm:ss");
|
||||
log.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
log.append(rowFormat(FILE_REPEAT,spectrumHandler.ftpSavePath));
|
||||
log.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
log.append(titleFormat(WRITE_INTO_ERROR,19,StringConstant.DASH,endIntoDatabaseTime,StringConstant.DASH));
|
||||
}
|
||||
|
||||
/**
|
||||
* 正常结束
|
||||
*/
|
||||
private void end(){
|
||||
final String endIntoDatabaseTime = DateUtils.formatDate(spectrumHandler.endIntoDatabaseTime, "yyyy-MM-dd HH:mm:ss");
|
||||
log.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
log.append(rowFormat(DETECTOR_ID,spectrumHandler.sampleData.getDetectorId().toString()));
|
||||
log.append(System.lineSeparator());
|
||||
log.append(rowFormat(STATION_ID,spectrumHandler.sampleData.getStationId().toString()));
|
||||
log.append(System.lineSeparator());
|
||||
log.append(rowFormat(SAMPLE_ID,spectrumHandler.sampleData.getSampleId().toString()));
|
||||
log.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
log.append(rowFormat(INSTANCE_STATUS, SampleStatus.UNTREATED.getValue()));
|
||||
log.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
log.append(titleFormat(WRITE_INTO_SUCCESS,19,StringConstant.DASH,endIntoDatabaseTime,StringConstant.DASH));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分析过程日志
|
||||
*/
|
||||
private class AnalyseProcessLog{
|
||||
private static final String anlyseResultsBegin = "%s Sample Analyse Beginning at %s %s";
|
||||
private static final String titleId = "%s Get DetaId and GasId %s";
|
||||
private static final String getDetaId = "%s Search DetFile :%s SampleID :%s";
|
||||
private static final String titleIdEnd = "%s Get DetaId and GasId finished %s";
|
||||
private static final String titleCalibration = "%s Read calibration data %s";
|
||||
private static final String setSampleBEnergyChannel = "Reading sample beta energy pairs(sampleID: %s).....";
|
||||
private static final String setSampleGEnergyChannel = "Reading sample gamma energy pairs(sampleID: %s).....";
|
||||
private static final String setDetaBEnergyChannel = "Reading DETBK Spectrum beta energy pairs(sampleID: %s).....";
|
||||
private static final String setDetaGEnergyChannel = "Reading DETBK Spectrum gamma energy pairs(sampleID: %s).....";
|
||||
private static final String setGasBEnergyChannel = "Reading GASBK Spectrum beta energy pairs(sampleID: %s).....";
|
||||
private static final String setGasGEnergyChannel = "Reading GASBK Spectrum gamma energy pairs(sampleID: %s)";
|
||||
private static final String getMeasurementTime = "Reading mesurement information.....";
|
||||
|
||||
private static final String dataStore = "Data store %s .....";
|
||||
private static final String setStatus = "Instance status successfully set to: %s .....";
|
||||
private static final String anlyseResultsEnd = "%s Sample Analyse Successfully at %s %s";
|
||||
private static final String dataAnlyseError = "Data Anlyse Error:gas or det file is no exist or is error..";
|
||||
private static final String anlyseResultsErrorEnd="%s Sample Analyse Error at %s %s";
|
||||
|
||||
/**
|
||||
* 开始处理分析过程日志
|
||||
*/
|
||||
private void start(){
|
||||
final String anlyseResultsBegin = "%s Sample Analyse Beginning at %s %s";
|
||||
final String startAnalysisTime = DateUtils.formatDate(sample_B_Analysis.startAnalysisTime, "yyyy-MM-dd HH:mm:ss");
|
||||
log.append(titleFormat(anlyseResultsBegin,26,StringConstant.DASH,startAnalysisTime,StringConstant.DASH));
|
||||
}
|
||||
|
||||
private void setDetAndGasIdLog(){
|
||||
final String titleId = "%s Get DetaId and GasId %s";
|
||||
log.append(titleFormat(titleId,40,StringConstant.DOT,StringConstant.DOT));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始存储流程日志
|
||||
* @return
|
||||
*/
|
||||
protected void storageProcessLogStart(){
|
||||
this.processLog = new StorageProcessLog();
|
||||
this.processLog.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* 结束存储流程日志
|
||||
*/
|
||||
protected void storageProcessLogEnd(){
|
||||
if(this.logStoreEndFlag == false){
|
||||
this.processLog.end();
|
||||
this.logStoreEndFlag = true;
|
||||
this.saveLogToFTP();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件重复异常结束存储流程日志
|
||||
*/
|
||||
protected void endOfFileRepeat(){
|
||||
if(this.logStoreEndFlag == false){
|
||||
this.processLog.endOfFileRepeat();
|
||||
this.logStoreEndFlag = true;
|
||||
this.saveLogToFTP();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存日志到ftp
|
||||
*/
|
||||
private void saveLogToFTP(){
|
||||
//保存日志文件到ftp
|
||||
final SpectrumPathProperties properties = spectrumHandler.spectrumServiceQuotes.getSpectrumPathProperties();
|
||||
spectrumHandler.logFilePath = spectrumHandler.getFileSavePath();
|
||||
spectrumHandler.logFileName = spectrumHandler.mailFile.getName().replace(spectrumHandler.currDataType.getSuffix(),SpectrumHandler.LOG_FILE_SUFFIX);
|
||||
|
||||
spectrumHandler.ftpUtil.saveOrAppendFile(properties.getLogPath()+StringConstant.SLASH+spectrumHandler.logFilePath,spectrumHandler.logFileName,new ByteArrayInputStream(log.toString().getBytes(StandardCharsets.UTF_8)));
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
ParsingProcessLog s = new ParsingProcessLog();
|
||||
s.storageProcessLogStart();
|
||||
s.endOfFileRepeat();
|
||||
System.out.println(s.log.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 行日志格式化
|
||||
* @param source 需要格式化的字符串
|
||||
* @param symbolNum 格式化的符号数量
|
||||
* @param args 格式化替换参数数组
|
||||
* @return
|
||||
*/
|
||||
private String titleFormat(String source, Integer symbolNum, String... args){
|
||||
StringBuilder firstParam = new StringBuilder();
|
||||
for (int i=0;i<symbolNum;i++){
|
||||
firstParam.append(args[0]);
|
||||
}
|
||||
args[0] = firstParam.toString();
|
||||
|
||||
StringBuilder lastParam = new StringBuilder();
|
||||
for (int i=0;i<symbolNum;i++){
|
||||
lastParam.append(args[args.length-1]);
|
||||
}
|
||||
args[args.length-1] = lastParam.toString();
|
||||
|
||||
return String.format(source,args);
|
||||
}
|
||||
|
||||
/**
|
||||
* 行格式化
|
||||
* @param source
|
||||
* @param args
|
||||
* @return
|
||||
*/
|
||||
private String rowFormat(String source, String... args){
|
||||
return String.format(source,args);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -39,13 +39,17 @@ public class QcphdSpectrum extends S_D_Q_G_SpectrumHandler{
|
|||
super.saveFileToFtp();
|
||||
//结构体数据入库
|
||||
super.handlerOriginalData();
|
||||
//把流程日志写入ftp日志文件
|
||||
super.saveLogToFtp();
|
||||
//处理流程日志
|
||||
super.handleProcessLog();
|
||||
}catch (Exception e){
|
||||
//异常结束日志
|
||||
super.exceptionEndLog(e);
|
||||
//处理解析失败的文件,上传到ftp->undeal目录
|
||||
super.handleParseingFailFile();
|
||||
throw e;
|
||||
}finally {
|
||||
//结束流程日志
|
||||
super.storageProcessLogEnd();
|
||||
//删除本地临时文件
|
||||
super.deleteLocalTemporaryFile();
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.jeecg.common.constant.StringConstant;
|
||||
import org.jeecg.common.properties.SpectrumPathProperties;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.jeecg.modules.base.entity.original.GardsSampleData;
|
||||
import org.jeecg.modules.base.enums.DataType;
|
||||
import org.jeecg.modules.config.datasource.DataSourceSwitcher;
|
||||
|
@ -20,15 +19,12 @@ import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
|
|||
import org.jeecg.modules.service.ISpectrumBlockService;
|
||||
import org.springframework.boot.system.ApplicationHome;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
|
||||
import java.io.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
@ -46,11 +42,11 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{
|
|||
/**
|
||||
* 开始存库时间
|
||||
*/
|
||||
private Date startIntoDatabaseTime = null;
|
||||
protected Date startIntoDatabaseTime = null;
|
||||
/**
|
||||
* 结束存库时间
|
||||
*/
|
||||
private Date endIntoDatabaseTime = null;
|
||||
protected Date endIntoDatabaseTime = null;
|
||||
/**
|
||||
* 基础数据
|
||||
*/
|
||||
|
@ -63,6 +59,10 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{
|
|||
* 日志文件名称
|
||||
*/
|
||||
protected String logFileName;
|
||||
/**
|
||||
* 流程日志对象
|
||||
*/
|
||||
protected ParsingProcessLog parsingProcessLog;
|
||||
|
||||
/**
|
||||
* 前置检查
|
||||
|
@ -121,7 +121,7 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{
|
|||
* 获取文件保存路径
|
||||
* @return
|
||||
*/
|
||||
private String getFileSavePath(){
|
||||
protected String getFileSavePath(){
|
||||
//处理此文件需要保存到ftp服务的路径
|
||||
//measurement_id切割后的字符数组
|
||||
String[] arr = this.sourceData.measurement_id.split(StringConstant.DASH);
|
||||
|
@ -211,8 +211,7 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{
|
|||
if(Objects.nonNull(query)){
|
||||
this.sampleData = query;
|
||||
this.endIntoDatabaseTime = new Date();
|
||||
log.warn("{} file data has been stored",super.mailFile.getName());
|
||||
return;
|
||||
throw new FileRepeatException("file repeat");
|
||||
}
|
||||
DataSourceSwitcher.switchToOracle();
|
||||
final TransactionStatus transactionStatus = spectrumServiceQuotes.getTransactionManager().getTransaction(spectrumServiceQuotes.getTransactionDefinition());
|
||||
|
@ -238,49 +237,11 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 把流程日志写入ftp日志文件
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
protected void saveLogToFtp() throws FileNotFoundException {
|
||||
//获取数据源属性
|
||||
final String oraUsername = spectrumServiceQuotes.getOraDataSourceProperties().getUsername();
|
||||
final String oraUrl = spectrumServiceQuotes.getOraDataSourceProperties().getUrl();
|
||||
//组装日志文件内容
|
||||
StringBuilder logContent = new StringBuilder();
|
||||
logContent.append("-------------------------- Write Data into Database at ").append(DateUtils.formatDate(this.startIntoDatabaseTime,"yyyy-MM-dd HH:mm:ss")).append(" ---------------------------");
|
||||
logContent.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
logContent.append("ApplicationPath:").append(this.getProjectAbsolutePath()).append(",").append("ApplicationName:").append(this.getProjectName()).append(",started by RNAUTO at ").append(this.startIntoDatabaseTime);
|
||||
logContent.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
logContent.append("Successfully connected to database,source:").append(oraUrl.substring(oraUrl.lastIndexOf(":")+1)).append(",user=").append(oraUsername);
|
||||
logContent.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
logContent.append("SourceFile:").append(super.mailFile.getAbsolutePath());
|
||||
logContent.append(System.lineSeparator());
|
||||
logContent.append("StandardFile:").append(spectrumServiceQuotes.getFtpProperties().getFtpRootPath()).append(StringConstant.SLASH).append(super.ftpSavePath);
|
||||
logContent.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
logContent.append("Detector ID:").append(this.sampleData.getDetectorId());
|
||||
logContent.append(System.lineSeparator());
|
||||
logContent.append("Station ID:").append(this.sampleData.getStationId());
|
||||
logContent.append(System.lineSeparator());
|
||||
logContent.append("Sample ID:").append(this.sampleData.getSampleId());
|
||||
logContent.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
logContent.append("Instance status successfully set to:").append(this.sampleData.getStatus()).append(".....");
|
||||
logContent.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
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 = this.getFileSavePath();
|
||||
this.logFileName = super.mailFile.getName().replace(this.currDataType.getSuffix(),LOG_FILE_SUFFIX);
|
||||
|
||||
super.ftpUtil.saveOrAppendFile(properties.getLogPath()+StringConstant.SLASH+logFilePath,logFileName,new ByteArrayInputStream(logContent.toString().getBytes(StandardCharsets.UTF_8)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取项目绝对路径
|
||||
* @return
|
||||
*/
|
||||
private String getProjectAbsolutePath(){
|
||||
protected String getProjectAbsolutePath(){
|
||||
ApplicationHome applicationHome = new ApplicationHome();
|
||||
return applicationHome.getDir().getAbsolutePath();
|
||||
}
|
||||
|
@ -289,7 +250,7 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{
|
|||
* 获取项目名称
|
||||
* @return
|
||||
*/
|
||||
private String getProjectName(){
|
||||
protected String getProjectName(){
|
||||
ApplicationHome applicationHome = new ApplicationHome();
|
||||
File[] files = applicationHome.getDir().listFiles(new FileFilter() {
|
||||
@Override
|
||||
|
@ -307,4 +268,33 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{
|
|||
}
|
||||
return Strings.EMPTY;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建流程日志对象处理解析流程日志
|
||||
*/
|
||||
protected void handleProcessLog(){
|
||||
ParsingProcessLog parsingProcessLog = new ParsingProcessLog();
|
||||
parsingProcessLog.setSpectrumHandler(this);
|
||||
parsingProcessLog.storageProcessLogStart();
|
||||
this.parsingProcessLog = parsingProcessLog;
|
||||
}
|
||||
|
||||
/**
|
||||
* 异常结束日志
|
||||
* @param e
|
||||
*/
|
||||
protected void exceptionEndLog(Exception e){
|
||||
if(e instanceof FileRepeatException){
|
||||
this.parsingProcessLog.endOfFileRepeat();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 正常结束日志
|
||||
*/
|
||||
protected void storageProcessLogEnd(){
|
||||
if(Objects.nonNull(this.parsingProcessLog)){
|
||||
this.parsingProcessLog.storageProcessLogEnd();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,10 +2,8 @@ package org.jeecg.modules.spectrum;
|
|||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import io.swagger.models.auth.In;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.RandomUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jeecg.common.constant.StringConstant;
|
||||
import org.jeecg.common.properties.SpectrumPathProperties;
|
||||
|
@ -27,10 +25,7 @@ import org.jeecg.modules.service.BlockConstant;
|
|||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -120,11 +115,11 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
/**
|
||||
* 开始分析时间
|
||||
*/
|
||||
private Date startAnalysisTime;
|
||||
protected Date startAnalysisTime;
|
||||
/**
|
||||
* 结束分析时间
|
||||
*/
|
||||
private Date endAnalysisTime;
|
||||
protected Date endAnalysisTime;
|
||||
|
||||
public Sample_B_Analysis() {
|
||||
}
|
||||
|
@ -270,6 +265,8 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
if(flag){
|
||||
throw new FileNotExistException("gas or det file is no exist or is error..");
|
||||
}
|
||||
this.detStruct = EnergySpectrumHandler.getSourceData(detSampleData.getInputFileName());
|
||||
this.gasStruct = EnergySpectrumHandler.getSourceData(gasSampleData.getInputFileName());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -295,11 +292,9 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
spectrumServiceQuotes.getGardsCalibrationPairsService().createB_EnergyRecord(sampleData.getSampleId(),analyses.getIdAnalysis(),this.sampleStruct);
|
||||
spectrumServiceQuotes.getGardsCalibrationPairsService().createG_EnergyRecord(sampleData.getSampleId(),analyses.getIdAnalysis(),this.sampleStruct);
|
||||
//存储det谱B_Energy和G_Energy块数据
|
||||
this.detStruct = EnergySpectrumHandler.getSourceData(detSampleData.getInputFileName());
|
||||
spectrumServiceQuotes.getGardsCalibrationPairsService().createB_EnergyRecord(detSampleData.getSampleId(),analyses.getIdAnalysis(),this.detStruct);
|
||||
spectrumServiceQuotes.getGardsCalibrationPairsService().createG_EnergyRecord(detSampleData.getSampleId(),analyses.getIdAnalysis(),this.detStruct);
|
||||
//存储gas谱B_Energy和G_Energy块数据
|
||||
this.gasStruct = EnergySpectrumHandler.getSourceData(gasSampleData.getInputFileName());
|
||||
spectrumServiceQuotes.getGardsCalibrationPairsService().createB_EnergyRecord(gasSampleData.getSampleId(),analyses.getIdAnalysis(),this.gasStruct);
|
||||
spectrumServiceQuotes.getGardsCalibrationPairsService().createG_EnergyRecord(gasSampleData.getSampleId(),analyses.getIdAnalysis(),this.gasStruct);
|
||||
|
||||
|
@ -602,6 +597,8 @@ 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());
|
||||
//此参数需第一位补0
|
||||
analyseResult.LC_CTS.add(0,0D);
|
||||
List<String> lc = analyseResult.LC_CTS.stream().map(v->formatToStr5(v)).collect(Collectors.toList());
|
||||
List<String> netCount = Lists.newArrayList();
|
||||
String flag = " +/- ";
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.jeecg.modules.spectrum;
|
||||
|
||||
import org.jeecg.modules.base.enums.DataType;
|
||||
import org.jeecg.modules.base.enums.SampleStatus;
|
||||
import org.jeecg.modules.base.enums.SystemType;
|
||||
|
||||
/**
|
||||
|
@ -40,15 +39,19 @@ public class SamplephdSpectrum extends S_D_Q_G_SpectrumHandler{
|
|||
super.saveFileToFtp();
|
||||
//结构体数据入库
|
||||
super.handlerOriginalData();
|
||||
//把原始库流程日志写入ftp日志文件
|
||||
super.saveLogToFtp();
|
||||
//处理流程日志
|
||||
super.handleProcessLog();
|
||||
//进行B、G(P)谱分析
|
||||
this.autoAnalysis();
|
||||
}catch (Exception e){
|
||||
//异常结束日志
|
||||
super.exceptionEndLog(e);
|
||||
//处理解析失败的文件,上传到ftp->undeal目录
|
||||
super.handleParseingFailFile();
|
||||
throw e;
|
||||
}finally {
|
||||
//结束流程日志
|
||||
super.storageProcessLogEnd();
|
||||
//删除本地临时文件
|
||||
super.deleteLocalTemporaryFile();
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ public abstract class SpectrumHandler extends Chain{
|
|||
/**
|
||||
* 把流程日志写入ftp日志文件
|
||||
*/
|
||||
protected abstract void saveLogToFtp() throws FileNotFoundException;
|
||||
protected void saveLogToFtp() throws FileNotFoundException{};
|
||||
|
||||
/**
|
||||
* 打印当前能谱类型
|
||||
|
|
|
@ -55,7 +55,7 @@ public class JeecgAutoProcessApplication extends SpringBootServletInitializer im
|
|||
public void run(String... args) throws Exception {
|
||||
//调用dll
|
||||
System.loadLibrary("ReadPHDFile");
|
||||
autoProcessManager.start();
|
||||
// autoProcessManager.start();
|
||||
undealHandleManager.start();
|
||||
fileSourceHandleManager.start();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user