Merge branch '0418_小程序开发' of http://182.92.166.109:3000/zhuangyuanke/PostDischargePatientManage into 0418_小程序开发

This commit is contained in:
haown 2024-08-02 18:00:56 +08:00
commit 1a7c8068b0
3 changed files with 25 additions and 27 deletions

View File

@ -235,10 +235,12 @@
<select id="selectRecordCountByManageRouteNodeIds"
resultType="com.xinelu.manage.vo.subscribemessagesendrecord.RecordNum">
select
manage_route_node_id,
COUNT(1) num
from subscribe_message_send_record
where manage_route_node_id IN
spmrn.id manageRouteNodeId,
COUNT(smsr.id) num
FROM
sign_patient_manage_route_node spmrn
LEFT JOIN subscribe_message_send_record smsr ON spmrn.id = smsr.manage_route_node_id
where spmrn.id IN
<foreach item="manageRouteNodeIds" collection="manageRouteNodeIds" open="(" separator="," close=")">
#{manageRouteNodeIds}
</foreach>

View File

@ -19,10 +19,7 @@ import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
@ -192,14 +189,21 @@ public class WeChatOfficialAccountUtils {
*/
public Integer 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()) && "thing1".equals(item.getName())).findFirst().orElse(new TemplateContent());
thing1 = templateContentTwo.getValue();
List<TemplateContent> templateContents = new ArrayList<>();
String thing5 = null;
String thing1 = null;
try {
//判断推送内容格式是否符合
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()) && "thing1".equals(item.getName())).findFirst().orElse(new TemplateContent());
thing1 = templateContentTwo.getValue();
}
} catch (Exception e) {
thing5 = "每日阅读有助于了解当前情况哦";
thing1 = "新入院注意事项指导、术前须知";
}
//获取微信小程序的accessToken
String accessToken = this.getWeChatAppletAccessToken();
@ -209,7 +213,7 @@ public class WeChatOfficialAccountUtils {
paramsMap.put("template_id", weChatAppletChatConfig.getHealthyPropagandaId());
//跳转小程序类型developer为开发版trial为体验版formal为正式版默认为正式版
//paramsMap.put("miniprogram_state", "developer");
paramsMap.put("page", "pages/propaganda/propaganda?manageRouteNodeId="+patientVO.getSignPatientManageRouteNodeId());
paramsMap.put("page", "pages/pushDetails/pushDetails?manageRouteNodeId=" + patientVO.getSignPatientManageRouteNodeId());
Map<String, Object> dataMap = new LinkedHashMap<>();
dataMap.put("thing5", new MessageValueEntity(thing5));
dataMap.put("thing4", new MessageValueEntity(patientVO.getHospitalAgencyName()));

View File

@ -1,6 +1,5 @@
package com.xinelu.quartz.service.impl;
import com.alibaba.fastjson2.JSON;
import com.xinelu.common.config.PushMessageRestrictions;
import com.xinelu.common.config.WeChatAppletChatConfig;
import com.xinelu.common.enums.*;
@ -9,7 +8,6 @@ import com.xinelu.manage.domain.subscribemessagesendrecord.SubscribeMessageSendR
import com.xinelu.manage.mapper.signpatientmanageroutenode.SignPatientManageRouteNodeMapper;
import com.xinelu.manage.mapper.subscribemessagesendrecord.SubscribeMessageSendRecordMapper;
import com.xinelu.manage.vo.subscribemessagesendrecord.RecordNum;
import com.xinelu.mobile.domain.TemplateContent;
import com.xinelu.mobile.mapper.homepage.HomePageMapper;
import com.xinelu.mobile.utils.WeChatOfficialAccountUtils;
import com.xinelu.mobile.vo.wechatofficialaccountcallback.PatientVO;
@ -87,9 +85,9 @@ public class subscribeTaskServiceImpl implements SubscribeTaskService {
}
boolean before = localDate.isBefore(LocalDate.now()) || localDate.isEqual(LocalDate.now());
if (before) {
long until =localDate.until(LocalDate.now(), ChronoUnit.DAYS);
long until = localDate.until(LocalDate.now(), ChronoUnit.DAYS);
if (until >= pushMessageRestrictions.getTime()) {
expiredManageRouteNodeIds.add(patientVO.getSignPatientManageRouteNodeId());
expiredManageRouteNodeIds.add(signPatientManageRouteNode.getSignPatientManageRouteNodeId());
continue;
}
signPatientManageRouteNode.setOpenId(patientVO.getOpenId());
@ -160,12 +158,6 @@ public class subscribeTaskServiceImpl implements SubscribeTaskService {
//发送失败
List<Long> failSignPatientManageRouteNodeIds = new ArrayList<>();
for (PatientVO patientVO : patientVOList) {
try {
//判断推送内容格式是否符合
JSON.parseArray(patientVO.getAppletNodeContent(), TemplateContent.class);
} catch (Exception e) {
continue;
}
// 开始推送消息
Integer integer = weChatOfficialAccountUtils.sendAppletTemplateMessage(patientVO);
SubscribeMessageSendRecord subscribeMessageSendRecord = new SubscribeMessageSendRecord();