diff --git a/servers/boe-server-all/src/main/java/com/xboe/data/service/impl/DataUserSyncServiceImpl.java b/servers/boe-server-all/src/main/java/com/xboe/data/service/impl/DataUserSyncServiceImpl.java index a32b544b..c2fa67ec 100644 --- a/servers/boe-server-all/src/main/java/com/xboe/data/service/impl/DataUserSyncServiceImpl.java +++ b/servers/boe-server-all/src/main/java/com/xboe/data/service/impl/DataUserSyncServiceImpl.java @@ -11,6 +11,7 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.Cache; import org.springframework.cache.CacheManager; +import org.springframework.cache.annotation.Cacheable; import org.springframework.retry.annotation.Recover; import org.springframework.retry.annotation.Retryable; import org.springframework.stereotype.Service; @@ -86,12 +87,6 @@ public class DataUserSyncServiceImpl implements IDataUserSyncService { log.info("账号不存在,新添加账号【" + user.getId() + "】"); } - Cache cache = cacheManager.getCache(CacheName.NAME_USER); - if(cache != null) { - String key = CacheName.KEY_ACCOUNT + user.getId(); - cache.evict(key); - } - if (u != null) { //更新部分用户字段 u.setDepartId(user.getDepartId()); @@ -129,6 +124,13 @@ public class DataUserSyncServiceImpl implements IDataUserSyncService { userDao.save(u); log.info("添加新用户"); } + + Cache cache = cacheManager.getCache(CacheName.NAME_USER); + if(cache != null) { + cache.evict(CacheName.KEY_ACCOUNT + user.getId()); + cache.evict(CacheName.KEY_USER + user.getId()); + } + //对机构的判断,不为空时才会处理,为空时不处理 if (StringUtils.isNotBlank(user.getDepartId())) { org = orgDao.get(user.getDepartId());