| 
					
				 | 
			
			
				@ -14,9 +14,11 @@ import com.yihu.wlyy.repository.doctor.DoctorDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.repository.doctor.DoctorPatientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.repository.patient.PatientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.repository.patient.SignFamilyDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.repository.security.TokenDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.task.SignSsGetTask; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.util.EncodesUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.util.IdcardInfoExtractor; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.util.SystemData; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.json.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -47,6 +49,8 @@ public class PatientService extends TokenService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private DoctorDao doctorDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private DoctorPatientDao doctorPatientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    TokenDao tokenDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private Clock clock = Clock.DEFAULT; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -96,16 +100,24 @@ public class PatientService extends TokenService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param patient 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void updatePatient(Patient patient, String openid) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (patientDao.countByOpenid(openid) >= 10) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Sort sort = new Sort(Sort.Direction.ASC, "czrq"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            PageRequest pageRequest = new PageRequest(0, 1, sort); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Page<Patient> pPage = patientDao.findPatientByOpenid(openid, pageRequest); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (Patient p : pPage) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                p.setOpenid(""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                patientDao.save(p); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void updatePatient(Patient patient, String openid) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Sort sort = new Sort(Sort.Direction.ASC, "czrq"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        PageRequest pageRequest = new PageRequest(0, 10, sort); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Page<Token> tokens = tokenDao.findByOpenid(openid, pageRequest); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (tokens != null && tokens.getSize() >= 10) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Token token = tokens.getContent().get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Patient p = patientDao.findByCode(token.getUser()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (p == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                throw new Exception("> 10 openid patient info can not find"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            p.setOpenid(""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            signFamilyDao.updateOpenidByPatient("", p.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            patientDao.save(p); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            tokenDao.delete(token); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            SystemData.wxPatientTokens.remove(p.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        patient.setOpenid(openid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        patientDao.save(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotEmpty(patient.getOpenid())) { 
			 |