| 
					
				 | 
			
			
				@ -1,5 +1,6 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				package com.yihu.jw.patient.service.myFamily; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				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; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -12,6 +13,7 @@ import org.apache.commons.lang.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				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.*; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -84,7 +86,18 @@ public class MyFamilyService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return resultList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void bindingMyFamily(HttpServletRequest request,String wechatId, String saasId, String patient, String familyMobile, Integer platform) throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 一键绑定 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param request 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param wechatId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param saasId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param patient 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param familyMobile 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param platform 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Transactional(rollbackFor = Exception.class) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public PatientApplyLog bindingMyFamily(HttpServletRequest request,String wechatId, String saasId, String patient, String familyMobile, Integer platform) throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BasePatientDO patientDO = patientService.findByIdAndDel(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //1、检验手机号码是否有存在账号, 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -94,7 +107,7 @@ public class MyFamilyService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BasePatientDO familyPatient = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //3、生成申请绑定的记录,二维码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        createFamilyQrCode(request,familyPatient,wechatId,patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        PatientApplyLog patientApplyLog = createFamilyQrCode(request,familyPatient,wechatId,patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //4、发送绑定家人的系统消息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BaseMessageDO messageDO = new BaseMessageDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        messageDO.setSaasId(saasId); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -115,6 +128,7 @@ public class MyFamilyService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        messageDO.setDel("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        messageDO.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        messageService.save(messageDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return patientApplyLog; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -126,7 +140,8 @@ public class MyFamilyService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String createFamilyQrCode(HttpServletRequest request,BasePatientDO familyPatient,String wechatId, String patient) throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Transactional(rollbackFor = Exception.class) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public PatientApplyLog createFamilyQrCode(HttpServletRequest request,BasePatientDO familyPatient,String wechatId, String patient) throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BasePatientDO patientDO = patientService.findByIdAndDel(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        PatientApplyLog patientApplyLog = new PatientApplyLog(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        patientApplyLog.setPatientFamilyMemberName(familyPatient.getName()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -145,12 +160,41 @@ public class MyFamilyService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        patientApplyLog.setCreateUser(familyPatient.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        patientApplyLog.setCreateUserName(patientDO.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        patientApplyLogService.save(patientApplyLog); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return qrCode; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return patientApplyLog; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 更新提醒方式 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param patientApplyLogId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param remindType 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void remindMyFamily(Integer patientApplyLogId,Integer remindType) throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        int i = patientApplyLogService.updateRemindTypeById(remindType,patientApplyLogId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(i<0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            throw new Exception("update data failur !"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void confirmApply(Integer messageId,Integer patientApplyLogId){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BaseMessageDO messageDO = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(messageId!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            messageDO = messageService.findById(messageId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(messageDO!=null&&patientApplyLogId==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String json = messageDO.getRelationData(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject jsonObject = JSONObject.parseObject(json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            patientApplyLogId = (Integer)jsonObject.get("patientApplyLogId"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            messageDO.setReadState(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            messageDO.setReadTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            messageService.save(messageDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 家庭关系转换 
			 |