自动处理报告增加停止标识,如果邮箱启用修改为未启用状态,停止标识设置为true,停止线程代码的执行

This commit is contained in:
qiaoqinzheng 2024-01-02 19:00:29 +08:00
parent 6cf57cf41a
commit bcc049191c
3 changed files with 14 additions and 5 deletions

View File

@ -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());
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);

View File

@ -80,7 +80,7 @@ public class AutoProcessManager{
if(next.isDelFlag()){
if(emailExecThreadMap.containsKey(next.getId())){
EmailParsingActuator actuator = emailExecThreadMap.get(next.getId());
actuator.interrupt();
actuator.setStop(true);
emailExecThreadMap.remove(next.getId());
}
iterator.remove();

View File

@ -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){
@ -50,10 +53,11 @@ public class EmailParsingActuator extends Thread{
@Override
public void run() {
if (this.isInterrupted()) {
for(;;){
if (isStop) {
System.out.println("EmailParsingActuator is Stop!");
return;
}
for(;;){
long start = System.currentTimeMillis();
final EmailServiceManager emailServiceManager = EmailServiceManager.getInstance();
emailServiceManager.init(this.emailProperties,this.taskProperties.getReceiveNum(),this.taskProperties.getTemporaryStoragePath(),this.systemStartupTime, spectrumServiceQuotes.getSpectrumPathProperties());