| 
					
				 | 
			
			
				@ -4,8 +4,10 @@ import com.alibaba.fastjson.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.message.BaseMessageDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.patient.BasePatientDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.patient.BasePatientFamilyMemberDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.patient.PatientMedicareCardDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.myFamily.PatientApplyLog; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.message.service.MessageService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.patient.service.BasePatientMedicardCardService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.patient.service.personal_Info.PatientService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.wechat.service.WeChatQrcodeService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.collections.map.HashedMap; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -36,6 +38,8 @@ public class MyFamilyService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private WeChatQrcodeService weChatQrcodeService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PatientApplyLogService patientApplyLogService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BasePatientMedicardCardService  patientMedicareCardService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<Map<String,Object>> getMyFamilyBindingRole(String patient) throws Exception{ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -97,7 +101,7 @@ public class MyFamilyService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Transactional(rollbackFor = Exception.class) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public PatientApplyLog bindingMyFamily(HttpServletRequest request,String wechatId, String saasId, String patient, String familyMobile, Integer platform) throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public PatientApplyLog bindingMyFamily(HttpServletRequest request,String wechatId, String saasId, String patient, String familyMobile, Integer platform,Integer familyBindRole) throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BasePatientDO patientDO = patientService.findByIdAndDel(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //1、检验手机号码是否有存在账号, 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -106,8 +110,8 @@ public class MyFamilyService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BasePatientDO familyPatient = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //3、生成申请绑定的记录,二维码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        PatientApplyLog patientApplyLog = createFamilyQrCode(request,familyPatient,wechatId,patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //3、生成申请绑定的记录,申请绑定二维码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        PatientApplyLog patientApplyLog = createFamilyQrCode(request,familyPatient,wechatId,patient,familyBindRole); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //4、发送绑定家人的系统消息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BaseMessageDO messageDO = new BaseMessageDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        messageDO.setSaasId(saasId); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -141,11 +145,11 @@ public class MyFamilyService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Transactional(rollbackFor = Exception.class) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public PatientApplyLog createFamilyQrCode(HttpServletRequest request,BasePatientDO familyPatient,String wechatId, String patient) throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public PatientApplyLog createFamilyQrCode(HttpServletRequest request,BasePatientDO familyPatient,String wechatId, String patient,Integer familyBindRole) throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BasePatientDO patientDO = patientService.findByIdAndDel(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        PatientApplyLog patientApplyLog = new PatientApplyLog(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        patientApplyLog.setPatientFamilyMemberName(familyPatient.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        patientApplyLog.setPatienyFamilyMemberCode(familyPatient.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        patientApplyLog.setFamilyMemberName(familyPatient.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        patientApplyLog.setFamilyMemberCode(familyPatient.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String scene ="family_"+familyPatient.getId()+"_"+familyPatient.getId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String qrCode = weChatQrcodeService.getQrcode(request,wechatId, scene); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isEmpty(qrCode)){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -159,6 +163,7 @@ public class MyFamilyService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        patientApplyLog.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        patientApplyLog.setCreateUser(familyPatient.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        patientApplyLog.setCreateUserName(patientDO.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        patientApplyLog.setFamilyBindRole(familyBindRole); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        patientApplyLogService.save(patientApplyLog); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return patientApplyLog; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -177,7 +182,14 @@ public class MyFamilyService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void confirmApply(Integer messageId,Integer patientApplyLogId){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 家人确认绑定 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param messageId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param patientApplyLogId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param status 1、添加家人(默认),2、邀请登录,3、通过,4、拒绝 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Transactional(rollbackFor = Exception.class) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void confirmApply(Integer messageId,Integer patientApplyLogId,Integer status,Integer isAuthorize){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BaseMessageDO messageDO = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(messageId!=null){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -192,7 +204,65 @@ public class MyFamilyService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            messageService.save(messageDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        PatientApplyLog patientApplyLog = patientApplyLogService.findById(patientApplyLogId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        patientApplyLog.setStatus(status); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        patientApplyLog.setConfirmTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        patientApplyLogService.save(patientApplyLog); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(status==3){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            BasePatientFamilyMemberDO patientFamilyMember = new BasePatientFamilyMemberDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            patientFamilyMember.setPatient(patientApplyLog.getCreateUser()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            patientFamilyMember.setFamilyMember(patientApplyLog.getFamilyMemberCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            patientFamilyMember.setFamilyRelation(patientApplyLog.getFamilyBindRole()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            patientFamilyMember.setIsAuthorize(isAuthorize); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            patientFamilyMember.setDel(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            patientFamilyMemberService.save(patientFamilyMember); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 签约界面已绑定家人列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param patient 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<Map<String,Object>> getBindingList(String patient) throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> resultList = new LinkedList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<BasePatientFamilyMemberDO> list = patientFamilyMemberService.getByPatientAndFamilyMember(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String patientTemp = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //自己 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BasePatientDO basePatientDO = patientService.findByIdAndDel(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String,Object> map = new HashedMap(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        map.put("appellation","自己");//别称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        map.put("patientCode",patient);//居民code 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        map.put("name",basePatientDO.getName());//姓名 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        map.put("cardTypeName","身份证"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        map.put("idcard",basePatientDO.getIdcard());//身份证 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        PatientMedicareCardDO patientMedicareCard = patientMedicareCardService.findByCode(basePatientDO.getPrincipalCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        map.put("principalNum",patientMedicareCard.getMedicareNumber());//社保卡号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        map.put("mobile",basePatientDO.getMobile());//手机号码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        resultList.add(map); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //家人 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for(BasePatientFamilyMemberDO one:list){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Map<String,Object> map2 = new HashedMap(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(patient.equals(one.getPatient())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                patientTemp = one.getPatient(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                patientTemp = one.getFamilyMember(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            basePatientDO = patientService.findByIdAndDel(patientTemp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map2.put("appellation",basePatientDO.getName());//别称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map2.put("patientCode",patientTemp);//居民code 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map2.put("name",basePatientDO.getName());//姓名 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map2.put("cardTypeName","身份证"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map2.put("idcard",basePatientDO.getIdcard());//身份证 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            patientMedicareCard = patientMedicareCardService.findByCode(basePatientDO.getPrincipalCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map2.put("principalNum",patientMedicareCard.getMedicareNumber());//社保卡号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map2.put("mobile",basePatientDO.getMobile());//手机号码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            resultList.add(map2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return resultList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 |