Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
cmeeting
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
翟斌
cmeeting
Commits
e23da381
提交
e23da381
authored
11月 28, 2025
作者:
洪东保
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
定时器里面都要异步执行
父级
99424384
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
228 行增加
和
213 行删除
+228
-213
src/main/java/com/cmeeting/job/CmeetingJob.java
+228
-213
没有找到文件。
src/main/java/com/cmeeting/job/CmeetingJob.java
浏览文件 @
e23da381
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
;
...
...
@@ -83,21 +84,23 @@ public class CmeetingJob {
*/
@Scheduled
(
cron
=
"0 30 6 * * ?"
)
public
void
weComUserSync
()
{
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"
);
}
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"
);
}
});
}
/**
...
...
@@ -106,20 +109,22 @@ public class CmeetingJob {
@Scheduled
(
cron
=
"0 0 7 * * ?"
)
// @Scheduled(fixedRate = 5 * 60 * 1000)
public
void
TencentUserSync
()
{
if
(!
redisUtils
.
setnx
(
"TencentUserSync"
,
"TencentUserSync"
,
20
*
60
*
60
))
{
return
;
}
try
{
log
.
info
(
"-------腾讯会议人员定时同步任务开始-------"
);
log
.
info
(
"当前时间: "
+
LocalDate
.
now
().
format
(
DateTimeFormatter
.
ISO_LOCAL_DATE
));
tencentMeetingService
.
doUsers
();
log
.
info
(
"-------腾讯会议人员定时同步任务结束--------"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
redisUtils
.
del
(
"TencentUserSync"
);
}
ThreadUtil
.
execute
(()->
{
if
(!
redisUtils
.
setnx
(
"TencentUserSync"
,
"TencentUserSync"
,
20
*
60
*
60
))
{
return
;
}
try
{
log
.
info
(
"-------腾讯会议人员定时同步任务开始-------"
);
log
.
info
(
"当前时间: "
+
LocalDate
.
now
().
format
(
DateTimeFormatter
.
ISO_LOCAL_DATE
));
tencentMeetingService
.
doUsers
();
log
.
info
(
"-------腾讯会议人员定时同步任务结束--------"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
redisUtils
.
del
(
"TencentUserSync"
);
}
});
}
/**
...
...
@@ -127,61 +132,65 @@ public class CmeetingJob {
*/
@Scheduled
(
cron
=
"0 20 7 * * ?"
)
public
void
userBind
()
{
if
(!
redisUtils
.
setnx
(
"userBind"
,
"userBind"
,
20
*
60
*
60
))
{
return
;
}
try
{
log
.
info
(
"-------关联企微腾会人员定时任务开始-------"
);
log
.
info
(
"当前时间: "
+
LocalDate
.
now
().
format
(
DateTimeFormatter
.
ISO_LOCAL_DATE
));
weComService
.
userBind
();
log
.
info
(
"-------关联企微腾会人员定时任务结束--------"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
redisUtils
.
del
(
"userBind"
);
}
ThreadUtil
.
execute
(()->
{
if
(!
redisUtils
.
setnx
(
"userBind"
,
"userBind"
,
20
*
60
*
60
))
{
return
;
}
try
{
log
.
info
(
"-------关联企微腾会人员定时任务开始-------"
);
log
.
info
(
"当前时间: "
+
LocalDate
.
now
().
format
(
DateTimeFormatter
.
ISO_LOCAL_DATE
));
weComService
.
userBind
();
log
.
info
(
"-------关联企微腾会人员定时任务结束--------"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
redisUtils
.
del
(
"userBind"
);
}
});
}
@Scheduled
(
fixedRate
=
20
*
60
*
1000
,
initialDelay
=
1
*
60
*
1000
)
public
void
execute
()
{
if
(
isDev
)
{
return
;
}
if
(!
redisUtils
.
setnx
(
"Scheduled-All"
,
"Scheduled-All"
,
18
*
60
))
{
return
;
}
try
{
//查出企微id和腾会id的关联关系
List
<
UserId
>
userIdRelations
=
userIdMapper
.
selectList
(
null
);
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
(
"无生成纪要权限的人员"
);
ThreadUtil
.
execute
(()->
{
if
(
isDev
)
{
return
;
}
List
<
TencentMeetingVO
.
RecordFile
>
meetingFiles
=
tencentMeetingService
.
getMeetingFiles
(
accessUserIds
,
weComUserMap
);
if
(
meetingFiles
==
null
||
meetingFiles
.
isEmpty
())
{
log
.
info
(
"没有录制文件需要处理"
);
if
(!
redisUtils
.
setnx
(
"Scheduled-All"
,
"Scheduled-All"
,
18
*
60
))
{
return
;
}
try
{
//查出企微id和腾会id的关联关系
List
<
UserId
>
userIdRelations
=
userIdMapper
.
selectList
(
null
);
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
;
}
List
<
TencentMeetingVO
.
RecordFile
>
meetingFiles
=
tencentMeetingService
.
getMeetingFiles
(
accessUserIds
,
weComUserMap
);
//获取模板授权的人员
List
<
UserDTO
.
TemplateAuthorizedUserDTO
>
authorizedUsers
=
meetingRecordTemplateService
.
selectAuthorizedUsers
();
if
(
meetingFiles
==
null
||
meetingFiles
.
isEmpty
())
{
log
.
info
(
"没有录制文件需要处理"
);
return
;
}
// 提交处理任务
producer
.
submitBatchTasks
(
meetingFiles
,
authorizedUsers
,
tidWidRelations
,
Boolean
.
FALSE
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
redisUtils
.
del
(
"Scheduled-All"
);
}
//获取模板授权的人员
List
<
UserDTO
.
TemplateAuthorizedUserDTO
>
authorizedUsers
=
meetingRecordTemplateService
.
selectAuthorizedUsers
();
// 提交处理任务
producer
.
submitBatchTasks
(
meetingFiles
,
authorizedUsers
,
tidWidRelations
,
Boolean
.
FALSE
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
redisUtils
.
del
(
"Scheduled-All"
);
}
});
}
...
...
@@ -190,110 +199,114 @@ public class CmeetingJob {
*/
@Scheduled
(
fixedRate
=
30
*
60
*
1000
,
initialDelay
=
3
*
60
*
1000
)
public
void
meetingMinutesRetry
()
{
if
(
isDev
)
{
return
;
}
if
(!
redisUtils
.
setnx
(
"Scheduled-retry"
,
"Scheduled-retry"
,
28
*
60
))
{
return
;
}
try
{
log
.
info
(
"-------生成纪要重试定时任务开始-------"
);
log
.
info
(
"当前时间: "
+
LocalDate
.
now
().
format
(
DateTimeFormatter
.
ISO_LOCAL_DATE
));
//查出所有早于一小时前的,生成失败且未重试过的会议
// 不能用status筛选,因为可能线程执行一般服务终止,status状态没变
List
<
MeetingInfo
>
meetingInfoList
=
meetingInfoService
.
list
(
new
LambdaQueryWrapper
<
MeetingInfo
>()
.
isNotNull
(
MeetingInfo:
:
getMeetingRecordId
)
.
eq
(
MeetingInfo:
:
getEmailPushAccess
,
Boolean
.
TRUE
)
.
eq
(
MeetingInfo:
:
getIsGenerated
,
Boolean
.
FALSE
)
.
eq
(
MeetingInfo:
:
getGenerateRetry
,
Boolean
.
FALSE
)
.
ne
(
MeetingInfo:
:
getStatus
,
MeetingState
.
EMPTY
.
getCode
())
.
le
(
MeetingInfo:
:
getSyncTime
,
LocalDateTime
.
now
().
minusHours
(
1
))
);
if
(
meetingInfoList
==
null
||
meetingInfoList
.
isEmpty
())
{
log
.
info
(
"没有生成失败的会议需要重试"
);
ThreadUtil
.
execute
(()->
{
if
(
isDev
)
{
return
;
}
List
<
TencentMeetingVO
.
RecordFile
>
meetingFiles
=
new
ArrayList
<>();
for
(
MeetingInfo
meetingInfo
:
meetingInfoList
)
{
TencentMeetingVO
.
RecordFile
recordFile
=
TencentMeetingVO
.
RecordFile
.
builder
()
.
meetingId
(
meetingInfo
.
getMeetingId
())
.
meetingRecordId
(
meetingInfo
.
getMeetingRecordId
())
.
subMeetingId
(
meetingInfo
.
getSubMeetingId
())
.
recordFileIdList
(
Arrays
.
asList
(
meetingInfo
.
getRecordFileId
().
split
(
","
))).
build
();
meetingFiles
.
add
(
recordFile
);
if
(!
redisUtils
.
setnx
(
"Scheduled-retry"
,
"Scheduled-retry"
,
28
*
60
))
{
return
;
}
//查出企微id和腾会id的关联关系
List
<
UserId
>
userIdRelations
=
userIdMapper
.
selectList
(
null
);
Map
<
String
,
String
>
tidWidRelations
=
userIdRelations
.
stream
().
collect
(
Collectors
.
toMap
(
UserId:
:
getTid
,
UserId:
:
getWid
));
//获取模板授权的人员
List
<
UserDTO
.
TemplateAuthorizedUserDTO
>
authorizedUsers
=
meetingRecordTemplateService
.
selectAuthorizedUsers
();
// 提交处理任务
producer
.
submitBatchTasks
(
meetingFiles
,
authorizedUsers
,
tidWidRelations
,
Boolean
.
TRUE
);
log
.
info
(
"-------生成纪要重试定时任务结束--------"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
redisUtils
.
del
(
"Scheduled-retry"
);
}
}
/**
* 定时扫描早于一小时之前的,所有邮件推送未重试过的会议,重新推送邮件
*/
@Scheduled
(
fixedRate
=
10
*
60
*
1000
,
initialDelay
=
1
*
60
*
1000
)
public
void
emailPushRetry
()
{
if
(
isDev
)
{
return
;
}
if
(!
redisUtils
.
setnx
(
"Scheduled-email-retry"
,
"Scheduled-email-retry"
,
28
*
60
))
{
return
;
}
try
{
log
.
info
(
"-------邮件推送重试定时任务开始-------"
);
//查出所有早于一小时前的,邮件推送失败且未重试过的会议
List
<
MeetingInfo
>
meetingInfoList
=
meetingInfoService
.
list
(
new
LambdaQueryWrapper
<
MeetingInfo
>()
.
isNotNull
(
MeetingInfo:
:
getMeetingRecordId
)
.
eq
(
MeetingInfo:
:
getEmailPushAccess
,
Boolean
.
TRUE
)
.
eq
(
MeetingInfo:
:
getIsGenerated
,
Boolean
.
TRUE
)
.
eq
(
MeetingInfo:
:
getIsPushed
,
Boolean
.
FALSE
)
.
eq
(
MeetingInfo:
:
getPushRetry
,
Boolean
.
FALSE
)
.
le
(
MeetingInfo:
:
getSyncTime
,
LocalDateTime
.
now
().
minusHours
(
1
))
);
if
(
meetingInfoList
==
null
||
meetingInfoList
.
isEmpty
())
{
log
.
info
(
"没有推送失败的邮件需要重试"
);
}
else
{
try
{
log
.
info
(
"-------生成纪要重试定时任务开始-------"
);
log
.
info
(
"当前时间: "
+
LocalDate
.
now
().
format
(
DateTimeFormatter
.
ISO_LOCAL_DATE
));
//查出所有早于一小时前的,生成失败且未重试过的会议
// 不能用status筛选,因为可能线程执行一般服务终止,status状态没变
List
<
MeetingInfo
>
meetingInfoList
=
meetingInfoService
.
list
(
new
LambdaQueryWrapper
<
MeetingInfo
>()
.
isNotNull
(
MeetingInfo:
:
getMeetingRecordId
)
.
eq
(
MeetingInfo:
:
getEmailPushAccess
,
Boolean
.
TRUE
)
.
eq
(
MeetingInfo:
:
getIsGenerated
,
Boolean
.
FALSE
)
.
eq
(
MeetingInfo:
:
getGenerateRetry
,
Boolean
.
FALSE
)
.
ne
(
MeetingInfo:
:
getStatus
,
MeetingState
.
EMPTY
.
getCode
())
.
le
(
MeetingInfo:
:
getSyncTime
,
LocalDateTime
.
now
().
minusHours
(
1
))
);
if
(
meetingInfoList
==
null
||
meetingInfoList
.
isEmpty
())
{
log
.
info
(
"没有生成失败的会议需要重试"
);
return
;
}
List
<
TencentMeetingVO
.
RecordFile
>
meetingFiles
=
new
ArrayList
<>();
for
(
MeetingInfo
meetingInfo
:
meetingInfoList
)
{
TencentMeetingVO
.
RecordFile
recordFile
=
TencentMeetingVO
.
RecordFile
.
builder
()
.
meetingId
(
meetingInfo
.
getMeetingId
())
.
subMeetingId
(
meetingInfo
.
getSubMeetingId
())
.
meetingRecordId
(
meetingInfo
.
getMeetingRecordId
())
.
recordFileIdList
(
Arrays
.
asList
(
meetingInfo
.
getRecordFileId
().
split
(
","
)
))
.
build
();
.
subMeetingId
(
meetingInfo
.
getSubMeetingId
(
))
.
recordFileIdList
(
Arrays
.
asList
(
meetingInfo
.
getRecordFileId
().
split
(
","
))).
build
();
meetingFiles
.
add
(
recordFile
);
}
//查出企微id和腾会id的关联关系
List
<
UserId
>
userIdRelations
=
userIdMapper
.
selectList
(
null
);
Map
<
String
,
String
>
tidWidRelations
=
userIdRelations
.
stream
().
collect
(
Collectors
.
toMap
(
UserId:
:
getTid
,
UserId:
:
getWid
));
//获取模板授权的人员
List
<
UserDTO
.
TemplateAuthorizedUserDTO
>
authorizedUsers
=
meetingRecordTemplateService
.
selectAuthorizedUsers
();
// 提交处理任务
producer
.
submitEmailPushTasks
(
meetingFiles
,
tidWidRelations
);
producer
.
submitBatchTasks
(
meetingFiles
,
authorizedUsers
,
tidWidRelations
,
Boolean
.
TRUE
);
log
.
info
(
"-------生成纪要重试定时任务结束--------"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
redisUtils
.
del
(
"Scheduled-retry"
);
}
log
.
info
(
"-------邮件推送重试定时任务结束--------"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
redisUtils
.
del
(
"Scheduled-email-retry"
);
}
});
}
/**
* 定时扫描早于一小时之前的,所有邮件推送未重试过的会议,重新推送邮件
*/
@Scheduled
(
fixedRate
=
10
*
60
*
1000
,
initialDelay
=
1
*
60
*
1000
)
public
void
emailPushRetry
()
{
ThreadUtil
.
execute
(()->
{
if
(
isDev
)
{
return
;
}
if
(!
redisUtils
.
setnx
(
"Scheduled-email-retry"
,
"Scheduled-email-retry"
,
28
*
60
))
{
return
;
}
try
{
log
.
info
(
"-------邮件推送重试定时任务开始-------"
);
//查出所有早于一小时前的,邮件推送失败且未重试过的会议
List
<
MeetingInfo
>
meetingInfoList
=
meetingInfoService
.
list
(
new
LambdaQueryWrapper
<
MeetingInfo
>()
.
isNotNull
(
MeetingInfo:
:
getMeetingRecordId
)
.
eq
(
MeetingInfo:
:
getEmailPushAccess
,
Boolean
.
TRUE
)
.
eq
(
MeetingInfo:
:
getIsGenerated
,
Boolean
.
TRUE
)
.
eq
(
MeetingInfo:
:
getIsPushed
,
Boolean
.
FALSE
)
.
eq
(
MeetingInfo:
:
getPushRetry
,
Boolean
.
FALSE
)
.
le
(
MeetingInfo:
:
getSyncTime
,
LocalDateTime
.
now
().
minusHours
(
1
))
);
if
(
meetingInfoList
==
null
||
meetingInfoList
.
isEmpty
())
{
log
.
info
(
"没有推送失败的邮件需要重试"
);
}
else
{
List
<
TencentMeetingVO
.
RecordFile
>
meetingFiles
=
new
ArrayList
<>();
for
(
MeetingInfo
meetingInfo
:
meetingInfoList
)
{
TencentMeetingVO
.
RecordFile
recordFile
=
TencentMeetingVO
.
RecordFile
.
builder
()
.
meetingId
(
meetingInfo
.
getMeetingId
())
.
subMeetingId
(
meetingInfo
.
getSubMeetingId
())
.
meetingRecordId
(
meetingInfo
.
getMeetingRecordId
())
.
recordFileIdList
(
Arrays
.
asList
(
meetingInfo
.
getRecordFileId
().
split
(
","
)))
.
build
();
meetingFiles
.
add
(
recordFile
);
}
//查出企微id和腾会id的关联关系
List
<
UserId
>
userIdRelations
=
userIdMapper
.
selectList
(
null
);
Map
<
String
,
String
>
tidWidRelations
=
userIdRelations
.
stream
().
collect
(
Collectors
.
toMap
(
UserId:
:
getTid
,
UserId:
:
getWid
));
// 提交处理任务
producer
.
submitEmailPushTasks
(
meetingFiles
,
tidWidRelations
);
}
log
.
info
(
"-------邮件推送重试定时任务结束--------"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
redisUtils
.
del
(
"Scheduled-email-retry"
);
}
});
}
@Resource
...
...
@@ -308,58 +321,60 @@ public class CmeetingJob {
@Scheduled
(
cron
=
"50 59 7,9,11,13,15,17,19,21,23 * * ?"
)
public
void
emailStatisticsPush
()
{
if
(
isDev
)
{
return
;
}
log
.
info
(
"推送统计邮件!"
);
if
(!
redisUtils
.
setnx
(
"emailStatisticsPush"
,
"emailStatisticsPush"
,
4000
))
{
return
;
}
log
.
info
(
"推送统计邮件开始!"
);
List
<
StatisticsEmailPush
.
Attachment
>
attachments
=
new
ArrayList
<>();
Date
date
=
new
Date
();
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
date
);
calendar
.
add
(
Calendar
.
HOUR_OF_DAY
,
1
);
// 增加 1 小时
Date
newDate
=
calendar
.
getTime
();
// 返回增加后的 Date 对象
String
subject
=
"会议纪要推送记录-"
+
new
SimpleDateFormat
(
"yyyyMMdd HH"
).
format
(
newDate
)
+
":00"
;
String
content
;
if
(
CollUtil
.
isEmpty
(
statisticsEmailPushProperties
.
getToEmails
()))
{
log
.
error
(
"收件人为空!"
);
return
;
}
File
file
=
new
File
(
savePath
+
subject
+
".xlsx"
);
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
SimpleDateFormat
simpleDateFormat1
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
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
));
if
(
b
)
{
content
=
"<p data-olk-copy-source=\\\"MessageBody\\\">Dear all:<br> 附件为今天Cmeeting会议纪要生成和发送情况,烦请查收。</p>"
;
StatisticsEmailPush
.
Attachment
attachment
=
new
StatisticsEmailPush
.
Attachment
();
attachment
.
setName
(
subject
);
attachment
.
setBytes
(
IOUtils
.
toByteArray
(
Files
.
newInputStream
(
file
.
toPath
())));
attachments
.
add
(
attachment
);
}
else
{
content
=
"<p data-olk-copy-source=\\\"MessageBody\\\">Dear all:<br> 今天到目前为止没有会议。</p>"
;
ThreadUtil
.
execute
(()->{
if
(
isDev
)
{
return
;
}
StatisticsEmailPush
emailPushBuilder
=
StatisticsEmailPush
.
builder
()
.
toEmails
(
statisticsEmailPushProperties
.
getToEmails
())
.
attachments
(
attachments
)
.
subject
(
subject
)
.
content
(
content
)
.
build
();
emailSender
.
emailStatisticsPush
(
emailPushBuilder
);
}
catch
(
IOException
|
ParseException
e
)
{
throw
new
RuntimeException
(
e
);
}
finally
{
file
.
delete
();
// redisUtils.del("emailStatisticsPush");
}
log
.
info
(
"推送统计邮件完成!"
);
log
.
info
(
"推送统计邮件!"
);
if
(!
redisUtils
.
setnx
(
"emailStatisticsPush"
,
"emailStatisticsPush"
,
4000
))
{
return
;
}
log
.
info
(
"推送统计邮件开始!"
);
List
<
StatisticsEmailPush
.
Attachment
>
attachments
=
new
ArrayList
<>();
Date
date
=
new
Date
();
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
date
);
calendar
.
add
(
Calendar
.
HOUR_OF_DAY
,
1
);
// 增加 1 小时
Date
newDate
=
calendar
.
getTime
();
// 返回增加后的 Date 对象
String
subject
=
"会议纪要推送记录-"
+
new
SimpleDateFormat
(
"yyyyMMdd HH"
).
format
(
newDate
)
+
":00"
;
String
content
;
if
(
CollUtil
.
isEmpty
(
statisticsEmailPushProperties
.
getToEmails
()))
{
log
.
error
(
"收件人为空!"
);
return
;
}
File
file
=
new
File
(
savePath
+
subject
+
".xlsx"
);
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
SimpleDateFormat
simpleDateFormat1
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
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
));
if
(
b
)
{
content
=
"<p data-olk-copy-source=\\\"MessageBody\\\">Dear all:<br> 附件为今天Cmeeting会议纪要生成和发送情况,烦请查收。</p>"
;
StatisticsEmailPush
.
Attachment
attachment
=
new
StatisticsEmailPush
.
Attachment
();
attachment
.
setName
(
subject
);
attachment
.
setBytes
(
IOUtils
.
toByteArray
(
Files
.
newInputStream
(
file
.
toPath
())));
attachments
.
add
(
attachment
);
}
else
{
content
=
"<p data-olk-copy-source=\\\"MessageBody\\\">Dear all:<br> 今天到目前为止没有会议。</p>"
;
}
StatisticsEmailPush
emailPushBuilder
=
StatisticsEmailPush
.
builder
()
.
toEmails
(
statisticsEmailPushProperties
.
getToEmails
())
.
attachments
(
attachments
)
.
subject
(
subject
)
.
content
(
content
)
.
build
();
emailSender
.
emailStatisticsPush
(
emailPushBuilder
);
}
catch
(
IOException
|
ParseException
e
)
{
throw
new
RuntimeException
(
e
);
}
finally
{
file
.
delete
();
redisUtils
.
del
(
"emailStatisticsPush"
);
}
log
.
info
(
"推送统计邮件完成!"
);
});
}
// @Scheduled(cron = "0 0 * * * ?")
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论