|  | @ -4218,23 +4218,105 @@ public class ImService {
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 导出医生所有的咨询记录
 | 
	
		
			
				|  |  |      * 查询患者所有的咨询记录总数
 | 
	
		
			
				|  |  |      * * @param doctor 患者标识
 | 
	
		
			
				|  |  |      * * @param id 会话ID(等同IM表topicId)
 | 
	
		
			
				|  |  |      * * @param type 咨询会话类型
 | 
	
		
			
				|  |  |      * * @param status 咨询状态:0全部,1候诊中,2就诊中,3结束
 | 
	
		
			
				|  |  |      * * @param title 标题关键字
 | 
	
		
			
				|  |  |      * * @param start_time 开始时间
 | 
	
		
			
				|  |  |      * * @param end_time 结束时间
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param doctor     医生标识
 | 
	
		
			
				|  |  |      * @param id         会话ID(等同IM表topicId)
 | 
	
		
			
				|  |  |      * @param type       咨询会话类型 : 0 全部
 | 
	
		
			
				|  |  |      * @param status     咨询状态:0全部,1候诊中,2就诊中,3结束
 | 
	
		
			
				|  |  |      * @param title      标题关键字
 | 
	
		
			
				|  |  |      * @param start_time 开始时间
 | 
	
		
			
				|  |  |      * @param end_time   结束时间
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     @Transactional(readOnly = true)
 | 
	
		
			
				|  |  |     public List<Map<String, Object>> findRecordNew(String doctor, String id,
 | 
	
		
			
				|  |  |                                                    String type, Integer status,
 | 
	
		
			
				|  |  |                                                    String title, String start_time, String end_time, String patient) {
 | 
	
		
			
				|  |  |     public Long countConsultRecordByDoctor2(String doctor, String id, String type, Integer status, String title, String start_time, String end_time) {
 | 
	
		
			
				|  |  |         String sql = "";
 | 
	
		
			
				|  |  |         sql = "SELECT " +
 | 
	
		
			
				|  |  |                 " COUNT(1) AS \"total\" " +
 | 
	
		
			
				|  |  |                 "FROM wlyy_outpatient op LEFT JOIN wlyy_consult a  ON a.relation_code = op.id \n" +
 | 
	
		
			
				|  |  |                 " LEFT join wlyy_consult_team b on a.id = b.consult" +
 | 
	
		
			
				|  |  |                 " LEFT JOIN base_patient d on op.patient = d.id " +
 | 
	
		
			
				|  |  |                 " WHERE 1=1 ";
 | 
	
		
			
				|  |  |         if (status == 1) {
 | 
	
		
			
				|  |  |             sql += " and op.status = 0";
 | 
	
		
			
				|  |  |         } else if (status == 0) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         } else if (status == 2) {
 | 
	
		
			
				|  |  |             sql += " and op.status = 1";
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             sql += " and op.status = " + status;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (org.apache.commons.lang.StringUtils.isNotBlank(doctor)) {
 | 
	
		
			
				|  |  |             sql += " AND op.doctor='" + doctor + "' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (!StringUtils.isEmpty(title)) {
 | 
	
		
			
				|  |  |             title = "%" + title + "%";
 | 
	
		
			
				|  |  |             sql += " and (op.patient_name like '" + title + "' OR op.doctor_name like '" + title + "' OR op.dept_name like '" + title + "' )";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (!StringUtils.isEmpty(start_time)) {
 | 
	
		
			
				|  |  |             if ("xm_ykyy_wx".equals(wxId)) {
 | 
	
		
			
				|  |  |                 if (flag) {
 | 
	
		
			
				|  |  |                     sql += " and op.create_time >= str_to_date('" + start_time + "','YYYY-MM-DD HH24:MI:SS')";
 | 
	
		
			
				|  |  |                 } else {
 | 
	
		
			
				|  |  |                     sql += " and op.create_time >= to_date('" + start_time + "','YYYY-MM-DD HH24:MI:SS')";
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 sql += " and op.create_time >= '" + start_time + "'";
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (!StringUtils.isEmpty(end_time)) {
 | 
	
		
			
				|  |  |             if ("xm_ykyy_wx".equals(wxId)) {
 | 
	
		
			
				|  |  |                 if (flag) {
 | 
	
		
			
				|  |  |                     sql += " and op.create_time <= str_to_date('" + end_time + "','YYYY-MM-DD HH24:MI:SS')";
 | 
	
		
			
				|  |  |                 } else {
 | 
	
		
			
				|  |  |                     sql += " and op.create_time <= to_date('" + end_time + "','YYYY-MM-DD HH24:MI:SS')";
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 sql += " and op.create_time <= '" + end_time + "'";
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //咨询类型
 | 
	
		
			
				|  |  |         if (!StringUtils.isEmpty(type)) {
 | 
	
		
			
				|  |  |             if (type.equalsIgnoreCase("9")) {
 | 
	
		
			
				|  |  |                 sql += " AND op.type =1 and op.outpatient_type = 1";
 | 
	
		
			
				|  |  |             } else if (type.equalsIgnoreCase("16")) {
 | 
	
		
			
				|  |  |                 sql += " AND op.type =2 and op.outpatient_type = 1";
 | 
	
		
			
				|  |  |             } else if (type.equalsIgnoreCase("1")) {
 | 
	
		
			
				|  |  |                 sql += " AND op.type =1 and op.outpatient_type = 3";
 | 
	
		
			
				|  |  |             } else if (type.equalsIgnoreCase("15")) {
 | 
	
		
			
				|  |  |                 sql += " AND op.type =3 and op.outpatient_type = 3";
 | 
	
		
			
				|  |  |             } else if (type.equalsIgnoreCase("17")) {
 | 
	
		
			
				|  |  |                 sql += " AND op.type =2 and op.outpatient_type = 3";
 | 
	
		
			
				|  |  |             } else if (type.equalsIgnoreCase("12")) {
 | 
	
		
			
				|  |  |                 sql += " AND op.outpatient_type = 2";
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 sql += " AND op.type in (1,2,3) ";
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (!StringUtils.isEmpty(id)) {
 | 
	
		
			
				|  |  |             sql += " and a.id = '" + id + "'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         sql += " ORDER BY op.create_time desc ";
 | 
	
		
			
				|  |  |         List<Map<String, Object>> mapList = hibenateUtils.createSQLQuery(sql);
 | 
	
		
			
				|  |  |         Long count = 0L;
 | 
	
		
			
				|  |  |         if (mapList != null && mapList.size() > 0) {
 | 
	
		
			
				|  |  |             count = Long.parseLong(mapList.get(0).get("total").toString());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return count;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public MixEnvelop recordByDoctor() { //String doctor, String id,String type, Integer status,String title, String start_time, String end_time, String patient
 | 
	
		
			
				|  |  |         String sql = "";
 | 
	
		
			
				|  |  |         /*sql = "SELECT " +
 | 
	
		
			
				|  |  |                 "a.id AS \"id\"," +
 | 
	
		
			
				|  |  |                 "op.pay_status AS \"payStatus\"," +
 | 
	
		
			
				|  |  |                 "op.type as \"type\"," +
 | 
	
	
		
			
				|  | @ -4347,7 +4429,7 @@ public class ImService {
 | 
	
		
			
				|  |  |             sql += " and a.id = '" + id + "'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         sql += " ORDER BY op.create_time desc ";
 | 
	
		
			
				|  |  |         List<Map<String, Object>> mapList = hibenateUtils.createSQLQuery(sql);
 | 
	
		
			
				|  |  |         List<Map<String, Object>> mapList = hibenateUtils.createSQLQuery(sql, page, pagesize);
 | 
	
		
			
				|  |  |         for (Map<String, Object> map : mapList) {
 | 
	
		
			
				|  |  |             if (map.get("patientIdcard") != null) {
 | 
	
		
			
				|  |  |                 String idcard = map.get("patientIdcard").toString();
 | 
	
	
		
			
				|  | @ -4419,126 +4501,34 @@ public class ImService {
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return mapList;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 查询患者所有的咨询记录总数
 | 
	
		
			
				|  |  |      * * @param doctor 患者标识
 | 
	
		
			
				|  |  |      * * @param id 会话ID(等同IM表topicId)
 | 
	
		
			
				|  |  |      * * @param type 咨询会话类型
 | 
	
		
			
				|  |  |      * * @param status 咨询状态:0全部,1候诊中,2就诊中,3结束
 | 
	
		
			
				|  |  |      * * @param title 标题关键字
 | 
	
		
			
				|  |  |      * * @param start_time 开始时间
 | 
	
		
			
				|  |  |      * * @param end_time 结束时间
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public Long countConsultRecordByDoctor2(String doctor, String id, String type, Integer status, String title, String start_time, String end_time) {
 | 
	
		
			
				|  |  |         String sql = "";
 | 
	
		
			
				|  |  |         sql = "SELECT " +
 | 
	
		
			
				|  |  |                 " COUNT(1) AS \"total\" " +
 | 
	
		
			
				|  |  |                 "FROM wlyy_outpatient op LEFT JOIN wlyy_consult a  ON a.relation_code = op.id \n" +
 | 
	
		
			
				|  |  |                 " LEFT join wlyy_consult_team b on a.id = b.consult" +
 | 
	
		
			
				|  |  |                 " LEFT JOIN base_patient d on op.patient = d.id " +
 | 
	
		
			
				|  |  |                 " WHERE 1=1 ";
 | 
	
		
			
				|  |  |         if (status == 1) {
 | 
	
		
			
				|  |  |             sql += " and op.status = 0";
 | 
	
		
			
				|  |  |         } else if (status == 0) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         } else if (status == 2) {
 | 
	
		
			
				|  |  |             sql += " and op.status = 1";
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             sql += " and op.status = " + status;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (org.apache.commons.lang.StringUtils.isNotBlank(doctor)) {
 | 
	
		
			
				|  |  |             sql += " AND op.doctor='" + doctor + "' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (!StringUtils.isEmpty(title)) {
 | 
	
		
			
				|  |  |             title = "%" + title + "%";
 | 
	
		
			
				|  |  |             sql += " and (op.patient_name like '" + title + "' OR op.doctor_name like '" + title + "' OR op.dept_name like '" + title + "' )";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (!StringUtils.isEmpty(start_time)) {
 | 
	
		
			
				|  |  |             if ("xm_ykyy_wx".equals(wxId)) {
 | 
	
		
			
				|  |  |                 if (flag) {
 | 
	
		
			
				|  |  |                     sql += " and op.create_time >= str_to_date('" + start_time + "','YYYY-MM-DD HH24:MI:SS')";
 | 
	
		
			
				|  |  |                 } else {
 | 
	
		
			
				|  |  |                     sql += " and op.create_time >= to_date('" + start_time + "','YYYY-MM-DD HH24:MI:SS')";
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 sql += " and op.create_time >= '" + start_time + "'";
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (!StringUtils.isEmpty(end_time)) {
 | 
	
		
			
				|  |  |             if ("xm_ykyy_wx".equals(wxId)) {
 | 
	
		
			
				|  |  |                 if (flag) {
 | 
	
		
			
				|  |  |                     sql += " and op.create_time <= str_to_date('" + end_time + "','YYYY-MM-DD HH24:MI:SS')";
 | 
	
		
			
				|  |  |                 } else {
 | 
	
		
			
				|  |  |                     sql += " and op.create_time <= to_date('" + end_time + "','YYYY-MM-DD HH24:MI:SS')";
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 sql += " and op.create_time <= '" + end_time + "'";
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //咨询类型
 | 
	
		
			
				|  |  |         if (!StringUtils.isEmpty(type)) {
 | 
	
		
			
				|  |  |             if (type.equalsIgnoreCase("9")) {
 | 
	
		
			
				|  |  |                 sql += " AND op.type =1 and op.outpatient_type = 1";
 | 
	
		
			
				|  |  |             } else if (type.equalsIgnoreCase("16")) {
 | 
	
		
			
				|  |  |                 sql += " AND op.type =2 and op.outpatient_type = 1";
 | 
	
		
			
				|  |  |             } else if (type.equalsIgnoreCase("1")) {
 | 
	
		
			
				|  |  |                 sql += " AND op.type =1 and op.outpatient_type = 3";
 | 
	
		
			
				|  |  |             } else if (type.equalsIgnoreCase("15")) {
 | 
	
		
			
				|  |  |                 sql += " AND op.type =3 and op.outpatient_type = 3";
 | 
	
		
			
				|  |  |             } else if (type.equalsIgnoreCase("17")) {
 | 
	
		
			
				|  |  |                 sql += " AND op.type =2 and op.outpatient_type = 3";
 | 
	
		
			
				|  |  |             } else if (type.equalsIgnoreCase("12")) {
 | 
	
		
			
				|  |  |                 sql += " AND op.outpatient_type = 2";
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 sql += " AND op.type in (1,2,3) ";
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (!StringUtils.isEmpty(id)) {
 | 
	
		
			
				|  |  |             sql += " and a.id = '" + id + "'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         sql += " ORDER BY op.create_time desc ";
 | 
	
		
			
				|  |  |         List<Map<String, Object>> mapList = hibenateUtils.createSQLQuery(sql);
 | 
	
		
			
				|  |  |         Long count = 0L;
 | 
	
		
			
				|  |  |         if (mapList != null && mapList.size() > 0) {
 | 
	
		
			
				|  |  |             count = Long.parseLong(mapList.get(0).get("total").toString());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return count;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public MixEnvelop recordByDoctor() {
 | 
	
		
			
				|  |  |         String sql = "";
 | 
	
		
			
				|  |  |         return mapList;*/
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         sql = "select \n" +
 | 
	
		
			
				|  |  |                 "IFNULL(a.patient_name,'null') AS pname,\n" +
 | 
	
		
			
				|  |  |                 "IFNULL(a.doctor_name,'null') as dname,\n" +
 | 
	
		
			
				|  |  |                 "IFNULL(a.dept_name,'null') as dept,\n" +
 | 
	
		
			
				|  |  |                 "IFNULL(a.outpatient_type,'null') as type,\n" +
 | 
	
		
			
				|  |  |                 "IFNULL(a.create_time,'null') as ctime,\n" +
 | 
	
		
			
				|  |  |                 "IFNULL(a.register_date,'null') as rtime,\n" +
 | 
	
		
			
				|  |  |                 "IFNULL(a.end_time,'null') as etime,\n" +
 | 
	
		
			
				|  |  |                 "IFNULL(a.description,'null') as des,\n" +
 | 
	
		
			
				|  |  |                 "IFNULL(a.patient_name,' ') AS pname,\n" +
 | 
	
		
			
				|  |  |                 "IFNULL(a.doctor_name,' ') as dname,\n" +
 | 
	
		
			
				|  |  |                 "IFNULL(a.dept_name,' ') as dept,\n" +
 | 
	
		
			
				|  |  |                 "CASE a.outpatient_type\n" +
 | 
	
		
			
				|  |  |                 "when 1 then '在线复诊'\n" +
 | 
	
		
			
				|  |  |                 "when 2 then '协同门诊'\n" +
 | 
	
		
			
				|  |  |                 "when 3 then '专家咨询'\n" +
 | 
	
		
			
				|  |  |                 "else ' ' end type,\n" +
 | 
	
		
			
				|  |  |                 "IFNULL(a.create_time,' ') as ctime,\n" +
 | 
	
		
			
				|  |  |                 "IFNULL(a.con_date,' ') as rtime,\n" +
 | 
	
		
			
				|  |  |                 "IFNULL(a.end_time,' ') as etime,\n" +
 | 
	
		
			
				|  |  |                 "IFNULL(a.description,' ') as des,\n" +
 | 
	
		
			
				|  |  |                 "IF(b.status >= 20 ,\"是\",\"否\") AS pay,\n" +
 | 
	
		
			
				|  |  |                 "IFNULL(a.status,'null') as sta\n" +
 | 
	
		
			
				|  |  |                 "CASE a.status \n" +
 | 
	
		
			
				|  |  |                 "WHEN '0' THEN '全部'\n" +
 | 
	
		
			
				|  |  |                 "WHEN '1' THEN '候诊中'\n" +
 | 
	
		
			
				|  |  |                 "WHEN '2' THEN '就诊中'\n" +
 | 
	
		
			
				|  |  |                 "when '3' then '结束'\n" +
 | 
	
		
			
				|  |  |                 "ELSE '取消' end status\n" +
 | 
	
		
			
				|  |  |                 "from \n" +
 | 
	
		
			
				|  |  |                 "wlyy_outpatient a \n" +
 | 
	
		
			
				|  |  |                 "LEFT JOIN \n" +
 | 
	
		
			
				|  |  |                 "wlyy_prescription b \n" +
 | 
	
		
			
				|  |  |                 "on a.patient_name = b.patient_name \n" +
 | 
	
		
			
				|  |  |                 "where 1=1";
 | 
	
		
			
				|  |  |                 "where 1=1;";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         List<Map<String, Object>> mapList = hibenateUtils.createSQLQuery(sql);
 |