Parcourir la source

Merge branch 'feature-refactor' of yeshijie/im.doctor into feature-refactor

yeshijie il y a 8 ans
Parent
commit
a65041776a

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

@ -33,6 +33,7 @@ const STICKY_SESSION_BASE_SCORE = require('../../include/commons').STICKY_SESSIO
const PARTICIPANT_ROLES = require('../../include/commons').PARTICIPANT_ROLES;
const CONTENT_TYPES = require('../../include/commons').CONTENT_TYPES;
const SESSION_BUSINESS_TYPE = require('../../include/commons').SESSION_BUSINESS_TYPE;
const SESSION_STATUS = require('../../include/commons').SESSION_STATUS;
class Sessions extends RedisModel {
@ -884,7 +885,9 @@ class Sessions extends RedisModel {
        let count = 0;
        let patientCount = 0;
        let doctorCount = 0;
        let patientEndCount = 0;
        SessionRepo.findAll(userId, function (err, res) {
        // SessionRepo.findUnEndAll(userId, function (err, res) {
            if (err) {
                if(handler)
                {
@ -933,7 +936,11 @@ class Sessions extends RedisModel {
                count = count + con;
                if (session.business_type == SESSION_BUSINESS_TYPE.PATIENT) {
                    patientCount = patientCount + con;
                    if(session.status == SESSION_STATUS.ENDED){//新增判断是否咨询结束
                        patientEndCount = patientEndCount + con;
                    }else{
                        patientCount = patientCount + con;
                    }
                } else {
                    doctorCount = doctorCount + con;
                }
@ -943,7 +950,7 @@ class Sessions extends RedisModel {
                        handler(err,count)
                        return;
                    }
                    ModelUtil.emitOK(self.eventEmitter, {count: count, patient: patientCount, doctor: doctorCount});
                    ModelUtil.emitOK(self.eventEmitter, {count: count, patient: patientCount,patientEnd: patientEndCount, doctor: doctorCount});
                }
            })
        }

+ 53 - 13
src/server/repository/mysql/session.repo.js

@ -9,6 +9,7 @@ let log = require('../../util/log.js');
const DB_TABLES = require('../../include/commons').DB_TABLES;
const PARTICIPANT_ROLES = require('../../include/commons').PARTICIPANT_ROLES;
const SESSION_STATUS = require('../../include/commons').SESSION_STATUS;
const SESSION_BUSINESS_TYPE = require('../../include/commons').SESSION_BUSINESS_TYPE;
class SessionRepo {
    constructor() {
    }
@ -49,6 +50,27 @@ class SessionRepo {
            }
        });
    }
    /**
     * 获取用户全部(未结束的)会话不包含角色未1的会话
     * @param userId
     * @param handler
     */
    static findUnEndAll(userId, handler) {
        let sql = "select session_id from " + DB_TABLES.Participants + " w where w.participant_id = ? and participant_role =0  group by w.session_id";
        let sys_session = "select session_id from " + DB_TABLES.Participants + " w where w.participant_id = 'system' and participant_role =0  group by w.session_id";
        let sessionSQL = "select id, name, type, create_date,business_type, last_sender_id, last_sender_name, last_content_type, last_content, last_message_time,status from "
            + DB_TABLES.Sessions + " s where s.id in(" + sql + ") and s.id not in ("+sys_session+") and s.`status` = 0";
        ImDb.execQuery({
            "sql": sessionSQL,
            "args": [userId],
            "handler": handler || function (err, res) {
                if(err) log.error(err);
            }
        });
    }
    /**
     * 获取用户全部会话忽略角色
     *
@ -100,19 +122,37 @@ class SessionRepo {
        let sessionSQL ="";
        let sql ="";
        if(status == SESSION_STATUS.ENDED){
            //找出已经结束的咨询
            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")
            sessionSQL =  "select * from "
                + DB_TABLES.Sessions + " s 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) limit "+page+","+pagesize;
            ImDb.execQuery({
                "sql": sessionSQL,
                "args": [userId, businessType,userId,businessType],
                "handler": handler || function (err, res) {
                    if(err) log.error(err);
                }
            });
            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")
                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;
                ImDb.execQuery({
                    "sql": sessionSQL,
                    "args": [userId, businessType,userId,businessType,userId],
                    "handler": handler || function (err, res) {
                        if(err) log.error(err);
                    }
                });
            }else{
                //找出已经结束的咨询
                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")
                sessionSQL =  "select * from "
                    + DB_TABLES.Sessions + " s 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) limit "+page+","+pagesize;
                ImDb.execQuery({
                    "sql": sessionSQL,
                    "args": [userId, businessType,userId,businessType],
                    "handler": handler || function (err, res) {
                        if(err) log.error(err);
                    }
                });
            }
        }else{
            sql = "select session_id from " + DB_TABLES.Participants + " w where w.participant_id = ? and participant_role ="+PARTICIPANT_ROLES.HOST+" group by w.session_id";

+ 1 - 1
src/server/resources/config/config.prod.js

@ -20,7 +20,7 @@ let redisConfig = {
// 三师后台
let wlyyServerConfig = {
    host: '27.155.100.191',
    host: '192.168.120.167',
    port: 9660,
    model:"/wlyy"
};