Merge remote-tracking branch 'origin/mdc' into mdc

This commit is contained in:
qiaoqinzheng 2024-02-26 14:45:49 +08:00
commit 8ae037e4d5
2 changed files with 17 additions and 12 deletions

View File

@ -603,7 +603,7 @@ public class EmailServiceManager {
subject = MimeUtility.decodeText(message.getSubject()); subject = MimeUtility.decodeText(message.getSubject());
receivedDate = message.getReceivedDate(); receivedDate = message.getReceivedDate();
message.setFlag(Flags.Flag.DELETED,true); message.setFlag(Flags.Flag.DELETED,true);
log.info("EmailServiceManager: Remove Email:{},receiveTime:{}",message.getSubject(), DateUtils.formatDate(message.getReceivedDate(),"yyyy-MM-dd HH:mm:ss")); // log.info("EmailServiceManager: Remove Email:{},receiveTime:{}",message.getSubject(), DateUtils.formatDate(message.getReceivedDate(),"yyyy-MM-dd HH:mm:ss"));
} catch (MessagingException | UnsupportedEncodingException e) { } catch (MessagingException | UnsupportedEncodingException e) {
status = EmailLogManager.STATUS_ERROR; status = EmailLogManager.STATUS_ERROR;
log.error("Email deletion failed, the subject of the email is :{}, the reason is :{}.",subject,e.getMessage()); log.error("Email deletion failed, the subject of the email is :{}, the reason is :{}.",subject,e.getMessage());

View File

@ -2,6 +2,7 @@ package org.jeecg.modules.spectrum;
import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.toolkit.StringPool; import com.baomidou.mybatisplus.core.toolkit.StringPool;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -84,13 +85,15 @@ public class SpectrumParsingActuator implements Runnable{
public void run() { public void run() {
String subject = null; String subject = null;
boolean downloadFlag = false; boolean downloadFlag = false;
String receiveDate = null;
try { try {
//获取邮件主题 //获取邮件主题
subject = emailServiceManager.getMailSubject(message,this.batchesCounter); subject = emailServiceManager.getMailSubject(message,this.batchesCounter);
//解析之前先把邮件唯一信息存储到redis //解析之前先把邮件唯一信息存储到redis
String messageId = ((MimeMessage) message).getMessageID(); String messageId = ((MimeMessage) message).getMessageID();
String emlName = subject+ StringConstant.UNDER_LINE+ DateUtils.formatDate(message.getReceivedDate(),"yyyy-MM-dd HH:mm:ss"); receiveDate = DateUtils.formatDate(message.getReceivedDate(),"yyyy-MM-dd HH:mm:ss");
String emlName = subject+ StringConstant.UNDER_LINE+ receiveDate;
String key = RedisConstant.EMAIL_MSG_ID+StringConstant.COLON+messageId; String key = RedisConstant.EMAIL_MSG_ID+StringConstant.COLON+messageId;
spectrumServiceQuotes.getRedisUtil().set(key,emlName,expiryTime); spectrumServiceQuotes.getRedisUtil().set(key,emlName,expiryTime);
//线程开始初始化时初始本线程负责的能谱日志事件 //线程开始初始化时初始本线程负责的能谱日志事件
@ -135,21 +138,23 @@ public class SpectrumParsingActuator implements Runnable{
} }
} }
} catch (Exception e) { } catch (Exception e) {
try {
if (StrUtil.isBlank(subject)) {
subject = message.getSubject();
}
if (StrUtil.isBlank(receiveDate)) {
receiveDate = DateUtils.formatDate(message.getReceivedDate(),"yyyy-MM-dd HH:mm:ss");
}
} catch (MessagingException ex) {
log.error("SpectrumParsingActuator中获取Message信息出现异常", ex);
}
// 如果不是下载导致的失败 并且 下载成功则删除下载的邮件对象 // 如果不是下载导致的失败 并且 下载成功则删除下载的邮件对象
if(!(e instanceof DownloadEmailException) && downloadFlag){ if(!(e instanceof DownloadEmailException) && downloadFlag){
try { log.error("Remove Email"+ subject + StringPool.UNDERSCORE + receiveDate + StringPool.UNDERSCORE);
log.error("Remove Email"+ message.getSubject() + StringPool.UNDERSCORE + DateUtils.formatDate(message.getReceivedDate(), "yyyy-MM-dd HH:mm:ss") + StringPool.UNDERSCORE);
} catch (MessagingException ex) {
throw new RuntimeException(ex);
}
emailServiceManager.removeMail(message,batchesCounter); emailServiceManager.removeMail(message,batchesCounter);
} }
//输出异常信息 //输出异常信息
try { log.error("邮件处理异常{},邮件主题:{}", e, subject);
log.error("邮件处理异常{},邮件主题:{}", e, message.getSubject());
} catch (MessagingException ex) {
ex.printStackTrace();
}
}finally { }finally {
try { try {
EmailLogEvent expungeEvent = new EmailLogEvent(this.batchesCounter,Thread.currentThread().getId(),EmailLogManager.GS_TYPE_GET,EmailLogManager.DONE); EmailLogEvent expungeEvent = new EmailLogEvent(this.batchesCounter,Thread.currentThread().getId(),EmailLogManager.GS_TYPE_GET,EmailLogManager.DONE);