|  | @ -9,6 +9,7 @@ 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.patient.service.servicepackage.PackageService;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.date.DateUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.wechat.service.WeChatQrcodeService;
 | 
	
		
			
				|  |  | import org.apache.commons.collections.map.HashedMap;
 | 
	
		
			
				|  |  | import org.apache.commons.collections.map.LinkedMap;
 | 
	
	
		
			
				|  | @ -18,7 +19,6 @@ import org.springframework.beans.factory.annotation.Value;
 | 
	
		
			
				|  |  | import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  | import org.springframework.transaction.annotation.Transactional;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import javax.servlet.http.HttpServletRequest;
 | 
	
		
			
				|  |  | import java.util.*;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | /**
 | 
	
	
		
			
				|  | @ -34,7 +34,7 @@ public class MyFamilyService {
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private MessageService messageService;
 | 
	
		
			
				|  |  |     @Value("${myFamily.qrCodeFailurTime}")
 | 
	
		
			
				|  |  |     private String qrCodeFailurTime;
 | 
	
		
			
				|  |  |     private String qrCodeFailurTime;//单位天
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private WeChatQrcodeService weChatQrcodeService;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
	
		
			
				|  | @ -91,61 +91,85 @@ public class MyFamilyService {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 一键绑定
 | 
	
		
			
				|  |  |      * @param request
 | 
	
		
			
				|  |  |      * @param wechatId
 | 
	
		
			
				|  |  |      * @param patient
 | 
	
		
			
				|  |  |      * @param familyMobile
 | 
	
		
			
				|  |  |      * @param platform
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  |     public PatientApplyLog bindingMyFamily(HttpServletRequest request,String wechatId, String patient, String familyMobile, Integer platform,Integer familyBindRole) throws Exception{
 | 
	
		
			
				|  |  |     public Map<String,Object> bindingMyFamily( String patient, String familyMobile, Integer platform,Integer familyBindRole) throws Exception{
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         BasePatientDO patientDO = patientService.findByIdAndDel(patient);
 | 
	
		
			
				|  |  |         //1、检验手机号码是否有存在账号,
 | 
	
		
			
				|  |  |         BasePatientDO familyPatient = patientService.findByMobileAndDel(familyMobile);
 | 
	
		
			
				|  |  |         if(familyPatient==null){
 | 
	
		
			
				|  |  |             //2、没有存在账号的,预注册一个账号,调用预注册接口
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //3、生成申请绑定的记录
 | 
	
		
			
				|  |  |         PatientApplyLog patientApplyLog = patientApplyLogService.findValidOne(patient,familyPatient.getId(),new Date(),familyBindRole);
 | 
	
		
			
				|  |  |         if(patientApplyLog==null){
 | 
	
		
			
				|  |  |             patientApplyLog = new PatientApplyLog();
 | 
	
		
			
				|  |  |             patientApplyLog.setFamilyMemberName(familyPatient.getName());
 | 
	
		
			
				|  |  |             patientApplyLog.setFamilyMemberCode(familyPatient.getId());
 | 
	
		
			
				|  |  |             patientApplyLog.setDel(1);
 | 
	
		
			
				|  |  |             patientApplyLog.setCreateTime(new Date());
 | 
	
		
			
				|  |  |             patientApplyLog.setCreateUser(familyPatient.getId());
 | 
	
		
			
				|  |  |             patientApplyLog.setCreateUserName(patientDO.getName());
 | 
	
		
			
				|  |  |             patientApplyLog.setFamilyBindRole(familyBindRole);
 | 
	
		
			
				|  |  |             //4、发送绑定家人的系统消息
 | 
	
		
			
				|  |  |             BaseMessageDO messageDO = new BaseMessageDO();
 | 
	
		
			
				|  |  |             messageDO.setReceiver(familyPatient.getId());
 | 
	
		
			
				|  |  |             messageDO.setReceiverName(familyPatient.getName());
 | 
	
		
			
				|  |  |             messageDO.setSender(patient);
 | 
	
		
			
				|  |  |             messageDO.setSenderName(patientDO.getName());
 | 
	
		
			
				|  |  |             messageDO.setSenderPhoto(patientDO.getPhoto());
 | 
	
		
			
				|  |  |             messageDO.setTitle("家人绑定");
 | 
	
		
			
				|  |  |             messageDO.setMsgDigest("");
 | 
	
		
			
				|  |  |             messageDO.setMsgContent("");
 | 
	
		
			
				|  |  |             messageDO.setMsgTypeCode("010801");
 | 
	
		
			
				|  |  |             messageDO.setMsgTypeName("");
 | 
	
		
			
				|  |  |             messageDO.setPlatform(platform);
 | 
	
		
			
				|  |  |             messageDO.setReadState(0);
 | 
	
		
			
				|  |  |             messageDO.setReadonly(0);
 | 
	
		
			
				|  |  |             messageDO.setDel("1");
 | 
	
		
			
				|  |  |             messageDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |             messageService.save(messageDO);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         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);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //2、没有存在账号的,预注册一个账号,调用预注册接口
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         BasePatientDO familyPatient = null;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //3、生成申请绑定的记录,申请绑定二维码
 | 
	
		
			
				|  |  |         PatientApplyLog patientApplyLog = createFamilyQrCode(request,familyPatient,wechatId,patient,familyBindRole);
 | 
	
		
			
				|  |  |         //4、发送绑定家人的系统消息
 | 
	
		
			
				|  |  |         BaseMessageDO messageDO = new BaseMessageDO();
 | 
	
		
			
				|  |  |         messageDO.setReceiver(familyPatient.getId());
 | 
	
		
			
				|  |  |         messageDO.setReceiverName(familyPatient.getName());
 | 
	
		
			
				|  |  |         messageDO.setSender(patient);
 | 
	
		
			
				|  |  |         messageDO.setType(1);
 | 
	
		
			
				|  |  |         messageDO.setFailureTime(patientApplyLog.getFailureTime());
 | 
	
		
			
				|  |  |         messageDO.setSenderName(patientDO.getName());
 | 
	
		
			
				|  |  |         messageDO.setSenderPhoto(patientDO.getPhoto());
 | 
	
		
			
				|  |  |         messageDO.setTitle("家人绑定");
 | 
	
		
			
				|  |  |         messageDO.setMsgDigest("");
 | 
	
		
			
				|  |  |         messageDO.setMsgContent("");
 | 
	
		
			
				|  |  |         messageDO.setMsgTypeCode("010801");
 | 
	
		
			
				|  |  |         messageDO.setMsgTypeName("");
 | 
	
		
			
				|  |  |         messageDO.setPlatform(platform);
 | 
	
		
			
				|  |  |         messageDO.setReadState(0);
 | 
	
		
			
				|  |  |         messageDO.setReadonly(0);
 | 
	
		
			
				|  |  |         messageDO.setDel("1");
 | 
	
		
			
				|  |  |         messageDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |         messageService.save(messageDO);
 | 
	
		
			
				|  |  |         return patientApplyLog;
 | 
	
		
			
				|  |  |         Map<String,Object> map = new HashedMap();
 | 
	
		
			
				|  |  |         map.put("patientApplyLogId",patientApplyLog.getId());//
 | 
	
		
			
				|  |  |         map.put("familyMemberName",patientApplyLog.getFamilyMemberName());//家人的名称
 | 
	
		
			
				|  |  |         map.put("familyMemberCode",patientApplyLog.getFamilyMemberCode());//家人的code
 | 
	
		
			
				|  |  |         map.put("familyMemberPhoto",familyPatient.getPhoto());//家人的头像
 | 
	
		
			
				|  |  |         map.put("failureTime", DateUtil.dateToStr(patientApplyLog.getFailureTime(),"yyyy-MM-dd HH:mm:ss"));//失效时间
 | 
	
		
			
				|  |  |         map.put("status",patientApplyLog.getStatus());//状态
 | 
	
		
			
				|  |  |         map.put("createTime",DateUtil.dateToStr(patientApplyLog.getCreateTime(),"yyyy-MM-dd HH:mm:ss"));//创建时间
 | 
	
		
			
				|  |  |         map.put("createUser",patientApplyLog.getCreateUser());//申请人
 | 
	
		
			
				|  |  |         map.put("createUserName",patientApplyLog.getCreateUserName());//申请人姓名
 | 
	
		
			
				|  |  |         map.put("createUserPhoto",patientDO.getPhoto());//申请人头像
 | 
	
		
			
				|  |  |         map.put("familyBindRole",patientApplyLog.getFamilyBindRole());//角色 1"配偶",2"父亲",3"母亲",4"公公",5"婆婆",6"岳父",7"岳母",8"女婿",9"儿媳",10"子女"
 | 
	
		
			
				|  |  |         map.put("familyMobile",familyMobile);//家人手机号码
 | 
	
		
			
				|  |  |         return map;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 签约绑定家人
 | 
	
		
			
				|  |  |      * @param request
 | 
	
		
			
				|  |  |      * @param wechatId
 | 
	
		
			
				|  |  |      * @param patient
 | 
	
		
			
				|  |  |      * @param familyMobile
 | 
	
		
			
				|  |  |      * @param platform
 | 
	
		
			
				|  |  |      * @param patient 申请绑定的居民code
 | 
	
		
			
				|  |  |      * @param familyMobile 家人的手机号码
 | 
	
		
			
				|  |  |      * @param platform  消息平台,1微信端/患者端,2医生APP端
 | 
	
		
			
				|  |  |      * @param familyBindRole 1"配偶",2"父亲",3"母亲",4"公公",5"婆婆",6"岳父",7"岳母",8"女婿",9"儿媳",10"子女"
 | 
	
		
			
				|  |  |      * @param isAdult 0未成年人 1成年人
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public PatientApplyLog signBindFamily(HttpServletRequest request,String wechatId, String patient, String familyMobile, Integer platform,Integer familyBindRole,Integer isAdult) throws Exception{
 | 
	
		
			
				|  |  |     public Map<String,Object> signBindFamily( String patient, String familyMobile, Integer platform,Integer familyBindRole,Integer isAdult) throws Exception{
 | 
	
		
			
				|  |  |         if(isAdult==1){
 | 
	
		
			
				|  |  |             PatientApplyLog p = bindingMyFamily(request,wechatId,patient, familyMobile, platform,familyBindRole);
 | 
	
		
			
				|  |  |             Map<String,Object> p = bindingMyFamily(patient, familyMobile, platform,familyBindRole);
 | 
	
		
			
				|  |  |             return p;
 | 
	
		
			
				|  |  |         }else if(isAdult==0){
 | 
	
		
			
				|  |  |             //注册一个没有手机号码的用户信息
 | 
	
	
		
			
				|  | @ -164,35 +188,24 @@ public class MyFamilyService {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 生成绑定家人的二维码
 | 
	
		
			
				|  |  |      * @param request
 | 
	
		
			
				|  |  |      * @param familyPatient
 | 
	
		
			
				|  |  |      * @param wechatId
 | 
	
		
			
				|  |  |      * @param patient
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  |     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.setFamilyMemberName(familyPatient.getName());
 | 
	
		
			
				|  |  |         patientApplyLog.setFamilyMemberCode(familyPatient.getId());
 | 
	
		
			
				|  |  |         String scene ="family_"+familyPatient.getId()+"_"+familyPatient.getId();
 | 
	
		
			
				|  |  |         String qrCode = weChatQrcodeService.getQrcode(request,wechatId, scene);
 | 
	
		
			
				|  |  |     public Map<String,Object> createFamilyQrCode(String wechatId, String patient,Integer familyBindRole) throws Exception{
 | 
	
		
			
				|  |  |         Map<String,Object> map = new HashedMap();
 | 
	
		
			
				|  |  |         String scene ="family_"+patient+"_"+familyBindRole;
 | 
	
		
			
				|  |  |         String qrCode = weChatQrcodeService.getQrcode(wechatId, scene);
 | 
	
		
			
				|  |  |         if(StringUtils.isEmpty(qrCode)){
 | 
	
		
			
				|  |  |             throw new Exception("qrCode is null");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         patientApplyLog.setQrCode(qrCode);
 | 
	
		
			
				|  |  |         Long time = 1000*60*60*Long.valueOf(qrCodeFailurTime);
 | 
	
		
			
				|  |  |         Long failurTime = (new Date()).getTime()+time;
 | 
	
		
			
				|  |  |         patientApplyLog.setFailureTime(new Date(failurTime));
 | 
	
		
			
				|  |  |         patientApplyLog.setDel(1);
 | 
	
		
			
				|  |  |         patientApplyLog.setCreateTime(new Date());
 | 
	
		
			
				|  |  |         patientApplyLog.setCreateUser(familyPatient.getId());
 | 
	
		
			
				|  |  |         patientApplyLog.setCreateUserName(patientDO.getName());
 | 
	
		
			
				|  |  |         patientApplyLog.setFamilyBindRole(familyBindRole);
 | 
	
		
			
				|  |  |         patientApplyLogService.save(patientApplyLog);
 | 
	
		
			
				|  |  |         return patientApplyLog;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         map.put("qrCode",qrCode);
 | 
	
		
			
				|  |  |         map.put("familyBindRole",familyBindRole);
 | 
	
		
			
				|  |  |         map.put("myFamilyBindingRole",getMyFamilyBindingRole(patient));
 | 
	
		
			
				|  |  |         return map;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -216,10 +229,20 @@ public class MyFamilyService {
 | 
	
		
			
				|  |  |      * @param status 1、添加家人(默认),2、邀请登录,3、通过,4、拒绝
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  |     public void confirmApply(Integer patientApplyLogId,Integer status,Integer isAuthorize){
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public Map<String,Object> confirmApply(Integer patientApplyLogId,Integer status,Integer isAuthorize)throws Exception{
 | 
	
		
			
				|  |  |         Map<String,Object> map = new HashedMap();
 | 
	
		
			
				|  |  |         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;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         patientApplyLog.setStatus(status);
 | 
	
		
			
				|  |  |         patientApplyLog.setConfirmTime(new Date());
 | 
	
		
			
				|  |  |         patientApplyLogService.save(patientApplyLog);
 | 
	
	
		
			
				|  | @ -229,11 +252,82 @@ public class MyFamilyService {
 | 
	
		
			
				|  |  |             patientFamilyMember.setPatient(patientApplyLog.getCreateUser());
 | 
	
		
			
				|  |  |             patientFamilyMember.setFamilyMember(patientApplyLog.getFamilyMemberCode());
 | 
	
		
			
				|  |  |             patientFamilyMember.setFamilyRelation(patientApplyLog.getFamilyBindRole());
 | 
	
		
			
				|  |  |             patientFamilyMember.setIsAuthorize(isAuthorize);
 | 
	
		
			
				|  |  |             patientFamilyMember.setIsAuthorize(0);
 | 
	
		
			
				|  |  |             patientFamilyMember.setDel(1);
 | 
	
		
			
				|  |  |             patientFamilyMemberService.save(patientFamilyMember);
 | 
	
		
			
				|  |  |             BasePatientFamilyMemberDO patientFamilyMember2 = new BasePatientFamilyMemberDO();
 | 
	
		
			
				|  |  |             patientFamilyMember2.setPatient(patientApplyLog.getFamilyMemberCode());
 | 
	
		
			
				|  |  |             patientFamilyMember2.setFamilyMember(patientApplyLog.getCreateUser());
 | 
	
		
			
				|  |  |             BasePatientDO createUser = patientService.findByIdAndDel(patientApplyLog.getCreateUser());
 | 
	
		
			
				|  |  |             patientFamilyMember2.setFamilyRelation(familyRelationTrans(patientApplyLog.getFamilyBindRole(),createUser.getSex()));
 | 
	
		
			
				|  |  |             patientFamilyMember2.setIsAuthorize(isAuthorize);
 | 
	
		
			
				|  |  |             patientFamilyMember2.setDel(1);
 | 
	
		
			
				|  |  |             patientFamilyMemberService.save(patientFamilyMember2);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         map.put("key","1");
 | 
	
		
			
				|  |  |         map.put("keyName","绑定成功");
 | 
	
		
			
				|  |  |         return map;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 扫码绑定确认
 | 
	
		
			
				|  |  |      * @param status
 | 
	
		
			
				|  |  |      * @param applyPatient
 | 
	
		
			
				|  |  |      * @param familyPatient
 | 
	
		
			
				|  |  |      * @param familyBindRole
 | 
	
		
			
				|  |  |      * @param isAuthorize
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public void scanQRcodeConfirmApply(Integer status,String applyPatient,String familyPatient,Integer familyBindRole,Integer isAuthorize)throws Exception{
 | 
	
		
			
				|  |  |         if(status==3){
 | 
	
		
			
				|  |  |             BasePatientFamilyMemberDO patientFamilyMember = new BasePatientFamilyMemberDO();
 | 
	
		
			
				|  |  |             patientFamilyMember.setPatient(applyPatient);
 | 
	
		
			
				|  |  |             patientFamilyMember.setFamilyMember(familyPatient);
 | 
	
		
			
				|  |  |             patientFamilyMember.setFamilyRelation(familyBindRole);
 | 
	
		
			
				|  |  |             patientFamilyMember.setIsAuthorize(0);
 | 
	
		
			
				|  |  |             patientFamilyMember.setDel(1);
 | 
	
		
			
				|  |  |             patientFamilyMemberService.save(patientFamilyMember);
 | 
	
		
			
				|  |  |             BasePatientFamilyMemberDO patientFamilyMember2 = new BasePatientFamilyMemberDO();
 | 
	
		
			
				|  |  |             patientFamilyMember2.setPatient(familyPatient);
 | 
	
		
			
				|  |  |             patientFamilyMember2.setFamilyMember(applyPatient);
 | 
	
		
			
				|  |  |             BasePatientDO createUser = patientService.findByIdAndDel(applyPatient);
 | 
	
		
			
				|  |  |             patientFamilyMember2.setFamilyRelation(familyRelationTrans(familyBindRole,createUser.getSex()));
 | 
	
		
			
				|  |  |             patientFamilyMember2.setIsAuthorize(isAuthorize);
 | 
	
		
			
				|  |  |             patientFamilyMember2.setDel(1);
 | 
	
		
			
				|  |  |             patientFamilyMemberService.save(patientFamilyMember2);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 扫码到确认绑定页面
 | 
	
		
			
				|  |  |      * @param applyPatient
 | 
	
		
			
				|  |  |      * @param familyPatient
 | 
	
		
			
				|  |  |      * @param familyBindRole
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public Map<String,Object> scanQRcode(String applyPatient,String familyPatient,Integer familyBindRole) throws Exception{
 | 
	
		
			
				|  |  |         Map<String,Object> map = new HashedMap();
 | 
	
		
			
				|  |  |         BasePatientDO apply = patientService.findByIdAndDel(applyPatient);
 | 
	
		
			
				|  |  |         BasePatientDO family = patientService.findByIdAndDel(familyPatient);
 | 
	
		
			
				|  |  |         Integer converRole = familyRelationTrans(familyBindRole,apply.getSex());
 | 
	
		
			
				|  |  |         map.put("applyPhoto",apply.getPhoto());
 | 
	
		
			
				|  |  |         map.put("familyPhoto",family.getPhoto());
 | 
	
		
			
				|  |  |         map.put("explain","您的"+role.get(converRole-1)+apply.getName()+"邀请您绑定家人账号");
 | 
	
		
			
				|  |  |         return map;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 消息到确认绑定页面
 | 
	
		
			
				|  |  |      * @param messageId
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public Map<String,Object> messageToBinding(Integer messageId)throws Exception{
 | 
	
		
			
				|  |  |         BaseMessageDO messageDO = messageService.findById(messageId);
 | 
	
		
			
				|  |  |         PatientApplyLog patientApplyLog = patientApplyLogService.findById(Integer.valueOf(messageDO.getRelationData()+""));
 | 
	
		
			
				|  |  |         Map<String,Object> map = scanQRcode(patientApplyLog.getCreateUser(),patientApplyLog.getFamilyMemberCode(),patientApplyLog.getFamilyBindRole());
 | 
	
		
			
				|  |  |         map.put("patientApplyLogId",patientApplyLog.getId());
 | 
	
		
			
				|  |  |         return map;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
	
		
			
				|  | @ -245,7 +339,6 @@ public class MyFamilyService {
 | 
	
		
			
				|  |  |     public List<Map<String,Object>> getBindingList(String patient,String packageId) 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();
 | 
	
	
		
			
				|  | @ -254,10 +347,10 @@ public class MyFamilyService {
 | 
	
		
			
				|  |  |         map.put("name",basePatientDO.getName());//姓名
 | 
	
		
			
				|  |  |         map.put("cardTypeName","身份证");
 | 
	
		
			
				|  |  |         map.put("idcard",basePatientDO.getIdcard());//身份证
 | 
	
		
			
				|  |  |         if(!StringUtils.isEmpty(basePatientDO.getPrincipalCode())){
 | 
	
		
			
				|  |  |         PatientMedicareCardDO patientMedicareCardDO = patientMedicareCardService.findByTypeAndPatientCodeAndDel(PatientMedicareCardDO.Type.SocialSecurityCard.getType(),patient,"1");
 | 
	
		
			
				|  |  |         if(patientMedicareCardDO!=null){
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             PatientMedicareCardDO patientMedicareCard = patientMedicareCardService.findByCode(basePatientDO.getPrincipalCode());
 | 
	
		
			
				|  |  |             map.put("principalNum",patientMedicareCard.getCode());//社保卡号
 | 
	
		
			
				|  |  |             map.put("principalNum",patientMedicareCardDO.getCode());//社保卡号
 | 
	
		
			
				|  |  |         }else{
 | 
	
		
			
				|  |  |             map.put("principalNum","");//社保卡号
 | 
	
		
			
				|  |  |         }
 | 
	
	
		
			
				|  | @ -274,20 +367,15 @@ public class MyFamilyService {
 | 
	
		
			
				|  |  |         //家人
 | 
	
		
			
				|  |  |         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);
 | 
	
		
			
				|  |  |             basePatientDO = patientService.findByIdAndDel(one.getPatient());
 | 
	
		
			
				|  |  |             map2.put("appellation",basePatientDO.getName());//别称
 | 
	
		
			
				|  |  |             map2.put("patientCode",patientTemp);//居民code
 | 
	
		
			
				|  |  |             map2.put("patientCode",basePatientDO.getId());//居民code
 | 
	
		
			
				|  |  |             map2.put("name",basePatientDO.getName());//姓名
 | 
	
		
			
				|  |  |             map2.put("cardTypeName","身份证");
 | 
	
		
			
				|  |  |             map2.put("idcard",basePatientDO.getIdcard());//身份证
 | 
	
		
			
				|  |  |             if(!StringUtils.isEmpty(basePatientDO.getPrincipalCode())){
 | 
	
		
			
				|  |  |             PatientMedicareCardDO patientMedicareCard = patientMedicareCardService.findByTypeAndPatientCodeAndDel(PatientMedicareCardDO.Type.SocialSecurityCard.getType(),patient,"1");
 | 
	
		
			
				|  |  |             if(patientMedicareCardDO!=null){
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 PatientMedicareCardDO patientMedicareCard = patientMedicareCardService.findByCode(basePatientDO.getPrincipalCode());
 | 
	
		
			
				|  |  |                 map2.put("principalNum",patientMedicareCard.getCode());//社保卡号
 | 
	
		
			
				|  |  |             }else{
 | 
	
		
			
				|  |  |                 map2.put("principalNum","");//社保卡号
 | 
	
	
		
			
				|  | @ -313,28 +401,15 @@ public class MyFamilyService {
 | 
	
		
			
				|  |  |         BasePatientDO patientDO = patientService.findByIdAndDel(patient);//绑定人
 | 
	
		
			
				|  |  |         for(BasePatientFamilyMemberDO one:bindList){
 | 
	
		
			
				|  |  |             Map<String,Object> map = new HashedMap();
 | 
	
		
			
				|  |  |             if(patient.equals(one.getPatient())){
 | 
	
		
			
				|  |  |                 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("mobile",familyMember.getMobile());//手机号码
 | 
	
		
			
				|  |  |                 map.put("isAuthorize",one.getIsAuthorize());//0:未授权,1:已授权
 | 
	
		
			
				|  |  |                 map.put("familyMemberId",one.getId());
 | 
	
		
			
				|  |  |                 map.put("patientId",familyMember.getId());
 | 
	
		
			
				|  |  |                 map.put("type",1);
 | 
	
		
			
				|  |  |             }else{
 | 
	
		
			
				|  |  |                 Integer familyRelation = familyRelationTrans(one.getFamilyRelation(),patientDO.getSex());
 | 
	
		
			
				|  |  |                 BasePatientDO familyMember = patientService.findByIdAndDel(one.getPatient());
 | 
	
		
			
				|  |  |                 map.put("photo",familyMember.getPhoto());//头像
 | 
	
		
			
				|  |  |                 map.put("name",familyMember.getName());//姓名
 | 
	
		
			
				|  |  |                 map.put("roleName",role.get(familyRelation+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("type",1);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             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("mobile",familyMember.getMobile());//手机号码
 | 
	
		
			
				|  |  |             map.put("isAuthorize",one.getIsAuthorize());//0:未授权,1:已授权
 | 
	
		
			
				|  |  |             map.put("familyMemberId",one.getId());
 | 
	
		
			
				|  |  |             map.put("patientId",familyMember.getId());
 | 
	
		
			
				|  |  |             map.put("type",1);
 | 
	
		
			
				|  |  |             resultList.add(map);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //已邀请的
 | 
	
	
		
			
				|  | @ -385,13 +460,20 @@ public class MyFamilyService {
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  |     public List<Map<String,Object>> applyMessageList(String patient) throws Exception{
 | 
	
		
			
				|  |  |         List<Map<String, Object>> msgList = messageService.applyMessageList(patient, new Date(), "010801");
 | 
	
		
			
				|  |  |         List<Map<String, Object>> msgList = messageService.applyMessageList(patient, "010801");
 | 
	
		
			
				|  |  |         List<Map<String,Object>> result = new ArrayList<>();
 | 
	
		
			
				|  |  |         PatientApplyLog patientApplyLog = null;
 | 
	
		
			
				|  |  |         for(Map<String, Object> one:msgList){
 | 
	
		
			
				|  |  |             Map<String,Object> map = new HashedMap();
 | 
	
		
			
				|  |  |             String relationData = one.get("relation_data")+"";
 | 
	
		
			
				|  |  |             patientApplyLog = patientApplyLogService.findById(Integer.valueOf(relationData));
 | 
	
		
			
				|  |  |             if(patientApplyLog.getFailureTime().getTime()<System.currentTimeMillis()){
 | 
	
		
			
				|  |  |                 BaseMessageDO msg = messageService.findById(Integer.valueOf(one.get("id")+""));
 | 
	
		
			
				|  |  |                 msg.setReadonly(1);
 | 
	
		
			
				|  |  |                 msg.setReadTime(new Date());
 | 
	
		
			
				|  |  |                 messageService.save(msg);
 | 
	
		
			
				|  |  |                continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             Integer bindRole = patientApplyLog.getFamilyBindRole();
 | 
	
		
			
				|  |  |             String createUser = patientApplyLog.getCreateUser();//申请人code
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -429,7 +511,7 @@ public class MyFamilyService {
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 家庭关系转换
 | 
	
		
			
				|  |  |      * @param familyRelation
 | 
	
		
			
				|  |  |      * @param sex 1男,2女
 | 
	
		
			
				|  |  |      * @param sex 申请人的性别 1男,2女
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public Integer familyRelationTrans(Integer familyRelation,Integer sex){
 | 
	
		
			
				|  |  |         //1"配偶",2"父亲",3"母亲",4"公公",5"婆婆",6"岳父",7"岳母",8"女婿",9"儿媳",10"子女"
 |