Browse Source

修改:

1.查询网格基本信息接口,增加缓存
dev_shibei_match
wxz 4 years ago
parent
commit
2cf07c6df7
  1. 9
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
  2. 12
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java
  3. 5
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java
  4. 3
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/GridController.java
  5. 2
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java
  6. 28
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java
  7. 4
      epmet-user/epmet-user-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java
  8. 8
      epmet-user/epmet-user-server/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallBack.java
  9. 6
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/RegisterRelationServiceImpl.java
  10. 8
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffPatrolRecordServiceImpl.java

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

@ -212,6 +212,15 @@ public class RedisKeys {
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
* @param customerId

12
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java

@ -427,4 +427,16 @@ public interface GovOrgOpenFeignClient {
*/
@PostMapping("/gov/org/customeragency/getAgencyInfo")
Result<OrgResultDTO> getAgencyInfo(@RequestBody OrgFormDTO formDTO);
/**
* desc: 获取网格基础数据
*
* @param customerGridFormDTO
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.CustomerGridDTO>
* @author LiuJanJun
* @date 2021/4/19 11:19 上午
*/
@PostMapping("/gov/org/grid/getbaseinfo")
Result<CustomerGridDTO> getGridBaseInfoByGridId(CustomerGridFormDTO customerGridFormDTO);
}

5
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java

@ -261,6 +261,11 @@ public class GovOrgOpenFeignClientFallback implements GovOrgOpenFeignClient {
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getAgencyInfo", formDTO);
}
@Override
public Result<CustomerGridDTO> getGridBaseInfoByGridId(CustomerGridFormDTO customerGridFormDTO) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getGridBaseInfoByGridId", customerGridFormDTO);
}
@Override
public Result<String> selectPidsByGridId(String gridId) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "selectPidsByGridId", gridId);

3
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/GridController.java

@ -179,6 +179,7 @@ public class GridController {
*/
@PostMapping("getbaseinfo")
public Result<CustomerGridDTO> getBaseInfo(@RequestBody CustomerGridFormDTO customerGridFormDTO) {
return customerGridService.getBaseInfo(customerGridFormDTO);
CustomerGridDTO gridInfo = customerGridService.getBaseInfo(customerGridFormDTO);
return new Result<CustomerGridDTO>().ok(gridInfo);
}
}

2
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java

@ -286,7 +286,7 @@ public interface CustomerGridService extends BaseService<CustomerGridEntity> {
* @author LiuJanJun
* @date 2021/4/19 11:53 上午
*/
Result<CustomerGridDTO> getBaseInfo(CustomerGridFormDTO customerGridFormDTO);
CustomerGridDTO getBaseInfo(CustomerGridFormDTO customerGridFormDTO);
/**
* @Description 根据网格ID查询pids

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

@ -17,6 +17,7 @@
package com.epmet.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
@ -26,6 +27,8 @@ import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils;
@ -77,6 +80,9 @@ public class CustomerGridServiceImpl extends BaseServiceImpl<CustomerGridDao, Cu
@Autowired
private CustomerGridDao customerGridDao;
@Autowired
private RedisUtils redisUtils;
@Override
public PageData<CustomerGridDTO> page(Map<String, Object> params) {
IPage<CustomerGridEntity> page = baseDao.selectPage(
@ -712,13 +718,23 @@ public class CustomerGridServiceImpl extends BaseServiceImpl<CustomerGridDao, Cu
}
@Override
public Result<CustomerGridDTO> getBaseInfo(CustomerGridFormDTO customerGridFormDTO) {
CustomerGridDTO restltDTO = ConvertUtils.sourceToTarget(baseDao.selectById(customerGridFormDTO.getGridId()), CustomerGridDTO.class);
if (null != restltDTO) {
CustomerAgencyEntity entity = customerAgencyService.selectById(restltDTO.getPid());
restltDTO.setAgencyName(null != entity ? entity.getOrganizationName() : "");
public CustomerGridDTO getBaseInfo(CustomerGridFormDTO customerGridFormDTO) {
String redisKey = RedisKeys.getGridByIdKey(customerGridFormDTO.getGridId());
Map<String, Object> gridCache = redisUtils.hGetAll(redisKey);
if (gridCache != null && gridCache.size() > 0) {
// 直接取缓存中的
CustomerGridDTO gridInfo = BeanUtil.mapToBean(gridCache, CustomerGridDTO.class, true);
return gridInfo;
}
return new Result<CustomerGridDTO>().ok(restltDTO);
CustomerGridDTO gridInfo = ConvertUtils.sourceToTarget(baseDao.selectById(customerGridFormDTO.getGridId()), CustomerGridDTO.class);
if (null != gridInfo) {
CustomerAgencyEntity entity = customerAgencyService.selectById(gridInfo.getPid());
gridInfo.setAgencyName(null != entity ? entity.getOrganizationName() : "");
}
redisUtils.hMSet(redisKey, BeanUtil.beanToMap(gridInfo));
return gridInfo;
}
/**

4
epmet-user/epmet-user-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java

@ -47,7 +47,7 @@ public interface GovOrgFeignClient {
* @author LiuJanJun
* @date 2021/4/19 11:19 上午
*/
@PostMapping("/gov/org/grid/getbaseinfo")
Result<CustomerGridDTO> getGridBaseInfoByGridId(CustomerGridFormDTO customerGridFormDTO);
//@PostMapping("/gov/org/grid/getbaseinfo")
//Result<CustomerGridDTO> getGridBaseInfoByGridId(CustomerGridFormDTO customerGridFormDTO);
}

8
epmet-user/epmet-user-server/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallBack.java

@ -29,8 +29,8 @@ public class GovOrgFeignClientFallBack implements GovOrgFeignClient {
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getGridStaffs", gridIdFormDTO);
}
@Override
public Result<CustomerGridDTO> getGridBaseInfoByGridId(CustomerGridFormDTO customerGridFormDTO) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getGridBaseInfoByGridId", customerGridFormDTO);
}
//@Override
//public Result<CustomerGridDTO> getGridBaseInfoByGridId(CustomerGridFormDTO customerGridFormDTO) {
// return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getGridBaseInfoByGridId", customerGridFormDTO);
//}
}

6
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/RegisterRelationServiceImpl.java

@ -40,6 +40,7 @@ import com.epmet.dto.result.UserRoleResultDTO;
import com.epmet.entity.RegisterRelationEntity;
import com.epmet.entity.UserCustomerEntity;
import com.epmet.feign.GovOrgFeignClient;
import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.service.GridVisitedService;
import com.epmet.service.RegisterRelationService;
import com.epmet.util.ModuleConstant;
@ -72,6 +73,9 @@ public class RegisterRelationServiceImpl extends BaseServiceImpl<RegisterRelatio
@Autowired
private GovOrgFeignClient govOrgFeignClient;
@Autowired
private GovOrgOpenFeignClient govOrgOpenFeignClient;
@Autowired
private UserCustomerDao userCustomerDao;
@ -299,7 +303,7 @@ public class RegisterRelationServiceImpl extends BaseServiceImpl<RegisterRelatio
private boolean setGridName(UserInfoOnEnterGridResultDTO resultObj, String gridId) {
CustomerGridFormDTO customerGridFormDTO = new CustomerGridFormDTO();
customerGridFormDTO.setGridId(gridId);
Result<CustomerGridDTO> gridDTOResult = govOrgFeignClient.getGridBaseInfoByGridId(customerGridFormDTO);
Result<CustomerGridDTO> gridDTOResult = govOrgOpenFeignClient.getGridBaseInfoByGridId(customerGridFormDTO);
if(gridDTOResult.success() && null != gridDTOResult.getData()){
resultObj.setCurrentGridName(gridDTOResult.getData().getGridName());
resultObj.setOrgId(resultObj.getCurrentGridId());

8
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffPatrolRecordServiceImpl.java

@ -24,6 +24,7 @@ import com.epmet.entity.StaffPatrolDetailEntity;
import com.epmet.entity.StaffPatrolRecordEntity;
import com.epmet.entity.StatsStaffPatrolRecordDailyEntity;
import com.epmet.feign.GovOrgFeignClient;
import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.feign.GovProjectOpenFeignClient;
import com.epmet.service.StaffPatrolDetailService;
import com.epmet.service.StaffPatrolRecordService;
@ -56,6 +57,9 @@ public class StaffPatrolRecordServiceImpl extends BaseServiceImpl<StaffPatrolRec
private StaffPatrolDetailService staffPatrolDetailService;
@Resource
private GovOrgFeignClient govOrgFeignClient;
// 这是是来自org-client的,以后都用这个就好了
@Autowired
private GovOrgOpenFeignClient govOrgOpenFeignClient;
@Autowired
private CustomerStaffDao customerStaffDao;
@ -106,7 +110,7 @@ public class StaffPatrolRecordServiceImpl extends BaseServiceImpl<StaffPatrolRec
if (PatrolConstant.PATROLLING.equals(entity.getStatus())) {
CustomerGridFormDTO customerGridFormDTO = new CustomerGridFormDTO();
customerGridFormDTO.setGridId(entity.getGrid());
Result<CustomerGridDTO> gridResult = govOrgFeignClient.getGridBaseInfoByGridId(customerGridFormDTO);
Result<CustomerGridDTO> gridResult = govOrgOpenFeignClient.getGridBaseInfoByGridId(customerGridFormDTO);
if (!gridResult.success() || null == gridResult.getData()) {
//查询网格名称失败
log.error(String.format("查找网格信息失败,网格Id:【%s】", entity.getGrid()));
@ -141,7 +145,7 @@ public class StaffPatrolRecordServiceImpl extends BaseServiceImpl<StaffPatrolRec
CustomerGridFormDTO customerGridFormDTO = new CustomerGridFormDTO();
customerGridFormDTO.setGridId(formDTO.getGridId());
Result<CustomerGridDTO> gridResult = govOrgFeignClient.getGridBaseInfoByGridId(customerGridFormDTO);
Result<CustomerGridDTO> gridResult = govOrgOpenFeignClient.getGridBaseInfoByGridId(customerGridFormDTO);
if (!gridResult.success() || null == gridResult.getData()) {
//查询网格名称失败
log.error(String.format("查找网格信息失败,网格Id:【%s】", formDTO.getGridId()));

Loading…
Cancel
Save