提交 f70f8f7d 作者: 洪东保

debug

父级 2392e820
...@@ -98,7 +98,7 @@ public class EmailSender { ...@@ -98,7 +98,7 @@ public class EmailSender {
if(StringUtils.isEmpty(toEmail)){ if(StringUtils.isEmpty(toEmail)){
log.error("收件邮箱为空,推送失败"); log.error("收件邮箱为空,推送失败");
processLogService.log(meetingId,subMeetingId,"收件邮箱为空,推送失败。environment->"+environment+",testReceiver->"+testReceiver+",realEmail->"+emailPushBuilder.getToEmail()); processLogService.log(meetingId,subMeetingId,"收件邮箱为空,推送失败。environment->"+environment+",testReceiver->"+testReceiver+",realEmail->"+emailPushBuilder.getToEmail());
return false; throw new RuntimeException("收件邮箱为空,推送失败");
} }
log.info("准备开始邮件推送..."); log.info("准备开始邮件推送...");
while (retryCount.intValue() < MAX_RETRY && isSent != null && !isSent){ while (retryCount.intValue() < MAX_RETRY && isSent != null && !isSent){
......
...@@ -78,17 +78,18 @@ public class CmeetingJob { ...@@ -78,17 +78,18 @@ public class CmeetingJob {
@Resource @Resource
private EmailSender emailSender; private EmailSender emailSender;
// @PostConstruct // @PostConstruct
public void weComUserInit(){ public void weComUserInit() {
weComUserSync(); weComUserSync();
} }
// @PostConstruct // @PostConstruct
public void tencentUserInit(){ public void tencentUserInit() {
TencentUserSync(); TencentUserSync();
} }
// @PostConstruct
public void userBindInit(){ // @PostConstruct
public void userBindInit() {
userBind(); userBind();
} }
...@@ -97,7 +98,7 @@ public class CmeetingJob { ...@@ -97,7 +98,7 @@ public class CmeetingJob {
*/ */
@Scheduled(cron = "0 30 6 * * ?") @Scheduled(cron = "0 30 6 * * ?")
public void weComUserSync() { public void weComUserSync() {
if (!redisUtils.setnx("weComUserSync", "weComUserSync", 20 * 60 * 60)){ if (!redisUtils.setnx("weComUserSync", "weComUserSync", 20 * 60 * 60)) {
return; return;
} }
try { try {
...@@ -119,7 +120,7 @@ public class CmeetingJob { ...@@ -119,7 +120,7 @@ public class CmeetingJob {
@Scheduled(cron = "0 0 7 * * ?") @Scheduled(cron = "0 0 7 * * ?")
// @Scheduled(fixedRate = 5 * 60 * 1000) // @Scheduled(fixedRate = 5 * 60 * 1000)
public void TencentUserSync() { public void TencentUserSync() {
if (!redisUtils.setnx("TencentUserSync", "TencentUserSync", 20 * 60 * 60)){ if (!redisUtils.setnx("TencentUserSync", "TencentUserSync", 20 * 60 * 60)) {
return; return;
} }
try { try {
...@@ -140,7 +141,7 @@ public class CmeetingJob { ...@@ -140,7 +141,7 @@ public class CmeetingJob {
*/ */
@Scheduled(cron = "0 20 7 * * ?") @Scheduled(cron = "0 20 7 * * ?")
public void userBind() { public void userBind() {
if (!redisUtils.setnx("userBind", "userBind", 20 * 60 * 60)){ if (!redisUtils.setnx("userBind", "userBind", 20 * 60 * 60)) {
return; return;
} }
try { try {
...@@ -155,12 +156,12 @@ public class CmeetingJob { ...@@ -155,12 +156,12 @@ 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() {
if (isDev) { if (isDev) {
return; return;
} }
if (!redisUtils.setnx("Scheduled-All", "Scheduled-All", 18 * 60)){ if (!redisUtils.setnx("Scheduled-All", "Scheduled-All", 18 * 60)) {
return; return;
} }
try { try {
...@@ -192,7 +193,7 @@ public class CmeetingJob { ...@@ -192,7 +193,7 @@ public class CmeetingJob {
// 提交处理任务 // 提交处理任务
producer.submitBatchTasks(meetingFiles, authorizedUsers, tidWidRelations, Boolean.FALSE); producer.submitBatchTasks(meetingFiles, authorizedUsers, tidWidRelations, Boolean.FALSE);
} catch (Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
redisUtils.del("Scheduled-All"); redisUtils.del("Scheduled-All");
...@@ -203,12 +204,12 @@ public class CmeetingJob { ...@@ -203,12 +204,12 @@ public class CmeetingJob {
/** /**
* 定时扫描早于一小时之前的,所有未重试过的会议,重新生成纪要 * 定时扫描早于一小时之前的,所有未重试过的会议,重新生成纪要
*/ */
@Scheduled(fixedRate = 30 * 60 * 1000,initialDelay = 10 * 60 * 1000) @Scheduled(fixedRate = 30 * 60 * 1000, initialDelay = 10 * 60 * 1000)
public void meetingMinutesRetry() { public void meetingMinutesRetry() {
if (isDev) { if (isDev) {
return; return;
} }
if (!redisUtils.setnx("Scheduled-retry", "Scheduled-retry", 28 * 60)){ if (!redisUtils.setnx("Scheduled-retry", "Scheduled-retry", 28 * 60)) {
return; return;
} }
try { try {
...@@ -219,10 +220,10 @@ public class CmeetingJob { ...@@ -219,10 +220,10 @@ public class CmeetingJob {
// 不能用status筛选,因为可能线程执行一般服务终止,status状态没变 // 不能用status筛选,因为可能线程执行一般服务终止,status状态没变
List<MeetingInfo> meetingInfoList = List<MeetingInfo> meetingInfoList =
meetingInfoService.list(new LambdaQueryWrapper<MeetingInfo>() meetingInfoService.list(new LambdaQueryWrapper<MeetingInfo>()
.eq(MeetingInfo::getEmailPushAccess,Boolean.TRUE) .eq(MeetingInfo::getEmailPushAccess, Boolean.TRUE)
.eq(MeetingInfo::getIsGenerated,Boolean.FALSE) .eq(MeetingInfo::getIsGenerated, Boolean.FALSE)
.eq(MeetingInfo::getGenerateRetry,Boolean.FALSE) .eq(MeetingInfo::getGenerateRetry, Boolean.FALSE)
.le(MeetingInfo::getSyncTime,LocalDateTime.now().minusHours(1)) .le(MeetingInfo::getSyncTime, LocalDateTime.now().minusHours(1))
); );
if (meetingInfoList == null || meetingInfoList.isEmpty()) { if (meetingInfoList == null || meetingInfoList.isEmpty()) {
...@@ -240,13 +241,13 @@ public class CmeetingJob { ...@@ -240,13 +241,13 @@ public class CmeetingJob {
//查出企微id和腾会id的关联关系 //查出企微id和腾会id的关联关系
List<UserId> userIdRelations = userIdMapper.selectList(null); List<UserId> userIdRelations = userIdMapper.selectList(null);
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<UserDTO.TemplateAuthorizedUserDTO> authorizedUsers = meetingRecordTemplateService.selectAuthorizedUsers(); List<UserDTO.TemplateAuthorizedUserDTO> authorizedUsers = meetingRecordTemplateService.selectAuthorizedUsers();
// 提交处理任务 // 提交处理任务
producer.submitBatchTasks(meetingFiles,authorizedUsers,tidWidRelations, Boolean.TRUE); producer.submitBatchTasks(meetingFiles, authorizedUsers, tidWidRelations, Boolean.TRUE);
log.info("-------生成纪要重试定时任务结束--------"); log.info("-------生成纪要重试定时任务结束--------");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
...@@ -258,12 +259,12 @@ public class CmeetingJob { ...@@ -258,12 +259,12 @@ 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() {
if (isDev) { if (isDev) {
return; return;
} }
if (!redisUtils.setnx("Scheduled-email-retry", "Scheduled-email-retry", 28 * 60)){ if (!redisUtils.setnx("Scheduled-email-retry", "Scheduled-email-retry", 28 * 60)) {
return; return;
} }
try { try {
...@@ -272,11 +273,11 @@ public class CmeetingJob { ...@@ -272,11 +273,11 @@ public class CmeetingJob {
//查出所有早于一小时前的,邮件推送失败且未重试过的会议 //查出所有早于一小时前的,邮件推送失败且未重试过的会议
List<MeetingInfo> meetingInfoList = List<MeetingInfo> meetingInfoList =
meetingInfoService.list(new LambdaQueryWrapper<MeetingInfo>() meetingInfoService.list(new LambdaQueryWrapper<MeetingInfo>()
.eq(MeetingInfo::getEmailPushAccess,Boolean.TRUE) .eq(MeetingInfo::getEmailPushAccess, Boolean.TRUE)
.eq(MeetingInfo::getIsGenerated,Boolean.TRUE) .eq(MeetingInfo::getIsGenerated, Boolean.TRUE)
.eq(MeetingInfo::getIsPushed,Boolean.FALSE) .eq(MeetingInfo::getIsPushed, Boolean.FALSE)
.eq(MeetingInfo::getPushRetry,Boolean.FALSE) .eq(MeetingInfo::getPushRetry, Boolean.FALSE)
.le(MeetingInfo::getSyncTime,LocalDateTime.now().minusHours(1)) .le(MeetingInfo::getSyncTime, LocalDateTime.now().minusHours(1))
); );
if (meetingInfoList == null || meetingInfoList.isEmpty()) { if (meetingInfoList == null || meetingInfoList.isEmpty()) {
...@@ -313,12 +314,13 @@ public class CmeetingJob { ...@@ -313,12 +314,13 @@ public class CmeetingJob {
@Value(value = "${tencent.base-save-path}") @Value(value = "${tencent.base-save-path}")
private String savePath; private String savePath;
@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() {
if (isDev) { if (isDev) {
return; return;
} }
if (!redisUtils.setnx("emailStatisticsPush", "emailStatisticsPush", 60 * 60)){ if (!redisUtils.setnx("emailStatisticsPush", "emailStatisticsPush", 60 * 60)) {
return; return;
} }
log.info("推送统计邮件开始!"); log.info("推送统计邮件开始!");
...@@ -368,4 +370,65 @@ public class CmeetingJob { ...@@ -368,4 +370,65 @@ public class CmeetingJob {
log.info("推送统计邮件完成!"); log.info("推送统计邮件完成!");
} }
// @Scheduled(cron = "0 0 * * * ?")
public void errorStatisticsPush() {
log.info("errorStatisticsPush");
Date now = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(now);
calendar.add(Calendar.HOUR_OF_DAY, -1);
Date start = calendar.getTime();
List<Integer> statusList = new ArrayList<>();
statusList.add(5);
statusList.add(6);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
List<MeetingInfo> meetingInfoList = meetingInfoService.list(new LambdaQueryWrapper<MeetingInfo>()
.notIn(MeetingInfo::getStatus, statusList)
.between(MeetingInfo::getSyncTime, sdf.format(start), sdf.format(now))
.select(MeetingInfo::getStatus)
);
if (meetingInfoList.size() == 0) {
return;
}
List<Integer> collect = meetingInfoList.stream().map(MeetingInfo::getStatus).collect(Collectors.toList());
if (collect.contains(0) || collect.contains(4)) {
return;
}
int sum = collect.size();
int geneError = 0;
int pushEmailError = 0;
for (Integer integer : collect) {
if (integer == 1){
geneError++;
}
if (integer == 4){
pushEmailError++;
}
}
if (sum > geneError + pushEmailError) {
return;
}
String subject = "会议纪要推送报警";
String content = "<p data-olk-copy-source=\\\"MessageBody\\\">Dear all:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;附件为今天Cmeeting会议纪要生成和发送情况,烦请查收。</p>";
// List<StatisticsEmailPush.Attachment> attachments = new ArrayList<>();
// StatisticsEmailPush.Attachment attachment = new StatisticsEmailPush.Attachment();
// attachment.setName(subject);
// attachment.setBytes(IOUtils.toByteArray(Files.newInputStream(file.toPath())));
// attachments.add(attachment);
StatisticsEmailPush emailPushBuilder = StatisticsEmailPush.builder()
.toEmails(statisticsEmailPushProperties.getToEmails())
// .attachments(attachments)
.subject(subject)
.content(content)
.build();
emailSender.emailStatisticsPush(emailPushBuilder);
}
} }
...@@ -140,7 +140,7 @@ public class EmailPushTask { ...@@ -140,7 +140,7 @@ public class EmailPushTask {
int currentRetryCount = retryCount.getAndIncrement(); int currentRetryCount = retryCount.getAndIncrement();
if (currentRetryCount > MAX_RETRY) { if (currentRetryCount > MAX_RETRY) {
log.error("达到最大重试次数:meetingId {}", meetingId); log.error("达到最大重试次数:meetingId {}", meetingId);
}else{ } else {
// 指数退避 // 指数退避
try { try {
Thread.sleep((long) Math.pow(2, currentRetryCount) * 1000); Thread.sleep((long) Math.pow(2, currentRetryCount) * 1000);
......
...@@ -544,21 +544,25 @@ public class MeetingInfoServiceImpl extends ServiceImpl<MeetingInfoMapper, Meeti ...@@ -544,21 +544,25 @@ public class MeetingInfoServiceImpl extends ServiceImpl<MeetingInfoMapper, Meeti
} }
} }
private static Map<String, String> DEPT_MAP = new HashMap<>(12); private static Map<String, String> DEPT_MAP = new HashMap<>(20);
static { static {
DEPT_MAP.put("10340", "集团总部"); DEPT_MAP.put("10340", "集团总部");
DEPT_MAP.put("11683", "中集车辆(集团)股份有限公司"); DEPT_MAP.put("602700", "能化板块");
DEPT_MAP.put("11080", "中集安瑞科投资控股(深圳)有限公司"); DEPT_MAP.put("616859", "空港板块");
DEPT_MAP.put("635364", "中集管理培训(深圳)有限公司"); DEPT_MAP.put("616766", "集装箱集团");
DEPT_MAP.put("612702", "中集世联达集装箱物流(深圳)有限公司"); DEPT_MAP.put("616844", "车辆板块");
DEPT_MAP.put("661082", "柏坚货柜机械维修(深圳)有限公司"); DEPT_MAP.put("616860", "海工板块");
DEPT_MAP.put("745168", "中集世联达国际物流有限公司"); DEPT_MAP.put("616861", "产城板块");
DEPT_MAP.put("766268", "中铁集物流装备有限公司"); DEPT_MAP.put("640071", "物流板块");
DEPT_MAP.put("698027", "深圳中集同创供应链有限公司"); DEPT_MAP.put("617560", "融资租赁贵公司");
DEPT_MAP.put("674199", "中集模块化建筑投资有限公司");
DEPT_MAP.put("698022", "深圳中集共享后勤服务有限公司");
DEPT_MAP.put("707436", "深圳市集家美寓公寓管理有限公司");
DEPT_MAP.put("640075", "财务公司"); DEPT_MAP.put("640075", "财务公司");
DEPT_MAP.put("641858", "其他类型企业");
DEPT_MAP.put("707435", "集团创新企业");
DEPT_MAP.put("686701", "中集海工");
DEPT_MAP.put("710972", "中集资本");
DEPT_MAP.put("711091", "中集载具");
DEPT_MAP.put("698023", "中集同创");
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论