|  | @ -5,6 +5,8 @@ import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.serializer.SimplePropertyPreFilter;
 | 
	
		
			
				|  |  | import com.fasterxml.jackson.databind.ObjectMapper;
 | 
	
		
			
				|  |  | import com.yihu.jw.base.dao.doctor.BaseDoctorDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.base.service.dict.DictDoctorDutyService;
 | 
	
		
			
				|  |  | import com.yihu.jw.base.service.dict.DictHospitalDeptService;
 | 
	
		
			
				|  |  | import com.yihu.jw.base.service.org.OrgTree;
 | 
	
		
			
				|  |  | import com.yihu.jw.base.service.org.OrgTreeService;
 | 
	
		
			
				|  |  | import com.yihu.jw.base.service.org.tree.SimpleTree;
 | 
	
	
		
			
				|  | @ -12,8 +14,11 @@ import com.yihu.jw.base.service.org.tree.SimpleTreeNode;
 | 
	
		
			
				|  |  | import com.yihu.jw.base.service.org.tree.TreeNode;
 | 
	
		
			
				|  |  | import com.yihu.jw.base.util.ConstantUtils;
 | 
	
		
			
				|  |  | import com.yihu.jw.base.util.JavaBeanUtils;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.dict.DictDoctorDutyDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.org.BaseOrgDO;
 | 
	
		
			
				|  |  | import com.yihu.mysql.query.BaseJpaService;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | import org.springframework.jdbc.core.JdbcTemplate;
 | 
	
	
		
			
				|  | @ -24,8 +29,8 @@ import org.springframework.util.CollectionUtils;
 | 
	
		
			
				|  |  | import org.springframework.util.StringUtils;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import java.io.IOException;
 | 
	
		
			
				|  |  | import java.text.ParseException;
 | 
	
		
			
				|  |  | import java.util.*;
 | 
	
		
			
				|  |  | import java.util.regex.Pattern;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | /**
 | 
	
		
			
				|  |  |  * 
 | 
	
	
		
			
				|  | @ -57,37 +62,52 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private ObjectMapper objectMapper;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private OrgTreeService orgTreeService;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private DictDoctorDutyService dictDoctorDutyService;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private DictHospitalDeptService dictHospitalDeptService;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取医生信息
 | 
	
		
			
				|  |  |      * @param orgId 医生所属机构id
 | 
	
		
			
				|  |  |      * @param doctorId 医生id
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public Map<String,Object> getOneDoctorInfo(String orgId, String doctorId) throws Exception{
 | 
	
		
			
				|  |  |         Map<String,Object> resultMap = new HashMap<>();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if(StringUtils.isEmpty(orgId) || StringUtils.isEmpty(doctorId)){
 | 
	
		
			
				|  |  |             return resultMap;
 | 
	
		
			
				|  |  |     public JSONObject getOneDoctorInfo(String doctorId) throws Exception{
 | 
	
		
			
				|  |  |         JSONObject result = new JSONObject();
 | 
	
		
			
				|  |  |         if(StringUtils.isEmpty(doctorId)){
 | 
	
		
			
				|  |  |             result.put("msg","parameter doctorId is null ");
 | 
	
		
			
				|  |  |             result.put("response",ConstantUtils.FAIL);
 | 
	
		
			
				|  |  |             return result;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //医生基本信息
 | 
	
		
			
				|  |  |         List<BaseDoctorDO> doctors = this.findByField("id",doctorId);
 | 
	
		
			
				|  |  |         if(CollectionUtils.isEmpty(doctors)){
 | 
	
		
			
				|  |  |             return resultMap;
 | 
	
		
			
				|  |  |             result.put("msg","doctor not exist for id:" + doctorId);
 | 
	
		
			
				|  |  |             result.put("response",ConstantUtils.FAIL);
 | 
	
		
			
				|  |  |             return result;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         resultMap = JavaBeanUtils.getInstance().bean2Map(doctors.get(0));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //医生执业信息
 | 
	
		
			
				|  |  |         String[] paramNames = {"hospCode","doctorCode"};
 | 
	
		
			
				|  |  |         Object[] paramValue = {orgId,doctorId};
 | 
	
		
			
				|  |  |         List<BaseDoctorHospitalDO> baseDoctorHospitalDOS = baseDoctorHospitalService.findByFields(paramNames,paramValue);
 | 
	
		
			
				|  |  |         if(CollectionUtils.isEmpty(baseDoctorHospitalDOS)){
 | 
	
		
			
				|  |  |             return resultMap;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //医生归属业务模块角色信息
 | 
	
		
			
				|  |  |         String[] paramNames = {"doctorCode","del"};
 | 
	
		
			
				|  |  |         Object[] paramValue = {doctorId,"1"};
 | 
	
		
			
				|  |  |         List<BaseDoctorRoleDO> roleList = baseDoctorRoleService.findByFields(paramNames,paramValue);
 | 
	
		
			
				|  |  |         if(CollectionUtils.isEmpty(roleList)){
 | 
	
		
			
				|  |  |             result.put("msg","doctor role not exist for id:" + doctorId);
 | 
	
		
			
				|  |  |             result.put("response",ConstantUtils.FAIL);
 | 
	
		
			
				|  |  |             return result;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         Map<String,Object> doctorHospMap = JavaBeanUtils.getInstance().bean2Map(baseDoctorHospitalDOS.get(0));
 | 
	
		
			
				|  |  |         resultMap.putAll(doctorHospMap);
 | 
	
		
			
				|  |  |         return resultMap;
 | 
	
		
			
				|  |  |         JSONObject jsonObject = new JSONObject();
 | 
	
		
			
				|  |  |         jsonObject.put("doctor",doctors.get(0));
 | 
	
		
			
				|  |  |         jsonObject.put("role",roleList);
 | 
	
		
			
				|  |  |         result.put("response",ConstantUtils.SUCCESS);
 | 
	
		
			
				|  |  |         result.put("msg",jsonObject);
 | 
	
		
			
				|  |  |         return result;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
	
		
			
				|  | @ -111,6 +131,7 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
 | 
	
		
			
				|  |  |                 "  tb.sex as sex,  " +
 | 
	
		
			
				|  |  |                 "  tb.mobile as mobile,  " +
 | 
	
		
			
				|  |  |                 "  GROUP_CONCAT(tb.org SEPARATOR ',') as orgInfo,  " +
 | 
	
		
			
				|  |  |                 "  tb.job_title_name as jobTitleName,  " +
 | 
	
		
			
				|  |  |                 "  tb.status as status " +
 | 
	
		
			
				|  |  |                 "from  " +
 | 
	
		
			
				|  |  |                 "  (  " +
 | 
	
	
		
			
				|  | @ -120,7 +141,8 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
 | 
	
		
			
				|  |  |                 "     doc.idcard,  " +
 | 
	
		
			
				|  |  |                 "     case doc.sex when 1 then '男' when 2 then '女' else '未知' end as sex,  " +
 | 
	
		
			
				|  |  |                 "     doc.mobile,  " +
 | 
	
		
			
				|  |  |                 "     concat(hos.hosp_name,'/',dept.name,'/',hos.doctor_duty_name,'/',hos.job_title_name) as org,  " +
 | 
	
		
			
				|  |  |                 "     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,  " +
 | 
	
		
			
				|  |  |                 "      doc.create_time  " +
 | 
	
		
			
				|  |  |                 "   from  " +
 | 
	
	
		
			
				|  | @ -130,11 +152,13 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
 | 
	
		
			
				|  |  |                 "  where  " +
 | 
	
		
			
				|  |  |                 "    doc.id = hos.doctor_code  " +
 | 
	
		
			
				|  |  |                 "    and  " +
 | 
	
		
			
				|  |  |                 "    hos.org_code = dept.org_code " +
 | 
	
		
			
				|  |  |                 "    and " +
 | 
	
		
			
				|  |  |                 "    hos.dept_code = dept.code  " +
 | 
	
		
			
				|  |  |                 "    and  " +
 | 
	
		
			
				|  |  |                 "    ((doc.idcard like '{idcard}' or ''= '{idcard}'  ) and (hos.hosp_code = '{orgCode}' or ''= '{orgCode}') and (doc.del = '{docStatus}' or ''= '{docStatus}'))  " +
 | 
	
		
			
				|  |  |                 "      or  " +
 | 
	
		
			
				|  |  |                 "    ((doc.name like '{name}'  or ''= '{name}' )  and (hos.hosp_code = '{orgCode}' or ''= '{orgCode}') and (doc.del = '{docStatus}' or ''= '{docStatus}'))  " +
 | 
	
		
			
				|  |  |                 "    ((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}'))  " +
 | 
	
		
			
				|  |  |                 "  ) tb  " +
 | 
	
		
			
				|  |  |                 "GROUP BY tb.id order by tb.create_time desc limit {start},{end} ";
 | 
	
		
			
				|  |  |         String finalSql = sql
 | 
	
	
		
			
				|  | @ -154,11 +178,13 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
 | 
	
		
			
				|  |  |                 "  where " +
 | 
	
		
			
				|  |  |                 "    doc.id = hos.doctor_code " +
 | 
	
		
			
				|  |  |                 "    and " +
 | 
	
		
			
				|  |  |                 "    hos.org_code = dept.org_code " +
 | 
	
		
			
				|  |  |                 "    and " +
 | 
	
		
			
				|  |  |                 "    hos.dept_code = dept.code " +
 | 
	
		
			
				|  |  |                 "    and " +
 | 
	
		
			
				|  |  |                 "    ((doc.idcard like '{idcard}' or ''= '{idcard}' ) and (hos.hosp_code = '{orgCode}' or ''= '{orgCode}') and (doc.del = '{docStatus}' or ''= '{docStatus}')) " +
 | 
	
		
			
				|  |  |                 "      or " +
 | 
	
		
			
				|  |  |                 "    ((doc.name like '{name}' or ''= '{name}')  and (hos.hosp_code = '{orgCode}' or ''= '{orgCode}') and (doc.del = '{docStatus}' or ''= '{docStatus}')) ";
 | 
	
		
			
				|  |  |                 "    ((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}')) ";
 | 
	
		
			
				|  |  |         String finalCountSql = countSql
 | 
	
		
			
				|  |  |                 .replace("{idcard}",nameOrIdcardValue)
 | 
	
		
			
				|  |  |                 .replace("{name}",nameOrIdcardValue)
 | 
	
	
		
			
				|  | @ -212,6 +238,7 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
 | 
	
		
			
				|  |  |             for(Object object : role){
 | 
	
		
			
				|  |  |                 baseDoctorRoleDO = objectMapper.readValue(object.toString(),BaseDoctorRoleDO.class);
 | 
	
		
			
				|  |  |                 baseDoctorRoleDO.setDoctorCode(baseDoctorDO.getId());
 | 
	
		
			
				|  |  |                 baseDoctorDO.setDel("1");
 | 
	
		
			
				|  |  |                 baseDoctorRoleDOList.add(baseDoctorRoleDO);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         } catch (IOException e) {
 | 
	
	
		
			
				|  | @ -258,8 +285,8 @@ 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)){
 | 
	
		
			
				|  |  |             result.put("msg","parameter doctor or hospital of jsonData is null");
 | 
	
		
			
				|  |  |         if(null == doctor || CollectionUtils.isEmpty(role)){
 | 
	
		
			
				|  |  |             result.put("msg","parameter role of jsonData is null");
 | 
	
		
			
				|  |  |             result.put("response", ConstantUtils.FAIL);
 | 
	
		
			
				|  |  |             return result.toJSONString();
 | 
	
		
			
				|  |  |         }
 | 
	
	
		
			
				|  | @ -298,23 +325,26 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         baseDoctorHospitalService.delete(roleIdList.toArray());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         // 修改医生任职机构及职业信息
 | 
	
		
			
				|  |  |         BaseDoctorHospitalDO baseDoctorHospitalDO = null;
 | 
	
		
			
				|  |  |         Set<Object> hospitalIdList = baseDoctorHospitalService.findDocHospIdList(baseDoctorDO.getId());
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             for(Object object : hospital){
 | 
	
		
			
				|  |  |                 baseDoctorHospitalDO = objectMapper.readValue(object.toString(),BaseDoctorHospitalDO.class);
 | 
	
		
			
				|  |  |                 if(hospitalIdList.contains(baseDoctorHospitalDO.getId())){
 | 
	
		
			
				|  |  |                     hospitalIdList.remove(baseDoctorHospitalDO.getId());
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 baseDoctorHospitalDO.setDoctorCode(baseDoctorDO.getId());
 | 
	
		
			
				|  |  |                 baseDoctorHospitalService.save(baseDoctorHospitalDO);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         } catch (IOException e) {
 | 
	
		
			
				|  |  |             result.put("msg","convert hospital jsonObject to baseDoctorHospitalDO failed," + e.getCause());
 | 
	
		
			
				|  |  |             result.put("response",ConstantUtils.FAIL);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         baseDoctorHospitalService.delete(hospitalIdList.toArray());
 | 
	
		
			
				|  |  |         // 修改医生任职机构及职业信息,前端不修改就不做任何操作
 | 
	
		
			
				|  |  |          if(!CollectionUtils.isEmpty(hospital)){
 | 
	
		
			
				|  |  |              BaseDoctorHospitalDO baseDoctorHospitalDO = null;
 | 
	
		
			
				|  |  |              Set<Object> hospitalIdList = baseDoctorHospitalService.findDocHospIdList(baseDoctorDO.getId());
 | 
	
		
			
				|  |  |              try {
 | 
	
		
			
				|  |  |                  for(Object object : hospital){
 | 
	
		
			
				|  |  |                      baseDoctorHospitalDO = objectMapper.readValue(object.toString(),BaseDoctorHospitalDO.class);
 | 
	
		
			
				|  |  |                      if(hospitalIdList.contains(baseDoctorHospitalDO.getId())){
 | 
	
		
			
				|  |  |                          hospitalIdList.remove(baseDoctorHospitalDO.getId());
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                      baseDoctorHospitalDO.setDoctorCode(baseDoctorDO.getId());
 | 
	
		
			
				|  |  |                      baseDoctorHospitalService.save(baseDoctorHospitalDO);
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              } catch (IOException e) {
 | 
	
		
			
				|  |  |                  result.put("msg","convert hospital jsonObject to baseDoctorHospitalDO failed," + e.getCause());
 | 
	
		
			
				|  |  |                  result.put("response",ConstantUtils.FAIL);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              baseDoctorHospitalService.delete(hospitalIdList.toArray());
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         result.put("response",ConstantUtils.SUCCESS);
 | 
	
		
			
				|  |  |         result.put("msg",baseDoctorDO);
 | 
	
		
			
				|  |  |         return result.toJSONString();
 | 
	
	
		
			
				|  | @ -346,30 +376,79 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取医生已选中的机构/职务树形结构
 | 
	
		
			
				|  |  |      * 获取医生已选中的区县/机构列表,当有机构是被选中时,要标有checked=true的状态前端加载生成树形机构,
 | 
	
		
			
				|  |  |      * @param doctorCode
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public JSONObject getOrgListByTownAndDoctorCode(String doctorCode,String townCode) throws Exception {
 | 
	
		
			
				|  |  |         JSONObject result = new JSONObject();
 | 
	
		
			
				|  |  |         if(StringUtils.isEmpty(townCode)){
 | 
	
		
			
				|  |  |             result.put("msg","townCode is not allowed to be null");
 | 
	
		
			
				|  |  |             result.put("response", ConstantUtils.FAIL);
 | 
	
		
			
				|  |  |             return result;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         List<Map<String, Object>> list = new ArrayList<>();
 | 
	
		
			
				|  |  |         list  = orgTreeService.findOrgListByParentCode(townCode);
 | 
	
		
			
				|  |  |         if(StringUtils.isEmpty(doctorCode)){
 | 
	
		
			
				|  |  |             result.put("response", ConstantUtils.SUCCESS);
 | 
	
		
			
				|  |  |             result.put("msg",list);
 | 
	
		
			
				|  |  |             return result;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         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);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         result.put("response", ConstantUtils.SUCCESS);
 | 
	
		
			
				|  |  |         result.put("msg",JavaBeanUtils.getInstance().mapListJson(orgCodeMap.values()));
 | 
	
		
			
				|  |  |         return result;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取医生已选中的机构/职务树形结构,当有机构是被选中时,要标有checked=true的状态
 | 
	
		
			
				|  |  |      * @param doctorCode
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String getDoctorDutyTree(String doctorCode){
 | 
	
		
			
				|  |  |     public JSONObject getDoctorDutyTree(String doctorCode) throws Exception {
 | 
	
		
			
				|  |  |         JSONObject result = new JSONObject();
 | 
	
		
			
				|  |  |         if(StringUtils.isEmpty(doctorCode)){
 | 
	
		
			
				|  |  |             return "";
 | 
	
		
			
				|  |  |             result.put("msg","doctorCode is not allowed to be null");
 | 
	
		
			
				|  |  |             result.put("response", ConstantUtils.FAIL);
 | 
	
		
			
				|  |  |             return result;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         List<BaseDoctorHospitalDO> list = baseDoctorHospitalService.getOrgAndDutyListByDoctorCode(doctorCode);
 | 
	
		
			
				|  |  |         List<DictDoctorDutyDO> dutyDOList = dictDoctorDutyService.search(null);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         List<BaseDoctorHospitalDO> selectedDutylist = baseDoctorHospitalService.getOrgAndDutyListByDoctorCode(doctorCode);
 | 
	
		
			
				|  |  |         Set<Object> selectedDutySet = new HashSet<>();
 | 
	
		
			
				|  |  |         selectedDutylist.forEach( one -> selectedDutySet.add(one.getDoctorDutyCode()) );
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         List<OrgTree> orgTreeList = new ArrayList<>();
 | 
	
		
			
				|  |  |         for(BaseDoctorHospitalDO one : list){
 | 
	
		
			
				|  |  |         for(BaseDoctorHospitalDO one : selectedDutylist){
 | 
	
		
			
				|  |  |             OrgTree orgTreeParent = new OrgTree();
 | 
	
		
			
				|  |  |             orgTreeParent.setParentCode("");
 | 
	
		
			
				|  |  |             orgTreeParent.setCode(one.getHospCode());
 | 
	
		
			
				|  |  |             orgTreeParent.setName(one.getHospName());
 | 
	
		
			
				|  |  |             orgTreeParent.setCode(one.getOrgCode());
 | 
	
		
			
				|  |  |             orgTreeParent.setName(one.getOrgName());
 | 
	
		
			
				|  |  |             orgTreeList.add(orgTreeParent);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             OrgTree orgTreeChild = new OrgTree();
 | 
	
		
			
				|  |  |             orgTreeChild.setParentCode(one.getHospCode());
 | 
	
		
			
				|  |  |             orgTreeChild.setCode(one.getDoctorDutyCode());
 | 
	
		
			
				|  |  |             orgTreeChild.setName(one.getDoctorDutyName());
 | 
	
		
			
				|  |  |             orgTreeList.add(orgTreeChild);
 | 
	
		
			
				|  |  |             for(DictDoctorDutyDO dictDoctorDutyDO :dutyDOList){
 | 
	
		
			
				|  |  |                 OrgTree orgTreeChild = new OrgTree();
 | 
	
		
			
				|  |  |                 orgTreeChild.setParentCode(one.getOrgCode());
 | 
	
		
			
				|  |  |                 orgTreeChild.setCode(dictDoctorDutyDO.getCode());
 | 
	
		
			
				|  |  |                 orgTreeChild.setName(dictDoctorDutyDO.getName());
 | 
	
		
			
				|  |  |                 if(selectedDutySet.contains(dictDoctorDutyDO.getCode())){
 | 
	
		
			
				|  |  |                     orgTreeParent.setChecked(true);
 | 
	
		
			
				|  |  |                     orgTreeChild.setChecked(true);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 orgTreeList.add(orgTreeChild);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return getOrgTree(orgTreeList);
 | 
	
		
			
				|  |  |         result.put("response", ConstantUtils.SUCCESS);
 | 
	
		
			
				|  |  |         result.put("msg", objectMapper.readValue(makeTree(orgTreeList),JSONArray.class));
 | 
	
		
			
				|  |  |         return result;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
	
		
			
				|  | @ -377,50 +456,65 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
 | 
	
		
			
				|  |  |      * @param doctorCode
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String getDoctorDeptTree(String doctorCode){
 | 
	
		
			
				|  |  |     public JSONObject getDoctorDeptTree(String doctorCode) throws Exception {
 | 
	
		
			
				|  |  |         JSONObject result = new JSONObject();
 | 
	
		
			
				|  |  |         if(StringUtils.isEmpty(doctorCode)){
 | 
	
		
			
				|  |  |             return "";
 | 
	
		
			
				|  |  |             result.put("msg","doctorCode is not allowed to be null");
 | 
	
		
			
				|  |  |             result.put("response", ConstantUtils.FAIL);
 | 
	
		
			
				|  |  |             return result;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String sql = "select" +
 | 
	
		
			
				|  |  |         String deptSql = "select" +
 | 
	
		
			
				|  |  |                 "  hos.doctor_code ," +
 | 
	
		
			
				|  |  |                 "  hos.hosp_code as parentCode," +
 | 
	
		
			
				|  |  |                 "  org.name as parentName," +
 | 
	
		
			
				|  |  |                 "  hos.dept_code as childCode," +
 | 
	
		
			
				|  |  |                 "  dept.name as childName" +
 | 
	
		
			
				|  |  |                 "  hos.org_code as orgCode," +
 | 
	
		
			
				|  |  |                 "  org.name as orgName," +
 | 
	
		
			
				|  |  |                 "  dept.code as deptCode," +
 | 
	
		
			
				|  |  |                 "  dept.name as deptName" +
 | 
	
		
			
				|  |  |                 " from" +
 | 
	
		
			
				|  |  |                 "  base_doctor_hospital hos," +
 | 
	
		
			
				|  |  |                 "  base_org org," +
 | 
	
		
			
				|  |  |                 "  dict_hospital_dept dept" +
 | 
	
		
			
				|  |  |                 " where" +
 | 
	
		
			
				|  |  |                 "  hos.hosp_code = org.code" +
 | 
	
		
			
				|  |  |                 "  and" +
 | 
	
		
			
				|  |  |                 "  hos.hosp_code = dept.org_code" +
 | 
	
		
			
				|  |  |                 "  hos.org_code = org.code" +
 | 
	
		
			
				|  |  |                 "  and" +
 | 
	
		
			
				|  |  |                 "  hos.dept_code = dept.code" +
 | 
	
		
			
				|  |  |                 "  and doctor_code = '{doctorCode}'";
 | 
	
		
			
				|  |  |         List<Map<String,Object>> list = jdbcTemplate.queryForList(sql.replace("{doctorCode}",doctorCode));
 | 
	
		
			
				|  |  |                 "  hos.org_code = dept.org_code";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String doctorSelectedDeptSql = deptSql + " and  hos.dept_code = dept.code and hos.doctor_code = '{doctorCode}'";
 | 
	
		
			
				|  |  |         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 : list){
 | 
	
		
			
				|  |  |         for(Map<String,Object> one : selectedDeptlist){
 | 
	
		
			
				|  |  |             OrgTree orgTreeParent = new OrgTree();
 | 
	
		
			
				|  |  |             orgTreeParent.setParentCode("");
 | 
	
		
			
				|  |  |             orgTreeParent.setCode(String.valueOf(one.get("parentCode")));
 | 
	
		
			
				|  |  |             orgTreeParent.setName(String.valueOf(one.get("parentName")));
 | 
	
		
			
				|  |  |             orgTreeParent.setCode(String.valueOf(one.get("orgCode")));
 | 
	
		
			
				|  |  |             orgTreeParent.setName(String.valueOf(one.get("orgName")));
 | 
	
		
			
				|  |  |             orgTreeList.add(orgTreeParent);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             OrgTree orgTreeChild = new OrgTree();
 | 
	
		
			
				|  |  |             orgTreeChild.setParentCode(String.valueOf(one.get("parentCode")));
 | 
	
		
			
				|  |  |             orgTreeChild.setCode(String.valueOf(one.get("childCode")));
 | 
	
		
			
				|  |  |             orgTreeChild.setName(String.valueOf(one.get("childName")));
 | 
	
		
			
				|  |  |             orgTreeList.add(orgTreeChild);
 | 
	
		
			
				|  |  |             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);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return getOrgTree(orgTreeList);
 | 
	
		
			
				|  |  |         result.put("response", ConstantUtils.SUCCESS);
 | 
	
		
			
				|  |  |         result.put("msg",objectMapper.readValue(makeTree(orgTreeList),JSONArray.class));
 | 
	
		
			
				|  |  |         return result;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 构建树形结构
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String getOrgTree(List<OrgTree> orgTreeList ){
 | 
	
		
			
				|  |  |     public String makeTree(List<OrgTree> orgTreeList ){
 | 
	
		
			
				|  |  |         List<TreeNode> treeNodes = new ArrayList<>();
 | 
	
		
			
				|  |  |         treeNodes.addAll(orgTreeList);
 | 
	
		
			
				|  |  |         SimpleTree tree = new SimpleTree(treeNodes);
 | 
	
	
		
			
				|  | @ -428,7 +522,6 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
 | 
	
		
			
				|  |  |         SimplePropertyPreFilter filter = new SimplePropertyPreFilter();
 | 
	
		
			
				|  |  |         filter.getExcludes().add("parent");
 | 
	
		
			
				|  |  |         filter.getExcludes().add("allChildren");
 | 
	
		
			
				|  |  |         filter.getExcludes().add("parentNodeId");
 | 
	
		
			
				|  |  |         filter.getExcludes().add("orderNum");
 | 
	
		
			
				|  |  |         filter.getExcludes().add("level");
 | 
	
		
			
				|  |  |         return JSONObject.toJSONString(treeNode, filter);
 |