|  | @ -155,14 +155,17 @@ class WechatClient extends RedisModel {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     static sendReadDoctorByDoctorId(doctorId, message) {
 | 
	
		
			
				|  |  |         let doctorClient = clientCache.findByIdAndType(doctorId,SOCKET_TYPES.DOCTOR);
 | 
	
		
			
				|  |  |         // let pc_doctorClient = clientCache.findByIdAndType("pc_"+doctorId,SOCKET_TYPES.PC_DOCTOR);
 | 
	
		
			
				|  |  |         if(!doctorClient){
 | 
	
		
			
				|  |  |         let pc_doctorClient = clientCache.findByIdAndType("pc_"+doctorId,SOCKET_TYPES.PC_DOCTOR);
 | 
	
		
			
				|  |  |         if(!doctorClient&&!pc_doctorClient){
 | 
	
		
			
				|  |  |             log.warn("target doctor is not online!");
 | 
	
		
			
				|  |  |             return;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         let sendDoctorClient = clientCache.findByIdAndType(message.sender_id,SOCKET_TYPES.DOCTOR);
 | 
	
		
			
				|  |  |         // let pc_sendDoctorClient = clientCache.findByIdAndType("pc_"+message.sender_id,SOCKET_TYPES.PC_DOCTOR);
 | 
	
		
			
				|  |  |         if(sendDoctorClient&&sendDoctorClient.sessionId==doctorClient.sessionId){
 | 
	
		
			
				|  |  |         if(!sendDoctorClient){
 | 
	
		
			
				|  |  |             sendDoctorClient = clientCache.findByIdAndType("pc_"+message.sender_id,SOCKET_TYPES.PC_DOCTOR);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         var count = 0;
 | 
	
		
			
				|  |  |         if(doctorClient&&sendDoctorClient&&sendDoctorClient.sessionId==doctorClient.sessionId){
 | 
	
		
			
				|  |  |             WechatClient.updateParticipantLastFetchTime(doctorClient.sessionId, doctorId, ObjectUtil.timestampToLong(message.timestamp));
 | 
	
		
			
				|  |  |             sendDoctorClient.socket.emit('message', {
 | 
	
		
			
				|  |  |                 id: message.id,
 | 
	
	
		
			
				|  | @ -177,45 +180,49 @@ class WechatClient extends RedisModel {
 | 
	
		
			
				|  |  |                 read:"one"
 | 
	
		
			
				|  |  |             });
 | 
	
		
			
				|  |  |         }else{
 | 
	
		
			
				|  |  |             log.warn("doctor is not in the same session or not online");
 | 
	
		
			
				|  |  |             count++;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //发送pc版医生端
 | 
	
		
			
				|  |  |         // if(pc_doctorClient&&pc_sendDoctorClient&&pc_sendDoctorClient.sessionId==pc_doctorClient.sessionId){
 | 
	
		
			
				|  |  |         //     WechatClient.updateParticipantLastFetchTime(pc_doctorClient.sessionId, doctorId, ObjectUtil.timestampToLong(message.timestamp));
 | 
	
		
			
				|  |  |         //     pc_sendDoctorClient.socket.emit('message', {
 | 
	
		
			
				|  |  |         //         id: message.id,
 | 
	
		
			
				|  |  |         //         session_id: message.session_id,
 | 
	
		
			
				|  |  |         //         sender_id: message.sender_id,
 | 
	
		
			
				|  |  |         //         sender_name: message.sender_name,
 | 
	
		
			
				|  |  |         //         content_type: message.content_type,
 | 
	
		
			
				|  |  |         //         content: message.content,
 | 
	
		
			
				|  |  |         //         timestamp: ObjectUtil.timestampToLong(message.timestamp),
 | 
	
		
			
				|  |  |         //         type: message.content_type,          // legacy support
 | 
	
		
			
				|  |  |         //         name: message.sender_name,
 | 
	
		
			
				|  |  |         //         read:"one"
 | 
	
		
			
				|  |  |         //     });
 | 
	
		
			
				|  |  |         // }else{
 | 
	
		
			
				|  |  |         //     log.warn("doctor is not in the same session or not online");
 | 
	
		
			
				|  |  |         // }
 | 
	
		
			
				|  |  |         if(pc_doctorClient&&sendDoctorClient&&sendDoctorClient.sessionId==pc_doctorClient.sessionId){
 | 
	
		
			
				|  |  |             WechatClient.updateParticipantLastFetchTime(pc_doctorClient.sessionId, doctorId, ObjectUtil.timestampToLong(message.timestamp));
 | 
	
		
			
				|  |  |             pc_sendDoctorClient.socket.emit('message', {
 | 
	
		
			
				|  |  |                 id: message.id,
 | 
	
		
			
				|  |  |                 session_id: message.session_id,
 | 
	
		
			
				|  |  |                 sender_id: message.sender_id,
 | 
	
		
			
				|  |  |                 sender_name: message.sender_name,
 | 
	
		
			
				|  |  |                 content_type: message.content_type,
 | 
	
		
			
				|  |  |                 content: message.content,
 | 
	
		
			
				|  |  |                 timestamp: ObjectUtil.timestampToLong(message.timestamp),
 | 
	
		
			
				|  |  |                 type: message.content_type,          // legacy support
 | 
	
		
			
				|  |  |                 name: message.sender_name,
 | 
	
		
			
				|  |  |                 read:"one"
 | 
	
		
			
				|  |  |             });
 | 
	
		
			
				|  |  |         }else{
 | 
	
		
			
				|  |  |             count++;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if(count==2){
 | 
	
		
			
				|  |  |             log.warn("doctor is not in the same session or is not online");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     static sendSocketMessageToDoctor(doctorId, message) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         let doctorClient = clientCache.findByIdAndType(doctorId,SOCKET_TYPES.DOCTOR);
 | 
	
		
			
				|  |  |         // let pc_doctorClient = clientCache.findByIdAndType("pc_"+doctorId,SOCKET_TYPES.PC_DOCTOR);
 | 
	
		
			
				|  |  |         if(!doctorClient){
 | 
	
		
			
				|  |  |         let pc_doctorClient = clientCache.findByIdAndType("pc_"+doctorId,SOCKET_TYPES.PC_DOCTOR);
 | 
	
		
			
				|  |  |         if(!doctorClient&&!pc_doctorClient){
 | 
	
		
			
				|  |  |             log.warn("target doctor is not online!");
 | 
	
		
			
				|  |  |             return;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         let sendClient = clientCache.findByIdAndType(message.sender_id,SOCKET_TYPES.DOCTOR);//app医生发送的消息
 | 
	
		
			
				|  |  |         // if(!sendClient){//pc医生发送的消息
 | 
	
		
			
				|  |  |         //     sendClient = clientCache.findByIdAndType("pc_"+message.sender_id,SOCKET_TYPES.PC_DOCTOR);
 | 
	
		
			
				|  |  |         // }
 | 
	
		
			
				|  |  |         if(!sendClient){//pc医生发送的消息
 | 
	
		
			
				|  |  |             sendClient = clientCache.findByIdAndType("pc_"+message.sender_id,SOCKET_TYPES.PC_DOCTOR);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(!sendClient){//居民发送的消息
 | 
	
		
			
				|  |  |             sendClient = clientCache.findByIdAndType(message.sender_id,SOCKET_TYPES.PATIENT);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if(sendClient&&sendClient.sessionId==doctorClient.sessionId){
 | 
	
		
			
				|  |  |         var count = 0;
 | 
	
		
			
				|  |  |         if(doctorClient&&sendClient&&sendClient.sessionId==doctorClient.sessionId){
 | 
	
		
			
				|  |  |             WechatClient.updateParticipantLastFetchTime(doctorClient.sessionId, doctorId, ObjectUtil.timestampToLong(message.timestamp));
 | 
	
		
			
				|  |  |             doctorClient.socket.emit('message', {
 | 
	
		
			
				|  |  |                 id: message.id,
 | 
	
	
		
			
				|  | @ -229,27 +236,61 @@ class WechatClient extends RedisModel {
 | 
	
		
			
				|  |  |                 name: message.sender_name,
 | 
	
		
			
				|  |  |             });
 | 
	
		
			
				|  |  |         }else{
 | 
	
		
			
				|  |  |             log.warn("doctor is not in the same session or is not online");
 | 
	
		
			
				|  |  |             count++;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //发送pc端
 | 
	
		
			
				|  |  |         // if(pc_doctorClient&&sendClient&&sendClient.sessionId==pc_doctorClient.sessionId){
 | 
	
		
			
				|  |  |         //     WechatClient.updateParticipantLastFetchTime(pc_doctorClient.sessionId, doctorId, ObjectUtil.timestampToLong(message.timestamp));
 | 
	
		
			
				|  |  |         //     pc_doctorClient.socket.emit('message', {
 | 
	
		
			
				|  |  |         //         id: message.id,
 | 
	
		
			
				|  |  |         //         session_id: message.session_id,
 | 
	
		
			
				|  |  |         //         sender_id: message.sender_id,
 | 
	
		
			
				|  |  |         //         sender_name: message.sender_name,
 | 
	
		
			
				|  |  |         //         content_type: message.content_type,
 | 
	
		
			
				|  |  |         //         content: message.content,
 | 
	
		
			
				|  |  |         //         timestamp: ObjectUtil.timestampToLong(message.timestamp),
 | 
	
		
			
				|  |  |         //         type: message.content_type,          // legacy support
 | 
	
		
			
				|  |  |         //         name: message.sender_name,
 | 
	
		
			
				|  |  |         //     });
 | 
	
		
			
				|  |  |         // }else{
 | 
	
		
			
				|  |  |         //     log.warn("doctor is not in the same session or is not online");
 | 
	
		
			
				|  |  |         // }
 | 
	
		
			
				|  |  |         if(pc_doctorClient&&sendClient&&sendClient.sessionId==pc_doctorClient.sessionId){
 | 
	
		
			
				|  |  |             WechatClient.updateParticipantLastFetchTime(pc_doctorClient.sessionId, doctorId, ObjectUtil.timestampToLong(message.timestamp));
 | 
	
		
			
				|  |  |             pc_doctorClient.socket.emit('message', {
 | 
	
		
			
				|  |  |                 id: message.id,
 | 
	
		
			
				|  |  |                 session_id: message.session_id,
 | 
	
		
			
				|  |  |                 sender_id: message.sender_id,
 | 
	
		
			
				|  |  |                 sender_name: message.sender_name,
 | 
	
		
			
				|  |  |                 content_type: message.content_type,
 | 
	
		
			
				|  |  |                 content: message.content,
 | 
	
		
			
				|  |  |                 timestamp: ObjectUtil.timestampToLong(message.timestamp),
 | 
	
		
			
				|  |  |                 type: message.content_type,          // legacy support
 | 
	
		
			
				|  |  |                 name: message.sender_name,
 | 
	
		
			
				|  |  |             });
 | 
	
		
			
				|  |  |         }else{
 | 
	
		
			
				|  |  |             count++;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if(count==2){
 | 
	
		
			
				|  |  |             log.warn("doctor is not in the same session or is not online");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     static sendPcImSocket(targetId, message, sessionType) {
 | 
	
		
			
				|  |  |         if (message.content_type == CONTENT_TYPES.PlainText ||
 | 
	
		
			
				|  |  |             message.content_type == CONTENT_TYPES.Image ||
 | 
	
		
			
				|  |  |             message.content_type == CONTENT_TYPES.Audio||
 | 
	
		
			
				|  |  |             message.content_type == CONTENT_TYPES.Video||
 | 
	
		
			
				|  |  |             message.content_type == CONTENT_TYPES.GoTo||
 | 
	
		
			
				|  |  |             sessionType==SESSION_TYPES.SYSTEM) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             let pcim_doctorClient = clientCache.findByIdAndType("pcim_"+targetId,SOCKET_TYPES.PCIM_DOCTOR);
 | 
	
		
			
				|  |  |             if(pcim_doctorClient) {
 | 
	
		
			
				|  |  |                  let customData = {
 | 
	
		
			
				|  |  |                     session_id: message.session_id||'',
 | 
	
		
			
				|  |  |                     session_type: sessionType,
 | 
	
		
			
				|  |  |                     from: message.sender_id|| '',
 | 
	
		
			
				|  |  |                     data: message.content,
 | 
	
		
			
				|  |  |                     business_type: message.business_type || 1
 | 
	
		
			
				|  |  |                 };
 | 
	
		
			
				|  |  |                 pcim_doctorClient.socket.emit('message', {
 | 
	
		
			
				|  |  |                     session_id: message.session_id||'',
 | 
	
		
			
				|  |  |                     session_type: sessionType,
 | 
	
		
			
				|  |  |                     from: message.sender_id|| '',
 | 
	
		
			
				|  |  |                     data: message.content,
 | 
	
		
			
				|  |  |                     business_type: message.business_type || 1
 | 
	
		
			
				|  |  |                 });
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 发送微信模板消息给居民
 | 
	
		
			
				|  |  |      *
 |