Commit a7b132df by 马黎滨

微博话题采集修复

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