email发送bug修复
This commit is contained in:
parent
75754b5246
commit
f346f9e8b8
|
|
@ -24,6 +24,10 @@ public class EmailService {
|
|||
|
||||
private Logger logger = LogManager.getLogger(EmailService.class);
|
||||
|
||||
private static final Integer EMAIL_JOB_NOT_DISPATCHED = -1; //处理成功
|
||||
private static final Integer EMAIL_JOB_DISPATCHED_SUCCESS = 1; //处理成功
|
||||
private static final Integer EMAIL_JOB_DISPATCHED_FAIL = 2; //处理失败
|
||||
|
||||
@Autowired
|
||||
private EmailJobsService emailJobsService;
|
||||
|
||||
|
|
@ -46,7 +50,7 @@ public class EmailService {
|
|||
//获取指定数量待处理列表
|
||||
List<EmailJob> emailJobList = new ArrayList<>();
|
||||
try {
|
||||
emailJobList = emailJobsService.getEmailJobsByDispatchedStatus(platform, -1, dispatchNumber);
|
||||
emailJobList = emailJobsService.getEmailJobsByDispatchedStatus(platform, EMAIL_JOB_NOT_DISPATCHED, dispatchNumber);
|
||||
} catch (Exception e) {
|
||||
logger.error("获取未处理邮件任务列表失败:\n" + e);
|
||||
}
|
||||
|
|
@ -61,7 +65,7 @@ public class EmailService {
|
|||
}
|
||||
//EmailJob分配成功,更新状态
|
||||
try {
|
||||
emailJobsService.markEmailJobsAs(platform, emailJob.getId(), new Date(), flag ? 1 : 2);
|
||||
emailJobsService.markEmailJobsAs(platform, emailJob.getId(), new Date(), flag ? EMAIL_JOB_DISPATCHED_SUCCESS : EMAIL_JOB_DISPATCHED_FAIL);
|
||||
} catch (Exception e) {
|
||||
logger.error("更新EmailJob状态失败,email_job_id: " + emailJob.getId() + "\n" + e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,5 +24,6 @@ public interface EmailSendRecordsMapper extends BaseMapper<EmailSendRecord> {
|
|||
|
||||
List<EmailSendRecord> getRecordsByStatus(@Param("platform") String platform, @Param("status") Integer status, @Param("size") Integer sentNumber);
|
||||
|
||||
//批量更新邮件发送任务记录
|
||||
int updateEmailSendRecordsBatch(@Param("platform") String platform, @Param("list") List<EmailSendRecord> emailSendRecordList);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,10 +5,7 @@ import cn.org.gitlink.notification.model.dao.entity.vo.NewEmailJobVo;
|
|||
import cn.org.gitlink.notification.model.dao.mapper.EmailJobsMapper;
|
||||
import cn.org.gitlink.notification.model.service.notification.EmailJobsService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
|
|
@ -18,11 +17,11 @@ public class EmailSendRecordsServiceImpl extends ServiceImpl<EmailSendRecordsMap
|
|||
@Override
|
||||
@Transactional
|
||||
public boolean newEmailSendRecords(String platform, String emails, Integer jobId) {
|
||||
EmailSendRecord emailSendRecord = new EmailSendRecord();
|
||||
emailSendRecord.setJobId(jobId);
|
||||
List<String> list = Arrays.asList(emails.split(","));
|
||||
List<EmailSendRecord> emailSendRecordList = new ArrayList<EmailSendRecord>();
|
||||
for (String email : list){
|
||||
EmailSendRecord emailSendRecord = new EmailSendRecord();
|
||||
emailSendRecord.setJobId(jobId);
|
||||
emailSendRecord.setEmail(email);
|
||||
emailSendRecordList.add(emailSendRecord);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue