Przeglądaj źródła

Merge branch 'im-internet-hospital' of http://192.168.1.220:10080/Amoy/im.doctor into im-internet-hospital

LAPTOP-KB9HII50\70708 3 lat temu
rodzic
commit
698302dfc6

+ 2 - 1
src/server/endpoints/v2/session.endpoint.js

@ -236,6 +236,7 @@ router.get(APIv2.Sessions.SessionListByType, function (req, res) {
    let type = req.query.type;
    let status = req.query.status;
    let name = req.query.name;
    let searchType = req.query.search_type;//p2p会话类型 1医生 2患者
    if (!page) {
        throw {httpStatus: 406, message: 'Missing page.'};
    }
@ -255,7 +256,7 @@ router.get(APIv2.Sessions.SessionListByType, function (req, res) {
    let sessions = new Sessions();
    ControllerUtil.regModelEventHandler(sessions, res);
    sessions.getUserSessionsByType(userId,type,page,size,status,name);
    sessions.getUserSessionsByType(userId,type,page,size,status,name,searchType);
});
router.get(APIv2.Sessions.SessionListByNoParticipant, function (req, res) {

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

@ -933,7 +933,7 @@ class Sessions extends RedisModel {
     * @param businessType
     * @param status 0:进行中的会话1:结束的会话
     */
    getUserSessionsByType(userId,type,page, size,status,name) {
    getUserSessionsByType(userId,type,page, size,status,name,searchType) {
        logger.info("根据用户类型获取用户的session列表1: ");
        let userSessionKey = RedisModel.makeRedisKey(REDIS_KEYS.UserSessions, userId);
        let self = this;
@ -941,7 +941,7 @@ class Sessions extends RedisModel {
        async.waterfall([
            // 获取会话ID列表
            function (callback) {
                SessionRepo.findListByType(userId,type,page,size,status,name,function(err,res){
                SessionRepo.findListByType(userId,type,page,size,status,name,searchType,function(err,res){
                    logger.info("根据用户类型获取用户的session列表: res :"+res);
                    if (res == null || res.length == 0) {
                        ModelUtil.emitOK(self.eventEmitter, []);
@ -1032,6 +1032,10 @@ class Sessions extends RedisModel {
                                            } else {
                                                sessionName = res[0].name;
                                            }
                                            var userType =null;
                                            if (session.type == SESSION_TYPES.P2P){
                                                userType = res[0].userType;
                                            }
                                            var bir = new Date().getTime();
                                            if (res && res.length != 0 && res[0].birthdate) {
                                                bir = res[0].birthdate.getTime();
@ -1056,6 +1060,7 @@ class Sessions extends RedisModel {
                                                sender_birthday: bir,
                                                participantsTimeArray:participantsTime,
                                                status:session.status,
                                                userType:userType,
                                            });
                                            index = (parseInt(index) + 1);

+ 1 - 1
src/server/repository/mysql/participant.repo.js

@ -185,7 +185,7 @@ class ParticipantRepo {
    }
    static findNameById(userId, handler) {
        let sql = "SELECT p.name,p.sex,p.birthdate FROM patients p WHERE p.id =? union SELECT d.name,d.sex,d.birthdate FROM doctors d WHERE d.id =?";
        let sql = "SELECT p.name,p.sex,p.birthdate,2 as userType FROM patients p WHERE p.id =? union SELECT d.name,d.sex,d.birthdate,1 as userType FROM doctors d WHERE d.id =?";
        ImDb.execQuery({
            "sql": sql,
            "args": [userId, userId],

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

@ -10,6 +10,7 @@ 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;
const SESSION_TYPES = require('../../include/commons').SESSION_TYPES;
class SessionRepo {
    constructor() {
    }
@ -166,7 +167,7 @@ class SessionRepo {
     * @param type
     * @param handler
     */
    static findListByType(userId, type,page,pagesize, status,name,handler) {
    static findListByType(userId, type,page,pagesize, status,name,searchType,handler) {
        log.info("type="+type);
        if (page > 0) {
            if (page == 1) {
@ -181,10 +182,21 @@ class SessionRepo {
         * userId 为传值时:管理员调度大屏获取im消息
         */
        if (userId != null && userId != "") {
            sql = "select session_id from " + DB_TABLES.Participants + " w where w.participant_id in(?) group by w.session_id";
            sql = "select session_id from " + DB_TABLES.Participants + " w where w.participant_id in(?)";
            if (searchType!= null&&type==SESSION_TYPES.P2P){
                if (1==searchType){
                    sql += "and EXISTS( select p.id from participants ww  INNER JOIN doctors p on p.id = ww.participant_id " +
                        "  where ww.session_id  = w.session_id and p.id<>'"+userId+"' )"
                }if (2==searchType){
                    sql += " and EXISTS( select p.id from participants ww  INNER JOIN patients p on p.id = ww.participant_id " +
                        "  where ww.session_id  = w.session_id and p.id<>'"+userId+"' ) ";
                }
            }
        } else {
            sql = "select session_id from " + DB_TABLES.Participants + " w group by w.session_id"
            sql = "select session_id from " + DB_TABLES.Participants + " w "
        }
        sql +=" group by w.session_id ";
        let sessionSQL = "select id, name, type, create_date, last_sender_id, last_sender_name, last_content_type, last_content, last_message_time from "
            + DB_TABLES.Sessions + " s where s.id in(" + sql + ") and s.type in("+type+") ";