|
@ -6,6 +6,7 @@
|
|
let RedisClient = require('../../repository/redis/redis.client.js');
|
|
let RedisClient = require('../../repository/redis/redis.client.js');
|
|
let TopicsRepo = require('../../repository/mysql/topics.repo');
|
|
let TopicsRepo = require('../../repository/mysql/topics.repo');
|
|
let SessionRepo = require('../../repository/mysql/session.repo');
|
|
let SessionRepo = require('../../repository/mysql/session.repo');
|
|
|
|
let TopicRepo = require('../../repository/mysql/topics.repo');
|
|
let ParticipantRepo = require('../../repository/mysql/participant.repo');
|
|
let ParticipantRepo = require('../../repository/mysql/participant.repo');
|
|
let RedisModel = require('./../redis.model.js');
|
|
let RedisModel = require('./../redis.model.js');
|
|
let ModelUtil = require('../../util/model.util');
|
|
let ModelUtil = require('../../util/model.util');
|
|
@ -225,7 +226,7 @@ class Topics extends RedisModel {
|
|
*/
|
|
*/
|
|
createTopic(topicName, topicId, sessionId, users, messages, sessionType) {
|
|
createTopic(topicName, topicId, sessionId, users, messages, sessionType) {
|
|
let self = this;
|
|
let self = this;
|
|
if (!sessionId && sessionType == SESSION_TYPES.MUC) {
|
|
|
|
|
|
if (!sessionId && (sessionType == SESSION_TYPES.MUC|| sessionType == SESSION_TYPES.PRESCRIPTION)) {
|
|
ModelUtil.emitOK(self.eventEmitter, {status: -1, message: "会话ID为空,请先生成会话ID"});
|
|
ModelUtil.emitOK(self.eventEmitter, {status: -1, message: "会话ID为空,请先生成会话ID"});
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@ -241,21 +242,30 @@ class Topics extends RedisModel {
|
|
sessions.createSession(sessionId, messages.sender_name, sessionType, pars, function (err, session) {
|
|
sessions.createSession(sessionId, messages.sender_name, sessionType, pars, function (err, session) {
|
|
sessionId = session.id;
|
|
sessionId = session.id;
|
|
let datetime = session.create_date;
|
|
let datetime = session.create_date;
|
|
self.saveTopicToRedis(topicName, topicId, sessionId, messages, datetime, function (err, startMsgId) {
|
|
|
|
if (err) {
|
|
|
|
ModelUtil.emitOK(self.eventEmitter, {status: -1, message: "议题创建失败!"});
|
|
|
|
|
|
//新增判断是否有未结束的咨询,用户网络差,会多次点击造成同时存在多个咨询
|
|
|
|
TopicRepo.findLastBySessionId(sessionId,function(err,res){
|
|
|
|
if(res&&res.length>0&&res[0].status!=10){
|
|
|
|
ModelUtil.emitOK(self.eventEmitter, {status: -1, message: "还有咨询未结束,不允许再次提交咨询!"});
|
|
return;
|
|
return;
|
|
|
|
}else{
|
|
|
|
self.saveTopicToRedis(topicName, topicId, sessionId, messages, datetime, function (err, startMsgId) {
|
|
|
|
if (err) {
|
|
|
|
ModelUtil.emitOK(self.eventEmitter, {status: -1, message: "议题创建失败!"});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
//返回给前端
|
|
|
|
ModelUtil.emitOK(self.eventEmitter, {status: 200, message: "议题创建成功!", start_msg_id: startMsgId});
|
|
|
|
sessions.updateSessionStatus(sessionId,SESSION_STATUS.PROCEEDINGS,function(err,res){});
|
|
|
|
//执行数据库操作
|
|
|
|
self.saveTopicToMySQL(topicName, topicId, sessionId, startMsgId, new Date(datetime), messages.description, TOPIC_STATUS.NEW, messages.agent, function (err, res) {
|
|
|
|
if (err) {
|
|
|
|
ModelUtil.logError("Save topic to mysql failed", err);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
}
|
|
}
|
|
//返回给前端
|
|
|
|
ModelUtil.emitOK(self.eventEmitter, {status: 200, message: "议题创建成功!", start_msg_id: startMsgId});
|
|
|
|
sessions.updateSessionStatus(sessionId,SESSION_STATUS.PROCEEDINGS,function(err,res){});
|
|
|
|
//执行数据库操作
|
|
|
|
self.saveTopicToMySQL(topicName, topicId, sessionId, startMsgId, new Date(datetime), messages.description, TOPIC_STATUS.NEW, messages.agent, function (err, res) {
|
|
|
|
if (err) {
|
|
|
|
ModelUtil.logError("Save topic to mysql failed", err);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
})
|
|
|
|
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|