|
@ -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
|
|
|
});
|
|
|
};
|