From 75f33e47d8e232bae7b1426519c48a01e206e335 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Fri, 29 Oct 2021 14:18:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=A1=A8=E5=8D=95=E6=94=BEre?= =?UTF-8?q?dis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/commons/tools/redis/RedisKeys.java | 10 ++++++++ .../com/epmet/redis/CustomerFootBarRedis.java | 25 +++++++++++++++++++ .../epmet/service/impl/IcFormServiceImpl.java | 13 +++++++--- 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java index fe293c5288..9b7a7afccb 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java @@ -579,4 +579,14 @@ public class RedisKeys { public static String loginTicket(String app, String ticket) { return rootPrefix.concat("sys:security:ticket:").concat(app).concat(":").concat(ticket); } + + /** + * 政府端机关单位缓存Key + * @param formCode + * @param customerId + * @return + */ + public static String getIcFormKey(String formCode,String customerId) { + return rootPrefix.concat("icform:").concat(formCode).concat(":").concat(customerId); + } } diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/redis/CustomerFootBarRedis.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/redis/CustomerFootBarRedis.java index 1d120429d8..8cded15b44 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/redis/CustomerFootBarRedis.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/redis/CustomerFootBarRedis.java @@ -17,9 +17,15 @@ package com.epmet.redis; +import cn.hutool.core.bean.BeanUtil; +import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisUtils; +import com.epmet.dto.result.CustomerFormResultDTO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.util.Map; /** * APP底部菜单栏信息 @@ -44,4 +50,23 @@ public class CustomerFootBarRedis { return null; } + public void deleteIcForm(String formCode,String customerId) { + String key = RedisKeys.getIcFormKey(formCode,customerId); + redisUtils.delete(key); + } + + public void setCustomerFormResultDTO(String formCode,String customerId, CustomerFormResultDTO value){ + String key = RedisKeys.getIcFormKey(formCode,customerId); + Map map = BeanUtil.beanToMap(value, false, true); + redisUtils.hMSet(key, map); + } + + public CustomerFormResultDTO getCustomerFormResultDTO(String formCode,String customerId){ + String key = RedisKeys.getIcFormKey(formCode,customerId); + Map resultMap = redisUtils.hGetAll(key); + if (CollectionUtils.isEmpty(resultMap)) { + return null; + } + return BeanUtil.mapToBean(resultMap, CustomerFormResultDTO.class, true); + } } \ No newline at end of file diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcFormServiceImpl.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcFormServiceImpl.java index 6a4d8a426c..f7cf1fe235 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcFormServiceImpl.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcFormServiceImpl.java @@ -32,8 +32,10 @@ import com.epmet.dto.result.CustomerFormResultDTO; import com.epmet.dto.result.FormGroupDTO; import com.epmet.dto.result.FormItem; import com.epmet.entity.IcFormEntity; +import com.epmet.redis.CustomerFootBarRedis; import com.epmet.service.IcFormService; import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -49,7 +51,8 @@ import java.util.Map; */ @Service public class IcFormServiceImpl extends BaseServiceImpl implements IcFormService { - + @Autowired + private CustomerFootBarRedis customerFootBarRedis; @Override public PageData page(Map params) { @@ -113,17 +116,19 @@ public class IcFormServiceImpl extends BaseServiceImpl */ @Override public CustomerFormResultDTO getCustomerForm(CustomerFormQueryDTO formDto) { - //todo + CustomerFormResultDTO customerFormResultDTO = customerFootBarRedis.getCustomerFormResultDTO(formDto.getFormCode(), formDto.getCustomerId()); + if (null != customerFormResultDTO) { + return customerFormResultDTO; + } CustomerFormResultDTO resultDTO=baseDao.selectByCode(formDto.getCustomerId(),formDto.getFormCode()); if (null == resultDTO) { throw new RenException(EpmetErrorCode.CUSTOMER_FORM_NOT_EXITS.getCode(),EpmetErrorCode.CUSTOMER_FORM_NOT_EXITS.getMsg()); } List itemList=baseDao.selectItemList(resultDTO.getFormId(),formDto.getDynamic()); List groupList=baseDao.selectListGroup(resultDTO.getFormId()); - resultDTO.setItemList(itemList); resultDTO.setGroupList(groupList); + customerFootBarRedis.setCustomerFormResultDTO(formDto.getFormCode(),formDto.getCustomerId(),resultDTO); return resultDTO; } - }