配置修改

This commit is contained in:
zhangheng 2024-07-02 18:13:17 +08:00
parent b60414e5bc
commit 236f2ad958
11 changed files with 90 additions and 90 deletions

View File

@ -203,14 +203,10 @@ wechat-applet-chat-config:
token: uI1NGHesp7ylIYVYQvp0TlcDmUTKCHj2 token: uI1NGHesp7ylIYVYQvp0TlcDmUTKCHj2
# 微信小程序事件回调消息加密密钥 # 微信小程序事件回调消息加密密钥
encoding-aes-key: 5rbyhMBpdnxTEVT54zeHMNcXi3ccilQZ209QqGi89EW encoding-aes-key: 5rbyhMBpdnxTEVT54zeHMNcXi3ccilQZ209QqGi89EW
# 优惠券领取模板id # 随访模板id
coupon-receive-template-id: e1JRZaw1OfTz2b6X9DTqqaJtV4rXEt7uhwXoZLDb_eA follow-template-id: p__w9HO65a8aqgy6OuNG9t_v9_j1dcT81CEA_cdMhaw
# 商品订单支付成功通知模板id # 健康宣教模板id
goods-order-template-id: -IxZeEkkXFhoSwGtBHbipKQ6kjEmkdTkswKeOypSsNQ healthy-propaganda-id: YNeOOaRXbtLFJ1H7HRb9Ot6HADnKO_mg2uLFrqYOhCw
# 预约服务订单通知模板id
appoint-order-template-id: nUB9HRbqQXOVuTpkKBIHMgzWlNq6touzxf5QYBiMkbU
# 签到成功通知模板id
sign-template-id: S_c9bR4znSWpXg-6ACIMn7AkaR11dzo113XM8w4CKz0
# 院后微信公众号参数配置 # 院后微信公众号参数配置
wechat-official-account-config: wechat-official-account-config:

View File

@ -46,22 +46,12 @@ public class WeChatAppletChatConfig {
private String encodingAesKey; private String encodingAesKey;
/** /**
* 优惠券领取模板id * 随访模板id
*/ */
private String couponReceiveTemplateId; private String followTemplateId;
/** /**
* 商品订单支付成功通知模板id * 健康宣教模板id
*/ */
private String goodsOrderTemplateId; private String healthyPropagandaId;
/**
* 预约服务订单通知模板id
*/
private String appointOrderTemplateId;
/**
* 签到通知模板
*/
private String signTemplateId;
} }

View File

