Merge branch '0418_小程序开发' of http://182.92.166.109:3000/zhuangyuanke/PostDischargePatientManage into 0418_小程序开发
This commit is contained in:
commit
deda0da48b
@ -264,6 +264,11 @@ public class Constants {
|
||||
*/
|
||||
public static final String OFFICIAL_ACCOUNT_TEMPLATE_SEND_URL = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=";
|
||||
|
||||
/**
|
||||
* 微信小程序模板消息推送发送接口地址
|
||||
*/
|
||||
public static final String OFFICIAL_ACCOUNT_SUBSCRIBE_SEND_URL = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=";
|
||||
|
||||
/**
|
||||
* 获取 access_token 时 AppSecret 错误,或者 access_token 无效。请开发者认真比对 AppSecret 的正确性,或查看是否正在为恰当的公众号调用接口
|
||||
*/
|
||||
@ -294,6 +299,11 @@ public class Constants {
|
||||
*/
|
||||
public static final int ARGUMENT_INVALID = 47003;
|
||||
|
||||
/**
|
||||
* api功能未授权
|
||||
*/
|
||||
public static final int API_UNAUTHORIZED = 48001;
|
||||
|
||||
/**
|
||||
* 成功
|
||||
*/
|
||||
|
||||
@ -82,4 +82,12 @@ public class HomePageController extends BaseController {
|
||||
private TableDataInfo satisfactionQuestionnaire(Long residentId) {
|
||||
return homePageService.satisfactionQuestionnaire(residentId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信小程序消息通知跳转页面
|
||||
*/
|
||||
@GetMapping("/subscriptionMessage")
|
||||
public AjaxResult subscriptionMessage(Long id){
|
||||
return homePageService.subscriptionMessage(id);
|
||||
}
|
||||
}
|
||||
@ -6,7 +6,6 @@ import com.xinelu.manage.domain.patienttaskexecuterecord.PatientTaskExecuteRecor
|
||||
import com.xinelu.manage.domain.scriptInfo.ScriptInfo;
|
||||
import com.xinelu.manage.dto.patientquestionsubmitresult.PatientQuestionSubmitResultDTO;
|
||||
import com.xinelu.mobile.vo.myfollowup.MyFollowUpVO;
|
||||
import com.xinelu.mobile.vo.satisfactionquestionnaire.SatisfactionQuestionnaire;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -42,7 +41,7 @@ public interface HomePageService {
|
||||
* @param patientQuestionSubmitResultId 记录表id
|
||||
* @return AjaxResult
|
||||
*/
|
||||
AjaxResult selectQuestionSubmit(Long patientQuestionSubmitResultId,Long patientTaskExecuteRecordId);
|
||||
AjaxResult selectQuestionSubmit(Long patientQuestionSubmitResultId, Long patientTaskExecuteRecordId);
|
||||
|
||||
/**
|
||||
* 问卷提交
|
||||
@ -67,4 +66,12 @@ public interface HomePageService {
|
||||
* @return SatisfactionQuestionnaire
|
||||
*/
|
||||
TableDataInfo satisfactionQuestionnaire(Long residentId);
|
||||
|
||||
/**
|
||||
* 微信小程序消息通知跳转页面
|
||||
*
|
||||
* @param id 节点
|
||||
* @return AjaxResult
|
||||
*/
|
||||
AjaxResult subscriptionMessage(Long id);
|
||||
}
|
||||
@ -26,6 +26,7 @@ import com.xinelu.manage.mapper.questioninfo.QuestionInfoMapper;
|
||||
import com.xinelu.manage.mapper.questionsubject.QuestionSubjectMapper;
|
||||
import com.xinelu.manage.mapper.questionsubjectoption.QuestionSubjectOptionMapper;
|
||||
import com.xinelu.manage.mapper.scriptInfo.ScriptInfoMapper;
|
||||
import com.xinelu.manage.mapper.signpatientmanageroutenode.SignPatientManageRouteNodeMapper;
|
||||
import com.xinelu.manage.vo.questionInfo.QuestionVO;
|
||||
import com.xinelu.manage.vo.questionsubject.QuestionSubjectVO;
|
||||
import com.xinelu.manage.vo.questionsubjectoption.QuestionSubjectOptionVO;
|
||||
@ -70,6 +71,8 @@ public class HomePageServiceImpl implements HomePageService {
|
||||
private PatientQuestionSubjectResultMapper patientQuestionSubjectResultMapper;
|
||||
@Resource
|
||||
private PatientQuestionOptionResultMapper patientQuestionOptionResultMapper;
|
||||
@Resource
|
||||
private SignPatientManageRouteNodeMapper signPatientManageRouteNodeMapper;
|
||||
|
||||
/**
|
||||
* 我的随访列表
|
||||
@ -244,4 +247,18 @@ public class HomePageServiceImpl implements HomePageService {
|
||||
}
|
||||
return pageServiceUtil.getDataTable(satisfactionQuestionnaires);
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信小程序消息通知跳转页面
|
||||
*
|
||||
* @param id 节点
|
||||
* @return AjaxResult
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult subscriptionMessage(Long id) {
|
||||
if (Objects.isNull(id)) {
|
||||
return AjaxResult.error("该节点以清空!");
|
||||
}
|
||||
return AjaxResult.success(signPatientManageRouteNodeMapper.selectSignPatientManageRouteNodeById(id));
|
||||
}
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
package com.xinelu.mobile.service.subscribemessagesendrecord;
|
||||
|
||||
/**
|
||||
* @Description 订阅消息数据业务层
|
||||
* @Author zh
|
||||
* @Date 2024-05-24
|
||||
*/
|
||||
public interface SubscribeMessageSendDataService {
|
||||
|
||||
void subscribeMessageSendDataTask();
|
||||
}
|
||||
@ -1,81 +0,0 @@
|
||||
package com.xinelu.mobile.service.subscribemessagesendrecord.impl;
|
||||
|
||||
import com.xinelu.common.config.WeChatAppletChatConfig;
|
||||
import com.xinelu.common.enums.PatientTypeEnum;
|
||||
import com.xinelu.common.enums.RouteNodeNameEnum;
|
||||
import com.xinelu.common.enums.SubscribeStatusEnum;
|
||||
import com.xinelu.mobile.mapper.homepage.HomePageMapper;
|
||||
import com.xinelu.mobile.service.subscribemessagesendrecord.SubscribeMessageSendDataService;
|
||||
import com.xinelu.mobile.utils.WeChatOfficialAccountUtils;
|
||||
import com.xinelu.mobile.vo.wechatofficialaccountcallback.PatientVO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description 订阅消息数据实现层
|
||||
* @Author zh
|
||||
* @Date 2024-05-24
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class SubscribeMessageSendDataServiceImpl implements SubscribeMessageSendDataService {
|
||||
|
||||
@Resource
|
||||
private HomePageMapper homePageMapper;
|
||||
@Resource
|
||||
private WeChatAppletChatConfig weChatAppletChatConfig;
|
||||
@Resource
|
||||
private WeChatOfficialAccountUtils weChatOfficialAccountUtils;
|
||||
|
||||
public void subscribeMessageSendDataTask() {
|
||||
List<PatientVO> patient = homePageMapper.selectResidentAndSubscribeMessageRecord(SubscribeStatusEnum.accept.getValue(), weChatAppletChatConfig.getSignTemplateId());
|
||||
List<Long> collect = patient.stream().filter(Objects::nonNull).map(PatientVO::getPatientId).filter(Objects::nonNull).collect(Collectors.toList());
|
||||
List<PatientVO> signPatientManageRouteNodes = homePageMapper.selectSignPatientManageRouteNode(collect);
|
||||
List<PatientVO> 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())) {
|
||||
LocalDate localDate = patientVO.getDischargeTime().plusDays(signPatientManageRouteNode.getRouteNodeDay());
|
||||
boolean before = localDate.isEqual(LocalDate.now());
|
||||
if (before) {
|
||||
patientVOS.add(signPatientManageRouteNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
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) {
|
||||
patientVOS.add(signPatientManageRouteNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
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.getDischargeTime() == null) {
|
||||
LocalDate localDate = patientVO.getVisitDate().plusDays(signPatientManageRouteNode.getRouteNodeDay());
|
||||
boolean before = localDate.isEqual(LocalDate.now());
|
||||
if (before) {
|
||||
patientVOS.add(signPatientManageRouteNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (PatientVO patientVO : patientVOS) {
|
||||
weChatOfficialAccountUtils.sendOfficialAccountTemplateMessage(patientVO);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -116,17 +116,21 @@
|
||||
spmrn.task_subdivision,
|
||||
spmrn.applet_push_sign,
|
||||
spmrn.node_content,
|
||||
spmrn.node_execute_status
|
||||
spmrn.node_execute_status,
|
||||
spmr.patient_id
|
||||
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
|
||||
<where>
|
||||
spmr.patient_id in
|
||||
<foreach item="patientId" collection="patientId" open="(" separator="," close=")">
|
||||
#{patientId}
|
||||
</foreach>
|
||||
and node_execute_status = 'UNEXECUTED'
|
||||
and del_flag = 0
|
||||
<if test="patientId != null and patientId.size() > 0">
|
||||
spmr.patient_id in
|
||||
<foreach item="patientId" collection="patientId" open="(" separator="," close=")">
|
||||
#{patientId}
|
||||
</foreach>
|
||||
</if>
|
||||
and spmrn.node_execute_status = 'UNEXECUTED'
|
||||
and spmrn.del_flag = 0
|
||||
and pi.del_flag = 0
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
@ -0,0 +1,30 @@
|
||||
package com.xinelu.quartz.controller;
|
||||
|
||||
import com.xinelu.quartz.task.SubscribeTask;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 消息推送
|
||||
*
|
||||
* @author xinelu
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/monitor/messageSubscription")
|
||||
public class MessageSubscriptionController {
|
||||
|
||||
@Resource
|
||||
private SubscribeTask subscribeTask;
|
||||
|
||||
|
||||
/**
|
||||
* 手动执行专病路径定时任务
|
||||
*/
|
||||
@GetMapping("/signPatientManageRouteNode")
|
||||
public void signPatientManageRouteNode() {
|
||||
subscribeTask.automaticSendSignPatientManageRouteNodeTask();
|
||||
}
|
||||
}
|
||||
@ -1,21 +1,83 @@
|
||||
package com.xinelu.quartz.service.impl;
|
||||
|
||||
import com.xinelu.mobile.service.subscribemessagesendrecord.SubscribeMessageSendDataService;
|
||||
import com.xinelu.common.config.WeChatAppletChatConfig;
|
||||
import com.xinelu.common.enums.PatientTypeEnum;
|
||||
import com.xinelu.common.enums.RouteNodeNameEnum;
|
||||
import com.xinelu.common.enums.SubscribeStatusEnum;
|
||||
import com.xinelu.mobile.mapper.homepage.HomePageMapper;
|
||||
import com.xinelu.mobile.utils.WeChatOfficialAccountUtils;
|
||||
import com.xinelu.mobile.vo.wechatofficialaccountcallback.PatientVO;
|
||||
import com.xinelu.quartz.service.SubscribeTaskService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class subscribeTaskServiceImpl implements SubscribeTaskService {
|
||||
|
||||
@Resource
|
||||
private SubscribeMessageSendDataService subscribeMessageSendRecordService;
|
||||
private HomePageMapper homePageMapper;
|
||||
@Resource
|
||||
private WeChatAppletChatConfig weChatAppletChatConfig;
|
||||
@Resource
|
||||
private WeChatOfficialAccountUtils weChatOfficialAccountUtils;
|
||||
|
||||
@Override
|
||||
public void signPatientManageRouteNodeTask() {
|
||||
subscribeMessageSendRecordService.subscribeMessageSendDataTask();
|
||||
List<PatientVO> patient = homePageMapper.selectResidentAndSubscribeMessageRecord(SubscribeStatusEnum.accept.getValue(), weChatAppletChatConfig.getSignTemplateId());
|
||||
List<Long> collect = patient.stream().filter(Objects::nonNull).map(PatientVO::getPatientId).filter(Objects::nonNull).collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(collect)) {
|
||||
return;
|
||||
}
|
||||
List<PatientVO> signPatientManageRouteNodes = homePageMapper.selectSignPatientManageRouteNode(collect);
|
||||
List<PatientVO> 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())) {
|
||||
LocalDate localDate = patientVO.getDischargeTime().plusDays(signPatientManageRouteNode.getRouteNodeDay());
|
||||
boolean before = localDate.isEqual(LocalDate.now());
|
||||
if (before) {
|
||||
signPatientManageRouteNode.setOpenId(patientVO.getOpenId());
|
||||
patientVOS.add(signPatientManageRouteNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
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());
|
||||
patientVOS.add(signPatientManageRouteNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
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.getDischargeTime() == null) {
|
||||
LocalDate localDate = patientVO.getVisitDate().plusDays(signPatientManageRouteNode.getRouteNodeDay());
|
||||
boolean before = localDate.isEqual(LocalDate.now());
|
||||
if (before) {
|
||||
signPatientManageRouteNode.setOpenId(patientVO.getOpenId());
|
||||
patientVOS.add(signPatientManageRouteNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (PatientVO patientVO : patientVOS) {
|
||||
weChatOfficialAccountUtils.sendOfficialAccountTemplateMessage(patientVO);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ public class SubscribeTask {
|
||||
/**
|
||||
* 签约患者管理任务路径节点消息推送定时任务,每10分钟执行一次
|
||||
*/
|
||||
public void automaticSendGoodsOrderTask() {
|
||||
public void automaticSendSignPatientManageRouteNodeTask() {
|
||||
log.info("开始执行签约患者管理任务路径节点推送定时任务......");
|
||||
subscribeTaskService.signPatientManageRouteNodeTask();
|
||||
log.info("完成订阅签约患者管理任务路径节点推送定时任务......");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user