Commit af50b376 by zt

修改

parent d9329eb6
...@@ -62,9 +62,13 @@ public class SoundMonitorService { ...@@ -62,9 +62,13 @@ public class SoundMonitorService {
SoundsMaxIdDao soundsMaxIdDao = session.getMapper(SoundsMaxIdDao.class); SoundsMaxIdDao soundsMaxIdDao = session.getMapper(SoundsMaxIdDao.class);
//检查ip锁数据库 //检查ip锁数据库
List<String> blackIpList = soundsMaxIdDao.getBlackIpList(); List<String> blackIpList = soundsMaxIdDao.getBlackIpList();
blackIpList.forEach( (blackIp) -> soundsMaxIdDao.deleteBlackIp(blackIp) ); if(blackIpList!=null){
session.commit(); blackIpList.forEach( (blackIp) ->{
soundsMaxIdDao.deleteBlackIp(blackIp);
log.info("删除的ip地址有:{}",blackIp);
session.commit();
});
}
SoundsMaxId maxId = soundsMaxIdDao.getMaxId(); SoundsMaxId maxId = soundsMaxIdDao.getMaxId();
String updateTime = maxId.getUpdateDate(); String updateTime = maxId.getUpdateDate();
Date date = new Date(); Date date = new Date();
...@@ -126,19 +130,7 @@ public class SoundMonitorService { ...@@ -126,19 +130,7 @@ public class SoundMonitorService {
FocSmsEmailRecord focSmsEmailRecord = soundsMaxIdDao.selectLatestOne(); FocSmsEmailRecord focSmsEmailRecord = soundsMaxIdDao.selectLatestOne();
Date currentTime = focSmsEmailRecord.getCreateTime(); Date currentTime = focSmsEmailRecord.getCreateTime();
boolean smsFlag; boolean smsFlag = checkSmsFlag(focSendSmsRecord,currentTime);
Date smsSendTime = focSendSmsRecord.getSmsSendTime();
if (smsSendTime == null){
smsFlag = true;
}else {
//判断是否超过了一小时
long second = currentTime.getTime()-smsSendTime.getTime()/1000;
if (second/360 < 1){
smsFlag = true;
}else {
smsFlag = false;
}
}
if (smsFlag){ if (smsFlag){
//发送短信 //发送短信
String smsResult = Sms.sendSms(accessInfo, mobile, "预警:智能首航录音记录显示异常,请处理。"); String smsResult = Sms.sendSms(accessInfo, mobile, "预警:智能首航录音记录显示异常,请处理。");
...@@ -159,19 +151,7 @@ public class SoundMonitorService { ...@@ -159,19 +151,7 @@ public class SoundMonitorService {
} }
} }
boolean emailFlag; boolean emailFlag = checkEmailFlag(focSendEmailRecord,currentTime);
Date emailSendTime = focSendEmailRecord.getEmailSendTime();
if (emailSendTime == null){
emailFlag = true;
}else {
//判断是否超过了一小时
long emailSecond = currentTime.getTime()-emailSendTime.getTime()/1000;
if (emailSecond/360 < 1){
emailFlag = true;
}else {
emailFlag = false;
}
}
if (emailFlag){ if (emailFlag){
//发送邮件 //发送邮件
String emailResult = Email.sendEmail("录音记录预警","智能首航录音记录显示异常,请处理。"); String emailResult = Email.sendEmail("录音记录预警","智能首航录音记录显示异常,请处理。");
...@@ -192,4 +172,35 @@ public class SoundMonitorService { ...@@ -192,4 +172,35 @@ public class SoundMonitorService {
} }
} }
} }
private static boolean checkEmailFlag(FocSmsEmailRecord focSendEmailRecord, Date currentTime) {
Date emailSendTime = focSendEmailRecord.getEmailSendTime();
if (emailSendTime == null){
return true;
}else {
//判断是否超过了一小时
long emailSecond = (currentTime.getTime()-emailSendTime.getTime())/1000;
if (emailSecond/3600 > 1){
return true;
}else {
return false;
}
}
}
private static boolean checkSmsFlag(FocSmsEmailRecord focSendSmsRecord, Date currentTime) {
Date smsSendTime = focSendSmsRecord.getSmsSendTime();
if (smsSendTime == null){
return true;
}else {
//判断是否超过了一小时
long second = (currentTime.getTime() - smsSendTime.getTime())/1000;
log.info("{}",second);
if (second/3600 > 1){
return true;
}else {
return false;
}
}
}
} }
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
<!-- 配置数据库连接信息 --> <!-- 配置数据库连接信息 -->
<dataSource type="POOLED"> <dataSource type="POOLED">
<property name="driver" value="com.mysql.jdbc.Driver"/> <property name="driver" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://106.75.97.50:3306/jd_foc?useUnicode=true&amp;characterEncoding=utf-8"/> <property name="url" value="jdbc:mysql://106.75.97.50:3306/jd_foc?serverTimezone=CTT&amp;useUnicode=true&amp;characterEncoding=utf-8"/>
<!--<property name="url" value="jdbc:mysql://mysql_server:3306/foc?useUnicode=true&amp;characterEncoding=utf-8"/>--> <!--<property name="url" value="jdbc:mysql://mysql_server:3306/foc?useUnicode=true&amp;characterEncoding=utf-8"/>-->
<property name="username" value="focuser"/> <property name="username" value="focuser"/>
<property name="password" value="FOC@2016"/> <property name="password" value="FOC@2016"/>
......
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