Merge remote-tracking branch 'origin/mdc' into mdc
This commit is contained in:
commit
f31f163d5c
|
@ -115,7 +115,12 @@ public class EmailServiceManager {
|
|||
properties.put("mail.store.protocol", "imap");
|
||||
properties.put("mail.imap.host", email.getEmailServerAddress());
|
||||
properties.put("mail.imap.port",email.getPort());
|
||||
properties.put("mail.imap.ssl.enable", "true");
|
||||
if (email.getIsQiye() == 1) {
|
||||
properties.put("mail.imap.ssl.enable", "true");
|
||||
} else {
|
||||
properties.put("mail.imap.ssl.enable", "false");
|
||||
}
|
||||
|
||||
//获取邮件回话
|
||||
final Session session = Session.getDefaultInstance(properties);
|
||||
|
||||
|
@ -492,7 +497,7 @@ public class EmailServiceManager {
|
|||
* 格式为:发件人_主题_年月日_时分秒毫秒_计数(0-10000)
|
||||
* 当计数大于10000后从0开始,服务重启后也从0开始
|
||||
*/
|
||||
public void downloadEmailToEmlDir(@NotNull Message message,Integer emailCounter) throws MessagingException, IOException {
|
||||
public File downloadEmailToEmlDir(@NotNull Message message,Integer emailCounter) throws MessagingException, IOException {
|
||||
String subject = "";
|
||||
File emlFile = null;
|
||||
String status = EmailLogManager.STATUS_SUCCESS;
|
||||
|
@ -534,6 +539,8 @@ public class EmailServiceManager {
|
|||
(Objects.isNull(emlFile)?" ":emlFile.getAbsolutePath()));
|
||||
EmailLogManager.getInstance().offer(Thread.currentThread().getId(),event);
|
||||
}
|
||||
|
||||
return emlFile;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -335,7 +335,11 @@ public class MyLogFormatUtil {
|
|||
public static List<String> getValuePoint(List<String> source, int num) {
|
||||
List<String> result = Lists.newLinkedList();
|
||||
for (String str : source) {
|
||||
result.add(String.format("%." + num + "f", Double.parseDouble(str)));
|
||||
if (StringUtils.isNotBlank(str)) {
|
||||
result.add(String.format("%." + num + "f", Double.parseDouble(str)));
|
||||
} else {
|
||||
result.add("null");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ public class AutoProcessManager{
|
|||
/**
|
||||
* 以邮件id为key,以邮件执行线程为value
|
||||
*/
|
||||
private Map<String,Thread> emailExecThreadMap = new HashMap<>();
|
||||
private Map<String,EmailParsingActuator> emailExecThreadMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 启动自动处理
|
||||
|
@ -79,12 +79,17 @@ public class AutoProcessManager{
|
|||
EmailProperties next = iterator.next();
|
||||
if(next.isDelFlag()){
|
||||
if(emailExecThreadMap.containsKey(next.getId())){
|
||||
Thread thread = emailExecThreadMap.get(next.getId());
|
||||
thread.interrupt();
|
||||
EmailParsingActuator actuator = emailExecThreadMap.get(next.getId());
|
||||
actuator.setStop(true);
|
||||
emailExecThreadMap.remove(next.getId());
|
||||
}
|
||||
iterator.remove();
|
||||
}
|
||||
if (next.isResetFlag()) {
|
||||
EmailParsingActuator actuator = emailExecThreadMap.get(next.getId());
|
||||
actuator.updateEmail(next);
|
||||
next.setResetFlag(false);
|
||||
}
|
||||
if(next.isNewEmailFlag()){
|
||||
EmailParsingActuator emailParsingActuator = new EmailParsingActuator();
|
||||
emailParsingActuator.init(next,spectrumServiceQuotes,emailCounter,systemStartupTime);
|
||||
|
@ -176,11 +181,25 @@ public class AutoProcessManager{
|
|||
//如果库里已有数据原来已开启使用并且监测Map中已存在,现在关闭使用则添加删除标记
|
||||
//如果本次查询数据监测Map中不存在,并且已开启使用的则加入监测Map
|
||||
for(EmailProperties email : receiveMails){
|
||||
//判断map里是否包含邮箱id
|
||||
final boolean flag = emailMap.containsKey(email.getId());
|
||||
//如果包含邮箱id 并且 邮箱处于未启用的状态 将邮箱的删除标识设置为true
|
||||
if(flag && email.getEnabled().equals(SysMailEnableType.NOT_ENABLE.getMailEnableType())){
|
||||
EmailProperties sourceEmail = emailMap.get(email.getId());
|
||||
sourceEmail.setDelFlag(true);
|
||||
}
|
||||
//如果包含邮箱id 并且 邮箱处于启用状态 将邮箱数据进行更新
|
||||
if (flag && email.getEnabled().equals(SysMailEnableType.ENABLE.getMailEnableType())) {
|
||||
EmailProperties properties = emailMap.get(email.getId());
|
||||
//判断邮箱的用户名,密码是否与原邮箱用户名,密码一致
|
||||
//如果不一致则进行更新
|
||||
if ( !properties.getUsername().equals(email.getUsername()) || !properties.getPassword().equals(email.getPassword()) ) {
|
||||
email.setResetFlag(true);
|
||||
putSysEmailMap(email);
|
||||
log.info("{}邮箱加入监测队列",email.getEmailServerAddress());
|
||||
}
|
||||
}
|
||||
//如果不包含邮箱id 并且 邮箱处于启用状态 将邮箱对象存入到map中 并将新邮箱标识设置为true
|
||||
if(!flag && email.getEnabled().equals(SysMailEnableType.ENABLE.getMailEnableType())){
|
||||
email.setNewEmailFlag(true);
|
||||
putSysEmailMap(email);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.jeecg.modules;
|
||||
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.jeecg.common.email.EmailLogManager;
|
||||
import org.jeecg.common.email.EmailServiceManager;
|
||||
|
@ -26,6 +27,8 @@ public class EmailParsingActuator extends Thread{
|
|||
private SpectrumServiceQuotes spectrumServiceQuotes;
|
||||
private EmailCounter emailCounter;
|
||||
private Date systemStartupTime;
|
||||
@Setter
|
||||
private boolean isStop;
|
||||
|
||||
public void init(EmailProperties emailProperties,SpectrumServiceQuotes spectrumServiceQuotes,
|
||||
EmailCounter emailCounter,Date systemStartupTime){
|
||||
|
@ -44,9 +47,17 @@ public class EmailParsingActuator extends Thread{
|
|||
poolExecutor = new ThreadPoolExecutor(taskProperties.getReceiveNum(),maximumPoolSize,5, TimeUnit.SECONDS, new LinkedBlockingQueue<>(),threadFactory);
|
||||
}
|
||||
|
||||
public void updateEmail(EmailProperties emailProperties) {
|
||||
this.emailProperties = emailProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for(;;){
|
||||
if (isStop) {
|
||||
System.out.println("EmailParsingActuator is Stop!");
|
||||
return;
|
||||
}
|
||||
long start = System.currentTimeMillis();
|
||||
final EmailServiceManager emailServiceManager = EmailServiceManager.getInstance();
|
||||
emailServiceManager.init(this.emailProperties,this.taskProperties.getReceiveNum(),this.taskProperties.getTemporaryStoragePath(),this.systemStartupTime, spectrumServiceQuotes.getSpectrumPathProperties());
|
||||
|
@ -87,4 +98,6 @@ public class EmailParsingActuator extends Thread{
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
package org.jeecg.modules;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import org.jeecg.common.constant.StringConstant;
|
||||
import org.jeecg.common.properties.SpectrumPathProperties;
|
||||
import org.jeecg.modules.eneity.event.SpectrumErrorEvent;
|
||||
import org.jeecg.modules.enums.ErrorEventType;
|
||||
import org.jeecg.modules.enums.ErrorType;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* 邮件过程日志
|
||||
*/
|
||||
public class ErrorLogManager {
|
||||
|
||||
private final static String ERROR_PREFIX = "Data Anlyse Error:";
|
||||
|
||||
private final static String SUFFIX = ".log";
|
||||
|
||||
private SpectrumPathProperties spectrumPathProperties;
|
||||
|
||||
private static ErrorLogManager errorLogManager = null;
|
||||
|
||||
public static ErrorLogManager getInstance(){
|
||||
return errorLogManager;
|
||||
}
|
||||
|
||||
public ErrorLogManager(SpectrumPathProperties spectrumPathProperties) {
|
||||
this.spectrumPathProperties = spectrumPathProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
* @param spectrumPathProperties
|
||||
*/
|
||||
public static void init(SpectrumPathProperties spectrumPathProperties){
|
||||
errorLogManager = new ErrorLogManager(spectrumPathProperties);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 把日志写入文件
|
||||
*/
|
||||
public void write(SpectrumErrorEvent event){
|
||||
//错误内容
|
||||
String errorContent = "";
|
||||
//文件名称
|
||||
String fileName = "";
|
||||
if(event.getEventType() == ErrorEventType.STATIC_EVENT.getEventType()){
|
||||
//台站找不到,格式化报错信息
|
||||
if(event.getErrorType().equals(ErrorType.STATION_ERROR)){
|
||||
errorContent = String.format(ErrorType.STATION_ERROR.getContent(),event.getFormatArgs());
|
||||
}else{
|
||||
errorContent = event.getErrorType().getContent();
|
||||
}
|
||||
//header、acquisition、ariSamplerFlow错误使用mesg_id生成文件名称
|
||||
if(event.getErrorType().equals(ErrorType.HEADER_ERROR) || event.getErrorType().equals(ErrorType.ACQUISITION_ERROR) ||
|
||||
event.getErrorType().equals(ErrorType.AIR_SAMPLER_FLOW_ERROR)){
|
||||
//第一个参数就是msg_id
|
||||
fileName = event.getFormatArgs()[0]+SUFFIX;
|
||||
}else{
|
||||
fileName = event.getFileName().substring(0,event.getFileName().lastIndexOf(StringConstant.DOT))+SUFFIX;
|
||||
}
|
||||
}else if(event.getEventType() == ErrorEventType.DYNAMIC_EVENT.getEventType()){
|
||||
errorContent = event.getDynamicErrorContent();
|
||||
fileName = event.getFileName().substring(0,event.getFileName().lastIndexOf(StringConstant.DOT))+SUFFIX;
|
||||
}
|
||||
|
||||
|
||||
StringBuilder logFilePath = new StringBuilder();
|
||||
logFilePath.append(spectrumPathProperties.getRootPath());
|
||||
logFilePath.append(File.separator);
|
||||
logFilePath.append(spectrumPathProperties.getLogPath());
|
||||
logFilePath.append(File.separator);
|
||||
logFilePath.append("error");
|
||||
logFilePath.append(File.separator);
|
||||
logFilePath.append(fileName);
|
||||
|
||||
StringBuilder finalErrorContent = new StringBuilder();
|
||||
finalErrorContent.append(DateUtil.format(event.getTime(),"yyyy-MM-dd HH:mm:ss"));
|
||||
finalErrorContent.append(StringConstant.SPACE);
|
||||
finalErrorContent.append(ERROR_PREFIX);
|
||||
finalErrorContent.append(errorContent);
|
||||
finalErrorContent.append(System.lineSeparator());
|
||||
FileUtil.appendString(finalErrorContent.toString(),logFilePath.toString(),"UTF-8");
|
||||
}
|
||||
|
||||
}
|
|
@ -23,4 +23,9 @@ public class EmailProperties extends SysEmail {
|
|||
*/
|
||||
private boolean delFlag;
|
||||
|
||||
/**
|
||||
* 邮箱是否需要进行更新
|
||||
*/
|
||||
private boolean resetFlag;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
package org.jeecg.modules.eneity.event;
|
||||
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.jeecg.modules.enums.ErrorEventType;
|
||||
import org.jeecg.modules.enums.ErrorType;
|
||||
import java.util.Date;
|
||||
|
||||
public class SpectrumErrorEvent {
|
||||
|
||||
/**
|
||||
* 事件类型
|
||||
* 0:静态枚举(默认),1:动态内容
|
||||
*/
|
||||
@Setter @Getter
|
||||
private int eventType;
|
||||
|
||||
@Setter @Getter
|
||||
private Date time;
|
||||
|
||||
/**
|
||||
* eventType 为0时内容为静态枚举类型
|
||||
*/
|
||||
@Setter @Getter
|
||||
private ErrorType errorType;
|
||||
|
||||
/**
|
||||
* eventType 为1时内容为动态传入内容
|
||||
*/
|
||||
@Setter @Getter
|
||||
private String dynamicErrorContent;
|
||||
|
||||
@Setter @Getter
|
||||
private String fileName;
|
||||
|
||||
@Setter @Getter
|
||||
private String[] formatArgs;
|
||||
|
||||
public SpectrumErrorEvent() {}
|
||||
|
||||
public SpectrumErrorEvent(Date time,String dynamicErrorContent,String fileName) {
|
||||
this.time = time;
|
||||
this.dynamicErrorContent = dynamicErrorContent;
|
||||
this.fileName = fileName;
|
||||
this.setEventType(ErrorEventType.DYNAMIC_EVENT.getEventType());
|
||||
}
|
||||
|
||||
public SpectrumErrorEvent(Date time,ErrorType errorType,String fileName) {
|
||||
this.time = time;
|
||||
this.errorType = errorType;
|
||||
this.fileName = fileName;
|
||||
this.setEventType(ErrorEventType.STATIC_EVENT.getEventType());
|
||||
}
|
||||
|
||||
public SpectrumErrorEvent(Date time,ErrorType errorType,String fileName,String... formatArgs) {
|
||||
this.time = time;
|
||||
this.errorType = errorType;
|
||||
this.fileName = fileName;
|
||||
this.formatArgs = formatArgs;
|
||||
this.setEventType(ErrorEventType.STATIC_EVENT.getEventType());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package org.jeecg.modules.enums;
|
||||
|
||||
/**
|
||||
* 错误事件类型
|
||||
*/
|
||||
public enum ErrorEventType {
|
||||
|
||||
/**
|
||||
* 静态错误事件header、acq等
|
||||
*/
|
||||
STATIC_EVENT(0),
|
||||
/**
|
||||
* 动态错误事件,手动传入
|
||||
*/
|
||||
DYNAMIC_EVENT(1);
|
||||
|
||||
private int eventType;
|
||||
|
||||
ErrorEventType(int eventType) {
|
||||
this.eventType = eventType;
|
||||
}
|
||||
|
||||
public int getEventType(){
|
||||
return this.eventType;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package org.jeecg.modules.enums;
|
||||
|
||||
public enum ErrorType {
|
||||
|
||||
HEADER_ERROR("this is no header data"),
|
||||
ACQUISITION_ERROR("this is no acquisition data"),
|
||||
STATION_ERROR("station_code:%s=0"),
|
||||
FILE_REPEAT("file repeat"),
|
||||
GAS_OR_DET_ERROR("gas or det file is no exist or is error"),
|
||||
AIR_SAMPLER_FLOW_ERROR("this is no ariSamplerFlow data");
|
||||
|
||||
private String content;
|
||||
|
||||
ErrorType(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getContent(){
|
||||
return this.content;
|
||||
}
|
||||
|
||||
}
|
|
@ -8,11 +8,15 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.jeecg.common.constant.StringConstant;
|
||||
import org.jeecg.common.properties.SpectrumPathProperties;
|
||||
import org.jeecg.common.properties.TaskProperties;
|
||||
import org.jeecg.modules.ErrorLogManager;
|
||||
import org.jeecg.modules.base.entity.configuration.GardsStations;
|
||||
import org.jeecg.modules.eneity.event.SpectrumErrorEvent;
|
||||
import org.jeecg.modules.enums.ErrorType;
|
||||
import org.jeecg.modules.exception.StationNotFoundException;
|
||||
import org.jeecg.modules.mapper.GardsStationsMapper;
|
||||
import org.jeecg.modules.service.GardsStationsService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
@Slf4j
|
||||
|
@ -37,13 +41,9 @@ public class GardsStationsServiceImpl extends ServiceImpl<GardsStationsMapper, G
|
|||
gardsStationsQuery.eq(GardsStations::getStationCode,site_code);
|
||||
final GardsStations station = this.baseMapper.selectOne(gardsStationsQuery);
|
||||
if (Objects.isNull(station)) {
|
||||
StringBuilder logContent = new StringBuilder();
|
||||
logContent.append("station_code:"+site_code+"=0");
|
||||
logContent.append(StringConstant.SPACE);
|
||||
logContent.append(taskProperties.getUndealFileTimeOut());
|
||||
|
||||
String errorFileName = fileName.substring(fileName.lastIndexOf("/"));
|
||||
ErrorLogManager.getInstance().write(new SpectrumErrorEvent(new Date(),ErrorType.STATION_ERROR,errorFileName,site_code));
|
||||
log.error("This station does not exist, the number is {}.",site_code);
|
||||
// LogFileUtil.errorLog(spectrumServiceQuotes.getSpectrumPathProperties().getRootPath() + File.separator + spectrumServiceQuotes.getSpectrumPathProperties().getLogPath(), finalFileName.toString(), warning);
|
||||
throw new StationNotFoundException("This station does not exist, the number is "+site_code+".");
|
||||
}
|
||||
return station;
|
||||
|
|
|
@ -31,7 +31,7 @@ public class SysMailServiceImpl extends ServiceImpl<SysMailMapper, SysEmail> imp
|
|||
public List<EmailProperties> findReceiveMails() {
|
||||
LambdaQueryWrapper<SysEmail> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysEmail::getEmilType, SysMailType.RECEIVE_EMAIL.getEmailType());
|
||||
queryWrapper.eq(SysEmail::getEnabled, SysMailEnableType.ENABLE.getMailEnableType());
|
||||
// queryWrapper.eq(SysEmail::getEnabled, SysMailEnableType.ENABLE.getMailEnableType());
|
||||
List<SysEmail> sysEmail = this.list(queryWrapper);
|
||||
if(!CollectionUtils.isEmpty(sysEmail)){
|
||||
List<EmailProperties> emailPropertiesList = Lists.newArrayList();
|
||||
|
|
|
@ -9,11 +9,14 @@ 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.ErrorLogManager;
|
||||
import org.jeecg.modules.base.entity.original.GardsSampleData;
|
||||
import org.jeecg.modules.base.enums.SampleStatus;
|
||||
import org.jeecg.modules.config.datasource.DataSourceSwitcher;
|
||||
import org.jeecg.modules.eneity.event.FormatErrorEvent;
|
||||
import org.jeecg.modules.eneity.event.RepeatErrorEvent;
|
||||
import org.jeecg.modules.eneity.event.SpectrumErrorEvent;
|
||||
import org.jeecg.modules.enums.ErrorType;
|
||||
import org.jeecg.modules.exception.*;
|
||||
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
|
||||
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
|
||||
|
@ -64,27 +67,18 @@ public abstract class AbstractS_D_Q_G_SpectrumHandler extends AbstractSpectrumHa
|
|||
/**
|
||||
* 前置检查
|
||||
*/
|
||||
@Override
|
||||
protected void preCheck() {
|
||||
this.checkHeaderBlock();
|
||||
super.checkHeaderBlock();
|
||||
this.checkAcquisitionBlock();
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查此邮件是否包含#Header block
|
||||
*/
|
||||
protected void checkHeaderBlock(){
|
||||
if(this.mailContent.indexOf("#Header") == -1){
|
||||
//发送格式化错误事件,后续统计报告使用
|
||||
spectrumServiceQuotes.getApplicationContext().publishEvent(new FormatErrorEvent());
|
||||
throw new HeaderBlockException("header data error");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查此邮件是否包含#Acquisition block
|
||||
*/
|
||||
protected void checkAcquisitionBlock(){
|
||||
if(this.mailContent.indexOf("#Acquisition") == -1){
|
||||
ErrorLogManager.getInstance().write(new SpectrumErrorEvent(new Date(),ErrorType.ACQUISITION_ERROR,super.spectrumFile.getName(),super.getMsgId()));
|
||||
throw new AcquisitionBlockException("acquisition data error");
|
||||
}
|
||||
}
|
||||
|
@ -175,6 +169,9 @@ public abstract class AbstractS_D_Q_G_SpectrumHandler extends AbstractSpectrumHa
|
|||
throw new FileNotFoundException(super.spectrumFile.getAbsolutePath()+" does not exist");
|
||||
}
|
||||
super.spectrumFile = FileUtil.rename(super.spectrumFile, newFileName.toString(), true);
|
||||
//设置能谱文件保存相对路径(包含文件名称)
|
||||
String fileSavePath = this.getFileSaveRelativePath();
|
||||
this.spectrumFileRelativePath = fileSavePath+File.separator+this.spectrumFile.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -230,36 +227,41 @@ public abstract class AbstractS_D_Q_G_SpectrumHandler extends AbstractSpectrumHa
|
|||
this.startIntoDatabaseTime = new Date();
|
||||
//如果数据已经存储,不在重复存储
|
||||
final GardsSampleData query = spectrumServiceQuotes.getSampleDataService().findByInputFileName(super.spectrumFileRelativePath);
|
||||
//如果数据已经存储 并且状态是 P 则判断文件重复 如果数据已经存储并且状态是 F 不进行处理
|
||||
if(Objects.nonNull(query)){
|
||||
this.sampleData = query;
|
||||
this.endIntoDatabaseTime = new Date();
|
||||
//设置文件重复标记为true
|
||||
this.parsingProcessLog.setFileRepeat(true);
|
||||
//发送文件重复错误事件,后续统计报告使用
|
||||
spectrumServiceQuotes.getApplicationContext().publishEvent(new RepeatErrorEvent());
|
||||
throw new FileRepeatException("file repeat");
|
||||
}
|
||||
DataSourceSwitcher.switchToOracle();
|
||||
final TransactionStatus transactionStatus = spectrumServiceQuotes.getTransactionManager().getTransaction(spectrumServiceQuotes.getTransactionDefinition());
|
||||
try{
|
||||
//存储基础数据
|
||||
this.sampleData = spectrumServiceQuotes.getSpectrumBaseBlockService().create(this.sourceData,super.spectrumFileRelativePath,status);
|
||||
//存储其他块数据
|
||||
for(String labels : spectrumFileLabels){
|
||||
final ISpectrumBlockService spectrumBlockService = spectrumServiceQuotes.getSpectrumBlockService().get(labels);
|
||||
if(Objects.nonNull(spectrumBlockService)){
|
||||
spectrumBlockService.create(sourceData,this.sampleData);
|
||||
}
|
||||
if (query.getStatus().equalsIgnoreCase(SampleStatus.COMPLETE.value)) {
|
||||
//设置文件重复标记为true
|
||||
this.parsingProcessLog.setFileRepeat(true);
|
||||
//发送文件重复错误事件,后续统计报告使用
|
||||
spectrumServiceQuotes.getApplicationContext().publishEvent(new RepeatErrorEvent());
|
||||
ErrorLogManager.getInstance().write(new SpectrumErrorEvent(new Date(),ErrorType.FILE_REPEAT,super.spectrumFile.getName()));
|
||||
throw new FileRepeatException("file repeat");
|
||||
}
|
||||
} else if (Objects.isNull(query)) { // 如果没有查询出对应的数据 则对数据进行存储操作
|
||||
DataSourceSwitcher.switchToOracle();
|
||||
final TransactionStatus transactionStatus = spectrumServiceQuotes.getTransactionManager().getTransaction(spectrumServiceQuotes.getTransactionDefinition());
|
||||
try{
|
||||
//存储基础数据
|
||||
this.sampleData = spectrumServiceQuotes.getSpectrumBaseBlockService().create(this.sourceData,super.spectrumFileRelativePath,status);
|
||||
//存储其他块数据
|
||||
for(String labels : spectrumFileLabels){
|
||||
final ISpectrumBlockService spectrumBlockService = spectrumServiceQuotes.getSpectrumBlockService().get(labels);
|
||||
if(Objects.nonNull(spectrumBlockService)){
|
||||
spectrumBlockService.create(sourceData,this.sampleData);
|
||||
}
|
||||
}
|
||||
//提交事务
|
||||
this.spectrumServiceQuotes.getTransactionManager().commit(transactionStatus);
|
||||
}catch (Exception e){
|
||||
//回滚事务
|
||||
spectrumServiceQuotes.getTransactionManager().rollback(transactionStatus);
|
||||
throw e;
|
||||
}finally {
|
||||
this.endIntoDatabaseTime = new Date();
|
||||
DataSourceSwitcher.clearDataSource();
|
||||
}
|
||||
//提交事务
|
||||
this.spectrumServiceQuotes.getTransactionManager().commit(transactionStatus);
|
||||
}catch (Exception e){
|
||||
//回滚事务
|
||||
spectrumServiceQuotes.getTransactionManager().rollback(transactionStatus);
|
||||
throw e;
|
||||
}finally {
|
||||
this.endIntoDatabaseTime = new Date();
|
||||
DataSourceSwitcher.clearDataSource();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,17 +4,24 @@ 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.apache.commons.lang3.ArrayUtils;
|
||||
import org.jeecg.common.email.EmailLogEvent;
|
||||
import org.jeecg.common.email.EmailLogManager;
|
||||
import org.jeecg.common.properties.SpectrumPathProperties;
|
||||
import org.jeecg.modules.ErrorLogManager;
|
||||
import org.jeecg.modules.base.enums.DataType;
|
||||
import org.jeecg.modules.eneity.event.FormatErrorEvent;
|
||||
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.FileRepeatException;
|
||||
import org.jeecg.modules.exception.HeaderBlockException;
|
||||
import org.jeecg.modules.file.FileOperation;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
@ -106,6 +113,23 @@ public abstract class AbstractSpectrumHandler extends AbstractChain {
|
|||
this.setChina();
|
||||
}
|
||||
|
||||
/**
|
||||
* 前置检查
|
||||
*/
|
||||
protected abstract void preCheck();
|
||||
|
||||
/**
|
||||
* 检查此邮件是否包含#Header block
|
||||
*/
|
||||
protected void checkHeaderBlock(){
|
||||
if(this.mailContent.indexOf("#Header") == -1){
|
||||
//发送格式化错误事件,后续统计报告使用
|
||||
spectrumServiceQuotes.getApplicationContext().publishEvent(new FormatErrorEvent());
|
||||
ErrorLogManager.getInstance().write(new SpectrumErrorEvent(new Date(), ErrorType.HEADER_ERROR,this.spectrumFile.getName(),this.getMsgId()));
|
||||
throw new HeaderBlockException("header data error");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查规则并处理数据
|
||||
*/
|
||||
|
@ -120,8 +144,6 @@ public abstract class AbstractSpectrumHandler extends AbstractChain {
|
|||
* 保存能谱文件到savefile
|
||||
*/
|
||||
protected void saveFileToSavefile() throws Exception{
|
||||
//修改能谱文件名称
|
||||
this.updateSpectrumFileName();
|
||||
//获取文件保存路径
|
||||
String fileSavePath = this.getFileSaveRelativePath();
|
||||
final SpectrumPathProperties properties = this.spectrumServiceQuotes.getSpectrumPathProperties();
|
||||
|
@ -135,8 +157,6 @@ public abstract class AbstractSpectrumHandler extends AbstractChain {
|
|||
finalPath.append(this.spectrumFile.getName());
|
||||
FileOperation.moveFile(this.spectrumFile,finalPath.toString(),true);
|
||||
this.spectrumFile = new File(finalPath.toString());
|
||||
//设置能谱文件保存相对路径(包含文件名称)
|
||||
this.spectrumFileRelativePath = fileSavePath+File.separator+this.spectrumFile.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -223,7 +243,10 @@ public abstract class AbstractSpectrumHandler extends AbstractChain {
|
|||
}
|
||||
|
||||
/**
|
||||
* 处理解析失败的文件,上传到undeal目录
|
||||
* 处理解析失败的文件
|
||||
* 1.格式错误移动到errorfile
|
||||
* 2.filerepeat错误直接删除
|
||||
* 3.非filerepeat错误移动到undel
|
||||
* @throws FileNotFoundException
|
||||
*/
|
||||
protected void handleParseingFailFile(Exception e) throws FileNotFoundException {
|
||||
|
@ -232,7 +255,7 @@ public abstract class AbstractSpectrumHandler extends AbstractChain {
|
|||
if (isDateFormatErr) {
|
||||
//修改能谱文件名称
|
||||
this.updateErrorSpectrumFileName();
|
||||
//解析失败会把文件移动到undeal目录
|
||||
//解析失败会把文件移动到errorfile目录
|
||||
final String rootPath = spectrumServiceQuotes.getSpectrumPathProperties().getRootPath();
|
||||
final String errorFilePath = spectrumServiceQuotes.getSpectrumPathProperties().getErrorFilePath();
|
||||
final String finalPath = rootPath+File.separator+errorFilePath;
|
||||
|
@ -242,11 +265,13 @@ public abstract class AbstractSpectrumHandler extends AbstractChain {
|
|||
final String rootPath = spectrumServiceQuotes.getSpectrumPathProperties().getRootPath();
|
||||
final String undealPath = spectrumServiceQuotes.getSpectrumPathProperties().getUndealPath();
|
||||
final String finalPath = rootPath+File.separator+undealPath;
|
||||
FileOperation.copyFile(spectrumFile,finalPath,true);
|
||||
FileOperation.moveFile(spectrumFile,finalPath,true);
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}else if(SpectrumSource.FROM_FILE_SOURCE.getSourceType().equals(spectrumSource) && (e instanceof FileRepeatException)){
|
||||
this.spectrumFile.delete();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -281,4 +306,20 @@ public abstract class AbstractSpectrumHandler extends AbstractChain {
|
|||
SpectrumLogManager.undelSpectrumLogManager.offer(Thread.currentThread().getId(),spectrumLog);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取MSG_ID
|
||||
* @return
|
||||
*/
|
||||
protected String getMsgId(){
|
||||
String msgIdBlockName = "MSG_ID";
|
||||
if(this.mailContent.contains(msgIdBlockName)){
|
||||
final List<String> list = FileUtil.readLines(this.spectrumFile, "UTF-8");
|
||||
final String[] msgIdBlock = list.get(2).split(" ");
|
||||
if(ArrayUtils.isNotEmpty(msgIdBlock) && msgIdBlock.length > 2){
|
||||
return msgIdBlock[1];
|
||||
}
|
||||
}
|
||||
return "default";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,10 +4,13 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.jeecg.common.constant.StringConstant;
|
||||
import org.jeecg.common.properties.SpectrumPathProperties;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.jeecg.modules.ErrorLogManager;
|
||||
import org.jeecg.modules.base.entity.original.GardsAlertData;
|
||||
import org.jeecg.modules.base.enums.DataType;
|
||||
import org.jeecg.modules.eneity.event.FormatErrorEvent;
|
||||
import org.jeecg.modules.eneity.event.RepeatErrorEvent;
|
||||
import org.jeecg.modules.eneity.event.SpectrumErrorEvent;
|
||||
import org.jeecg.modules.enums.ErrorType;
|
||||
import org.jeecg.modules.exception.FileRepeatException;
|
||||
import org.jeecg.modules.exception.PHD_ReadException;
|
||||
import org.jeecg.modules.file.FileOperation;
|
||||
|
@ -54,6 +57,13 @@ public class AlertSpectrum extends AbstractSpectrumHandler{
|
|||
super.setNext(spectrumHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* 前置检查
|
||||
*/
|
||||
@Override
|
||||
protected void preCheck() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查规则并处理数据
|
||||
*/
|
||||
|
@ -68,15 +78,20 @@ public class AlertSpectrum extends AbstractSpectrumHandler{
|
|||
super.printCurrDataType();
|
||||
//解析邮件内容
|
||||
this.parseingEmail();
|
||||
//保存PHD文件到savefile
|
||||
super.saveFileToSavefile();
|
||||
//修改能谱文件名称
|
||||
this.updateSpectrumFileName();
|
||||
//结构体数据入库
|
||||
this.handlerOriginalData();
|
||||
//保存PHD文件到savefile
|
||||
super.saveFileToSavefile();
|
||||
//若本次文件来自于undel目录,解析成功则删除
|
||||
deleteIfFromUndelFile();
|
||||
}catch (Exception e){
|
||||
//异常返回文件名称用于报错日志
|
||||
super.returnFileName.append(super.spectrumFile.getName());
|
||||
|
||||
//处理解析失败的文件
|
||||
super.handleParseingFailFile(e);
|
||||
throw e;
|
||||
}finally {
|
||||
//把流程日志保存到日志目录
|
||||
|
@ -139,6 +154,9 @@ public class AlertSpectrum extends AbstractSpectrumHandler{
|
|||
throw new FileNotFoundException(super.spectrumFile.getAbsolutePath()+" does not exist");
|
||||
}
|
||||
super.spectrumFile = FileOperation.rename(super.spectrumFile,newFileName.toString(),true);
|
||||
//设置能谱文件保存相对路径(包含文件名称)
|
||||
String fileSavePath = this.getFileSaveRelativePath();
|
||||
this.spectrumFileRelativePath = fileSavePath+File.separator+this.spectrumFile.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -173,6 +191,7 @@ public class AlertSpectrum extends AbstractSpectrumHandler{
|
|||
this.isFileRepeat = true;
|
||||
//发送文件重复错误事件,后续统计报告使用
|
||||
spectrumServiceQuotes.getApplicationContext().publishEvent(new FormatErrorEvent());
|
||||
ErrorLogManager.getInstance().write(new SpectrumErrorEvent(new Date(), ErrorType.FILE_REPEAT,super.spectrumFile.getName()));
|
||||
throw new FileRepeatException("file repeat");
|
||||
}
|
||||
this.alertData = super.spectrumServiceQuotes.getAlertSpectrumService().create(this.sourceData, super.spectrumFileRelativePath);
|
||||
|
|
|
@ -38,10 +38,12 @@ public class DetbkphdSpectrum extends AbstractS_D_Q_G_SpectrumHandler {
|
|||
super.parseingEmail();
|
||||
//读取邮件内容标签
|
||||
super.readFileLabel();
|
||||
//保存PHD文件到savefile
|
||||
super.saveFileToSavefile();
|
||||
//修改能谱文件名称
|
||||
super.updateSpectrumFileName();
|
||||
//结构体数据入库
|
||||
super.handlerOriginalData();
|
||||
//保存PHD文件到savefile
|
||||
super.saveFileToSavefile();
|
||||
//修改状态为解析完成
|
||||
super.status = SampleStatus.COMPLETE.getValue();
|
||||
super.updateStatus();
|
||||
|
@ -54,7 +56,7 @@ public class DetbkphdSpectrum extends AbstractS_D_Q_G_SpectrumHandler {
|
|||
super.status = SampleStatus.FAIL.getValue();
|
||||
super.updateStatus();
|
||||
|
||||
//处理解析失败的文件,上传到undeal目录
|
||||
//处理解析失败的文件
|
||||
super.handleParseingFailFile(e);
|
||||
throw e;
|
||||
}finally {
|
||||
|
|
|
@ -40,10 +40,12 @@ public class GasbkphdSpectrum extends AbstractS_D_Q_G_SpectrumHandler {
|
|||
super.parseingEmail();
|
||||
//读取邮件内容标签
|
||||
super.readFileLabel();
|
||||
//保存PHD文件到savefile
|
||||
super.saveFileToSavefile();
|
||||
//修改能谱文件名称
|
||||
super.updateSpectrumFileName();
|
||||
//结构体数据入库
|
||||
super.handlerOriginalData();
|
||||
//保存PHD文件到savefile
|
||||
super.saveFileToSavefile();
|
||||
//修改状态为解析完成
|
||||
super.status = SampleStatus.COMPLETE.getValue();
|
||||
super.updateStatus();
|
||||
|
@ -56,7 +58,7 @@ public class GasbkphdSpectrum extends AbstractS_D_Q_G_SpectrumHandler {
|
|||
super.status = SampleStatus.FAIL.getValue();
|
||||
super.updateStatus();
|
||||
|
||||
//处理解析失败的文件,上传到undeal目录
|
||||
//处理解析失败的文件
|
||||
super.handleParseingFailFile(e);
|
||||
throw e;
|
||||
}finally {
|
||||
|
|
|
@ -4,9 +4,12 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.jeecg.common.constant.StringConstant;
|
||||
import org.jeecg.common.properties.SpectrumPathProperties;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.jeecg.modules.ErrorLogManager;
|
||||
import org.jeecg.modules.base.entity.original.GardsSohData;
|
||||
import org.jeecg.modules.base.enums.DataType;
|
||||
import org.jeecg.modules.eneity.event.FormatErrorEvent;
|
||||
import org.jeecg.modules.eneity.event.SpectrumErrorEvent;
|
||||
import org.jeecg.modules.enums.ErrorType;
|
||||
import org.jeecg.modules.exception.AirSamplerFlowException;
|
||||
import org.jeecg.modules.exception.PHD_ReadException;
|
||||
import org.jeecg.modules.file.FileOperation;
|
||||
|
@ -46,8 +49,18 @@ public class HealthStatusSpectrum extends AbstractSpectrumHandler{
|
|||
protected void setChina() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 前置检查
|
||||
*/
|
||||
@Override
|
||||
protected void preCheck() {
|
||||
super.checkHeaderBlock();
|
||||
this.checkAirSamplerFlowBlock();
|
||||
}
|
||||
|
||||
protected void checkAirSamplerFlowBlock(){
|
||||
if(super.mailContent.indexOf("#AirSamplerFlow") == -1){
|
||||
ErrorLogManager.getInstance().write(new SpectrumErrorEvent(new Date(), ErrorType.AIR_SAMPLER_FLOW_ERROR,super.spectrumFile.getName(),super.getMsgId()));
|
||||
throw new AirSamplerFlowException("this is no ariSamplerFlow data");
|
||||
}
|
||||
}
|
||||
|
@ -59,14 +72,18 @@ public class HealthStatusSpectrum extends AbstractSpectrumHandler{
|
|||
public void handler() throws Exception {
|
||||
if(DataType.SOH.getType().equals(super.currDataType.getType())){
|
||||
try {
|
||||
//前置检查
|
||||
this.preCheck();
|
||||
//打印当前处理的能谱类型
|
||||
super.printCurrDataType();
|
||||
//解析邮件内容
|
||||
this.parseingEmail();
|
||||
//保存PHD文件到savefile
|
||||
super.saveFileToSavefile();
|
||||
//修改能谱文件名称
|
||||
this.updateSpectrumFileName();
|
||||
//结构体数据入库
|
||||
this.handlerOriginalData();
|
||||
//保存PHD文件到savefile
|
||||
super.saveFileToSavefile();
|
||||
//把流程日志保存到日志目录
|
||||
this.saveLogToLogDir();
|
||||
//若本次文件来自于undel目录,解析成功则删除
|
||||
|
@ -74,6 +91,8 @@ public class HealthStatusSpectrum extends AbstractSpectrumHandler{
|
|||
}catch (Exception e){
|
||||
//异常返回文件名称用于报错日志
|
||||
super.returnFileName.append(super.spectrumFile.getName());
|
||||
//处理解析失败的文件
|
||||
super.handleParseingFailFile(e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -134,6 +153,9 @@ public class HealthStatusSpectrum extends AbstractSpectrumHandler{
|
|||
throw new FileNotFoundException(super.spectrumFile.getAbsolutePath()+" does not exist");
|
||||
}
|
||||
super.spectrumFile = FileOperation.rename(super.spectrumFile,newFileName.toString(),true);
|
||||
//设置能谱文件保存相对路径(包含文件名称)
|
||||
String fileSavePath = this.getFileSaveRelativePath();
|
||||
this.spectrumFileRelativePath = fileSavePath+File.separator+this.spectrumFile.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -49,6 +49,14 @@ public class MetSpectrum extends AbstractSpectrumHandler{
|
|||
super.setNext(spectrumHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* 前置检查
|
||||
*/
|
||||
@Override
|
||||
protected void preCheck() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查规则并处理数据
|
||||
*/
|
||||
|
@ -60,10 +68,12 @@ public class MetSpectrum extends AbstractSpectrumHandler{
|
|||
super.printCurrDataType();
|
||||
//解析邮件内容
|
||||
this.parseingEmail();
|
||||
//保存PHD文件到savefile
|
||||
super.saveFileToSavefile();
|
||||
//修改能谱文件名称
|
||||
this.updateSpectrumFileName();
|
||||
//结构体数据入库
|
||||
this.handlerOriginalData();
|
||||
//保存PHD文件到savefile
|
||||
super.saveFileToSavefile();
|
||||
//把流程日志保存到日志目录
|
||||
this.saveLogToLogDir();
|
||||
//若本次文件来自于undel目录,解析成功则删除
|
||||
|
@ -130,6 +140,9 @@ public class MetSpectrum extends AbstractSpectrumHandler{
|
|||
throw new FileNotFoundException(super.spectrumFile.getAbsolutePath()+" does not exist");
|
||||
}
|
||||
super.spectrumFile = FileOperation.rename(super.spectrumFile,newFileName.toString(),true);
|
||||
//设置能谱文件保存相对路径(包含文件名称)
|
||||
String fileSavePath = this.getFileSaveRelativePath();
|
||||
this.spectrumFileRelativePath = fileSavePath+File.separator+this.spectrumFile.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.jeecg.modules.spectrum;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import lombok.Setter;
|
||||
import org.jeecg.common.constant.StringConstant;
|
||||
import org.jeecg.common.properties.SpectrumPathProperties;
|
||||
|
@ -47,6 +48,12 @@ public class ParsingProcessLog extends AbstractAutoLogOrReport{
|
|||
@Setter
|
||||
private boolean analysisDataStoreFlag = false;
|
||||
|
||||
/**
|
||||
* 分析数据是否成功
|
||||
*/
|
||||
@Setter
|
||||
private boolean analysisResultFlag = false;
|
||||
|
||||
/**
|
||||
* 能谱处理父类
|
||||
*/
|
||||
|
@ -163,26 +170,44 @@ public class ParsingProcessLog extends AbstractAutoLogOrReport{
|
|||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
|
||||
this.setDetAndGasIdLog();
|
||||
if(fileNotExist){
|
||||
// Gas谱或Det谱文件找不到异常结束
|
||||
fileNotExistException();
|
||||
}else{
|
||||
this.readCalibrationData();
|
||||
this.reading_roi_limits();
|
||||
this.reading_roi_ratios();
|
||||
this.reading_B_G_Efficiency();
|
||||
this.NCC_analysis();
|
||||
//获取analyseResult
|
||||
BgAnalyseResult analyseResult = sample_B_Analysis.analyseResult;
|
||||
if (Objects.nonNull(analyseResult) && !analyseResult.analyse_flag) {
|
||||
analysisResultFlag = true;
|
||||
}
|
||||
|
||||
if(fileRepeat || fileNotExist || analysisDataStoreFlag){
|
||||
//如果分析结果错误
|
||||
if (analysisResultFlag) {
|
||||
storeFlag = "Error";
|
||||
analysisLog.append(rowFormat(storeResult,storeFlag));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append(rowFormat(storeStatus,storeFlag,spectrumHandler.status));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append(analyseResult.error_log);
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append(titleFormat(analysisResultsEnd,25,StringConstant.DASH,storeFlag,endAnalysisTime,StringConstant.DASH));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
} else {
|
||||
if (fileNotExist){
|
||||
// Gas谱或Det谱文件找不到异常结束
|
||||
fileNotExistException();
|
||||
} else {
|
||||
this.readCalibrationData();
|
||||
this.reading_roi_limits();
|
||||
this.reading_roi_ratios();
|
||||
this.reading_B_G_Efficiency();
|
||||
this.NCC_analysis();
|
||||
}
|
||||
|
||||
if(fileRepeat || fileNotExist || analysisDataStoreFlag){
|
||||
storeFlag = "Error";
|
||||
}
|
||||
analysisLog.append(rowFormat(storeResult,storeFlag));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append(rowFormat(storeStatus,storeFlag,spectrumHandler.status));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append(titleFormat(analysisResultsEnd,25,StringConstant.DASH,storeFlag,endAnalysisTime,StringConstant.DASH));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
analysisLog.append(rowFormat(storeResult,storeFlag));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append(rowFormat(storeStatus,storeFlag,spectrumHandler.status));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append(titleFormat(analysisResultsEnd,25,StringConstant.DASH,storeFlag,endAnalysisTime,StringConstant.DASH));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -789,7 +814,7 @@ public class ParsingProcessLog extends AbstractAutoLogOrReport{
|
|||
this.handleStorageProcessLog();
|
||||
if(DataType.SAMPLEPHD.getType().equals(this.spectrumHandler.currDataType.getType()) &&
|
||||
this.spectrumHandler.sourceData.system_type.equals(SystemType.BETA.getType()) &&
|
||||
this.fileRepeat == false && this.fileNotExist == false){
|
||||
this.fileRepeat == false){
|
||||
|
||||
this.handleAnalysisProcessLog();
|
||||
}
|
||||
|
|
|
@ -39,10 +39,12 @@ public class QcphdSpectrum extends AbstractS_D_Q_G_SpectrumHandler {
|
|||
super.parseingEmail();
|
||||
//读取邮件内容标签
|
||||
super.readFileLabel();
|
||||
//保存PHD文件到savefile
|
||||
super.saveFileToSavefile();
|
||||
//修改能谱文件名称
|
||||
super.updateSpectrumFileName();
|
||||
//结构体数据入库
|
||||
super.handlerOriginalData();
|
||||
//保存PHD文件到savefile
|
||||
super.saveFileToSavefile();
|
||||
//修改状态为解析完成
|
||||
super.status = SampleStatus.COMPLETE.getValue();
|
||||
super.updateStatus();
|
||||
|
@ -55,7 +57,7 @@ public class QcphdSpectrum extends AbstractS_D_Q_G_SpectrumHandler {
|
|||
super.status = SampleStatus.FAIL.getValue();
|
||||
super.updateStatus();
|
||||
|
||||
//处理解析失败的文件,上传到undeal目录
|
||||
//处理解析失败的文件
|
||||
super.handleParseingFailFile(e);
|
||||
throw e;
|
||||
}finally {
|
||||
|
|
|
@ -8,11 +8,14 @@ import org.jeecg.common.constant.StringConstant;
|
|||
import org.jeecg.common.properties.SpectrumPathProperties;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.jeecg.common.util.NumberFormatUtil;
|
||||
import org.jeecg.modules.ErrorLogManager;
|
||||
import org.jeecg.modules.base.dto.Info;
|
||||
import org.jeecg.modules.base.entity.original.GardsSampleData;
|
||||
import org.jeecg.modules.base.entity.rnauto.GardsAnalyses;
|
||||
import org.jeecg.modules.base.enums.*;
|
||||
import org.jeecg.modules.config.datasource.DataSourceSwitcher;
|
||||
import org.jeecg.modules.eneity.event.SpectrumErrorEvent;
|
||||
import org.jeecg.modules.enums.ErrorType;
|
||||
import org.jeecg.modules.exception.BAnalyseException;
|
||||
import org.jeecg.modules.exception.FileNotExistException;
|
||||
import org.jeecg.modules.file.FileOperation;
|
||||
|
@ -191,6 +194,7 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
parsingProcessLog.setFileNotExist(true);
|
||||
|
||||
this.spectrumServiceQuotes.getSampleDataService().updateStatus(SampleStatus.FAIL.getValue(),this.sampleData.getInputFileName());
|
||||
ErrorLogManager.getInstance().write(new SpectrumErrorEvent(new Date(), ErrorType.GAS_OR_DET_ERROR,this.phdFileName));
|
||||
throw new FileNotExistException("gas or det file is no exist or is error..");
|
||||
}
|
||||
}
|
||||
|
@ -221,10 +225,11 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
private void autoAnalyse() throws BAnalyseException, FileNotExistException {
|
||||
BgAnalyseResult analyseResult = EnergySpectrumHandler.bgAnalyse(this.sampleFileFinalPath,this.gasFileFinalPath,this.detFileFinalPath);
|
||||
System.out.println(analyseResult);
|
||||
this.analyseResult = analyseResult;
|
||||
if(Objects.isNull(analyseResult) || !analyseResult.analyse_flag){
|
||||
ErrorLogManager.getInstance().write(new SpectrumErrorEvent(new Date(), analyseResult.error_log, this.phdFileName));
|
||||
throw new BAnalyseException("THE PHD file cannot be parsed:"+this.sampleFileFinalPath+","+this.gasFileFinalPath+","+this.detFileFinalPath);
|
||||
}
|
||||
this.analyseResult = analyseResult;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -261,6 +266,7 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
|
||||
if(flag){
|
||||
parsingProcessLog.setFileNotExist(true);
|
||||
ErrorLogManager.getInstance().write(new SpectrumErrorEvent(new Date(), ErrorType.GAS_OR_DET_ERROR,this.phdFileName));
|
||||
throw new FileNotExistException("gas or det file is no exist or is error..");
|
||||
}
|
||||
this.detStruct = EnergySpectrumHandler.getSourceData(this.detFileFinalPath);
|
||||
|
|
|
@ -39,13 +39,14 @@ public class SamplephdSpectrum extends AbstractS_D_Q_G_SpectrumHandler {
|
|||
super.parseingEmail();
|
||||
//读取邮件内容标签
|
||||
super.readFileLabel();
|
||||
//保存PHD文件到savefile
|
||||
super.saveFileToSavefile();
|
||||
//修改能谱文件名称
|
||||
super.updateSpectrumFileName();
|
||||
//结构体数据入库
|
||||
super.handlerOriginalData();
|
||||
//进行B、G(P)谱分析
|
||||
this.autoAnalysis();
|
||||
|
||||
//保存PHD文件到savefile
|
||||
super.saveFileToSavefile();
|
||||
//修改状态为解析完成
|
||||
super.status = SampleStatus.COMPLETE.getValue();
|
||||
super.updateStatus();
|
||||
|
@ -58,7 +59,7 @@ public class SamplephdSpectrum extends AbstractS_D_Q_G_SpectrumHandler {
|
|||
super.status = SampleStatus.FAIL.getValue();
|
||||
super.updateStatus();
|
||||
|
||||
//处理解析失败的文件,上传到undeal目录
|
||||
//处理解析失败的文件
|
||||
super.handleParseingFailFile(e);
|
||||
throw e;
|
||||
}finally {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.jeecg.modules.spectrum;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jeecg.common.email.EmailLogEvent;
|
||||
|
@ -8,6 +9,8 @@ import org.jeecg.common.email.EmailServiceManager;
|
|||
import org.jeecg.modules.email.EmailProperties;
|
||||
import org.jeecg.modules.enums.SpectrumSource;
|
||||
import javax.mail.Message;
|
||||
import java.io.File;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
/**
|
||||
|
@ -68,15 +71,17 @@ public class SpectrumParsingActuator implements Runnable{
|
|||
//获取邮件主题
|
||||
subject = emailServiceManager.getMailSubject(message);
|
||||
|
||||
//获取邮件内容
|
||||
StringBuilder mailContent = new StringBuilder();
|
||||
emailServiceManager.getMailContent(message,mailContent);
|
||||
|
||||
//所有邮件都需以.eml格式存储到eml文件夹中
|
||||
emailServiceManager.downloadEmailToEmlDir(message,emailCounter.getCurrValue());
|
||||
final File emlFile = emailServiceManager.downloadEmailToEmlDir(message, emailCounter.getCurrValue());
|
||||
//保存邮件日志到PG数据库
|
||||
this.spectrumServiceQuotes.getMailLogService().create(message,emailProperties);
|
||||
|
||||
//获取邮件内容
|
||||
StringBuilder mailContent = new StringBuilder();
|
||||
if(Objects.nonNull(emlFile) && emlFile.length() > 0){
|
||||
mailContent.append(FileUtil.readUtf8String(emlFile));
|
||||
}
|
||||
|
||||
//判断是否是IMS2.0协议文件
|
||||
if(checkMailContent(mailContent,subject)){
|
||||
AbstractSpectrumHandler spectrumHandler = new SamplephdSpectrum();
|
||||
|
|
|
@ -2607,7 +2607,7 @@ public class GammaFileUtil extends AbstractLogOrReport {
|
|||
String data16 = "Name : %-15s Pass/Fail : %-9s Value : %-14s Test : %-16s";
|
||||
String qcName = middleData.QC_CHECK_QC_NAME.get(i);
|
||||
String qcResult = middleData.QC_CHECK_QC_RESULT.get(i).equals("0") ? "Fail" : "Pass";
|
||||
String qcValue = String.format("%.3f", Double.valueOf(middleData.QC_CHECK_QC_VALUE.get(i)));
|
||||
String qcValue = StringUtils.isBlank(middleData.QC_CHECK_QC_VALUE.get(i))?"null":String.format("%.3f", Double.valueOf(middleData.QC_CHECK_QC_VALUE.get(i)));
|
||||
String standard = middleData.QC_CHECK_QC_STANDARD.get(i);
|
||||
strBuffer.append(rowFormat(data16, qcName, qcResult, qcValue, standard));
|
||||
//换行
|
||||
|
@ -3070,7 +3070,7 @@ public class GammaFileUtil extends AbstractLogOrReport {
|
|||
//换行
|
||||
strBuffer.append(System.lineSeparator());
|
||||
for (int i=0;i<middleData.QC_CHECK_QC_NAME.size(); i++){
|
||||
strBuffer.append(rowFormat(qualityTitle, StringPool.SPACE+middleData.QC_CHECK_QC_NAME.get(i), (Double.valueOf(middleData.QC_CHECK_QC_RESULT.get(i)) < 1?"Fail":"Pass"), String.format("%.3f", Double.valueOf(middleData.QC_CHECK_QC_VALUE.get(i))), middleData.QC_CHECK_QC_STANDARD.get(i)));
|
||||
strBuffer.append(rowFormat(qualityTitle, StringPool.SPACE+middleData.QC_CHECK_QC_NAME.get(i), (Double.valueOf(middleData.QC_CHECK_QC_RESULT.get(i)) < 1?"Fail":"Pass"), StringUtils.isNotBlank(middleData.QC_CHECK_QC_VALUE.get(i))?String.format("%.3f", Double.valueOf(middleData.QC_CHECK_QC_VALUE.get(i))):"null", middleData.QC_CHECK_QC_STANDARD.get(i)));
|
||||
//换行
|
||||
strBuffer.append(System.lineSeparator());
|
||||
}
|
||||
|
|
|
@ -78,6 +78,8 @@ public class JeecgAutoProcessApplication extends SpringBootServletInitializer im
|
|||
checkTempStorageDirectory();
|
||||
//初始化邮箱邮件声明周期日志
|
||||
EmailLogManager.init(spectrumPathProperties);
|
||||
//初始化能谱解析错误日志管理器
|
||||
ErrorLogManager.init(spectrumPathProperties);
|
||||
//校验存储目录是否存在,不存在则创建,存在无操作
|
||||
checkStorageDirectory();
|
||||
autoProcessManager.start(systemStartupTime);
|
||||
|
|
Loading…
Reference in New Issue
Block a user