From 764c84f446804dded0abf4587c693ef905835718 Mon Sep 17 00:00:00 2001 From: shiyang <316555390@qq.com> Date: Mon, 20 Dec 2021 14:10:31 +0800 Subject: [PATCH] update --- .../com/lyms/talkonlineweb/domain/LymsPatient.java | 6 ++++++ .../lyms/talkonlineweb/task/PushArticleTask.java | 23 +++++++++++----------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/domain/LymsPatient.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/domain/LymsPatient.java index 194a3de..39822bd 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/domain/LymsPatient.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/domain/LymsPatient.java @@ -53,6 +53,12 @@ public class LymsPatient implements Serializable { private String openid; /** + * 用户关注的公众号openid + */ + @TableField(value = "gzopenid") + private String gzopenid; + + /** * 性别 */ @TableField(value = "sex") diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/PushArticleTask.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/PushArticleTask.java index cc507bc..80731f9 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/PushArticleTask.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/PushArticleTask.java @@ -39,7 +39,7 @@ public class PushArticleTask { @Autowired private LymsDictService lymsDictService; - final String gzopenid ="oQEmP6rFmf0lOb--mUf4_MAZPXEQ";//测试:公众号关注的微信openId +// final String gzopenid ="oQEmP6rFmf0lOb--mUf4_MAZPXEQ";//测试:公众号关注的微信openId final String template_id ="ZDxcRDJ3okC9Lbzpfhr_v4e8W1VWrho-f5uHW_VZHTg";//公众号模板:诊后注意事项id @Scheduled(cron = "0 0 9 * * ?")//每天上午9点执行文章推送 @@ -63,12 +63,17 @@ public class PushArticleTask { pushedart.setIsread((byte) 0); //PushedartId(如果null表示需要推送文章,否则需要推送短消息) if(null!=lymsPushMessage.getPushedartId()){ + if(StringUtil.isEmpty(token)){ + log.info("推送短消息1,获取token失败。。。"); + continue; + } + if(StringUtil.isEmpty(lymsPushMessage.getGzopenid())){ + log.info(lymsPushMessage.getPname()+":公众号openId为空。。。"); + continue; + } + //LymsPushedart的主键id赋值,表示修改。找到以前的推送记录,修改短文字的推送状态 pushedart.setId(lymsPushMessage.getPushedartId()); if(lymsPushMessage.getIsweixinOne()==1){ - if(StringUtil.isEmpty(token)){ - log.info("推送短消息1,获取token失败。。。"); - continue; - } //推送微信消息1 Map map=new HashMap<>(); map.put("first",new DataEntity(lymsPushMessage.getWeixTextOne(),"#173177")); @@ -76,7 +81,7 @@ public class PushArticleTask { map.put("keyword2",new DataEntity(lymsPushMessage.getHname(),"#173177")); map.put("keyword3",new DataEntity(lymsPushMessage.getDname(),"#173177")); map.put("remark",new DataEntity("预祝您早日康复","#173177")); - Integer code= WeiXinUtil.SendWeChatMsg(token,gzopenid,template_id,map); + Integer code= WeiXinUtil.SendWeChatMsg(token,lymsPushMessage.getGzopenid(),template_id,map); if(null==code||code!=0){ log.info("推送短消息1失败。。。"+lymsPushMessage.getPname()+"; code:"+code); continue; @@ -84,10 +89,6 @@ public class PushArticleTask { //成功标记记录1 pushedart.setIsweixinone(1);//0未推送1已推送 }else if(lymsPushMessage.getIsweixinTwo()==1){ - if(StringUtil.isEmpty(token)){ - log.info("推送短消息2,获取token失败。。。"); - continue; - } //推送微信消息2 Map map=new HashMap<>(); map.put("first",new DataEntity(lymsPushMessage.getWeixTextTwo(),"#173177")); @@ -95,7 +96,7 @@ public class PushArticleTask { map.put("keyword2",new DataEntity(lymsPushMessage.getHname(),"#173177")); map.put("keyword3",new DataEntity(lymsPushMessage.getDname(),"#173177")); map.put("remark",new DataEntity("预祝您早日康复","#173177")); - Integer code= WeiXinUtil.SendWeChatMsg(token,gzopenid,template_id,map); + Integer code= WeiXinUtil.SendWeChatMsg(token,lymsPushMessage.getGzopenid(),template_id,map); if(null==code||code!=0){ log.info("推送短消息2失败。。。"+lymsPushMessage.getPname()+"; code:"+code); continue; -- 1.8.3.1