wsl 2 yıl önce
ebeveyn
işleme
34b6271582

+ 8 - 2
src/server/endpoints/v2/session.endpoint.js

@ -84,6 +84,8 @@ router.get("/", function (req, res) {
    let userId = req.query.user_id;
    let businessType = req.query.business_type;
    let status = req.query.status;
    let patientName = req.query.patientName;
    console.log("patientName----------------------------"+patientName);
    if (!page) {
        throw {httpStatus: 406, message: 'Missing page.'};
    }
@ -97,8 +99,12 @@ router.get("/", function (req, res) {
    let sessions = new Sessions();
    ControllerUtil.regModelEventHandler(sessions, res);
    //传入参数齐全走过滤方法
    if(status&&businessType&&userId&&size&&page){
        sessions.getUserStatusSessions(userId,status,businessType,page,size);
    if (patientName||!patientName==0){
        console.log("存在居民名字!");
        patientName = decodeURIComponent(patientName);
    }
    if(status&&businessType&&userId&&size&&page&&patientName){
        sessions.getUserStatusSessions(userId,status,businessType,page,size,patientName);
    }else{
        sessions.getUserSessions(userId, page, size, businessType);
    }

+ 2 - 1
src/server/endpoints/v2/topic.endpoint.js

@ -66,10 +66,11 @@ router.get(APIv2.Sessions.HealthTopicList, function (req, res) {
    let reply = req.query.reply;//SESSION_TYPES
    let page = req.query.page;
    let pagesize = req.query.pagesize;
    let patientName = req.query.patientName;
    let topic = new Topics();
    ControllerUtil.regModelEventHandler(topic, res);
    let users = user.split(",");
    topic.findAllByUserAndReplyAndStatusHealthTopic(users,reply,status,page,pagesize);
    topic.findAllByUserAndReplyAndStatusHealthTopic(users,reply,status,page,pagesize,patientName);
});
/**

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

@ -823,7 +823,7 @@ class Sessions extends RedisModel {
     * @param size
     * @param businessType
     */
    getUserStatusSessions(userId,status,businessType,page, size) {
    getUserStatusSessions(userId,status,businessType,page, size,patientName) {
        let userSessionKey = RedisModel.makeRedisKey(REDIS_KEYS.UserSessions, userId);
        log.info(userId);
        let self = this;
@ -840,7 +840,7 @@ class Sessions extends RedisModel {
                    //     sessionIds.push(res[j].id);
                    // }
                    callback(null,res);
                })
                },patientName)
            },
            // 遍历会话
            function (sessionIds) {

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

@ -128,7 +128,7 @@ class Topics extends RedisModel {
     * @param page
     * @param pagesize
     */
    findAllByUserAndReplyAndStatusHealthTopic(users,reply, status, page, pagesize) {
    findAllByUserAndReplyAndStatusHealthTopic(users,reply, status, page, pagesize,patientName) {
        let self = this;
        page = (page - 1 < 0 ? 0 : page - 1) * pagesize;
        if (!pagesize) pagesize = 10;
@ -138,7 +138,7 @@ class Topics extends RedisModel {
                ModelUtil.emitError(self.eventEmitter, "获取列表失败" + err);
            }
            ModelUtil.emitOK(self.eventEmitter, res);
        })
        },patientName)
    }
    /**

+ 10 - 2
src/server/repository/mysql/session.repo.js

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

+ 11 - 5
src/server/repository/mysql/topics.repo.js

@ -92,21 +92,27 @@ class TopicRepo {
     * @param size
     * @param handler
     */
    static findAllByUserAndReplyAndStatusHealthTopic(userId,reply,status,page,size,handler){
    static findAllByUserAndReplyAndStatusHealthTopic(userId,reply,status,page,size,handler,patientName){
        let sql = "";
        var args =[];
        var tempParms = "";
        if (patientName){
            tempParms += " and s.name like '%"+patientName+"%' ";
        }
        if(status==10){
            args.push(userId,status,page,size);
            args.push(userId,status,page,size,patientName);
            sql =  "SELECT t.*, s.avatar,s.sex,s.birthdate, s.`name` AS patient_name,c.doctor FROM "+
                DB_TABLES.Topics+" t,"+DB_TABLES.Participants+" p,"+DB_TABLES.Doctors+" d,"+DB_TABLES.WlyyConsult+" c,"+DB_TABLES.Patients+" s "+
                "WHERE d.id = p.participant_id AND c.id = t.id AND c.patient = s.id AND p.session_id = t.session_id "+
                "AND d.id in (?) AND t. STATUS = ? AND c.type not in ('6','8') ORDER BY create_time DESC limit ?,?";
                "AND d.id in (?) AND t. STATUS = ? AND c.type not in ('6','8')"+tempParms+" ORDER BY create_time DESC limit ?,?";
        }else{
            args.push(userId,status,reply,page,size);
            args.push(userId,status,reply,page,size,patientName);
            sql =  "SELECT t.*, s.avatar,s.sex,s.birthdate, s.`name` AS patient_name,c.doctor FROM "+
                DB_TABLES.Topics+" t,"+DB_TABLES.Participants+" p,"+DB_TABLES.Doctors+" d,"+DB_TABLES.WlyyConsult+" c,"+DB_TABLES.Patients+" s "+
                "WHERE d.id = p.participant_id AND c.id = t.id AND c.patient = s.id AND p.session_id = t.session_id "+
                "AND d.id in (?) AND t. STATUS = ? and t.reply=? AND c.type not in ('6','8') ORDER BY create_time DESC limit ?,?";
                "AND d.id in (?) AND t. STATUS = ? and t.reply=? AND c.type not in ('6','8')"+tempParms+" ORDER BY create_time DESC limit ?,?";
        }
        ImDb.execQuery({
            sql: sql,