|
|
@ -19,15 +19,20 @@ package com.epmet.modules.group.redis; |
|
|
|
|
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.redis.RedisKeys; |
|
|
|
import com.epmet.commons.tools.redis.RedisUtils; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.dto.BizPointTotalDetailDTO; |
|
|
|
import com.epmet.dto.form.GroupPointFormDTO; |
|
|
|
import com.epmet.dto.result.UserBaseInfoResultDTO; |
|
|
|
import com.epmet.feign.EpmetPointOpenFeignClient; |
|
|
|
import com.epmet.feign.EpmetUserOpenFeignClient; |
|
|
|
import com.epmet.modules.constant.ResiGroupRedisKeys; |
|
|
|
import com.epmet.modules.group.service.ResiGroupService; |
|
|
|
import com.epmet.modules.group.service.ResiGroupStatisticalService; |
|
|
|
import com.epmet.modules.support.GroupLevelUtils; |
|
|
|
import com.epmet.modules.utils.ModuleConstant; |
|
|
|
import com.epmet.resi.group.constant.TopicConstant; |
|
|
|
import com.epmet.resi.group.dto.group.ResiGroupDTO; |
|
|
@ -64,6 +69,8 @@ public class ResiGroupRedis { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private EpmetUserOpenFeignClient epmetUserOpenFeignClient; |
|
|
|
@Autowired |
|
|
|
private EpmetPointOpenFeignClient epmetPointOpenFeignClient; |
|
|
|
|
|
|
|
|
|
|
|
public void delete(Object[] ids) { |
|
|
@ -92,16 +99,37 @@ public class ResiGroupRedis { |
|
|
|
public ResiGroupInfoRedisDTO get(String groupId){ |
|
|
|
|
|
|
|
if(StringUtils.isNotBlank(groupId)){ |
|
|
|
GroupPointFormDTO groupPointFormDTO = new GroupPointFormDTO(); |
|
|
|
groupPointFormDTO.setGroupId(groupId); |
|
|
|
Result<BizPointTotalDetailDTO> bizPointTotalDetailResult = epmetPointOpenFeignClient.getGroupPoint(groupPointFormDTO); |
|
|
|
if (!bizPointTotalDetailResult.success()) { |
|
|
|
throw new RenException(bizPointTotalDetailResult.getCode(), bizPointTotalDetailResult.getMsg()); |
|
|
|
} |
|
|
|
Integer level = 1; |
|
|
|
if (null != bizPointTotalDetailResult.getData()) { |
|
|
|
level = GroupLevelUtils.getLevel(bizPointTotalDetailResult.getData().getTotalPoint()); |
|
|
|
if (null == level) { |
|
|
|
level = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
ResiGroupDTO groupMySql = groupService.get(groupId); |
|
|
|
|
|
|
|
if (!level.equals(groupMySql.getLevel())) { |
|
|
|
ResiGroupDTO dto = new ResiGroupDTO(); |
|
|
|
dto.setId(groupMySql.getId()); |
|
|
|
dto.setLevel(level); |
|
|
|
groupService.update(dto); |
|
|
|
} |
|
|
|
|
|
|
|
ResiGroupInfoRedisDTO groupCache = (ResiGroupInfoRedisDTO) |
|
|
|
redisUtils.get(ResiGroupRedisKeys.getResiGroupInfoKey(groupId)); |
|
|
|
if(null == groupCache || StringUtils.isBlank(groupCache.getGroupId()) || null == groupCache.getGroupStatisticalInfo()){ |
|
|
|
//如果缓存中没有该组信息,从数据库中查询并放入缓存
|
|
|
|
ResiGroupDTO groupMySql = groupService.get(groupId); |
|
|
|
if(null != groupMySql && StringUtils.isNotBlank(groupMySql.getId())){ |
|
|
|
if(StringUtils.isNotBlank(groupMySql.getId())){ |
|
|
|
ResiGroupInfoRedisDTO groupRedis = ConvertUtils.sourceToTarget(groupMySql,ResiGroupInfoRedisDTO.class); |
|
|
|
groupRedis.setGroupId(groupMySql.getId()); |
|
|
|
groupRedis.setGroupState(groupMySql.getState()); |
|
|
|
groupRedis.setLevel("LV" + groupMySql.getLevel()); |
|
|
|
groupRedis.setLevel("LV" + level); |
|
|
|
Map<String,Object> param = new HashMap<>(); |
|
|
|
param.put(TopicConstant.RESI_GROUP_ID,groupId); |
|
|
|
param.put(FieldConstant.DEL_FLAG, NumConstant.ZERO_STR); |
|
|
@ -127,6 +155,9 @@ public class ResiGroupRedis { |
|
|
|
//返回数据
|
|
|
|
return groupRedis; |
|
|
|
} |
|
|
|
} else { |
|
|
|
groupCache.setLevel("LV" + level); |
|
|
|
set(groupCache); |
|
|
|
} |
|
|
|
return groupCache; |
|
|
|
} |
|
|
|