fix:1.修改所有能谱文件日志的sourcefile属性路径
This commit is contained in:
parent
3b062b2de8
commit
ff6d8b9baa
|
@ -2,7 +2,6 @@ package org.jeecg.modules;
|
|||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.jeecg.common.properties.TaskProperties;
|
||||
import org.jeecg.modules.enums.SpectrumSource;
|
||||
import org.jeecg.modules.service.BlockConstant;
|
||||
|
@ -77,7 +76,7 @@ public class FileSourceHandleManager{
|
|||
TimeUnit.SECONDS.sleep(5);
|
||||
}
|
||||
ParseingFileSourceThread parseingFileSourceThread = new ParseingFileSourceThread();
|
||||
parseingFileSourceThread.init(spectrumFile,filePath,taskLatch);
|
||||
parseingFileSourceThread.init(spectrumFile,taskLatch);
|
||||
poolExecutor.execute(parseingFileSourceThread);
|
||||
}
|
||||
taskLatch.await();
|
||||
|
@ -107,20 +106,11 @@ public class FileSourceHandleManager{
|
|||
* 能谱文件名称
|
||||
*/
|
||||
private File spectrumFile;
|
||||
/**
|
||||
* 手动放置能谱文件获取路径
|
||||
*/
|
||||
private String filePath;
|
||||
/**
|
||||
* 获取文件内容
|
||||
*/
|
||||
private String fileContent;
|
||||
|
||||
private CountDownLatch taskLatch;
|
||||
|
||||
public void init(File spectrumFile,String filePath,CountDownLatch taskLatch){
|
||||
public void init(File spectrumFile,CountDownLatch taskLatch){
|
||||
this.spectrumFile = spectrumFile;
|
||||
this.filePath = filePath;
|
||||
this.taskLatch = taskLatch;
|
||||
}
|
||||
|
||||
|
@ -128,11 +118,9 @@ public class FileSourceHandleManager{
|
|||
public void run() {
|
||||
StringBuilder finalFileName = new StringBuilder();
|
||||
try {
|
||||
//获取文件内容
|
||||
fileContent = FileUtils.readFileToString(spectrumFile,"UTF-8");
|
||||
//解析文件
|
||||
AbstractSpectrumHandler spectrumHandler = new SamplephdSpectrum();
|
||||
spectrumHandler.init(fileContent,spectrumServiceQuotes,finalFileName,SpectrumSource.FROM_FILE_SOURCE.getSourceType());
|
||||
spectrumHandler.init(spectrumFile,spectrumServiceQuotes,finalFileName,SpectrumSource.FROM_FILE_SOURCE.getSourceType());
|
||||
final boolean matchResult = spectrumHandler.saveEmailToLocal();
|
||||
if(matchResult){
|
||||
//开始解析
|
||||
|
@ -144,7 +132,7 @@ public class FileSourceHandleManager{
|
|||
}finally {
|
||||
taskLatch.countDown();
|
||||
//解析成功或者失败都会删除源文件
|
||||
spectrumFile.delete();
|
||||
// spectrumFile.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package org.jeecg.modules;
|
|||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.jeecg.common.properties.TaskProperties;
|
||||
import org.jeecg.modules.enums.SpectrumSource;
|
||||
import org.jeecg.modules.service.BlockConstant;
|
||||
|
@ -77,7 +76,7 @@ public class UndealHandleManager{
|
|||
TimeUnit.SECONDS.sleep(5);
|
||||
}
|
||||
ParseingFaliFileThread faliFileThread = new ParseingFaliFileThread();
|
||||
faliFileThread.init(spectrumFile,filePath,taskLatch);
|
||||
faliFileThread.init(spectrumFile,taskLatch);
|
||||
poolExecutor.execute(faliFileThread);
|
||||
}
|
||||
taskLatch.await();
|
||||
|
@ -108,16 +107,11 @@ public class UndealHandleManager{
|
|||
* 能谱文件名称
|
||||
*/
|
||||
private File spectrumFile;
|
||||
/**
|
||||
* 失败文件存储路径
|
||||
*/
|
||||
private String filePath;
|
||||
|
||||
private CountDownLatch taskLatch;
|
||||
|
||||
public void init(File spectrumFile,String filePath,CountDownLatch taskLatch){
|
||||
public void init(File spectrumFile,CountDownLatch taskLatch){
|
||||
this.spectrumFile = spectrumFile;
|
||||
this.filePath = filePath;
|
||||
this.taskLatch = taskLatch;
|
||||
}
|
||||
|
||||
|
@ -133,11 +127,9 @@ public class UndealHandleManager{
|
|||
spectrumServiceQuotes.getRedisStreamUtil().set(spectrumFile.getName(), currentMillis);
|
||||
}
|
||||
try {
|
||||
//获取文件内容
|
||||
final String fileContent = FileUtils.readFileToString(spectrumFile,"UTF-8");
|
||||
//解析文件
|
||||
AbstractSpectrumHandler spectrumHandler = new SamplephdSpectrum();
|
||||
spectrumHandler.init(fileContent,spectrumServiceQuotes,finalFileName,SpectrumSource.FORM_FILE_UNDEL.getSourceType());
|
||||
spectrumHandler.init(spectrumFile,spectrumServiceQuotes,finalFileName,SpectrumSource.FORM_FILE_UNDEL.getSourceType());
|
||||
final boolean matchResult = spectrumHandler.saveEmailToLocal();
|
||||
if(matchResult){
|
||||
//开始解析
|
||||
|
@ -151,7 +143,6 @@ public class UndealHandleManager{
|
|||
//满足undeal文件处理周期时长会删除源文件
|
||||
if ((currentMillis - createMillis) >= taskProperties.getUndealFileTimeOut()) {
|
||||
spectrumServiceQuotes.getRedisStreamUtil().del(spectrumFile.getName());
|
||||
//解析成功或者失败都会删除源文件
|
||||
spectrumFile.delete();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.jeecg.modules.spectrum;
|
|||
import cn.hutool.core.io.FileUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.jeecg.common.email.EmailLogEvent;
|
||||
import org.jeecg.common.email.EmailLogManager;
|
||||
import org.jeecg.common.properties.SpectrumPathProperties;
|
||||
|
@ -39,7 +40,11 @@ public abstract class AbstractSpectrumHandler extends AbstractChain {
|
|||
*/
|
||||
protected DataType currDataType;
|
||||
/**
|
||||
* 当前解析的能谱文件路径
|
||||
* 源文件路径(临时、undel、filesource路径)
|
||||
*/
|
||||
protected String sourceFilePath;
|
||||
/**
|
||||
* 当前解析的能谱文件路径,前期在临时、undel、filesource路径,解析完毕后移动到savefile
|
||||
*/
|
||||
protected File spectrumFile = null;
|
||||
/**
|
||||
|
@ -59,15 +64,6 @@ public abstract class AbstractSpectrumHandler extends AbstractChain {
|
|||
*/
|
||||
protected List<String> spectrumFileLabels = Lists.newArrayList();
|
||||
|
||||
/**
|
||||
* 初始化参数
|
||||
*/
|
||||
public void init(String mailContent,SpectrumServiceQuotes spectrumServiceQuotes,StringBuilder returnFileName) throws Exception{
|
||||
this.mailContent = mailContent;
|
||||
this.spectrumServiceQuotes = spectrumServiceQuotes;
|
||||
this.returnFileName = returnFileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化参数
|
||||
*/
|
||||
|
@ -81,10 +77,25 @@ public abstract class AbstractSpectrumHandler extends AbstractChain {
|
|||
/**
|
||||
* 初始化参数
|
||||
*/
|
||||
protected void initNext(SpectrumServiceQuotes spectrumServiceQuotes,File spectrumFile,DataType currDataType,
|
||||
public void init(File phdFile,SpectrumServiceQuotes spectrumServiceQuotes,StringBuilder returnFileName,Integer spectrumSource) throws Exception{
|
||||
this.spectrumServiceQuotes = spectrumServiceQuotes;
|
||||
this.returnFileName = returnFileName;
|
||||
this.spectrumSource = spectrumSource;
|
||||
this.spectrumFile = phdFile;
|
||||
this.mailContent = FileUtils.readFileToString(spectrumFile,"UTF-8");
|
||||
this.sourceFilePath = spectrumFile.getAbsolutePath();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化参数
|
||||
*/
|
||||
protected void initNext(SpectrumServiceQuotes spectrumServiceQuotes,File spectrumFile,
|
||||
String sourceFilePath,DataType currDataType,
|
||||
String mailContent,Integer spectrumSource,StringBuilder returnFileName){
|
||||
this.spectrumServiceQuotes = spectrumServiceQuotes;
|
||||
this.spectrumFile = spectrumFile;
|
||||
this.sourceFilePath = sourceFilePath;
|
||||
this.currDataType = currDataType;
|
||||
this.mailContent = mailContent;
|
||||
this.spectrumSource = spectrumSource;
|
||||
|
@ -166,12 +177,15 @@ public abstract class AbstractSpectrumHandler extends AbstractChain {
|
|||
for(DataType value : values){
|
||||
// 判断能谱数据类型是否正确
|
||||
if(this.mailContent.contains(DATA_TYPE_PREFIX + value.getType())){
|
||||
StringBuilder localPath = new StringBuilder();
|
||||
localPath.append(this.spectrumServiceQuotes.getTaskProperties().getTemporaryStoragePath());
|
||||
localPath.append(File.separator);
|
||||
localPath.append(UUID.randomUUID());
|
||||
localPath.append(value.getSuffix());
|
||||
this.spectrumFile = FileUtil.writeString(this.mailContent, localPath.toString(), "UTF-8");
|
||||
if(SpectrumSource.FORM_EMAIL_SERVICE.getSourceType().equals(spectrumSource)){
|
||||
StringBuilder localPath = new StringBuilder();
|
||||
localPath.append(this.spectrumServiceQuotes.getTaskProperties().getTemporaryStoragePath());
|
||||
localPath.append(File.separator);
|
||||
localPath.append(UUID.randomUUID());
|
||||
localPath.append(value.getSuffix());
|
||||
this.spectrumFile = FileUtil.writeString(this.mailContent, localPath.toString(), "UTF-8");
|
||||
this.sourceFilePath = spectrumFile.getAbsolutePath();
|
||||
}
|
||||
// 能谱数据类型如果是 SPHDP 或者 SPHDF 统一改为 SAMPLEPHD
|
||||
if (value.equals(DataType.SPHDP) || value.equals(DataType.SPHDF)) {
|
||||
this.currDataType = DataType.SAMPLEPHD;
|
||||
|
|
|
@ -48,7 +48,7 @@ public class AlertSpectrum extends AbstractSpectrumHandler{
|
|||
@Override
|
||||
protected void setChina() {
|
||||
AbstractSpectrumHandler spectrumHandler = new HealthStatusSpectrum();
|
||||
spectrumHandler.initNext(super.spectrumServiceQuotes,super.spectrumFile,
|
||||
spectrumHandler.initNext(super.spectrumServiceQuotes,super.spectrumFile,super.sourceFilePath,
|
||||
super.currDataType,super.mailContent,super.spectrumSource,super.returnFileName);
|
||||
spectrumHandler.setPrevious(this);
|
||||
super.setNext(spectrumHandler);
|
||||
|
|
|
@ -15,7 +15,7 @@ public class DetbkphdSpectrum extends AbstractS_D_Q_G_SpectrumHandler {
|
|||
@Override
|
||||
protected void setChina() {
|
||||
AbstractSpectrumHandler spectrumHandler = new QcphdSpectrum();
|
||||
spectrumHandler.initNext(super.spectrumServiceQuotes,super.spectrumFile,
|
||||
spectrumHandler.initNext(super.spectrumServiceQuotes,super.spectrumFile,super.sourceFilePath,
|
||||
super.currDataType,super.mailContent,super.spectrumSource,super.returnFileName);
|
||||
spectrumHandler.setPrevious(this);
|
||||
super.setNext(spectrumHandler);
|
||||
|
|
|
@ -17,7 +17,7 @@ public class GasbkphdSpectrum extends AbstractS_D_Q_G_SpectrumHandler {
|
|||
@Override
|
||||
protected void setChina() {
|
||||
AbstractSpectrumHandler spectrumHandler = new MetSpectrum();
|
||||
spectrumHandler.initNext(super.spectrumServiceQuotes,super.spectrumFile,
|
||||
spectrumHandler.initNext(super.spectrumServiceQuotes,super.spectrumFile,super.sourceFilePath,
|
||||
super.currDataType,super.mailContent,super.spectrumSource,super.returnFileName);
|
||||
spectrumHandler.setPrevious(this);
|
||||
super.setNext(spectrumHandler);
|
||||
|
|
|
@ -43,7 +43,7 @@ public class MetSpectrum extends AbstractSpectrumHandler{
|
|||
@Override
|
||||
protected void setChina() {
|
||||
AbstractSpectrumHandler spectrumHandler = new AlertSpectrum();
|
||||
spectrumHandler.initNext(super.spectrumServiceQuotes,super.spectrumFile,
|
||||
spectrumHandler.initNext(super.spectrumServiceQuotes,super.spectrumFile,super.sourceFilePath,
|
||||
super.currDataType,super.mailContent,super.spectrumSource,super.returnFileName);
|
||||
spectrumHandler.setPrevious(this);
|
||||
super.setNext(spectrumHandler);
|
||||
|
|
|
@ -94,14 +94,13 @@ public class ParsingProcessLog extends AbstractAutoLogOrReport{
|
|||
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 sourceFile = spectrumHandler.spectrumServiceQuotes.getTaskProperties().getTemporaryStoragePath()+File.separator+spectrumHandler.spectrumFile.getName();
|
||||
storageLog.append(titleFormat(WRITE_INTO_START,26, StringConstant.DASH,startIntoDatabaseTime,StringConstant.DASH));
|
||||
storageLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
storageLog.append(rowFormat(APPLICATION_PATH,spectrumHandler.getProjectAbsolutePath(),spectrumHandler.getProjectName(),startIntoDatabaseTime));
|
||||
storageLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
storageLog.append(rowFormat(DATABASE_CONNECTED,oraUrl.substring(oraUrl.lastIndexOf(":")+1),oraUsername));
|
||||
storageLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
storageLog.append(rowFormat(SOURCE_FILE,sourceFile));
|
||||
storageLog.append(rowFormat(SOURCE_FILE,spectrumHandler.sourceFilePath));
|
||||
storageLog.append(System.lineSeparator());
|
||||
storageLog.append(rowFormat(STANDARD_FILE,spectrumHandler.spectrumFile.getAbsolutePath()));
|
||||
storageLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
|
|
|
@ -15,7 +15,7 @@ public class QcphdSpectrum extends AbstractS_D_Q_G_SpectrumHandler {
|
|||
@Override
|
||||
protected void setChina() {
|
||||
AbstractSpectrumHandler spectrumHandler = new GasbkphdSpectrum();
|
||||
spectrumHandler.initNext(super.spectrumServiceQuotes,super.spectrumFile,
|
||||
spectrumHandler.initNext(super.spectrumServiceQuotes,super.spectrumFile,super.sourceFilePath,
|
||||
super.currDataType,super.mailContent,super.spectrumSource,super.returnFileName);
|
||||
spectrumHandler.setPrevious(this);
|
||||
super.setNext(spectrumHandler);
|
||||
|
|
|
@ -16,7 +16,7 @@ public class SamplephdSpectrum extends AbstractS_D_Q_G_SpectrumHandler {
|
|||
@Override
|
||||
protected void setChina() {
|
||||
AbstractSpectrumHandler spectrumHandler = new DetbkphdSpectrum();
|
||||
spectrumHandler.initNext(super.spectrumServiceQuotes,super.spectrumFile,
|
||||
spectrumHandler.initNext(super.spectrumServiceQuotes,super.spectrumFile,super.sourceFilePath,
|
||||
super.currDataType,super.mailContent,super.spectrumSource,super.returnFileName);
|
||||
spectrumHandler.setPrevious(this);
|
||||
super.setNext(spectrumHandler);
|
||||
|
|
|
@ -80,7 +80,7 @@ public class JeecgAutoProcessApplication extends SpringBootServletInitializer im
|
|||
EmailLogManager.init(spectrumPathProperties);
|
||||
//校验存储目录是否存在,不存在则创建,存在无操作
|
||||
checkStorageDirectory();
|
||||
autoProcessManager.start(systemStartupTime);
|
||||
// autoProcessManager.start(systemStartupTime);
|
||||
undealHandleManager.start();
|
||||
fileSourceHandleManager.start();
|
||||
// 删除过期的文件
|
||||
|
|
Loading…
Reference in New Issue
Block a user