@ -12,24 +12,14 @@ import lombok.Getter;
public enum SubscribeMessageTypeEnum { public enum SubscribeMessageTypeEnum {
/** /**
* 预约服务付款通知提醒 * 随访通知提醒
*/ */
APPOINT_ORDER_MESSAGE_PUSH("APPOINT_ORDER_MESSAGE_PUSH"), FOLLOW_MESSAGE_PUSH("FOLLOW_MESSAGE_PUSH"),
/** /**
* 优惠券领取提醒 * 健康宣教提醒
*/ */
COUPON_RECEIVE_MESSAGE_PUSH("COUPON_RECEIVE_MESSAGE_PUSH"), HEALTHY_PROPAGANDA_MESSAGE_PUSH("HEALTHY_PROPAGANDA_MESSAGE_PUSH"),
/**
* 商品订单支付成功提醒
*/
GOODS_ORDER_MESSAGE_PUSH("GOODS_ORDER_MESSAGE_PUSH"),
/**
* 签到积分通知提醒
*/
SIGN_MESSAGE_PUSH("SIGN_MESSAGE_PUSH"),
; ;
final private String info; final private String info;

View File

@ -357,7 +357,7 @@
<if test="portraitStatus != null"> <if test="portraitStatus != null">
and lfc.portrait_status = #{portraitStatus} and lfc.portrait_status = #{portraitStatus}
</if> </if>
Order by tpd.task_partition_sort,lfc.portrait_sn Order by tpd.task_partition_sort,lfc.portrait_sn,lfc.content_sort
</select> </select>
<insert id="insertLabelFieldContentList"> <insert id="insertLabelFieldContentList">

View File

@ -0,0 +1,14 @@
package com.xinelu.mobile.domain;
import lombok.Data;
/**
* 微信内容实体
*/
@Data
public class TemplateContent {
private String name;
private String value;
}

View File

@ -41,7 +41,20 @@ public interface HomePageMapper {
*/ */
List<SatisfactionQuestionnaire> satisfactionQuestionnaireByResidentId(@Param("residentId") Long residentId, @Param("questionType") String questionType, @Param("questionnaireStatus") String questionnaireStatus); List<SatisfactionQuestionnaire> satisfactionQuestionnaireByResidentId(@Param("residentId") Long residentId, @Param("questionType") String questionType, @Param("questionnaireStatus") String questionnaireStatus);
/**
* 微信小程序订阅消息记录表
*
* @param subscribeStatus 状态
* @param templateId 模版
* @return PatientVO
*/
List<PatientVO> selectResidentAndSubscribeMessageRecord(@Param("subscribeStatus") String subscribeStatus, @Param("templateId") String templateId); List<PatientVO> selectResidentAndSubscribeMessageRecord(@Param("subscribeStatus") String subscribeStatus, @Param("templateId") String templateId);
/**
* 患者节点表
*
* @param patientId 患者id
* @return PatientVO
*/
List<PatientVO> selectSignPatientManageRouteNode(@Param("patientId") List<Long> patientId); List<PatientVO> selectSignPatientManageRouteNode(@Param("patientId") List<Long> patientId);
} }

View File

@ -203,17 +203,8 @@ public class WeChatAppletCallBackServiceImpl implements WeChatAppletCallBackServ
subscribe.setOpenid(StringUtils.isBlank(weChatMessagePushVO.getFromUserName()) ? "" : weChatMessagePushVO.getFromUserName()); subscribe.setOpenid(StringUtils.isBlank(weChatMessagePushVO.getFromUserName()) ? "" : weChatMessagePushVO.getFromUserName());
subscribe.setAppletId(StringUtils.isBlank(weChatMessagePushVO.getToUserName()) ? "" : weChatMessagePushVO.getToUserName()); subscribe.setAppletId(StringUtils.isBlank(weChatMessagePushVO.getToUserName()) ? "" : weChatMessagePushVO.getToUserName());
subscribe.setTemplateId(StringUtils.isBlank(item.getTemplateId()) ? "" : item.getTemplateId()); subscribe.setTemplateId(StringUtils.isBlank(item.getTemplateId()) ? "" : item.getTemplateId());
if (StringUtils.isNotBlank(item.getTemplateId()) && appletChatConfig.getCouponReceiveTemplateId().equals(item.getTemplateId())) { if (StringUtils.isNotBlank(item.getTemplateId()) && appletChatConfig.getFollowTemplateId().equals(item.getTemplateId())) {
subscribe.setMessageType(SubscribeMessageTypeEnum.COUPON_RECEIVE_MESSAGE_PUSH.getInfo()); subscribe.setMessageType(SubscribeMessageTypeEnum.FOLLOW_MESSAGE_PUSH.getInfo());
}
if (StringUtils.isNotBlank(item.getTemplateId()) && appletChatConfig.getAppointOrderTemplateId().equals(item.getTemplateId())) {
subscribe.setMessageType(SubscribeMessageTypeEnum.APPOINT_ORDER_MESSAGE_PUSH.getInfo());
}
if (StringUtils.isNotBlank(item.getTemplateId()) && appletChatConfig.getGoodsOrderTemplateId().equals(item.getTemplateId())) {
subscribe.setMessageType(SubscribeMessageTypeEnum.GOODS_ORDER_MESSAGE_PUSH.getInfo());
}
if (StringUtils.isNotBlank(item.getTemplateId()) && appletChatConfig.getSignTemplateId().equals(item.getTemplateId())) {
subscribe.setMessageType(SubscribeMessageTypeEnum.SIGN_MESSAGE_PUSH.getInfo());
} }
subscribe.setSubscribeCount(1); subscribe.setSubscribeCount(1);
subscribe.setSubscribeTime(StringUtils.isBlank(weChatMessagePushVO.getCreateTime()) ? null : DateUtils.timestampToLocalDateTime(Long.parseLong(weChatMessagePushVO.getCreateTime()) * 1000L)); subscribe.setSubscribeTime(StringUtils.isBlank(weChatMessagePushVO.getCreateTime()) ? null : DateUtils.timestampToLocalDateTime(Long.parseLong(weChatMessagePushVO.getCreateTime()) * 1000L));
@ -232,17 +223,8 @@ public class WeChatAppletCallBackServiceImpl implements WeChatAppletCallBackServ
subscribe.setOpenid(StringUtils.isBlank(weChatMessagePushVO.getFromUserName()) ? "" : weChatMessagePushVO.getFromUserName()); subscribe.setOpenid(StringUtils.isBlank(weChatMessagePushVO.getFromUserName()) ? "" : weChatMessagePushVO.getFromUserName());
subscribe.setAppletId(StringUtils.isBlank(weChatMessagePushVO.getToUserName()) ? "" : weChatMessagePushVO.getToUserName()); subscribe.setAppletId(StringUtils.isBlank(weChatMessagePushVO.getToUserName()) ? "" : weChatMessagePushVO.getToUserName());
subscribe.setTemplateId(StringUtils.isBlank(item.getTemplateId()) ? "" : item.getTemplateId()); subscribe.setTemplateId(StringUtils.isBlank(item.getTemplateId()) ? "" : item.getTemplateId());
if (StringUtils.isNotBlank(item.getTemplateId()) && appletChatConfig.getCouponReceiveTemplateId().equals(item.getTemplateId())) { if (StringUtils.isNotBlank(item.getTemplateId()) && appletChatConfig.getFollowTemplateId().equals(item.getTemplateId())) {
subscribe.setMessageType(SubscribeMessageTypeEnum.COUPON_RECEIVE_MESSAGE_PUSH.getInfo()); subscribe.setMessageType(SubscribeMessageTypeEnum.FOLLOW_MESSAGE_PUSH.getInfo());
}
if (StringUtils.isNotBlank(item.getTemplateId()) && appletChatConfig.getAppointOrderTemplateId().equals(item.getTemplateId())) {
subscribe.setMessageType(SubscribeMessageTypeEnum.APPOINT_ORDER_MESSAGE_PUSH.getInfo());
}
if (StringUtils.isNotBlank(item.getTemplateId()) && appletChatConfig.getGoodsOrderTemplateId().equals(item.getTemplateId())) {
subscribe.setMessageType(SubscribeMessageTypeEnum.GOODS_ORDER_MESSAGE_PUSH.getInfo());
}
if (StringUtils.isNotBlank(item.getTemplateId()) && appletChatConfig.getSignTemplateId().equals(item.getTemplateId())) {
subscribe.setMessageType(SubscribeMessageTypeEnum.SIGN_MESSAGE_PUSH.getInfo());
} }
subscribe.setSubscribeCount(1); subscribe.setSubscribeCount(1);
subscribe.setSubscribeTime(StringUtils.isBlank(weChatMessagePushVO.getCreateTime()) ? null : DateUtils.timestampToLocalDateTime(Long.parseLong(weChatMessagePushVO.getCreateTime()) * 1000L)); subscribe.setSubscribeTime(StringUtils.isBlank(weChatMessagePushVO.getCreateTime()) ? null : DateUtils.timestampToLocalDateTime(Long.parseLong(weChatMessagePushVO.getCreateTime()) * 1000L));

View File

@ -8,15 +8,18 @@ import com.xinelu.common.entity.AccessToken;
import com.xinelu.common.entity.MessageValueEntity; import com.xinelu.common.entity.MessageValueEntity;
import com.xinelu.common.exception.ServiceException; import com.xinelu.common.exception.ServiceException;
import com.xinelu.common.utils.http.HttpUtils; import com.xinelu.common.utils.http.HttpUtils;
import com.xinelu.mobile.domain.TemplateContent;
import com.xinelu.mobile.vo.wechatofficialaccountcallback.PatientVO; import com.xinelu.mobile.vo.wechatofficialaccountcallback.PatientVO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.time.LocalDate; import java.time.LocalDateTime;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -187,17 +190,30 @@ public class WeChatOfficialAccountUtils {
* 微信小程序模板消息发送 * 微信小程序模板消息发送
*/ */
public void sendAppletTemplateMessage(PatientVO patientVO) { public void sendAppletTemplateMessage(PatientVO patientVO) {
//微信模版组装
String thing5 = "每日阅读有助于了解当前情况哦";
String thing1 = "新入院注意事项指导、术前须知";
List<TemplateContent> templateContents = JSON.parseArray(patientVO.getAppletNodeContent(), TemplateContent.class);
if (CollectionUtils.isNotEmpty(templateContents)) {
TemplateContent templateContent = templateContents.stream().filter(Objects::nonNull).filter(item -> Objects.nonNull(item.getName()) && Objects.nonNull(item.getValue()) && "thing5".equals(item.getName())).findFirst().orElse(new TemplateContent());
thing5 = templateContent.getValue();
TemplateContent templateContentTwo = templateContents.stream().filter(Objects::nonNull).filter(item -> Objects.nonNull(item.getName()) && Objects.nonNull(item.getValue()) && "thing5".equals(item.getName())).findFirst().orElse(new TemplateContent());
thing1 = templateContentTwo.getValue();
}
//获取微信小程序的accessToken //获取微信小程序的accessToken
String accessToken = this.getWeChatAppletAccessToken(); String accessToken = this.getWeChatAppletAccessToken();
LocalDateTime now = LocalDateTime.now();
//定义模板内容 //定义模板内容
Map<String, Object> paramsMap = new LinkedHashMap<>(); Map<String, Object> paramsMap = new LinkedHashMap<>();
paramsMap.put("touser", patientVO.getOpenId()); paramsMap.put("touser", patientVO.getOpenId());
paramsMap.put("template_id", "S_c9bR4znSWpXg-6ACIMn7AkaR11dzo113XM8w4CKz0"); paramsMap.put("template_id", weChatAppletChatConfig.getHealthyPropagandaId());
paramsMap.put("page", "/postDischarge/homePage/subscriptionMessage?id =" + patientVO.getSignPatientManageRouteNodeId()); paramsMap.put("page", "/postDischarge/homePage/subscriptionMessage?id =" + patientVO.getSignPatientManageRouteNodeId());
Map<String, Object> dataMap = new LinkedHashMap<>(); Map<String, Object> dataMap = new LinkedHashMap<>();
dataMap.put("thing1", new MessageValueEntity("每日签到")); dataMap.put("thing5", new MessageValueEntity(thing5));
dataMap.put("thing2", new MessageValueEntity(LocalDate.now().getYear() + "" + LocalDate.now().getMonthValue() + "" + LocalDate.now().getDayOfMonth() + "日签到成功")); dataMap.put("thing4", new MessageValueEntity(patientVO.getHospitalName()));
dataMap.put("thing3", new MessageValueEntity(patientVO.getRouteNodeName() + "" + patientVO.getRouteNodeDay())); dataMap.put("time3", new MessageValueEntity(now.getYear() + "" + now.getMonthValue() + "" + now.getDayOfMonth() + "" + now.getHour() + ":" + now.getSecond()));
dataMap.put("thing6", new MessageValueEntity(patientVO.getRouteNodeName() + "" + patientVO.getRouteNodeDay()));
dataMap.put("thing1", new MessageValueEntity(thing1));
paramsMap.put("data", dataMap); paramsMap.put("data", dataMap);
//拼接请求地址并发送 //拼接请求地址并发送
String messageUrl = Constants.OFFICIAL_ACCOUNT_SUBSCRIBE_SEND_URL + accessToken; String messageUrl = Constants.OFFICIAL_ACCOUNT_SUBSCRIBE_SEND_URL + accessToken;

View File

@ -1,6 +1,5 @@
package com.xinelu.mobile.vo.wechatofficialaccountcallback; package com.xinelu.mobile.vo.wechatofficialaccountcallback;
import com.xinelu.common.annotation.Excel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@ -9,80 +8,72 @@ import java.time.LocalDate;
@Data @Data
public class PatientVO { public class PatientVO {
/** 居民表 */ @ApiModelProperty(value = "居民表id")
private Long residentId; private Long residentId;
/** 微信标识 */ @ApiModelProperty(value = "微信标识")
private String openId; private String openId;
/** 患者姓名 */ @ApiModelProperty(value = "患者姓名")
private String patientName; private String patientName;
/** 患者手机号 */ @ApiModelProperty(value = "患者手机号")
private String patientPhone; private String patientPhone;
/** 患者身份证号 */ @ApiModelProperty(value = "患者身份证号")
private String cardNo; private String cardNo;
/** 患者类型 */ @ApiModelProperty(value = "患者类型")
private String patientType; private String patientType;
/** 入院时间 */ @ApiModelProperty(value = "入院时间")
private LocalDate admissionTime; private LocalDate admissionTime;
/** 出院时间 */ @ApiModelProperty(value = "出院时间")
private LocalDate dischargeTime; private LocalDate dischargeTime;
/** 就诊时间 */ @ApiModelProperty(value = "就诊时间")
private LocalDate visitDate; private LocalDate visitDate;
@ApiModelProperty(value = "签约患者管理任务表id")
private Long patientId; private Long patientId;
/** 签约患者管理任务表id */
@ApiModelProperty(value = "签约患者管理任务表id") @ApiModelProperty(value = "签约患者管理任务表id")
private Long manageRouteId; private Long manageRouteId;
/** 路径名称(任务名称) */
@ApiModelProperty(value = "路径名称") @ApiModelProperty(value = "路径名称")
private String manageRouteName; private String manageRouteName;
/** 管理路径节点名称 */
@ApiModelProperty(value = "管理路径节点名称") @ApiModelProperty(value = "管理路径节点名称")
private String routeNodeName; private String routeNodeName;
/** 管理路径节点时间,时间单位为:天 */
@ApiModelProperty(value = "管理路径节点时间,时间单位为:天") @ApiModelProperty(value = "管理路径节点时间,时间单位为:天")
private Integer routeNodeDay; private Integer routeNodeDay;
/** 任务类型 */
@ApiModelProperty(value = "任务类型") @ApiModelProperty(value = "任务类型")
private String taskType; private String taskType;
/** 任务状态 */
@ApiModelProperty(value = "任务状态") @ApiModelProperty(value = "任务状态")
private String taskStatus; private String taskStatus;
/** 任务细分 */
@ApiModelProperty(value = "任务细分") @ApiModelProperty(value = "任务细分")
private String taskSubdivision; private String taskSubdivision;
/** 公众号推送标识0未开启1已开启 */
@ApiModelProperty(value = "公众号推送标识0未开启1已开启") @ApiModelProperty(value = "公众号推送标识0未开启1已开启")
private Integer officialPushSign; private Integer officialPushSign;
/** 小程序推送标识0未开启1已开启 */
@ApiModelProperty(value = "小程序推送标识0未开启1已开启") @ApiModelProperty(value = "小程序推送标识0未开启1已开启")
private Integer appletPushSign; private Integer appletPushSign;
/**
* 节点内容
*/
@ApiModelProperty(value = "节点内容") @ApiModelProperty(value = "节点内容")
private String nodeContent; private String nodeContent;
@ApiModelProperty(value = "节点id")
private Long signPatientManageRouteNodeId; private Long signPatientManageRouteNodeId;
@ApiModelProperty(value = "医院名称")
private String hospitalName;
@ApiModelProperty(value = "微信内容")
private String appletNodeContent;
} }

View File

@ -118,7 +118,7 @@
spmrn.applet_push_sign, spmrn.applet_push_sign,
spmrn.node_content, spmrn.node_content,
spmrn.node_execute_status, spmrn.node_execute_status,
spmr.patient_id spmrn.applet_node_content
from sign_patient_manage_route_node spmrn from sign_patient_manage_route_node spmrn
LEFT JOIN sign_patient_manage_route spmr ON spmr.id = spmrn.manage_route_id LEFT JOIN sign_patient_manage_route spmr ON spmr.id = spmrn.manage_route_id
LEFT JOIN patient_info pi ON pi.id = spmr.patient_id LEFT JOIN patient_info pi ON pi.id = spmr.patient_id

View File

@ -30,18 +30,25 @@ public class subscribeTaskServiceImpl implements SubscribeTaskService {
@Resource @Resource
private WeChatOfficialAccountUtils weChatOfficialAccountUtils; private WeChatOfficialAccountUtils weChatOfficialAccountUtils;
/**
* 推送任务组装数据
*/
public void signPatientManageRouteNodeTask() { public void signPatientManageRouteNodeTask() {
List<PatientVO> patient = homePageMapper.selectResidentAndSubscribeMessageRecord(SubscribeStatusEnum.accept.getValue(), weChatAppletChatConfig.getSignTemplateId()); //微信小程序订阅消息记录表
List<PatientVO> patient = homePageMapper.selectResidentAndSubscribeMessageRecord(SubscribeStatusEnum.accept.getValue(), weChatAppletChatConfig.getFollowTemplateId());
List<Long> collect = patient.stream().filter(Objects::nonNull).map(PatientVO::getPatientId).filter(Objects::nonNull).collect(Collectors.toList()); List<Long> collect = patient.stream().filter(Objects::nonNull).map(PatientVO::getPatientId).filter(Objects::nonNull).collect(Collectors.toList());
if (CollectionUtils.isEmpty(collect)) { if (CollectionUtils.isEmpty(collect)) {
return; return;
} }
//患者节点表
List<PatientVO> signPatientManageRouteNodes = homePageMapper.selectSignPatientManageRouteNode(collect); List<PatientVO> signPatientManageRouteNodes = homePageMapper.selectSignPatientManageRouteNode(collect);
List<PatientVO> patientVOS = new ArrayList<>(); List<PatientVO> patientVOS = new ArrayList<>();
for (PatientVO signPatientManageRouteNode : signPatientManageRouteNodes) { for (PatientVO signPatientManageRouteNode : signPatientManageRouteNodes) {
//判断推送状态
if (Objects.isNull(signPatientManageRouteNode.getAppletPushSign()) || signPatientManageRouteNode.getAppletPushSign() != 1) { if (Objects.isNull(signPatientManageRouteNode.getAppletPushSign()) || signPatientManageRouteNode.getAppletPushSign() != 1) {
continue; continue;
} }
//判断路径节点组装数据
if (signPatientManageRouteNode.getRouteNodeName().equals(RouteNodeNameEnum.AFTER_DISCHARGE.getInfo()) || signPatientManageRouteNode.getRouteNodeName().equals(RouteNodeNameEnum.AFTER_VISIT_DISCHARGE.getInfo())) { 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()); 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())) { if (patientVO.getPatientType().equals(PatientTypeEnum.DISCHARGED_PATIENT.getInfo())) {
@ -76,6 +83,7 @@ public class subscribeTaskServiceImpl implements SubscribeTaskService {
} }
} }
} }
//发送
for (PatientVO patientVO : patientVOS) { for (PatientVO patientVO : patientVOS) {
weChatOfficialAccountUtils.sendAppletTemplateMessage(patientVO); weChatOfficialAccountUtils.sendAppletTemplateMessage(patientVO);
} }