|
@ -67,32 +67,64 @@ class WechatClient extends RedisModel {
|
|
message.content_type == CONTENT_TYPES.ChangeDoorDoctor ||
|
|
message.content_type == CONTENT_TYPES.ChangeDoorDoctor ||
|
|
message.content_type == CONTENT_TYPES.ChangeDoorPackageItems)) {
|
|
message.content_type == CONTENT_TYPES.ChangeDoorPackageItems)) {
|
|
let patientClient = clientCache.findById(targetUserId);
|
|
let patientClient = clientCache.findById(targetUserId);
|
|
|
|
let pc_patientClient = clientCache.findById("pcpatient_"+targetUserId);
|
|
let doctorClient = clientCache.findByIdAndType(message.sender_id,SOCKET_TYPES.DOCTOR);
|
|
let doctorClient = clientCache.findByIdAndType(message.sender_id,SOCKET_TYPES.DOCTOR);
|
|
let pc_doctorClient = clientCache.findByIdAndType("pc_"+message.sender_id,SOCKET_TYPES.PC_DOCTOR);
|
|
let pc_doctorClient = clientCache.findByIdAndType("pc_"+message.sender_id,SOCKET_TYPES.PC_DOCTOR);
|
|
var count = 0;
|
|
var count = 0;
|
|
if (patientClient) {
|
|
|
|
log.warn("User's wechat endpoint is online, sending via web socket. User id: ", targetUserId);
|
|
|
|
WechatClient.sendViaWebSocket(patientClient.socket, message);
|
|
|
|
|
|
if (patientClient || pc_patientClient) {
|
|
|
|
|
|
|
|
if(patientClient){
|
|
|
|
log.warn("User's wechat endpoint is online, sending via web socket. User id: ", targetUserId);
|
|
|
|
WechatClient.sendViaWebSocket(patientClient.socket, message);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(pc_patientClient){
|
|
|
|
log.warn("User's pc endpoint is online, sending via web socket. User id: ", targetUserId);
|
|
|
|
WechatClient.sendViaWebSocket(pc_patientClient.socket, message);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(doctorClient){
|
|
if(doctorClient){
|
|
log.error("doctor sessionid "+doctorClient.sessionId);
|
|
log.error("doctor sessionid "+doctorClient.sessionId);
|
|
log.error("patient sessionid "+patientClient.sessionId);
|
|
|
|
if(patientClient.sessionId==doctorClient.sessionId){
|
|
|
|
|
|
|
|
|
|
if(patientClient && patientClient.sessionId==doctorClient.sessionId){
|
|
|
|
log.error("patient sessionid "+patientClient.sessionId);
|
|
//用户socket在线,推送给用户后,告知医生此消息已读
|
|
//用户socket在线,推送给用户后,告知医生此消息已读
|
|
WechatClient.updateParticipantLastFetchTime(doctorClient.sessionId, targetUserId, ObjectUtil.timestampToLong(message.timestamp));
|
|
WechatClient.updateParticipantLastFetchTime(doctorClient.sessionId, targetUserId, ObjectUtil.timestampToLong(message.timestamp));
|
|
WechatClient.sendReadDoctor(doctorClient.socket, message);
|
|
WechatClient.sendReadDoctor(doctorClient.socket, message);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if(pc_patientClient && pc_patientClient.sessionId==doctorClient.sessionId){
|
|
|
|
log.error("pc_patient sessionid "+pc_patientClient.sessionId);
|
|
|
|
//用户socket在线,推送给用户后,告知医生此消息已读
|
|
|
|
WechatClient.updateParticipantLastFetchTime(doctorClient.sessionId, targetUserId, ObjectUtil.timestampToLong(message.timestamp));
|
|
|
|
WechatClient.sendReadDoctor(doctorClient.socket, message);
|
|
|
|
}
|
|
|
|
|
|
}else{
|
|
}else{
|
|
count++;
|
|
count++;
|
|
}
|
|
}
|
|
if(pc_doctorClient){
|
|
if(pc_doctorClient){
|
|
log.error("doctor sessionid "+pc_doctorClient.sessionId);
|
|
log.error("doctor sessionid "+pc_doctorClient.sessionId);
|
|
log.error("patient sessionid "+patientClient.sessionId);
|
|
|
|
if(patientClient.sessionId==pc_doctorClient.sessionId){
|
|
|
|
//用户socket在线,推送给用户后,告知医生此消息已读
|
|
|
|
WechatClient.updateParticipantLastFetchTime(pc_doctorClient.sessionId, targetUserId, ObjectUtil.timestampToLong(message.timestamp));
|
|
|
|
WechatClient.sendReadDoctor(pc_doctorClient.socket, message);
|
|
|
|
|
|
|
|
|
|
if(patientClient){
|
|
|
|
log.error("patient sessionid "+patientClient.sessionId);
|
|
|
|
if(patientClient.sessionId==pc_doctorClient.sessionId){
|
|
|
|
//用户socket在线,推送给用户后,告知医生此消息已读
|
|
|
|
WechatClient.updateParticipantLastFetchTime(pc_doctorClient.sessionId, targetUserId, ObjectUtil.timestampToLong(message.timestamp));
|
|
|
|
WechatClient.sendReadDoctor(pc_doctorClient.socket, message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(pc_patientClient){
|
|
|
|
log.error("pc_patient sessionid "+pc_patientClient.sessionId);
|
|
|
|
if(pc_patientClient.sessionId==pc_doctorClient.sessionId){
|
|
|
|
//用户socket在线,推送给用户后,告知医生此消息已读
|
|
|
|
WechatClient.updateParticipantLastFetchTime(pc_doctorClient.sessionId, targetUserId, ObjectUtil.timestampToLong(message.timestamp));
|
|
|
|
WechatClient.sendReadDoctor(pc_doctorClient.socket, message);
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}else{
|
|
}else{
|
|
count++;
|
|
count++;
|
|
}
|
|
}
|
|
@ -102,7 +134,7 @@ class WechatClient extends RedisModel {
|
|
}
|
|
}
|
|
|
|
|
|
} else {
|
|
} else {
|
|
log.info("User's wechat endpoint is not online, sending via wechat template message. User id: ", targetUserId);
|
|
|
|
|
|
log.info("User's wechat and pc endpoint is not online, sending via wechat template message. User id: ", targetUserId);
|
|
var isSendWXTem = true;//是否发送微信模板
|
|
var isSendWXTem = true;//是否发送微信模板
|
|
if(message.content_type == CONTENT_TYPES.PrescriptionBloodStatus||message.content_type == CONTENT_TYPES.PrescriptionFollowupContent){
|
|
if(message.content_type == CONTENT_TYPES.PrescriptionBloodStatus||message.content_type == CONTENT_TYPES.PrescriptionFollowupContent){
|
|
var content = JSON.parse(message.content);
|
|
var content = JSON.parse(message.content);
|
|
@ -120,8 +152,16 @@ class WechatClient extends RedisModel {
|
|
}
|
|
}
|
|
} else if(message.content_type == CONTENT_TYPES.TopicEnd){
|
|
} else if(message.content_type == CONTENT_TYPES.TopicEnd){
|
|
let patientClient = clientCache.findById(targetUserId);
|
|
let patientClient = clientCache.findById(targetUserId);
|
|
if(patientClient)//结束咨询的告知患者
|
|
|
|
|
|
if(patientClient){//结束咨询的告知患者
|
|
WechatClient.sendViaWebSocket(patientClient.socket, message);
|
|
WechatClient.sendViaWebSocket(patientClient.socket, message);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let pc_patientClient = clientCache.findById("pcpatient_"+targetUserId);
|
|
|
|
if(pc_patientClient)//结束咨询的告知患者
|
|
|
|
{
|
|
|
|
WechatClient.sendViaWebSocket(pc_patientClient.socket, message);
|
|
|
|
}
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|