|  | @ -6,6 +6,7 @@ import com.yihu.wlyy.entity.address.City;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.entity.address.Province;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.entity.address.Town;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.entity.consult.Consult;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.entity.consult.ConsultTeam;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.entity.consult.ConsultTeamDoctor;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.entity.doctor.profile.Doctor;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.entity.doctor.team.sign.DoctorPatientGroup;
 | 
	
	
		
			
				|  | @ -13,11 +14,13 @@ import com.yihu.wlyy.entity.doctor.team.sign.DoctorPatientGroupInfo;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeam;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeamMember;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.entity.patient.Patient;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.entity.patient.SignFamily;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.entity.patient.WlyyPatientSick;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.repository.address.CityDao;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.repository.address.ProvinceDao;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.repository.address.TownDao;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.repository.consult.ConsultDao;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.repository.consult.ConsultTeamDao;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.repository.consult.ConsultTeamDoctorDao;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.repository.doctor.DoctorDao;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.repository.doctor.DoctorPatientGroupInfoDao;
 | 
	
	
		
			
				|  | @ -81,6 +84,8 @@ public class DoctorInfoService extends BaseService {
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private SignFamilyDao signFamilyDao;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     private ConsultTeamDao consultTeamDao;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取医生的签约病人
 | 
	
		
			
				|  |  |      *
 | 
	
	
		
			
				|  | @ -604,7 +609,7 @@ public class DoctorInfoService extends BaseService {
 | 
	
		
			
				|  |  |         return doctorDao.findAll(spec, pageRequest);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public Page<Doctor> findFamousDoctor(String key, int page, int pageSize) {
 | 
	
		
			
				|  |  |     public Page<Doctor> findFamousDoctor(String key,Integer type, int page, int pageSize) {
 | 
	
		
			
				|  |  |         if (pageSize <= 0) {
 | 
	
		
			
				|  |  |             pageSize = 10;
 | 
	
		
			
				|  |  |         }
 | 
	
	
		
			
				|  | @ -618,11 +623,73 @@ public class DoctorInfoService extends BaseService {
 | 
	
		
			
				|  |  |         // 查询全部
 | 
	
		
			
				|  |  |         Map<String, SearchFilter> filters = new HashMap<String, SearchFilter>();
 | 
	
		
			
				|  |  |         if (StringUtils.isNotEmpty(key)) {
 | 
	
		
			
				|  |  |             filters.put("name", new SearchFilter("name", SearchFilter.Operator.LIKE, key));
 | 
	
		
			
				|  |  |                 filters.put("name", new SearchFilter("name", SearchFilter.Operator.LIKE, key));
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         filters.put("isFamous", new SearchFilter("isFamous", SearchFilter.Operator.EQ, 1));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         filters.put("isFamous", new SearchFilter("isFamous", SearchFilter.Operator.EQ, type));
 | 
	
		
			
				|  |  |         filters.put("level", new SearchFilter("level", SearchFilter.Operator.EQ, 1));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Specification<Doctor> spec = DynamicSpecifications.bySearchFilter(filters.values(), Doctor.class);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return doctorDao.findAll(spec, pageRequest);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public void updateTeamHealthDoctor(String newDoctorCode, String oldDoctorCode, String patient)throws Exception {
 | 
	
		
			
				|  |  |         ConsultTeam consultTeam= consultTeamDao.findByParientCodeAndSignTypeAndDoctor(patient,oldDoctorCode,"2");
 | 
	
		
			
				|  |  |         if(consultTeam!=null){
 | 
	
		
			
				|  |  |             throw new Exception("存在没有关闭的健康咨询");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         Patient patientObj=patientDao.findByCode(patient);
 | 
	
		
			
				|  |  |         Doctor newD=doctorDao.findByCode(newDoctorCode);
 | 
	
		
			
				|  |  |         //得到患者的签约信息
 | 
	
		
			
				|  |  |         SignFamily signFamily= signFamilyDao.findByPatient(patient);
 | 
	
		
			
				|  |  |         //修改签约中的健康管理师
 | 
	
		
			
				|  |  |         signFamily.setDoctorHealth(newD.getCode());
 | 
	
		
			
				|  |  |         signFamily.setDoctorHealthName(newD.getName());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //修改医生服务团队 删除旧的健康管理师
 | 
	
		
			
				|  |  |         DoctorTeamMember doctorTeamMember=  doctorTeamDoctor.findMemberByTeamAndCode(signFamily.getTeamCode(),oldDoctorCode);
 | 
	
		
			
				|  |  |         doctorTeamMember.setDel("0");
 | 
	
		
			
				|  |  |         //添加新的健康管理师到服务团队里
 | 
	
		
			
				|  |  |         DoctorTeamMember  newDoctorTeamMember=new DoctorTeamMember();
 | 
	
		
			
				|  |  |         newDoctorTeamMember.setTeam(signFamily.getTeamCode());
 | 
	
		
			
				|  |  |         newDoctorTeamMember.setCzrq(new Date());
 | 
	
		
			
				|  |  |         newDoctorTeamMember.setName(newD.getName());
 | 
	
		
			
				|  |  |         newDoctorTeamMember.setMemberCode(newD.getCode());
 | 
	
		
			
				|  |  |         newDoctorTeamMember.setType(3);
 | 
	
		
			
				|  |  |         newDoctorTeamMember.setSignType("2");
 | 
	
		
			
				|  |  |         newDoctorTeamMember.setDel("1");
 | 
	
		
			
				|  |  |         newDoctorTeamMember.setCode(UUID.randomUUID().toString().replace("-",""));
 | 
	
		
			
				|  |  |         doctorTeamDoctor.save(newDoctorTeamMember);
 | 
	
		
			
				|  |  |         String groupCode="";
 | 
	
		
			
				|  |  |         //把患者移除旧的健康管理师的患者表
 | 
	
		
			
				|  |  |         List<DoctorPatientGroupInfo>  oldDoctorPatientGroupInfos=doctorPatientGroupInfoDao.findByPatientAndDoctor(patient,oldDoctorCode);
 | 
	
		
			
				|  |  |         for(DoctorPatientGroupInfo doctorPatientGroupInfo:oldDoctorPatientGroupInfos){
 | 
	
		
			
				|  |  |             doctorPatientGroupInfo.setCzrq(new Date());
 | 
	
		
			
				|  |  |             doctorPatientGroupInfo.setStatus(0);//设置为无效
 | 
	
		
			
				|  |  |             //保存原来旧的分组
 | 
	
		
			
				|  |  |             if(Integer.valueOf(doctorPatientGroupInfo.getGroup())<4){
 | 
	
		
			
				|  |  |                 groupCode=doctorPatientGroupInfo.getGroup()+"";
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //把患者加到新的健康管理师的患者表
 | 
	
		
			
				|  |  |         DoctorPatientGroupInfo doctorPatientGroupInfo = new DoctorPatientGroupInfo();
 | 
	
		
			
				|  |  |         doctorPatientGroupInfo.setCzrq(new Date());
 | 
	
		
			
				|  |  |         doctorPatientGroupInfo.setDoctor(newDoctorCode);
 | 
	
		
			
				|  |  |         doctorPatientGroupInfo.setStatus(1);
 | 
	
		
			
				|  |  |         doctorPatientGroupInfo.setPatient(patientObj.getCode());
 | 
	
		
			
				|  |  |         doctorPatientGroupInfo.setPname(patientObj.getName());
 | 
	
		
			
				|  |  |         doctorPatientGroupInfo.setPartAmount(0);
 | 
	
		
			
				|  |  |         doctorPatientGroupInfo.setGroup(groupCode);//默认健康分组
 | 
	
		
			
				|  |  |         doctorPatientGroupInfo.setQyrq(new Date());
 | 
	
		
			
				|  |  |         doctorPatientGroupInfo.setSignType("2");//家庭签约
 | 
	
		
			
				|  |  |         doctorPatientGroupInfoDao.save(doctorPatientGroupInfo);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public void updateTeamHealthDoctors(String newDoctorCode, String oldDoctorCode, String patients)throws Exception {
 | 
	
		
			
				|  |  |         String [] patiensString=patients.split(",");
 | 
	
		
			
				|  |  |         for (int i=0;i<patiensString.length;i++){
 | 
	
		
			
				|  |  |             updateTeamHealthDoctor(newDoctorCode,oldDoctorCode,patiensString[i]);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | }
 |