Bladeren bron

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

zd_123 5 jaren geleden
bovenliggende
commit
694d3ded13

+ 2 - 0
readme.md

@ -180,6 +180,8 @@ REST API遵循REST最佳实践,规范命名URL中的每个部分。注意POST
            18、个人名片
            19、消息转发
            20、康复计划发送
            21、转诊待预约发送
            22、已知悉
    **会话类型** 
    
        sessions的type字段

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

@ -976,6 +976,7 @@ class Sessions extends RedisModel {
        let message_timestamp_key = RedisModel.makeRedisKey(REDIS_KEYS.MessagesByTimestamp, sessionId);
        if (!start_msg_id && !end_msg_id) {
            redis.zrevrangeAsync(message_timestamp_key, 0, 0).then(function (res) {
                logger.info("redis return res-----"+res);
                if (res.length == 0) {
                    //修复应redis没有缓冲聊天记录导致会话列表加载不出来
                    // cache messages
@ -1422,6 +1423,7 @@ class Sessions extends RedisModel {
        let sessionKey = RedisModel.makeRedisKey(REDIS_KEYS.Session, sessionId);
        let messageId = mongoose.Types.ObjectId().toString();
        let sessionType =0;
        let sessionName;
        message.id = messageId;
        // 检查会话中是否存在此成员
@ -1436,8 +1438,49 @@ class Sessions extends RedisModel {
                    sessionType = res[0];
                    let sessionName = res[1];
                    if (sessionType == null) {
                        ModelUtil.emitError(self.eventEmitter, "Session " + sessionId + " is not found.");
                        return;
                        self.getSessions(sessionId,function(err,res){
                            if (err){
                                logger.error("session data is error");
                            } else {
                                sessionName=res[0].name;
                                sessionType = res[0].type;
                            }
                        });
                        let participantArray = [];
                        let participantsStr="{";
                        ParticipantRepo.findAll(sessionId, function (err, participants) {
                            if (err) {
                                ModelUtil.emitError(self.eventEmitter, err.message);
                                return;
                            }
                            participants.forEach(function (participant) {
                                let participantId = participant.id;
                                let participantRole = participant.role;
                                let score = ObjectUtil.timestampToLong(participant.last_fetch_time||(new Date()));
                                participantsStr +="\""+participantId+"\":\""+participantRole+"\",";
                            });
                            participantsStr = participantsStr.substring(0,participantsStr.length-1)+'}';
                            participantsStr = JSON.parse(participantsStr);
                            for (let j in participantsStr) {
                                participantArray.push(j + ":" + participantsStr[j]);
                            }
                            //创建session到redis
                            self.createSessionToRedis(sessionId, sessionName, sessionType, participantArray, messageId, function (err, res) {
                                if (err) {
                                    if (handler) {
                                        handler(err, null);
                                    }
                                    ModelUtil.emitError(self.eventEmitter, {message: err, status: -1}, null);
                                } else {
                                    if (handler) {
                                        handler(null, res);
                                    }
                                    ModelUtil.emitOK(self.eventEmitter, {status: 200, data: res});
                                }
                            });
                        });
                    }
                    if(sessionType == SESSION_TYPES.MUC || sessionType == SESSION_TYPES.PRESCRIPTION){
                        if(message.content_type == CONTENT_TYPES.PlainText ||

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

@ -23,9 +23,9 @@ class ParticipantRepo {
     * @param handler
     */
    static findAll(sessionId, handler) {
        let sql = "SELECT u.id, u.name, u.sex, u.birthdate, u.avatar, p.participant_role role, false is_patient,p.last_fetch_time,u.level FROM sessions s, participants p, doctors u " +
        let sql = "SELECT u.id, u.name, u.sex, u.birthdate, u.avatar,u.hospital_name, p.participant_role role, false is_patient,p.last_fetch_time,u.level FROM sessions s, participants p, doctors u " +
            "WHERE s.id = ? AND s.id = p.session_id AND p.participant_id = u.id union " +
            "SELECT u.id, u.name, u.sex, u.birthdate, u.avatar, p.participant_role role, true is_patient,p.last_fetch_time,0 as level FROM sessions s, participants p, patients u " +
            "SELECT u.id, u.name, u.sex, u.birthdate, u.avatar,u.hospital_name, p.participant_role role, true is_patient,p.last_fetch_time,0 as level FROM sessions s, participants p, patients u " +
            "WHERE s.id = ? AND s.id = p.session_id AND p.participant_id = u.id";
        ImDb.execQuery({

+ 3 - 3
src/server/resources/config/config.dev.js

@ -11,7 +11,7 @@ let imDbConfig = {
// Redis
let redisConfig = {
    host: '172.19.103.88',
    host: '192.168.131.172',
    port: 6379,
    db: 6
};
@ -22,7 +22,7 @@ let redisConfig = {
// };
// 内网Redis
let innerRedisConfig = {
    host: '172.19.103.88',
    host: '192.168.131.172',
    port: 6379,
    db: 6
};
@ -35,7 +35,7 @@ let wlyyServerConfig = {
//医生助手配置
let wlyyDAServerConfig = {
    host: '172.19.103.88',
    host: '192.168.131.172',
    port: 9092,
    model:"/wlyy"
};

+ 4 - 4
src/server/resources/config/config.test.js

@ -11,7 +11,7 @@ let imDbConfig = {
// Redis
let redisConfig = {
    host: '172.19.103.88',
    host: '192.168.131.172',
    port: 6379,
    db: 1
};
@ -22,20 +22,20 @@ let redisConfig = {
// };
// 内网Redis
let innerRedisConfig = {
    host: '172.19.103.88',
    host: '192.168.131.172',
    port: 6379,
    db: 1
};
// 三师后台
let wlyyServerConfig = {
    host: '172.19.103.88',
    host: '192.168.131.172',
    port: 9092,
    model:"/wlyy"
};
//医生助手配置
let wlyyDAServerConfig = {
    host: '172.19.103.88',
    host: '192.168.131.172',
    port: 9092,
    model:"/wlyy"
};