diff --git a/postdischarge-admin/src/main/resources/application.yml b/postdischarge-admin/src/main/resources/application.yml
index c9d79cb8..f9d0fd12 100644
--- a/postdischarge-admin/src/main/resources/application.yml
+++ b/postdischarge-admin/src/main/resources/application.yml
@@ -203,14 +203,10 @@ wechat-applet-chat-config:
token: uI1NGHesp7ylIYVYQvp0TlcDmUTKCHj2
# 微信小程序事件回调消息加密密钥
encoding-aes-key: 5rbyhMBpdnxTEVT54zeHMNcXi3ccilQZ209QqGi89EW
- # 优惠券领取模板id
- coupon-receive-template-id: e1JRZaw1OfTz2b6X9DTqqaJtV4rXEt7uhwXoZLDb_eA
- # 商品订单支付成功通知模板id
- goods-order-template-id: -IxZeEkkXFhoSwGtBHbipKQ6kjEmkdTkswKeOypSsNQ
- # 预约服务订单通知模板id
- appoint-order-template-id: nUB9HRbqQXOVuTpkKBIHMgzWlNq6touzxf5QYBiMkbU
- # 签到成功通知模板id
- sign-template-id: S_c9bR4znSWpXg-6ACIMn7AkaR11dzo113XM8w4CKz0
+ # 随访模板id
+ follow-template-id: p__w9HO65a8aqgy6OuNG9t_v9_j1dcT81CEA_cdMhaw
+ # 健康宣教模板id
+ healthy-propaganda-id: YNeOOaRXbtLFJ1H7HRb9Ot6HADnKO_mg2uLFrqYOhCw
# 院后微信公众号参数配置
wechat-official-account-config:
diff --git a/postdischarge-common/src/main/java/com/xinelu/common/config/WeChatAppletChatConfig.java b/postdischarge-common/src/main/java/com/xinelu/common/config/WeChatAppletChatConfig.java
index d2db2da6..939fd2d2 100644
--- a/postdischarge-common/src/main/java/com/xinelu/common/config/WeChatAppletChatConfig.java
+++ b/postdischarge-common/src/main/java/com/xinelu/common/config/WeChatAppletChatConfig.java
@@ -46,22 +46,12 @@ public class WeChatAppletChatConfig {
private String encodingAesKey;
/**
- * 优惠券领取模板id
+ * 随访模板id
*/
- private String couponReceiveTemplateId;
+ private String followTemplateId;
/**
- * 商品订单支付成功通知模板id
+ * 健康宣教模板id
*/
- private String goodsOrderTemplateId;
-
- /**
- * 预约服务订单通知模板id
- */
- private String appointOrderTemplateId;
-
- /**
- * 签到通知模板
- */
- private String signTemplateId;
+ private String healthyPropagandaId;
}
diff --git a/postdischarge-common/src/main/java/com/xinelu/common/enums/SubscribeMessageTypeEnum.java b/postdischarge-common/src/main/java/com/xinelu/common/enums/SubscribeMessageTypeEnum.java
index a2ce93f0..ba10629c 100644
--- a/postdischarge-common/src/main/java/com/xinelu/common/enums/SubscribeMessageTypeEnum.java
+++ b/postdischarge-common/src/main/java/com/xinelu/common/enums/SubscribeMessageTypeEnum.java
@@ -12,24 +12,14 @@ import lombok.Getter;
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"),
-
- /**
- * 商品订单支付成功提醒
- */
- GOODS_ORDER_MESSAGE_PUSH("GOODS_ORDER_MESSAGE_PUSH"),
-
- /**
- * 签到积分通知提醒
- */
- SIGN_MESSAGE_PUSH("SIGN_MESSAGE_PUSH"),
+ HEALTHY_PROPAGANDA_MESSAGE_PUSH("HEALTHY_PROPAGANDA_MESSAGE_PUSH"),
;
final private String info;
diff --git a/postdischarge-manage/src/main/resources/mapper/manage/labelfieldcontent/LabelFieldContentMapper.xml b/postdischarge-manage/src/main/resources/mapper/manage/labelfieldcontent/LabelFieldContentMapper.xml
index bf330aa4..9fa13096 100644
--- a/postdischarge-manage/src/main/resources/mapper/manage/labelfieldcontent/LabelFieldContentMapper.xml
+++ b/postdischarge-manage/src/main/resources/mapper/manage/labelfieldcontent/LabelFieldContentMapper.xml
@@ -357,7 +357,7 @@
and lfc.portrait_status = #{portraitStatus}
- Order by tpd.task_partition_sort,lfc.portrait_sn
+ Order by tpd.task_partition_sort,lfc.portrait_sn,lfc.content_sort
diff --git a/postdischarge-mobile/src/main/java/com/xinelu/mobile/domain/TemplateContent.java b/postdischarge-mobile/src/main/java/com/xinelu/mobile/domain/TemplateContent.java
new file mode 100644
index 00000000..9243e4d0
--- /dev/null
+++ b/postdischarge-mobile/src/main/java/com/xinelu/mobile/domain/TemplateContent.java
@@ -0,0 +1,14 @@
+package com.xinelu.mobile.domain;
+
+import lombok.Data;
+
+/**
+ * 微信内容实体
+ */
+@Data
+public class TemplateContent {
+
+ private String name;
+
+ private String value;
+}
\ No newline at end of file
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 a6796b59..b324f34e 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
@@ -41,7 +41,20 @@ public interface HomePageMapper {
*/
List satisfactionQuestionnaireByResidentId(@Param("residentId") Long residentId, @Param("questionType") String questionType, @Param("questionnaireStatus") String questionnaireStatus);
+ /**
+ * 微信小程序订阅消息记录表
+ *
+ * @param subscribeStatus 状态
+ * @param templateId 模版
+ * @return PatientVO
+ */
List selectResidentAndSubscribeMessageRecord(@Param("subscribeStatus") String subscribeStatus, @Param("templateId") String templateId);
+ /**
+ * 患者节点表
+ *
+ * @param patientId 患者id
+ * @return PatientVO
+ */
List selectSignPatientManageRouteNode(@Param("patientId") List patientId);
}
\ No newline at end of file
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 56c427dd..501225ef 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
@@ -203,17 +203,8 @@ public class WeChatAppletCallBackServiceImpl implements WeChatAppletCallBackServ
subscribe.setOpenid(StringUtils.isBlank(weChatMessagePushVO.getFromUserName()) ? "" : weChatMessagePushVO.getFromUserName());
subscribe.setAppletId(StringUtils.isBlank(weChatMessagePushVO.getToUserName()) ? "" : weChatMessagePushVO.getToUserName());
subscribe.setTemplateId(StringUtils.isBlank(item.getTemplateId()) ? "" : item.getTemplateId());
- if (StringUtils.isNotBlank(item.getTemplateId()) && appletChatConfig.getCouponReceiveTemplateId().equals(item.getTemplateId())) {
- subscribe.setMessageType(SubscribeMessageTypeEnum.COUPON_RECEIVE_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());
+ if (StringUtils.isNotBlank(item.getTemplateId()) && appletChatConfig.getFollowTemplateId().equals(item.getTemplateId())) {
+ subscribe.setMessageType(SubscribeMessageTypeEnum.FOLLOW_MESSAGE_PUSH.getInfo());
}
subscribe.setSubscribeCount(1);
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.setAppletId(StringUtils.isBlank(weChatMessagePushVO.getToUserName()) ? "" : weChatMessagePushVO.getToUserName());
subscribe.setTemplateId(StringUtils.isBlank(item.getTemplateId()) ? "" : item.getTemplateId());
- if (StringUtils.isNotBlank(item.getTemplateId()) && appletChatConfig.getCouponReceiveTemplateId().equals(item.getTemplateId())) {
- subscribe.setMessageType(SubscribeMessageTypeEnum.COUPON_RECEIVE_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());
+ if (StringUtils.isNotBlank(item.getTemplateId()) && appletChatConfig.getFollowTemplateId().equals(item.getTemplateId())) {
+ subscribe.setMessageType(SubscribeMessageTypeEnum.FOLLOW_MESSAGE_PUSH.getInfo());
}
subscribe.setSubscribeCount(1);
subscribe.setSubscribeTime(StringUtils.isBlank(weChatMessagePushVO.getCreateTime()) ? null : DateUtils.timestampToLocalDateTime(Long.parseLong(weChatMessagePushVO.getCreateTime()) * 1000L));
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 ba8ec775..36aacd0b 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
@@ -8,15 +8,18 @@ import com.xinelu.common.entity.AccessToken;
import com.xinelu.common.entity.MessageValueEntity;
import com.xinelu.common.exception.ServiceException;
import com.xinelu.common.utils.http.HttpUtils;
+import com.xinelu.mobile.domain.TemplateContent;
import com.xinelu.mobile.vo.wechatofficialaccountcallback.PatientVO;
import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
-import java.time.LocalDate;
+import java.time.LocalDateTime;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
@@ -187,17 +190,30 @@ public class WeChatOfficialAccountUtils {
* 微信小程序模板消息发送
*/
public void sendAppletTemplateMessage(PatientVO patientVO) {
+ //微信模版组装
+ String thing5 = "每日阅读有助于了解当前情况哦";
+ String thing1 = "新入院注意事项指导、术前须知";
+ List 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
String accessToken = this.getWeChatAppletAccessToken();
+ LocalDateTime now = LocalDateTime.now();
//定义模板内容
Map paramsMap = new LinkedHashMap<>();
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());
Map dataMap = new LinkedHashMap<>();
- dataMap.put("thing1", new MessageValueEntity("每日签到"));
- dataMap.put("thing2", new MessageValueEntity(LocalDate.now().getYear() + "年" + LocalDate.now().getMonthValue() + "月" + LocalDate.now().getDayOfMonth() + "日签到成功"));
- dataMap.put("thing3", new MessageValueEntity(patientVO.getRouteNodeName() + "第" + patientVO.getRouteNodeDay()));
+ dataMap.put("thing5", new MessageValueEntity(thing5));
+ dataMap.put("thing4", new MessageValueEntity(patientVO.getHospitalName()));
+ 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);
//拼接请求地址并发送
String messageUrl = Constants.OFFICIAL_ACCOUNT_SUBSCRIBE_SEND_URL + accessToken;
diff --git a/postdischarge-mobile/src/main/java/com/xinelu/mobile/vo/wechatofficialaccountcallback/PatientVO.java b/postdischarge-mobile/src/main/java/com/xinelu/mobile/vo/wechatofficialaccountcallback/PatientVO.java
index 83abc4bf..6fed97de 100644
--- a/postdischarge-mobile/src/main/java/com/xinelu/mobile/vo/wechatofficialaccountcallback/PatientVO.java
+++ b/postdischarge-mobile/src/main/java/com/xinelu/mobile/vo/wechatofficialaccountcallback/PatientVO.java
@@ -1,6 +1,5 @@
package com.xinelu.mobile.vo.wechatofficialaccountcallback;
-import com.xinelu.common.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -9,80 +8,72 @@ import java.time.LocalDate;
@Data
public class PatientVO {
- /** 居民表 */
+ @ApiModelProperty(value = "居民表id")
private Long residentId;
- /** 微信标识 */
+ @ApiModelProperty(value = "微信标识")
private String openId;
- /** 患者姓名 */
+ @ApiModelProperty(value = "患者姓名")
private String patientName;
- /** 患者手机号 */
+ @ApiModelProperty(value = "患者手机号")
private String patientPhone;
- /** 患者身份证号 */
+ @ApiModelProperty(value = "患者身份证号")
private String cardNo;
- /** 患者类型 */
+ @ApiModelProperty(value = "患者类型")
private String patientType;
- /** 入院时间 */
+ @ApiModelProperty(value = "入院时间")
private LocalDate admissionTime;
- /** 出院时间 */
+ @ApiModelProperty(value = "出院时间")
private LocalDate dischargeTime;
- /** 就诊时间 */
+ @ApiModelProperty(value = "就诊时间")
private LocalDate visitDate;
+ @ApiModelProperty(value = "签约患者管理任务表id")
private Long patientId;
- /** 签约患者管理任务表id */
@ApiModelProperty(value = "签约患者管理任务表id")
private Long manageRouteId;
- /** 路径名称(任务名称) */
@ApiModelProperty(value = "路径名称")
private String manageRouteName;
- /** 管理路径节点名称 */
@ApiModelProperty(value = "管理路径节点名称")
private String routeNodeName;
-
- /** 管理路径节点时间,时间单位为:天 */
@ApiModelProperty(value = "管理路径节点时间,时间单位为:天")
private Integer routeNodeDay;
- /** 任务类型 */
@ApiModelProperty(value = "任务类型")
private String taskType;
- /** 任务状态 */
@ApiModelProperty(value = "任务状态")
private String taskStatus;
- /** 任务细分 */
@ApiModelProperty(value = "任务细分")
private String taskSubdivision;
-
- /** 公众号推送标识,0:未开启,1:已开启 */
@ApiModelProperty(value = "公众号推送标识,0:未开启,1:已开启")
private Integer officialPushSign;
- /** 小程序推送标识,0:未开启,1:已开启 */
@ApiModelProperty(value = "小程序推送标识,0:未开启,1:已开启")
private Integer appletPushSign;
- /**
- * 节点内容
- */
@ApiModelProperty(value = "节点内容")
private String nodeContent;
+ @ApiModelProperty(value = "节点id")
private Long signPatientManageRouteNodeId;
+ @ApiModelProperty(value = "医院名称")
+ private String hospitalName;
+ @ApiModelProperty(value = "微信内容")
+ private String appletNodeContent;
}
diff --git a/postdischarge-mobile/src/main/resources/mapper/homepage/HomePageMapper.xml b/postdischarge-mobile/src/main/resources/mapper/homepage/HomePageMapper.xml
index 7ed0eddf..74424dbd 100644
--- a/postdischarge-mobile/src/main/resources/mapper/homepage/HomePageMapper.xml
+++ b/postdischarge-mobile/src/main/resources/mapper/homepage/HomePageMapper.xml
@@ -118,7 +118,7 @@
spmrn.applet_push_sign,
spmrn.node_content,
spmrn.node_execute_status,
- spmr.patient_id
+ spmrn.applet_node_content
from sign_patient_manage_route_node spmrn
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
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 3e9fe107..ed936a54 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
@@ -30,18 +30,25 @@ public class subscribeTaskServiceImpl implements SubscribeTaskService {
@Resource
private WeChatOfficialAccountUtils weChatOfficialAccountUtils;
+ /**
+ * 推送任务组装数据
+ */
public void signPatientManageRouteNodeTask() {
- List patient = homePageMapper.selectResidentAndSubscribeMessageRecord(SubscribeStatusEnum.accept.getValue(), weChatAppletChatConfig.getSignTemplateId());
+ //微信小程序订阅消息记录表
+ List patient = homePageMapper.selectResidentAndSubscribeMessageRecord(SubscribeStatusEnum.accept.getValue(), weChatAppletChatConfig.getFollowTemplateId());
List collect = patient.stream().filter(Objects::nonNull).map(PatientVO::getPatientId).filter(Objects::nonNull).collect(Collectors.toList());
if (CollectionUtils.isEmpty(collect)) {
return;
}
+ //患者节点表
List signPatientManageRouteNodes = homePageMapper.selectSignPatientManageRouteNode(collect);
List patientVOS = new ArrayList<>();
for (PatientVO signPatientManageRouteNode : signPatientManageRouteNodes) {
+ //判断推送状态
if (Objects.isNull(signPatientManageRouteNode.getAppletPushSign()) || signPatientManageRouteNode.getAppletPushSign() != 1) {
continue;
}
+ //判断路径节点,组装数据
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())) {
@@ -76,6 +83,7 @@ public class subscribeTaskServiceImpl implements SubscribeTaskService {
}
}
}
+ //发送
for (PatientVO patientVO : patientVOS) {
weChatOfficialAccountUtils.sendAppletTemplateMessage(patientVO);
}