| 
					
				 | 
			
			
				@ -14,7 +14,11 @@ import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.jdbc.core.JdbcTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import javax.persistence.criteria.CriteriaBuilder; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.ArrayList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.Comparator; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 * Created by Bing on 2021/4/10. 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -51,28 +55,42 @@ public class DoctorMessageService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer count; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (typeNull||type.equals("10")){//床位申请-未完成 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject tmpJson = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Map<String,Object>> listTmp = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            count=0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (BaseDoctorHospitalDO obj:hospitalDO){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String sql ="select count(*) from base_patient_bed_apply where org_code='"+obj.getOrgCode()+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "and status <> -1 and status<>0"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Integer sqlCount = jdbcTemplate.queryForObject(sql,Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String sql ="select count(*) count,patient_name,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') create_time from base_patient_bed_apply where org_code='"+obj.getOrgCode()+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "and status <> -1 and status<>0 order by create_time asc"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Map<String,Object> sqlResult  = jdbcTemplate.queryForMap(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Integer sqlCount =Integer.parseInt(sqlResult.get("count").toString()) ; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                count +=sqlCount; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                listTmp.add(sqlResult); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            listTmp.sort(Comparator.comparing(obj ->  obj.get("create_time").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            tmpJson.put("count",count); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            tmpJson.put("message",listTmp.get(0).get("patient_name").toString()+"居民申请床位"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            tmpJson.put("time",listTmp.get(0).get("create_time").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put("bedApply",tmpJson); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (typeNull||type.equals("11")){//安全监护 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject tmpJson = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            count=0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Map<String,Object>> listTmp = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (BaseDoctorHospitalDO obj:hospitalDO){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String sql ="select count(*) from base_security_monitoring_order where hospital='"+obj.getOrgCode()+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "and status <>-1 and status<> 7"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Integer sqlCount = jdbcTemplate.queryForObject(sql,Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String sql ="select count(*) count,patient_name,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') create_time,serve_desc from base_security_monitoring_order where hospital='"+obj.getOrgCode()+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "and status <>-1 and status<> 7 order by create_time asc"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Map<String,Object> sqlResult  = jdbcTemplate.queryForMap(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Integer sqlCount =Integer.parseInt(sqlResult.get("count").toString()) ; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                count +=sqlCount; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                listTmp.add(sqlResult); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            listTmp.sort(Comparator.comparing(obj ->  obj.get("create_time").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            tmpJson.put("count",count); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            tmpJson.put("message",listTmp.get(0).get("patient_name").toString()+"居民"+listTmp.get(0).get("serve_desc").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            tmpJson.put("time",listTmp.get(0).get("create_time")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put("security",tmpJson); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 |