|  | @ -4,11 +4,14 @@ 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.BasePatientService;
 | 
	
		
			
				|  |  | 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;
 | 
	
		
			
				|  |  | import org.apache.commons.collections.map.LinkedMap;
 | 
	
		
			
				|  |  | import org.apache.commons.lang.StringUtils;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Value;
 | 
	
	
		
			
				|  | @ -27,7 +30,7 @@ public class MyFamilyService {
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private PatientFamilyMemberService patientFamilyMemberService;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private BasePatientService patientService;
 | 
	
		
			
				|  |  |     private PatientService patientService;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private MessageService messageService;
 | 
	
		
			
				|  |  |     @Value("${myFamily.qrCodeFailurTime}")
 | 
	
	
		
			
				|  | @ -36,6 +39,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{
 | 
	
	
		
			
				|  | @ -44,9 +49,9 @@ public class MyFamilyService {
 | 
	
		
			
				|  |  |         BasePatientDO patientDO = patientService.findByIdAndDel(patient);
 | 
	
		
			
				|  |  |         Integer sex = patientDO.getSex();
 | 
	
		
			
				|  |  |         LinkedList<String> role = new LinkedList<>(Arrays.asList("配偶","父亲","母亲","公公","婆婆","岳父","岳母","女婿","儿媳","子女"));
 | 
	
		
			
				|  |  |         Map<String,Map<String,Object>> map = new HashedMap();
 | 
	
		
			
				|  |  |         Map<String,Map<String,Object>> map = new LinkedMap();
 | 
	
		
			
				|  |  |         for(int i =0;i<role.size();i++){
 | 
	
		
			
				|  |  |             Map<String,Object> m = new HashedMap();
 | 
	
		
			
				|  |  |             Map<String,Object> m = new LinkedMap();
 | 
	
		
			
				|  |  |             m.put("name",role.get(i));
 | 
	
		
			
				|  |  |             m.put("isBinding",0);
 | 
	
		
			
				|  |  |             m.put("key",(i+1));
 | 
	
	
		
			
				|  | @ -77,13 +82,9 @@ public class MyFamilyService {
 | 
	
		
			
				|  |  |         if(childrenList.size()==2){
 | 
	
		
			
				|  |  |             map.get("10").put("isBinding",1);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         List<Map<String,Object>> resultList = new ArrayList();
 | 
	
		
			
				|  |  |         Iterator iter = map.entrySet().iterator(); // 获得map的Iterator
 | 
	
		
			
				|  |  |         while (iter.hasNext()) {
 | 
	
		
			
				|  |  |             String key = iter.next().toString();
 | 
	
		
			
				|  |  |             resultList.add(map.get(key));
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return resultList;
 | 
	
		
			
				|  |  |         Collection<Map<String,Object>> valueCollection = map.values();
 | 
	
		
			
				|  |  |         List<Map<String,Object>> valueList = new LinkedList<>(valueCollection);
 | 
	
		
			
				|  |  |         return valueList;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
	
		
			
				|  | @ -97,7 +98,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 +107,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 +142,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 +160,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 +179,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,9 +201,77 @@ 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());//身份证
 | 
	
		
			
				|  |  |         if(!StringUtils.isEmpty(basePatientDO.getPrincipalCode())){
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             PatientMedicareCardDO patientMedicareCard = patientMedicareCardService.findByCode(basePatientDO.getPrincipalCode());
 | 
	
		
			
				|  |  |             map.put("principalNum",patientMedicareCard.getMedicareNumber());//社保卡号
 | 
	
		
			
				|  |  |         }else{
 | 
	
		
			
				|  |  |             map.put("principalNum","");//社保卡号
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         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());//身份证
 | 
	
		
			
				|  |  |             if(!StringUtils.isEmpty(basePatientDO.getPrincipalCode())){
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 PatientMedicareCardDO patientMedicareCard = patientMedicareCardService.findByCode(basePatientDO.getPrincipalCode());
 | 
	
		
			
				|  |  |                 map2.put("principalNum",patientMedicareCard.getMedicareNumber());//社保卡号
 | 
	
		
			
				|  |  |             }else{
 | 
	
		
			
				|  |  |                 map2.put("principalNum","");//社保卡号
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             map2.put("mobile",basePatientDO.getMobile());//手机号码
 | 
	
		
			
				|  |  |             resultList.add(map2);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return resultList;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 家庭关系转换
 |