Commit 95690c91 by java-李谡

修改20分钟内梧桐花记录仍会预警bug

parent fceef1eb
......@@ -6,7 +6,7 @@
<groupId>com.foc</groupId>
<artifactId>task</artifactId>
<version>3.0-SNAPSHOT</version>
<version>3.1-SNAPSHOT</version>
<properties>
<!-- log4j日志文件管理包版本 -->
......
......@@ -58,62 +58,63 @@ public class SoundMonitorService {
*/
public static boolean test() {
Properties properties = PropertiesUtils.getProperties();
//间隔时间
//获取录音同步任务间隔时间
String interval = properties.getProperty("interval");
SoundsMaxIdDao soundsMaxIdDao = session.getMapper(SoundsMaxIdDao.class);
//获取录音同步任务最后更新时间
SoundsMaxId maxId = soundsMaxIdDao.getMaxId();
String updateTime = maxId.getUpdateDate();
Date date = new Date();
log.info("当前系统时间:{}",date);
log.info("当前系统时间:{}", date);
FocSmsEmailRecord focSmsEmailRecord = new FocSmsEmailRecord();
focSmsEmailRecord.setCreateTime(date);
//比较时间,如果相差20分钟没有执行
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime ldt = LocalDateTime.parse(updateTime,df);
if (DateUtils.until(ldt) > Long.parseLong(interval)){
//2019年10月5日14:38:07 zt
SoundInfo soundInfo = soundsMaxIdDao.getInfoByUpdateTime(updateTime);
if(soundInfo != null){
log.info("更新时间与最新时间间隔大于20分钟,有通话记录start_time:{}",soundInfo.getBeginTime());
}else {
log.info("更新时间异常,与最新时间间隔大于20分钟,updateTime:{}", updateTime);
focSmsEmailRecord.setDescription("更新时间异常,与最新时间间隔大于20分钟,updateTime为" + updateTime);
focSmsEmailRecord.setMonitorState((short)1);
LocalDateTime ldt = LocalDateTime.parse(updateTime, df);
//获取录音同步任务最后一次更新时间后的通话成功的记录
List<SoundInfo> list = soundsMaxIdDao.getInfo(updateTime);
//比较时间,如果相差20分钟没有执行
if (DateUtils.until(ldt) > Long.parseLong(interval)) {
//判断通话记录,如果没有,则说明间隔时间内,未同步到录音记录,正常
if (CollectionUtils.isEmpty(list)) {
log.info("最新同步时间20分钟内未查询到成功通话记录");
focSmsEmailRecord.setDescription("最新同步时间20分钟内未查询到成功通话记录");
focSmsEmailRecord.setMonitorState((short) 0);
soundsMaxIdDao.insertFocRecord(focSmsEmailRecord);
session.commit();
return false;
} else {
//说明录音定时任务未正常执行,异常
log.info("更新时间异常,与最新时间间隔大于20分钟且有成功通话记录,updateTime:{}", updateTime);
focSmsEmailRecord.setDescription("更新时间异常,与最新时间间隔大于20分钟且有成功通话记录,updateTime为" + updateTime);
focSmsEmailRecord.setMonitorState((short) 1);
soundsMaxIdDao.insertFocRecord(focSmsEmailRecord);
session.commit();
return true;
}
}
List<SoundInfo> list = soundsMaxIdDao.getInfo(updateTime);
if (CollectionUtils.isEmpty(list)){
log.info("查询不到记录" );
focSmsEmailRecord.setDescription("查询不到记录");
focSmsEmailRecord.setMonitorState((short)0);
soundsMaxIdDao.insertFocRecord(focSmsEmailRecord);
session.commit();
return false;
}
for (SoundInfo soundInfo : list){
//录音任务正常同步,监测数据是否有录音文件下载地址,如果没有,说明录音功能异常
for (SoundInfo soundInfo : list) {
//成功且没有url的
if(StringUtils.isEmpty(soundInfo.getDownloadUrl() ) ){
log.info("{}该条记录无url:{}",date,soundInfo.toString());
if (StringUtils.isEmpty(soundInfo.getDownloadUrl())) {
System.out.println(soundInfo.getBeginTime());
log.info("{}该条记录无url:{}", date, soundInfo.toString());
focSmsEmailRecord.setDescription("该条记录无url" + soundInfo.toString());
focSmsEmailRecord.setMonitorState((short)1);
focSmsEmailRecord.setMonitorState((short) 1);
soundsMaxIdDao.insertFocRecord(focSmsEmailRecord);
session.commit();
return true;
}
}
log.info("全部成功" );
focSmsEmailRecord.setDescription("全部成功");
focSmsEmailRecord.setMonitorState((short)0);
soundsMaxIdDao.insertFocRecord(focSmsEmailRecord);
session.commit();
return false;
log.info("全部成功");
focSmsEmailRecord.setDescription("全部成功");
focSmsEmailRecord.setMonitorState((short) 0);
soundsMaxIdDao.insertFocRecord(focSmsEmailRecord);
session.commit();
return false;
}
public static void sendEmailAndSms(String aicc, String aicp, String resultCode,String mobile) {
public static void sendEmailAndSms(String aicc, String aicp, String resultCode, String mobile) {
SoundsMaxIdDao soundsMaxIdDao = session.getMapper(SoundsMaxIdDao.class);
AccessInfo accessInfo = new AccessInfo();
accessInfo.setAicc(aicc);
......@@ -128,42 +129,42 @@ public class SoundMonitorService {
FocSmsEmailRecord focSmsEmailRecord = soundsMaxIdDao.selectLatestOne();
Date currentTime = focSmsEmailRecord.getCreateTime();
boolean smsFlag = checkSmsFlag(focSendSmsRecord,currentTime);
if (smsFlag){
//发送短信
String smsResult = Sms.sendSms(accessInfo, mobile, "预警:智能首航录音记录显示异常,请处理。");
SmsResult rootEntity = JSON.parseObject(smsResult, SmsResult.class);
if (rootEntity.getResult().getResultCode().equals(resultCode)){
log.info("短信发送成功,Time:{},result:{}", now,smsResult);
focSmsEmailRecord.setSmsSendTime(date);
focSmsEmailRecord.setSmsSendStatus((short)1);
focSmsEmailRecord.setSmsErrorLog(smsResult);
soundsMaxIdDao.updateSms(focSmsEmailRecord);
session.commit();
}else {
log.info("短信发送失败,Time:{},result:{}", now,smsResult);
focSmsEmailRecord.setSmsSendStatus((short)0);
focSmsEmailRecord.setSmsErrorLog(smsResult);
soundsMaxIdDao.updateSms(focSmsEmailRecord);
session.commit();
}
boolean smsFlag = checkSmsFlag(focSendSmsRecord, currentTime);
if (smsFlag) {
//发送短信
String smsResult = Sms.sendSms(accessInfo, mobile, "预警:智能首航录音记录显示异常,请处理。");
SmsResult rootEntity = JSON.parseObject(smsResult, SmsResult.class);
if (rootEntity.getResult().getResultCode().equals(resultCode)) {
log.info("短信发送成功,Time:{},result:{}", now, smsResult);
focSmsEmailRecord.setSmsSendTime(date);
focSmsEmailRecord.setSmsSendStatus((short) 1);
focSmsEmailRecord.setSmsErrorLog(smsResult);
soundsMaxIdDao.updateSms(focSmsEmailRecord);
session.commit();
} else {
log.info("短信发送失败,Time:{},result:{}", now, smsResult);
focSmsEmailRecord.setSmsSendStatus((short) 0);
focSmsEmailRecord.setSmsErrorLog(smsResult);
soundsMaxIdDao.updateSms(focSmsEmailRecord);
session.commit();
}
}
boolean emailFlag = checkEmailFlag(focSendEmailRecord,currentTime);
if (emailFlag){
boolean emailFlag = checkEmailFlag(focSendEmailRecord, currentTime);
if (emailFlag) {
//发送邮件
String emailResult = Email.sendEmail("录音记录预警","智能首航录音记录显示异常,请处理。");
EmailResult emailResult1 = JSON.parseObject(emailResult,EmailResult.class);
if (emailResult1.getResult().getResultCode().equals(resultCode)){
log.info("邮件发送成功,Time:{},result:{}",now,emailResult);
String emailResult = Email.sendEmail("录音记录预警", "智能首航录音记录显示异常,请处理。");
EmailResult emailResult1 = JSON.parseObject(emailResult, EmailResult.class);
if (emailResult1.getResult().getResultCode().equals(resultCode)) {
log.info("邮件发送成功,Time:{},result:{}", now, emailResult);
focSmsEmailRecord.setEmailSendTime(date);
focSmsEmailRecord.setEmailSendStatus((short)1);
focSmsEmailRecord.setEmailSendStatus((short) 1);
focSmsEmailRecord.setEmailErrorLog(emailResult);
soundsMaxIdDao.updateEmail(focSmsEmailRecord);
session.commit();
}else {
log.info("邮件发送失败,Time:{},result:{}",now,emailResult);
focSmsEmailRecord.setEmailSendStatus((short)0);
} else {
log.info("邮件发送失败,Time:{},result:{}", now, emailResult);
focSmsEmailRecord.setEmailSendStatus((short) 0);
focSmsEmailRecord.setEmailErrorLog(emailResult);
soundsMaxIdDao.updateEmail(focSmsEmailRecord);
session.commit();
......@@ -173,15 +174,15 @@ public class SoundMonitorService {
private static boolean checkEmailFlag(FocSmsEmailRecord focSendEmailRecord, Date currentTime) {
Date emailSendTime = focSendEmailRecord.getEmailSendTime();
if (emailSendTime == null){
if (emailSendTime == null) {
return true;
}else {
} else {
//判断是否超过了一小时
long emailSecond = (currentTime.getTime()-emailSendTime.getTime())/1000;
log.info("邮件距上次发送已经过了{}秒",emailSecond);
if (emailSecond/3600 >= 1){
long emailSecond = (currentTime.getTime() - emailSendTime.getTime()) / 1000;
log.info("邮件距上次发送已经过了{}秒", emailSecond);
if (emailSecond / 3600 >= 1) {
return true;
}else {
} else {
return false;
}
}
......@@ -189,15 +190,15 @@ public class SoundMonitorService {
private static boolean checkSmsFlag(FocSmsEmailRecord focSendSmsRecord, Date currentTime) {
Date smsSendTime = focSendSmsRecord.getSmsSendTime();
if (smsSendTime == null){
if (smsSendTime == null) {
return true;
}else {
} else {
//判断是否超过了一小时
long second = (currentTime.getTime() - smsSendTime.getTime())/1000;
log.info("短信距上次发送已经过了{}秒",second);
if (second/3600 >= 1){
long second = (currentTime.getTime() - smsSendTime.getTime()) / 1000;
log.info("短信距上次发送已经过了{}秒", second);
if (second / 3600 >= 1) {
return true;
}else {
} else {
return false;
}
}
......
......@@ -28,11 +28,7 @@
LEFT JOIN foc_sound_phones ap ON ac.id = ap.record_id
WHERE
ac.end_status = 'SUCCESS'
AND ac.start_time &lt;= #{date}
AND (
ac.end_time &lt; #{date}
OR ac.end_time IS NULL
)
AND ac.start_time &gt;= #{date}
ORDER BY
beginTime DESC
LIMIT 20
......
......@@ -47,22 +47,12 @@
<dataSource type="POOLED">
<property name="driver" value="com.mysql.jdbc.Driver"/>
<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?serverTimezone=CTT&amp;useUnicode=true&amp;characterEncoding=utf-8"/>-->
<property name="username" value="focuser"/>
<property name="password" value="FOC@2016"/>
</dataSource>
</environment>
<!--<environment id="prod">-->
<!--<transactionManager type="JDBC"/>-->
<!--&lt;!&ndash; 配置数据库连接信息 &ndash;&gt;-->
<!--<dataSource type="POOLED">-->
<!--<property name="driver" value="com.mysql.jdbc.Driver"/>-->
<!--<property name="url" value="jdbc:mysql://sms.db.com:3306/sms"/>-->
<!--<property name="username" value="sms_develop"/>-->
<!--<property name="password" value="Develop2018!@#"/>-->
<!--</dataSource>-->
<!--</environment>-->
</environments>
......
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