|
@ -62,7 +62,7 @@ class Topics extends RedisModel {
|
|
|
createTopic(topicName, topicId, sessionId, users, messages,sessionType) {
|
|
|
let self = this;
|
|
|
//MUC模式中sessionID就是患者ID
|
|
|
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();
|
|
@ -70,37 +70,44 @@ class Topics extends RedisModel {
|
|
|
//从数据库中获取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", sessionId,
|
|
|
"create_time", date.getTime(),
|
|
|
"end_time", "",
|
|
|
"description", messages.description,
|
|
|
"status", TOPIC_STATUS.NEW)
|
|
|
.then(function (res) {
|
|
|
participants.getMucSessionIdByParticipants(users, function (err, res) {
|
|
|
// 已经存在对应的会话更新全科为旁听
|
|
|
if (res && res.length > 0) {
|
|
|
for (var j in users) {
|
|
|
participants.updateUser(sessionId, j, users[j]);
|
|
|
}
|
|
|
callbegin();
|
|
|
} else {
|
|
|
// 不存在创建SESSION
|
|
|
for (var j in users) {
|
|
|
pars.push(j + ":" + users[j]);
|
|
|
}
|
|
|
sessions.createSession(sessionId, messages.senderName, sessionType, pars, function (res) {
|
|
|
if (res) {
|
|
|
callbegin();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
})
|
|
|
})
|
|
|
}).catch();
|
|
|
participants.getMucSessionIdByParticipants(users, function (err, res) {
|
|
|
if(!err){
|
|
|
if(res&&res.length>0){
|
|
|
sessionId = res[0].id;
|
|
|
}
|
|
|
let topics_key = RedisModel.makeRedisKey(REDIS_KEYS.Topics, sessionId);
|
|
|
redis.zaddAsync(topics_key, date.getTime(), topicId).then(function (res) {
|
|
|
redis.hmsetAsync(topic_key,
|
|
|
"name", topicName,
|
|
|
"end_by", "",
|
|
|
"session_id", sessionId,
|
|
|
"create_time", date.getTime(),
|
|
|
"end_time", "",
|
|
|
"description", messages.description,
|
|
|
"status", TOPIC_STATUS.NEW)
|
|
|
.then(function (res) {
|
|
|
|
|
|
})
|
|
|
}).catch();
|
|
|
}
|
|
|
// 已经存在对应的会话更新全科为旁听
|
|
|
if (res && res.length > 0) {
|
|
|
for (var j in users) {
|
|
|
participants.updateUser(sessionId, j, users[j]);
|
|
|
}
|
|
|
callbegin();
|
|
|
} else {
|
|
|
// 不存在创建SESSION
|
|
|
for (var j in users) {
|
|
|
pars.push(j + ":" + users[j]);
|
|
|
}
|
|
|
sessions.createSession(sessionId, messages.senderName, sessionType, pars, function (res) {
|
|
|
if (res) {
|
|
|
callbegin();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
})
|
|
|
|
|
|
/**
|
|
|
* 开始消息发送
|