Commit 0941c9c456da5d21e6f4a4d344024c21a89ba71a
1 parent
7812e91ec9
Exists in
master
and in
1 other branch
update
Showing 2 changed files with 34 additions and 5 deletions
talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/PushArticleTask.java
View file @
0941c9c
| ... | ... | @@ -77,6 +77,14 @@ |
| 77 | 77 | pushedart.setIsweixintwo(2);//是否推送短消息2(0否,1是 2推送失败) |
| 78 | 78 | } |
| 79 | 79 | //LymsPushedart的主键id赋值,表示修改。找到以前的推送记录,修改短文字的推送状态 |
| 80 | + //这里查询为了去掉推送文章的记录重复存 | |
| 81 | + QueryWrapper<LymsPushedart> queryWrapper2=new QueryWrapper<>(); | |
| 82 | + queryWrapper.eq("pid", lymsPushMessage.getPid()); | |
| 83 | + queryWrapper.eq("aid", lymsPushMessage.getAid()); | |
| 84 | + LymsPushedart lymsPushedart = lymsPushedartService.getOne(queryWrapper2); | |
| 85 | + if(lymsPushedart!=null){ | |
| 86 | + lymsPushMessage.setPushedartId(lymsPushedart.getId()); | |
| 87 | + } | |
| 80 | 88 | pushedart.setId(lymsPushMessage.getPushedartId()); |
| 81 | 89 | lymsPushedartService.saveOrUpdate(pushedart); |
| 82 | 90 | log.info("推送短消息"+(lymsPushMessage.getIsweixinOne()==1?"1":"2")+",获取token失败!"); |
| ... | ... | @@ -96,6 +104,16 @@ |
| 96 | 104 | pushedart.setIsweixintwo(2);//是否推送短消息2(0否,1是 2推送失败) |
| 97 | 105 | } |
| 98 | 106 | //LymsPushedart的主键id赋值,表示修改。找到以前的推送记录,修改短文字的推送状态 |
| 107 | + //这里查询为了去掉推送文章的记录重复存 | |
| 108 | + if(lymsPushMessage.getPushedartId()==null){ | |
| 109 | + QueryWrapper<LymsPushedart> queryWrapper2=new QueryWrapper<>(); | |
| 110 | + queryWrapper2.eq("pid", lymsPushMessage.getPid()); | |
| 111 | + queryWrapper2.eq("aid", lymsPushMessage.getAid()); | |
| 112 | + LymsPushedart lymsPushedart = lymsPushedartService.getOne(queryWrapper2); | |
| 113 | + if(lymsPushedart!=null){ | |
| 114 | + lymsPushMessage.setPushedartId(lymsPushedart.getId()); | |
| 115 | + } | |
| 116 | + } | |
| 99 | 117 | pushedart.setId(lymsPushMessage.getPushedartId()); |
| 100 | 118 | lymsPushedartService.saveOrUpdate(pushedart); |
| 101 | 119 | log.info(lymsPushMessage.getPname()+":公众号openId为空!"); |
| 102 | 120 | |
| ... | ... | @@ -122,9 +140,16 @@ |
| 122 | 140 | pushedart.setId(lymsPushMessage.getPushedartId()); |
| 123 | 141 | lymsPushedartService.saveOrUpdate(pushedart); |
| 124 | 142 | log.info("推送短消息1失败!"+lymsPushMessage.getPname()+"; code:"+code); |
| 143 | + continue; | |
| 125 | 144 | } |
| 126 | 145 | //成功标记记录1 |
| 127 | 146 | pushedart.setIsweixinone(1);//是否推送短消息1(0否,1是 2推送失败) |
| 147 | + //插入or更新到LymsPushedart记录 | |
| 148 | + lymsPushedartService.saveOrUpdate(pushedart); | |
| 149 | + //更新到LymsPushMessages记录 | |
| 150 | + lymsPushMessage.setState(1);//推送状态:0待推送 1成功 2失败。(在备注写失败原因) | |
| 151 | + lymsPushMessage.setPushTime(new Date()); | |
| 152 | + lymsPushMessagesService.updateById(lymsPushMessage); | |
| 128 | 153 | }else if(lymsPushMessage.getIsweixinTwo()==1){ |
| 129 | 154 | //LymsPushedart的主键id赋值,表示修改。找到以前的推送记录,修改短文字的推送状态 |
| 130 | 155 | pushedart.setId(lymsPushMessage.getPushedartId()); |
| 131 | 156 | |
| ... | ... | @@ -150,10 +175,14 @@ |
| 150 | 175 | } |
| 151 | 176 | //成功标记记录2 |
| 152 | 177 | pushedart.setIsweixintwo(1);//是否推送短消息1(0否,1是 2推送失败) |
| 178 | + //插入or更新到LymsPushedart记录 | |
| 179 | + lymsPushedartService.saveOrUpdate(pushedart); | |
| 180 | + //更新到LymsPushMessages记录 | |
| 181 | + lymsPushMessage.setState(1);//推送状态:0待推送 1成功 2失败。(在备注写失败原因) | |
| 182 | + lymsPushMessage.setPushTime(new Date()); | |
| 183 | + lymsPushMessagesService.updateById(lymsPushMessage); | |
| 153 | 184 | } |
| 154 | - //插入or更新到LymsPushedart记录 | |
| 155 | - lymsPushedartService.saveOrUpdate(pushedart); | |
| 156 | - //更新到LymsPushMessages记录 | |
| 185 | + //更新到LymsPushMessages记录(推送的是文章的情况IsweixinOne和IsweixinTwo都是0的时候) | |
| 157 | 186 | lymsPushMessage.setState(1);//推送状态:0待推送 1成功 2失败。(在备注写失败原因) |
| 158 | 187 | lymsPushMessage.setPushTime(new Date()); |
| 159 | 188 | lymsPushMessagesService.updateById(lymsPushMessage); |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/PushArticleTaskData.java
View file @
0941c9c
| ... | ... | @@ -52,8 +52,8 @@ |
| 52 | 52 | Map<String,Object> param=new HashMap<>(); |
| 53 | 53 | param.put("vtype",999); |
| 54 | 54 | List<LymsDict> dcLst=lymsDictService.listByMap(param); |
| 55 | - //防止重复 | |
| 56 | 55 | if (dcLst.size()>0 && dcLst.get(0).getCode()==1){ |
| 56 | + //防止重复 | |
| 57 | 57 | QueryWrapper<LymsPushMessages> queryWrapper2 = new QueryWrapper<>(); |
| 58 | 58 | queryWrapper2.apply("TO_DAYS(created_time) = TO_DAYS(NOW()) and state in (0,1,2)"); |
| 59 | 59 | List<LymsPushMessages> list = lymsPushMessagesService.list(queryWrapper2); |
| ... | ... | @@ -89,7 +89,7 @@ |
| 89 | 89 | //需要推送的短消息1 |
| 90 | 90 | lymsPushMessagesService.save(lymsPushMessages); |
| 91 | 91 | } |
| 92 | - //标记要推送的文章-短消息1标记0 | |
| 92 | + //标记要推送的文章-短消息1标记为0说明这是推送的文章 | |
| 93 | 93 | lymsPushMessages.setIsweixinOne(0); |
| 94 | 94 | //保存到要推送的表lyms_push_messages需要推送的文章 |
| 95 | 95 | lymsPushMessagesService.save(lymsPushMessages); |