| 
					
				 | 
			
			
				@ -29,6 +29,7 @@ import com.yihu.wlyy.repository.patient.SignFamilyDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.repository.prescription.PrescriptionDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.BaseService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.app.sign.FamilyContractService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.app.talk.TalkGroupService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.common.SMSService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.third.httplog.LogService; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -41,6 +42,8 @@ import org.apache.http.NameValuePair; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.http.message.BasicNameValuePair; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.json.JSONArray; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.json.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.slf4j.Logger; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.slf4j.LoggerFactory; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Value; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.data.domain.Page; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -70,6 +73,7 @@ import java.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				@Component 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				public class DoctorInfoService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private static Logger logger = LoggerFactory.getLogger(DoctorInfoService.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private DoctorDao doctorDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -131,6 +135,9 @@ public class DoctorInfoService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private LogService logService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private FamilyContractService familyContractService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 获取医生的签约病人 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -851,6 +858,9 @@ public class DoctorInfoService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Doctor newD = doctorDao.findByCode(newDoctorCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String oldDoctorHealthName = signFamily.getDoctorHealthName(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //1.4.2更新重点关注列表,取消关注 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        familyContractService.updateTrackPatient(patient,signFamily.getDoctorHealth(),signFamily.getDoctor(),null,newDoctorCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //修改签约中的健康管理师 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        signFamily.setDoctorHealth(newD.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        signFamily.setDoctorHealthName(newD.getName()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1004,6 +1014,10 @@ public class DoctorInfoService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Doctor newD = doctorDao.findByCode(newDoctorCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //1.4.2更新重点关注列表,取消关注 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        familyContractService.updateTrackPatient(patient,signFamily.getDoctorHealth(),signFamily.getDoctor(),null,newDoctorCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //修改签约中的健康管理师 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        signFamily.setDoctorHealth(newD.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        signFamily.setDoctorHealthName(newD.getName()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1226,6 +1240,10 @@ public class DoctorInfoService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Doctor newD = doctorDao.findByCode(newDoctorCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String oldDoctorName = signFamily.getDoctorName(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //1.4.2更新重点关注列表,取消关注 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        familyContractService.updateTrackPatient(patient,signFamily.getDoctor(),signFamily.getDoctorHealth(),newDoctorCode,null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //修改签约中的全科医生 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        signFamily.setDoctor(newD.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        signFamily.setDoctorName(newD.getName()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1242,50 +1260,45 @@ public class DoctorInfoService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        newDoctorTeamMember.setCode(UUID.randomUUID().toString().replace("-", "")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        doctorTeamDoctor.save(newDoctorTeamMember); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Patient p = patientDao.findByCode(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject data = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("toUser", patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("represented",patient);//被代理人 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("doctor", newD.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("doctorName", newD.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("keyword3", "家庭医生-全科医生"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("keyword2", DateUtil.dateToStrNoSecond(new Date())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("keyword1", newD.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isEmpty(signFamily.getDoctorHealth()) || signFamily.getDoctor().equals(signFamily.getDoctorHealth())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            data.put("remark", newD.getName() + "医生将继续为您提供优质健康服务"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            data.put("remark", newD.getName() + "医生将继续为您提供优质健康服务"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Patient p = patientDao.findByCode(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject data = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            data.put("toUser", patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            data.put("represented",patient);//被代理人 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            data.put("doctor", newD.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            data.put("doctorName", newD.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            data.put("keyword3", "家庭医生-全科医生"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            data.put("keyword2", DateUtil.dateToStrNoSecond(new Date())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            data.put("keyword1", newD.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (StringUtils.isEmpty(signFamily.getDoctorHealth()) || signFamily.getDoctor().equals(signFamily.getDoctorHealth())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                data.put("remark", newD.getName() + "医生将继续为您提供优质健康服务"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                data.put("remark", newD.getName() + "医生将继续为您提供优质健康服务"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(p.getOpenid())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            data.put("first", p.getName() + ",您签约团队的全科医生已变更,您的新全科医生信息如下:"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            pushMsgTask.putWxMsg(accessTokenUtils.getAccessToken(), 10, p.getOpenid(), p.getName(), data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            //如果自己没有绑定,则发给家人 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            JSONObject json = weiXinOpenIdUtils.getFamilyOpenId(p.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            Patient member = (Patient) json.get("member"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            if (StringUtils.isNotBlank(member.getOpenid())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                data.put("first", weiXinOpenIdUtils.getTitleMes(p, (int) json.get("relation"), member.getName()) + p.getName() + ",您好!因签约团队内分工调整,您的责任医生有变动," + oldDoctorName + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        "医生无法继续为您服务,具体变动如下:"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                pushMsgTask.putWxMsg(accessTokenUtils.getAccessToken(), 10, member.getOpenid(), member.getName(), data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (StringUtils.isNotBlank(p.getOpenid())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                data.put("first", p.getName() + ",您签约团队的全科医生已变更,您的新全科医生信息如下:"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                pushMsgTask.putWxMsg(accessTokenUtils.getAccessToken(), 10, p.getOpenid(), p.getName(), data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //发送代理人 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray jsonArray = weiXinOpenIdUtils.getAgentOpenId(p.getCode(),p.getOpenid()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(jsonArray!=null&&jsonArray.length()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (int i = 0;i<jsonArray.length();i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                JSONObject j  = jsonArray.getJSONObject(i); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Patient member = (Patient) j.get("member"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                JSONObject json = data; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                json.remove("toUser"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                json.put("toUser",member.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                json.remove("first"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                json.put("first", weiXinOpenIdUtils.getTitleMes(p, (int) json.get("relation"), p.getName()) + p.getName() + ",您好!您签约团队的全科医生已变更,您的新全科医生信息如下:"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                pushMsgTask.putWxMsg(accessTokenUtils.getAccessToken(), 10, member.getOpenid(), p.getName(), json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //发送代理人 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONArray jsonArray = weiXinOpenIdUtils.getAgentOpenId(p.getCode(),p.getOpenid()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(jsonArray!=null&&jsonArray.length()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (int i = 0;i<jsonArray.length();i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONObject j  = jsonArray.getJSONObject(i); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    Patient member = (Patient) j.get("member"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONObject json = data; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    json.remove("toUser"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    json.put("toUser",member.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    json.remove("first"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    json.put("first", weiXinOpenIdUtils.getTitleMes(p, (int) json.get("relation"), p.getName()) + p.getName() + ",您好!您签约团队的全科医生已变更,您的新全科医生信息如下:"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    pushMsgTask.putWxMsg(accessTokenUtils.getAccessToken(), 10, member.getOpenid(), p.getName(), json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            logger.info(e.getMessage()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//    /** 
			 |