Commit 8b912371 by 马黎滨

Merge branch 'mlbWork' into 'master'

微博话题采集修复

See merge request !13
parents 7e9c499e a7b132df
...@@ -25,31 +25,33 @@ public class TipsUtils { ...@@ -25,31 +25,33 @@ public class TipsUtils {
HotSearchListDAO hotSearchListDAO = new HotSearchListDAO(); HotSearchListDAO hotSearchListDAO = new HotSearchListDAO();
//获取数据库最后一条数据判断该程序几分钟没有采集到数据 //获取数据库最后一条数据判断该程序几分钟没有采集到数据
Date lastTime = hotSearchListDAO.getLastTimeByType(type); Date lastTime = hotSearchListDAO.getLastTimeByType(type);
if(time.getTime() - lastTime.getTime() > timeDifference){ if(lastTime != null) {
if(!typeTips.containsKey(type)){ if (time.getTime() - lastTime.getTime() > timeDifference) {
if (!typeTips.containsKey(type)) {
//发送预警 //发送预警
String crawlerContent = String.format("%s数据采集异常",type); String crawlerContent = String.format("%s数据采集异常", type);
// QYWechatUtil.send(key, QYWechatUtil.MSGTYPE_TEXT, crawlerContent, QYWechatUtil.send(key, QYWechatUtil.MSGTYPE_TEXT, crawlerContent,
// null, null); null, null);
System.out.println(crawlerContent); }
typeTips.put(type, time);
} }
typeTips.put(type,time);
} }
} }
//数据采集恢复发送通知 //数据采集恢复发送通知
public static void recoveryTips(String type,Date time){ public static void recoveryTips(String type,Date time){
if(typeTips.containsKey(type)){ if(typeTips.containsKey(type)) {
//最后一次未采集到数据的时间 //最后一次未采集到数据的时间
Date lastTime = typeTips.get(type); Date lastTime = typeTips.get(type);
//两者比较,相差10分钟以上认为恢复采集 //两者比较,相差10分钟以上认为恢复采集
if(time.getTime() - lastTime.getTime() > timeDifference){ if (lastTime != null) {
if (time.getTime() - lastTime.getTime() > timeDifference) {
typeTips.remove(type); typeTips.remove(type);
//发送恢复通知 //发送恢复通知
String crawlerContent = String.format("%s数据采集恢复正常",type); String crawlerContent = String.format("%s数据采集恢复正常", type);
// QYWechatUtil.send(key, QYWechatUtil.MSGTYPE_TEXT, crawlerContent, QYWechatUtil.send(key, QYWechatUtil.MSGTYPE_TEXT, crawlerContent,
// null, null); null, null);
System.out.println(crawlerContent); }
} }
} }
} }
......
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