huangwenjie %!s(int64=5) %!d(string=hai) anos
pai
achega
04913db3e4

+ 8 - 3
readme.md

@ -188,9 +188,14 @@ REST API遵循REST最佳实践,规范命名URL中的每个部分。注意POST
            26、专家建议
            26、专家建议
            27、药品处方(在线复诊)
            27、药品处方(在线复诊)
            28、服务评价
            28、服务评价
            29、视屏请求 content:{
                            answer_status:0 //0请求,1已接听
                        }
            2101、上门服务-预约信息
            2102、上门服务-修改工单卡片信息
            2102、上门服务-修改工单卡片信息
            2103、上门服务-变更工单医生信息
            2103、上门服务-变更工单医生信息
            2104、上门服务-变更工单服务项信息
            2104、上门服务-变更工单服务项信息
            2105、修改卡片消息触发刷新消息列表
    **会话类型** 
    **会话类型** 
    
    
        sessions的type字段
        sessions的type字段
@ -231,10 +236,10 @@ REST API遵循REST最佳实践,规范命名URL中的每个部分。注意POST
            j、type =11 思明区上门护理
            j、type =11 思明区上门护理
            sessionId: 居民code+"_"+咨询code+"_"+咨询类型
            sessionId: 居民code+"_"+咨询code+"_"+咨询类型
            k、type =12 候诊室群聊
            sessionId: 诊室code+"_"+咨询code+"_"+咨询类型
            k、type =12 医院协同门诊
            sessionId: 家庭医生CODE+"_"+咨询code+"_"+咨询类型
            
            
            l、type =13 专家咨询
            l、type =13 健康咨询
            sessionId: 居民code+"_"+医生code+"_"+咨询类型
            sessionId: 居民code+"_"+医生code+"_"+咨询类型

+ 30 - 9
src/server/endpoints/v2/session.endpoint.js

