Redis 获取序列
@Override
public synchronized Integer generateInstitutionNo() {
String serialNo = RedisClient.lpop(RedisConstants.REDIS_DB_03, RedisConstants.KEY_INSTITUTION_NO);
if (StringUtil.isEmpty(serialNo)) {
Integer maxId = institutionService.getMaxId();
RedisClient.del(RedisConstants.REDIS_DB_03, RedisConstants.KEY_INSTITUTION_NO);
Integer i = 1 ;
while (i < 1000) {
maxId ++ ;
RedisClient.rpush(RedisConstants.REDIS_DB_03, RedisConstants.KEY_INSTITUTION_NO, String.valueOf(maxId));
i++;
}
serialNo = RedisClient.lpop(RedisConstants.REDIS_DB_03, RedisConstants.KEY_INSTITUTION_NO);
}
return Integer.valueOf(serialNo);
}