Commit 138f137e by shenjunjie

品见项目预警模块上测试环境

parent c047b2e2
package com.zhiwei.brandkbs2.common;
import com.zhiwei.brandkbs2.auth.UserThreadLocal;
import com.zhiwei.brandkbs2.util.Tools;
import java.util.Objects;
......@@ -82,6 +83,19 @@ public class RedisKeyPrefix {
*/
private static final String EVENT_ANALYZE_PROGRESS = "BRANDKBS:EVENT:ANALYZE:PROGRESS:";
/**
* 项目预警相关缓存
*/
public static final String PROJECT_WARN_HOT_TOP = "BRANDKBS:HOT_TOP:";
public static String projectWarnHotTopKeyAll(String projectId, String type) {
return RedisKeyPrefix.generateRedisKey(RedisKeyPrefix.PROJECT_WARN_HOT_TOP, projectId, Tools.concat(type, "*"));
}
public static String projectWarnHotTopKey(String projectId, String type, String name) {
return RedisKeyPrefix.generateRedisKey(RedisKeyPrefix.PROJECT_WARN_HOT_TOP, projectId, Tools.concat(type, name));
}
public static String eventAnalysisProgress(String eventId, String projectId) {
return RedisKeyPrefix.generateRedisKey(RedisKeyPrefix.EVENT_ANALYZE_PROGRESS, projectId, eventId);
}
......
package com.zhiwei.brandkbs2.pojo.external;
import com.alibaba.fastjson.JSONObject;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;
/**
......@@ -51,6 +54,17 @@ public class BrandkbsHotTopWarn {
* 上榜时间
*/
private Long time;
public static HotTop createFromJSON(JSONObject json, String topReason, String topName) {
HotTop hotTop = new HotTop();
hotTop.setTitle(json.getString("name"));
hotTop.setTopReason(topReason);
hotTop.setRank(json.getString("lastRank") + "名");
hotTop.setHot(BigDecimal.valueOf(json.getLongValue("lastCount") / 10000.00).setScale(2, RoundingMode.UP) + "w");
hotTop.setTopName(topName);
hotTop.setTime(json.getLong("endTime"));
return hotTop;
}
}
}
......@@ -5,6 +5,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import java.util.Set;
import java.util.concurrent.TimeUnit;
/**
......@@ -74,6 +75,10 @@ public class RedisUtil {
return stringRedisTemplate.opsForValue().get(key);
}
public Set<String> keys(String key) {
return stringRedisTemplate.keys(key);
}
public void remove(String key) {
setExpire(key, "-1", 1, TimeUnit.SECONDS);
}
......
......@@ -884,6 +884,34 @@ public class Tools {
return false;
}
public static boolean isExclusive(String keyword, String content) {
return isExclusive(Arrays.asList(keyword.split("\\|")), content);
}
/**
* 是否排除关键字 只有或逻辑
*
* @param filterKeywords 排除关键词
* @param data 字符串标题+内容
* @return 是否包含关键字
*/
public static boolean isExclusive(List<String> filterKeywords, String data) {
boolean exclusive = true;
for (String key : filterKeywords) {
if(StringUtils.isBlank(key)){
continue;
}
if (data.contains(key.toLowerCase())) {
exclusive=false;
}
if (!exclusive) {
//已经满足条件,视为有效数据,结束循环
break;
}
}
return exclusive;
}
public static JSONObject getBrandkbsHitMap(Map<String, Object> esMap, String hitKey) {
List<Map<String, Object>> cacheMaps = (List<Map<String, Object>>) esMap.get(GenericAttribute.ES_BRANDKBS_CACHE_MAPS);
for (Map<String, Object> cacheMap : cacheMaps) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment