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

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

parent 4cfada5b
...@@ -37,13 +37,22 @@ public class SaticScheduleTask { ...@@ -37,13 +37,22 @@ public class SaticScheduleTask {
@Scheduled(cron = "${cron}") @Scheduled(cron = "${cron}")
private void configureTasks() { private void configureTasks() {
DetectorInfo jingye = jingyeDetectorInfoDao.getRecentSendData(); DetectorInfo jingye = jingyeDetectorInfoDao.getRecentSendData();
if(null != jingye && null != jingye.getUpdateTime()){
compareReportDate(jingye.getUpdateTime(),"jingye"); compareReportDate(jingye.getUpdateTime(),"jingye");
}
DetectorInfo yingde = yingdeDetectorInfoDao.getRecentSendData(); DetectorInfo yingde = yingdeDetectorInfoDao.getRecentSendData();
if(null != yingde && null != yingde.getUpdateTime()){
compareReportDate(yingde.getUpdateTime(),"yingde"); compareReportDate(yingde.getUpdateTime(),"yingde");
}
DetectorInfo zhengyuan = zhengyuanDetectorInfoDao.getRecentSendData(); DetectorInfo zhengyuan = zhengyuanDetectorInfoDao.getRecentSendData();
if(null != zhengyuan && null != zhengyuan.getUpdateTime()){
compareReportDate(zhengyuan.getUpdateTime(),"zhengyuan"); compareReportDate(zhengyuan.getUpdateTime(),"zhengyuan");
} }
}
/** /**
* 比较上报时间 超过五分钟为发送数据发送短信预警 * 比较上报时间 超过五分钟为发送数据发送短信预警
* @param reportDate 上报时间 * @param reportDate 上报时间
...@@ -51,8 +60,12 @@ public class SaticScheduleTask { ...@@ -51,8 +60,12 @@ public class SaticScheduleTask {
*/ */
private void compareReportDate(Date reportDate,String company){ private void compareReportDate(Date reportDate,String company){
long period = System.currentTimeMillis() - reportDate.getTime(); long period = System.currentTimeMillis() - reportDate.getTime();
//超过五分钟未发送数据发送短信报警 //超过五分钟未发送数据发送短信报警
if(15 < period/(60 * 1000)){ if(15 < period/(60 * 1000)){
//如果超过四小时未推送,不再提醒
if(isOverFourHour(period,company)){
return;
}
//如未及时处理没半小时发送一次短信 //如未及时处理没半小时发送一次短信
if(!dynamicTask.isExist(company)){ if(!dynamicTask.isExist(company)){
//发送短信 //发送短信
...@@ -60,8 +73,30 @@ public class SaticScheduleTask { ...@@ -60,8 +73,30 @@ public class SaticScheduleTask {
//启动定时半小时后重新发送 //启动定时半小时后重新发送
dynamicTask.add(company,sendSmsCron); dynamicTask.add(company,sendSmsCron);
} }
return; 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)){ if (dynamicTask.isExist(company)){
dynamicTask.stop(company); dynamicTask.stop(company);
} }
......
...@@ -23,7 +23,7 @@ logging.level.com.zehong.monitorreprotdatafrogovernmentnew.dao: DEBUG ...@@ -23,7 +23,7 @@ logging.level.com.zehong.monitorreprotdatafrogovernmentnew.dao: DEBUG
cron: 0 0/2 * * * ? cron: 0 0/2 * * * ?
#定时发送短信时间 #定时发送短信时间
sendSmsCron: 0 0/30 * * * ? sendSmsCron: 0 0/60 * * * ?
sendSmsUrl: http://36.148.23.59:8801/sms/sendBatchSms 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