Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
brandkbs2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
shenjunjie
brandkbs2
Commits
138f137e
Commit
138f137e
authored
Nov 14, 2022
by
shenjunjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
品见项目预警模块上测试环境
parent
c047b2e2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
0 deletions
+61
-0
src/main/java/com/zhiwei/brandkbs2/common/RedisKeyPrefix.java
+14
-0
src/main/java/com/zhiwei/brandkbs2/pojo/external/BrandkbsHotTopWarn.java
+14
-0
src/main/java/com/zhiwei/brandkbs2/service/impl/ProjectWarnServiceImpl.java
+0
-0
src/main/java/com/zhiwei/brandkbs2/util/RedisUtil.java
+5
-0
src/main/java/com/zhiwei/brandkbs2/util/Tools.java
+28
-0
No files found.
src/main/java/com/zhiwei/brandkbs2/common/RedisKeyPrefix.java
View file @
138f137e
package
com
.
zhiwei
.
brandkbs2
.
common
;
package
com
.
zhiwei
.
brandkbs2
.
common
;
import
com.zhiwei.brandkbs2.auth.UserThreadLocal
;
import
com.zhiwei.brandkbs2.auth.UserThreadLocal
;
import
com.zhiwei.brandkbs2.util.Tools
;
import
java.util.Objects
;
import
java.util.Objects
;
...
@@ -82,6 +83,19 @@ public class RedisKeyPrefix {
...
@@ -82,6 +83,19 @@ public class RedisKeyPrefix {
*/
*/
private
static
final
String
EVENT_ANALYZE_PROGRESS
=
"BRANDKBS:EVENT:ANALYZE:PROGRESS:"
;
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
)
{
public
static
String
eventAnalysisProgress
(
String
eventId
,
String
projectId
)
{
return
RedisKeyPrefix
.
generateRedisKey
(
RedisKeyPrefix
.
EVENT_ANALYZE_PROGRESS
,
projectId
,
eventId
);
return
RedisKeyPrefix
.
generateRedisKey
(
RedisKeyPrefix
.
EVENT_ANALYZE_PROGRESS
,
projectId
,
eventId
);
}
}
...
...
src/main/java/com/zhiwei/brandkbs2/pojo/external/BrandkbsHotTopWarn.java
View file @
138f137e
package
com
.
zhiwei
.
brandkbs2
.
pojo
.
external
;
package
com
.
zhiwei
.
brandkbs2
.
pojo
.
external
;
import
com.alibaba.fastjson.JSONObject
;
import
lombok.AllArgsConstructor
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.Data
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -51,6 +54,17 @@ public class BrandkbsHotTopWarn {
...
@@ -51,6 +54,17 @@ public class BrandkbsHotTopWarn {
* 上榜时间
* 上榜时间
*/
*/
private
Long
time
;
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
;
}
}
}
}
}
src/main/java/com/zhiwei/brandkbs2/service/impl/ProjectWarnServiceImpl.java
View file @
138f137e
This diff is collapsed.
Click to expand it.
src/main/java/com/zhiwei/brandkbs2/util/RedisUtil.java
View file @
138f137e
...
@@ -5,6 +5,7 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -5,6 +5,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.util.Set
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
/**
/**
...
@@ -74,6 +75,10 @@ public class RedisUtil {
...
@@ -74,6 +75,10 @@ public class RedisUtil {
return
stringRedisTemplate
.
opsForValue
().
get
(
key
);
return
stringRedisTemplate
.
opsForValue
().
get
(
key
);
}
}
public
Set
<
String
>
keys
(
String
key
)
{
return
stringRedisTemplate
.
keys
(
key
);
}
public
void
remove
(
String
key
)
{
public
void
remove
(
String
key
)
{
setExpire
(
key
,
"-1"
,
1
,
TimeUnit
.
SECONDS
);
setExpire
(
key
,
"-1"
,
1
,
TimeUnit
.
SECONDS
);
}
}
...
...
src/main/java/com/zhiwei/brandkbs2/util/Tools.java
View file @
138f137e
...
@@ -884,6 +884,34 @@ public class Tools {
...
@@ -884,6 +884,34 @@ public class Tools {
return
false
;
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
)
{
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
);
List
<
Map
<
String
,
Object
>>
cacheMaps
=
(
List
<
Map
<
String
,
Object
>>)
esMap
.
get
(
GenericAttribute
.
ES_BRANDKBS_CACHE_MAPS
);
for
(
Map
<
String
,
Object
>
cacheMap
:
cacheMaps
)
{
for
(
Map
<
String
,
Object
>
cacheMap
:
cacheMaps
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment