diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/ScreenProjectDetailResultDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/ScreenProjectDetailResultDTO.java index 287703b6ef..ece032ba4d 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/ScreenProjectDetailResultDTO.java +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/ScreenProjectDetailResultDTO.java @@ -26,7 +26,7 @@ public class ScreenProjectDetailResultDTO implements Serializable { */ private String projectId; /** - * 项目标题 + * 项目标题,06.25新增,工作端小程序难点赌点+群众不满详情用 */ private String projectTitle; @@ -73,7 +73,7 @@ public class ScreenProjectDetailResultDTO implements Serializable { private List processList; /** - * 满意度得分 + * 满意度得分 06.25新增,这个返参目前大屏和工作端小程序都没有用到,工作端小程序详情的得分是取得列表返回去的值 */ private BigDecimal score; diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/redis/DataReportRedis.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/redis/DataReportRedis.java new file mode 100644 index 0000000000..f9bdc24a1e --- /dev/null +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/redis/DataReportRedis.java @@ -0,0 +1,39 @@ +package com.epmet.datareport.redis; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.map.MapUtil; +import com.epmet.commons.tools.redis.RedisUtils; +import com.epmet.dto.result.AgencyDetailMulticResultDTO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.Map; + +/** + * 描述一下 + * + * @author yinzuomei@elink-cn.com + * @date 2021/6/29 15:46 + */ +@Component +public class DataReportRedis { + @Autowired + private RedisUtils redisUtils; + private String agencyDetailKeyPrefix="epmet:screen:"; + + public AgencyDetailMulticResultDTO queryAgencyDetailMulticResultDTO(String customerId, String agencyId) { + String agencyDetailKey=agencyDetailKeyPrefix.concat(customerId).concat(":").concat(agencyId); + Map map = redisUtils.hGetAll(agencyDetailKey); + if (MapUtil.isEmpty(map)) { + return null; + } + AgencyDetailMulticResultDTO dto = BeanUtil.mapToBean(map, AgencyDetailMulticResultDTO.class, true); + return dto; + } + + public void setAgencyDetailMulticResultDTO(String customerId, String agencyId, AgencyDetailMulticResultDTO agencysResultDTO) { + String agencyDetailKey = agencyDetailKeyPrefix.concat(customerId).concat(":").concat(agencyId); + Map map = BeanUtil.beanToMap(agencysResultDTO); + redisUtils.hMSet(agencyDetailKey, map, RedisUtils.DEFAULT_EXPIRE); + } +} diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/AgencyServiceImpl.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/AgencyServiceImpl.java index 1d039d9f01..d8c9efc155 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/AgencyServiceImpl.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/AgencyServiceImpl.java @@ -12,6 +12,7 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.constant.DataSourceConstant; import com.epmet.datareport.dao.evaluationindex.screen.ScreenCustomerAgencyDao; import com.epmet.datareport.dao.evaluationindex.screen.ScreenCustomerGridDao; +import com.epmet.datareport.redis.DataReportRedis; import com.epmet.datareport.service.evaluationindex.screen.AgencyService; import com.epmet.dto.AgencyInfoDTO; import com.epmet.dto.ScreenCustomerGridDTO; @@ -67,6 +68,8 @@ public class AgencyServiceImpl implements AgencyService { private GovOrgOpenFeignClient govOrgOpenFeignClient; @Autowired private OperCrmOpenFeignClient operCrmOpenFeignClient; + @Autowired + private DataReportRedis dataReportRedis; /** * @Description 1、组织机构树 @@ -371,7 +374,12 @@ public class AgencyServiceImpl implements AgencyService { @DataSource(value = DataSourceConstant.EVALUATION_INDEX,datasourceNameFromArg = true) @Override public AgencyDetailMulticResultDTO queryAgencyDetailMultiC(AgencyDetailMulticFormDTO formDTO) { - AgencyDetailMulticResultDTO agencysResultDTO = new AgencyDetailMulticResultDTO(); + AgencyDetailMulticResultDTO agencysResultDTO =dataReportRedis.queryAgencyDetailMulticResultDTO(formDTO.getCustomerId(),formDTO.getAgencyId()); + if (null != agencysResultDTO) { + log.info("queryAgencyDetailMultiC从redis取值入参:"+ JSON.toJSONString(formDTO)); + return agencysResultDTO; + } + agencysResultDTO = new AgencyDetailMulticResultDTO(); List parentList = new ArrayList<>(); agencysResultDTO.setParentList(parentList); @@ -405,7 +413,6 @@ public class AgencyServiceImpl implements AgencyService { if(agencysResultDTO.getHaveSubCustomer()){ // 5、多客户时根据area_code查询上级,自下向上,查询到当前客户的跟组织即可stop - // TODO log.info("多客户版本parentList、level要重新赋值"); ScreenCustomerAgencyDTO parentAgency=screenCustomerAgencyDao.selectByAreaCode(agencysResultDTO.getParentAreaCode()); agencysResultDTO.setLevel(getAgencyLevelMultiC(parentAgency)); @@ -429,6 +436,7 @@ public class AgencyServiceImpl implements AgencyService { agencysResultDTO.setParentList(screenCustomerAgencyDao.selectPAgencyById(pidList)); } } + dataReportRedis.setAgencyDetailMulticResultDTO(formDTO.getCustomerId(),formDTO.getAgencyId(),agencysResultDTO); return agencysResultDTO; } diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/redis/CustomerRedis.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/redis/CustomerRedis.java index 63ad887526..2911420fe3 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/redis/CustomerRedis.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/redis/CustomerRedis.java @@ -17,10 +17,15 @@ package com.epmet.redis; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.map.MapUtil; import com.epmet.commons.tools.redis.RedisUtils; +import com.epmet.dto.CustomerDTO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.util.Map; + /** * 客户表 * @@ -32,6 +37,11 @@ public class CustomerRedis { @Autowired private RedisUtils redisUtils; + /** + * 客户信息rediskey前缀 + */ + private String customerInfoKeyPref="epmet:customer:info:"; + public void delete(Object[] ids) { } @@ -44,4 +54,26 @@ public class CustomerRedis { return null; } + + /** + * 查询客户基本信息 + */ + public CustomerDTO queryCustomerInfo(String customerId) { + String customerInfoKey=customerInfoKeyPref.concat(customerId); + Map customerDtoMap = redisUtils.hGetAll(customerInfoKey); + if (MapUtil.isEmpty(customerDtoMap)) { + return null; + } + CustomerDTO customerDTO = BeanUtil.mapToBean(customerDtoMap, CustomerDTO.class, true); + return customerDTO; + } + + /** + * 将客户基本信息放到redis,有效期一天 + */ + public void saveCustomerInfo(String customerId, CustomerDTO data) { + String customerInfoKey = customerInfoKeyPref.concat(customerId); + Map customerDtoMap = BeanUtil.beanToMap(data); + redisUtils.hMSet(customerInfoKey, customerDtoMap,RedisUtils.DEFAULT_EXPIRE); + } } \ No newline at end of file diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerRelationServiceImpl.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerRelationServiceImpl.java index 72727b7f22..6a3a82127d 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerRelationServiceImpl.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerRelationServiceImpl.java @@ -27,14 +27,20 @@ import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.dao.CustomerRelationDao; +import com.epmet.dto.CustomerDTO; import com.epmet.dto.CustomerRelationDTO; import com.epmet.entity.CustomerRelationEntity; +import com.epmet.redis.CustomerRedis; import com.epmet.service.CustomerRelationService; +import com.epmet.service.CustomerService; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -48,6 +54,10 @@ import java.util.Map; @Slf4j @Service public class CustomerRelationServiceImpl extends BaseServiceImpl implements CustomerRelationService { + @Autowired + private CustomerRedis customerRedis; + @Autowired + private CustomerService customerService; @Override public PageData page(Map params) { @@ -146,7 +156,18 @@ public class CustomerRelationServiceImpl extends BaseServiceImpl getAllSubCustomerIds(String customerId) { - return baseDao.selectAllSubCustomerIds(customerId); + CustomerDTO customerDTO = customerRedis.queryCustomerInfo(customerId); + if (null != customerDTO) { + return customerDTO.getSubCustomerIds(); + } + CustomerDTO data = customerService.get(customerId); + if (null != data) { + data.setSubCustomerIds(baseDao.selectAllSubCustomerIds(customerId)); + data.setHaveSubCustomer(CollectionUtils.isNotEmpty(data.getSubCustomerIds()) ? true : false); + customerRedis.saveCustomerInfo(customerId, data); + return data.getSubCustomerIds(); + } + return new ArrayList<>(); } } \ No newline at end of file