瀏覽代碼

Merge branch 'feature-refactor' of http://192.168.1.220:10080/Amoy/im.doctor into feature-refactor

 Conflicts:
	src/server/endpoints/v2/session.endpoint.js
	src/server/models/sessions/sessions.js
	src/server/repository/mysql/session.repo.js
wsl 2 年之前
父節點
當前提交
6493f887ef

+ 3 - 0
src/server/endpoints/v2/session.endpoint.js

@ -83,6 +83,7 @@ router.get("/", function (req, res) {
    let size = req.query.size;
    let userId = req.query.user_id;
    let businessType = req.query.business_type;
    let sessionType = req.query.type;
    let status = req.query.status;
    let patientName = req.query.patientName;
    console.log("patientName----------------------------"+patientName);
@ -105,6 +106,8 @@ router.get("/", function (req, res) {
    }
    if(status&&businessType&&userId&&size&&page&&patientName){
        sessions.getUserStatusSessions(userId,status,businessType,page,size,patientName);
    if(status&&businessType&&userId&&size&&page){
        sessions.getUserStatusSessions(userId,status,sessionType,businessType,page,size);
    }else{
        sessions.getUserSessions(userId, page, size, businessType);
    }

+ 20 - 2
src/server/models/sessions/sessions.js

@ -824,13 +824,14 @@ class Sessions extends RedisModel {
     * @param businessType
     */
    getUserStatusSessions(userId,status,businessType,page, size,patientName) {
    getUserStatusSessions(userId,status,sessionType,businessType,page, size) {
        let userSessionKey = RedisModel.makeRedisKey(REDIS_KEYS.UserSessions, userId);
        log.info(userId);
        let self = this;
        async.waterfall([
            // 获取会话ID列表
            function (callback) {
                SessionRepo.findAllByTypeAndStatus(userId,businessType,status,page,size,function(err,res){
                SessionRepo.findAllByTypeAndStatus(userId,sessionType,businessType,status,page,size,function(err,res){
                    if (res.length == 0) {
                        ModelUtil.emitOK(self.eventEmitter, []);
                        return;
@ -1573,7 +1574,9 @@ class Sessions extends RedisModel {
                        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.Video||
                           (sessionType == SESSION_TYPES.MUC&&message.content_type == 0)//MUC 医生提醒消息记录进已回复
                        ){
                            TopicRepo.findLastBySessionId(sessionId,function(err,res){
                                if(res&&res.length>0&&res[0].reply==0){
                                    TopicRepo.replyTopic(message.sender_id,message.id,res[0].id,function(err,res){
@ -1717,6 +1720,21 @@ class Sessions extends RedisModel {
                }).catch(function (err) {
                    log.error(err);
                    return;
                }).then(function (res) {
                    //续方审核的系统消息也记录进已回复
                    if(sessionType == SESSION_TYPES.PRESCRIPTION&&message.content_type == CONTENT_TYPES.PrescriptionCheck){
                        TopicRepo.findLastBySessionId(sessionId,function(err,res){
                                if(res&&res.length>0&&res[0].reply==0){
                                    TopicRepo.replyTopic(message.sender_id,message.id,res[0].id,function(err,res){
                                        if(err){
                                            logger.error("update topic reply error");
                                        }else{
                                            logger.warn("update topic reply success");
                                        }
                                    });
                                }
                        })
                    }
                })
            } else {
                if (handler){ handler("用户不在此会话当中!", messageId);return;}

+ 11 - 3
src/server/repository/mysql/session.repo.js

@ -191,6 +191,7 @@ class SessionRepo {
        });
    }
    static findAllByTypeAndStatus(userId,sessionType, businessType,status,page,pagesize, handler) {
    static findAllByTypeAndStatus(userId, businessType,status,page,pagesize, handler,patientName) {
        if (page > 0) {
            if (page == 1) {
@ -206,18 +207,26 @@ class SessionRepo {
        let sessionSQL ="";
        let sql ="";
        if(status == SESSION_STATUS.ENDED){
            console.log("----------------------进到结束咨询里面----------------------");
            if(businessType == SESSION_BUSINESS_TYPE.PATIENT){//区分居民,有未读消息的置顶排列
                //找出已经结束的咨询
                sql = "select session_id from " + DB_TABLES.Participants + " w where w.participant_id = ?  group by w.session_id";
                //找出角色讨论组中为旁听且未结束的咨询
                let sql1 = ("select session_id from " + DB_TABLES.Participants + " w where w.participant_id = ? and participant_role ="+PARTICIPANT_ROLES.REGULAR+" group by w.session_id")
                if(sessionType){
                    sessionSQL =  "select s.* from " + DB_TABLES.Sessions + " s, " + DB_TABLES.Participants + " p " +
                        " where s.type='"+sessionType+"' and  ((s.id in(" + sql + ") and s.business_type = ? and s.status = 1) or (s.id in(" + sql1 + ") and s.business_type = ? and s.status = 0)) " +
                        " and s.id = p.session_id and p.participant_id = ? ORDER BY s.last_message_time desc limit "+page+","+pagesize;
                }else {
                    sessionSQL =  "select s.* from " + DB_TABLES.Sessions + " s, " + DB_TABLES.Participants + " p " +
                        " where ((s.id in(" + sql + ") and s.business_type = ? and s.status = 1) or (s.id in(" + sql1 + ") and s.business_type = ? and s.status = 0)) " +
                        " and s.id = p.session_id and p.participant_id = ? ORDER BY s.last_message_time desc limit "+page+","+pagesize;
                }
                sessionSQL =  "select s.* from " + DB_TABLES.Sessions + " s, " + DB_TABLES.Participants + " p " +
                    " where ((s.id in(" + sql + ") and s.business_type = ? and s.status = 1) or (s.id in(" + sql1 + ") and s.business_type = ? and s.status = 0)) " +
                    // " and s.id = p.session_id and p.participant_id = ? ORDER BY (p.last_fetch_time - s.last_message_time+1)>0,s.create_date desc limit "+page+","+pagesize;
                    " and s.id = p.session_id and p.participant_id = ? "+patientNameSql+" ORDER BY s.last_message_time desc limit "+page+","+pagesize;
                log.info("1."+sessionSQL);
                console.log("SQL------------:"+sessionSQL);
                ImDb.execQuery({
                    "sql": sessionSQL,
                    "args": [userId, businessType,userId,businessType,userId],
@ -226,7 +235,6 @@ class SessionRepo {
                    }
                });
            }else{
                console.log("else 咨询--------------------------");
                //找出已经结束的咨询
                sql = "select session_id from " + DB_TABLES.Participants + " w where w.participant_id = ?  group by w.session_id";
                //找出角色讨论组中为旁听且未结束的咨询

+ 100 - 0
src/server/resources/config/config.laprod.js

@ -0,0 +1,100 @@
"use strict";
let imDbConfig = {
    host: '192.10.20.42',
    user: 'root',
    password: '1jMQNUAZXip#!0B^',
    database: 'im_new',
    connectionLimit: '50',
    charset: 'utf8mb4'
};
// Redis
let redisConfig = {
    host: '192.10.20.42',
    port: 6379,
    db: 1,
    password:'Kb6wKDQP1W4'
};
// let redisConfig = {
//     host: '192.168.1.220',
//     port: 6379,
//     db: 1
// };
// 内网Redis
let innerRedisConfig = {
    host: '192.10.20.42',
    port: 6379,
    db: 1,
    password:'Kb6wKDQP1W4'
};
// 三师后台
let wlyyServerConfig = {
    host: '192.10.20.43',
    port: 8081,
    model:"/wlyy"
};
//医生助手配置
let wlyyDAServerConfig = {
    host: '174',
    port: 8080,
    model:"/wlyy"
};
// 个推AppStore版参数
let getTuiConfig = {
    HOST: 'https://api.htm',
    APPID: 'H6FY3uH7V6',
    APPKEY: '0PFWlFWVgYA',
    MASTERSECRET: 'pODkxc816'
};
// 微信配置
let wechatConfig = {
    appId: 'wx1f11428',
    appSecret: '988f042431fb',
    token: '27eb3bb1bb154b08040',
    accId: 'gh_ffb21',
    baseUrl: 'http://ehwlyy',
    template: {
        consultTemplate: '-dr4QNywJ21vBLhf18'  // 咨询回复模板
    }
};
// 会话配置
let sessionConfig = {
    maxMessageCount: 1000,                  // 会话缓存的消息数量
    maxMessageTimespan: 7 * 24 * 3600,      // 会话缓存的最大时间跨度
    expireSessionCleanCount: 10             // 每次清理多少个过期会话
};
// 议题配置
let topicConfig = {
    TTL: 24,                                // 议题的存活时间,TTL = Time To Live
    TERMINATING_CRON: "* 30 * * * *"        // 议题自动关闭的任务执行时间间隔
};
exports.environment = 'laprod';
exports.pubChannel = 'prod';
exports.subChannel = 'dev';
exports.pubSubSwitch = false;
exports.app = 'im.server';
exports.version = '2.0.0';
exports.debug = true;
exports.serverPort = 3000;
exports.sessionExpire = 1800;
exports.showSQL = false;
exports.imDbConfig = imDbConfig;
exports.redisConfig = redisConfig;
exports.innerRedisConfig = innerRedisConfig;
exports.getTuiConfig = getTuiConfig;
exports.wlyyServerConfig = wlyyServerConfig;
exports.wlyyDAServerConfig = wlyyDAServerConfig;
exports.wechatConfig = wechatConfig;
exports.sessionConfig = sessionConfig;
exports.topicConfig = topicConfig;