| 
					
				 | 
			
			
				@ -15,6 +15,7 @@ import com.yihu.jw.restmodel.web.PageEnvelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.util.common.IdCardUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.utils.StringUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.mysql.query.BaseJpaService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.lang.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.slf4j.Logger; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.slf4j.LoggerFactory; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -134,39 +135,61 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Map<String,Object> getOrgDoctor(String doctorId,String orgType){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<BaseOrgDO> orgList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String,Object> orgListMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String,Object> result = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (orgType.equals("3")){//养老机构 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            orgList = orgDao.findByDoctorAndType(doctorId,"3"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<Map<String,Object>> getOrgList(String doctorId,String orgType){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> result = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql ="SELECT org.code org_code,org.`name`,org.type from base_org org  where  org.del=1 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (orgType.equals("3")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql= " SELECT org.code org_code,org.`name`,org.type from base_org org,base_doctor_hospital dh  where dh.org_code = org.code " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "and  org.del=1 and dh.del=1 and doctor_code='"+doctorId+"' and org.type=3 GROUP BY org.`code` "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (orgType.equals("1,2")){//医疗机构 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            orgList = orgDao.findByTypeIn(new String[]{"1","2"}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        else if (orgType.equals("1,2")){//医疗机构 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           sql+=" and org.type in(1,2) "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (orgType.equals("4")){//托育机构 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            orgList = orgDao.findByDoctorAndType(doctorId,"4"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql+=" and org.type='"+orgType+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> doctorList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (orgList.size()==0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql+=" ORDER BY org.`code` asc"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> tmpList = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (Map<String,Object>tmp:tmpList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql ="select dict.code deptCode,dict.name deptName " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "from base_org org LEFT JOIN dict_hospital_dept dict on org.code = dict.org_code  where org.del=1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "and org.code ='"+tmp.get("org_code").toString()+"' ORDER BY dict.`code` asc "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Map<String,Object>> deptList = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            tmp.put("deptList",deptList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (BaseOrgDO org:orgList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String sql = "select dh.org_code,dh.org_name,doc.id,doc.name,doc.mobile,doc.photo,dict.code deptCode,dict.name deptName,dh.doctor_duty_code job,dh.doctor_duty_name jobName\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "from base_doctor_hospital dh,dict_hospital_dept dict,base_doctor doc where  dh.doctor_code = doc.id  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "and dh.dept_code = dict.`code` and dh.org_code = dict.org_code and dh.del=1 and dh.org_code='"+org.getCode()+"' GROUP BY doc.id" ; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Map<String,Object>> tmpList = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Map<String,List<Map<String,Object>>> docTmp = tmpList.stream().collect(Collectors.groupingBy(e->e.get("deptCode").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				          Map<String,String> deptList = tmpList.stream().collect(Collectors.toMap(s->s.get("deptCode").toString(),s->s.get("deptName").toString(),(oldVal, currVal) -> currVal)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Map<String,Object> tmpMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            tmpMap.put("orgCode",org.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            tmpMap.put("orgName",org.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            tmpMap.put("deptList",deptList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            orgListMap.put(org.getCode(),tmpMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            doctorList.addAll(tmpList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("orgList",orgListMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        System.out.println(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return tmpList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONObject getOrgDoctor(String orgCode,String deptCode,int page,int size){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject result = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String count = "select count(Distinct doc.id)\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "from base_doctor_hospital dh,dict_hospital_dept dict,base_doctor doc where  dh.doctor_code = doc.id  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "and dh.dept_code = dict.`code` and dh.org_code = dict.org_code and dh.del=1 and dh.org_code='"+orgCode+"' " ; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(deptCode)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            count+=" and dict.code='"+deptCode+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "select dh.org_code,dh.org_name,doc.id,doc.name,doc.mobile,doc.photo,dict.code deptCode,dict.name deptName,dh.doctor_duty_code job,dh.doctor_duty_name jobName\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "from base_doctor_hospital dh,dict_hospital_dept dict,base_doctor doc where  dh.doctor_code = doc.id  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "and dh.dept_code = dict.`code` and dh.org_code = dict.org_code and dh.del=1 and dh.org_code='"+orgCode+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(deptCode)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql+=" and dict.code='"+deptCode+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql+=" GROUP BY doc.id limit "+(page-1)*size+","+size; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> tmpList = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer total = jdbcTemplate.queryForObject(count,Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("total",total); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        int totalPage = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (total%size==0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            totalPage = total/size; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            totalPage = total/size+1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("totalPage",totalPage); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("doctorList",tmpList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 |