| 
					
				 | 
			
			
				@ -106,8 +106,8 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //医生基本信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<BaseDoctorDO> doctors = this.findByField("id",doctorId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(CollectionUtils.isEmpty(doctors)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BaseDoctorDO doctors = baseDoctorDao.findOne(doctorId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(null == doctors){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put("msg","doctor not exist for id:" + doctorId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put("response",ConstantUtils.FAIL); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return result; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -123,7 +123,7 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject jsonObject = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        jsonObject.put("doctor",doctors.get(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        jsonObject.put("doctor",doctors); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        jsonObject.put("role",roleList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("response",ConstantUtils.SUCCESS); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("msg",jsonObject); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -141,7 +141,7 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject result = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String orgCodeVale = null == orgCode ? "" : orgCode; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String del = null == docStatus ? "" : docStatus; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String nameOrIdcardValue = null == nameOrIdcard ? "" : nameOrIdcard; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String nameOrIdcardValue = null == nameOrIdcard ? "" : "%" + nameOrIdcard + "%"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        int start = 0 == page ? page++ : (page - 1) * size; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        int end = 0 == size ? 15 : page * size; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "select" + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -163,7 +163,7 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "     doc.mobile,  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "     concat(hos.org_name,'/',dept.name,'/',hos.doctor_duty_name) as org,  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "     doc.job_title_name,  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "     case doc.del when 0 then '无效' when 1 then '有效' end as status,  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "     case doc.del when 0 then '已失效' when 1 then '生效中' end as status,  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "      doc.create_time  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "   from  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "     base_doctor doc,  " + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -176,9 +176,7 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    and " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    hos.dept_code = dept.code  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    and  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    ((doc.idcard like '{idcard}' or ''= '{idcard}'  ) and (hos.org_code = '{orgCode}' or ''= '{orgCode}') and (doc.del = '{docStatus}' or ''= '{docStatus}'))  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "      and  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    ((doc.name like '{name}'  or ''= '{name}' )  and (hos.org_code = '{orgCode}' or ''= '{orgCode}') and (doc.del = '{docStatus}' or ''= '{docStatus}'))  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    ((doc.idcard like '{idcard}' or ''= '{idcard}' ) or (doc.name like '{name}'  or ''= '{name}' )  and (hos.org_code = '{orgCode}' or ''= '{orgCode}') and (doc.del = '{docStatus}' or ''= '{docStatus}'))  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  ) tb  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "GROUP BY tb.id order by tb.create_time desc limit {start},{end} "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String finalSql = sql 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -202,9 +200,7 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    and " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    hos.dept_code = dept.code " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    and " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    ((doc.idcard like '{idcard}' or ''= '{idcard}' ) and (hos.org_code = '{orgCode}' or ''= '{orgCode}') and (doc.del = '{docStatus}' or ''= '{docStatus}')) " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "      and " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    ((doc.name like '{name}' or ''= '{name}')  and (hos.org_code = '{orgCode}' or ''= '{orgCode}') and (doc.del = '{docStatus}' or ''= '{docStatus}')) "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    ((doc.idcard like '{idcard}' or ''= '{idcard}' ) or (doc.name like '{name}' or ''= '{name}') and (hos.org_code = '{orgCode}' or ''= '{orgCode}') and (doc.del = '{docStatus}' or ''= '{docStatus}')) " ; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String finalCountSql = countSql 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                .replace("{idcard}",nameOrIdcardValue) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                .replace("{name}",nameOrIdcardValue) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -234,7 +230,7 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject doctor = jsonObject.getJSONObject("doctor"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray role = jsonObject.getJSONArray("role"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray hospital = jsonObject.getJSONArray("hospital"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(null == doctor || CollectionUtils.isEmpty(role) || CollectionUtils.isEmpty(hospital)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(null == doctor || CollectionUtils.isEmpty(hospital)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put("msg","parameter doctor or hospital of jsonData is null"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put("response", ConstantUtils.FAIL); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return result.toJSONString(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -251,14 +247,14 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        baseDoctorDO.setPassword(baseDoctorDO.getIdcard().substring(11,17)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        this.save(baseDoctorDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //组装医生角色关联关系 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //组装医生角色关联关系,医生默认可以没有角色 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(!CollectionUtils.isEmpty(role)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BaseDoctorRoleDO baseDoctorRoleDO = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<BaseDoctorRoleDO> baseDoctorRoleDOList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for(Object object : role){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                baseDoctorRoleDO = objectMapper.readValue(object.toString(),BaseDoctorRoleDO.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                baseDoctorRoleDO.setDoctorCode(baseDoctorDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                baseDoctorDO.setDel("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                baseDoctorRoleDOList.add(baseDoctorRoleDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } catch (IOException e) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -267,6 +263,7 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return result.toJSONString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        baseDoctorRoleService.batchInsert(baseDoctorRoleDOList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        // 组装医生任职机构及职业信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BaseDoctorHospitalDO baseDoctorHospitalDO = null; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -305,7 +302,7 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject doctor = jsonObject.getJSONObject("doctor"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray role = jsonObject.getJSONArray("role"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray hospital = jsonObject.getJSONArray("hospital"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(null == doctor || CollectionUtils.isEmpty(role)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(null == doctor){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put("msg","parameter role of jsonData is null"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put("response", ConstantUtils.FAIL); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return result.toJSONString(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -318,8 +315,11 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        // 修改医生信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BaseDoctorDO baseDoctorDO = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            baseDoctorDO = objectMapper.readValue(doctor.toJSONString(),BaseDoctorDO.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            BaseDoctorDO oldDoctor = baseDoctorDao.findOne(baseDoctorDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            baseDoctorDO.setPassword(oldDoctor.getPassword()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } catch (IOException e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put("msg","convert doctor jsonObject to BaseDoctorDO failed," + e.getCause()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put("response",ConstantUtils.FAIL); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -327,23 +327,28 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        this.save(baseDoctorDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //修改医生角色关联关系 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BaseDoctorRoleDO baseDoctorRoleDO = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Set<Object> roleIdList = baseDoctorRoleService.findRoleIdList(baseDoctorDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for(Object object : hospital){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                baseDoctorRoleDO = objectMapper.readValue(object.toString(),BaseDoctorRoleDO.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if(roleIdList.contains(baseDoctorRoleDO.getId())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    roleIdList.remove(baseDoctorRoleDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //修改医生角色关联关系,医生默认可以没有角色 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(!CollectionUtils.isEmpty(role)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            BaseDoctorRoleDO baseDoctorRoleDO = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Set<Object> roleIdList = baseDoctorRoleService.findRoleIdList(baseDoctorDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for(Object object : role){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    baseDoctorRoleDO = objectMapper.readValue(object.toString(),BaseDoctorRoleDO.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if(roleIdList.contains(baseDoctorRoleDO.getId())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        roleIdList.remove(baseDoctorRoleDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    baseDoctorRoleDO.setDoctorCode(baseDoctorDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    baseDoctorRoleService.save(baseDoctorRoleDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                baseDoctorRoleDO.setDoctorCode(baseDoctorDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                baseDoctorRoleService.save(baseDoctorRoleDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } catch (IOException e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                result.put("msg","convert hospital jsonObject to baseDoctorHospitalDO failed," + e.getCause()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                result.put("response",ConstantUtils.FAIL); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(roleIdList.size() > 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                baseDoctorRoleService.delete(roleIdList.toArray()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } catch (IOException e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put("msg","convert hospital jsonObject to baseDoctorHospitalDO failed," + e.getCause()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put("response",ConstantUtils.FAIL); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        baseDoctorHospitalService.delete(roleIdList.toArray()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        // 修改医生任职机构及职业信息,前端不修改就不做任何操作 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if(!CollectionUtils.isEmpty(hospital)){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -362,7 +367,9 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 result.put("msg","convert hospital jsonObject to baseDoctorHospitalDO failed," + e.getCause()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 result.put("response",ConstantUtils.FAIL); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             baseDoctorHospitalService.delete(hospitalIdList.toArray()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if(hospitalIdList.size() > 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 baseDoctorHospitalService.delete(hospitalIdList.toArray()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("response",ConstantUtils.SUCCESS); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -396,7 +403,7 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 获取医生已选中的区县/机构列表,当有机构是被选中时,要标有checked=true的状态前端加载生成树形机构, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 获取医生已选中的区县/机构列表,当有机构是被选中时,要标有checked=true的状态,由前端加载生成树形机构, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param doctorCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -416,10 +423,10 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String,Map<String, Object>> orgCodeMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        list.forEach( one-> orgCodeMap.put(String.valueOf(one.get("code")),one)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<BaseDoctorHospitalDO> selectedList = baseDoctorHospitalService.getOrgAndDutyListByDoctorCode(doctorCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for(BaseDoctorHospitalDO one : selectedList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(orgCodeMap.containsKey(one.getOrgCode())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                orgCodeMap.get(one.getOrgCode()).put("checked",true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> selectedList = baseDoctorHospitalService.getOrgAndDutyListByDoctorCode(doctorCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for(Map<String,Object> one : selectedList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(orgCodeMap.containsKey(one.get("orgCode"))){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                orgCodeMap.get(one.get("orgCode")).put("checked",true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("response", ConstantUtils.SUCCESS); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -429,7 +436,7 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 获取医生已选中的机构/职务树形结构,当有机构是被选中时,要标有checked=true的状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 获取医生已选中的机构/职务树形结构,当有机构是被选中时,要标有checked=true的状态,生成树形结构,前端直接获取 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param doctorCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -440,26 +447,26 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put("response", ConstantUtils.FAIL); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<DictDoctorDutyDO> dutyDOList = dictDoctorDutyService.search(null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<DictDoctorDutyDO> dutyDOList = dictDoctorDutyService.search(null,"-name"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<BaseDoctorHospitalDO> selectedDutylist = baseDoctorHospitalService.getOrgAndDutyListByDoctorCode(doctorCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Set<Object> selectedDutySet = new HashSet<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        selectedDutylist.forEach( one -> selectedDutySet.add(one.getDoctorDutyCode()) ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> selectedDutylist = baseDoctorHospitalService.getOrgAndDutyListByDoctorCode(doctorCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Set<String> selectedDutySet = new HashSet<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        selectedDutylist.forEach( one -> selectedDutySet.add(String.valueOf(one.get("orgCode"))+one.get("doctorDutyCode"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<OrgTree> orgTreeList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for(BaseDoctorHospitalDO one : selectedDutylist){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for(Map<String,Object> one : selectedDutylist){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            OrgTree orgTreeParent = new OrgTree(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            orgTreeParent.setParentCode(""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            orgTreeParent.setCode(one.getOrgCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            orgTreeParent.setName(one.getOrgName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            orgTreeParent.setCode(String.valueOf(one.get("orgCode"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            orgTreeParent.setName(String.valueOf(one.get("orgName"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            orgTreeList.add(orgTreeParent); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for(DictDoctorDutyDO dictDoctorDutyDO :dutyDOList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                OrgTree orgTreeChild = new OrgTree(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                orgTreeChild.setParentCode(one.getOrgCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                orgTreeChild.setParentCode(String.valueOf(one.get("orgCode"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                orgTreeChild.setCode(dictDoctorDutyDO.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                orgTreeChild.setName(dictDoctorDutyDO.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if(selectedDutySet.contains(dictDoctorDutyDO.getCode())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if(selectedDutySet.contains(String.valueOf(one.get("orgCode"))+dictDoctorDutyDO.getCode())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    orgTreeParent.setChecked(true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    orgTreeChild.setChecked(true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -467,12 +474,13 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("response", ConstantUtils.SUCCESS); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("msg", objectMapper.readValue(makeTree(orgTreeList),JSONArray.class)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        // 不同医院职务可以相同 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("msg", objectMapper.readValue(makeTree(orgTreeList,true),JSONArray.class)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 获取医生已选中的机构/科室树形结构 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 获取医生已选中的机构/科室树形结构,当有机构是被选中时,要标有checked=true的状态,生成树形结构,前端直接获取 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param doctorCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -483,7 +491,28 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put("response", ConstantUtils.FAIL); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String deptSql = "select" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //医生已选中的机构的里的科室列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String orgDeptSql = "SELECT" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  org.code AS orgCode," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  org.name     AS orgName," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  dept.code    AS deptCode," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  dept.name    AS deptName" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  base_org org," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  dict_hospital_dept dept" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  dept.org_code = org.code" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  AND" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  dept.org_code" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  in (" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    SELECT DISTINCT hos.org_code from" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "      base_doctor_hospital hos where hos.doctor_code = '" + doctorCode + "'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  ) ORDER BY dept.name"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> deptList = jdbcTemplate.queryForList(orgDeptSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //医生已选中的机构的里的所在科室 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String doctorSelectedDeptSql = "select" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  hos.doctor_code ," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  hos.org_code as orgCode," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  org.name as orgName," + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -496,37 +525,39 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " where" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  hos.org_code = org.code" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  and" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  hos.org_code = dept.org_code"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String doctorSelectedDeptSql = deptSql + " and  hos.dept_code = dept.code and hos.doctor_code = '{doctorCode}'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  hos.org_code = dept.org_code" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " and  hos.dept_code = dept.code and hos.doctor_code = '" + doctorCode + "' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  ORDER BY dept.name"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> selectedDeptlist = jdbcTemplate.queryForList(doctorSelectedDeptSql.replace("{doctorCode}",doctorCode)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> deptList = jdbcTemplate.queryForList(deptSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Set<String> selectedDeptCodeSet = new HashSet<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        selectedDeptlist.forEach( one -> selectedDeptCodeSet.add(String.valueOf(one.get("orgCode")) + String.valueOf(one.get("deptCode")))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<OrgTree> orgTreeList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for(Map<String,Object> one : selectedDeptlist){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        selectedDeptlist.forEach(one -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            selectedDeptCodeSet.add(String.valueOf(one.get("orgCode")) + String.valueOf(one.get("deptCode"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //机构树 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            OrgTree orgTreeParent = new OrgTree(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            orgTreeParent.setParentCode(""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            orgTreeParent.setCode(String.valueOf(one.get("orgCode"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            orgTreeParent.setName(String.valueOf(one.get("orgName"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            orgTreeList.add(orgTreeParent); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for(Map<String,Object> dept :deptList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                OrgTree orgTreeChild = new OrgTree(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                orgTreeChild.setParentCode(String.valueOf(dept.get("orgCode"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                orgTreeChild.setCode(String.valueOf(dept.get("deptCode"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                orgTreeChild.setName(String.valueOf(dept.get("deptName"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                orgTreeList.add(orgTreeChild); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if(selectedDeptCodeSet.contains(String.valueOf(dept.get("orgCode")) + dept.get("deptCode"))){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    orgTreeParent.setChecked(true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    orgTreeChild.setChecked(true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //本身就是加载已经选中了的机构,所以机构状态为true 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            orgTreeParent.setChecked(true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //科室树 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (Map<String, Object> dept : deptList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            OrgTree orgTreeChild = new OrgTree(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            orgTreeChild.setParentCode(String.valueOf(dept.get("orgCode"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            orgTreeChild.setCode(String.valueOf(dept.get("deptCode"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            orgTreeChild.setName(String.valueOf(dept.get("deptName"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            orgTreeList.add(orgTreeChild); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (selectedDeptCodeSet.contains(String.valueOf(dept.get("orgCode")) + dept.get("deptCode"))) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                orgTreeChild.setChecked(true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("response", ConstantUtils.SUCCESS); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("msg",objectMapper.readValue(makeTree(orgTreeList),JSONArray.class)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //不同医院科室可以相同 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("msg",objectMapper.readValue(makeTree(orgTreeList,true),JSONArray.class)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -534,10 +565,10 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 构建树形结构 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String makeTree(List<OrgTree> orgTreeList ){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String makeTree(List<OrgTree> orgTreeList,boolean isAllowedRepeat){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<TreeNode> treeNodes = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        treeNodes.addAll(orgTreeList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        SimpleTree tree = new SimpleTree(treeNodes); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        SimpleTree tree = new SimpleTree(treeNodes,isAllowedRepeat); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<SimpleTreeNode> treeNode = tree.getRoot(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        SimplePropertyPreFilter filter = new SimplePropertyPreFilter(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        filter.getExcludes().add("parent"); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -642,9 +673,9 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        dictJobTitleDO = jobTitleDao.findByCode(roleCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        baseDoctorRoleDO = new BaseDoctorRoleDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        baseDoctorRoleDO.setDoctorCode(baseDoctorDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        baseDoctorRoleDO.setRoleModuleCode(dictJobTitleDO.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        baseDoctorRoleDO.setName(dictJobTitleDO.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        baseDoctorRoleDO.setDel("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        baseDoctorRoleDO.setRoleModuleCode(dictJobTitleDO.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        baseDoctorRoleDO.setName(dictJobTitleDO.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        baseDoctorRoleDO.setDel("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        baseDoctorRoleDOList.add(baseDoctorRoleDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    baseDoctorRoleService.batchInsert(baseDoctorRoleDOList); 
			 |