|
|
@ -21,6 +21,8 @@ import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.redis.RedisUtils; |
|
|
|
import com.epmet.constant.GovIssueRedisKeys; |
|
|
|
import com.epmet.dto.result.IssueCategoryTagResultDTO; |
|
|
|
import com.epmet.utils.ModuleConstants; |
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
@ -33,10 +35,7 @@ import org.springframework.lang.Nullable; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
@ -99,21 +98,42 @@ public class IssueProjectTagDictRedis { |
|
|
|
},redisTemplate.getValueSerializer()); |
|
|
|
//热度Map 分数为key
|
|
|
|
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; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
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){ |
|
|
|
//TODO 补偿机制
|
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
@ -153,4 +173,9 @@ public class IssueProjectTagDictRedis { |
|
|
|
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; |
|
|
|
} |
|
|
|
} |