浏览代码

Merge branch 'dev' of linzhuo/im.doctor into dev

linzhuo 8 年之前
父节点
当前提交
d208a67cdb

+ 8 - 0
src/doctor/models/doctor.js

@ -458,6 +458,8 @@ class Doctor extends BaseModel {
            var amount = 0;
            for (let i = 0; i < doctors.length; i++) {
                let doctor = doctors[i];
                //过滤结束的咨询
                //if(doctor.last_content_type==7)continue;
                amount = doctor.new_msg_count+amount;
            }
            // 再获取医生间的组
@ -469,6 +471,8 @@ class Doctor extends BaseModel {
                for (let i = 0; i < groups.length; i++) {
                    let group = groups[i];
                    //过滤结束的咨询
                    //if(group.last_content_type==7)continue;
                    amount =   group.new_msg_count+amount;
                }
                chats.doctor = amount;
@ -481,6 +485,8 @@ class Doctor extends BaseModel {
                    }
                    for (let i = 0; i < patients.length; i++) {
                             let patient = patients[i];
                            //过滤结束的咨询
                            // if(patient.last_content_type==7)continue;
                             patientAmount =patientAmount+ patient.new_msg_count;
                    }
@ -494,6 +500,8 @@ class Doctor extends BaseModel {
                            let group = groups[i];
                            // 过滤掉医生间的求助团队
                            if (group.group_type === 2) continue;
                            //过滤结束的咨询
                            //if(group.last_content_type==7)continue;
                            patientAmount = patientAmount+ group.new_msg_count;
                        }
                        chats.patient = patientAmount;

+ 12 - 3
src/doctor/models/patient.js

@ -72,7 +72,7 @@ class Patient extends BaseModel {
            }
            // 结束网络连接,后续操作继续执行
            pmRepo.findOneMessage(result.insertId, function (err, msg) {
            pmRepo.findOnePatientMessage(result.insertId, function (err, msg) {
                if (err) {
                    modelUtil.emitDbError(self.eventEmitter, 'Save private message success, but return last message failed', err);
                    return;
@ -81,7 +81,16 @@ class Patient extends BaseModel {
                modelUtil.emitData(self.eventEmitter, Doctor.fillMessages(msg));
                // 通过Web Socket推送给患者
                self.pushGroupMessage(message);
                let patientClient = clientCache.findById(message.to);
                if (!patientClient) {
                    log.warn("User is not online, user id: ", message.to);
                    //发送微信模板消息
                    self.sendConsultWechatReplyTempMsg(message);
                    return;
                }
                let row = msg[0];
                row.timestamp = objectUtil.timestampToLong(row.timestamp);
                patientClient.socketServer.sockets.emit('message', row);
            });
            // 更新自身的聊天统计信息
@ -112,7 +121,7 @@ class Patient extends BaseModel {
            return;
        }
        patientClient.socketServer.sockets.emit('message', message);
        patientClient.socketServer.sockets.emit('message',groupRepo.getOnGroupMsg(message.msgId));
    };
    /**

+ 2 - 1
src/doctor/models/search.js

@ -341,7 +341,8 @@ class Search extends BaseModel {
                        content: t.content,
                        type: t.type,
                        msg_id: t.msg_id,
                        groupType: t.group_type
                        groupType: t.group_type,
                        avatar:t.photo
                    };
                    data.push(message);
                }

文件差异内容过多而无法显示
+ 2 - 7
src/doctor/repository/group.msg.repo.js


+ 8 - 0
src/doctor/repository/group.repo.js

@ -9,6 +9,14 @@
var wlyyRepo = require("./database/wlyy.db.js");
var GROUP_TYPE = require('../include/commons').GROUP_TYPE;
exports.getOnGroupMsg=function(msgid,handler){
    wlyyRepo.execQuery({
        "sql": " select g.*,d.`name`,d.photo from msg_group g,wlyy.wlyy_doctor d where g.msg_id=? and g.from_uid=d.code;",
        "args": [msgid],
        "handler": handler
    });
}
/**
 * 判断是否为团队成员。
 *

+ 19 - 3
src/doctor/repository/private.msg.repo.js

@ -27,6 +27,15 @@ exports.findOneMessage = function (messageId, handler) {
  });
};
exports.findOnePatientMessage = function (messageId,handler) {
    imRepo.execQuery({
        "sql": "SELECT m.*,d.name,d.photo FROM msg_p2p m, wlyy.wlyy_doctor d, wlyy.wlyy_patient p WHERE m.from_uid = d. CODE AND m.to_uid = p. CODE AND m.msg_id =?",
        "args": [messageId],
        "handler": handler
    });
};
/**
 * 查找所有消息。
 *
@ -93,11 +102,18 @@ exports.findAllP2PWithPatient = function (userId, handler) {
    var sql="SELECT p1. CODE as code , p1. NAME as name, p1.birthday, p1.sex, p1.photo, w.last_content, w.last_content_type, w. TIMESTAMP as timestamp, w.new_msg_count " +
             "FROM msg_p2p p, wlyy.wlyy_patient p1, msg_statistic w " +
             "WHERE (( p.to_uid = p1.`code` AND p.from_uid = ? ) OR ( p.from_uid = p1.`code` AND p.to_uid = ? )) " +
             "AND p.type IN (1, 2, 3, 5, 6) AND w.uid = ? AND w.peer_uid = p1.`code` AND w.from_gid IS NULL " +
        "GROUP BY p1. CODE, p1. NAME, p1.birthday, p1.sex, p1.photo"
             "AND w.last_content_type IN (1, 2, 3, 5, 6) AND w.uid = ? AND w.peer_uid = p1.`code` AND w.from_gid IS NULL " +
            "GROUP BY p1. CODE, p1. NAME, p1.birthday, p1.sex, p1.photo " +
            "union all " +
            "SELECT p1. CODE AS code, p1. NAME AS name, p1.birthday, p1.sex, p1.photo, w.last_content, t.type, w. TIMESTAMP AS timestamp, w.new_msg_count " +
            "FROM msg_p2p p, wlyy.wlyy_patient p1, msg_statistic w, wlyy.wlyy_consult_team t " +
            "WHERE (( p.to_uid = p1.`code` AND p.from_uid = ? ) OR ( p.from_uid = p1.`code` AND p.to_uid = ? )) " +
            "AND w.last_content_type = 7 AND t.type = 6 " +
            "AND (( t.patient = p.from_uid AND t.doctor = p.to_uid ) OR ( t.patient = p.to_uid AND t.doctor = p.from_uid )) " +
            "AND w.uid = ? AND w.peer_uid = p1.`code` AND w.from_gid IS NULL GROUP BY p1. CODE, p1. NAME, p1.birthday, p1.sex, p1.photo;";
    imRepo.execQuery({
        "sql": sql,
        "args": [userId, userId,userId],
        "args": [userId, userId,userId,userId, userId,userId],
        "handler": handler
    });
};

+ 15 - 10
src/doctor/repository/search.repo.js

@ -183,7 +183,7 @@ module.exports.searchDoctorsContentDetail = function(userId,keyword,groupcode,ty
            imRepo.execQuery({
                "sql": p2psql,
                "args": [userId,groupcode,userId,groupcode,"%" + keyword + "%"],
                "args": [groupcode,userId,groupcode,userId,"%" + keyword + "%"],
                "handler": handler
            });
        }
@ -195,17 +195,22 @@ module.exports.searchDoctorsContentDetail = function(userId,keyword,groupcode,ty
 * 搜索聊天过的医生(仅限群组聊天)
 */
module.exports.searchGroupDoctors = function(userId,keyword,handler){
    var sql ="SELECT g.`code`, g.`name`,g.type as group_type, (( SELECT group_concat(temp.member_name) FROM wlyy.wlyy_talk_group_member temp WHERE temp.group_code = g. CODE and  t.type<4 AND temp.member_name LIKE ? )) AS con " +
        "FROM msg_group w, wlyy.wlyy_talk_group g, wlyy.wlyy_talk_group_member t " +
        "WHERE w.to_gid = g.`code` and  t.type<4 " +
        "AND t.group_code = g. CODE " +
        "AND w.to_gid IN ( SELECT w1.group_code FROM wlyy.wlyy_talk_group_member w1 WHERE w1.member_code = ? ) " +
        "AND W.to_gid NOT IN (SELECT w1.group_code FROM wlyy.wlyy_talk_group_member w1 WHERE w1.group_code = g.code and  w1. STATUS = 1  AND w1.TYPE =4) "+
        "AND ( g.`name` LIKE ? OR t.member_name LIKE ?) " +
        "GROUP BY g. NAME, g.`code` order by w.msg_id desc";
    var sql ="SELECT g.`code`, g.`name`,'2' as group_type, (( SELECT group_concat(temp.member_name) FROM wlyy.wlyy_talk_group_member temp WHERE temp.group_code = g. CODE and  t.type<4 AND temp.member_name LIKE ? )) AS con " +
            "FROM msg_group w, wlyy.wlyy_talk_group g, wlyy.wlyy_talk_group_member t " +
            "WHERE w.to_gid = g.`code` and  t.type<4 " +
            "AND t.group_code = g. CODE " +
            "AND w.to_gid IN ( SELECT w1.group_code FROM wlyy.wlyy_talk_group_member w1 WHERE w1.member_code = ? ) " +
            "AND W.to_gid NOT IN (SELECT w1.group_code FROM wlyy.wlyy_talk_group_member w1 WHERE w1.group_code = g.code and  w1. STATUS = 1  AND w1.TYPE =4) "+
            "AND ( g.`name` LIKE ? OR t.member_name LIKE ?) " +
            "GROUP BY g. NAME, g.`code` " +
            " UNION ALL" +//下面是行政团队信息
            " SELECT g.id CODE, g. NAME NAME, '1' AS group_type, " +
            "( SELECT group_concat(temp. NAME) FROM wlyy.wlyy_admin_team_member m1, wlyy.wlyy_doctor temp WHERE temp. CODE = m1.doctor_code AND m1.team_id = g.id AND temp.`name` LIKE ? ) AS con " +
            " FROM wlyy.wlyy_admin_team g, wlyy.wlyy_admin_team_member m, wlyy.wlyy_doctor d, msg_statistic ms " +
            " WHERE d. CODE = m.doctor_code AND m.team_id = g.id AND g.id = ms.from_gid AND ms.uid = ? AND ms.last_content_type IN (1, 2, 3, 5, 6) AND (d. NAME LIKE ? OR g. NAME LIKE ?) GROUP BY g.id, g. NAME";
    imRepo.execQuery({
        "sql": sql,
        "args": ["%" + keyword + "%",userId,  "%" + keyword + "%", "%" + keyword + "%"],
        "args": ["%" + keyword + "%",userId,  "%" + keyword + "%", "%" + keyword + "%", "%" + keyword + "%",userId, "%" + keyword + "%", "%" + keyword + "%"],
        "handler": handler
    });
}

+ 23 - 8
src/doctor/repository/stats.msg.repo.js

@ -36,7 +36,7 @@ exports.getChatList = function (userId, handler) {
 * @param userId
 * @param handler
 */
exports.getChatAllUnReadCount = function (userId, handler) {
  exports.getChatAllUnReadCount = function (userId, handler) {
    imRepo.execQuery({
        "sql": "SELECT new_msg_count from msg_statistic WHERE uid=? AND new_msg_count>0",
        "args": [userId],
@ -50,6 +50,7 @@ exports.updatePrivateChatSummary = function (userId, peerId, from, type, content
    if (userId == from) {
        //userId  = from ,peerId = to from = from
        // 更新自身的统计信息
        var sql = "INSERT INTO msg_statistic (uid,uuid,from_uid,peer_uid,msg_type,last_content_type,last_content,new_msg_count) " +
            "VALUES (?,?,?,?,?,?,?,?) ON DUPLICATE KEY UPDATE peer_uid=?,last_content_type=?,last_content=?";
@ -59,15 +60,29 @@ exports.updatePrivateChatSummary = function (userId, peerId, from, type, content
            "handler": handler
        });
    } else {
        var sql ="";
        if(type==7){//结束的咨询
            //userId  = to ,peerId = from, from = from
            sql = "INSERT INTO msg_statistic (uid,uuid,from_uid,peer_uid,msg_type,last_content_type,last_content) " +
                "VALUES (?,?,?,?,?,?,?) ON DUPLICATE KEY UPDATE peer_uid=?,last_content_type=?,last_content=?";
            // 更新对端的统计信息
            imRepo.execQuery({
                "sql": sql,
                "args": [userId, uuid, from, peerId, 1, type, content, peerId, type, content],
                "handler": handler
            });
        }else{
        //userId  = to ,peerId = from, from = from
        var sql = "INSERT INTO msg_statistic (uid,uuid,from_uid,peer_uid,msg_type,last_content_type,last_content,new_msg_count) " +
         sql = "INSERT INTO msg_statistic (uid,uuid,from_uid,peer_uid,msg_type,last_content_type,last_content,new_msg_count) " +
            "VALUES (?,?,?,?,?,?,?,?) ON DUPLICATE KEY UPDATE peer_uid=?,last_content_type=?,last_content=?,new_msg_count=new_msg_count+1";
        // 更新对端的统计信息
        imRepo.execQuery({
            "sql": sql,
            "args": [userId, uuid, from, peerId, 1, type, content, 1, peerId, type, content],
            "handler": handler
        });
            // 更新对端的统计信息
            imRepo.execQuery({
                "sql": sql,
                "args": [userId, uuid, from, peerId, 1, type, content, 1, peerId, type, content],
                "handler": handler
            });
        }
    }
};

+ 22 - 34
src/doctor/resources/config/config.test.js

@ -1,23 +1,23 @@
"use strict";
let wlyyDbConfig = {
    host: '120.41.251.85',
    user: 'root',
    password: 't_s_6_7$1',
    database: 'wlyy_test',
var wlyyDbConfig = {
    host: '172.17.110.160',
    user: 'ssgg',
    password: 'ssgg',
    database: 'wlyy',
    connectionLimit: '100'
};
let imDbConfig = {
    host: 'localhost',
    user: 'root',
    password: '19991120',
    database: 'im_test',
var imDbConfig = {
    host: '172.17.110.160',
    user: 'ssgg',
    password: 'ssgg',
    database: 'im_new',
    connectionLimit: '100'
};
// 企业版的推送配置
let geTuiConfig = {
var geTuiConfig = {
    HOST: 'https://api.getui.com/apiex.htm',
    APPID: 'qWmRh2X88l7HuE36z3qBe8',
    APPKEY: 'EzERfV8c849lBkZqHWzQG1',
@ -25,44 +25,32 @@ let geTuiConfig = {
};
//AppStore版的推送App配置
let geTuiAppStoreCfg = {
    HOST: 'https://api.getui.com/apiex.htm',
    APPID: 'H6FYbDejks6VjMmW3uH7V6',
    APPKEY: '0PFWlKmLBN9YzhCfFWVgYA',
    MASTERSECRET: 'pvjCGtRZJx9SRVODkxc816'
var geTuiAppStoreCfg = {
    HOST : 'https://api.getui.com/apiex.htm',
    APPID : 'H6FYbDejks6VjMmW3uH7V6',
    APPKEY : '0PFWlKmLBN9YzhCfFWVgYA',
    MASTERSECRET : 'pvjCGtRZJx9SRVODkxc816'
};
// 三师后台
let wlyyServerConfig = {
    host: '172.19.103.87',
    port: 9090
var wlyyServerConfig = {
    host: '172.19.103.88',
    port: 9092
};
// 透传服务
let transServerConfig = {
var transServerConfig = {
    host: '172.19.103.76',
    port: 8000
};
// 微信配置
let wechatConfig = {
    appId: 'wx1f129f7b51701428'
    , appSecret: '988f005d8309ed1795939e0f042431fb'
    , token: '27eb3bb24f149a7760cf1bb154b08040'
    , baseUrl: 'ehr.yihu.com/wlyy'
    , template: {
        // 咨询回复模板
        consultTemplate: '-dr4QNyFoRvVsf8uWxXMC1dRyjwnbUuJwJ21vBLhf18'
    }
};
exports.app = 'im.server';
exports.version = '1.2.7';
exports.version = '1.0.2.20160805';
exports.debug = true;
exports.serverPort = 3000;
exports.sessionExpire = 1800;
exports.showSQL = true;
exports.showSQL= true;
exports.wlyyDbConfig = wlyyDbConfig;
exports.imDbConfig = imDbConfig;