Browse Source

自定义标签类别Id常量

dev_shibei_match
wangchao 5 years ago
parent
commit
e4c97e6823
  1. 45
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/redis/IssueProjectTagDictRedis.java
  2. 4
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/utils/ModuleConstants.java

45
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/redis/IssueProjectTagDictRedis.java

@ -21,6 +21,8 @@ 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.GovIssueRedisKeys; import com.epmet.constant.GovIssueRedisKeys;
import com.epmet.dto.result.IssueCategoryTagResultDTO; import com.epmet.dto.result.IssueCategoryTagResultDTO;
import com.epmet.utils.ModuleConstants;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -33,10 +35,7 @@ import org.springframework.lang.Nullable;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.util.HashMap; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -99,21 +98,42 @@ public class IssueProjectTagDictRedis {
},redisTemplate.getValueSerializer()); },redisTemplate.getValueSerializer());
//热度Map 分数为key //热度Map 分数为key
Map<Double,List<IssueCategoryTagResultDTO>> heatMap = new HashMap<>(); Map<Double,List<IssueCategoryTagResultDTO>> heatMap = new HashMap<>();
if(CollectionUtils.isEmpty(heatTuple)){ if(!CollectionUtils.isEmpty(heatTuple)){
heatTuple.forEach(tupleSet -> {
tupleSet.forEach( tuple -> {
IssueCategoryTagResultDTO entity = parseObject(tuple.getValue(),IssueCategoryTagResultDTO.class);
Double heatScore = tuple.getScore();
List<IssueCategoryTagResultDTO> queue = heatMap.get(heatScore);
if(CollectionUtils.isEmpty(queue)) queue = new LinkedList<>();
queue.add(entity);
} );
});
List<IssueCategoryTagResultDTO> result = new LinkedList<>();
heatMap.keySet().stream().sorted(Comparator.reverseOrder()).collect(Collectors.toList()).forEach(count -> {
result.addAll(heatMap.get(count));
});
return result;
} }
log.warn("fetch customer govern tag cache blankly , customerId:{} , now begin compensation...",customerId); if(CollectionUtils.isEmpty(keys) || !keys.iterator().next().contains(ModuleConstants.CUSTOMIZED_TAG_CATEGORY_ID)) {
log.warn("fetch customer govern tag cache blankly , customerId:{} , now begin compensation...", customerId);
List<IssueCategoryTagResultDTO> compensate = compensate(customerId, category); List<IssueCategoryTagResultDTO> compensate = compensate(customerId, category);
if(CollectionUtils.isEmpty(compensate)) {log.error("compensation failure or there is no default tag data in database !!"); return null;}
else{log.warn("compensation completed !!"); return compensate;}
if (CollectionUtils.isEmpty(compensate)) {
log.error("compensation failure or there is no default tag data in database !!");
return null;
} else {
log.warn("compensation completed !!");
return compensate;
}
}return null;
} }
public List<IssueCategoryTagResultDTO> compensate(String customerId,List<String> category){ public List<IssueCategoryTagResultDTO> compensate(String customerId,List<String> category){
//TODO 补偿机制 //TODO 补偿机制
return null; return null;
} }
@ -153,4 +173,9 @@ public class IssueProjectTagDictRedis {
redisUtils.zSetAdd(key,o); redisUtils.zSetAdd(key,o);
} }
public <T> T parseObject(Object o,Class<T> clazz){
ObjectMapper objectMapper = new ObjectMapper();
T t = objectMapper.convertValue(o, clazz);
return t;
}
} }

4
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/utils/ModuleConstants.java

@ -156,4 +156,8 @@ public interface ModuleConstants {
String ISSUE_ACTION_REJECT = "驳回"; String ISSUE_ACTION_REJECT = "驳回";
String ASTERISK = "*"; String ASTERISK = "*";
/**
* 自定义标签类别缺省值
*/
String CUSTOMIZED_TAG_CATEGORY_ID = "customize";
} }

Loading…
Cancel
Save