Browse Source

网格缓存避免空指针

master
yinzuomei 3 years ago
parent
commit
9844445fba
  1. 6
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/CustomerOrgRedis.java

6
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/CustomerOrgRedis.java

@ -1,7 +1,6 @@
package com.epmet.commons.tools.redis.common; package com.epmet.commons.tools.redis.common;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.dto.form.CustomerGridFormDTO; import com.epmet.commons.tools.dto.form.CustomerGridFormDTO;
import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.feign.CommonAggFeignClient; import com.epmet.commons.tools.feign.CommonAggFeignClient;
@ -13,6 +12,7 @@ import com.epmet.commons.tools.redis.common.bean.GridInfoCache;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
@ -55,6 +55,10 @@ public class CustomerOrgRedis {
* @date 2021/11/5 3:12 下午 * @date 2021/11/5 3:12 下午
*/ */
public static GridInfoCache getGridInfo(String gridId){ public static GridInfoCache getGridInfo(String gridId){
if (StringUtils.isBlank(gridId)) {
log.warn("查询网格缓存,gridId is null");
return null;
}
String key = RedisKeys.getGridInfoKey(gridId); String key = RedisKeys.getGridInfoKey(gridId);
Map<String, Object> grid = customerOrgRedis.redisUtils.hGetAll(key); Map<String, Object> grid = customerOrgRedis.redisUtils.hGetAll(key);
if (!CollectionUtils.isEmpty(grid)) { if (!CollectionUtils.isEmpty(grid)) {

Loading…
Cancel
Save