|  | @ -1,6 +1,7 @@
 | 
	
		
			
				|  |  | package com.yihu.jw.care.service.doctor;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  | import com.sun.xml.internal.rngom.parse.host.Base;
 | 
	
		
			
				|  |  | import com.yihu.jw.care.service.role.RoleService;
 | 
	
		
			
				|  |  | import com.yihu.jw.doctor.dao.BaseDoctorDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
 | 
	
	
		
			
				|  | @ -131,10 +132,40 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     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` ";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         BaseDoctorDO doctorDO = baseDoctorDao.findById(doctorId);
 | 
	
		
			
				|  |  |         if (doctorDO==null){
 | 
	
		
			
				|  |  |             return new ArrayList<>();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //教师角色登录时为本机构科室列表,点击展开人员列表
 | 
	
		
			
				|  |  |         //助老员角色登录时为本机构科室列表,点击展开人员列表
 | 
	
		
			
				|  |  |         Integer doctorLevel = doctorDO.getLevel();
 | 
	
		
			
				|  |  |         Integer doctorOrgType =0 ;
 | 
	
		
			
				|  |  |         boolean isSearchDoctorOrgType=false;
 | 
	
		
			
				|  |  |         if (3==doctorLevel){//教师
 | 
	
		
			
				|  |  |             doctorOrgType=4;
 | 
	
		
			
				|  |  |             if ("4".equals(orgType)){
 | 
	
		
			
				|  |  |                 isSearchDoctorOrgType=true;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (2==doctorLevel) {//助老员
 | 
	
		
			
				|  |  |             doctorOrgType=3;
 | 
	
		
			
				|  |  |             if ("3".equals(orgType)){
 | 
	
		
			
				|  |  |                 isSearchDoctorOrgType=true;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String sql ="select org.code from base_doctor_hospital dh inner join base_org org on dh.org_code = org.code " +
 | 
	
		
			
				|  |  |                 "and dh.doctor_code='"+doctorId+"' and org.type='"+doctorOrgType+"' ORDER BY dh.create_time desc limit 1";
 | 
	
		
			
				|  |  |         List<String> doctorOrg = jdbcTemplate.queryForList(sql,String.class);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         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 where  " +
 | 
	
		
			
				|  |  |                     "  org.del=1  and org.type=3 " ;
 | 
	
		
			
				|  |  |             if (isSearchDoctorOrgType&&doctorOrg.size()>0){
 | 
	
		
			
				|  |  |                 sql += " and org.code = '"+doctorOrg.get(0)+"' ";
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             sql += " GROUP BY org.`code` ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         else if (orgType.equals("1,2")){//医疗机构
 | 
	
		
			
				|  |  |            sql+=" and org.type in(1,2) ";
 | 
	
	
		
			
				|  | @ -142,6 +173,7 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
 | 
	
		
			
				|  |  |         else {
 | 
	
		
			
				|  |  |             sql+=" and org.type='"+orgType+"' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         sql+=" ORDER BY org.`code` asc";
 | 
	
		
			
				|  |  |         List<Map<String,Object>> tmpList = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -158,14 +190,16 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
 | 
	
		
			
				|  |  |     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+"' " ;
 | 
	
		
			
				|  |  |                 " from base_doctor_hospital dh INNER JOIN base_doctor doc on dh.doctor_code = doc.id  " +
 | 
	
		
			
				|  |  |                 " and dh.del=1 LEFT JOIN " +
 | 
	
		
			
				|  |  |                 " dict_hospital_dept dict on dh.dept_code = dict.`code` and dh.org_code = dict.org_code where 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+"' ";
 | 
	
		
			
				|  |  |                 " from base_doctor_hospital dh INNER JOIN base_doctor doc on dh.doctor_code = doc.id  " +
 | 
	
		
			
				|  |  |                 " and dh.del=1 LEFT JOIN " +
 | 
	
		
			
				|  |  |                 " dict_hospital_dept dict on dh.dept_code = dict.`code` and dh.org_code = dict.org_code where dh.org_code='"+orgCode+"' ";
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(deptCode)){
 | 
	
		
			
				|  |  |             sql+=" and dict.code='"+deptCode+"' ";
 | 
	
		
			
				|  |  |         }
 |