|
@ -5,6 +5,7 @@
|
|
|
|
|
|
let ImDb = require('../mysql/db/im.db');
|
|
let ImDb = require('../mysql/db/im.db');
|
|
let log = require('../../util/log.js');
|
|
let log = require('../../util/log.js');
|
|
|
|
const {setColoredOutput} = require("../../util/log");
|
|
|
|
|
|
const DB_TABLES = require('../../include/commons').DB_TABLES;
|
|
const DB_TABLES = require('../../include/commons').DB_TABLES;
|
|
const PARTICIPANT_ROLES = require('../../include/commons').PARTICIPANT_ROLES;
|
|
const PARTICIPANT_ROLES = require('../../include/commons').PARTICIPANT_ROLES;
|
|
@ -190,7 +191,7 @@ class SessionRepo {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
static findAllByTypeAndStatus(userId, businessType,status,page,pagesize, handler) {
|
|
|
|
|
|
static findAllByTypeAndStatus(userId, businessType,status,page,pagesize, handler,patientName) {
|
|
if (page > 0) {
|
|
if (page > 0) {
|
|
if (page == 1) {
|
|
if (page == 1) {
|
|
page = 0;
|
|
page = 0;
|
|
@ -198,9 +199,14 @@ class SessionRepo {
|
|
page = (parseInt(page)-1) * parseInt(pagesize);
|
|
page = (parseInt(page)-1) * parseInt(pagesize);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
let patientNameSql = "";
|
|
|
|
if (patientName){
|
|
|
|
patientNameSql+="and s.name like '%"+patientName+"%'";
|
|
|
|
}
|
|
let sessionSQL ="";
|
|
let sessionSQL ="";
|
|
let sql ="";
|
|
let sql ="";
|
|
if(status == SESSION_STATUS.ENDED){
|
|
if(status == SESSION_STATUS.ENDED){
|
|
|
|
console.log("----------------------进到结束咨询里面----------------------");
|
|
if(businessType == SESSION_BUSINESS_TYPE.PATIENT){//区分居民,有未读消息的置顶排列
|
|
if(businessType == SESSION_BUSINESS_TYPE.PATIENT){//区分居民,有未读消息的置顶排列
|
|
//找出已经结束的咨询
|
|
//找出已经结束的咨询
|
|
sql = "select session_id from " + DB_TABLES.Participants + " w where w.participant_id = ? group by w.session_id";
|
|
sql = "select session_id from " + DB_TABLES.Participants + " w where w.participant_id = ? group by w.session_id";
|
|
@ -209,8 +215,9 @@ class SessionRepo {
|
|
sessionSQL = "select s.* from " + DB_TABLES.Sessions + " s, " + DB_TABLES.Participants + " p " +
|
|
sessionSQL = "select s.* from " + DB_TABLES.Sessions + " s, " + DB_TABLES.Participants + " p " +
|
|
" where ((s.id in(" + sql + ") and s.business_type = ? and s.status = 1) or (s.id in(" + sql1 + ") and s.business_type = ? and s.status = 0)) " +
|
|
" where ((s.id in(" + sql + ") and s.business_type = ? and s.status = 1) or (s.id in(" + sql1 + ") and s.business_type = ? and s.status = 0)) " +
|
|
// " and s.id = p.session_id and p.participant_id = ? ORDER BY (p.last_fetch_time - s.last_message_time+1)>0,s.create_date desc limit "+page+","+pagesize;
|
|
// " and s.id = p.session_id and p.participant_id = ? ORDER BY (p.last_fetch_time - s.last_message_time+1)>0,s.create_date desc limit "+page+","+pagesize;
|
|
" and s.id = p.session_id and p.participant_id = ? ORDER BY s.last_message_time desc limit "+page+","+pagesize;
|
|
|
|
|
|
" and s.id = p.session_id and p.participant_id = ? "+patientNameSql+" ORDER BY s.last_message_time desc limit "+page+","+pagesize;
|
|
log.info("1."+sessionSQL);
|
|
log.info("1."+sessionSQL);
|
|
|
|
console.log("SQL------------:"+sessionSQL);
|
|
ImDb.execQuery({
|
|
ImDb.execQuery({
|
|
"sql": sessionSQL,
|
|
"sql": sessionSQL,
|
|
"args": [userId, businessType,userId,businessType,userId],
|
|
"args": [userId, businessType,userId,businessType,userId],
|
|
@ -219,6 +226,7 @@ class SessionRepo {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}else{
|
|
}else{
|
|
|
|
console.log("else 咨询--------------------------");
|
|
//找出已经结束的咨询
|
|
//找出已经结束的咨询
|
|
sql = "select session_id from " + DB_TABLES.Participants + " w where w.participant_id = ? group by w.session_id";
|
|
sql = "select session_id from " + DB_TABLES.Participants + " w where w.participant_id = ? group by w.session_id";
|
|
//找出角色讨论组中为旁听且未结束的咨询
|
|
//找出角色讨论组中为旁听且未结束的咨询
|