From 1d4a0a4481c7b1597488a6d46aaf6531160d151b Mon Sep 17 00:00:00 2001 From: zhangheng <3226558941@qq.com> Date: Fri, 5 Jul 2024 17:28:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SubscribeMessageRecord.java | 21 +++++++++- .../mapper/patientinfo/PatientInfoMapper.java | 3 +- .../manage/patientinfo/PatientInfoMapper.xml | 30 ++++++--------- .../mapper/homepage/HomePageMapper.java | 8 ++++ .../homepage/Impl/HomePageServiceImpl.java | 2 +- .../impl/WeChatAppletCallBackServiceImpl.java | 38 +++++++++---------- ...hatOfficialAccountCallbackServiceImpl.java | 4 +- .../utils/WeChatOfficialAccountUtils.java | 3 +- .../mapper/homepage/HomePageMapper.xml | 11 ++++++ .../impl/subscribeTaskServiceImpl.java | 19 ++++++++-- 10 files changed, 91 insertions(+), 48 deletions(-) diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/domain/subscribemessagerecord/SubscribeMessageRecord.java b/postdischarge-manage/src/main/java/com/xinelu/manage/domain/subscribemessagerecord/SubscribeMessageRecord.java index 434714bc..b166b955 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/domain/subscribemessagerecord/SubscribeMessageRecord.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/domain/subscribemessagerecord/SubscribeMessageRecord.java @@ -7,12 +7,12 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.AllArgsConstructor; import lombok.Data; -import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import java.time.LocalDateTime; +import java.util.Objects; /** * 微信小程序订阅消息记录对象 subscribe_message_record @@ -23,7 +23,6 @@ import java.time.LocalDateTime; @Data @AllArgsConstructor @NoArgsConstructor -@EqualsAndHashCode(callSuper = true) @ApiModel(value = "微信小程序订阅消息记录对象", description = "subscribe_message_record") public class SubscribeMessageRecord extends BaseEntity { private static final long serialVersionUID = 1L; @@ -105,6 +104,24 @@ public class SubscribeMessageRecord extends BaseEntity { private String subscribeStatus; + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SubscribeMessageRecord that = (SubscribeMessageRecord) o; + return Objects.equals(openid, that.openid) && Objects.equals(templateId, that.templateId); + } + + @Override + public int hashCode() { + return Objects.hash(openid, templateId); + } + + @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/patientinfo/PatientInfoMapper.java b/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/patientinfo/PatientInfoMapper.java index 6410ed05..bbf95f95 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/patientinfo/PatientInfoMapper.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/patientinfo/PatientInfoMapper.java @@ -1,6 +1,7 @@ package com.xinelu.manage.mapper.patientinfo; import com.xinelu.manage.domain.patientinfo.PatientInfo; +import com.xinelu.manage.domain.residentinfo.ResidentInfo; import com.xinelu.manage.dto.patientinfo.PatientInfoDto; import com.xinelu.manage.vo.patientinfo.PatientBaseInfoVo; import java.util.List; @@ -82,5 +83,5 @@ public interface PatientInfoMapper { * @param openId 微信openId * @return 被护理人基本信息 */ - PatientInfo getPatientInfoByOpenId(String openId); + ResidentInfo getPatientInfoByOpenId(String openId); } diff --git a/postdischarge-manage/src/main/resources/mapper/manage/patientinfo/PatientInfoMapper.xml b/postdischarge-manage/src/main/resources/mapper/manage/patientinfo/PatientInfoMapper.xml index ccbf9da2..c2c42718 100644 --- a/postdischarge-manage/src/main/resources/mapper/manage/patientinfo/PatientInfoMapper.xml +++ b/postdischarge-manage/src/main/resources/mapper/manage/patientinfo/PatientInfoMapper.xml @@ -578,32 +578,26 @@ - SELECT id, - community_code, - area_code, - patient_code, - patient_name, + patient_name, + patient_phone, + family_member_phone, + birth_date, card_no, - user_id, - unionid, - openid, - official_account_openid, - phone, + sex, address, - urgent_contact_name, - urgent_contact_phone, - community_alias_name, - home_longitude, - home_latitude, - head_picture_url + open_id, + union_id, + official_account_openid, + avatar_picture_url FROM - patient_info + resident_info del_flag = 0 - and openid = #{openId} + and open_id = #{openId} diff --git a/postdischarge-mobile/src/main/java/com/xinelu/mobile/mapper/homepage/HomePageMapper.java b/postdischarge-mobile/src/main/java/com/xinelu/mobile/mapper/homepage/HomePageMapper.java index b324f34e..cc22e2d7 100644 --- a/postdischarge-mobile/src/main/java/com/xinelu/mobile/mapper/homepage/HomePageMapper.java +++ b/postdischarge-mobile/src/main/java/com/xinelu/mobile/mapper/homepage/HomePageMapper.java @@ -57,4 +57,12 @@ public interface HomePageMapper { * @return PatientVO */ List selectSignPatientManageRouteNode(@Param("patientId") List patientId); + + /** + * 修改执行状态 + * + * @param signPatientManageRouteNodeIds + * @return int + */ + int updateNodeExecuteStatusByIds(@Param("signPatientManageRouteNodeIds") List signPatientManageRouteNodeIds); } \ No newline at end of file diff --git a/postdischarge-mobile/src/main/java/com/xinelu/mobile/service/homepage/Impl/HomePageServiceImpl.java b/postdischarge-mobile/src/main/java/com/xinelu/mobile/service/homepage/Impl/HomePageServiceImpl.java index cf2a2723..8100ecc9 100644 --- a/postdischarge-mobile/src/main/java/com/xinelu/mobile/service/homepage/Impl/HomePageServiceImpl.java +++ b/postdischarge-mobile/src/main/java/com/xinelu/mobile/service/homepage/Impl/HomePageServiceImpl.java @@ -227,7 +227,7 @@ public class HomePageServiceImpl implements HomePageService { */ @Override public List selectPatientTaskExecuteRecord(Long residentId) { - return homePageMapper.selectTaskExecuteRecordByResidentId(residentId, NodeExecuteStatusEnum.EXECUTED.getInfo()); + return homePageMapper.selectTaskExecuteRecordByResidentId(residentId, null); } /** diff --git a/postdischarge-mobile/src/main/java/com/xinelu/mobile/service/wechatappletcallback/impl/WeChatAppletCallBackServiceImpl.java b/postdischarge-mobile/src/main/java/com/xinelu/mobile/service/wechatappletcallback/impl/WeChatAppletCallBackServiceImpl.java index 501225ef..1064f39a 100644 --- a/postdischarge-mobile/src/main/java/com/xinelu/mobile/service/wechatappletcallback/impl/WeChatAppletCallBackServiceImpl.java +++ b/postdischarge-mobile/src/main/java/com/xinelu/mobile/service/wechatappletcallback/impl/WeChatAppletCallBackServiceImpl.java @@ -4,7 +4,7 @@ import com.xinelu.common.config.WeChatAppletChatConfig; import com.xinelu.common.enums.SubscribeMessageTypeEnum; import com.xinelu.common.exception.ServiceException; import com.xinelu.common.utils.DateUtils; -import com.xinelu.manage.domain.patientinfo.PatientInfo; +import com.xinelu.manage.domain.residentinfo.ResidentInfo; import com.xinelu.manage.domain.subscribemessagerecord.SubscribeMessageRecord; import com.xinelu.manage.domain.subscribemessagesendrecord.SubscribeMessageSendRecord; import com.xinelu.manage.mapper.patientinfo.PatientInfoMapper; @@ -92,9 +92,9 @@ public class WeChatAppletCallBackServiceImpl implements WeChatAppletCallBackServ return; } //查询用户信息表 - PatientInfo patientInfo = patientInfoMapper.getPatientInfoByOpenId(StringUtils.isBlank(weChatMessagePushVO.getFromUserName()) ? "" : weChatMessagePushVO.getFromUserName()); + ResidentInfo residentInfo = patientInfoMapper.getPatientInfoByOpenId(StringUtils.isBlank(weChatMessagePushVO.getFromUserName()) ? "" : weChatMessagePushVO.getFromUserName()); //组装数据 - List subscribeMessageRecordList = createSubscribeMessageRecordList(patientInfo, weChatMessagePushVO, SUBSCRIBE_MSG_POPUP_EVENT); + List subscribeMessageRecordList = createSubscribeMessageRecordList(residentInfo, weChatMessagePushVO, SUBSCRIBE_MSG_POPUP_EVENT); if (CollectionUtils.isEmpty(subscribeMessageRecordList)) { return; } @@ -116,9 +116,9 @@ public class WeChatAppletCallBackServiceImpl implements WeChatAppletCallBackServ //修改订阅信息状态 for (SubscribeMessageRecord messageRecord : intersectionSubscribeList) { Long patientId = null; - if (Objects.nonNull(patientInfo) && Objects.nonNull(patientInfo.getId())) { - patientId = patientInfo.getId(); - } +// if (Objects.nonNull(residentInfo) && Objects.nonNull(residentInfo.getId())) { +// patientId = residentInfo.getId(); +// } String openId = StringUtils.isBlank(messageRecord.getOpenid()) ? "" : messageRecord.getOpenid(); String templateId = StringUtils.isBlank(messageRecord.getTemplateId()) ? "" : messageRecord.getTemplateId(); String subscribeStatus = StringUtils.isBlank(messageRecord.getSubscribeStatus()) ? "" : messageRecord.getSubscribeStatus(); @@ -137,9 +137,9 @@ public class WeChatAppletCallBackServiceImpl implements WeChatAppletCallBackServ return; } //查询用户信息表 - PatientInfo patientInfo = patientInfoMapper.getPatientInfoByOpenId(StringUtils.isBlank(weChatMessagePushVO.getFromUserName()) ? "" : weChatMessagePushVO.getFromUserName()); + ResidentInfo residentInfo = patientInfoMapper.getPatientInfoByOpenId(StringUtils.isBlank(weChatMessagePushVO.getFromUserName()) ? "" : weChatMessagePushVO.getFromUserName()); //组装数据 - List subscribeMessageRecordList = createSubscribeMessageRecordList(patientInfo, weChatMessagePushVO, SUBSCRIBE_MSG_CHANGE_EVENT); + List subscribeMessageRecordList = createSubscribeMessageRecordList(residentInfo, weChatMessagePushVO, SUBSCRIBE_MSG_CHANGE_EVENT); if (CollectionUtils.isEmpty(subscribeMessageRecordList)) { return; } @@ -152,9 +152,9 @@ public class WeChatAppletCallBackServiceImpl implements WeChatAppletCallBackServ //修改订阅信息状态 for (SubscribeMessageRecord messageRecord : intersectionSubscribeList) { Long patientId = null; - if (Objects.nonNull(patientInfo) && Objects.nonNull(patientInfo.getId())) { - patientId = patientInfo.getId(); - } +// if (Objects.nonNull(residentInfo) && Objects.nonNull(residentInfo.getId())) { +// patientId = residentInfo.getId(); +// } String openId = StringUtils.isBlank(messageRecord.getOpenid()) ? "" : messageRecord.getOpenid(); String templateId = StringUtils.isBlank(messageRecord.getTemplateId()) ? "" : messageRecord.getTemplateId(); String subscribeStatus = StringUtils.isBlank(messageRecord.getSubscribeStatus()) ? "" : messageRecord.getSubscribeStatus(); @@ -186,19 +186,19 @@ public class WeChatAppletCallBackServiceImpl implements WeChatAppletCallBackServ /** * 组装订阅消息数据 * - * @param patientInfo 会员用户信息 + * @param residentInfo 会员用户信息 * @param weChatMessagePushVO 微信请求参数信息 * @param eventType 事件类型 * @return List */ - private List createSubscribeMessageRecordList(PatientInfo patientInfo, WeChatMessagePushVO weChatMessagePushVO, String eventType) { + private List createSubscribeMessageRecordList(ResidentInfo residentInfo, WeChatMessagePushVO weChatMessagePushVO, String eventType) { List subscribeMessageRecordList = Lists.newArrayList(); if (SUBSCRIBE_MSG_POPUP_EVENT.equals(eventType)) { subscribeMessageRecordList = weChatMessagePushVO.getSubscribeMsgPopupEvent().getSubscribeMsgPopupEventList().stream().filter(Objects::nonNull).map(item -> { SubscribeMessageRecord subscribe = new SubscribeMessageRecord(); - if (Objects.nonNull(patientInfo) && Objects.nonNull(patientInfo.getId())) { - subscribe.setPatientId(patientInfo.getId()); - } +// if (Objects.nonNull(residentInfo) && Objects.nonNull(residentInfo.getId())) { +// subscribe.setPatientId(residentInfo.getId()); +// } //此处模板通知需要根据实际情况进行修改 subscribe.setOpenid(StringUtils.isBlank(weChatMessagePushVO.getFromUserName()) ? "" : weChatMessagePushVO.getFromUserName()); subscribe.setAppletId(StringUtils.isBlank(weChatMessagePushVO.getToUserName()) ? "" : weChatMessagePushVO.getToUserName()); @@ -216,9 +216,9 @@ public class WeChatAppletCallBackServiceImpl implements WeChatAppletCallBackServ if (SUBSCRIBE_MSG_CHANGE_EVENT.equals(eventType)) { subscribeMessageRecordList = weChatMessagePushVO.getSubscribeMsgChangeEvent().getSubscribeMsgPopupEventList().stream().filter(Objects::nonNull).map(item -> { SubscribeMessageRecord subscribe = new SubscribeMessageRecord(); - if (Objects.nonNull(patientInfo) && Objects.nonNull(patientInfo.getId())) { - subscribe.setPatientId(patientInfo.getId()); - } +// if (Objects.nonNull(residentInfo) && Objects.nonNull(residentInfo.getId())) { +// subscribe.setPatientId(residentInfo.getId()); +// } //此处模板通知需要根据实际情况进行修改 subscribe.setOpenid(StringUtils.isBlank(weChatMessagePushVO.getFromUserName()) ? "" : weChatMessagePushVO.getFromUserName()); subscribe.setAppletId(StringUtils.isBlank(weChatMessagePushVO.getToUserName()) ? "" : weChatMessagePushVO.getToUserName()); diff --git a/postdischarge-mobile/src/main/java/com/xinelu/mobile/service/wechatofficialaccountcallback/impl/WeChatOfficialAccountCallbackServiceImpl.java b/postdischarge-mobile/src/main/java/com/xinelu/mobile/service/wechatofficialaccountcallback/impl/WeChatOfficialAccountCallbackServiceImpl.java index 454c8b63..5a40f065 100644 --- a/postdischarge-mobile/src/main/java/com/xinelu/mobile/service/wechatofficialaccountcallback/impl/WeChatOfficialAccountCallbackServiceImpl.java +++ b/postdischarge-mobile/src/main/java/com/xinelu/mobile/service/wechatofficialaccountcallback/impl/WeChatOfficialAccountCallbackServiceImpl.java @@ -6,7 +6,7 @@ import com.xinelu.common.exception.ServiceException; import com.xinelu.common.utils.DateUtils; import com.xinelu.manage.domain.officialaccountsubscribeevent.OfficialAccountSubscribeEvent; import com.xinelu.manage.domain.officialaccounttemplateevent.OfficialAccountTemplateEvent; -import com.xinelu.manage.domain.patientinfo.PatientInfo; +import com.xinelu.manage.domain.residentinfo.ResidentInfo; import com.xinelu.manage.mapper.officialaccountsubscribeevent.OfficialAccountSubscribeEventMapper; import com.xinelu.manage.mapper.officialaccounttemplateevent.OfficialAccountTemplateEventMapper; import com.xinelu.manage.mapper.patientinfo.PatientInfoMapper; @@ -47,7 +47,7 @@ public class WeChatOfficialAccountCallbackServiceImpl implements WeChatOfficialA @Override public void handleOfficialAccountTemplateEvent(WeChatOfficialAccountEventPushVO eventPushVO) { //查询患者信息 - PatientInfo patientInfo = patientInfoMapper.getPatientInfoByOpenId(eventPushVO.getFromUserName()); + ResidentInfo patientInfo = patientInfoMapper.getPatientInfoByOpenId(eventPushVO.getFromUserName()); if (Objects.isNull(patientInfo)) { log.info("当前患者信息不存在,微信用户openid为:{}", eventPushVO.getFromUserName()); return; diff --git a/postdischarge-mobile/src/main/java/com/xinelu/mobile/utils/WeChatOfficialAccountUtils.java b/postdischarge-mobile/src/main/java/com/xinelu/mobile/utils/WeChatOfficialAccountUtils.java index c0789941..6aca8efe 100644 --- a/postdischarge-mobile/src/main/java/com/xinelu/mobile/utils/WeChatOfficialAccountUtils.java +++ b/postdischarge-mobile/src/main/java/com/xinelu/mobile/utils/WeChatOfficialAccountUtils.java @@ -190,7 +190,7 @@ public class WeChatOfficialAccountUtils { /** * 微信小程序模板消息发送 */ - public void sendAppletTemplateMessage(PatientVO patientVO) { + public Integer sendAppletTemplateMessage(PatientVO patientVO) { //微信模版组装 String thing5 = "每日阅读有助于了解当前情况哦"; String thing1 = "新入院注意事项指导、术前须知"; @@ -252,5 +252,6 @@ public class WeChatOfficialAccountUtils { break; } } + return errCode.getErrcode(); } } diff --git a/postdischarge-mobile/src/main/resources/mapper/homepage/HomePageMapper.xml b/postdischarge-mobile/src/main/resources/mapper/homepage/HomePageMapper.xml index 81d463ab..61ad6e1a 100644 --- a/postdischarge-mobile/src/main/resources/mapper/homepage/HomePageMapper.xml +++ b/postdischarge-mobile/src/main/resources/mapper/homepage/HomePageMapper.xml @@ -137,4 +137,15 @@ and pi.del_flag = 0 + + + update sign_patient_manage_route_node + set node_execute_status = 'EXECUTED' + where + id in + + #{signPatientManageRouteNodeIds} + + \ No newline at end of file diff --git a/postdischarge-quartz/src/main/java/com/xinelu/quartz/service/impl/subscribeTaskServiceImpl.java b/postdischarge-quartz/src/main/java/com/xinelu/quartz/service/impl/subscribeTaskServiceImpl.java index ea660b43..74affbc4 100644 --- a/postdischarge-quartz/src/main/java/com/xinelu/quartz/service/impl/subscribeTaskServiceImpl.java +++ b/postdischarge-quartz/src/main/java/com/xinelu/quartz/service/impl/subscribeTaskServiceImpl.java @@ -49,43 +49,54 @@ public class subscribeTaskServiceImpl implements SubscribeTaskService { continue; } //判断路径节点,组装数据 - if (signPatientManageRouteNode.getRouteNodeName().equals(RouteNodeNameEnum.AFTER_DISCHARGE.getName()) || signPatientManageRouteNode.getRouteNodeName().equals(RouteNodeNameEnum.AFTER_VISIT_DISCHARGE.getName())) { + if (signPatientManageRouteNode.getRouteNodeName().equals(RouteNodeNameEnum.AFTER_DISCHARGE.getInfo()) || signPatientManageRouteNode.getRouteNodeName().equals(RouteNodeNameEnum.AFTER_VISIT_DISCHARGE.getInfo())) { PatientVO patientVO = patient.stream().filter(Objects::nonNull).filter(item -> signPatientManageRouteNode.getPatientId().equals(item.getPatientId())).findFirst().orElse(new PatientVO()); if (patientVO.getPatientType().equals(PatientTypeEnum.DISCHARGED_PATIENT.getInfo())) { LocalDate localDate = patientVO.getDischargeTime().plusDays(signPatientManageRouteNode.getRouteNodeDay()); boolean before = localDate.isEqual(LocalDate.now()); if (before) { signPatientManageRouteNode.setOpenId(patientVO.getOpenId()); + signPatientManageRouteNode.setRouteNodeName(RouteNodeNameEnum.AFTER_DISCHARGE.getName()); patientVOS.add(signPatientManageRouteNode); } } } - if (signPatientManageRouteNode.getRouteNodeName().equals(RouteNodeNameEnum.AFTER_ADMISSION.getName())) { + if (signPatientManageRouteNode.getRouteNodeName().equals(RouteNodeNameEnum.AFTER_ADMISSION.getInfo())) { PatientVO patientVO = patient.stream().filter(Objects::nonNull).filter(item -> signPatientManageRouteNode.getPatientId().equals(item.getPatientId())).findFirst().orElse(new PatientVO()); if (patientVO.getPatientType().equals(PatientTypeEnum.IN_HOSPITAL_PATIENT.getInfo())) { LocalDate localDate = patientVO.getAdmissionTime().plusDays(signPatientManageRouteNode.getRouteNodeDay()); boolean before = localDate.isEqual(LocalDate.now()); if (before) { signPatientManageRouteNode.setOpenId(patientVO.getOpenId()); + signPatientManageRouteNode.setRouteNodeName(RouteNodeNameEnum.AFTER_ADMISSION.getName()); patientVOS.add(signPatientManageRouteNode); } } } - if (signPatientManageRouteNode.getRouteNodeName().equals(RouteNodeNameEnum.AFTER_CONSULTATION.getName()) || signPatientManageRouteNode.getRouteNodeName().equals(RouteNodeNameEnum.AFTER_VISIT_DISCHARGE.getName())) { + if (signPatientManageRouteNode.getRouteNodeName().equals(RouteNodeNameEnum.AFTER_CONSULTATION.getInfo()) || signPatientManageRouteNode.getRouteNodeName().equals(RouteNodeNameEnum.AFTER_VISIT_DISCHARGE.getInfo())) { PatientVO patientVO = patient.stream().filter(Objects::nonNull).filter(item -> signPatientManageRouteNode.getPatientId().equals(item.getPatientId())).findFirst().orElse(new PatientVO()); if (patientVO.getPatientType().equals(PatientTypeEnum.OUTPATIENT.getInfo()) && patientVO.getAdmissionTime() == null) { LocalDate localDate = patientVO.getVisitDate().plusDays(signPatientManageRouteNode.getRouteNodeDay()); boolean before = localDate.isEqual(LocalDate.now()); if (before) { signPatientManageRouteNode.setOpenId(patientVO.getOpenId()); + signPatientManageRouteNode.setRouteNodeName(RouteNodeNameEnum.AFTER_CONSULTATION.getName()); patientVOS.add(signPatientManageRouteNode); } } } } + List signPatientManageRouteNodeIds = new ArrayList<>(); //发送 for (PatientVO patientVO : patientVOS) { - weChatOfficialAccountUtils.sendAppletTemplateMessage(patientVO); + Integer integer = weChatOfficialAccountUtils.sendAppletTemplateMessage(patientVO); + if (integer == 0) { + signPatientManageRouteNodeIds.add(patientVO.getSignPatientManageRouteNodeId()); + } + //更改执行状态 + if (CollectionUtils.isNotEmpty(signPatientManageRouteNodeIds)) { + homePageMapper.updateNodeExecuteStatusByIds(signPatientManageRouteNodeIds); + } } } }