Browse Source

Merge branch 'dev' of lyr/patient-co-management into dev

lyr 8 years ago
parent
commit
1be7f7e7a2

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/security/TokenDao.java

@ -37,7 +37,7 @@ public interface TokenDao extends PagingAndSortingRepository<Token, Long> {
	@Query("delete Token a where a.user = ?1 and a.platform = 3 and a.del = '1'")
	int deleteWxTokenByPatient(String patient);
	@Query("select a from Token a where a.imei = ?1 and a.platform = 3 and a.del = '1'")
	@Query("select a from Token a where a.imei = ?1 and a.platform = 3 and a.del = 1")
	Page<Token> findByOpenid(String openid, Pageable pageable);
}

+ 18 - 11
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java

@ -102,20 +102,27 @@ public class PatientService extends TokenService {
     */
    public void updatePatient(Patient patient, String openid) throws Exception {
        Sort sort = new Sort(Sort.Direction.ASC, "czrq");
        PageRequest pageRequest = new PageRequest(0, 10, sort);
        PageRequest pageRequest = new PageRequest(0, 100, 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");
        if (tokens != null && tokens.getContent().size() >= 10) {
            int i = 0;
            int last = tokens.getContent().size() - 10;
            for(Token token : tokens) {
                i++;
                Patient p = patientDao.findByCode(token.getUser());
                if (p == null || i <= last) {
                    tokenDao.delete(token);
                    SystemData.wxPatientTokens.remove(token.getUser());
                    continue;
                }
                p.setOpenid("");
                signFamilyDao.updateOpenidByPatient("", p.getCode());
                patientDao.save(p);
                tokenDao.delete(token);
                SystemData.wxPatientTokens.remove(p.getCode());
                break;
            }
            p.setOpenid("");
            signFamilyDao.updateOpenidByPatient("", p.getCode());
            patientDao.save(p);
            tokenDao.delete(token);
            SystemData.wxPatientTokens.remove(p.getCode());
        }
        patient.setOpenid(openid);