| 
					
				 | 
			
			
				@ -3,9 +3,12 @@ package com.yihu.jw.security.service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.alibaba.fastjson.JSON; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.alibaba.fastjson.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.patient.BasePatientDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.wx.BasePatientWechatDo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.hospital.family.WlyyPatientFamilyMemberDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.security.dao.patient.BasePatientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.security.dao.patient.BasePatientWechatDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.security.dao.patient.WlyyPatientFamilyMemberDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.security.model.PatientWechat; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.security.utils.AES; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.security.utils.IdCardUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.utils.security.MD5; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -20,9 +23,12 @@ import org.springframework.transaction.annotation.Transactional; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.net.URLDecoder; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.Date; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.UUID; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.util.Base64Utils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import javax.sound.midi.MidiDevice; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 * Created by Trick on 2020/2/24. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 */ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -36,6 +42,8 @@ public class OauthWjwConfigService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BasePatientDao basePatientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private WlyyPatientFamilyMemberDao familyMemberDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BasePatientWechatDao basePatientWechatDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public BasePatientDO savePatient(String data)throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        logger.info("savePatient :"+data); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -52,6 +60,7 @@ public class OauthWjwConfigService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String userSex = info.getString("userSex"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String userIdNo = info.getString("userIdNo"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String dType = info.getString("dType"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String openId = info.getString("openid"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(StringUtils.isNotBlank(userIdNo)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -84,6 +93,7 @@ public class OauthWjwConfigService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String pw = userIdNo.substring(userIdNo.length()-6); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                patient.setIdcard(userIdNo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                patient.setCardType("01"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                patient.setName(name); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                patient.setPassword(MD5.md5Hex(pw + "{" + salt + "}")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                patient.setSalt(salt); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -112,8 +122,22 @@ public class OauthWjwConfigService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    basePatientFamilyMemberDO.setFamilyMember(patient.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    familyMemberDao.save(basePatientFamilyMemberDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                List<BasePatientWechatDo> patientWechatDos = basePatientWechatDao.findByWechatIdAndPatientId("xm_tasy_wx",patient.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (patientWechatDos!=null&&patientWechatDos.size()!=0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    BasePatientWechatDo basePatientWechatDo = patientWechatDos.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    basePatientWechatDo.setOpenid(openId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    BasePatientWechatDo patientWechatDo = new BasePatientWechatDo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    patientWechatDo.setOpenid(openId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    patientWechatDo.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    patientWechatDo.setPatientId(patient.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    patientWechatDo.setWechatId("xm_tasy_wx"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    patientWechatDo.setSaasId("prod"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    basePatientWechatDao.save(patientWechatDo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                return basePatientDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                return patient; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return null; 
			 |