Browse Source

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

sand 8 years ago
parent
commit
168ddb1361
2 changed files with 22 additions and 12 deletions
  1. 2 0
      src/doctor/endpoints/chats.endpoint.js
  2. 20 12
      src/doctor/repository/group.msg.repo.js

+ 2 - 0
src/doctor/endpoints/chats.endpoint.js

@ -542,6 +542,8 @@ router.get(APIv1.Chats.List, function (req, res) {
                // 过滤掉医生间的求助团队
                if(group.group_type === 2) continue;
                //查找医生在讨论组的最新的消息记录数
                chats.groups.push({
                    code: group.code,
                    name: group.name,

+ 20 - 12
src/doctor/repository/group.msg.repo.js

@ -30,16 +30,18 @@ exports.findAllMessages = function (groupId, contentType, start, end, count, han
 */
exports.findAllGroupsWithDoctor = function (userId, handler) {
    var sql = "SELECT DISTINCT g.id code, g.name name, ms.last_content_type, ms.last_content, ms.timestamp, ms.new_msg_count, '1' group_type " +
        "FROM wlyy.wlyy_admin_team g, wlyy.wlyy_admin_team_member m, wlyy.wlyy_doctor d, msg_statistic ms " +
        "WHERE d.code = ? AND d.code = m.doctor_code AND m.team_id = g.id AND g.id = ms.from_gid AND ms.last_content_type IN (1,2,3,5,6) GROUP BY g.id , g.name " +
        " FROM wlyy.wlyy_admin_team g, wlyy.wlyy_admin_team_member m, wlyy.wlyy_doctor d, msg_statistic ms ," +
        " ( SELECT new_msg_count, from_gid  FROM  msg_statistic  WHERE uid =?  GROUP BY from_gid  ORDER BY  `timestamp` DESC ) msgcount " +
        " WHERE d.code = ? AND d.code = m.doctor_code AND msgcount.from_gid=ms.from_gid AND m.team_id = g.id AND g.id = ms.from_gid AND ms.last_content_type IN (1,2,3,5,6) GROUP BY g.id , g.name " +
        " UNION " +
        "SELECT m.group_code, m.group_name, ms.last_content_type, ms.last_content, ms.timestamp, ms.new_msg_count, '2' group_type " +
        "FROM wlyy.wlyy_talk_group g, wlyy.wlyy_talk_group_member m, wlyy.wlyy_doctor d, msg_statistic ms " +
        "WHERE d.code = ? AND d.code = m.member_code AND m.group_code = g.code AND g.code = ms.from_gid group by m.group_code, m.group_name";
        " SELECT m.group_code, m.group_name, ms.last_content_type, ms.last_content, ms.timestamp, ms.new_msg_count, '2' group_type " +
        " FROM wlyy.wlyy_talk_group g, wlyy.wlyy_talk_group_member m, wlyy.wlyy_doctor d, msg_statistic ms, " +
        " ( SELECT new_msg_count, from_gid  FROM  msg_statistic  WHERE uid =?  GROUP BY from_gid  ORDER BY  `timestamp` DESC ) msgcount " +
        " WHERE d.code = ? AND d.code = m.member_code AND msgcount.from_gid=ms.from_gid AND m.group_code = g.code AND g.type=2  AND g.code = ms.from_gid group by m.group_code, m.group_name";
    imRepo.execQuery({
        "sql": sql,
        "args": [userId, userId],
        "args": [userId, userId,userId,userId],
        "handler": handler
    });
};
@ -51,16 +53,22 @@ exports.findAllGroupsWithDoctor = function (userId, handler) {
 * @param handler
 */
exports.findAllGroupsWithPatient = function (userId, handler) {
    var sql = "SELECT g.code, g.name, '', '', '', ms.last_content_type, ms.last_content, ms.timestamp, ms.new_msg_count, g.type group_type " +
        "FROM msg_statistic ms, (" +
    var sql = "SELECT g.code, g.name, '', '', '', ms.last_content_type, ms.last_content, ms.timestamp, msgcount.new_msg_count, g.type group_type " +
        " FROM msg_statistic ms, (" +
        " SELECT g.code code, g.name name, g.type type FROM wlyy.wlyy_talk_group g, wlyy.wlyy_talk_group_member m " +
        " WHERE g.code = m.group_code and m.member_code = ?) g, wlyy.wlyy_patient p " +
        "WHERE ((ms.uid = ? and ms.from_uid = p.code) OR (ms.uid = p.code and ms.from_uid = ?)) " +
        "and ms.from_gid = g.code and ms.msg_type = 2 AND ms.last_content_type in (1,2,3,5,6) ";
        " WHERE g.code = m.group_code and m.member_code = ?) g, wlyy.wlyy_patient p , " +
        " ( SELECT new_msg_count, from_gid  FROM  msg_statistic  WHERE uid =?  GROUP BY from_gid  ORDER BY  `timestamp` DESC ) msgcount " +
        " WHERE ((ms.uid = ? and ms.from_uid = p.code) OR (ms.uid = p.code and ms.from_uid = ?)) " +
        " and ms.from_gid = g.code and ms.msg_type = 2 AND ms.last_content_type in (1,2,3,5,6) AND msgcount.from_gid=ms.from_gid " +
        " UNION " +
        " SELECT m.group_code code, m.group_name name, '', '', '', ms.last_content_type, ms.last_content, ms.timestamp, ms.new_msg_count, '2' group_type " +
        " FROM wlyy.wlyy_talk_group g, wlyy.wlyy_talk_group_member m, wlyy.wlyy_doctor d, msg_statistic ms, " +
        " ( SELECT new_msg_count, from_gid  FROM  msg_statistic  WHERE uid =?  GROUP BY from_gid  ORDER BY  `timestamp` DESC ) msgcount " +
        " WHERE d.code = ? AND d.code = m.member_code AND msgcount.from_gid=ms.from_gid AND m.group_code = g.code AND g.type=1  AND g.code = ms.from_gid group by m.group_code, m.group_name";
    imRepo.execQuery({
        "sql": sql,
        "args": [userId, userId, userId],
        "args": [userId, userId, userId,userId,userId,userId],
        "handler": handler
    });
};