|
@ -17,14 +17,13 @@ |
|
|
|
|
|
|
|
|
package com.epmet.redis; |
|
|
package com.epmet.redis; |
|
|
|
|
|
|
|
|
import com.alibaba.druid.sql.visitor.functions.Concat; |
|
|
|
|
|
import com.epmet.commons.tools.constant.Constant; |
|
|
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
import com.epmet.commons.tools.redis.RedisUtils; |
|
|
import com.epmet.commons.tools.redis.RedisUtils; |
|
|
import com.epmet.constant.TagConstant; |
|
|
import com.epmet.constant.TagConstant; |
|
|
import com.epmet.dto.form.CorrelationTagListFormDto; |
|
|
import com.epmet.dto.form.CorrelationTagListFormDTO; |
|
|
import com.epmet.dto.result.CorrelationTagListResultDto; |
|
|
import com.epmet.dto.form.TagCascadeListFormDTO; |
|
|
import com.epmet.dto.result.TagInfoResultDto; |
|
|
import com.epmet.dto.result.CorrelationTagListResultDTO; |
|
|
|
|
|
import com.epmet.dto.result.TagInfoResultDTO; |
|
|
import com.fasterxml.jackson.databind.ObjectMapper; |
|
|
import com.fasterxml.jackson.databind.ObjectMapper; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Component; |
|
|
import org.springframework.stereotype.Component; |
|
@ -47,7 +46,13 @@ public class TagRedis { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public List<CorrelationTagListResultDto> get(String customerId, CorrelationTagListFormDto formDto){ |
|
|
/** |
|
|
|
|
|
* @Description 已发布列表页-获取关联标签——政府端 |
|
|
|
|
|
* @param customerId |
|
|
|
|
|
* @param formDto |
|
|
|
|
|
* @author zxc |
|
|
|
|
|
*/ |
|
|
|
|
|
public List<CorrelationTagListResultDTO> get(String customerId, CorrelationTagListFormDTO formDto){ |
|
|
List<String> tagIdList = formDto.getTagIdList(); |
|
|
List<String> tagIdList = formDto.getTagIdList(); |
|
|
Set<Object> objects ; |
|
|
Set<Object> objects ; |
|
|
Collection<String> keys = new ArrayList<>(); |
|
|
Collection<String> keys = new ArrayList<>(); |
|
@ -63,13 +68,13 @@ public class TagRedis { |
|
|
String key = TagConstant.GOV_RETAG_KEY+customerId+TagConstant.COLON+tagIdList.get(0); |
|
|
String key = TagConstant.GOV_RETAG_KEY+customerId+TagConstant.COLON+tagIdList.get(0); |
|
|
objects = redisUtils.sMembers(key); |
|
|
objects = redisUtils.sMembers(key); |
|
|
} |
|
|
} |
|
|
List<CorrelationTagListResultDto> resultList = new ArrayList<>(); |
|
|
List<CorrelationTagListResultDTO> resultList = new ArrayList<>(); |
|
|
if (objects.size()==NumConstant.ZERO){ |
|
|
if (objects.size()==NumConstant.ZERO){ |
|
|
return resultList; |
|
|
return resultList; |
|
|
} |
|
|
} |
|
|
ObjectMapper objectMapper = new ObjectMapper(); |
|
|
ObjectMapper objectMapper = new ObjectMapper(); |
|
|
for (Object object : objects) { |
|
|
for (Object object : objects) { |
|
|
CorrelationTagListResultDto correlationTag = objectMapper.convertValue(object, CorrelationTagListResultDto.class); |
|
|
CorrelationTagListResultDTO correlationTag = objectMapper.convertValue(object, CorrelationTagListResultDTO.class); |
|
|
resultList.add(correlationTag); |
|
|
resultList.add(correlationTag); |
|
|
} |
|
|
} |
|
|
return resultList; |
|
|
return resultList; |
|
@ -81,7 +86,7 @@ public class TagRedis { |
|
|
* @param key == customerId |
|
|
* @param key == customerId |
|
|
* @author zxc |
|
|
* @author zxc |
|
|
*/ |
|
|
*/ |
|
|
public List<TagInfoResultDto> zRevRange(String key){ |
|
|
public List<TagInfoResultDTO> zRevRange(String key){ |
|
|
long start = 0; |
|
|
long start = 0; |
|
|
long end = -1; |
|
|
long end = -1; |
|
|
String tagKey = TagConstant.GOV_TAG_KEY+key; |
|
|
String tagKey = TagConstant.GOV_TAG_KEY+key; |
|
@ -89,10 +94,10 @@ public class TagRedis { |
|
|
if (objects.size()== NumConstant.ZERO){ |
|
|
if (objects.size()== NumConstant.ZERO){ |
|
|
return new ArrayList<>(); |
|
|
return new ArrayList<>(); |
|
|
} |
|
|
} |
|
|
List<TagInfoResultDto> result = new ArrayList<TagInfoResultDto>(); |
|
|
List<TagInfoResultDTO> result = new ArrayList<TagInfoResultDTO>(); |
|
|
ObjectMapper objectMapper = new ObjectMapper(); |
|
|
ObjectMapper objectMapper = new ObjectMapper(); |
|
|
for (Object object : objects) { |
|
|
for (Object object : objects) { |
|
|
TagInfoResultDto tagInfoResultDto = objectMapper.convertValue(object, TagInfoResultDto.class); |
|
|
TagInfoResultDTO tagInfoResultDto = objectMapper.convertValue(object, TagInfoResultDTO.class); |
|
|
result.add(tagInfoResultDto); |
|
|
result.add(tagInfoResultDto); |
|
|
} |
|
|
} |
|
|
return result; |
|
|
return result; |
|
@ -103,7 +108,7 @@ public class TagRedis { |
|
|
* @param key == gridId |
|
|
* @param key == gridId |
|
|
* @author zxc |
|
|
* @author zxc |
|
|
*/ |
|
|
*/ |
|
|
public List<TagInfoResultDto> zGridRevRange(String key){ |
|
|
public List<TagInfoResultDTO> zGridRevRange(String key){ |
|
|
long start = 0; |
|
|
long start = 0; |
|
|
long end = -1; |
|
|
long end = -1; |
|
|
String tagKey = TagConstant.GRID_TAG_KEY+key; |
|
|
String tagKey = TagConstant.GRID_TAG_KEY+key; |
|
@ -111,13 +116,47 @@ public class TagRedis { |
|
|
if (objects.size()== NumConstant.ZERO){ |
|
|
if (objects.size()== NumConstant.ZERO){ |
|
|
return new ArrayList<>(); |
|
|
return new ArrayList<>(); |
|
|
} |
|
|
} |
|
|
List<TagInfoResultDto> result = new ArrayList<TagInfoResultDto>(); |
|
|
List<TagInfoResultDTO> result = new ArrayList<TagInfoResultDTO>(); |
|
|
ObjectMapper objectMapper = new ObjectMapper(); |
|
|
ObjectMapper objectMapper = new ObjectMapper(); |
|
|
for (Object object : objects) { |
|
|
for (Object object : objects) { |
|
|
TagInfoResultDto tagInfoResultDto = objectMapper.convertValue(object, TagInfoResultDto.class); |
|
|
TagInfoResultDTO tagInfoResultDto = objectMapper.convertValue(object, TagInfoResultDTO.class); |
|
|
result.add(tagInfoResultDto); |
|
|
result.add(tagInfoResultDto); |
|
|
} |
|
|
} |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @Description |
|
|
|
|
|
* @param formDto |
|
|
|
|
|
* @author zxc |
|
|
|
|
|
*/ |
|
|
|
|
|
public List<TagInfoResultDTO> getResiTag(TagCascadeListFormDTO formDto){ |
|
|
|
|
|
List<String> tagIdList = formDto.getTagIdList(); |
|
|
|
|
|
String gridId = formDto.getGridId(); |
|
|
|
|
|
Set<Object> objects ; |
|
|
|
|
|
Collection<String> keys = new ArrayList<>(); |
|
|
|
|
|
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; |
|
|
|
|
|
keys.add(tagId); |
|
|
|
|
|
} |
|
|
|
|
|
String key = TagConstant.GRID_RETAG_KEY+gridId+TagConstant.COLON+tagIdList.get(0); |
|
|
|
|
|
objects = redisUtils.sUnion(key, keys); |
|
|
|
|
|
}else { |
|
|
|
|
|
String key = TagConstant.GRID_RETAG_KEY+gridId+TagConstant.COLON+tagIdList.get(0); |
|
|
|
|
|
objects = redisUtils.sMembers(key); |
|
|
|
|
|
} |
|
|
|
|
|
List<TagInfoResultDTO> resultList = new ArrayList<>(); |
|
|
|
|
|
if (objects.size()==NumConstant.ZERO){ |
|
|
|
|
|
return resultList; |
|
|
|
|
|
} |
|
|
|
|
|
ObjectMapper objectMapper = new ObjectMapper(); |
|
|
|
|
|
for (Object object : objects) { |
|
|
|
|
|
TagInfoResultDTO tagInfo = objectMapper.convertValue(object, TagInfoResultDTO.class); |
|
|
|
|
|
resultList.add(tagInfo); |
|
|
|
|
|
} |
|
|
|
|
|
return resultList; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |