Commit 60dee462 authored by 耿迪迪's avatar 耿迪迪

超过四小时不再发送信息 gengdidi

parent 4cfada5b
......@@ -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);
}
......
......@@ -23,7 +23,7 @@ logging.level.com.zehong.monitorreprotdatafrogovernmentnew.dao: DEBUG
cron: 0 0/2 * * * ?
#定时发送短信时间
sendSmsCron: 0 0/30 * * * ?
sendSmsCron: 0 0/60 * * * ?
sendSmsUrl: http://36.148.23.59:8801/sms/sendBatchSms
#通知号码
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment