Merge remote-tracking branch 'origin/mdc' into mdc
This commit is contained in:
commit
fdd3838e9b
|
@ -0,0 +1,9 @@
|
|||
package org.jeecg.modules.exception;
|
||||
|
||||
public class AnalySpectrumException extends AnalyseException {
|
||||
|
||||
public AnalySpectrumException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
|
@ -17,6 +17,7 @@ import org.jeecg.modules.eneity.event.SpectrumErrorEvent;
|
|||
import org.jeecg.modules.eneity.event.SpectrumLog;
|
||||
import org.jeecg.modules.enums.ErrorType;
|
||||
import org.jeecg.modules.enums.SpectrumSource;
|
||||
import org.jeecg.modules.exception.AnalySpectrumException;
|
||||
import org.jeecg.modules.exception.AnalyseException;
|
||||
import org.jeecg.modules.exception.FileRepeatException;
|
||||
import org.jeecg.modules.exception.HeaderBlockException;
|
||||
|
@ -268,7 +269,7 @@ public abstract class AbstractSpectrumHandler extends AbstractChain {
|
|||
protected void handleParseingFailFile(Exception e) throws FileNotFoundException {
|
||||
if(!SpectrumSource.FORM_FILE_UNDEL.getSourceType().equals(spectrumSource) && !(e instanceof FileRepeatException)){
|
||||
try {
|
||||
if (isDateFormatErr) {
|
||||
if (isDateFormatErr || (e instanceof AnalySpectrumException)) {
|
||||
//修改能谱文件名称
|
||||
this.updateErrorSpectrumFileName();
|
||||
//解析失败会把文件移动到errorfile目录
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.jeecg.modules.config.datasource.DataSourceSwitcher;
|
|||
import org.jeecg.modules.eneity.event.SpectrumErrorEvent;
|
||||
import org.jeecg.modules.entity.vo.*;
|
||||
import org.jeecg.modules.enums.ErrorType;
|
||||
import org.jeecg.modules.exception.AnalySpectrumException;
|
||||
import org.jeecg.modules.exception.GAnalyseException;
|
||||
import org.jeecg.modules.file.FileOperation;
|
||||
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
|
||||
|
@ -130,7 +131,7 @@ public class Sample_G_Analysis {
|
|||
sampleData.getInputFileName().lastIndexOf((StringConstant.SLASH))+1);
|
||||
}
|
||||
|
||||
public void analysis() throws GAnalyseException{
|
||||
public void analysis() throws GAnalyseException, AnalySpectrumException{
|
||||
log.info("Gamma自动处理分析--Start");
|
||||
PHDFile phdFile = new PHDFile();
|
||||
try {
|
||||
|
@ -174,30 +175,37 @@ public class Sample_G_Analysis {
|
|||
//读取参数内容
|
||||
readMDCParameter(phdFile);
|
||||
// 执行分析业务代码
|
||||
gammaFileUtil.GetMiddleData(phdFile, CommonConstant.REPORT_PREFIX_AUTO, nuclideLibs, middleData, MiddleDataType.Auto.getType(), "");
|
||||
boolean analyFlag = gammaFileUtil.GetMiddleData(phdFile, CommonConstant.REPORT_PREFIX_AUTO, nuclideLibs, middleData, MiddleDataType.Auto.getType(), "");
|
||||
|
||||
// 数据插入数据库
|
||||
this.storageDataToDatabase(phdFile, middleData, phdFile.getQcItems());
|
||||
if (analyFlag) {
|
||||
// 数据插入数据库
|
||||
this.storageDataToDatabase(phdFile, middleData, phdFile.getQcItems());
|
||||
|
||||
// 生成日志文件
|
||||
writeLog(middleData.getAnalyses_LogPath(), middleData);
|
||||
// 生成日志文件
|
||||
writeLog(middleData.getAnalyses_LogPath(), middleData);
|
||||
|
||||
// 生成报告文件
|
||||
String reportContent = gammaFileUtil.GetReportContent(middleData);
|
||||
String reportPath = StringUtils.substringBeforeLast(middleData.getAnalyses_ReportPath(), StringPool.SLASH);
|
||||
String reportName = StringUtils.substringAfterLast(middleData.getAnalyses_ReportPath(), StringPool.SLASH) + ".txt";
|
||||
String savePath = spectrumPathProperties.getRootPath() + spectrumPathProperties.getSaveFilePath() + File.separator + reportPath +
|
||||
File.separator + reportName;
|
||||
// 保存文件
|
||||
FileOperation.saveOrAppendFile(savePath, reportContent, false);
|
||||
//发送数据到redis
|
||||
middleData.setSample_id(String.valueOf(sampleId));
|
||||
pushToRedis(middleData);
|
||||
}catch (Exception e){
|
||||
// 生成报告文件
|
||||
String reportContent = gammaFileUtil.GetReportContent(middleData);
|
||||
String reportPath = StringUtils.substringBeforeLast(middleData.getAnalyses_ReportPath(), StringPool.SLASH);
|
||||
String reportName = StringUtils.substringAfterLast(middleData.getAnalyses_ReportPath(), StringPool.SLASH) + ".txt";
|
||||
String savePath = spectrumPathProperties.getRootPath() + spectrumPathProperties.getSaveFilePath() + File.separator + reportPath +
|
||||
File.separator + reportName;
|
||||
// 保存文件
|
||||
FileOperation.saveOrAppendFile(savePath, reportContent, false);
|
||||
//发送数据到redis
|
||||
middleData.setSample_id(String.valueOf(sampleId));
|
||||
pushToRedis(middleData);
|
||||
} else {
|
||||
ErrorLogManager.getInstance().write(new SpectrumErrorEvent(new Date(), phdFile.getAnalyMessage(), this.sampleFilename));
|
||||
throw new AnalySpectrumException(phdFile.getAnalyMessage());
|
||||
}
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("Sample_G_Analysis", e);
|
||||
if (e instanceof DuplicateKeyException) {
|
||||
throw new GAnalyseException("Sample Analyse Error at "+DateUtils.formatDate(new Date(),"yyyy-MM-dd HH:mm:ss"), true);
|
||||
} else if (e instanceof AnalySpectrumException) {
|
||||
throw new AnalySpectrumException(e.getMessage());
|
||||
} else {
|
||||
throw new GAnalyseException("Sample Analyse Error at "+DateUtils.formatDate(new Date(),"yyyy-MM-dd HH:mm:ss"));
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import org.jeecg.modules.base.enums.SystemType;
|
|||
import org.jeecg.modules.eneity.event.SpectrumErrorEvent;
|
||||
import org.jeecg.modules.enums.ErrorType;
|
||||
import org.jeecg.modules.enums.SpectrumSource;
|
||||
import org.jeecg.modules.exception.AnalySpectrumException;
|
||||
import org.jeecg.modules.exception.AnalyseException;
|
||||
import org.jeecg.modules.exception.GAnalyseException;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.jeecg.common.exception.DownloadEmailException;
|
|||
import org.jeecg.common.util.DateUtils;
|
||||
import org.jeecg.modules.email.EmailProperties;
|
||||
import org.jeecg.modules.enums.SpectrumSource;
|
||||
import org.jeecg.modules.exception.AnalySpectrumException;
|
||||
import org.jeecg.modules.file.FileOperation;
|
||||
|
||||
import javax.mail.Message;
|
||||
|
@ -119,8 +120,23 @@ public class SpectrumParsingActuator implements Runnable{
|
|||
spectrumHandler.init(mailContent.toString(),emlFile.getName(),spectrumServiceQuotes,new StringBuilder(),SpectrumSource.FORM_EMAIL_SERVICE.getSourceType(),batchesCounter);
|
||||
final boolean matchResult = spectrumHandler.saveEmailToLocal();
|
||||
if(matchResult){
|
||||
//开始解析
|
||||
spectrumHandler.handler();
|
||||
try {
|
||||
//开始解析
|
||||
spectrumHandler.handler();
|
||||
} catch (Exception e) {
|
||||
//如果是gamma谱的分析异常
|
||||
if (e instanceof AnalySpectrumException) {
|
||||
// 如果邮件内容校验失败(邮件内容不完整) 将错误邮件从eml移动到emlError
|
||||
if (Objects.nonNull(emlFile) && emlFile.exists()){
|
||||
moveEmail(emlFile, key);
|
||||
}
|
||||
//删除邮件
|
||||
emailServiceManager.removeMail(message,batchesCounter);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
log.warn("This email {} parsing failed and is not listed in the Met, Alert, SOH, Sample, Detbkphd, QC, Gasbkphd spectra.",subject);
|
||||
}
|
||||
|
@ -128,12 +144,7 @@ public class SpectrumParsingActuator implements Runnable{
|
|||
}else {
|
||||
// 如果邮件内容校验失败(邮件内容不完整) 将错误邮件从eml移动到emlError
|
||||
if (Objects.nonNull(emlFile) && emlFile.exists()){
|
||||
final String rootPath = spectrumServiceQuotes.getSpectrumPathProperties().getRootPath();
|
||||
final String emlErrorPath = spectrumServiceQuotes.getSpectrumPathProperties().getEmlErrorPath();
|
||||
final String finalPath = rootPath+emlErrorPath;
|
||||
FileOperation.moveFile(emlFile,finalPath,true);
|
||||
// 删除 key,防止下次线程执行删除邮件
|
||||
spectrumServiceQuotes.getRedisUtil().del(key);
|
||||
moveEmail(emlFile, key);
|
||||
throw new DownloadEmailException("邮件移走后手动抛出DownloadEmailException");
|
||||
}
|
||||
}
|
||||
|
@ -187,4 +198,13 @@ public class SpectrumParsingActuator implements Runnable{
|
|||
return false;
|
||||
}
|
||||
|
||||
private void moveEmail(File emlFile, String key) throws IOException {
|
||||
final String rootPath = spectrumServiceQuotes.getSpectrumPathProperties().getRootPath();
|
||||
final String emlErrorPath = spectrumServiceQuotes.getSpectrumPathProperties().getEmlErrorPath();
|
||||
final String finalPath = rootPath+emlErrorPath;
|
||||
FileOperation.moveFile(emlFile,finalPath,true);
|
||||
// 删除 key,防止下次线程执行删除邮件
|
||||
spectrumServiceQuotes.getRedisUtil().del(key);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user