| 
					
				 | 
			
			
				@ -102,8 +102,15 @@ public class MyFamilyService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BasePatientDO patientDO = patientService.findByIdAndDel(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //1、检验手机号码是否有存在账号, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BasePatientDO familyPatient = patientService.findByMobileAndDel(familyMobile); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Long time = 1000*60*60*24*Long.valueOf(qrCodeFailurTime); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(familyPatient==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //2、没有存在账号的,预注册一个账号,调用预注册接口 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Map<String,Object> map = patientService.bespeakRegist(familyMobile,time); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(Integer.valueOf(map.get("code")+"")==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                familyPatient = (BasePatientDO)map.get("patient"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                throw new Exception(map.get("message")+""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //3、生成申请绑定的记录 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -113,10 +120,14 @@ public class MyFamilyService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            patientApplyLog.setFamilyMemberName(familyPatient.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            patientApplyLog.setFamilyMemberCode(familyPatient.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            patientApplyLog.setDel(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            patientApplyLog.setStatus(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            patientApplyLog.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            patientApplyLog.setCreateUser(familyPatient.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            patientApplyLog.setCreateUser(patientDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            patientApplyLog.setCreateUserName(patientDO.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            patientApplyLog.setFamilyBindRole(familyBindRole); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Long failurTime = System.currentTimeMillis()+time; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            patientApplyLog.setFailureTime(new Date(failurTime)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            patientApplyLog = patientApplyLogService.save(patientApplyLog); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //4、发送绑定家人的系统消息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            BaseMessageDO messageDO = new BaseMessageDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            messageDO.setReceiver(familyPatient.getId()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -134,12 +145,14 @@ public class MyFamilyService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            messageDO.setReadonly(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            messageDO.setDel("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            messageDO.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            messageDO.setRelationData(patientApplyLog.getId()+""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            messageService.save(messageDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Long failurTime = System.currentTimeMillis()+time; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            patientApplyLog.setFailureTime(new Date(failurTime)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            patientApplyLog = patientApplyLogService.save(patientApplyLog); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Long time = 1000*60*60*Long.valueOf(qrCodeFailurTime); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Long failurTime = System.currentTimeMillis()+time; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        patientApplyLog.setFailureTime(new Date(failurTime)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        patientApplyLog = patientApplyLogService.save(patientApplyLog); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        PatientApplyLog patientApplyLog = createFamilyQrCode(request,familyPatient,wechatId,patient,familyBindRole); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -234,15 +247,9 @@ public class MyFamilyService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        PatientApplyLog patientApplyLog = patientApplyLogService.findById(patientApplyLogId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BasePatientDO apply = patientService.findByIdAndDel(patientApplyLog.getCreateUser()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BasePatientDO family = patientService.findByIdAndDel(patientApplyLog.getFamilyMemberCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer converRole = familyRelationTrans(patientApplyLog.getFamilyBindRole(),apply.getSex()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(patientApplyLog.getFailureTime().getTime()<System.currentTimeMillis()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("key","0"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("keyName","绑定过期"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("applyPhoto",apply.getPhoto()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("familyPhoto",family.getPhoto()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("explain","您的"+role.get(converRole-1)+apply.getName()+"向您发起的绑定邀请已过期,您可以点下下方邀请绑定按钮,重新邀请绑定家人。"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        map.put("applyPhoto",apply.getPhoto()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        map.put("familyPhoto",family.getPhoto()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        patientApplyLog.setStatus(status); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        patientApplyLog.setConfirmTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        patientApplyLogService.save(patientApplyLog); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -264,8 +271,6 @@ public class MyFamilyService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            patientFamilyMember2.setDel(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            patientFamilyMemberService.save(patientFamilyMember2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        map.put("key","1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        map.put("keyName","绑定成功"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -278,7 +283,9 @@ public class MyFamilyService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param isAuthorize 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void scanQRcodeConfirmApply(Integer status,String applyPatient,String familyPatient,Integer familyBindRole,Integer isAuthorize)throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Transactional(rollbackFor = Exception.class) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Map<String,Object> scanQRcodeConfirmApply(Integer status,String applyPatient,String familyPatient,Integer familyBindRole,Integer isAuthorize)throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String,Object> map = new HashedMap(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(status==3){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            BasePatientFamilyMemberDO patientFamilyMember = new BasePatientFamilyMemberDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            patientFamilyMember.setPatient(applyPatient); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -296,6 +303,11 @@ public class MyFamilyService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            patientFamilyMember2.setDel(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            patientFamilyMemberService.save(patientFamilyMember2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BasePatientDO apply = patientService.findByIdAndDel(applyPatient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BasePatientDO family = patientService.findByIdAndDel(familyPatient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        map.put("applyPhoto",apply.getPhoto()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        map.put("familyPhoto",family.getPhoto()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -326,6 +338,15 @@ public class MyFamilyService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BaseMessageDO messageDO = messageService.findById(messageId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        PatientApplyLog patientApplyLog = patientApplyLogService.findById(Integer.valueOf(messageDO.getRelationData()+"")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String,Object> map = scanQRcode(patientApplyLog.getCreateUser(),patientApplyLog.getFamilyMemberCode(),patientApplyLog.getFamilyBindRole()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BasePatientDO apply = patientService.findByIdAndDel(patientApplyLog.getCreateUser()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer converRole = familyRelationTrans(patientApplyLog.getFamilyBindRole(),apply.getSex()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(patientApplyLog.getFailureTime().getTime()<System.currentTimeMillis()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("overdue", "1");//过期 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("explain", "您的" + role.get(converRole - 1) + apply.getName() + "向您发起的绑定邀请已过期"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("overdue", "0"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        map.put("patientApplyLogId",patientApplyLog.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -404,11 +425,12 @@ public class MyFamilyService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            BasePatientDO familyMember = patientService.findByIdAndDel(one.getFamilyMember()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("photo",familyMember.getPhoto());//头像 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("name",familyMember.getName());//姓名 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("roleName",role.get(one.getFamilyRelation()+1));//角色名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("roleName",role.get(one.getFamilyRelation()-1));//角色名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("mobile",familyMember.getMobile());//手机号码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("isAuthorize",one.getIsAuthorize());//0:未授权,1:已授权 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("familyMemberId",one.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("patientId",familyMember.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("familyPatientId",familyMember.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("patientId",patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("type",1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            resultList.add(map); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -419,15 +441,20 @@ public class MyFamilyService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            BasePatientDO familyMember = patientService.findByIdAndDel(one.get("family_member_code")+""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("photo",familyMember.getPhoto());//头像 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("name",familyMember.getName());//姓名 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("roleName",role.get(Integer.valueOf(one.get("family_bind_role")+"")+1));//角色名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("roleName",role.get(Integer.valueOf(one.get("family_bind_role")+"")-1));//角色名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("mobile",familyMember.getMobile());//手机号码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //有效期 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Date failurTime = (Date)one.get("failure_time"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Long l = failurTime.getTime()-System.currentTimeMillis(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Long day24 = 1000*60*60*24L; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("day",l/day24); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(l%day24>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                map.put("day",(l/day24)+1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                map.put("day",l/day24); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("patientApplyId",one.get("id")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("patientId",familyMember.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("familyPatientId",familyMember.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("patientId",patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("type",2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            resultList.add(map); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -438,7 +465,7 @@ public class MyFamilyService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            BasePatientDO familyMember = patientService.findByIdAndDel(one.get("family_member_code")+""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("photo",familyMember.getPhoto());//头像 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("name",familyMember.getName());//姓名 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("roleName",role.get(Integer.valueOf(one.get("family_bind_role")+"")+1));//角色名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("roleName",role.get(Integer.valueOf(one.get("family_bind_role")+"")-1));//角色名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("mobile",familyMember.getMobile());//手机号码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Integer status = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if("1".equals(one.get("status")+"")||"2".equals(one.get("status")+"")){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -448,6 +475,8 @@ public class MyFamilyService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("status",one.get("status"));//状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("statusName",getStatusName(status));//状态名称; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("familyPatientId",familyMember.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("patientId",patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("type",3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            resultList.add(map); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -507,6 +536,32 @@ public class MyFamilyService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 解除绑定 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param familyMemberId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Transactional(rollbackFor = Exception.class) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void cancelBindFamily(String familyMemberId) throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        int i = patientFamilyMemberService.cancelBindFamily(familyMemberId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(i<0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            throw new Exception("update data failur !"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 更新授权 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param familyMemberId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Transactional(rollbackFor = Exception.class) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void updateAuthorizeById(Integer isAuthorize,String familyMemberId) throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        int i = patientFamilyMemberService.updateAuthorizeById(isAuthorize,familyMemberId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(i<0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            throw new Exception("update data failur !"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 家庭关系转换 
			 |