初始化定时任务
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
83ff42c7a8
commit
592bf3dcbf
@ -0,0 +1,25 @@
|
|||||||
|
package com.ruoyi.flyingbook.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 【请填写功能名称】对象 lark_table_relation
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2023-03-15
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class LarkCompanyTableInfo implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private String appId;
|
||||||
|
private String appSecret;
|
||||||
|
private String fromAppToken;
|
||||||
|
private String fromTableId;
|
||||||
|
private String toAppToken;
|
||||||
|
private String toTableId;
|
||||||
|
|
||||||
|
}
|
@ -1,107 +1,79 @@
|
|||||||
package com.ruoyi.flyingbook.mail;
|
package com.ruoyi.flyingbook.mail;
|
||||||
|
|
||||||
import com.ruoyi.flyingbook.mail.request.MailRequest;
|
import com.lark.oapi.service.bitable.v1.model.CreateAppTableRecordRespBody;
|
||||||
|
import com.ruoyi.common.enums.EventOperateType;
|
||||||
|
import com.ruoyi.flyingbook.LarkHelper.LarkTableHelper;
|
||||||
|
import com.ruoyi.flyingbook.domain.Event;
|
||||||
|
import com.ruoyi.flyingbook.domain.EventLog;
|
||||||
|
import com.ruoyi.flyingbook.domain.lark.LarkTableRequest;
|
||||||
|
import com.ruoyi.flyingbook.mapper.EventLogMapper;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Component;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
import javax.mail.*;
|
import javax.mail.Flags;
|
||||||
|
import javax.mail.Message;
|
||||||
import javax.mail.internet.InternetAddress;
|
import javax.mail.internet.InternetAddress;
|
||||||
import javax.mail.internet.MimeUtility;
|
import javax.mail.internet.MimeUtility;
|
||||||
import javax.mail.search.*;
|
import java.util.ArrayList;
|
||||||
import java.security.Security;
|
import java.util.HashMap;
|
||||||
import java.util.Properties;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author yuxiangyong
|
* @author yuxiangyong
|
||||||
* @create 2023-04-09 15:28
|
* @create 2023-04-09 20:27
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
|
||||||
public class MailHelper {
|
public class MailHelper {
|
||||||
|
|
||||||
/**
|
@Autowired
|
||||||
* ssl加密
|
private LarkTableHelper larkTableHelper;
|
||||||
*/
|
@Autowired
|
||||||
private static final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";
|
private EventLogMapper eventLogMapper;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
protected void parseMsg(Message[] messages,LarkTableRequest add) {
|
||||||
MailHelper mailHelper = new MailHelper();
|
|
||||||
MailRequest req = new MailRequest("imap.qq.com",993,"932687738","ohziejkxqvsgbbag");
|
|
||||||
mailHelper.receiveMail(req);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void receiveMail(MailRequest req){
|
|
||||||
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
|
|
||||||
// 定义连接imap服务器的属性信息
|
|
||||||
String portStr = String.valueOf(req.getEmailPort());
|
|
||||||
Properties props = new Properties();
|
|
||||||
props.setProperty("mail.imap.socketFactory.class", SSL_FACTORY);
|
|
||||||
props.setProperty("mail.imap.socketFactory.fallback", "false");
|
|
||||||
props.setProperty("mail.transport.protocol", req.getEmailProtocol());
|
|
||||||
props.setProperty("mail.imap.port", portStr);
|
|
||||||
props.setProperty("mail.imap.socketFactory.port", portStr);
|
|
||||||
|
|
||||||
//创建会话
|
/**
|
||||||
Session session = Session.getInstance(props, new Authenticator() {
|
* 意向度、现有学历、学生姓名、报名时间、手机号码、省市、备注、回放记录、业务员、信息完成度、数据来源、目标国家、所属学校、邮箱来源
|
||||||
@Override
|
*/
|
||||||
protected PasswordAuthentication getPasswordAuthentication() {
|
List<EventLog> logs = new ArrayList<>();
|
||||||
return new PasswordAuthentication(req.getUserName(),req.getAuthorizationCode());
|
for (Message message : messages) {
|
||||||
}
|
|
||||||
});
|
|
||||||
Store store = null;
|
|
||||||
Folder folder = null;
|
|
||||||
try {
|
try {
|
||||||
//存储对象
|
System.out.println("消息:" + message.getSubject());
|
||||||
store = session.getStore(req.getEmailProtocol());
|
String from = MimeUtility.decodeText(message.getFrom()[0].toString());
|
||||||
//连接
|
InternetAddress internetAddress = new InternetAddress(from);
|
||||||
store.connect(req.getEmailServer(),req.getEmailPort(),req.getUserName(),req.getAuthorizationCode());
|
System.out.println("发件人:" + internetAddress.getPersonal() + '(' + internetAddress.getAddress() + ')');
|
||||||
// 获得收件箱
|
String recordId = syncLarkTable(message,add);
|
||||||
folder = store.getFolder(req.getReceiveFolder());
|
this.buildLog(logs,message,recordId,null);
|
||||||
// 以读写模式打开收件箱
|
message.setFlag(Flags.Flag.SEEN, true);
|
||||||
folder.open(Folder.READ_WRITE);
|
|
||||||
//false 表示未读
|
|
||||||
FlagTerm flagTerm = new FlagTerm(new Flags(Flags.Flag.SEEN),false);
|
|
||||||
//获得收件箱的邮件列表
|
|
||||||
Message[] messages = folder.search(flagTerm);
|
|
||||||
// 打印不同状态的邮件数量
|
|
||||||
log.info("收件箱中共{}封邮件!\n共{}封未读邮件!\n共{}封新邮件!\n共{}封已删除邮件!",
|
|
||||||
messages.length,
|
|
||||||
folder.getUnreadMessageCount(),
|
|
||||||
folder.getNewMessageCount(),
|
|
||||||
folder.getDeletedMessageCount());
|
|
||||||
log.info("------------------------开始解析邮件----------------------------------");
|
|
||||||
for (int i = 0; i < messages.length; i++) {
|
|
||||||
Message message = messages[i];
|
|
||||||
parseMsg(message);
|
|
||||||
//设置已读
|
|
||||||
message.setFlag(Flags.Flag.SEEN,true);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("邮件解析失败",e);
|
this.buildLog(logs,message,null,e);
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (folder != null) {
|
|
||||||
folder.close(false);
|
|
||||||
}
|
|
||||||
if (store != null) {
|
|
||||||
store.close();
|
|
||||||
}
|
}
|
||||||
} catch (MessagingException e) {
|
|
||||||
log.error("邮件解析失败",e);
|
|
||||||
}
|
}
|
||||||
|
if (CollectionUtils.isNotEmpty(logs)){
|
||||||
|
eventLogMapper.insertBatchEventLog(logs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseMsg(Message message){
|
private void buildLog(List<EventLog> logs,Message message,String recordId,Exception e){
|
||||||
try {
|
EventLog log = e != null ?
|
||||||
System.out.println("消息:"+ message.getSubject());
|
new EventLog(null, EventOperateType.SYNC_MAIL.getCode(), message.toString())
|
||||||
String from = MimeUtility.decodeText(message.getFrom()[0].toString());
|
: new EventLog(null, EventOperateType.SYNC_MAIL.getCode(), message.toString(),null,e.getMessage());
|
||||||
InternetAddress internetAddress = new InternetAddress(from);
|
log.setRemark(recordId);
|
||||||
System.out.println("发件人:" + internetAddress.getPersonal() + '(' + internetAddress.getAddress() + ')');
|
logs.add(log);
|
||||||
|
}
|
||||||
}catch (Exception e){
|
|
||||||
|
|
||||||
|
private String syncLarkTable(Message message,LarkTableRequest add){
|
||||||
|
Map<String, Object> body = this.buildBody(message);
|
||||||
|
add.setBody(body);
|
||||||
|
CreateAppTableRecordRespBody respBody = larkTableHelper.addTableRecord(add);
|
||||||
|
return respBody.getRecord().getRecordId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected Map<String,Object> buildBody(Message message){
|
||||||
|
return new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,108 @@
|
|||||||
|
package com.ruoyi.flyingbook.mail;
|
||||||
|
|
||||||
|
import com.ruoyi.flyingbook.domain.lark.LarkTableRequest;
|
||||||
|
import com.ruoyi.flyingbook.mail.request.MailRequest;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.mail.*;
|
||||||
|
import javax.mail.internet.InternetAddress;
|
||||||
|
import javax.mail.internet.MimeUtility;
|
||||||
|
import javax.mail.search.FlagTerm;
|
||||||
|
import java.security.Security;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author yuxiangyong
|
||||||
|
* @create 2023-04-09 15:28
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class MailHttpHelper extends MailHelper{
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
MailHttpHelper mailHelper = new MailHttpHelper();
|
||||||
|
MailRequest req = new MailRequest("xjia.synology.me",5000,"xjzsb","12345678");
|
||||||
|
// req = new MailRequest("imap.qq.com",993,"932687738","lwoapikuenmzbfaj");
|
||||||
|
mailHelper.test(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void test(MailRequest req){
|
||||||
|
try {
|
||||||
|
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
|
||||||
|
Properties props = new Properties();
|
||||||
|
props.setProperty("mail.debug","true");
|
||||||
|
// props.setProperty("mail.pop3.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
|
||||||
|
// props.setProperty("mail.pop3.socketFactory.fallback", "false");
|
||||||
|
props.setProperty("mail.transport.protocol", "pop3");
|
||||||
|
Session session = Session.getInstance(props, new Authenticator() {
|
||||||
|
@Override
|
||||||
|
protected PasswordAuthentication getPasswordAuthentication() {
|
||||||
|
return new PasswordAuthentication(req.getUserName(),req.getAuthorizationCode());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Store store = session.getStore("pop3");
|
||||||
|
store.connect(req.getEmailServer(),req.getEmailPort(),req.getUserName(), req.getAuthorizationCode());
|
||||||
|
Folder inbox = store.getFolder("INBOX");
|
||||||
|
}catch (Exception e){
|
||||||
|
log.info("",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void receiveMail(MailRequest req, LarkTableRequest add){
|
||||||
|
// 定义连接imap服务器的属性信息
|
||||||
|
String portStr = String.valueOf(req.getEmailPort());
|
||||||
|
Properties props = new Properties();
|
||||||
|
props.setProperty("mail.smtp.ssl.enable","false");
|
||||||
|
props.setProperty("mail.imap.starttls.enable","true");
|
||||||
|
props.setProperty("mail.imap.socketFactory.fallback", "false");
|
||||||
|
props.setProperty("mail.transport.protocol", req.getEmailProtocol());
|
||||||
|
props.setProperty("mail.imap.port", portStr);
|
||||||
|
props.setProperty("mail.imap.socketFactory.port", portStr);
|
||||||
|
props.setProperty("mail.debug","false");
|
||||||
|
//创建会话
|
||||||
|
Session session = Session.getInstance(props, new Authenticator() {
|
||||||
|
@Override
|
||||||
|
protected PasswordAuthentication getPasswordAuthentication() {
|
||||||
|
return new PasswordAuthentication(req.getUserName(),req.getAuthorizationCode());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Store store = null;
|
||||||
|
Folder folder = null;
|
||||||
|
try {
|
||||||
|
//存储对象
|
||||||
|
store = session.getStore(req.getEmailProtocol());
|
||||||
|
//连接
|
||||||
|
store.connect(req.getEmailServer(),req.getEmailPort(),req.getUserName(),req.getAuthorizationCode());
|
||||||
|
// 获得收件箱
|
||||||
|
folder = store.getFolder(req.getReceiveFolder());
|
||||||
|
// 以读写模式打开收件箱
|
||||||
|
folder.open(Folder.READ_WRITE);
|
||||||
|
//false 表示未读
|
||||||
|
FlagTerm flagTerm = new FlagTerm(new Flags(Flags.Flag.SEEN),false);
|
||||||
|
//获得收件箱的邮件列表
|
||||||
|
Message[] messages = folder.search(flagTerm);
|
||||||
|
// 打印不同状态的邮件数量
|
||||||
|
log.info("收件箱中共{}封邮件!\n共{}封未读邮件!\n共{}封新邮件!\n共{}封已删除邮件!",
|
||||||
|
messages.length,
|
||||||
|
folder.getUnreadMessageCount(),
|
||||||
|
folder.getNewMessageCount(),
|
||||||
|
folder.getDeletedMessageCount());
|
||||||
|
log.info("------------------------开始解析邮件----------------------------------");
|
||||||
|
// this.parseMsg(messages,add);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("邮件解析失败",e);
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if (folder != null) {
|
||||||
|
folder.close(false);
|
||||||
|
}
|
||||||
|
if (store != null) {
|
||||||
|
store.close();
|
||||||
|
}
|
||||||
|
} catch (MessagingException e) {
|
||||||
|
log.error("邮件解析失败",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,107 @@
|
|||||||
|
package com.ruoyi.flyingbook.mail;
|
||||||
|
|
||||||
|
import com.ruoyi.flyingbook.mail.request.MailRequest;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.mail.*;
|
||||||
|
import javax.mail.internet.InternetAddress;
|
||||||
|
import javax.mail.internet.MimeUtility;
|
||||||
|
import javax.mail.search.*;
|
||||||
|
import java.security.Security;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author yuxiangyong
|
||||||
|
* @create 2023-04-09 15:28
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class MailTencentHelper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ssl加密
|
||||||
|
*/
|
||||||
|
private static final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
MailTencentHelper mailHelper = new MailTencentHelper();
|
||||||
|
MailRequest req = new MailRequest("imap.qq.com",993,"932687738","ohziejkxqvsgbbag");
|
||||||
|
mailHelper.receiveMail(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void receiveMail(MailRequest req){
|
||||||
|
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
|
||||||
|
// 定义连接imap服务器的属性信息
|
||||||
|
String portStr = String.valueOf(req.getEmailPort());
|
||||||
|
Properties props = new Properties();
|
||||||
|
props.setProperty("mail.imap.socketFactory.class", SSL_FACTORY);
|
||||||
|
props.setProperty("mail.imap.socketFactory.fallback", "false");
|
||||||
|
props.setProperty("mail.transport.protocol", req.getEmailProtocol());
|
||||||
|
props.setProperty("mail.imap.port", portStr);
|
||||||
|
props.setProperty("mail.imap.socketFactory.port", portStr);
|
||||||
|
|
||||||
|
//创建会话
|
||||||
|
Session session = Session.getInstance(props, new Authenticator() {
|
||||||
|
@Override
|
||||||
|
protected PasswordAuthentication getPasswordAuthentication() {
|
||||||
|
return new PasswordAuthentication(req.getUserName(),req.getAuthorizationCode());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Store store = null;
|
||||||
|
Folder folder = null;
|
||||||
|
try {
|
||||||
|
//存储对象
|
||||||
|
store = session.getStore(req.getEmailProtocol());
|
||||||
|
//连接
|
||||||
|
store.connect(req.getEmailServer(),req.getEmailPort(),req.getUserName(),req.getAuthorizationCode());
|
||||||
|
// 获得收件箱
|
||||||
|
folder = store.getFolder(req.getReceiveFolder());
|
||||||
|
// 以读写模式打开收件箱
|
||||||
|
folder.open(Folder.READ_WRITE);
|
||||||
|
//false 表示未读
|
||||||
|
FlagTerm flagTerm = new FlagTerm(new Flags(Flags.Flag.SEEN),false);
|
||||||
|
//获得收件箱的邮件列表
|
||||||
|
Message[] messages = folder.search(flagTerm);
|
||||||
|
// 打印不同状态的邮件数量
|
||||||
|
log.info("收件箱中共{}封邮件!\n共{}封未读邮件!\n共{}封新邮件!\n共{}封已删除邮件!",
|
||||||
|
messages.length,
|
||||||
|
folder.getUnreadMessageCount(),
|
||||||
|
folder.getNewMessageCount(),
|
||||||
|
folder.getDeletedMessageCount());
|
||||||
|
log.info("------------------------开始解析邮件----------------------------------");
|
||||||
|
for (int i = 0; i < messages.length; i++) {
|
||||||
|
Message message = messages[i];
|
||||||
|
parseMsg(message);
|
||||||
|
//设置已读
|
||||||
|
message.setFlag(Flags.Flag.SEEN,true);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("邮件解析失败",e);
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if (folder != null) {
|
||||||
|
folder.close(false);
|
||||||
|
}
|
||||||
|
if (store != null) {
|
||||||
|
store.close();
|
||||||
|
}
|
||||||
|
} catch (MessagingException e) {
|
||||||
|
log.error("邮件解析失败",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parseMsg(Message message){
|
||||||
|
try {
|
||||||
|
System.out.println("消息:"+ message.getSubject());
|
||||||
|
String from = MimeUtility.decodeText(message.getFrom()[0].toString());
|
||||||
|
InternetAddress internetAddress = new InternetAddress(from);
|
||||||
|
System.out.println("发件人:" + internetAddress.getPersonal() + '(' + internetAddress.getAddress() + ')');
|
||||||
|
|
||||||
|
}catch (Exception e){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,94 @@
|
|||||||
|
package com.ruoyi.quartz.task;
|
||||||
|
|
||||||
|
import com.ruoyi.common.enums.FlagStatus;
|
||||||
|
import com.ruoyi.common.enums.TableRelationTypeEnum;
|
||||||
|
import com.ruoyi.flyingbook.domain.LarkCompanyTableInfo;
|
||||||
|
import com.ruoyi.flyingbook.domain.MailInfo;
|
||||||
|
import com.ruoyi.flyingbook.domain.lark.LarkTableRequest;
|
||||||
|
import com.ruoyi.flyingbook.mail.MailHttpHelper;
|
||||||
|
import com.ruoyi.flyingbook.mail.request.MailRequest;
|
||||||
|
import com.ruoyi.flyingbook.mapper.LarkTableRelationMapper;
|
||||||
|
import com.ruoyi.flyingbook.service.IMailInfoService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定时任务调度测试
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component("mailSyncTask")
|
||||||
|
public class MailSyncTask {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MailHttpHelper mailHttpHelper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IMailInfoService iMailInfoService;
|
||||||
|
@Autowired
|
||||||
|
private LarkTableRelationMapper larkTableRelationMapper;
|
||||||
|
|
||||||
|
public void syncMail() {
|
||||||
|
log.info("MailSyncTask start");
|
||||||
|
MailInfo mailInfo = new MailInfo();
|
||||||
|
mailInfo.setFlag(FlagStatus.OK.getCode());
|
||||||
|
List<MailInfo> mailInfos = iMailInfoService.selectMailInfoList(mailInfo);
|
||||||
|
log.info("MailSyncTask execute size:{}", mailInfos.size());
|
||||||
|
Map<Long, LarkTableRequest> larkMap = this.getLarkMap(mailInfos);
|
||||||
|
|
||||||
|
for (MailInfo info : mailInfos) {
|
||||||
|
LarkTableRequest addRequest = larkMap.get(info.getLarkTableId());
|
||||||
|
if (addRequest == null) {
|
||||||
|
log.info("待同步邮箱未配置飞书相关信息,mailInfo:{}", info);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
MailRequest request = new MailRequest(info, Boolean.TRUE);
|
||||||
|
mailHttpHelper.receiveMail(request,addRequest);
|
||||||
|
}
|
||||||
|
log.info("MailSyncTask end");
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<Long, LarkTableRequest> getLarkMap(List<MailInfo> mailInfos) {
|
||||||
|
List<Long> tableIds = mailInfos.stream()
|
||||||
|
.filter(r -> {
|
||||||
|
return r.getLarkTableId() != null;
|
||||||
|
})
|
||||||
|
.map(MailInfo::getLarkTableId)
|
||||||
|
.distinct()
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if (CollectionUtils.isEmpty(tableIds)) {
|
||||||
|
return new HashMap<>();
|
||||||
|
}
|
||||||
|
List<LarkCompanyTableInfo> larkCompanyTableInfos = larkTableRelationMapper.queryListByIdListJoinLarkCompany(tableIds, FlagStatus.OK.getCode(), TableRelationTypeEnum.SYNC_EMAIL.getCode());
|
||||||
|
return larkCompanyTableInfos.stream()
|
||||||
|
.filter(r -> {
|
||||||
|
return r.getId() != null
|
||||||
|
&& StringUtils.isNotBlank(r.getAppId())
|
||||||
|
&& StringUtils.isNotBlank(r.getAppSecret())
|
||||||
|
&& StringUtils.isNotBlank(r.getToAppToken())
|
||||||
|
&& StringUtils.isNotBlank(r.getToTableId());
|
||||||
|
})
|
||||||
|
.map(r -> {
|
||||||
|
LarkTableRequest request = new LarkTableRequest();
|
||||||
|
request.setId(r.getId());
|
||||||
|
request.setAppId(r.getAppId());
|
||||||
|
request.setAppSecret(r.getAppSecret());
|
||||||
|
request.setAppToken(r.getToAppToken());
|
||||||
|
request.setAppTable(r.getToTableId());
|
||||||
|
return request;
|
||||||
|
})
|
||||||
|
.collect(
|
||||||
|
Collectors.toMap(LarkTableRequest::getId, Function.identity(), (k1, k2) -> k1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue