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
62cc2ad2
Commit
62cc2ad2
authored
Nov 14, 2022
by
shenjunjie
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature' into 'dev'
品见项目预警模块上测试环境2 See merge request
!79
parents
8c51a0f7
31bed0e8
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
86 additions
and
13 deletions
+86
-13
src/main/java/com/zhiwei/brandkbs2/service/impl/ProjectWarnServiceImpl.java
+80
-13
src/main/resources/application-dev.properties
+2
-0
src/main/resources/application-local.properties
+2
-0
src/main/resources/application-prod.properties
+2
-0
No files found.
src/main/java/com/zhiwei/brandkbs2/service/impl/ProjectWarnServiceImpl.java
View file @
62cc2ad2
...
...
@@ -72,6 +72,19 @@ public class ProjectWarnServiceImpl implements ProjectWarnService {
@Resource
(
name
=
"redisUtil"
)
RedisUtil
redisUtil
;
private
static
final
Map
<
String
,
String
>
TYPE_SEARCH
=
new
HashMap
<>();
static
{
TYPE_SEARCH
.
put
(
"微博热搜"
,
"weibo"
);
TYPE_SEARCH
.
put
(
"微博话题"
,
"weibo-topic"
);
TYPE_SEARCH
.
put
(
"微博预热"
,
"weibo-rise"
);
TYPE_SEARCH
.
put
(
"头条热搜"
,
"toutiao"
);
TYPE_SEARCH
.
put
(
"抖音热搜"
,
"douyin"
);
TYPE_SEARCH
.
put
(
"知乎热搜"
,
"zhihu"
);
TYPE_SEARCH
.
put
(
"B站热搜"
,
"bilibili-ranking"
);
TYPE_SEARCH
.
put
(
"快手热搜"
,
"kuaishou"
);
}
@Override
public
ResponseResult
getProjectWarnCriteria
(
String
projectId
,
String
type
)
{
Map
<
String
,
Object
>
res
=
new
HashMap
<>();
...
...
@@ -242,7 +255,7 @@ public class ProjectWarnServiceImpl implements ProjectWarnService {
}
int
firstCount
=
datas
.
size
();
// key1
String
key1
=
"【品见】舆情动态"
+
project
.
getProjectName
();
String
key1
=
"【品见】舆情动态
-
"
+
project
.
getProjectName
();
// key2
String
key2Header
=
"全部"
;
StringBuilder
mediaChannel
=
new
StringBuilder
();
...
...
@@ -360,7 +373,7 @@ public class ProjectWarnServiceImpl implements ProjectWarnService {
}
int
firstCount
=
datas
.
size
();
// key1
String
key1
=
"【品见】渠道参与"
+
project
.
getProjectName
();
String
key1
=
"【品见】渠道参与
-
"
+
project
.
getProjectName
();
// key2
String
key2
=
"自定义渠道"
;
if
(
Boolean
.
TRUE
.
equals
(
config
.
getFriendlyChannel
()))
{
...
...
@@ -441,7 +454,7 @@ public class ProjectWarnServiceImpl implements ProjectWarnService {
if
(
firstCount
==
0
)
{
return
null
;
}
String
key1
=
"【品见】热点事件"
+
project
.
getProjectName
();
String
key1
=
"【品见】热点事件
-
"
+
project
.
getProjectName
();
// key2
String
key2
=
null
;
// key3
...
...
@@ -474,27 +487,81 @@ public class ProjectWarnServiceImpl implements ProjectWarnService {
long
start
=
end
-
config
.
getPushInterval
();
try
{
log
.
info
(
"获取上榜热搜预警开始,project:{}"
,
project
.
getProjectName
());
// 根据配置榜单类型
List
<
String
>
listType
=
config
.
getListType
();
if
(
listType
.
contains
(
"微博热搜"
))
{
//获取当前微博热搜数据
List
<
JSONObject
>
wbRankList
=
getRankListByType
(
"weibo"
);
getHotTopList
(
config
,
projectId
,
wbRankList
,
"微博热搜"
);
if
(
null
==
config
.
getListType
())
{
return
ResponseResult
.
success
();
}
// 根据配置榜单类型
List
<
BrandkbsHotTopWarn
.
HotTop
>
resList
=
new
ArrayList
<>();
config
.
getListType
().
forEach
(
type
->
resList
.
addAll
(
getHotTopList
(
config
,
projectId
,
getRankListByType
(
type
),
type
)));
log
.
info
(
"获取上榜热搜预警结束,project:{}"
,
project
.
getProjectName
());
return
ResponseResult
.
success
();
return
ResponseResult
.
success
(
brandkbsWarnTemplate4HotTop
(
config
,
resList
,
start
,
end
,
project
)
);
}
catch
(
Exception
e
)
{
log
.
info
(
"获取上榜热搜预警失败,project:{}"
,
project
.
getProjectName
(),
e
);
}
return
ResponseResult
.
failure
(
"获取上榜热搜预警失败"
);
}
private
BrandkbsWarnTemplate
brandkbsWarnTemplate4HotTop
(
BrandkbsHotTopConfig
config
,
List
<
BrandkbsHotTopWarn
.
HotTop
>
datas
,
long
start
,
long
end
,
AbstractProject
project
)
{
if
(
CollectionUtils
.
isEmpty
(
datas
))
{
return
null
;
}
String
key1
=
"【品见】上榜热搜-"
+
project
.
getProjectName
();
// key2
String
key2
=
""
;
List
<
String
>
key2Element
=
new
ArrayList
<>();
config
.
getListType
().
forEach
(
type
->
{
if
(
config
.
getFirstTop
())
{
key2Element
.
add
(
type
+
"榜-首次上榜"
);
}
if
(
config
.
getNewHeight
())
{
key2Element
.
add
(
type
+
"榜-排名新高"
);
}
if
(
config
.
getTopOnceAgain
())
{
key2Element
.
add
(
type
+
"榜-掉榜和再次上榜"
);
}
if
((
type
.
equals
(
"微博话题"
)
||
type
.
equals
(
"微博热搜"
))
&&
config
.
getIntroduction
())
{
key2Element
.
add
(
type
+
"榜-导语"
);
}
});
if
(
key2Element
.
size
()
>
2
)
{
key2
=
key2Element
.
get
(
0
)
+
"、"
+
key2Element
.
get
(
1
)
+
"..."
;
}
else
if
(
1
==
key2Element
.
size
())
{
key2
=
key2Element
.
get
(
0
);
}
else
if
(
2
==
key2Element
.
size
())
{
key2
=
key2Element
.
get
(
0
)
+
"、"
+
key2Element
.
get
(
1
);
}
// key3
String
key3
=
Constant
.
SPEC_MINUTE_FORMAT
.
format
(
start
)
+
" ~ "
+
Constant
.
SPEC_MINUTE_FORMAT
.
format
(
end
);
// key4
String
key4
;
StringBuilder
keyBuilder4
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
BrandkbsHotTopWarn
.
HotTop
hotTop
=
datas
.
get
(
i
);
String
topName
=
hotTop
.
getTopName
()
+
"榜"
;
String
title
=
hotTop
.
getTitle
();
keyBuilder4
.
append
(
topName
).
append
(
"/r/n"
);
keyBuilder4
.
append
(
i
+
1
).
append
(
"、"
).
append
(
title
).
append
(
"/r/n"
);
}
if
(
datas
.
size
()
>
2
)
{
key4
=
keyBuilder4
.
append
(
"..."
).
toString
();
}
else
{
key4
=
keyBuilder4
.
substring
(
0
,
keyBuilder4
.
length
()
-
4
);
}
return
new
BrandkbsWarnTemplate
(
datas
.
size
(),
key1
,
key2
,
key3
,
key4
,
new
BrandkbsHotTopWarn
(
config
.
getWarnKeyword
(),
config
.
getFilterKeyword
(),
datas
));
}
private
List
<
JSONObject
>
getRankListByType
(
String
type
)
{
String
search
=
TYPE_SEARCH
.
get
(
type
);
if
(
null
==
search
)
{
log
.
error
(
"getRankListByType,search-null,type:{}"
,
type
);
return
Collections
.
emptyList
();
}
try
{
ResponseEntity
<
String
>
response
=
restTemplate
.
getForEntity
(
hotSearchUrl
,
String
.
class
,
type
);
ResponseEntity
<
String
>
response
=
restTemplate
.
getForEntity
(
hotSearchUrl
,
String
.
class
,
search
);
return
JSON
.
parseObject
(
response
.
getBody
()).
getJSONArray
(
"data"
).
toJavaList
(
JSONObject
.
class
);
}
catch
(
Exception
e
)
{
log
.
error
(
"{} 热搜获取失败:"
,
type
,
e
);
log
.
error
(
"{} 热搜获取失败:"
,
search
,
e
);
}
return
Collections
.
emptyList
();
}
...
...
@@ -603,7 +670,7 @@ public class ProjectWarnServiceImpl implements ProjectWarnService {
hotTops
.
addAll
(
dropList
.
stream
().
map
(
json
->
BrandkbsHotTopWarn
.
HotTop
.
createFromJSON
(
json
,
"掉榜"
,
type
)).
collect
(
Collectors
.
toList
()));
hotTops
.
addAll
(
reappearList
.
stream
().
map
(
json
->
BrandkbsHotTopWarn
.
HotTop
.
createFromJSON
(
json
,
"再次上榜"
,
type
)).
collect
(
Collectors
.
toList
()));
}
if
(
Boolean
.
TRUE
.
equals
(
config
.
getIntroduction
(
)))
{
if
(
((
type
.
equals
(
"微博话题"
)
||
type
.
equals
(
"微博热搜"
))
&&
Boolean
.
TRUE
.
equals
(
config
.
getIntroduction
()
)))
{
List
<
JSONObject
>
topLeads
=
rankList
.
stream
().
filter
(
wbRank
->
{
if
(
wbRank
.
getString
(
"topicLead"
)
==
null
)
{
return
false
;
...
...
src/main/resources/application-dev.properties
View file @
62cc2ad2
...
...
@@ -93,3 +93,4 @@ warn.yuQing.url=https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/bra
warn.taskSwitch.url
=
https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/brandkbs/enable/used
#\u9884\u8B66\u5916\u90E8\u63A5\u53E3
ef.external.filterNew.url
=
https://ef.zhiweidata.com/external/filterNew.do?firstTypes={1}&start={2}&end={3}
hot.search.url
=
https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/findNewHotSearch?type={1}
\ No newline at end of file
src/main/resources/application-local.properties
View file @
62cc2ad2
...
...
@@ -95,3 +95,4 @@ warn.yuQing.url=http://192.168.0.225:11003/qbjc/brandkbsPush/interface/brandkbs/
warn.taskSwitch.url
=
http://192.168.0.225:11003/qbjc/brandkbsPush/interface/brandkbs/enable/used
#\u9884\u8B66\u5916\u90E8\u63A5\u53E3
ef.external.filterNew.url
=
https://ef.zhiweidata.com/external/filterNew.do?firstTypes={1}&start={2}&end={3}
hot.search.url
=
https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/findNewHotSearch?type={1}
\ No newline at end of file
src/main/resources/application-prod.properties
View file @
62cc2ad2
...
...
@@ -93,3 +93,4 @@ warn.yuQing.url=https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/bra
warn.taskSwitch.url
=
https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/brandkbs/enable/used
#\u9884\u8B66\u5916\u90E8\u63A5\u53E3
ef.external.filterNew.url
=
https://ef.zhiweidata.com/external/filterNew.do?firstTypes={1}&start={2}&end={3}
hot.search.url
=
https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/findNewHotSearch?type={1}
\ No newline at end of file
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