@ -14,6 +14,9 @@ let ControllerUtil = require('../../util/controller.util');
let Sessions = require('../../models/sessions/sessions');
let Sessions = require('../../models/sessions/sessions');
let Messages = require('../../models/messages/messages');
let Messages = require('../../models/messages/messages');
let Participants = require('../../models/sessions/participants');
let Participants = require('../../models/sessions/participants');
let log = require("../../util/log.js");
let clientCache = require('../../models/socket.io/client.cache').clientCache();
const SESSION_TYPES = require('../../include/commons').SESSION_TYPES;
const SESSION_TYPES = require('../../include/commons').SESSION_TYPES;
const APIv2 = require('../../include/endpoints').APIv2;
const APIv2 = require('../../include/endpoints').APIv2;
@ -48,29 +51,47 @@ router.post("/", function (req, res) {
    let sessionId = payload.session_id;
    let sessionId = payload.session_id;
    let sessions = new Sessions();
    let sessions = new Sessions();
    let participantArray = [];
    let participantArray = [];
    ///是否视频会议的会话
    let videoconferencing = false;
    log.info("participants: "+participants);
    participants = JSON.parse(participants);
    participants = JSON.parse(participants);
    for (let j in participants) {
    for (let j in participants) {
        log.info("aaaa:"+j + ":" + participants[j]);
        participantArray.push(j + ":" + participants[j]);
        participantArray.push(j + ":" + participants[j]);
    }
    }
    ControllerUtil.regModelEventHandler(sessions, res);
    ControllerUtil.regModelEventHandler(sessions, res);
    console.log(sessionId, sessionName, sessionType, participantArray)
    sessions.createSession(sessionId, sessionName, sessionType, participantArray);
    sessions.createSession(sessionId, sessionName, sessionType, participantArray);
    ///是否视频会议的会话
    let videoconferencing = false;
    // participants = JSON.parse(participants);
    // for (let j in participants) {
    //     participantArray.push(j + ":" + participants[j]);
    // }
    //视频会议的会话 szx add 20181121
    //视频会议的会话 szx add 20181121
    if (!payload.hasOwnProperty('videoconferencing') && payload.videoconferencing == 1){
    if (payload.hasOwnProperty('videoconferencing') && payload.videoconferencing == 1){
        let access_token = "";
        if(payload.hasOwnProperty("mobile"))access_token = payload.access_token;
        videoconferencing = true;
        videoconferencing = true;
        //发送广播,给相关的与会人员
        //发送广播,给相关的与会人员
        for (let j in participants) {
        for (let j in participants) {
            let participant = participants[j];
            let socketClient = ClientCache.findById(participant.userId);
            socketClient.emt("startVideoconference",{"session_id":sessionId});
            let userId = "pcim_"+j;
            let pc_doctorClient = clientCache.findById(userId);
            if(pc_doctorClient){
                log.info("videoconferencing send to "+userId);
                pc_doctorClient.socket.emit("startVideoconference",{"sessionId":sessionId,"user_id":j});
            }
            else{
                log.info("videoconferencing not find "+userId);
            }
        }
        }
        
    }
    }
});
});
/**
/**

+ 27 - 6
src/server/models/sessions/sessions.js

@ -384,7 +384,7 @@ class Sessions extends RedisModel {
        })
        })
    }
    }
    /**
     /**
     * 根据用户ID获取用户的session列表
     * 根据用户ID获取用户的session列表
     * @param userId
     * @param userId
     * @param page
     * @param page
@ -393,7 +393,6 @@ class Sessions extends RedisModel {
     */
     */
    getUserSessions(userId, page, size, businessType) {
    getUserSessions(userId, page, size, businessType) {
        let userSessionKey = RedisModel.makeRedisKey(REDIS_KEYS.UserSessions, userId);
        let userSessionKey = RedisModel.makeRedisKey(REDIS_KEYS.UserSessions, userId);
        logger.info(userId);
        let self = this;
        let self = this;
        if (page > 0) {
        if (page > 0) {
            if (page == 1) {
            if (page == 1) {
@ -415,7 +414,7 @@ class Sessions extends RedisModel {
            // },
            // },
            function (callback) {
            function (callback) {
                SessionRepo.findAllByType(userId,businessType,page,size,function(err,res){
                SessionRepo.findAllByType(userId,businessType,page,size,function(err,res){
                    if (res && res.length == 0) {
                    if (res.length == 0) {
                        ModelUtil.emitOK(self.eventEmitter, []);
                        ModelUtil.emitOK(self.eventEmitter, []);
                        return;
                        return;
                    }
                    }
@ -430,16 +429,22 @@ class Sessions extends RedisModel {
            function (sessionIds) {
            function (sessionIds) {
                let sessionList = [];
                let sessionList = [];
                let functionList = [];
                let functionList = [];
                log.info("sessionIds.length:" + sessionIds.length);
                for (let j = 0; j < sessionIds.length; j++) {
                for (let j = 0; j < sessionIds.length; j++) {
                    log.info("遍历会话 :" + sessionIds);
                    let fun = function (index, callback) {
                    let fun = function (index, callback) {
                        log.info("!callback:" + !callback);
                        if (!callback) {
                        if (!callback) {
                            callback = index, index = 0
                            callback = index, index = 0
                        }
                        }
                        log.info("top=.index:" + index);
                        let sessionId = sessionIds[index];
                        let sessionId = sessionIds[index];
                        log.info("top=.session.id:" + sessionId);
                        let sessionKey = RedisModel.makeRedisKey(REDIS_KEYS.Session, sessionId);
                        let sessionKey = RedisModel.makeRedisKey(REDIS_KEYS.Session, sessionId);
                        log.info("top=.sessionKey:" + sessionKey);
                        let participantsRoleKey = RedisModel.makeRedisKey(REDIS_KEYS.SessionParticipantsRole, sessionId);
                        let participantsRoleKey = RedisModel.makeRedisKey(REDIS_KEYS.SessionParticipantsRole, sessionId);
                        log.info("top=.participantsRoleKey:" + participantsRoleKey);
                        let sessionParticipantsKey = RedisModel.makeRedisKey(REDIS_KEYS.SessionParticipants, sessionId);
                        let sessionParticipantsKey = RedisModel.makeRedisKey(REDIS_KEYS.SessionParticipants, sessionId);
                        log.info("top=.sessionParticipantsKey:" + sessionParticipantsKey);
                        redis.multi()
                        redis.multi()
                            .hgetall(sessionKey)                       // 会话实体
                            .hgetall(sessionKey)                       // 会话实体
                            .hget(participantsRoleKey, userId)         // 用户在此会话中的角色
                            .hget(participantsRoleKey, userId)         // 用户在此会话中的角色
@ -450,6 +455,9 @@ class Sessions extends RedisModel {
                            .execAsync()
                            .execAsync()
                            .then(function (res) {
                            .then(function (res) {
                                let session = res[0];
                                let session = res[0];
                                log.info("top.session.id:" + session.id);
                                log.info("top.session.name:" + session.name);
                                log.info("tope.session.business_type:" + session.business_type);
                                let role = res[1];
                                let role = res[1];
                                let lastFetchTime = res[2];
                                let lastFetchTime = res[2];
                                let users = res[3];
                                let users = res[3];
@ -459,11 +467,19 @@ class Sessions extends RedisModel {
                                let isInvite = true;
                                let isInvite = true;
                                //处理session未加入redis的bug
                                //处理session未加入redis的bug
                                log.info("1.session==null:" + session==null);
                                if(session==null){
                                if(session==null){
                                    let lastLoginTime = new Date();
                                    let lastLoginTime = new Date();
                                    SessionRepo.findOne(sessionId, function (err, res) {
                                    SessionRepo.findOne(sessionId, function (err, res) {
                                        if(res){
                                        if(res){
                                            session = res;
                                            session = res;
                                            log.info("1.session.id:" + session.id);
                                            log.info("1.session.name:" + session.name);
                                            log.info("1.session.business_type:" + session.business_type);
                                            let redisSession = [
                                            let redisSession = [
                                                "id", session.id,
                                                "id", session.id,
                                                "name", session.name,
                                                "name", session.name,
@ -625,14 +641,19 @@ class Sessions extends RedisModel {
                                                sessionName = res[0].name;
                                                sessionName = res[0].name;
                                            }
                                            }
                                            var bir = new Date().getTime();
                                            var bir = new Date().getTime();
                                            if (res && res.length != 0 && res[0].birthdate) {
                                            if (res.length != 0 && res[0].birthdate) {
                                                bir = res[0].birthdate.getTime();
                                                bir = res[0].birthdate.getTime();
                                            }
                                            }
                                            var sex = 1;
                                            var sex = 1;
                                            if (res && res.length != 0 && res[0].sex) {
                                            if (res.length != 0 && res[0].sex) {
                                                sex = res[0].sex;
                                                sex = res[0].sex;
                                            }
                                            }
                                            //end
                                            //end
                                            log.info("2.session.id:" + sessionId);
                                            log.info("2.session.name:" + sessionName);
                                            log.info("2.session.business_type:" + session.business_type);
                                            sessionList.push({
                                            sessionList.push({
                                                id: sessionId,
                                                id: sessionId,
                                                name: sessionName,
                                                name: sessionName,

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

@ -240,7 +240,9 @@ class SessionRepo {
        }
        }
        let sessionSQL ="";
        let sessionSQL ="";
        let sql ="";
        let sql ="";
        sql = "select session_id from " + DB_TABLES.Participants + " w where w.participant_id = ? and participant_role ="+PARTICIPANT_ROLES.HOST+" group by w.session_id";
        //sql = "select session_id from " + DB_TABLES.Participants + " w where w.participant_id = ? and participant_role ="+PARTICIPANT_ROLES.HOST+" group by w.session_id";
        //中山医院无法查询到所有会话记录,暂时取消participant_role的判断条件 20190619
        sql = "select session_id from " + DB_TABLES.Participants + " w where w.participant_id = ? group by w.session_id";
        sessionSQL =  "select * from "
        sessionSQL =  "select * from "
            + DB_TABLES.Sessions + " s where s.id in(" + sql + ") and s.business_type = ? and s.type!=0 limit "+page+","+pagesize;
            + DB_TABLES.Sessions + " s where s.id in(" + sql + ") and s.business_type = ? and s.type!=0 limit "+page+","+pagesize;
        ImDb.execQuery({
        ImDb.execQuery({