|
|
@ -88,14 +88,14 @@ public class TagRedis { |
|
|
|
if (tagIdList.size() > 1){ |
|
|
|
for (int i = NumConstant.ONE; i < tagIdList.size(); i++) { |
|
|
|
String tagId = tagIdList.get(i); |
|
|
|
tagId = TagConstant.GOV_RETAG_KEY+customerId+TagConstant.COLON+tagId; |
|
|
|
tagId = RedisKeys.getCustomerReTagKey(customerId,tagId); |
|
|
|
keys.add(tagId); |
|
|
|
} |
|
|
|
String key = TagConstant.GOV_RETAG_KEY+customerId+TagConstant.COLON+tagIdList.get(0); |
|
|
|
String key = RedisKeys.getCustomerReTagKey(customerId,tagIdList.get(0)); |
|
|
|
objects = redisUtils.intersect(key, keys); |
|
|
|
}else { |
|
|
|
// 查询关联标签数量 等于1条时
|
|
|
|
String key = TagConstant.GOV_RETAG_KEY+customerId+TagConstant.COLON+tagIdList.get(0); |
|
|
|
String key = RedisKeys.getCustomerReTagKey(customerId,tagIdList.get(0)); |
|
|
|
objects = redisUtils.sMembers(key); |
|
|
|
} |
|
|
|
List<CorrelationTagListResultDTO> resultList = new ArrayList<>(); |
|
|
@ -113,7 +113,7 @@ public class TagRedis { |
|
|
|
if (resultList.size() > NumConstant.ZERO) { |
|
|
|
long start = 0; |
|
|
|
long end = -1; |
|
|
|
String customerKey = TagConstant.GOV_TAG_KEY + customerId; |
|
|
|
String customerKey = RedisKeys.getCustomerTagKey(customerId); |
|
|
|
Set<ZSetOperations.TypedTuple<Object>> typedTuples = redisUtils.zReverseRangeWithScores(customerKey, start, end); |
|
|
|
for (CorrelationTagListResultDTO correlationTagList : resultList) { |
|
|
|
for (ZSetOperations.TypedTuple<Object> typedTuple : typedTuples) { |
|
|
@ -145,7 +145,7 @@ public class TagRedis { |
|
|
|
public List<TagInfoResultDTO> zRevRange(String key){ |
|
|
|
long start = 0; |
|
|
|
long end = -1; |
|
|
|
String tagKey = TagConstant.GOV_TAG_KEY+key; |
|
|
|
String tagKey = RedisKeys.getCustomerTagKey(key); |
|
|
|
Set<Object> objects = redisUtils.zRevRange(tagKey, start, end); |
|
|
|
if (objects.size()== NumConstant.ZERO){ |
|
|
|
return new ArrayList<>(); |
|
|
@ -166,7 +166,7 @@ public class TagRedis { |
|
|
|
public List<TagInfoResultDTO> zGridRevRange(String key){ |
|
|
|
long start = 0; |
|
|
|
long end = -1; |
|
|
|
String tagKey = TagConstant.GRID_TAG_KEY+key; |
|
|
|
String tagKey = RedisKeys.getGridTagKey(key); |
|
|
|
Set<Object> objects = redisUtils.zRevRange(tagKey, start, end); |
|
|
|
if (objects.size()== NumConstant.ZERO){ |
|
|
|
return new ArrayList<>(); |
|
|
@ -192,14 +192,14 @@ public class TagRedis { |
|
|
|
if (tagIdList.size() > 1){ |
|
|
|
for (int i = NumConstant.ONE; i < tagIdList.size(); i++) { |
|
|
|
String tagId = tagIdList.get(i); |
|
|
|
tagId = TagConstant.GRID_RETAG_KEY+gridId+TagConstant.COLON+tagId; |
|
|
|
tagId = RedisKeys.getGridReTagKey(gridId,tagId); |
|
|
|
keys.add(tagId); |
|
|
|
} |
|
|
|
String key = TagConstant.GRID_RETAG_KEY+gridId+TagConstant.COLON+tagIdList.get(0); |
|
|
|
String key = RedisKeys.getGridReTagKey(gridId,tagIdList.get(0)); |
|
|
|
objects = redisUtils.intersect(key, keys); |
|
|
|
}else { |
|
|
|
//当级联标签为一条时
|
|
|
|
String key = TagConstant.GRID_RETAG_KEY+gridId+TagConstant.COLON+tagIdList.get(0); |
|
|
|
String key = RedisKeys.getGridReTagKey(gridId,tagIdList.get(0)); |
|
|
|
objects = redisUtils.sMembers(key); |
|
|
|
} |
|
|
|
List<TagInfoResultDTO> resultList = new ArrayList<>(); |
|
|
@ -216,8 +216,9 @@ public class TagRedis { |
|
|
|
if (resultList.size() > NumConstant.ZERO) { |
|
|
|
long start = 0; |
|
|
|
long end = -1; |
|
|
|
String customerKey = TagConstant.GRID_TAG_KEY+formDto.getGridId(); |
|
|
|
Set<ZSetOperations.TypedTuple<Object>> typedTuples = redisUtils.zReverseRangeWithScores(customerKey, start, end); |
|
|
|
String gridTagKey =RedisKeys.getGridTagKey(formDto.getGridId()); |
|
|
|
|
|
|
|
Set<ZSetOperations.TypedTuple<Object>> typedTuples = redisUtils.zReverseRangeWithScores(gridTagKey, start, end); |
|
|
|
for (TagInfoResultDTO tagInfo : resultList) { |
|
|
|
for (ZSetOperations.TypedTuple<Object> typedTuple : typedTuples) { |
|
|
|
TagRankResultDTO tagRank = objectToDTO(typedTuple.getValue(), TagRankResultDTO.class); |
|
|
@ -291,14 +292,11 @@ public class TagRedis { |
|
|
|
public void updateMoreTag(String key, Set<UpdateTagUseCountsResultDTO> value) { |
|
|
|
try { |
|
|
|
log.info(TagConstant.BEGIN_UPDATE); |
|
|
|
redisTemplate.executePipelined(new RedisCallback<Set<UpdateTagUseCountsResultDTO>>() { |
|
|
|
@Override |
|
|
|
public Set doInRedis(RedisConnection connection) throws DataAccessException { |
|
|
|
redisTemplate.executePipelined((RedisCallback<Set<UpdateTagUseCountsResultDTO>>) connection -> { |
|
|
|
for (UpdateTagUseCountsResultDTO tag : value) { |
|
|
|
connection.sAdd(redisTemplate.getKeySerializer().serialize(key),redisTemplate.getValueSerializer().serialize(tag)); |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
}); |
|
|
|
log.info(TagConstant.SUCCESS_UPDATE); |
|
|
|
}catch (Exception e){ |
|
|
|