|
@ -29,7 +29,7 @@ class Topics extends RedisModel {
|
|
|
* @param page
|
|
|
* @param size
|
|
|
*/
|
|
|
getTopicMessages(topicId, page, size) {
|
|
|
getTopicMessages(topicId) {
|
|
|
let self = this;
|
|
|
let topic_key = RedisModel.makeRedisKey(REDIS_KEYS.Topic, topicId);
|
|
|
let _super = RedisModel.makeRedisKey;
|
|
@ -57,35 +57,35 @@ class Topics extends RedisModel {
|
|
|
*
|
|
|
* @param topicName 发起议题的名称
|
|
|
* @param topicId
|
|
|
* @param patient 发起议题的患者
|
|
|
* @param healthDoctor
|
|
|
* @param doctor 参与的医生
|
|
|
* @param users 发起议题的患者{"userId1:role", "userId2:role"}
|
|
|
* @param messages 发送的消息对象{description:"",title:"",img:"",patient:"",patientName:""}图片多个用逗号隔开
|
|
|
*/
|
|
|
createTopics(topicName, topicId, patient, healthDoctor, doctor, messages) {
|
|
|
createTopics(topicName, topicId,sessionId,users, messages) {
|
|
|
let self = this;
|
|
|
|
|
|
//MUC模式中sessionID就是患者ID
|
|
|
let topics_key = RedisModel.makeRedisKey(REDIS_KEYS.Topics, patient);
|
|
|
let topics_key = RedisModel.makeRedisKey(REDIS_KEYS.Topics, sessionId);
|
|
|
let topic_key = RedisModel.makeRedisKey(REDIS_KEYS.Topic, topicId);
|
|
|
let sessions = new Sessions();
|
|
|
let participants = new Participants();
|
|
|
|
|
|
//从数据库中获取sessionId
|
|
|
let date = new Date();
|
|
|
var pars=[];
|
|
|
redis.zaddAsync(topics_key, date.getTime(), topicId).then(function (res) {
|
|
|
redis.hmsetAsync(topic_key, "name", topicName, "end_by", "", "session_id", patient, "create_time", date.getTime(), "end_time", "", "description", messages.description).then(function (res) {
|
|
|
sessions.getSessions(patient, function (err, res) {
|
|
|
redis.hmsetAsync(topic_key, "name", topicName, "end_by", "", "session_id", sessionId, "create_time", date.getTime(), "end_time", "", "description", messages.description).then(function (res) {
|
|
|
sessions.getSessions(sessionId, function (err, res) {
|
|
|
//已经存在对应的会话更新全科为旁听
|
|
|
if (res && res.length > 0) {
|
|
|
participants.updateUser(patient, doctor, SESSION_USER_STATUS.OTHER);
|
|
|
for(var j in users){
|
|
|
participants.updateUser(sessionId, j, users[j]);
|
|
|
}
|
|
|
callbegin();
|
|
|
} else {//不存在创建SESSION
|
|
|
var users = {};
|
|
|
users[patient] = SESSION_USER_STATUS.ONLINE;
|
|
|
users[healthDoctor] = SESSION_USER_STATUS.ONLINE;
|
|
|
users[doctor] = SESSION_USER_STATUS.OTHER;
|
|
|
sessions.createSession(patient, messages.patientName, config.sessionConfig.MUC, JSON.stringify(users), function (res) {
|
|
|
for(var j in users){
|
|
|
pars.push(j+":"+users[j]);
|
|
|
}
|
|
|
sessions.createSession(sessionId, messages.patientName, config.sessionConfig.MUC, pars, function (res) {
|
|
|
if (res) {
|
|
|
callbegin();
|
|
|
}
|
|
@ -105,12 +105,12 @@ class Topics extends RedisModel {
|
|
|
msg.contentType = 6;
|
|
|
msg.content = "开始咨询"
|
|
|
msg.timestamp = date;
|
|
|
sessions.saveMessageByTopic(msg, patient, function (err, msgId) {
|
|
|
sessions.saveMessageByTopic(msg, sessionId, function (err, msgId) {
|
|
|
if (err) {
|
|
|
ModelUtil.emitOK(self.eventEmitter, err);
|
|
|
} else {
|
|
|
self.saveTopicsToSql(topicName, topicId, patient, msgId, date);
|
|
|
callBeginMsg();
|
|
|
self.saveTopicsToSql(topicName, topicId, sessionId, msgId, date);
|
|
|
callBeginMsg(startMsgId);
|
|
|
}
|
|
|
})
|
|
|
}
|
|
@ -118,7 +118,7 @@ class Topics extends RedisModel {
|
|
|
/**
|
|
|
* 发送求助内容
|
|
|
*/
|
|
|
function callBeginMsg() {
|
|
|
function callBeginMsg(startMsgId) {
|
|
|
let msg = {};
|
|
|
msg.senderId = messages.patient;
|
|
|
msg.senderName = messages.patientName;
|
|
@ -143,7 +143,7 @@ class Topics extends RedisModel {
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
ModelUtil.emitOK(self.eventEmitter, "创建成功!");
|
|
|
ModelUtil.emitOK(self.eventEmitter, startMsgId);
|
|
|
}
|
|
|
}
|
|
|
|