定时任务修改
This commit is contained in:
parent
15ae71e230
commit
1d4a0a4481
@ -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)
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -578,32 +578,26 @@
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<select id="getPatientInfoByOpenId" parameterType="string" resultType="patientInfo">
|
||||
<select id="getPatientInfoByOpenId" parameterType="string" resultType="ResidentInfo">
|
||||
SELECT
|
||||
id,
|
||||
community_code,
|
||||
area_code,
|
||||
patient_code,
|
||||
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
|
||||
<where>
|
||||
del_flag = 0
|
||||
<if test="openId != null and openId != ''">
|
||||
and openid = #{openId}
|
||||
and open_id = #{openId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
@ -57,4 +57,12 @@ public interface HomePageMapper {
|
||||
* @return PatientVO
|
||||
*/
|
||||
List<PatientVO> selectSignPatientManageRouteNode(@Param("patientId") List<Long> patientId);
|
||||
|
||||
/**
|
||||
* 修改执行状态
|
||||
*
|
||||
* @param signPatientManageRouteNodeIds
|
||||
* @return int
|
||||
*/
|
||||
int updateNodeExecuteStatusByIds(@Param("signPatientManageRouteNodeIds") List<Long> signPatientManageRouteNodeIds);
|
||||
}
|
||||
@ -227,7 +227,7 @@ public class HomePageServiceImpl implements HomePageService {
|
||||
*/
|
||||
@Override
|
||||
public List<PatientTaskExecuteRecord> selectPatientTaskExecuteRecord(Long residentId) {
|
||||
return homePageMapper.selectTaskExecuteRecordByResidentId(residentId, NodeExecuteStatusEnum.EXECUTED.getInfo());
|
||||
return homePageMapper.selectTaskExecuteRecordByResidentId(residentId, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -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<SubscribeMessageRecord> subscribeMessageRecordList = createSubscribeMessageRecordList(patientInfo, weChatMessagePushVO, SUBSCRIBE_MSG_POPUP_EVENT);
|
||||
List<SubscribeMessageRecord> 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<SubscribeMessageRecord> subscribeMessageRecordList = createSubscribeMessageRecordList(patientInfo, weChatMessagePushVO, SUBSCRIBE_MSG_CHANGE_EVENT);
|
||||
List<SubscribeMessageRecord> 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<SubscribeMessageRecord>
|
||||
*/
|
||||
private List<SubscribeMessageRecord> createSubscribeMessageRecordList(PatientInfo patientInfo, WeChatMessagePushVO weChatMessagePushVO, String eventType) {
|
||||
private List<SubscribeMessageRecord> createSubscribeMessageRecordList(ResidentInfo residentInfo, WeChatMessagePushVO weChatMessagePushVO, String eventType) {
|
||||
List<SubscribeMessageRecord> 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());
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -137,4 +137,15 @@
|
||||
and pi.del_flag = 0
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<update id="updateNodeExecuteStatusByIds">
|
||||
update sign_patient_manage_route_node
|
||||
set node_execute_status = 'EXECUTED'
|
||||
where
|
||||
id in
|
||||
<foreach item="signPatientManageRouteNodeIds" collection="signPatientManageRouteNodeIds" open="(" separator=","
|
||||
close=")">
|
||||
#{signPatientManageRouteNodeIds}
|
||||
</foreach>
|
||||
</update>
|
||||
</mapper>
|
||||
@ -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<Long> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user