Browse Source

修复:

1.【小组排名】&【调查问卷】中网格缓存内容不一致的bug
dev
wxz 4 years ago
parent
commit
c5bc13d3af
  1. 9
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
  2. 12
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/GridInfoCache.java
  3. 36
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/BizPointTotalDetailServiceImpl.java
  4. 3
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/CustomerGridDTO.java
  5. 7
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java

9
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java

@ -212,15 +212,6 @@ public class RedisKeys {
return rootPrefix.concat("gov:agency:").concat(agencyId); return rootPrefix.concat("gov:agency:").concat(agencyId);
} }
/**
* 网格信息key
* @param gridId
* @return
*/
public static String getGridByIdKey(String gridId) {
return rootPrefix.concat("gov:grid:").concat(gridId);
}
/** /**
* 客户标签排行 缓存Key * 客户标签排行 缓存Key
* @param customerId * @param customerId

12
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/GridInfoCache.java

@ -1,12 +0,0 @@
package com.epmet.commons.tools.redis.common.bean;
import lombok.Data;
@Data
public class GridInfoCache {
private String gridId;
private String gridNamePath;
private String customerId;
private String pid;
private String pids;
}

36
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/BizPointTotalDetailServiceImpl.java

@ -29,7 +29,7 @@ import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.feign.ResultDataResolver; import com.epmet.commons.tools.feign.ResultDataResolver;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.common.bean.GridInfoCache; import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
@ -47,7 +47,6 @@ import com.epmet.resi.group.dto.group.result.GroupPointDetailResultDTO;
import com.epmet.dto.result.GroupPointRankingResultDTO; import com.epmet.dto.result.GroupPointRankingResultDTO;
import com.epmet.entity.BizPointTotalDetailEntity; import com.epmet.entity.BizPointTotalDetailEntity;
import com.epmet.resi.group.dto.group.ResiGroupDTO; import com.epmet.resi.group.dto.group.ResiGroupDTO;
import com.epmet.resi.group.dto.group.result.RankingResultDTO;
import com.epmet.resi.group.enums.SearchScopeTypeEnum; import com.epmet.resi.group.enums.SearchScopeTypeEnum;
import com.epmet.resi.group.feign.ResiGroupOpenFeignClient; import com.epmet.resi.group.feign.ResiGroupOpenFeignClient;
import com.epmet.service.BizPointTotalDetailService; import com.epmet.service.BizPointTotalDetailService;
@ -88,6 +87,8 @@ public class BizPointTotalDetailServiceImpl extends BaseServiceImpl<BizPointTota
private RedisTemplate<String, ?> redisTemplate; private RedisTemplate<String, ?> redisTemplate;
@Autowired @Autowired
private GovOrgOpenFeignClient govOrgOpenFeignClient; private GovOrgOpenFeignClient govOrgOpenFeignClient;
@Autowired
private RedisUtils redisUtils;
@Override @Override
public PageData<BizPointTotalDetailDTO> page(Map<String, Object> params) { public PageData<BizPointTotalDetailDTO> page(Map<String, Object> params) {
@ -320,8 +321,8 @@ public class BizPointTotalDetailServiceImpl extends BaseServiceImpl<BizPointTota
ranking ++; ranking ++;
} }
GridInfoCache gridInfo = getGridInfo(g.getGridId()); CustomerGridDTO gridInfo = getGridInfo(g.getGridId());
g.setGridId(g.getGridId()); //g.setGridId(g.getGridId());
if (gridInfo != null) { if (gridInfo != null) {
g.setGridNamePath(gridInfo.getGridNamePath()); g.setGridNamePath(gridInfo.getGridNamePath());
} else { } else {
@ -441,28 +442,19 @@ public class BizPointTotalDetailServiceImpl extends BaseServiceImpl<BizPointTota
* @author wxz * @author wxz
* @date 2021.09.08 11:17:17 * @date 2021.09.08 11:17:17
*/ */
public GridInfoCache getGridInfo(String gridId) { public CustomerGridDTO getGridInfo(String gridId) {
HashOperations<String, String, Object> ope = redisTemplate.opsForHash(); String redisKey = RedisKeys.getGridInfoKey(gridId);
Map<String, Object> entries = ope.entries(RedisKeys.getGridInfoKey(gridId)); Map<String, Object> gridCache = redisUtils.hGetAll(redisKey);
if (entries.size() != 0) { if (gridCache != null && gridCache.size() > 0) {
return BeanUtil.mapToBean(entries, GridInfoCache.class, true); // 直接取缓存中的
CustomerGridDTO gridInfo = BeanUtil.mapToBean(gridCache, CustomerGridDTO.class, true);
return gridInfo;
} }
CustomerGridFormDTO form = new CustomerGridFormDTO(); CustomerGridFormDTO form = new CustomerGridFormDTO();
form.setGridId(gridId); form.setGridId(gridId);
Result<CustomerGridDTO> result = govOrgOpenFeignClient.getCustomerGridByGridId(form); Result<CustomerGridDTO> result = govOrgOpenFeignClient.getGridBaseInfoByGridId(form);
if (result == null || !result.success() || result.getData() == null) { return getResultDataOrThrowsException(result, ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【小组排名】查询网格信息失败");
return null;
}
GridInfoCache cache = new GridInfoCache();
cache.setCustomerId(result.getData().getCustomerId());
cache.setGridId(result.getData().getId());
cache.setGridNamePath(result.getData().getGridName());
cache.setPid(result.getData().getPid());
cache.setPids(result.getData().getPids());
ope.putAll(RedisKeys.getGridInfoKey(gridId), BeanUtil.beanToMap(cache));
return cache;
} }
@Override @Override

3
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/CustomerGridDTO.java

@ -49,6 +49,9 @@ public class CustomerGridDTO implements Serializable {
*/ */
private String gridName; private String gridName;
/** 组织-网格 */
private String gridNamePath;
/** /**
* 中心位置经度 * 中心位置经度
*/ */

7
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java

@ -720,7 +720,7 @@ public class CustomerGridServiceImpl extends BaseServiceImpl<CustomerGridDao, Cu
@Override @Override
public CustomerGridDTO getBaseInfo(CustomerGridFormDTO customerGridFormDTO) { public CustomerGridDTO getBaseInfo(CustomerGridFormDTO customerGridFormDTO) {
String redisKey = RedisKeys.getGridByIdKey(customerGridFormDTO.getGridId()); String redisKey = RedisKeys.getGridInfoKey(customerGridFormDTO.getGridId());
Map<String, Object> gridCache = redisUtils.hGetAll(redisKey); Map<String, Object> gridCache = redisUtils.hGetAll(redisKey);
if (gridCache != null && gridCache.size() > 0) { if (gridCache != null && gridCache.size() > 0) {
// 直接取缓存中的 // 直接取缓存中的
@ -730,8 +730,9 @@ public class CustomerGridServiceImpl extends BaseServiceImpl<CustomerGridDao, Cu
CustomerGridDTO gridInfo = ConvertUtils.sourceToTarget(baseDao.selectById(customerGridFormDTO.getGridId()), CustomerGridDTO.class); CustomerGridDTO gridInfo = ConvertUtils.sourceToTarget(baseDao.selectById(customerGridFormDTO.getGridId()), CustomerGridDTO.class);
if (null != gridInfo) { if (null != gridInfo) {
CustomerAgencyEntity entity = customerAgencyService.selectById(gridInfo.getPid()); CustomerAgencyEntity agency = customerAgencyService.selectById(gridInfo.getPid());
gridInfo.setAgencyName(null != entity ? entity.getOrganizationName() : ""); gridInfo.setAgencyName(null != agency ? agency.getOrganizationName() : "");
gridInfo.setGridNamePath(null != agency ? agency.getOrganizationName().concat("-").concat(gridInfo.getGridName()) : gridInfo.getGridName());
} }
redisUtils.hMSet(redisKey, BeanUtil.beanToMap(gridInfo)); redisUtils.hMSet(redisKey, BeanUtil.beanToMap(gridInfo));

Loading…
Cancel
Save