|  | @ -1939,20 +1939,133 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         return result;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  |     
 | 
	
		
			
				|  |  |     public List<Map<String,Object>> findClinicRoomList(String dept) {
 | 
	
		
			
				|  |  |     public List<JSONObject> findClinicRoomList(String dept,String date) {
 | 
	
		
			
				|  |  |         if(StringUtils.isBlank(date)){
 | 
	
		
			
				|  |  |             date = DateUtil.getStringDateShort();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         
 | 
	
		
			
				|  |  |         String sql ="SELECT " +
 | 
	
		
			
				|  |  |                 "id," +
 | 
	
		
			
				|  |  |                 "doctor_name," +
 | 
	
		
			
				|  |  |                 "clinic_status AS visit_status," +
 | 
	
		
			
				|  |  |                 "patient_name AS patient_name," +
 | 
	
		
			
				|  |  |                 "waiting_count AS waiting_count," +
 | 
	
		
			
				|  |  |                 "room_name AS room_name " +
 | 
	
		
			
				|  |  |                 "FROM wlyy_doctor_clinic_room ";
 | 
	
		
			
				|  |  |         //获取今天的排班列表
 | 
	
		
			
				|  |  |         String doctorsql ="SELECT doctor,doctor_name FROM wlyy_doctor_work_time WHERE date='"+date+"' GROUP BY doctor";
 | 
	
		
			
				|  |  |     
 | 
	
		
			
				|  |  |         List<Map<String,Object>> doctorlist = jdbcTemplate.queryForList(doctorsql);
 | 
	
		
			
				|  |  |     
 | 
	
		
			
				|  |  |         HashMap<String ,JSONObject> result = new HashMap<>();
 | 
	
		
			
				|  |  |     
 | 
	
		
			
				|  |  |         for (int i = 0; i < doctorlist.size(); i++) {
 | 
	
		
			
				|  |  |             JSONObject jsonObject = new JSONObject();
 | 
	
		
			
				|  |  |             jsonObject.put("id",(String)doctorlist.get(0).get("doctor"));
 | 
	
		
			
				|  |  |     
 | 
	
		
			
				|  |  |             if(StringUtils.isNoneBlank((String)doctorlist.get(0).get("doctor_name"))){
 | 
	
		
			
				|  |  |                 jsonObject.put("doctor_name",(String)doctorlist.get(0).get("doctor_name"));
 | 
	
		
			
				|  |  |             }else{
 | 
	
		
			
				|  |  |                 jsonObject.put("doctor_name","");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             jsonObject.put("visit_status",0);
 | 
	
		
			
				|  |  |             jsonObject.put("waiting_count",0);
 | 
	
		
			
				|  |  |             jsonObject.put("patient_name","");
 | 
	
		
			
				|  |  |             jsonObject.put("time_cost",0);
 | 
	
		
			
				|  |  |             result.put((String)doctorlist.get(0).get("doctor"),jsonObject);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         
 | 
	
		
			
				|  |  |         List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         //获取预约了今天的候诊居民
 | 
	
		
			
				|  |  |         String waitingSql ="SELECT count(op.id) AS waitCount," +
 | 
	
		
			
				|  |  |                 "room.doctor AS doctor, " +
 | 
	
		
			
				|  |  |                 "room.doctor_name AS doctorName " +
 | 
	
		
			
				|  |  |                 "FROM wlyy_outpatient op,wlyy_hospital_waiting_room room " +
 | 
	
		
			
				|  |  |                 "WHERE op.`status`=0 AND room.outpatient_id=op.id AND room.consult_type=2 " +
 | 
	
		
			
				|  |  |                 "AND room.doctor IS NOT NULL " +
 | 
	
		
			
				|  |  |                 "AND room.reservation_time>='"+date+" 00:00:00' AND room.reservation_time<='"+date+" 23:59:59' GROUP BY room.doctor; ";
 | 
	
		
			
				|  |  |     
 | 
	
		
			
				|  |  |         List<Map<String,Object>> waitinglist = jdbcTemplate.queryForList(waitingSql);
 | 
	
		
			
				|  |  |         if(waitinglist!=null&&waitinglist.size()>0){
 | 
	
		
			
				|  |  |             //根据身份证计算年龄
 | 
	
		
			
				|  |  |             for(Map<String,Object> waitObj :waitinglist){
 | 
	
		
			
				|  |  |                 String doctor = (String) waitObj.get("doctor");
 | 
	
		
			
				|  |  |                 if(StringUtils.isNoneBlank(doctor)){
 | 
	
		
			
				|  |  |                     Long waitCount = (Long) waitObj.get("waitCount");
 | 
	
		
			
				|  |  |                     if(result.keySet().contains(doctor)){
 | 
	
		
			
				|  |  |                         result.get(doctor).put("waiting_count",waitCount);
 | 
	
		
			
				|  |  |                     }else{
 | 
	
		
			
				|  |  |                         JSONObject jsonObject = new JSONObject();
 | 
	
		
			
				|  |  |                         jsonObject.put("id",doctor);
 | 
	
		
			
				|  |  |                         jsonObject.put("visit_status",0);
 | 
	
		
			
				|  |  |                         jsonObject.put("waiting_count",waitCount);
 | 
	
		
			
				|  |  |                         if(StringUtils.isNoneBlank((String)waitObj.get("doctorName"))){
 | 
	
		
			
				|  |  |                             jsonObject.put("doctor_name",(String)waitObj.get("doctorName"));
 | 
	
		
			
				|  |  |                         }else{
 | 
	
		
			
				|  |  |                             jsonObject.put("doctor_name","");
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                         jsonObject.put("patient_name","");
 | 
	
		
			
				|  |  |                         jsonObject.put("time_cost",0);
 | 
	
		
			
				|  |  |                         result.put(doctor,jsonObject);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         
 | 
	
		
			
				|  |  |         return list;
 | 
	
		
			
				|  |  |         //获取进行中的居民
 | 
	
		
			
				|  |  |         String onlineSql ="SELECT " +
 | 
	
		
			
				|  |  |                 "room.outpatient_id AS id," +
 | 
	
		
			
				|  |  |                 "room.patient_id AS patient_id," +
 | 
	
		
			
				|  |  |                 "room.patient_name AS patient_name," +
 | 
	
		
			
				|  |  |                 "patient.sex AS sex," +
 | 
	
		
			
				|  |  |                 "patient.idcard AS idcard," +
 | 
	
		
			
				|  |  |                 "patient.photo AS photo," +
 | 
	
		
			
				|  |  |                 "patient.birthday AS birthday," +
 | 
	
		
			
				|  |  |                 "room.consult_type AS consult_type," +
 | 
	
		
			
				|  |  |                 "room.reservation_time AS time," +
 | 
	
		
			
				|  |  |                 "TIMESTAMPDIFF(MINUTE, room.reservation_time,NOW()) AS time_cost," +
 | 
	
		
			
				|  |  |                 "room.doctor AS doctor, " +
 | 
	
		
			
				|  |  |                 "room.doctor_name AS doctorName " +
 | 
	
		
			
				|  |  |                 "FROM " +
 | 
	
		
			
				|  |  |                 "wlyy_hospital_waiting_room room," +
 | 
	
		
			
				|  |  |                 "base_patient patient," +
 | 
	
		
			
				|  |  |                 "wlyy_outpatient outpatient," +
 | 
	
		
			
				|  |  |                 "wlyy_consult_team consult " +
 | 
	
		
			
				|  |  |                 "WHERE " +
 | 
	
		
			
				|  |  |                 "room.patient_id=patient.id " +
 | 
	
		
			
				|  |  |                 "AND room.outpatient_id=outpatient.id " +
 | 
	
		
			
				|  |  |                 "AND consult.relation_code=outpatient.id " +
 | 
	
		
			
				|  |  |                 "AND outpatient.STATUS=1 " +
 | 
	
		
			
				|  |  |                 "AND room.consult_type=2 " +
 | 
	
		
			
				|  |  |                 "AND room.reservation_time>='"+date+" 00:00:00' AND room.reservation_time<='"+date+" 23:59:59' " +
 | 
	
		
			
				|  |  |                 "GROUP BY room.doctor";
 | 
	
		
			
				|  |  |         List<Map<String,Object>> onlinelist = jdbcTemplate.queryForList(onlineSql);
 | 
	
		
			
				|  |  |         if(waitinglist!=null&&waitinglist.size()>0){
 | 
	
		
			
				|  |  |             //根据身份证计算年龄
 | 
	
		
			
				|  |  |             for(Map<String,Object> onlineObj :onlinelist){
 | 
	
		
			
				|  |  |                 String doctor = (String) onlineObj.get("doctor");
 | 
	
		
			
				|  |  |                 if(StringUtils.isNoneBlank(doctor)){
 | 
	
		
			
				|  |  |                     if(result.keySet().contains(doctor)){
 | 
	
		
			
				|  |  |                         result.get(doctor).put("visit_status",1);
 | 
	
		
			
				|  |  |                         result.get(doctor).put("patient_name",(String) onlineObj.get("patient_name"));
 | 
	
		
			
				|  |  |                         result.get(doctor).put("time_cost",(Long) onlineObj.get("time_cost"));
 | 
	
		
			
				|  |  |                     }else{
 | 
	
		
			
				|  |  |                         JSONObject jsonObject = new JSONObject();
 | 
	
		
			
				|  |  |                         jsonObject.put("id",doctor);
 | 
	
		
			
				|  |  |     
 | 
	
		
			
				|  |  |                         if(StringUtils.isNoneBlank((String) onlineObj.get("doctorName"))){
 | 
	
		
			
				|  |  |                             jsonObject.put("doctor_name",(String) onlineObj.get("doctorName"));
 | 
	
		
			
				|  |  |                         }else{
 | 
	
		
			
				|  |  |                             jsonObject.put("doctor_name","");
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                         jsonObject.put("visit_status",1);
 | 
	
		
			
				|  |  |                         jsonObject.put("waiting_count",0);
 | 
	
		
			
				|  |  |                         jsonObject.put("patient_name",(String) onlineObj.get("patient_name"));
 | 
	
		
			
				|  |  |                         jsonObject.put("time_cost",(Long) onlineObj.get("time_cost"));
 | 
	
		
			
				|  |  |                         result.put(doctor,jsonObject);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         
 | 
	
		
			
				|  |  |         List<JSONObject> finalresult  = new ArrayList<>();
 | 
	
		
			
				|  |  |     
 | 
	
		
			
				|  |  |         for (JSONObject jsonObject : result.values()) {
 | 
	
		
			
				|  |  |             finalresult.add(jsonObject);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         
 | 
	
		
			
				|  |  |         return finalresult;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  |     
 | 
	
		
			
				|  |  |     public WlyyDoctorClinicRoomDO findClinicRoomStatus(String id) {
 |