Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
monitor-reprotdata-frogovernment
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
耿迪迪
monitor-reprotdata-frogovernment
Commits
60dee462
Commit
60dee462
authored
Dec 17, 2021
by
耿迪迪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
超过四小时不再发送信息 gengdidi
parent
4cfada5b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
5 deletions
+40
-5
SaticScheduleTask.java
...torreprotdatafrogovernmentnew/task/SaticScheduleTask.java
+39
-4
application.yml
src/main/resources/application.yml
+1
-1
No files found.
src/main/java/com/zehong/monitorreprotdatafrogovernmentnew/task/SaticScheduleTask.java
View file @
60dee462
...
...
@@ -37,11 +37,20 @@ public class SaticScheduleTask {
@Scheduled
(
cron
=
"${cron}"
)
private
void
configureTasks
()
{
DetectorInfo
jingye
=
jingyeDetectorInfoDao
.
getRecentSendData
();
compareReportDate
(
jingye
.
getUpdateTime
(),
"jingye"
);
if
(
null
!=
jingye
&&
null
!=
jingye
.
getUpdateTime
()){
compareReportDate
(
jingye
.
getUpdateTime
(),
"jingye"
);
}
DetectorInfo
yingde
=
yingdeDetectorInfoDao
.
getRecentSendData
();
compareReportDate
(
yingde
.
getUpdateTime
(),
"yingde"
);
if
(
null
!=
yingde
&&
null
!=
yingde
.
getUpdateTime
()){
compareReportDate
(
yingde
.
getUpdateTime
(),
"yingde"
);
}
DetectorInfo
zhengyuan
=
zhengyuanDetectorInfoDao
.
getRecentSendData
();
compareReportDate
(
zhengyuan
.
getUpdateTime
(),
"zhengyuan"
);
if
(
null
!=
zhengyuan
&&
null
!=
zhengyuan
.
getUpdateTime
()){
compareReportDate
(
zhengyuan
.
getUpdateTime
(),
"zhengyuan"
);
}
}
/**
...
...
@@ -51,8 +60,12 @@ public class SaticScheduleTask {
*/
private
void
compareReportDate
(
Date
reportDate
,
String
company
){
long
period
=
System
.
currentTimeMillis
()
-
reportDate
.
getTime
();
//超过五分钟未发送数据发送短信报警
//超过
十
五分钟未发送数据发送短信报警
if
(
15
<
period
/(
60
*
1000
)){
//如果超过四小时未推送,不再提醒
if
(
isOverFourHour
(
period
,
company
)){
return
;
}
//如未及时处理没半小时发送一次短信
if
(!
dynamicTask
.
isExist
(
company
)){
//发送短信
...
...
@@ -60,8 +73,30 @@ public class SaticScheduleTask {
//启动定时半小时后重新发送
dynamicTask
.
add
(
company
,
sendSmsCron
);
}
return
;
}
removeTask
(
company
);
}
/**
* 判断未推送时间,超过四小时不再提醒
* @param period 未推送时间
* @param company 公司名称
*/
private
boolean
isOverFourHour
(
long
period
,
String
company
){
if
(
4
<
period
/
(
60
*
60
*
1000
)){
removeTask
(
company
);
return
true
;
}
return
false
;
}
/**
* 移除定时器
* @param company 公司名称
*/
private
void
removeTask
(
String
company
){
if
(
dynamicTask
.
isExist
(
company
)){
dynamicTask
.
stop
(
company
);
}
...
...
src/main/resources/application.yml
View file @
60dee462
...
...
@@ -23,7 +23,7 @@ logging.level.com.zehong.monitorreprotdatafrogovernmentnew.dao: DEBUG
cron
:
0 0/2 * * * ?
#定时发送短信时间
sendSmsCron
:
0 0/
3
0 * * * ?
sendSmsCron
:
0 0/
6
0 * * * ?
sendSmsUrl
:
http://36.148.23.59:8801/sms/sendBatchSms
#通知号码
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment