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.store.protocol", "imap");
|
||||||
properties.put("mail.imap.host", email.getEmailServerAddress());
|
properties.put("mail.imap.host", email.getEmailServerAddress());
|
||||||
properties.put("mail.imap.port",email.getPort());
|
properties.put("mail.imap.port",email.getPort());
|
||||||
|
if (email.getIsQiye() == 1) {
|
||||||
properties.put("mail.imap.ssl.enable", "true");
|
properties.put("mail.imap.ssl.enable", "true");
|
||||||
|
} else {
|
||||||
|
properties.put("mail.imap.ssl.enable", "false");
|
||||||
|
}
|
||||||
|
|
||||||
//获取邮件回话
|
//获取邮件回话
|
||||||
final Session session = Session.getDefaultInstance(properties);
|
final Session session = Session.getDefaultInstance(properties);
|
||||||
|
|
||||||
|
@ -492,7 +497,7 @@ public class EmailServiceManager {
|
||||||
* 格式为:发件人_主题_年月日_时分秒毫秒_计数(0-10000)
|
* 格式为:发件人_主题_年月日_时分秒毫秒_计数(0-10000)
|
||||||
* 当计数大于10000后从0开始,服务重启后也从0开始
|
* 当计数大于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 = "";
|
String subject = "";
|
||||||
File emlFile = null;
|
File emlFile = null;
|
||||||
String status = EmailLogManager.STATUS_SUCCESS;
|
String status = EmailLogManager.STATUS_SUCCESS;
|
||||||
|
@ -534,6 +539,8 @@ public class EmailServiceManager {
|
||||||
(Objects.isNull(emlFile)?" ":emlFile.getAbsolutePath()));
|
(Objects.isNull(emlFile)?" ":emlFile.getAbsolutePath()));
|
||||||
EmailLogManager.getInstance().offer(Thread.currentThread().getId(),event);
|
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) {
|
public static List<String> getValuePoint(List<String> source, int num) {
|
||||||
List<String> result = Lists.newLinkedList();
|
List<String> result = Lists.newLinkedList();
|
||||||
for (String str : source) {
|
for (String str : source) {
|
||||||
|
if (StringUtils.isNotBlank(str)) {
|
||||||
result.add(String.format("%." + num + "f", Double.parseDouble(str)));
|
result.add(String.format("%." + num + "f", Double.parseDouble(str)));
|
||||||
|
} else {
|
||||||
|
result.add("null");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class AutoProcessManager{
|
||||||
/**
|
/**
|
||||||
* 以邮件id为key,以邮件执行线程为value
|
* 以邮件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();
|
EmailProperties next = iterator.next();
|
||||||
if(next.isDelFlag()){
|
if(next.isDelFlag()){
|
||||||
if(emailExecThreadMap.containsKey(next.getId())){
|
if(emailExecThreadMap.containsKey(next.getId())){
|
||||||
Thread thread = emailExecThreadMap.get(next.getId());
|
EmailParsingActuator actuator = emailExecThreadMap.get(next.getId());
|
||||||
thread.interrupt();
|
actuator.setStop(true);
|
||||||
emailExecThreadMap.remove(next.getId());
|
emailExecThreadMap.remove(next.getId());
|
||||||
}
|
}
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
|
if (next.isResetFlag()) {
|
||||||
|
EmailParsingActuator actuator = emailExecThreadMap.get(next.getId());
|
||||||
|
actuator.updateEmail(next);
|
||||||
|
next.setResetFlag(false);
|
||||||
|
}
|
||||||
if(next.isNewEmailFlag()){
|
if(next.isNewEmailFlag()){
|
||||||
EmailParsingActuator emailParsingActuator = new EmailParsingActuator();
|
EmailParsingActuator emailParsingActuator = new EmailParsingActuator();
|
||||||
emailParsingActuator.init(next,spectrumServiceQuotes,emailCounter,systemStartupTime);
|
emailParsingActuator.init(next,spectrumServiceQuotes,emailCounter,systemStartupTime);
|
||||||
|
@ -176,11 +181,25 @@ public class AutoProcessManager{
|
||||||
//如果库里已有数据原来已开启使用并且监测Map中已存在,现在关闭使用则添加删除标记
|
//如果库里已有数据原来已开启使用并且监测Map中已存在,现在关闭使用则添加删除标记
|
||||||
//如果本次查询数据监测Map中不存在,并且已开启使用的则加入监测Map
|
//如果本次查询数据监测Map中不存在,并且已开启使用的则加入监测Map
|
||||||
for(EmailProperties email : receiveMails){
|
for(EmailProperties email : receiveMails){
|
||||||
|
//判断map里是否包含邮箱id
|
||||||
final boolean flag = emailMap.containsKey(email.getId());
|
final boolean flag = emailMap.containsKey(email.getId());
|
||||||
|
//如果包含邮箱id 并且 邮箱处于未启用的状态 将邮箱的删除标识设置为true
|
||||||
if(flag && email.getEnabled().equals(SysMailEnableType.NOT_ENABLE.getMailEnableType())){
|
if(flag && email.getEnabled().equals(SysMailEnableType.NOT_ENABLE.getMailEnableType())){
|
||||||
EmailProperties sourceEmail = emailMap.get(email.getId());
|
EmailProperties sourceEmail = emailMap.get(email.getId());
|
||||||
sourceEmail.setDelFlag(true);
|
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())){
|
if(!flag && email.getEnabled().equals(SysMailEnableType.ENABLE.getMailEnableType())){
|
||||||
email.setNewEmailFlag(true);
|
email.setNewEmailFlag(true);
|
||||||
putSysEmailMap(email);
|
putSysEmailMap(email);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.jeecg.modules;
|
package org.jeecg.modules;
|
||||||
|
|
||||||
|
import lombok.Setter;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.jeecg.common.email.EmailLogManager;
|
import org.jeecg.common.email.EmailLogManager;
|
||||||
import org.jeecg.common.email.EmailServiceManager;
|
import org.jeecg.common.email.EmailServiceManager;
|
||||||
|
@ -26,6 +27,8 @@ public class EmailParsingActuator extends Thread{
|
||||||
private SpectrumServiceQuotes spectrumServiceQuotes;
|
private SpectrumServiceQuotes spectrumServiceQuotes;
|
||||||
private EmailCounter emailCounter;
|
private EmailCounter emailCounter;
|
||||||
private Date systemStartupTime;
|
private Date systemStartupTime;
|
||||||
|
@Setter
|
||||||
|
private boolean isStop;
|
||||||
|
|
||||||
public void init(EmailProperties emailProperties,SpectrumServiceQuotes spectrumServiceQuotes,
|
public void init(EmailProperties emailProperties,SpectrumServiceQuotes spectrumServiceQuotes,
|
||||||
EmailCounter emailCounter,Date systemStartupTime){
|
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);
|
poolExecutor = new ThreadPoolExecutor(taskProperties.getReceiveNum(),maximumPoolSize,5, TimeUnit.SECONDS, new LinkedBlockingQueue<>(),threadFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateEmail(EmailProperties emailProperties) {
|
||||||
|
this.emailProperties = emailProperties;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for(;;){
|
for(;;){
|
||||||
|
if (isStop) {
|
||||||
|
System.out.println("EmailParsingActuator is Stop!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
final EmailServiceManager emailServiceManager = EmailServiceManager.getInstance();
|
final EmailServiceManager emailServiceManager = EmailServiceManager.getInstance();
|
||||||
emailServiceManager.init(this.emailProperties,this.taskProperties.getReceiveNum(),this.taskProperties.getTemporaryStoragePath(),this.systemStartupTime, spectrumServiceQuotes.getSpectrumPathProperties());
|
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 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.constant.StringConstant;
|
||||||
import org.jeecg.common.properties.SpectrumPathProperties;
|
import org.jeecg.common.properties.SpectrumPathProperties;
|
||||||
import org.jeecg.common.properties.TaskProperties;
|
import org.jeecg.common.properties.TaskProperties;
|
||||||
|
import org.jeecg.modules.ErrorLogManager;
|
||||||
import org.jeecg.modules.base.entity.configuration.GardsStations;
|
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.exception.StationNotFoundException;
|
||||||
import org.jeecg.modules.mapper.GardsStationsMapper;
|
import org.jeecg.modules.mapper.GardsStationsMapper;
|
||||||
import org.jeecg.modules.service.GardsStationsService;
|
import org.jeecg.modules.service.GardsStationsService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@ -37,13 +41,9 @@ public class GardsStationsServiceImpl extends ServiceImpl<GardsStationsMapper, G
|
||||||
gardsStationsQuery.eq(GardsStations::getStationCode,site_code);
|
gardsStationsQuery.eq(GardsStations::getStationCode,site_code);
|
||||||
final GardsStations station = this.baseMapper.selectOne(gardsStationsQuery);
|
final GardsStations station = this.baseMapper.selectOne(gardsStationsQuery);
|
||||||
if (Objects.isNull(station)) {
|
if (Objects.isNull(station)) {
|
||||||
StringBuilder logContent = new StringBuilder();
|
String errorFileName = fileName.substring(fileName.lastIndexOf("/"));
|
||||||
logContent.append("station_code:"+site_code+"=0");
|
ErrorLogManager.getInstance().write(new SpectrumErrorEvent(new Date(),ErrorType.STATION_ERROR,errorFileName,site_code));
|
||||||
logContent.append(StringConstant.SPACE);
|
|
||||||
logContent.append(taskProperties.getUndealFileTimeOut());
|
|
||||||
|
|
||||||
log.error("This station does not exist, the number is {}.",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+".");
|
throw new StationNotFoundException("This station does not exist, the number is "+site_code+".");
|
||||||
}
|
}
|
||||||
return station;
|
return station;
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class SysMailServiceImpl extends ServiceImpl<SysMailMapper, SysEmail> imp
|
||||||
public List<EmailProperties> findReceiveMails() {
|
public List<EmailProperties> findReceiveMails() {
|
||||||
LambdaQueryWrapper<SysEmail> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SysEmail> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
queryWrapper.eq(SysEmail::getEmilType, SysMailType.RECEIVE_EMAIL.getEmailType());
|
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);
|
List<SysEmail> sysEmail = this.list(queryWrapper);
|
||||||
if(!CollectionUtils.isEmpty(sysEmail)){
|
if(!CollectionUtils.isEmpty(sysEmail)){
|
||||||
List<EmailProperties> emailPropertiesList = Lists.newArrayList();
|
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.constant.StringConstant;
|
||||||
import org.jeecg.common.properties.SpectrumPathProperties;
|
import org.jeecg.common.properties.SpectrumPathProperties;
|
||||||
import org.jeecg.common.util.DateUtils;
|
import org.jeecg.common.util.DateUtils;
|
||||||
|
import org.jeecg.modules.ErrorLogManager;
|
||||||
import org.jeecg.modules.base.entity.original.GardsSampleData;
|
import org.jeecg.modules.base.entity.original.GardsSampleData;
|
||||||
import org.jeecg.modules.base.enums.SampleStatus;
|
import org.jeecg.modules.base.enums.SampleStatus;
|
||||||
import org.jeecg.modules.config.datasource.DataSourceSwitcher;
|
import org.jeecg.modules.config.datasource.DataSourceSwitcher;
|
||||||
import org.jeecg.modules.eneity.event.FormatErrorEvent;
|
import org.jeecg.modules.eneity.event.FormatErrorEvent;
|
||||||
import org.jeecg.modules.eneity.event.RepeatErrorEvent;
|
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.exception.*;
|
||||||
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
|
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
|
||||||
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
|
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() {
|
protected void preCheck() {
|
||||||
this.checkHeaderBlock();
|
super.checkHeaderBlock();
|
||||||
this.checkAcquisitionBlock();
|
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
|
* 检查此邮件是否包含#Acquisition block
|
||||||
*/
|
*/
|
||||||
protected void checkAcquisitionBlock(){
|
protected void checkAcquisitionBlock(){
|
||||||
if(this.mailContent.indexOf("#Acquisition") == -1){
|
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");
|
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");
|
throw new FileNotFoundException(super.spectrumFile.getAbsolutePath()+" does not exist");
|
||||||
}
|
}
|
||||||
super.spectrumFile = FileUtil.rename(super.spectrumFile, newFileName.toString(), true);
|
super.spectrumFile = FileUtil.rename(super.spectrumFile, newFileName.toString(), true);
|
||||||
|
//设置能谱文件保存相对路径(包含文件名称)
|
||||||
|
String fileSavePath = this.getFileSaveRelativePath();
|
||||||
|
this.spectrumFileRelativePath = fileSavePath+File.separator+this.spectrumFile.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -230,15 +227,19 @@ public abstract class AbstractS_D_Q_G_SpectrumHandler extends AbstractSpectrumHa
|
||||||
this.startIntoDatabaseTime = new Date();
|
this.startIntoDatabaseTime = new Date();
|
||||||
//如果数据已经存储,不在重复存储
|
//如果数据已经存储,不在重复存储
|
||||||
final GardsSampleData query = spectrumServiceQuotes.getSampleDataService().findByInputFileName(super.spectrumFileRelativePath);
|
final GardsSampleData query = spectrumServiceQuotes.getSampleDataService().findByInputFileName(super.spectrumFileRelativePath);
|
||||||
|
//如果数据已经存储 并且状态是 P 则判断文件重复 如果数据已经存储并且状态是 F 不进行处理
|
||||||
if(Objects.nonNull(query)){
|
if(Objects.nonNull(query)){
|
||||||
this.sampleData = query;
|
this.sampleData = query;
|
||||||
this.endIntoDatabaseTime = new Date();
|
this.endIntoDatabaseTime = new Date();
|
||||||
|
if (query.getStatus().equalsIgnoreCase(SampleStatus.COMPLETE.value)) {
|
||||||
//设置文件重复标记为true
|
//设置文件重复标记为true
|
||||||
this.parsingProcessLog.setFileRepeat(true);
|
this.parsingProcessLog.setFileRepeat(true);
|
||||||
//发送文件重复错误事件,后续统计报告使用
|
//发送文件重复错误事件,后续统计报告使用
|
||||||
spectrumServiceQuotes.getApplicationContext().publishEvent(new RepeatErrorEvent());
|
spectrumServiceQuotes.getApplicationContext().publishEvent(new RepeatErrorEvent());
|
||||||
|
ErrorLogManager.getInstance().write(new SpectrumErrorEvent(new Date(),ErrorType.FILE_REPEAT,super.spectrumFile.getName()));
|
||||||
throw new FileRepeatException("file repeat");
|
throw new FileRepeatException("file repeat");
|
||||||
}
|
}
|
||||||
|
} else if (Objects.isNull(query)) { // 如果没有查询出对应的数据 则对数据进行存储操作
|
||||||
DataSourceSwitcher.switchToOracle();
|
DataSourceSwitcher.switchToOracle();
|
||||||
final TransactionStatus transactionStatus = spectrumServiceQuotes.getTransactionManager().getTransaction(spectrumServiceQuotes.getTransactionDefinition());
|
final TransactionStatus transactionStatus = spectrumServiceQuotes.getTransactionManager().getTransaction(spectrumServiceQuotes.getTransactionDefinition());
|
||||||
try{
|
try{
|
||||||
|
@ -263,6 +264,7 @@ public abstract class AbstractS_D_Q_G_SpectrumHandler extends AbstractSpectrumHa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改解析状态
|
* 修改解析状态
|
||||||
|
|
|
@ -4,17 +4,24 @@ import cn.hutool.core.io.FileUtil;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.jeecg.common.email.EmailLogEvent;
|
import org.jeecg.common.email.EmailLogEvent;
|
||||||
import org.jeecg.common.email.EmailLogManager;
|
import org.jeecg.common.email.EmailLogManager;
|
||||||
import org.jeecg.common.properties.SpectrumPathProperties;
|
import org.jeecg.common.properties.SpectrumPathProperties;
|
||||||
|
import org.jeecg.modules.ErrorLogManager;
|
||||||
import org.jeecg.modules.base.enums.DataType;
|
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.eneity.event.SpectrumLog;
|
||||||
|
import org.jeecg.modules.enums.ErrorType;
|
||||||
import org.jeecg.modules.enums.SpectrumSource;
|
import org.jeecg.modules.enums.SpectrumSource;
|
||||||
import org.jeecg.modules.exception.FileRepeatException;
|
import org.jeecg.modules.exception.FileRepeatException;
|
||||||
|
import org.jeecg.modules.exception.HeaderBlockException;
|
||||||
import org.jeecg.modules.file.FileOperation;
|
import org.jeecg.modules.file.FileOperation;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -106,6 +113,23 @@ public abstract class AbstractSpectrumHandler extends AbstractChain {
|
||||||
this.setChina();
|
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
|
* 保存能谱文件到savefile
|
||||||
*/
|
*/
|
||||||
protected void saveFileToSavefile() throws Exception{
|
protected void saveFileToSavefile() throws Exception{
|
||||||
//修改能谱文件名称
|
|
||||||
this.updateSpectrumFileName();
|
|
||||||
//获取文件保存路径
|
//获取文件保存路径
|
||||||
String fileSavePath = this.getFileSaveRelativePath();
|
String fileSavePath = this.getFileSaveRelativePath();
|
||||||
final SpectrumPathProperties properties = this.spectrumServiceQuotes.getSpectrumPathProperties();
|
final SpectrumPathProperties properties = this.spectrumServiceQuotes.getSpectrumPathProperties();
|
||||||
|
@ -135,8 +157,6 @@ public abstract class AbstractSpectrumHandler extends AbstractChain {
|
||||||
finalPath.append(this.spectrumFile.getName());
|
finalPath.append(this.spectrumFile.getName());
|
||||||
FileOperation.moveFile(this.spectrumFile,finalPath.toString(),true);
|
FileOperation.moveFile(this.spectrumFile,finalPath.toString(),true);
|
||||||
this.spectrumFile = new File(finalPath.toString());
|
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
|
* @throws FileNotFoundException
|
||||||
*/
|
*/
|
||||||
protected void handleParseingFailFile(Exception e) throws FileNotFoundException {
|
protected void handleParseingFailFile(Exception e) throws FileNotFoundException {
|
||||||
|
@ -232,7 +255,7 @@ public abstract class AbstractSpectrumHandler extends AbstractChain {
|
||||||
if (isDateFormatErr) {
|
if (isDateFormatErr) {
|
||||||
//修改能谱文件名称
|
//修改能谱文件名称
|
||||||
this.updateErrorSpectrumFileName();
|
this.updateErrorSpectrumFileName();
|
||||||
//解析失败会把文件移动到undeal目录
|
//解析失败会把文件移动到errorfile目录
|
||||||
final String rootPath = spectrumServiceQuotes.getSpectrumPathProperties().getRootPath();
|
final String rootPath = spectrumServiceQuotes.getSpectrumPathProperties().getRootPath();
|
||||||
final String errorFilePath = spectrumServiceQuotes.getSpectrumPathProperties().getErrorFilePath();
|
final String errorFilePath = spectrumServiceQuotes.getSpectrumPathProperties().getErrorFilePath();
|
||||||
final String finalPath = rootPath+File.separator+errorFilePath;
|
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 rootPath = spectrumServiceQuotes.getSpectrumPathProperties().getRootPath();
|
||||||
final String undealPath = spectrumServiceQuotes.getSpectrumPathProperties().getUndealPath();
|
final String undealPath = spectrumServiceQuotes.getSpectrumPathProperties().getUndealPath();
|
||||||
final String finalPath = rootPath+File.separator+undealPath;
|
final String finalPath = rootPath+File.separator+undealPath;
|
||||||
FileOperation.copyFile(spectrumFile,finalPath,true);
|
FileOperation.moveFile(spectrumFile,finalPath,true);
|
||||||
}
|
}
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
ex.printStackTrace();
|
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);
|
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.constant.StringConstant;
|
||||||
import org.jeecg.common.properties.SpectrumPathProperties;
|
import org.jeecg.common.properties.SpectrumPathProperties;
|
||||||
import org.jeecg.common.util.DateUtils;
|
import org.jeecg.common.util.DateUtils;
|
||||||
|
import org.jeecg.modules.ErrorLogManager;
|
||||||
import org.jeecg.modules.base.entity.original.GardsAlertData;
|
import org.jeecg.modules.base.entity.original.GardsAlertData;
|
||||||
import org.jeecg.modules.base.enums.DataType;
|
import org.jeecg.modules.base.enums.DataType;
|
||||||
import org.jeecg.modules.eneity.event.FormatErrorEvent;
|
import org.jeecg.modules.eneity.event.FormatErrorEvent;
|
||||||
import org.jeecg.modules.eneity.event.RepeatErrorEvent;
|
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.FileRepeatException;
|
||||||
import org.jeecg.modules.exception.PHD_ReadException;
|
import org.jeecg.modules.exception.PHD_ReadException;
|
||||||
import org.jeecg.modules.file.FileOperation;
|
import org.jeecg.modules.file.FileOperation;
|
||||||
|
@ -54,6 +57,13 @@ public class AlertSpectrum extends AbstractSpectrumHandler{
|
||||||
super.setNext(spectrumHandler);
|
super.setNext(spectrumHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前置检查
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void preCheck() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查规则并处理数据
|
* 检查规则并处理数据
|
||||||
*/
|
*/
|
||||||
|
@ -68,15 +78,20 @@ public class AlertSpectrum extends AbstractSpectrumHandler{
|
||||||
super.printCurrDataType();
|
super.printCurrDataType();
|
||||||
//解析邮件内容
|
//解析邮件内容
|
||||||
this.parseingEmail();
|
this.parseingEmail();
|
||||||
//保存PHD文件到savefile
|
//修改能谱文件名称
|
||||||
super.saveFileToSavefile();
|
this.updateSpectrumFileName();
|
||||||
//结构体数据入库
|
//结构体数据入库
|
||||||
this.handlerOriginalData();
|
this.handlerOriginalData();
|
||||||
|
//保存PHD文件到savefile
|
||||||
|
super.saveFileToSavefile();
|
||||||
//若本次文件来自于undel目录,解析成功则删除
|
//若本次文件来自于undel目录,解析成功则删除
|
||||||
deleteIfFromUndelFile();
|
deleteIfFromUndelFile();
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
//异常返回文件名称用于报错日志
|
//异常返回文件名称用于报错日志
|
||||||
super.returnFileName.append(super.spectrumFile.getName());
|
super.returnFileName.append(super.spectrumFile.getName());
|
||||||
|
|
||||||
|
//处理解析失败的文件
|
||||||
|
super.handleParseingFailFile(e);
|
||||||
throw e;
|
throw e;
|
||||||
}finally {
|
}finally {
|
||||||
//把流程日志保存到日志目录
|
//把流程日志保存到日志目录
|
||||||
|
@ -139,6 +154,9 @@ public class AlertSpectrum extends AbstractSpectrumHandler{
|
||||||
throw new FileNotFoundException(super.spectrumFile.getAbsolutePath()+" does not exist");
|
throw new FileNotFoundException(super.spectrumFile.getAbsolutePath()+" does not exist");
|
||||||
}
|
}
|
||||||
super.spectrumFile = FileOperation.rename(super.spectrumFile,newFileName.toString(),true);
|
super.spectrumFile = FileOperation.rename(super.spectrumFile,newFileName.toString(),true);
|
||||||
|
//设置能谱文件保存相对路径(包含文件名称)
|
||||||
|
String fileSavePath = this.getFileSaveRelativePath();
|
||||||
|
this.spectrumFileRelativePath = fileSavePath+File.separator+this.spectrumFile.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -173,6 +191,7 @@ public class AlertSpectrum extends AbstractSpectrumHandler{
|
||||||
this.isFileRepeat = true;
|
this.isFileRepeat = true;
|
||||||
//发送文件重复错误事件,后续统计报告使用
|
//发送文件重复错误事件,后续统计报告使用
|
||||||
spectrumServiceQuotes.getApplicationContext().publishEvent(new FormatErrorEvent());
|
spectrumServiceQuotes.getApplicationContext().publishEvent(new FormatErrorEvent());
|
||||||
|
ErrorLogManager.getInstance().write(new SpectrumErrorEvent(new Date(), ErrorType.FILE_REPEAT,super.spectrumFile.getName()));
|
||||||
throw new FileRepeatException("file repeat");
|
throw new FileRepeatException("file repeat");
|
||||||
}
|
}
|
||||||
this.alertData = super.spectrumServiceQuotes.getAlertSpectrumService().create(this.sourceData, super.spectrumFileRelativePath);
|
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.parseingEmail();
|
||||||
//读取邮件内容标签
|
//读取邮件内容标签
|
||||||
super.readFileLabel();
|
super.readFileLabel();
|
||||||
//保存PHD文件到savefile
|
//修改能谱文件名称
|
||||||
super.saveFileToSavefile();
|
super.updateSpectrumFileName();
|
||||||
//结构体数据入库
|
//结构体数据入库
|
||||||
super.handlerOriginalData();
|
super.handlerOriginalData();
|
||||||
|
//保存PHD文件到savefile
|
||||||
|
super.saveFileToSavefile();
|
||||||
//修改状态为解析完成
|
//修改状态为解析完成
|
||||||
super.status = SampleStatus.COMPLETE.getValue();
|
super.status = SampleStatus.COMPLETE.getValue();
|
||||||
super.updateStatus();
|
super.updateStatus();
|
||||||
|
@ -54,7 +56,7 @@ public class DetbkphdSpectrum extends AbstractS_D_Q_G_SpectrumHandler {
|
||||||
super.status = SampleStatus.FAIL.getValue();
|
super.status = SampleStatus.FAIL.getValue();
|
||||||
super.updateStatus();
|
super.updateStatus();
|
||||||
|
|
||||||
//处理解析失败的文件,上传到undeal目录
|
//处理解析失败的文件
|
||||||
super.handleParseingFailFile(e);
|
super.handleParseingFailFile(e);
|
||||||
throw e;
|
throw e;
|
||||||
}finally {
|
}finally {
|
||||||
|
|
|
@ -40,10 +40,12 @@ public class GasbkphdSpectrum extends AbstractS_D_Q_G_SpectrumHandler {
|
||||||
super.parseingEmail();
|
super.parseingEmail();
|
||||||
//读取邮件内容标签
|
//读取邮件内容标签
|
||||||
super.readFileLabel();
|
super.readFileLabel();
|
||||||
//保存PHD文件到savefile
|
//修改能谱文件名称
|
||||||
super.saveFileToSavefile();
|
super.updateSpectrumFileName();
|
||||||
//结构体数据入库
|
//结构体数据入库
|
||||||
super.handlerOriginalData();
|
super.handlerOriginalData();
|
||||||
|
//保存PHD文件到savefile
|
||||||
|
super.saveFileToSavefile();
|
||||||
//修改状态为解析完成
|
//修改状态为解析完成
|
||||||
super.status = SampleStatus.COMPLETE.getValue();
|
super.status = SampleStatus.COMPLETE.getValue();
|
||||||
super.updateStatus();
|
super.updateStatus();
|
||||||
|
@ -56,7 +58,7 @@ public class GasbkphdSpectrum extends AbstractS_D_Q_G_SpectrumHandler {
|
||||||
super.status = SampleStatus.FAIL.getValue();
|
super.status = SampleStatus.FAIL.getValue();
|
||||||
super.updateStatus();
|
super.updateStatus();
|
||||||
|
|
||||||
//处理解析失败的文件,上传到undeal目录
|
//处理解析失败的文件
|
||||||
super.handleParseingFailFile(e);
|
super.handleParseingFailFile(e);
|
||||||
throw e;
|
throw e;
|
||||||
}finally {
|
}finally {
|
||||||
|
|
|
@ -4,9 +4,12 @@ import org.apache.commons.lang3.StringUtils;
|
||||||
import org.jeecg.common.constant.StringConstant;
|
import org.jeecg.common.constant.StringConstant;
|
||||||
import org.jeecg.common.properties.SpectrumPathProperties;
|
import org.jeecg.common.properties.SpectrumPathProperties;
|
||||||
import org.jeecg.common.util.DateUtils;
|
import org.jeecg.common.util.DateUtils;
|
||||||
|
import org.jeecg.modules.ErrorLogManager;
|
||||||
import org.jeecg.modules.base.entity.original.GardsSohData;
|
import org.jeecg.modules.base.entity.original.GardsSohData;
|
||||||
import org.jeecg.modules.base.enums.DataType;
|
import org.jeecg.modules.base.enums.DataType;
|
||||||
import org.jeecg.modules.eneity.event.FormatErrorEvent;
|
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.AirSamplerFlowException;
|
||||||
import org.jeecg.modules.exception.PHD_ReadException;
|
import org.jeecg.modules.exception.PHD_ReadException;
|
||||||
import org.jeecg.modules.file.FileOperation;
|
import org.jeecg.modules.file.FileOperation;
|
||||||
|
@ -46,8 +49,18 @@ public class HealthStatusSpectrum extends AbstractSpectrumHandler{
|
||||||
protected void setChina() {
|
protected void setChina() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前置检查
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void preCheck() {
|
||||||
|
super.checkHeaderBlock();
|
||||||
|
this.checkAirSamplerFlowBlock();
|
||||||
|
}
|
||||||
|
|
||||||
protected void checkAirSamplerFlowBlock(){
|
protected void checkAirSamplerFlowBlock(){
|
||||||
if(super.mailContent.indexOf("#AirSamplerFlow") == -1){
|
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");
|
throw new AirSamplerFlowException("this is no ariSamplerFlow data");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,14 +72,18 @@ public class HealthStatusSpectrum extends AbstractSpectrumHandler{
|
||||||
public void handler() throws Exception {
|
public void handler() throws Exception {
|
||||||
if(DataType.SOH.getType().equals(super.currDataType.getType())){
|
if(DataType.SOH.getType().equals(super.currDataType.getType())){
|
||||||
try {
|
try {
|
||||||
|
//前置检查
|
||||||
|
this.preCheck();
|
||||||
//打印当前处理的能谱类型
|
//打印当前处理的能谱类型
|
||||||
super.printCurrDataType();
|
super.printCurrDataType();
|
||||||
//解析邮件内容
|
//解析邮件内容
|
||||||
this.parseingEmail();
|
this.parseingEmail();
|
||||||
//保存PHD文件到savefile
|
//修改能谱文件名称
|
||||||
super.saveFileToSavefile();
|
this.updateSpectrumFileName();
|
||||||
//结构体数据入库
|
//结构体数据入库
|
||||||
this.handlerOriginalData();
|
this.handlerOriginalData();
|
||||||
|
//保存PHD文件到savefile
|
||||||
|
super.saveFileToSavefile();
|
||||||
//把流程日志保存到日志目录
|
//把流程日志保存到日志目录
|
||||||
this.saveLogToLogDir();
|
this.saveLogToLogDir();
|
||||||
//若本次文件来自于undel目录,解析成功则删除
|
//若本次文件来自于undel目录,解析成功则删除
|
||||||
|
@ -74,6 +91,8 @@ public class HealthStatusSpectrum extends AbstractSpectrumHandler{
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
//异常返回文件名称用于报错日志
|
//异常返回文件名称用于报错日志
|
||||||
super.returnFileName.append(super.spectrumFile.getName());
|
super.returnFileName.append(super.spectrumFile.getName());
|
||||||
|
//处理解析失败的文件
|
||||||
|
super.handleParseingFailFile(e);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,6 +153,9 @@ public class HealthStatusSpectrum extends AbstractSpectrumHandler{
|
||||||
throw new FileNotFoundException(super.spectrumFile.getAbsolutePath()+" does not exist");
|
throw new FileNotFoundException(super.spectrumFile.getAbsolutePath()+" does not exist");
|
||||||
}
|
}
|
||||||
super.spectrumFile = FileOperation.rename(super.spectrumFile,newFileName.toString(),true);
|
super.spectrumFile = FileOperation.rename(super.spectrumFile,newFileName.toString(),true);
|
||||||
|
//设置能谱文件保存相对路径(包含文件名称)
|
||||||
|
String fileSavePath = this.getFileSaveRelativePath();
|
||||||
|
this.spectrumFileRelativePath = fileSavePath+File.separator+this.spectrumFile.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -49,6 +49,14 @@ public class MetSpectrum extends AbstractSpectrumHandler{
|
||||||
super.setNext(spectrumHandler);
|
super.setNext(spectrumHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前置检查
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void preCheck() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查规则并处理数据
|
* 检查规则并处理数据
|
||||||
*/
|
*/
|
||||||
|
@ -60,10 +68,12 @@ public class MetSpectrum extends AbstractSpectrumHandler{
|
||||||
super.printCurrDataType();
|
super.printCurrDataType();
|
||||||
//解析邮件内容
|
//解析邮件内容
|
||||||
this.parseingEmail();
|
this.parseingEmail();
|
||||||
//保存PHD文件到savefile
|
//修改能谱文件名称
|
||||||
super.saveFileToSavefile();
|
this.updateSpectrumFileName();
|
||||||
//结构体数据入库
|
//结构体数据入库
|
||||||
this.handlerOriginalData();
|
this.handlerOriginalData();
|
||||||
|
//保存PHD文件到savefile
|
||||||
|
super.saveFileToSavefile();
|
||||||
//把流程日志保存到日志目录
|
//把流程日志保存到日志目录
|
||||||
this.saveLogToLogDir();
|
this.saveLogToLogDir();
|
||||||
//若本次文件来自于undel目录,解析成功则删除
|
//若本次文件来自于undel目录,解析成功则删除
|
||||||
|
@ -130,6 +140,9 @@ public class MetSpectrum extends AbstractSpectrumHandler{
|
||||||
throw new FileNotFoundException(super.spectrumFile.getAbsolutePath()+" does not exist");
|
throw new FileNotFoundException(super.spectrumFile.getAbsolutePath()+" does not exist");
|
||||||
}
|
}
|
||||||
super.spectrumFile = FileOperation.rename(super.spectrumFile,newFileName.toString(),true);
|
super.spectrumFile = FileOperation.rename(super.spectrumFile,newFileName.toString(),true);
|
||||||
|
//设置能谱文件保存相对路径(包含文件名称)
|
||||||
|
String fileSavePath = this.getFileSaveRelativePath();
|
||||||
|
this.spectrumFileRelativePath = fileSavePath+File.separator+this.spectrumFile.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.jeecg.modules.spectrum;
|
package org.jeecg.modules.spectrum;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.jeecg.common.constant.StringConstant;
|
import org.jeecg.common.constant.StringConstant;
|
||||||
import org.jeecg.common.properties.SpectrumPathProperties;
|
import org.jeecg.common.properties.SpectrumPathProperties;
|
||||||
|
@ -47,6 +48,12 @@ public class ParsingProcessLog extends AbstractAutoLogOrReport{
|
||||||
@Setter
|
@Setter
|
||||||
private boolean analysisDataStoreFlag = false;
|
private boolean analysisDataStoreFlag = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分析数据是否成功
|
||||||
|
*/
|
||||||
|
@Setter
|
||||||
|
private boolean analysisResultFlag = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 能谱处理父类
|
* 能谱处理父类
|
||||||
*/
|
*/
|
||||||
|
@ -163,6 +170,23 @@ public class ParsingProcessLog extends AbstractAutoLogOrReport{
|
||||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||||
|
|
||||||
this.setDetAndGasIdLog();
|
this.setDetAndGasIdLog();
|
||||||
|
//获取analyseResult
|
||||||
|
BgAnalyseResult analyseResult = sample_B_Analysis.analyseResult;
|
||||||
|
if (Objects.nonNull(analyseResult) && !analyseResult.analyse_flag) {
|
||||||
|
analysisResultFlag = true;
|
||||||
|
}
|
||||||
|
//如果分析结果错误
|
||||||
|
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){
|
if (fileNotExist){
|
||||||
// Gas谱或Det谱文件找不到异常结束
|
// Gas谱或Det谱文件找不到异常结束
|
||||||
fileNotExistException();
|
fileNotExistException();
|
||||||
|
@ -184,6 +208,7 @@ public class ParsingProcessLog extends AbstractAutoLogOrReport{
|
||||||
analysisLog.append(titleFormat(analysisResultsEnd,25,StringConstant.DASH,storeFlag,endAnalysisTime,StringConstant.DASH));
|
analysisLog.append(titleFormat(analysisResultsEnd,25,StringConstant.DASH,storeFlag,endAnalysisTime,StringConstant.DASH));
|
||||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理获取Det和Gas文件日志
|
* 处理获取Det和Gas文件日志
|
||||||
|
@ -789,7 +814,7 @@ public class ParsingProcessLog extends AbstractAutoLogOrReport{
|
||||||
this.handleStorageProcessLog();
|
this.handleStorageProcessLog();
|
||||||
if(DataType.SAMPLEPHD.getType().equals(this.spectrumHandler.currDataType.getType()) &&
|
if(DataType.SAMPLEPHD.getType().equals(this.spectrumHandler.currDataType.getType()) &&
|
||||||
this.spectrumHandler.sourceData.system_type.equals(SystemType.BETA.getType()) &&
|
this.spectrumHandler.sourceData.system_type.equals(SystemType.BETA.getType()) &&
|
||||||
this.fileRepeat == false && this.fileNotExist == false){
|
this.fileRepeat == false){
|
||||||
|
|
||||||
this.handleAnalysisProcessLog();
|
this.handleAnalysisProcessLog();
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,10 +39,12 @@ public class QcphdSpectrum extends AbstractS_D_Q_G_SpectrumHandler {
|
||||||
super.parseingEmail();
|
super.parseingEmail();
|
||||||
//读取邮件内容标签
|
//读取邮件内容标签
|
||||||
super.readFileLabel();
|
super.readFileLabel();
|
||||||
//保存PHD文件到savefile
|
//修改能谱文件名称
|
||||||
super.saveFileToSavefile();
|
super.updateSpectrumFileName();
|
||||||
//结构体数据入库
|
//结构体数据入库
|
||||||
super.handlerOriginalData();
|
super.handlerOriginalData();
|
||||||
|
//保存PHD文件到savefile
|
||||||
|
super.saveFileToSavefile();
|
||||||
//修改状态为解析完成
|
//修改状态为解析完成
|
||||||
super.status = SampleStatus.COMPLETE.getValue();
|
super.status = SampleStatus.COMPLETE.getValue();
|
||||||
super.updateStatus();
|
super.updateStatus();
|
||||||
|
@ -55,7 +57,7 @@ public class QcphdSpectrum extends AbstractS_D_Q_G_SpectrumHandler {
|
||||||
super.status = SampleStatus.FAIL.getValue();
|
super.status = SampleStatus.FAIL.getValue();
|
||||||
super.updateStatus();
|
super.updateStatus();
|
||||||
|
|
||||||
//处理解析失败的文件,上传到undeal目录
|
//处理解析失败的文件
|
||||||
super.handleParseingFailFile(e);
|
super.handleParseingFailFile(e);
|
||||||
throw e;
|
throw e;
|
||||||
}finally {
|
}finally {
|
||||||
|
|
|
@ -8,11 +8,14 @@ import org.jeecg.common.constant.StringConstant;
|
||||||
import org.jeecg.common.properties.SpectrumPathProperties;
|
import org.jeecg.common.properties.SpectrumPathProperties;
|
||||||
import org.jeecg.common.util.DateUtils;
|
import org.jeecg.common.util.DateUtils;
|
||||||
import org.jeecg.common.util.NumberFormatUtil;
|
import org.jeecg.common.util.NumberFormatUtil;
|
||||||
|
import org.jeecg.modules.ErrorLogManager;
|
||||||
import org.jeecg.modules.base.dto.Info;
|
import org.jeecg.modules.base.dto.Info;
|
||||||
import org.jeecg.modules.base.entity.original.GardsSampleData;
|
import org.jeecg.modules.base.entity.original.GardsSampleData;
|
||||||
import org.jeecg.modules.base.entity.rnauto.GardsAnalyses;
|
import org.jeecg.modules.base.entity.rnauto.GardsAnalyses;
|
||||||
import org.jeecg.modules.base.enums.*;
|
import org.jeecg.modules.base.enums.*;
|
||||||
import org.jeecg.modules.config.datasource.DataSourceSwitcher;
|
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.BAnalyseException;
|
||||||
import org.jeecg.modules.exception.FileNotExistException;
|
import org.jeecg.modules.exception.FileNotExistException;
|
||||||
import org.jeecg.modules.file.FileOperation;
|
import org.jeecg.modules.file.FileOperation;
|
||||||
|
@ -191,6 +194,7 @@ public class Sample_B_Analysis implements BlockConstant {
|
||||||
parsingProcessLog.setFileNotExist(true);
|
parsingProcessLog.setFileNotExist(true);
|
||||||
|
|
||||||
this.spectrumServiceQuotes.getSampleDataService().updateStatus(SampleStatus.FAIL.getValue(),this.sampleData.getInputFileName());
|
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..");
|
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 {
|
private void autoAnalyse() throws BAnalyseException, FileNotExistException {
|
||||||
BgAnalyseResult analyseResult = EnergySpectrumHandler.bgAnalyse(this.sampleFileFinalPath,this.gasFileFinalPath,this.detFileFinalPath);
|
BgAnalyseResult analyseResult = EnergySpectrumHandler.bgAnalyse(this.sampleFileFinalPath,this.gasFileFinalPath,this.detFileFinalPath);
|
||||||
System.out.println(analyseResult);
|
System.out.println(analyseResult);
|
||||||
|
this.analyseResult = analyseResult;
|
||||||
if(Objects.isNull(analyseResult) || !analyseResult.analyse_flag){
|
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);
|
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){
|
if(flag){
|
||||||
parsingProcessLog.setFileNotExist(true);
|
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..");
|
throw new FileNotExistException("gas or det file is no exist or is error..");
|
||||||
}
|
}
|
||||||
this.detStruct = EnergySpectrumHandler.getSourceData(this.detFileFinalPath);
|
this.detStruct = EnergySpectrumHandler.getSourceData(this.detFileFinalPath);
|
||||||
|
|
|
@ -39,13 +39,14 @@ public class SamplephdSpectrum extends AbstractS_D_Q_G_SpectrumHandler {
|
||||||
super.parseingEmail();
|
super.parseingEmail();
|
||||||
//读取邮件内容标签
|
//读取邮件内容标签
|
||||||
super.readFileLabel();
|
super.readFileLabel();
|
||||||
//保存PHD文件到savefile
|
//修改能谱文件名称
|
||||||
super.saveFileToSavefile();
|
super.updateSpectrumFileName();
|
||||||
//结构体数据入库
|
//结构体数据入库
|
||||||
super.handlerOriginalData();
|
super.handlerOriginalData();
|
||||||
//进行B、G(P)谱分析
|
//进行B、G(P)谱分析
|
||||||
this.autoAnalysis();
|
this.autoAnalysis();
|
||||||
|
//保存PHD文件到savefile
|
||||||
|
super.saveFileToSavefile();
|
||||||
//修改状态为解析完成
|
//修改状态为解析完成
|
||||||
super.status = SampleStatus.COMPLETE.getValue();
|
super.status = SampleStatus.COMPLETE.getValue();
|
||||||
super.updateStatus();
|
super.updateStatus();
|
||||||
|
@ -58,7 +59,7 @@ public class SamplephdSpectrum extends AbstractS_D_Q_G_SpectrumHandler {
|
||||||
super.status = SampleStatus.FAIL.getValue();
|
super.status = SampleStatus.FAIL.getValue();
|
||||||
super.updateStatus();
|
super.updateStatus();
|
||||||
|
|
||||||
//处理解析失败的文件,上传到undeal目录
|
//处理解析失败的文件
|
||||||
super.handleParseingFailFile(e);
|
super.handleParseingFailFile(e);
|
||||||
throw e;
|
throw e;
|
||||||
}finally {
|
}finally {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.jeecg.modules.spectrum;
|
package org.jeecg.modules.spectrum;
|
||||||
|
|
||||||
|
import cn.hutool.core.io.FileUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.jeecg.common.email.EmailLogEvent;
|
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.email.EmailProperties;
|
||||||
import org.jeecg.modules.enums.SpectrumSource;
|
import org.jeecg.modules.enums.SpectrumSource;
|
||||||
import javax.mail.Message;
|
import javax.mail.Message;
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,15 +71,17 @@ public class SpectrumParsingActuator implements Runnable{
|
||||||
//获取邮件主题
|
//获取邮件主题
|
||||||
subject = emailServiceManager.getMailSubject(message);
|
subject = emailServiceManager.getMailSubject(message);
|
||||||
|
|
||||||
//获取邮件内容
|
|
||||||
StringBuilder mailContent = new StringBuilder();
|
|
||||||
emailServiceManager.getMailContent(message,mailContent);
|
|
||||||
|
|
||||||
//所有邮件都需以.eml格式存储到eml文件夹中
|
//所有邮件都需以.eml格式存储到eml文件夹中
|
||||||
emailServiceManager.downloadEmailToEmlDir(message,emailCounter.getCurrValue());
|
final File emlFile = emailServiceManager.downloadEmailToEmlDir(message, emailCounter.getCurrValue());
|
||||||
//保存邮件日志到PG数据库
|
//保存邮件日志到PG数据库
|
||||||
this.spectrumServiceQuotes.getMailLogService().create(message,emailProperties);
|
this.spectrumServiceQuotes.getMailLogService().create(message,emailProperties);
|
||||||
|
|
||||||
|
//获取邮件内容
|
||||||
|
StringBuilder mailContent = new StringBuilder();
|
||||||
|
if(Objects.nonNull(emlFile) && emlFile.length() > 0){
|
||||||
|
mailContent.append(FileUtil.readUtf8String(emlFile));
|
||||||
|
}
|
||||||
|
|
||||||
//判断是否是IMS2.0协议文件
|
//判断是否是IMS2.0协议文件
|
||||||
if(checkMailContent(mailContent,subject)){
|
if(checkMailContent(mailContent,subject)){
|
||||||
AbstractSpectrumHandler spectrumHandler = new SamplephdSpectrum();
|
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 data16 = "Name : %-15s Pass/Fail : %-9s Value : %-14s Test : %-16s";
|
||||||
String qcName = middleData.QC_CHECK_QC_NAME.get(i);
|
String qcName = middleData.QC_CHECK_QC_NAME.get(i);
|
||||||
String qcResult = middleData.QC_CHECK_QC_RESULT.get(i).equals("0") ? "Fail" : "Pass";
|
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);
|
String standard = middleData.QC_CHECK_QC_STANDARD.get(i);
|
||||||
strBuffer.append(rowFormat(data16, qcName, qcResult, qcValue, standard));
|
strBuffer.append(rowFormat(data16, qcName, qcResult, qcValue, standard));
|
||||||
//换行
|
//换行
|
||||||
|
@ -3070,7 +3070,7 @@ public class GammaFileUtil extends AbstractLogOrReport {
|
||||||
//换行
|
//换行
|
||||||
strBuffer.append(System.lineSeparator());
|
strBuffer.append(System.lineSeparator());
|
||||||
for (int i=0;i<middleData.QC_CHECK_QC_NAME.size(); i++){
|
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());
|
strBuffer.append(System.lineSeparator());
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,6 +78,8 @@ public class JeecgAutoProcessApplication extends SpringBootServletInitializer im
|
||||||
checkTempStorageDirectory();
|
checkTempStorageDirectory();
|
||||||
//初始化邮箱邮件声明周期日志
|
//初始化邮箱邮件声明周期日志
|
||||||
EmailLogManager.init(spectrumPathProperties);
|
EmailLogManager.init(spectrumPathProperties);
|
||||||
|
//初始化能谱解析错误日志管理器
|
||||||
|
ErrorLogManager.init(spectrumPathProperties);
|
||||||
//校验存储目录是否存在,不存在则创建,存在无操作
|
//校验存储目录是否存在,不存在则创建,存在无操作
|
||||||
checkStorageDirectory();
|
checkStorageDirectory();
|
||||||
autoProcessManager.start(systemStartupTime);
|
autoProcessManager.start(systemStartupTime);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user