Commit 7fde64b8 by zhiwei

添加错误日志打印

parent 8ae3d2d2
...@@ -5,6 +5,7 @@ import java.util.concurrent.ScheduledExecutorService; ...@@ -5,6 +5,7 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import com.zhiwei.searchhotcrawler.cache.CacheListener; import com.zhiwei.searchhotcrawler.cache.CacheListener;
import com.zhiwei.searchhotcrawler.timer.SendWeiboHotSearchRun;
import com.zhiwei.searchhotcrawler.timer.SendZhihuHotSearchRun; import com.zhiwei.searchhotcrawler.timer.SendZhihuHotSearchRun;
import com.zhiwei.searchhotcrawler.timer.WeiboHotSearchRun; import com.zhiwei.searchhotcrawler.timer.WeiboHotSearchRun;
import com.zhiwei.searchhotcrawler.timer.ZhihuHotSearchRun; import com.zhiwei.searchhotcrawler.timer.ZhihuHotSearchRun;
...@@ -22,7 +23,7 @@ public class HotSearchRun { ...@@ -22,7 +23,7 @@ public class HotSearchRun {
scheduExec.scheduleAtFixedRate(new WeiboHotSearchRun(), 0, 1, TimeUnit.MINUTES); scheduExec.scheduleAtFixedRate(new WeiboHotSearchRun(), 0, 1, TimeUnit.MINUTES);
scheduExec.scheduleAtFixedRate(new ZhihuHotSearchRun(), 0, 1 , TimeUnit.MINUTES); scheduExec.scheduleAtFixedRate(new ZhihuHotSearchRun(), 0, 1 , TimeUnit.MINUTES);
scheduExec.scheduleAtFixedRate(new SendZhihuHotSearchRun(), 0, 60 , TimeUnit.MINUTES); scheduExec.scheduleAtFixedRate(new SendZhihuHotSearchRun(), 0, 60 , TimeUnit.MINUTES);
// scheduExec.scheduleAtFixedRate(new SendWeiboHotSearchRun(), 0, 60 , TimeUnit.MINUTES); scheduExec.scheduleAtFixedRate(new SendWeiboHotSearchRun(), 0, 60 , TimeUnit.MINUTES);
} }
public static void main(String[] args) { public static void main(String[] args) {
......
...@@ -74,18 +74,23 @@ public class SendZhihuHotSearchRun extends Thread{ ...@@ -74,18 +74,23 @@ public class SendZhihuHotSearchRun extends Thread{
dataMap.put("remark", remark); dataMap.put("remark", remark);
List<String> userList = getUserList(); List<String> userList = getUserList();
for (String openId : userList) { if(userList!=null && userList.size()>0) {
Template template = new Template(); for (String openId : userList) {
template.setTouser(openId); Template template = new Template();
if(url!=null){ template.setTouser(openId);
template.setUrl(url); if(url!=null){
template.setUrl(url);
}
template.setTemplate_id(WechatConstant.WECHAT_TEMPLATEID_EARLY_IT);
template.setData(dataMap);
JSONObject templateJson = (JSONObject)JSONObject.toJSON(template);
WechatCodeUtil.sendDataJson(templateJson);
} }
template.setTemplate_id(WechatConstant.WECHAT_TEMPLATEID_EARLY_IT); }else {
template.setData(dataMap); logger.info("知乎推送拉取用户列表失败");
JSONObject templateJson = (JSONObject)JSONObject.toJSON(template);
WechatCodeUtil.sendDataJson(templateJson);
} }
} }
/** /**
......
...@@ -61,10 +61,12 @@ public class WechatCodeUtil { ...@@ -61,10 +61,12 @@ public class WechatCodeUtil {
if (null != jsonObject) { if (null != jsonObject) {
if ("ok".equals(jsonObject.getString("errmsg"))) { if ("ok".equals(jsonObject.getString("errmsg"))) {
msgid = jsonObject.getIntValue("msgid"); msgid = jsonObject.getIntValue("msgid");
}else {
logger.info("消息推送失败,错误为::{}",jsonObject.toString());
} }
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); logger.error("消息推送失败,错误为::{}",e.fillInStackTrace());
msgid = 0; msgid = 0;
} }
return msgid; return msgid;
......
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