消息推送修改
This commit is contained in:
parent
ce17d4606d
commit
b9a125dade
@ -19,6 +19,11 @@ public enum NodeExecuteResultStatusEnum {
|
|||||||
* 失败
|
* 失败
|
||||||
*/
|
*/
|
||||||
FAILURE("FAILURE"),
|
FAILURE("FAILURE"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 过期
|
||||||
|
*/
|
||||||
|
EXPIRED("EXPIRED"),
|
||||||
;
|
;
|
||||||
|
|
||||||
final private String info;
|
final private String info;
|
||||||
|
|||||||
@ -66,7 +66,7 @@ public interface HomePageMapper {
|
|||||||
* @param signPatientManageRouteNodeIds 节点id
|
* @param signPatientManageRouteNodeIds 节点id
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
int updateNodeExecuteStatusByIds(@Param("signPatientManageRouteNodeIds") List<Long> signPatientManageRouteNodeIds);
|
int updateNodeExecuteStatusByIds(@Param("signPatientManageRouteNodeIds") List<Long> signPatientManageRouteNodeIds, @Param("nodeExecuteStatus") String nodeExecuteStatus, @Param("appletNodeExecuteResultStatus") String appletNodeExecuteResultStatus);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询个人任务消息
|
* 查询个人任务消息
|
||||||
|
|||||||
@ -70,15 +70,15 @@
|
|||||||
|
|
||||||
<select id="satisfactionQuestionnaireByResidentId"
|
<select id="satisfactionQuestionnaireByResidentId"
|
||||||
resultType="com.xinelu.mobile.vo.satisfactionquestionnaire.SatisfactionQuestionnaire">
|
resultType="com.xinelu.mobile.vo.satisfactionquestionnaire.SatisfactionQuestionnaire">
|
||||||
SELECT spmrn.question_info_id templateId,
|
SELECT spmrn.question_info_id templateId,
|
||||||
spmrn.questionnaire_name,
|
spmrn.questionnaire_name,
|
||||||
pqsr.create_time executeTime,
|
pqsr.create_time executeTime,
|
||||||
spmrn.id manageRouteNodeId,
|
spmrn.id manageRouteNodeId,
|
||||||
(SELECT id
|
(SELECT id
|
||||||
FROM patient_question_submit_result pqsr2
|
FROM patient_question_submit_result pqsr2
|
||||||
WHERE pqsr2.resident_id = #{residentId}
|
WHERE pqsr2.resident_id = #{residentId}
|
||||||
AND pqsr2.question_info_id = spmrn.question_info_id
|
AND pqsr2.question_info_id = spmrn.question_info_id
|
||||||
AND pqsr2.manage_route_node_id = spmrn.id ) patientQuestionSubmitResultId
|
AND pqsr2.manage_route_node_id = spmrn.id) patientQuestionSubmitResultId
|
||||||
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
|
||||||
@ -133,6 +133,7 @@
|
|||||||
LEFT JOIN patient_info pi ON pi.id = spmr.patient_id
|
LEFT JOIN patient_info pi ON pi.id = spmr.patient_id
|
||||||
where
|
where
|
||||||
spmrn.node_execute_status = 'UNEXECUTED'
|
spmrn.node_execute_status = 'UNEXECUTED'
|
||||||
|
and (spmrn.applet_node_execute_result_status is null or spmrn.applet_node_execute_result_status = '')
|
||||||
and spmrn.del_flag = 0
|
and spmrn.del_flag = 0
|
||||||
and spmrn.applet_push_sign = 1
|
and spmrn.applet_push_sign = 1
|
||||||
and pi.del_flag = 0
|
and pi.del_flag = 0
|
||||||
@ -148,9 +149,9 @@
|
|||||||
|
|
||||||
<update id="updateNodeExecuteStatusByIds">
|
<update id="updateNodeExecuteStatusByIds">
|
||||||
update sign_patient_manage_route_node
|
update sign_patient_manage_route_node
|
||||||
set node_execute_status = 'EXECUTED'
|
set node_execute_status = #{nodeExecuteStatus},
|
||||||
where
|
applet_node_execute_result_status = #{appletNodeExecuteResultStatus}
|
||||||
id in
|
where id in
|
||||||
<foreach item="signPatientManageRouteNodeIds" collection="signPatientManageRouteNodeIds" open="(" separator=","
|
<foreach item="signPatientManageRouteNodeIds" collection="signPatientManageRouteNodeIds" open="(" separator=","
|
||||||
close=")">
|
close=")">
|
||||||
#{signPatientManageRouteNodeIds}
|
#{signPatientManageRouteNodeIds}
|
||||||
|
|||||||
@ -2,8 +2,10 @@ package com.xinelu.quartz.service.impl;
|
|||||||
|
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.xinelu.common.config.WeChatAppletChatConfig;
|
import com.xinelu.common.config.WeChatAppletChatConfig;
|
||||||
import com.xinelu.common.enums.RouteNodeNameEnum;
|
import com.xinelu.common.enums.*;
|
||||||
import com.xinelu.common.enums.SubscribeStatusEnum;
|
import com.xinelu.common.utils.SecurityUtils;
|
||||||
|
import com.xinelu.manage.domain.subscribemessagesendrecord.SubscribeMessageSendRecord;
|
||||||
|
import com.xinelu.manage.mapper.subscribemessagesendrecord.SubscribeMessageSendRecordMapper;
|
||||||
import com.xinelu.mobile.domain.TemplateContent;
|
import com.xinelu.mobile.domain.TemplateContent;
|
||||||
import com.xinelu.mobile.mapper.homepage.HomePageMapper;
|
import com.xinelu.mobile.mapper.homepage.HomePageMapper;
|
||||||
import com.xinelu.mobile.utils.WeChatOfficialAccountUtils;
|
import com.xinelu.mobile.utils.WeChatOfficialAccountUtils;
|
||||||
@ -15,6 +17,7 @@ import org.springframework.stereotype.Service;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -35,6 +38,8 @@ public class subscribeTaskServiceImpl implements SubscribeTaskService {
|
|||||||
private WeChatAppletChatConfig weChatAppletChatConfig;
|
private WeChatAppletChatConfig weChatAppletChatConfig;
|
||||||
@Resource
|
@Resource
|
||||||
private WeChatOfficialAccountUtils weChatOfficialAccountUtils;
|
private WeChatOfficialAccountUtils weChatOfficialAccountUtils;
|
||||||
|
@Resource
|
||||||
|
private SubscribeMessageSendRecordMapper subscribeMessageSendRecordMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 推送任务组装数据
|
* 推送任务组装数据
|
||||||
@ -50,6 +55,8 @@ public class subscribeTaskServiceImpl implements SubscribeTaskService {
|
|||||||
List<PatientVO> signPatientManageRouteNodes = homePageMapper.selectSignPatientManageRouteNode(patientIdList);
|
List<PatientVO> signPatientManageRouteNodes = homePageMapper.selectSignPatientManageRouteNode(patientIdList);
|
||||||
// 注:PatientVO 包含签约路径节点相关属性,后面用于推送消息
|
// 注:PatientVO 包含签约路径节点相关属性,后面用于推送消息
|
||||||
List<PatientVO> patientVOList = new ArrayList<>();
|
List<PatientVO> patientVOList = new ArrayList<>();
|
||||||
|
//发送消息到期节点id集合
|
||||||
|
List<Long> expiredManageRouteNodeIds = 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) {
|
||||||
@ -69,12 +76,21 @@ public class subscribeTaskServiceImpl implements SubscribeTaskService {
|
|||||||
}
|
}
|
||||||
boolean before = localDate.isBefore(LocalDate.now()) || localDate.isEqual(LocalDate.now());
|
boolean before = localDate.isBefore(LocalDate.now()) || localDate.isEqual(LocalDate.now());
|
||||||
if (before) {
|
if (before) {
|
||||||
|
int i = LocalDate.now().compareTo(localDate);
|
||||||
|
if (i >= 1) {
|
||||||
|
expiredManageRouteNodeIds.add(patientVO.getSignPatientManageRouteNodeId());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
signPatientManageRouteNode.setOpenId(patientVO.getOpenId());
|
signPatientManageRouteNode.setOpenId(patientVO.getOpenId());
|
||||||
//转换成中文……
|
//转换成中文……
|
||||||
signPatientManageRouteNode.setRouteNodeName(RouteNodeNameEnum.getNameByInfo(signPatientManageRouteNode.getRouteNodeName()).getName());
|
signPatientManageRouteNode.setRouteNodeName(RouteNodeNameEnum.getNameByInfo(signPatientManageRouteNode.getRouteNodeName()).getName());
|
||||||
patientVOList.add(signPatientManageRouteNode);
|
patientVOList.add(signPatientManageRouteNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//更改过期执行状态
|
||||||
|
if (CollectionUtils.isNotEmpty(expiredManageRouteNodeIds)) {
|
||||||
|
homePageMapper.updateNodeExecuteStatusByIds(expiredManageRouteNodeIds, NodeExecuteStatusEnum.EXECUTED.getInfo(), NodeExecuteResultStatusEnum.EXPIRED.getInfo());
|
||||||
|
}
|
||||||
|
|
||||||
// //如果节点 适用范围是 出院后或就诊/出院后
|
// //如果节点 适用范围是 出院后或就诊/出院后
|
||||||
// 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())) {
|
||||||
@ -121,9 +137,9 @@ public class subscribeTaskServiceImpl implements SubscribeTaskService {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
List<Long> signPatientManageRouteNodeIds = new ArrayList<>();
|
|
||||||
//发送
|
//发送
|
||||||
|
//发送失败id集合
|
||||||
|
List<Long> signPatientManageRouteNodeIds = new ArrayList<>();
|
||||||
for (PatientVO patientVO : patientVOList) {
|
for (PatientVO patientVO : patientVOList) {
|
||||||
try {
|
try {
|
||||||
JSON.parseArray(patientVO.getAppletNodeContent(), TemplateContent.class);
|
JSON.parseArray(patientVO.getAppletNodeContent(), TemplateContent.class);
|
||||||
@ -132,13 +148,28 @@ public class subscribeTaskServiceImpl implements SubscribeTaskService {
|
|||||||
}
|
}
|
||||||
// 开始推送消息
|
// 开始推送消息
|
||||||
Integer integer = weChatOfficialAccountUtils.sendAppletTemplateMessage(patientVO);
|
Integer integer = weChatOfficialAccountUtils.sendAppletTemplateMessage(patientVO);
|
||||||
|
SubscribeMessageSendRecord subscribeMessageSendRecord = new SubscribeMessageSendRecord();
|
||||||
if (integer == 0) {
|
if (integer == 0) {
|
||||||
signPatientManageRouteNodeIds.add(patientVO.getSignPatientManageRouteNodeId());
|
signPatientManageRouteNodeIds.add(patientVO.getSignPatientManageRouteNodeId());
|
||||||
|
subscribeMessageSendRecord.setErrorCode(0);
|
||||||
|
subscribeMessageSendRecord.setErrorStatus(ErrorStatusEnum.success.getValue());
|
||||||
|
} else {
|
||||||
|
subscribeMessageSendRecord.setErrorCode(1);
|
||||||
|
subscribeMessageSendRecord.setErrorStatus(ErrorStatusEnum.fail.getValue());
|
||||||
}
|
}
|
||||||
//更改执行状态
|
subscribeMessageSendRecord.setPatientId(patientVO.getPatientId());
|
||||||
if (CollectionUtils.isNotEmpty(signPatientManageRouteNodeIds)) {
|
subscribeMessageSendRecord.setManageRouteNodeId(patientVO.getSignPatientManageRouteNodeId());
|
||||||
homePageMapper.updateNodeExecuteStatusByIds(signPatientManageRouteNodeIds);
|
subscribeMessageSendRecord.setSubscribeTime(LocalDateTime.now());
|
||||||
}
|
subscribeMessageSendRecord.setOpenid(patientVO.getOpenId());
|
||||||
|
subscribeMessageSendRecord.setAppletId(weChatAppletChatConfig.getAppletId());
|
||||||
|
subscribeMessageSendRecord.setTemplateId(weChatAppletChatConfig.getHealthyPropagandaId());
|
||||||
|
subscribeMessageSendRecord.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
subscribeMessageSendRecord.setCreateTime(LocalDateTime.now());
|
||||||
|
subscribeMessageSendRecordMapper.insertSubscribeMessageSendRecord(subscribeMessageSendRecord);
|
||||||
|
}
|
||||||
|
//更改成功执行状态
|
||||||
|
if (CollectionUtils.isNotEmpty(signPatientManageRouteNodeIds)) {
|
||||||
|
homePageMapper.updateNodeExecuteStatusByIds(signPatientManageRouteNodeIds, NodeExecuteStatusEnum.EXECUTED.getInfo(), NodeExecuteResultStatusEnum.SUCCESS.getInfo());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user