Commit 1637edb33d2ba27fe0f9dfb1f552a36684627306
1 parent
5ba77c5cae
Exists in
master
and in
1 other branch
小程序多人关注一个病人短消息推送
Showing 7 changed files with 296 additions and 26 deletions
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/domain/LymsPushAttentionRecord.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsPushAttentionRecordMapper.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsPushAttentionRecordService.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsPushAttentionRecordServiceImpl.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/PushArticleTask.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/PushArticleTaskData.java
- talkonlineweb/src/main/resources/mapper/LymsPushAttentionRecordMapper.xml
talkonlineweb/src/main/java/com/lyms/talkonlineweb/domain/LymsPushAttentionRecord.java
View file @
1637edb
| 1 | +package com.lyms.talkonlineweb.domain; | |
| 2 | + | |
| 3 | +import com.baomidou.mybatisplus.annotation.IdType; | |
| 4 | +import com.baomidou.mybatisplus.annotation.TableField; | |
| 5 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 6 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 7 | +import java.io.Serializable; | |
| 8 | +import java.util.Date; | |
| 9 | +import lombok.Data; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * 子女关注患者推送短文字记录 | |
| 13 | + * @TableName lyms_push_attention_record | |
| 14 | + */ | |
| 15 | +@TableName(value ="lyms_push_attention_record") | |
| 16 | +@Data | |
| 17 | +public class LymsPushAttentionRecord implements Serializable { | |
| 18 | + /** | |
| 19 | + * | |
| 20 | + */ | |
| 21 | + @TableId(value = "id", type = IdType.AUTO) | |
| 22 | + private Integer id; | |
| 23 | + | |
| 24 | + /** | |
| 25 | + * 推送子女的小程序用户id | |
| 26 | + */ | |
| 27 | + @TableField(value = "pid") | |
| 28 | + private Integer pid; | |
| 29 | + | |
| 30 | + /** | |
| 31 | + * 推送子女的公众号id | |
| 32 | + */ | |
| 33 | + @TableField(value = "p_gzopenid") | |
| 34 | + private String pGzopenid; | |
| 35 | + | |
| 36 | + /** | |
| 37 | + * 被关注患者id | |
| 38 | + */ | |
| 39 | + @TableField(value = "pa_id") | |
| 40 | + private Integer paId; | |
| 41 | + | |
| 42 | + /** | |
| 43 | + * 推送类型:1:短文字一,2:短文字二 | |
| 44 | + */ | |
| 45 | + @TableField(value = "pa_isweixin_type") | |
| 46 | + private Integer paIsweixinType; | |
| 47 | + | |
| 48 | + /** | |
| 49 | + * 被关注患者推送的短文字内容 | |
| 50 | + */ | |
| 51 | + @TableField(value = "pa_weix_text") | |
| 52 | + private String paWeixText; | |
| 53 | + | |
| 54 | + /** | |
| 55 | + * 推送状态 0待推送 1成功 2失败(在备注写失败原因) | |
| 56 | + */ | |
| 57 | + @TableField(value = "isweixin_state") | |
| 58 | + private Integer isweixinState; | |
| 59 | + | |
| 60 | + /** | |
| 61 | + * 备注。失败原因 | |
| 62 | + */ | |
| 63 | + @TableField(value = "remark") | |
| 64 | + private String remark; | |
| 65 | + | |
| 66 | + /** | |
| 67 | + * 推送时间 | |
| 68 | + */ | |
| 69 | + @TableField(value = "push_time") | |
| 70 | + private Date pushTime; | |
| 71 | + | |
| 72 | + | |
| 73 | + @TableField(exist = false) | |
| 74 | + private static final long serialVersionUID = 1L; | |
| 75 | + | |
| 76 | + @Override | |
| 77 | + public boolean equals(Object that) { | |
| 78 | + if (this == that) { | |
| 79 | + return true; | |
| 80 | + } | |
| 81 | + if (that == null) { | |
| 82 | + return false; | |
| 83 | + } | |
| 84 | + if (getClass() != that.getClass()) { | |
| 85 | + return false; | |
| 86 | + } | |
| 87 | + LymsPushAttentionRecord other = (LymsPushAttentionRecord) that; | |
| 88 | + return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) | |
| 89 | + && (this.getPid() == null ? other.getPid() == null : this.getPid().equals(other.getPid())) | |
| 90 | + && (this.getPGzopenid() == null ? other.getPGzopenid() == null : this.getPGzopenid().equals(other.getPGzopenid())) | |
| 91 | + && (this.getPaId() == null ? other.getPaId() == null : this.getPaId().equals(other.getPaId())) | |
| 92 | + && (this.getPaIsweixinType() == null ? other.getPaIsweixinType() == null : this.getPaIsweixinType().equals(other.getPaIsweixinType())) | |
| 93 | + && (this.getPaWeixText() == null ? other.getPaWeixText() == null : this.getPaWeixText().equals(other.getPaWeixText())) | |
| 94 | + && (this.getIsweixinState() == null ? other.getIsweixinState() == null : this.getIsweixinState().equals(other.getIsweixinState())) | |
| 95 | + && (this.getRemark() == null ? other.getRemark() == null : this.getRemark().equals(other.getRemark())) | |
| 96 | + && (this.getPushTime() == null ? other.getPushTime() == null : this.getPushTime().equals(other.getPushTime())); | |
| 97 | + } | |
| 98 | + | |
| 99 | + @Override | |
| 100 | + public int hashCode() { | |
| 101 | + final int prime = 31; | |
| 102 | + int result = 1; | |
| 103 | + result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); | |
| 104 | + result = prime * result + ((getPid() == null) ? 0 : getPid().hashCode()); | |
| 105 | + result = prime * result + ((getPGzopenid() == null) ? 0 : getPGzopenid().hashCode()); | |
| 106 | + result = prime * result + ((getPaId() == null) ? 0 : getPaId().hashCode()); | |
| 107 | + result = prime * result + ((getPaIsweixinType() == null) ? 0 : getPaIsweixinType().hashCode()); | |
| 108 | + result = prime * result + ((getPaWeixText() == null) ? 0 : getPaWeixText().hashCode()); | |
| 109 | + result = prime * result + ((getIsweixinState() == null) ? 0 : getIsweixinState().hashCode()); | |
| 110 | + result = prime * result + ((getRemark() == null) ? 0 : getRemark().hashCode()); | |
| 111 | + result = prime * result + ((getPushTime() == null) ? 0 : getPushTime().hashCode()); | |
| 112 | + return result; | |
| 113 | + } | |
| 114 | + | |
| 115 | + @Override | |
| 116 | + public String toString() { | |
| 117 | + StringBuilder sb = new StringBuilder(); | |
| 118 | + sb.append(getClass().getSimpleName()); | |
| 119 | + sb.append(" ["); | |
| 120 | + sb.append("Hash = ").append(hashCode()); | |
| 121 | + sb.append(", id=").append(id); | |
| 122 | + sb.append(", pid=").append(pid); | |
| 123 | + sb.append(", pGzopenid=").append(pGzopenid); | |
| 124 | + sb.append(", paId=").append(paId); | |
| 125 | + sb.append(", paIsweixinType=").append(paIsweixinType); | |
| 126 | + sb.append(", paWeixText=").append(paWeixText); | |
| 127 | + sb.append(", isweixinState=").append(isweixinState); | |
| 128 | + sb.append(", remark=").append(remark); | |
| 129 | + sb.append(", pushTime=").append(pushTime); | |
| 130 | + sb.append(", serialVersionUID=").append(serialVersionUID); | |
| 131 | + sb.append("]"); | |
| 132 | + return sb.toString(); | |
| 133 | + } | |
| 134 | +} |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsPushAttentionRecordMapper.java
View file @
1637edb
| 1 | +package com.lyms.talkonlineweb.mapper; | |
| 2 | + | |
| 3 | +import com.lyms.talkonlineweb.domain.LymsPushAttentionRecord; | |
| 4 | +import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |
| 5 | + | |
| 6 | +/** | |
| 7 | + * @Entity com.lyms.talkonlineweb.domain.LymsPushAttentionRecord | |
| 8 | + */ | |
| 9 | +public interface LymsPushAttentionRecordMapper extends BaseMapper<LymsPushAttentionRecord> { | |
| 10 | + | |
| 11 | +} |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsPushAttentionRecordService.java
View file @
1637edb
| 1 | +package com.lyms.talkonlineweb.service; | |
| 2 | + | |
| 3 | +import com.lyms.talkonlineweb.domain.LymsPushAttentionRecord; | |
| 4 | +import com.baomidou.mybatisplus.extension.service.IService; | |
| 5 | + | |
| 6 | +/** | |
| 7 | + * | |
| 8 | + */ | |
| 9 | +public interface LymsPushAttentionRecordService extends IService<LymsPushAttentionRecord> { | |
| 10 | + | |
| 11 | +} |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsPushAttentionRecordServiceImpl.java
View file @
1637edb
| 1 | +package com.lyms.talkonlineweb.service.impl; | |
| 2 | + | |
| 3 | +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |
| 4 | +import com.lyms.talkonlineweb.domain.LymsPushAttentionRecord; | |
| 5 | +import com.lyms.talkonlineweb.service.LymsPushAttentionRecordService; | |
| 6 | +import com.lyms.talkonlineweb.mapper.LymsPushAttentionRecordMapper; | |
| 7 | +import org.springframework.stereotype.Service; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * | |
| 11 | + */ | |
| 12 | +@Service | |
| 13 | +public class LymsPushAttentionRecordServiceImpl extends ServiceImpl<LymsPushAttentionRecordMapper, LymsPushAttentionRecord> | |
| 14 | + implements LymsPushAttentionRecordService{ | |
| 15 | + | |
| 16 | +} |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/PushArticleTask.java
View file @
1637edb
| ... | ... | @@ -14,6 +14,8 @@ |
| 14 | 14 | import org.springframework.beans.factory.annotation.Autowired; |
| 15 | 15 | import org.springframework.scheduling.annotation.Scheduled; |
| 16 | 16 | import org.springframework.stereotype.Component; |
| 17 | +import org.springframework.transaction.annotation.Transactional; | |
| 18 | + | |
| 17 | 19 | import java.util.*; |
| 18 | 20 | |
| 19 | 21 | import static com.lyms.talkonlineweb.util.DateUtil.YYYY_MM_DD; |
| 20 | 22 | |
| ... | ... | @@ -41,12 +43,15 @@ |
| 41 | 43 | |
| 42 | 44 | @Autowired |
| 43 | 45 | private LymsDictService lymsDictService; |
| 46 | + @Autowired | |
| 47 | + public LymsPushAttentionRecordService lymsPushAttentionRecordService; | |
| 44 | 48 | |
| 45 | 49 | /** |
| 46 | 50 | * 每天18点执行文章推送 |
| 47 | 51 | */ |
| 48 | 52 | @Scheduled(cron = "0 0 18 * * ?") |
| 49 | 53 | // @Scheduled(cron = "0 15 17 * * ?")//测试用 下午5点15 |
| 54 | + @Transactional(rollbackFor = Exception.class) | |
| 50 | 55 | public void pushArtcle(){ |
| 51 | 56 | Map<String,Object> param=new HashMap<>(); |
| 52 | 57 | param.put("vtype",999); |
| ... | ... | @@ -132,7 +137,7 @@ |
| 132 | 137 | map.put("keyword3",new DataEntity(lymsPushMessage.getDname(),"#173177")); |
| 133 | 138 | map.put("remark",new DataEntity("预祝您早日康复!","#173177")); |
| 134 | 139 | //公众号跳转小程序需要的登录信息 |
| 135 | - Map<String,Object> mapInfo =pLoginInfo(lymsPushMessage); | |
| 140 | + Map<String,Object> mapInfo =pLoginInfo(lymsPushMessage.getPid()); | |
| 136 | 141 | Integer code= WeiXinUtil.SendWeChatMsg(lymsPushMessage.getGzopenid(), Constant.GZ_TEMPLATE_ID,map,mapInfo); |
| 137 | 142 | if(null==code||code!=0){ |
| 138 | 143 | //更新到LymsPushMessages记录 |
| ... | ... | @@ -156,6 +161,8 @@ |
| 156 | 161 | lymsPushMessage.setState(1);//推送状态:0待推送 1成功 2失败。(在备注写失败原因) |
| 157 | 162 | lymsPushMessage.setPushTime(new Date()); |
| 158 | 163 | lymsPushMessagesService.updateById(lymsPushMessage); |
| 164 | + //子女关注的患者推送短消息 | |
| 165 | + pushPatientAttention(lymsPushMessage,map); | |
| 159 | 166 | }else if(lymsPushMessage.getIsweixinTwo()==1){ |
| 160 | 167 | //LymsPushedart的主键id赋值,表示修改。找到以前的推送记录,修改短文字的推送状态 |
| 161 | 168 | pushedart.setId(lymsPushMessage.getPushedartId()); |
| ... | ... | @@ -167,7 +174,7 @@ |
| 167 | 174 | map.put("keyword3",new DataEntity(lymsPushMessage.getDname(),"#173177")); |
| 168 | 175 | map.put("remark",new DataEntity("预祝您早日康复!","#173177")); |
| 169 | 176 | //公众号跳转小程序需要的登录信息 |
| 170 | - Map<String,Object> mapInfo =pLoginInfo(lymsPushMessage); | |
| 177 | + Map<String,Object> mapInfo =pLoginInfo(lymsPushMessage.getPid()); | |
| 171 | 178 | Integer code= WeiXinUtil.SendWeChatMsg(lymsPushMessage.getGzopenid(),Constant.GZ_TEMPLATE_ID,map,mapInfo); |
| 172 | 179 | if(null==code||code!=0){ |
| 173 | 180 | //更新到LymsPushMessages记录 |
| ... | ... | @@ -189,6 +196,8 @@ |
| 189 | 196 | lymsPushMessage.setState(1);//推送状态:0待推送 1成功 2失败。(在备注写失败原因) |
| 190 | 197 | lymsPushMessage.setPushTime(new Date()); |
| 191 | 198 | lymsPushMessagesService.updateById(lymsPushMessage); |
| 199 | + //子女关注的患者推送短消息 | |
| 200 | + pushPatientAttention(lymsPushMessage,map); | |
| 192 | 201 | } |
| 193 | 202 | } |
| 194 | 203 | //更新到LymsPushMessages记录(推送的是文章的情况IsweixinOne和IsweixinTwo都是0的时候) |
| 195 | 204 | |
| 196 | 205 | |
| 197 | 206 | |
| 198 | 207 | |
| ... | ... | @@ -201,28 +210,48 @@ |
| 201 | 210 | } |
| 202 | 211 | } |
| 203 | 212 | } |
| 204 | -public Map<String,Object> pLoginInfo(LymsPushMessages lymsPushMessage){ | |
| 205 | - //获取登录信息 | |
| 206 | - Map<String,Object> map=new HashMap<>(); | |
| 207 | - String plogin=null; | |
| 208 | - LymsPatient lymsPatient = lymsPatientService.getById(lymsPushMessage.getPid()); | |
| 209 | - if(StringUtil.isNotEmpty(lymsPatient.getEnrolmentPhone())){ | |
| 213 | + //用户登录id | |
| 214 | + public Map<String,Object> pLoginInfo(Integer pid){ | |
| 215 | + //获取登录信息 | |
| 216 | + Map<String,Object> map=new HashMap<>(); | |
| 217 | + String plogin=null; | |
| 218 | + LymsPatient lymsPatient = lymsPatientService.getById(pid); | |
| 210 | 219 | if(StringUtil.isNotEmpty(lymsPatient.getEnrolmentPhone())){ |
| 211 | - plogin=lymsPatient.getEnrolmentPhone(); | |
| 220 | + if(StringUtil.isNotEmpty(lymsPatient.getEnrolmentPhone())){ | |
| 221 | + plogin=lymsPatient.getEnrolmentPhone(); | |
| 222 | + } | |
| 212 | 223 | |
| 224 | + }else { | |
| 225 | + List<PatientInfo> pLst=patientInfoService.list(new QueryWrapper<PatientInfo>().eq("id", lymsPatient.getId())); | |
| 226 | + if(CollectionUtils.isNotEmpty(pLst)){ | |
| 227 | + plogin=pLst.get(0).getMobile(); | |
| 228 | + } | |
| 213 | 229 | } |
| 214 | - | |
| 215 | - }else { | |
| 216 | - List<PatientInfo> pLst=patientInfoService.list(new QueryWrapper<PatientInfo>().eq("id", lymsPatient.getId()) | |
| 217 | - .eq("iid", lymsPushMessage.getIid())); | |
| 218 | - if(CollectionUtils.isNotEmpty(pLst)){ | |
| 219 | - plogin=pLst.get(0).getMobile(); | |
| 230 | + map.put("plogin", plogin); | |
| 231 | + map.put("passwd", lymsPatient.getPpasswd()); | |
| 232 | + return map; | |
| 233 | + } | |
| 234 | + //子女关注的患者推送短消息 | |
| 235 | + public void pushPatientAttention(LymsPushMessages lymsPushMessage,Map map){ | |
| 236 | + QueryWrapper<LymsPushAttentionRecord> queryWrapper=new QueryWrapper<>(); | |
| 237 | + queryWrapper.apply("TO_DAYS(created_time) = TO_DAYS(NOW()) and isweixin_state=0");//今天需要推送的消息 | |
| 238 | + final List<LymsPushAttentionRecord> pushAttentionRecords = lymsPushAttentionRecordService.list(queryWrapper); | |
| 239 | + for (LymsPushAttentionRecord pushAttentionRecord : pushAttentionRecords) { | |
| 240 | + Map<String,Object> mapInfo =pLoginInfo(pushAttentionRecord.getPid()); | |
| 241 | + Integer code= WeiXinUtil.SendWeChatMsg(pushAttentionRecord.getPGzopenid(),Constant.GZ_TEMPLATE_ID,map,mapInfo); | |
| 242 | + if(null==code||code!=0){ | |
| 243 | + //更新到 lyms_push_attention_record 记录 | |
| 244 | + pushAttentionRecord.setIsweixinState(2);//推送状态:0待推送 1成功 2失败。(在备注写失败原因) | |
| 245 | + pushAttentionRecord.setRemark("推送短消息"+pushAttentionRecord.getPaIsweixinType()+"失败!"+lymsPushMessage.getPname()+"; code:"+code); | |
| 246 | + pushAttentionRecord.setPushTime(new Date()); | |
| 247 | + lymsPushAttentionRecordService.updateById(pushAttentionRecord); | |
| 248 | + continue; | |
| 249 | + } | |
| 250 | + pushAttentionRecord.setIsweixinState(1);//推送状态:0待推送 1成功 2失败。(在备注写失败原因) | |
| 251 | + pushAttentionRecord.setPushTime(new Date()); | |
| 252 | + lymsPushAttentionRecordService.updateById(pushAttentionRecord); | |
| 220 | 253 | } |
| 221 | 254 | } |
| 222 | - map.put("plogin", plogin); | |
| 223 | - map.put("passwd", lymsPatient.getPpasswd()); | |
| 224 | - return map; | |
| 225 | -} | |
| 226 | 255 | |
| 227 | 256 | } |
| 228 | 257 |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/PushArticleTaskData.java
View file @
1637edb
| 1 | 1 | package com.lyms.talkonlineweb.task; |
| 2 | 2 | |
| 3 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| 4 | -import com.lyms.talkonlineweb.domain.LymsDict; | |
| 5 | -import com.lyms.talkonlineweb.domain.LymsPushMessages; | |
| 6 | -import com.lyms.talkonlineweb.domain.LymsPushedart; | |
| 7 | -import com.lyms.talkonlineweb.domain.PushArticle; | |
| 4 | +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; | |
| 5 | +import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |
| 6 | +import com.lyms.talkonlineweb.domain.*; | |
| 8 | 7 | import com.lyms.talkonlineweb.service.*; |
| 9 | 8 | import com.lyms.talkonlineweb.util.DateUtil; |
| 10 | 9 | import com.lyms.talkonlineweb.util.StringUtil; |
| 11 | 10 | import com.lyms.talkonlineweb.util.WeiXinUtil; |
| 11 | +import com.mysql.cj.Query; | |
| 12 | 12 | import lombok.Data; |
| 13 | 13 | import lombok.extern.log4j.Log4j2; |
| 14 | 14 | import org.springframework.beans.BeanUtils; |
| ... | ... | @@ -16,7 +16,7 @@ |
| 16 | 16 | import org.springframework.beans.factory.annotation.Autowired; |
| 17 | 17 | import org.springframework.scheduling.annotation.Scheduled; |
| 18 | 18 | import org.springframework.stereotype.Component; |
| 19 | -import org.springframework.util.CollectionUtils; | |
| 19 | +import org.springframework.transaction.annotation.Transactional; | |
| 20 | 20 | import org.springframework.util.unit.DataUnit; |
| 21 | 21 | |
| 22 | 22 | import java.util.*; |
| 23 | 23 | |
| 24 | 24 | |
| ... | ... | @@ -45,13 +45,21 @@ |
| 45 | 45 | private LymsDictService lymsDictService; |
| 46 | 46 | @Autowired |
| 47 | 47 | public PushArticleTask pushArticleTask; |
| 48 | + @Autowired | |
| 49 | + public LymsPushAttentionRecordService lymsPushAttentionRecordService; | |
| 50 | + @Autowired | |
| 51 | + private LymsPatientAttentionService lymsPatientAttentionService; | |
| 52 | + @Autowired | |
| 53 | + private LymsPatientService lymsPatientService;//患者 | |
| 48 | 54 | |
| 49 | 55 | |
| 56 | + | |
| 50 | 57 | /** |
| 51 | 58 | * 每天下17点执行-要推送的文章存到数据库 |
| 52 | 59 | */ |
| 53 | 60 | @Scheduled(cron = "0 0 17 * * ?") |
| 54 | 61 | // @Scheduled(cron = "0 */3 * * * ?")//测试用 |
| 62 | + @Transactional(rollbackFor = Exception.class) | |
| 55 | 63 | public void pushArtcleData(){ |
| 56 | 64 | Map<String,Object> param=new HashMap<>(); |
| 57 | 65 | param.put("vtype",999); |
| 58 | 66 | |
| 59 | 67 | |
| 60 | 68 | |
| 61 | 69 | |
| 62 | 70 | |
| 63 | 71 | |
| ... | ... | @@ -82,29 +90,56 @@ |
| 82 | 90 | log.info("数据不同步,不需要推送>>>>>>"); |
| 83 | 91 | return; |
| 84 | 92 | } |
| 85 | - if(!CollectionUtils.isEmpty(lymsPushedartList)){ | |
| 93 | + if(CollectionUtils.isNotEmpty(lymsPushedartList)){ | |
| 86 | 94 | //标记要推送的记录需要推送短消息2 |
| 87 | 95 | lymsPushMessages.setIsweixinTwo(1); |
| 88 | 96 | //存入已推送文章列表id |
| 89 | 97 | lymsPushMessages.setPushedartId(lymsPushedartList.get(0).getId()); |
| 98 | + //子女关注的患者要推送的短消息 | |
| 99 | + pushPatientAttention(lymsPushMessages); | |
| 90 | 100 | }else { |
| 91 | 101 | //标记要推送的记录需要推送短消息1 |
| 92 | 102 | lymsPushMessages.setIsweixinOne(1); |
| 93 | 103 | //需要推送的短消息1 |
| 94 | 104 | lymsPushMessagesService.save(lymsPushMessages); |
| 105 | + //子女关注的患者要推送的短消息 | |
| 106 | + pushPatientAttention(lymsPushMessages); | |
| 95 | 107 | } |
| 96 | 108 | //标记要推送的文章-短消息1标记为0说明这是推送的文章 |
| 97 | 109 | lymsPushMessages.setIsweixinOne(0); |
| 98 | 110 | //保存到要推送的表lyms_push_messages需要推送的文章 |
| 99 | 111 | lymsPushMessagesService.save(lymsPushMessages); |
| 100 | - | |
| 101 | 112 | } catch (BeansException e) { |
| 102 | 113 | e.printStackTrace(); |
| 103 | 114 | } |
| 104 | 115 | } |
| 105 | 116 | } |
| 106 | 117 | // pushArticleTask.pushArtcle();//测试用 |
| 118 | + | |
| 107 | 119 | } |
| 120 | + //子女关注的患者要推送的短消息,数据构建 | |
| 121 | + public void pushPatientAttention(LymsPushMessages lymsPushMessages){ | |
| 122 | + if (null!=lymsPushMessages.getPid()) { | |
| 123 | + final List<LymsPatientAttention> lymsPatientAttentions = lymsPatientAttentionService.list(new QueryWrapper<LymsPatientAttention>().eq("attention_id", lymsPushMessages.getPid())); | |
| 124 | + for (LymsPatientAttention lymsPatientAttention : lymsPatientAttentions) { | |
| 125 | + final LymsPatient patient = lymsPatientService.getOne(new QueryWrapper<LymsPatient>().eq("id", lymsPatientAttention.getPid())); | |
| 126 | + if (null!=patient.getId()) { | |
| 127 | + LymsPushAttentionRecord attentionRecord=new LymsPushAttentionRecord(); | |
| 128 | + attentionRecord.setPid(patient.getId()); | |
| 129 | + attentionRecord.setPGzopenid(patient.getGzopenid()); | |
| 130 | + attentionRecord.setPaId(lymsPushMessages.getPid()); | |
| 131 | + if(null!=lymsPushMessages.getIsweixinOne() && 1==lymsPushMessages.getIsweixinOne()) { | |
| 132 | + attentionRecord.setPaIsweixinType(1); | |
| 133 | + attentionRecord.setPaWeixText(lymsPushMessages.getWeixTextOne()); | |
| 134 | + }else { | |
| 135 | + attentionRecord.setPaIsweixinType(2); | |
| 136 | + attentionRecord.setPaWeixText(lymsPushMessages.getWeixTextTwo()); | |
| 137 | + } | |
| 138 | + lymsPushAttentionRecordService.save(attentionRecord); | |
| 139 | + } | |
| 108 | 140 | |
| 141 | + } | |
| 142 | + } | |
| 143 | + } | |
| 109 | 144 | } |
talkonlineweb/src/main/resources/mapper/LymsPushAttentionRecordMapper.xml
View file @
1637edb
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<!DOCTYPE mapper | |
| 3 | + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |
| 4 | + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |
| 5 | +<mapper namespace="com.lyms.talkonlineweb.mapper.LymsPushAttentionRecordMapper"> | |
| 6 | + | |
| 7 | + <resultMap id="BaseResultMap" type="com.lyms.talkonlineweb.domain.LymsPushAttentionRecord"> | |
| 8 | + <id property="id" column="id" jdbcType="INTEGER"/> | |
| 9 | + <result property="pid" column="pid" jdbcType="INTEGER"/> | |
| 10 | + <result property="pGzopenid" column="p_gzopenid" jdbcType="VARCHAR"/> | |
| 11 | + <result property="paId" column="pa_id" jdbcType="INTEGER"/> | |
| 12 | + <result property="paIsweixinType" column="pa_isweixin_type" jdbcType="INTEGER"/> | |
| 13 | + <result property="paWeixText" column="pa_weix_text" jdbcType="VARCHAR"/> | |
| 14 | + <result property="isweixinState" column="isweixin_state" jdbcType="INTEGER"/> | |
| 15 | + <result property="remark" column="remark" jdbcType="VARCHAR"/> | |
| 16 | + <result property="pushTime" column="push_time" jdbcType="TIMESTAMP"/> | |
| 17 | + <result property="createdTime" column="created_time" jdbcType="TIMESTAMP"/> | |
| 18 | + </resultMap> | |
| 19 | + | |
| 20 | + <sql id="Base_Column_List"> | |
| 21 | + id,pid,p_gzopenid, | |
| 22 | + pa_id,pa_isweixin_type,pa_weix_text, | |
| 23 | + isweixin_state,remark,push_time, | |
| 24 | + created_time | |
| 25 | + </sql> | |
| 26 | +</mapper> |