提交 3d4aa2d3 作者: 洪东保

定时器里面都要异步执行

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