提交 3d4aa2d3 作者: 洪东保

定时器里面都要异步执行

父级 75c404bb
package com.cmeeting.job;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.thread.ThreadUtil;
import com.azure.core.credential.AccessToken;
import com.azure.core.credential.TokenRequestContext;
import com.azure.identity.ClientSecretCredential;
import com.azure.identity.ClientSecretCredentialBuilder;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cmeeting.config.StatisticsEmailPushProperties;
import com.cmeeting.constant.DeptCollect;
......@@ -68,22 +73,23 @@ public class CmeetingJob {
*/
@Scheduled(cron = "0 30 6 * * ?")
public void weComUserSync() {
if (isDev) {
return;
}
ThreadUtil.execute(()-> {
if (!redisUtils.setnx("weComUserSync", "weComUserSync", 20 * 60 * 60)) {
return;
}
try {
log.info("-------企微人员定时同步任务开始-------");
log.info("当前时间: " + LocalDate.now().format(DateTimeFormatter.ISO_LOCAL_DATE));
weComService.doUsers();
log.info("-------企微人员定时同步任务结束--------");
} catch (Exception e) {
e.printStackTrace();
log.error("企微人员定时同步失败");
} finally {
redisUtils.del("weComUserSync");
}
});
}
/**
......@@ -91,9 +97,7 @@ public class CmeetingJob {
*/
@Scheduled(cron = "0 0 7 * * ?")
public void TencentUserSync() {
if (isDev) {
return;
}
ThreadUtil.execute(()-> {
if (!redisUtils.setnx("TencentUserSync", "TencentUserSync", 20 * 60 * 60)) {
return;
}
......@@ -107,6 +111,7 @@ public class CmeetingJob {
} finally {
redisUtils.del("TencentUserSync");
}
});
}
/**
......@@ -114,9 +119,7 @@ public class CmeetingJob {
*/
@Scheduled(cron = "0 20 7 * * ?")
public void userBind() {
if (isDev) {
return;
}
ThreadUtil.execute(()-> {
if (!redisUtils.setnx("userBind", "userBind", 20 * 60 * 60)) {
return;
}
......@@ -129,6 +132,7 @@ public class CmeetingJob {
} finally {
redisUtils.del("userBind");
}
});
}
/**
......@@ -136,6 +140,7 @@ public class CmeetingJob {
*/
@Scheduled(fixedRate = 20 * 60 * 1000, initialDelay = 2 * 60 * 1000)
public void execute() {
ThreadUtil.execute(()-> {
if (isDev) {
return;
}
......@@ -149,25 +154,23 @@ public class CmeetingJob {
Map<String, String> widTidRelations = userIdRelations.stream().collect(Collectors.toMap(UserId::getWid, UserId::getTid));
Map<String, String> tidWidRelations = userIdRelations.stream().collect(Collectors.toMap(UserId::getTid, UserId::getWid));
//查出企微的人员信息
// List<WeComUser> weComUserList = weComService.list();
// Map<String, WeComUser> weComUserMap = weComUserList.stream().collect(Collectors.toMap(WeComUser::getUserId, Function.identity()));
// //智能体授权人员
// List<UserDTO> accessUserIds = tencentMeetingService.getAccessUserIds(widTidRelations);
// if (CollectionUtils.isEmpty(accessUserIds)) {
// log.info("无生成纪要权限的人员");
// return;
// } else {
// log.info("生成纪要权限人员:->{}", accessUserIds.toString());
// }
List<TencentMeetingVO.RecordFile> meetingFiles = tencentMeetingService.getMeetingFiles();
List<WeComUser> weComUserList = weComService.list();
Map<String, WeComUser> weComUserMap = weComUserList.stream().collect(Collectors.toMap(WeComUser::getUserId, Function.identity()));
//智能体授权人员
List<UserDTO> accessUserIds = tencentMeetingService.getAccessUserIds(widTidRelations);
if (CollectionUtils.isEmpty(accessUserIds)) {
log.info("无生成纪要权限的人员");
return;
}
List<TencentMeetingVO.RecordFile> meetingFiles = tencentMeetingService.getMeetingFiles(accessUserIds, weComUserMap);
if (meetingFiles == null || meetingFiles.isEmpty()) {
log.info("没有录制文件需要处理");
return;
}
//获取模板授权的人员--待删没用上
//获取模板授权的人员
List<UserDTO.TemplateAuthorizedUserDTO> authorizedUsers = meetingRecordTemplateService.selectAuthorizedUsers();
// 提交处理任务
......@@ -177,6 +180,7 @@ public class CmeetingJob {
} finally {
redisUtils.del("Scheduled-All");
}
});
}
......@@ -185,6 +189,7 @@ public class CmeetingJob {
*/
@Scheduled(fixedRate = 30 * 60 * 1000, initialDelay = 3 * 60 * 1000)
public void meetingMinutesRetry() {
ThreadUtil.execute(()-> {
if (isDev) {
return;
}
......@@ -236,6 +241,7 @@ public class CmeetingJob {
} finally {
redisUtils.del("Scheduled-retry");
}
});
}
/**
......@@ -243,6 +249,7 @@ public class CmeetingJob {
*/
@Scheduled(fixedRate = 10 * 60 * 1000, initialDelay = 1 * 60 * 1000)
public void emailPushRetry() {
ThreadUtil.execute(()-> {
if (isDev) {
return;
}
......@@ -289,6 +296,7 @@ public class CmeetingJob {
} finally {
redisUtils.del("Scheduled-email-retry");
}
});
}
@Resource
......@@ -305,6 +313,7 @@ public class CmeetingJob {
@Scheduled(cron = "50 59 7,9,11,13,15,17,19,21,23 * * ?")
public void emailStatisticsPush() {
ThreadUtil.execute(()->{
if (isDev) {
return;
}
......@@ -335,7 +344,7 @@ public class CmeetingJob {
try {
boolean b = meetingInfoService.statisticsEmail(subject, simpleDateFormat1.parse(simpleDateFormat.format(date) + " 00:00:00"),
simpleDateFormat1.parse(simpleDateFormat.format(date) + " 23:59:59"), new FileOutputStream(file), DeptCollect.DEPT_MAP);
simpleDateFormat1.parse(simpleDateFormat.format(date) + " 23:59:59"), new FileOutputStream(file));
if (b) {
content = "<p data-olk-copy-source=\\\"MessageBody\\\">Dear all:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;附件为今天Cmeeting会议纪要生成和发送情况,烦请查收。</p>";
StatisticsEmailPush.Attachment attachment = new StatisticsEmailPush.Attachment();
......@@ -356,9 +365,10 @@ public class CmeetingJob {
throw new RuntimeException(e);
} finally {
file.delete();
// redisUtils.del("emailStatisticsPush");
redisUtils.del("emailStatisticsPush");
}
log.info("推送统计邮件完成!");
});
}
......@@ -367,6 +377,7 @@ public class CmeetingJob {
*/
@Scheduled(cron = "0 0 6 * * ? ")
public void pullAllDate() {
ThreadUtil.execute(()-> {
if (isDev) {
return;
}
......@@ -374,6 +385,7 @@ public class CmeetingJob {
long l = System.currentTimeMillis();
cimcService.pullCimcData();
log.info("同步用户结束,耗时: {}ms", System.currentTimeMillis() - l);
});
}
/**
......@@ -381,10 +393,12 @@ public class CmeetingJob {
*/
@Scheduled(cron = "00 59 23 * * ?")
public void deleteDataAfterThan3Months() {
ThreadUtil.execute(()-> {
String date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
log.info("删除2天前的数据开始,开始时间: {}", date);
int count = meetingInfoService.deleteDataAfterThan2Days(date);
log.info("删除2天前的数据结束,删除数量: {}", count);
});
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论