Browse Source

Merge branch 'dev' of yeshijie/patient-co-management into dev

yeshijie 7 năm trước cách đây
mục cha
commit
e21ad107aa

+ 32 - 6
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/consult/FinishConsultJob.java

@ -44,21 +44,47 @@ public class FinishConsultJob implements Job {
            .append("SELECT id FROM ").append(imDb).append(".doctors d where d.id<>t.patient) ")
            .append("AND UNIX_TIMESTAMP(now()) - UNIX_TIMESTAMP(s.last_message_time) > 24*3600 ")
            .append("ORDER BY t.create_time");
            JSONObject userAgent = new JSONObject();
            userAgent.put("uid","admin");
            userAgent.put("admin_token","0a5c5258-8863-4b07-a3f9-88c768528ab4");
            userAgent.put("token","");
            userAgent.put("imei","admin_imei");
            List<Map<String,Object>> list = jdbcTemplate.queryForList(sql.toString());
            list.stream().forEach(one->{
                String topicId = one.get("topic_id").toString();
                String topicName = one.get("topic_name").toString();
                JSONObject userAgent = new JSONObject();
                userAgent.put("uid","admin");
                userAgent.put("admin_token","0a5c5258-8863-4b07-a3f9-88c768528ab4");
                userAgent.put("token","");
                userAgent.put("imei","admin_imei");
                logger.info("Got topic to terminate, " + topicId + ": " + topicName + ", last active time: " + one.get("last_message_time"));
                String response = httpUtil.sendLoginGet(server_url+"/doctor/consult/finish_consult","consult="+topicId,userAgent.toString());
                logger.info("FinishConsultJob response....."+response);
            });
            logger.info("FinishConsultJob 处理医生回复后,居民进入了咨询但是没有回复的 咨询也要自动结束.....");
            sql = new StringBuffer();
            sql.append("SELECT s.id session_id,t.id topic_id, t.name topic_name ")
             .append("FROM ").append(imDb).append(".sessions s,").append(imDb).append(".wlyy_consults t ")
             .append("WHERE s.id = t.session_id  AND t.end_message_id IS NULL AND s.last_content_type =14 ")
             .append("AND UNIX_TIMESTAMP(now()) - UNIX_TIMESTAMP(s.last_message_time) > 24*3600 and s.type =1 ");
            StringBuffer sql2 = new StringBuffer();
            sql2.append("SELECT a.id from ( ")
             .append(" SELECT * from ").append(imDb).append(".muc_messages WHERE session_id=? ORDER BY `timestamp` desc LIMIT 1,1 ")
             .append(") a, wlyy_doctor d WHERE a.sender_id=d.code ");
            //查找超过24小时,且最后一条消息是居民进入系统的会话id
            List<Map<String,Object>> sessionIdList = jdbcTemplate.queryForList(sql.toString());
            sessionIdList.stream().forEach(one->{
                String sessionId = one.get("session_id").toString();
                String topicId = one.get("topic_id").toString();
                String topicName = one.get("topic_name").toString();
                List<Map<String,Object>> temp = jdbcTemplate.queryForList(sql2.toString(),sessionId);
                if(temp!=null&&temp.size()>=0){
                    logger.info("Got topic to terminate, " + topicId + ": " + topicName + ", last active time: " + one.get("last_message_time"));
                    String response = httpUtil.sendLoginGet(server_url+"/doctor/consult/finish_consult","consult="+topicId,userAgent.toString());
                    logger.info("FinishConsultJob response....."+response);
                }
            });
            logger.info("FinishConsultJob end.....");
        }catch (Exception e){
            logger.error("FinishConsultJob error....."+e.getMessage());