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
7ad4922d
Commit
7ad4922d
authored
Jun 19, 2023
by
shenjunjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
热搜模板调整上线
parent
b3910e54
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
362 additions
and
29 deletions
+362
-29
pom.xml
+1
-1
src/main/java/com/zhiwei/brandkbs2/common/RedisKeyPrefix.java
+5
-0
src/main/java/com/zhiwei/brandkbs2/config/Constant.java
+1
-0
src/main/java/com/zhiwei/brandkbs2/controller/app/AppHotController.java
+211
-19
src/main/java/com/zhiwei/brandkbs2/enmus/HotPlatformEnum.java
+57
-0
src/main/java/com/zhiwei/brandkbs2/pojo/vo/SupplementWord.java
+41
-0
src/main/java/com/zhiwei/brandkbs2/service/CommonService.java
+2
-0
src/main/java/com/zhiwei/brandkbs2/service/impl/CommonServiceImpl.java
+7
-0
src/main/java/com/zhiwei/brandkbs2/util/RedisUtil.java
+27
-6
src/main/resources/application-dev.properties
+3
-1
src/main/resources/application-local.properties
+4
-1
src/main/resources/application-prod.properties
+3
-1
No files found.
pom.xml
View file @
7ad4922d
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
<java.version>
1.8
</java.version>
<java.version>
1.8
</java.version>
<springboot.version>
2.2.5.RELEASE
</springboot.version>
<springboot.version>
2.2.5.RELEASE
</springboot.version>
<qbjc.bean.version>
1.1.7.1-SNAPSHOT
</qbjc.bean.version>
<qbjc.bean.version>
1.1.7.1-SNAPSHOT
</qbjc.bean.version>
<springfox.version>
2.
7.0
</springfox.version>
<springfox.version>
2.
9.2
</springfox.version>
<fastjson.version>
1.2.47
</fastjson.version>
<fastjson.version>
1.2.47
</fastjson.version>
<easyexcel.version>
3.0.5
</easyexcel.version>
<easyexcel.version>
3.0.5
</easyexcel.version>
<marker.client.version>
1.1.9-SNAPSHOT
</marker.client.version>
<marker.client.version>
1.1.9-SNAPSHOT
</marker.client.version>
...
...
src/main/java/com/zhiwei/brandkbs2/common/RedisKeyPrefix.java
View file @
7ad4922d
...
@@ -63,6 +63,7 @@ public class RedisKeyPrefix {
...
@@ -63,6 +63,7 @@ public class RedisKeyPrefix {
public
static
final
String
HOT_RANK_LIST
=
"BRANDKBS:HOT:RANK_LIST:"
;
public
static
final
String
HOT_RANK_LIST
=
"BRANDKBS:HOT:RANK_LIST:"
;
public
static
final
String
HOT_LIST
=
"BRANDKBS:HOT:LIST:"
;
public
static
final
String
HOT_LIST
=
"BRANDKBS:HOT:LIST:"
;
public
static
final
String
HOT_KEYWORD
=
"BRANDKBS:HOT:KEYWORD:"
;
public
static
final
String
HOT_KEYWORD
=
"BRANDKBS:HOT:KEYWORD:"
;
public
static
final
String
HOT_SUPPLEMENT_WORD
=
"BRANDKBS:HOT:SUPPLEMENT_WORD:"
;
/**
/**
* 项目简报报相关缓存KEY
* 项目简报报相关缓存KEY
...
@@ -125,6 +126,10 @@ public class RedisKeyPrefix {
...
@@ -125,6 +126,10 @@ public class RedisKeyPrefix {
return
RedisKeyPrefix
.
generateRedisKey
(
RedisKeyPrefix
.
HOT_KEYWORD
,
projectId
);
return
RedisKeyPrefix
.
generateRedisKey
(
RedisKeyPrefix
.
HOT_KEYWORD
,
projectId
);
}
}
public
static
String
supplementWordKey
(
String
projectId
)
{
return
RedisKeyPrefix
.
generateRedisKey
(
RedisKeyPrefix
.
HOT_SUPPLEMENT_WORD
,
projectId
);
}
private
static
String
generateRedisKey
(
String
...
keys
)
{
private
static
String
generateRedisKey
(
String
...
keys
)
{
Objects
.
requireNonNull
(
keys
);
Objects
.
requireNonNull
(
keys
);
boolean
contains
=
keys
[
0
].
endsWith
(
":"
);
boolean
contains
=
keys
[
0
].
endsWith
(
":"
);
...
...
src/main/java/com/zhiwei/brandkbs2/config/Constant.java
View file @
7ad4922d
...
@@ -16,6 +16,7 @@ public class Constant {
...
@@ -16,6 +16,7 @@ public class Constant {
public
static
final
Long
ONE_DAY
=
24
*
60
*
60
*
1000L
;
public
static
final
Long
ONE_DAY
=
24
*
60
*
60
*
1000L
;
public
static
final
Long
ONE_WEEK
=
7
*
24
*
60
*
60
*
1000L
;
public
static
final
Long
ONE_WEEK
=
7
*
24
*
60
*
60
*
1000L
;
public
static
final
Long
ONE_MONTH
=
30
*
24
*
60
*
60
*
1000L
;
public
static
final
Long
ONE_MONTH
=
30
*
24
*
60
*
60
*
1000L
;
public
static
final
Long
ONE_YEAR
=
ONE_MONTH
*
12
;
public
static
final
String
SPEC_MINUTE_PATTERN
=
"yyyy.MM.dd HH:mm"
;
public
static
final
String
SPEC_MINUTE_PATTERN
=
"yyyy.MM.dd HH:mm"
;
public
static
final
String
HOUR_PATTERN
=
"yyyy-MM-dd HH"
;
public
static
final
String
HOUR_PATTERN
=
"yyyy-MM-dd HH"
;
...
...
src/main/java/com/zhiwei/brandkbs2/controller/app/AppHotController.java
View file @
7ad4922d
...
@@ -9,14 +9,17 @@ import com.zhiwei.brandkbs2.auth.UserThreadLocal;
...
@@ -9,14 +9,17 @@ import com.zhiwei.brandkbs2.auth.UserThreadLocal;
import
com.zhiwei.brandkbs2.common.RedisKeyPrefix
;
import
com.zhiwei.brandkbs2.common.RedisKeyPrefix
;
import
com.zhiwei.brandkbs2.config.Constant
;
import
com.zhiwei.brandkbs2.config.Constant
;
import
com.zhiwei.brandkbs2.controller.BaseController
;
import
com.zhiwei.brandkbs2.controller.BaseController
;
import
com.zhiwei.brandkbs2.enmus.HotPlatformEnum
;
import
com.zhiwei.brandkbs2.enmus.RoleEnum
;
import
com.zhiwei.brandkbs2.enmus.RoleEnum
;
import
com.zhiwei.brandkbs2.model.ResponseResult
;
import
com.zhiwei.brandkbs2.model.ResponseResult
;
import
com.zhiwei.brandkbs2.pojo.BaseMap
;
import
com.zhiwei.brandkbs2.pojo.BaseMap
;
import
com.zhiwei.brandkbs2.pojo.vo.SupplementWord
;
import
com.zhiwei.brandkbs2.service.CommonService
;
import
com.zhiwei.brandkbs2.service.MarkDataService
;
import
com.zhiwei.brandkbs2.service.MarkDataService
;
import
com.zhiwei.brandkbs2.service.ProjectService
;
import
com.zhiwei.brandkbs2.service.ProjectService
;
import
com.zhiwei.brandkbs2.util.RedisUtil
;
import
com.zhiwei.brandkbs2.util.RedisUtil
;
import
io.swagger.annotations.
Api
;
import
io.swagger.annotations.
*
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.time.DateUtils
;
import
org.apache.commons.lang3.time.DateUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -64,12 +67,23 @@ public class AppHotController extends BaseController {
...
@@ -64,12 +67,23 @@ public class AppHotController extends BaseController {
@Resource
(
name
=
"projectServiceImpl"
)
@Resource
(
name
=
"projectServiceImpl"
)
ProjectService
projectService
;
ProjectService
projectService
;
@Resource
(
name
=
"commonServiceImpl"
)
CommonService
commonService
;
@Resource
(
name
=
"esSearchExecutor"
)
@Resource
(
name
=
"esSearchExecutor"
)
ThreadPoolTaskExecutor
executor
;
ThreadPoolTaskExecutor
executor
;
@Value
(
"${trends.getHotSearchFromEsInTimeAndTypeOrWord.url}"
)
@Value
(
"${trends.getHotSearchFromEsInTimeAndTypeOrWord.url}"
)
private
String
hotSearchUrl
;
private
String
hotSearchUrl
;
@Value
(
"${trends.queryHotSearchTrendInner.url}"
)
private
String
hotSearchTrendUrl
;
@Value
(
"${trends.getHotSearchSnapshot.url}"
)
private
String
hotSearchSnapshotUrl
;
private
final
String
allPlatform
=
"brandkbs-all"
;
/**
/**
* weibo 热搜
* weibo 热搜
* weibo-topic 话题
* weibo-topic 话题
...
@@ -87,32 +101,28 @@ public class AppHotController extends BaseController {
...
@@ -87,32 +101,28 @@ public class AppHotController extends BaseController {
@RequestParam
(
value
=
"sort"
,
defaultValue
=
"endTime"
)
String
sort
,
@RequestParam
(
value
=
"sort"
,
defaultValue
=
"endTime"
)
String
sort
,
@RequestParam
(
value
=
"startTime"
,
required
=
false
)
Long
startTime
,
@RequestParam
(
value
=
"startTime"
,
required
=
false
)
Long
startTime
,
@RequestParam
(
value
=
"endTime"
,
required
=
false
)
Long
endTime
)
{
@RequestParam
(
value
=
"endTime"
,
required
=
false
)
Long
endTime
)
{
String
keywordStr
=
redisUtil
.
get
(
RedisKeyPrefix
.
hotKeywordKey
(
UserThreadLocal
.
getProjectId
()));
JSONObject
result
=
searchHotHandler
(
pageSize
,
page
,
type
,
sort
,
startTime
,
endTime
);
if
(
null
==
keywordStr
)
{
return
ResponseResult
.
success
();
}
String
keyword
=
StringUtils
.
join
(
JSONArray
.
parseArray
(
keywordStr
,
String
.
class
),
"|"
);
ResponseEntity
<
JSONObject
>
jsonObjectResponseEntity
;
if
(
null
!=
startTime
&&
null
!=
endTime
)
{
jsonObjectResponseEntity
=
restTemplate
.
getForEntity
(
hotSearchUrl
+
"&startTime={6}&endTime={7}"
,
JSONObject
.
class
,
pageSize
,
page
,
type
,
keyword
,
sort
,
startTime
,
endTime
);
}
else
{
jsonObjectResponseEntity
=
restTemplate
.
getForEntity
(
hotSearchUrl
,
JSONObject
.
class
,
pageSize
,
page
,
type
,
keyword
,
sort
);
}
JSONObject
result
=
jsonObjectResponseEntity
.
getBody
();
if
(
Objects
.
isNull
(
result
))
{
if
(
Objects
.
isNull
(
result
))
{
return
ResponseResult
.
failure
(
"响应超时"
);
return
ResponseResult
.
success
(
);
}
}
// 查询在榜数据
// 查询在榜数据
ResponseEntity
<
JSONObject
>
responseEntity
=
restTemplate
.
getForEntity
(
trendsListUrl
,
JSONObject
.
class
,
null
,
type
,
null
);
ResponseEntity
<
JSONObject
>
responseEntity
=
restTemplate
.
getForEntity
(
trendsListUrl
,
JSONObject
.
class
,
null
,
type
,
null
);
if
(
Objects
.
isNull
(
responseEntity
.
getBody
()))
{
List
<
String
>
rankingIds
=
new
ArrayList
<>();
return
ResponseResult
.
success
(
result
);
if
(
Objects
.
nonNull
(
responseEntity
.
getBody
()))
{
rankingIds
=
responseEntity
.
getBody
().
getJSONArray
(
"data"
).
stream
().
map
(
obj
->
((
JSONObject
)
obj
).
getString
(
"_id"
)).
collect
(
Collectors
.
toList
());
}
}
List
<
String
>
rankingIds
=
responseEntity
.
getBody
().
getJSONArray
(
"data"
).
stream
().
map
(
obj
->
((
JSONObject
)
obj
).
getString
(
"_id"
)).
collect
(
Collectors
.
toList
());
List
<
String
>
finalRankingIds
=
rankingIds
;
// 对比补录词
List
<
Object
>
valueList
=
redisUtil
.
getMapValueAll
(
RedisKeyPrefix
.
supplementWordKey
(
UserThreadLocal
.
getProjectId
()));
List
<
String
>
supplementList
=
valueList
.
stream
().
map
(
word
->
JSON
.
parseObject
((
String
)
word
,
SupplementWord
.
class
).
getTitle
()).
collect
(
Collectors
.
toList
());
List
<
JSONObject
>
list
=
result
.
getJSONArray
(
"data"
).
stream
().
map
(
obj
->
{
List
<
JSONObject
>
list
=
result
.
getJSONArray
(
"data"
).
stream
().
map
(
obj
->
{
JSONObject
json
=
(
JSONObject
)
obj
;
JSONObject
json
=
(
JSONObject
)
obj
;
if
(
r
ankingIds
.
contains
(
json
.
getString
(
"id"
)))
{
if
(
finalR
ankingIds
.
contains
(
json
.
getString
(
"id"
)))
{
json
.
put
(
"inTheList"
,
true
);
json
.
put
(
"inTheList"
,
true
);
}
}
if
(
supplementList
.
contains
(
json
.
getString
(
"name"
)))
{
json
.
put
(
"supplement"
,
true
);
}
return
json
;
return
json
;
}).
collect
(
Collectors
.
toList
());
}).
collect
(
Collectors
.
toList
());
result
.
put
(
"data"
,
list
);
result
.
put
(
"data"
,
list
);
...
@@ -187,6 +197,136 @@ public class AppHotController extends BaseController {
...
@@ -187,6 +197,136 @@ public class AppHotController extends BaseController {
}
}
}
}
@ApiOperation
(
"热点库-根据热搜平台和标题匹配查询条件"
)
@GetMapping
(
"/match-criteria"
)
public
ResponseResult
matchSearchCriteria
(
@RequestParam
String
name
,
@RequestParam
String
type
)
{
Long
[]
timeRangeMonth
=
commonService
.
getTimeRangeMonth
();
int
defaultPageSize
=
5
;
JSONObject
result
=
searchHotHandler
(
10000
,
1
,
HotPlatformEnum
.
convertFromName2Eng
(
type
),
"endTime"
,
timeRangeMonth
[
0
],
timeRangeMonth
[
1
]);
int
index
=
0
;
boolean
matched
=
false
;
List
<
JSONObject
>
data
=
result
.
getJSONArray
(
"data"
).
toJavaList
(
JSONObject
.
class
);
for
(
JSONObject
json
:
data
)
{
index
++;
if
(
name
.
equals
(
json
.
getString
(
"name"
)))
{
matched
=
true
;
break
;
}
}
JSONObject
res
=
new
JSONObject
();
res
.
put
(
"matched"
,
matched
);
if
(
matched
)
{
res
.
put
(
"page"
,
(
10000
+
index
-
1
)
/
defaultPageSize
);
res
.
put
(
"type"
,
HotPlatformEnum
.
convertFromName2Eng
(
type
));
}
return
ResponseResult
.
success
(
res
);
}
@ApiOperation
(
"热点库-品牌热点-补录获取"
)
@GetMapping
(
"/supplementWord/get"
)
public
ResponseResult
getSupplementWord
()
{
String
projectId
=
UserThreadLocal
.
getProjectId
();
String
key
=
RedisKeyPrefix
.
supplementWordKey
(
projectId
);
List
<
Object
>
valueList
=
redisUtil
.
getMapValueAll
(
key
);
List
<
SupplementWord
>
collect
=
valueList
.
stream
().
map
(
word
->
JSON
.
parseObject
((
String
)
word
,
SupplementWord
.
class
)).
sorted
((
x
,
y
)
->
Long
.
compare
(
y
.
getUpdateTime
(),
x
.
getUpdateTime
())).
collect
(
Collectors
.
toList
());
return
ResponseResult
.
success
(
collect
);
}
@ApiOperation
(
"热点库-品牌热点-补录新增"
)
@PostMapping
(
"/supplementWord/add"
)
public
ResponseResult
addSupplementWord
(
@ApiParam
(
name
=
"json:{title:标题}"
)
@RequestBody
JSONObject
json
)
{
String
key
=
RedisKeyPrefix
.
supplementWordKey
(
UserThreadLocal
.
getProjectId
());
if
(
redisUtil
.
getMapSize
(
key
)
>=
50
)
{
return
ResponseResult
.
failure
(
"补录超过预设上限"
);
}
String
title
=
json
.
getString
(
"title"
);
if
(
StringUtils
.
isEmpty
(
title
))
{
return
ResponseResult
.
failure
(
"补录新增失败"
);
}
SupplementWord
supplementWord
=
new
SupplementWord
(
title
,
UserThreadLocal
.
getNickname
());
boolean
result
=
redisUtil
.
setMapValue
(
key
,
supplementWord
.
uniqueKey
(),
JSON
.
toJSONString
(
supplementWord
));
if
(!
result
)
{
return
ResponseResult
.
failure
(
"补录新增失败"
);
}
return
ResponseResult
.
success
();
}
@ApiOperation
(
"热点库-品牌热点-补录修改"
)
@PutMapping
(
"/supplementWord/update"
)
public
ResponseResult
updateSupplementWord
(
@ApiParam
(
name
=
"json:{title:原标题,newTitle:新标题,updateTime:更新时间}"
)
@RequestBody
JSONObject
json
)
{
String
newTitle
=
json
.
getString
(
"newTitle"
);
String
title
=
json
.
getString
(
"title"
);
Long
updateTime
=
json
.
getLong
(
"updateTime"
);
SupplementWord
supplementWord
=
new
SupplementWord
(
newTitle
,
UserThreadLocal
.
getNickname
());
boolean
result
=
redisUtil
.
resetMapValue
(
RedisKeyPrefix
.
supplementWordKey
(
UserThreadLocal
.
getProjectId
()),
title
+
updateTime
,
supplementWord
.
uniqueKey
(),
JSON
.
toJSONString
(
supplementWord
));
if
(!
result
)
{
return
ResponseResult
.
failure
(
"补录修改失败"
);
}
return
ResponseResult
.
success
();
}
@ApiOperation
(
"热点库-品牌热点-补录删除"
)
@DeleteMapping
(
"/supplementWord/delete"
)
public
ResponseResult
deleteSupplementWord
(
@ApiParam
(
name
=
"json:{title:原标题,updateTime:更新时间}"
)
@RequestBody
JSONObject
json
)
{
String
title
=
json
.
getString
(
"title"
);
Long
updateTime
=
json
.
getLong
(
"updateTime"
);
redisUtil
.
deleteMapValue
(
RedisKeyPrefix
.
supplementWordKey
(
UserThreadLocal
.
getProjectId
()),
title
+
updateTime
);
return
ResponseResult
.
success
();
}
@ApiOperation
(
"热点库-品牌热点-热点总览"
)
@GetMapping
(
"/overview"
)
public
ResponseResult
hotOverview
()
{
Long
[]
timeMonth
=
commonService
.
getTimeRangeFormatMonth
();
JSONObject
result
=
searchHotHandler
(
10000
,
1
,
allPlatform
,
"endTime"
,
timeMonth
[
0
],
timeMonth
[
1
]);
if
(
Objects
.
isNull
(
result
))
{
return
ResponseResult
.
success
();
}
List
<
JSONObject
>
list
=
result
.
getJSONArray
(
"data"
).
stream
().
map
(
obj
->
{
JSONObject
json
=
(
JSONObject
)
obj
;
json
.
put
(
"platform"
,
HotPlatformEnum
.
convertPlatform
(
json
.
getString
(
"type"
)));
return
json
;
}).
collect
(
Collectors
.
toList
());
result
.
put
(
"data"
,
list
);
return
ResponseResult
.
success
(
result
);
}
@ApiOperation
(
"热点库-品牌热点-热搜对比"
)
@GetMapping
(
"/contrast"
)
public
ResponseResult
hotContrast
()
{
// 默认返回近一年的数据
JSONObject
result
=
searchHotHandler
(
10000
,
1
,
allPlatform
,
"endTime"
,
null
,
null
);
if
(
Objects
.
isNull
(
result
))
{
return
ResponseResult
.
success
();
}
JSONObject
data
=
new
JSONObject
();
List
<
JSONObject
>
list
=
result
.
getJSONArray
(
"data"
).
toJavaList
(
JSONObject
.
class
);
// 近一周的数据统计
data
.
put
(
"weekContrast"
,
contrastReport
(
list
,
commonService
.
getTimeRangeFormatWeek
(),
Constant
.
ONE_WEEK
));
data
.
put
(
"monthContrast"
,
contrastReport
(
list
,
commonService
.
getTimeRangeFormatMonth
(),
Constant
.
ONE_MONTH
));
return
ResponseResult
.
success
(
data
);
}
@ApiOperation
(
"热点库-品牌热点-热搜趋势"
)
@GetMapping
(
"/trend"
)
public
ResponseResult
hotSearchTrend
(
@RequestParam
String
name
,
@RequestParam
Long
startTime
,
@RequestParam
String
type
)
{
ResponseEntity
<
JSONObject
>
jsonObjectResponseEntity
=
restTemplate
.
getForEntity
(
hotSearchTrendUrl
,
JSONObject
.
class
,
name
,
startTime
,
HotPlatformEnum
.
convertFromName2Eng
(
type
));
if
(
Objects
.
isNull
(
jsonObjectResponseEntity
.
getBody
()))
{
return
ResponseResult
.
failure
(
"查询热搜趋势失败"
);
}
return
ResponseResult
.
success
(
jsonObjectResponseEntity
.
getBody
());
}
@ApiOperation
(
"热点库-品牌热点-上榜/峰值截图"
)
@GetMapping
(
"/snapshot"
)
public
ResponseResult
hotSnapshot
(
@RequestParam
String
type
,
@RequestParam
Long
time
,
@RequestParam
Integer
rank
)
{
ResponseEntity
<
JSONObject
>
jsonObjectResponseEntity
=
restTemplate
.
getForEntity
(
hotSearchSnapshotUrl
,
JSONObject
.
class
,
HotPlatformEnum
.
convertFromName2Eng
(
type
),
time
,
rank
);
if
(
Objects
.
isNull
(
jsonObjectResponseEntity
.
getBody
()))
{
return
ResponseResult
.
failure
(
"上榜/峰值截图失败"
);
}
return
ResponseResult
.
success
(
jsonObjectResponseEntity
.
getBody
());
}
@ApiOperation
(
"首页-近24小时热门舆情,查竞品-竞品动态"
)
@ApiOperation
(
"首页-近24小时热门舆情,查竞品-竞品动态"
)
@GetMapping
(
"/latestNews"
)
@GetMapping
(
"/latestNews"
)
public
ResponseResult
latestNews
(
@RequestParam
(
value
=
"size"
,
defaultValue
=
"5"
)
Integer
size
,
public
ResponseResult
latestNews
(
@RequestParam
(
value
=
"size"
,
defaultValue
=
"5"
)
Integer
size
,
...
@@ -217,4 +357,56 @@ public class AppHotController extends BaseController {
...
@@ -217,4 +357,56 @@ public class AppHotController extends BaseController {
},
executor
)).
toArray
(
CompletableFuture
[]::
new
)).
join
();
},
executor
)).
toArray
(
CompletableFuture
[]::
new
)).
join
();
return
ResponseResult
.
success
(
resultList
);
return
ResponseResult
.
success
(
resultList
);
}
}
/**
* 通过热搜中间件获取数据
*
* @param pageSize
* @param page
* @param type
* @param sort
* @param startTime
* @param endTime
* @return
*/
private
JSONObject
searchHotHandler
(
int
pageSize
,
int
page
,
String
type
,
String
sort
,
Long
startTime
,
Long
endTime
)
{
String
keywordStr
=
redisUtil
.
get
(
RedisKeyPrefix
.
hotKeywordKey
(
UserThreadLocal
.
getProjectId
()));
if
(
null
==
keywordStr
)
{
return
null
;
}
String
accurateWord
=
null
;
List
<
Object
>
valueList
=
redisUtil
.
getMapValueAll
(
RedisKeyPrefix
.
supplementWordKey
(
UserThreadLocal
.
getProjectId
()));
if
(
CollectionUtils
.
isNotEmpty
(
valueList
))
{
List
<
String
>
collect
=
valueList
.
stream
().
map
(
word
->
JSON
.
parseObject
((
String
)
word
,
SupplementWord
.
class
).
getTitle
()).
collect
(
Collectors
.
toList
());
accurateWord
=
StringUtils
.
join
(
collect
,
"|"
);
}
String
keyword
=
StringUtils
.
join
(
JSONArray
.
parseArray
(
keywordStr
,
String
.
class
),
"|"
);
ResponseEntity
<
JSONObject
>
jsonObjectResponseEntity
;
if
(
null
!=
startTime
&&
null
!=
endTime
)
{
jsonObjectResponseEntity
=
restTemplate
.
getForEntity
(
hotSearchUrl
+
"&startTime={7}&endTime={8}"
,
JSONObject
.
class
,
pageSize
,
page
,
type
,
keyword
,
sort
,
accurateWord
,
startTime
,
endTime
);
}
else
{
jsonObjectResponseEntity
=
restTemplate
.
getForEntity
(
hotSearchUrl
,
JSONObject
.
class
,
pageSize
,
page
,
type
,
keyword
,
sort
,
accurateWord
);
}
return
jsonObjectResponseEntity
.
getBody
();
}
private
JSONObject
contrastReport
(
List
<
JSONObject
>
source
,
Long
[]
timeRange
,
Long
space
)
{
JSONObject
result
=
new
JSONObject
();
List
<
JSONObject
>
list
=
source
.
stream
().
filter
(
json
->
json
.
getLong
(
"startTime"
)
>=
timeRange
[
0
]).
collect
(
Collectors
.
toList
());
List
<
JSONObject
>
lastList
=
source
.
stream
().
filter
(
json
->
json
.
getLong
(
"startTime"
)
>=
(
timeRange
[
0
]
-
space
)
&&
json
.
getLong
(
"startTime"
)
<
timeRange
[
0
]).
collect
(
Collectors
.
toList
());
result
.
put
(
"currentCount"
,
list
.
size
());
result
.
put
(
"lastCount"
,
list
.
size
()
-
lastList
.
size
());
Map
<
String
,
List
<
JSONObject
>>
platformMap
=
list
.
stream
().
collect
(
Collectors
.
groupingBy
(
json
->
HotPlatformEnum
.
convertPlatform
(
json
.
getString
(
"type"
))));
List
<
JSONObject
>
platformCount
=
new
ArrayList
<>();
platformMap
.
forEach
((
platform
,
datas
)
->
{
JSONObject
json
=
new
JSONObject
();
json
.
put
(
"platform"
,
platform
);
json
.
put
(
"count"
,
datas
.
size
());
platformCount
.
add
(
json
);
});
result
.
put
(
"platformCount"
,
platformCount
);
result
.
put
(
"averageCount"
,
source
.
size
()
/
(
Constant
.
ONE_YEAR
/
space
));
return
result
;
}
}
}
src/main/java/com/zhiwei/brandkbs2/enmus/HotPlatformEnum.java
0 → 100644
View file @
7ad4922d
package
com
.
zhiwei
.
brandkbs2
.
enmus
;
import
lombok.Getter
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* @ClassName: HotPlatformEnum
* @Description 热搜中间件返回平台枚举
* @author: sjj
* @date: 2023-06-13 14:30
*/
@Getter
public
enum
HotPlatformEnum
{
WEIBO
(
"微博"
,
"weibo"
,
"微博热搜"
),
WEIBO_TOPIC
(
"微博"
,
"weibo-topic"
,
"微博话题"
),
WEIBO_RISE
(
"微博"
,
"weibo-rise"
,
"微博预热榜"
),
ZHIHU
(
"知乎"
,
"zhihu"
,
"知乎热搜"
),
JINRITOUTIAO
(
"今日头条"
,
"toutiao"
,
"今日头条热搜"
),
DOUYIN
(
"抖音"
,
"douyin"
,
"抖音热搜"
),
BILIBILI
(
"B站"
,
"bilibili-ranking"
,
"B站热搜"
),
KUAISHOU
(
"快手"
,
"kuaishou"
,
"快手热榜"
),
BAIDU
(
"百度"
,
"baidu"
,
"百度热搜"
);
private
final
String
platform
;
private
final
String
engName
;
private
final
String
name
;
private
static
final
Map
<
String
,
String
>
CONVERT_MAP
=
new
HashMap
<>();
static
{
for
(
HotPlatformEnum
platform
:
HotPlatformEnum
.
values
())
{
CONVERT_MAP
.
put
(
platform
.
name
,
platform
.
platform
);
}
}
HotPlatformEnum
(
String
platform
,
String
engName
,
String
name
)
{
this
.
platform
=
platform
;
this
.
engName
=
engName
;
this
.
name
=
name
;
}
public
static
String
convertPlatform
(
String
name
)
{
return
CONVERT_MAP
.
get
(
name
);
}
public
static
String
convertFromName2Eng
(
String
name
)
{
for
(
HotPlatformEnum
platform
:
HotPlatformEnum
.
values
())
{
if
(
name
.
equals
(
platform
.
name
))
{
return
platform
.
engName
;
}
}
return
name
;
}
}
src/main/java/com/zhiwei/brandkbs2/pojo/vo/SupplementWord.java
0 → 100644
View file @
7ad4922d
package
com
.
zhiwei
.
brandkbs2
.
pojo
.
vo
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
/**
* @ClassName: SupplementWord
* @Description SupplementWord
* @author: sjj
* @date: 2023-06-12 17:42
*/
@Data
@NoArgsConstructor
public
class
SupplementWord
{
/**
* 补录标题
*/
private
String
title
;
/**
* 更新时间
*/
private
Long
updateTime
;
/**
* 提交人
*/
private
String
submitter
;
public
SupplementWord
(
String
title
,
String
submitter
)
{
this
.
title
=
title
;
this
.
submitter
=
submitter
;
this
.
updateTime
=
System
.
currentTimeMillis
();
}
public
String
uniqueKey
()
{
return
title
+
updateTime
;
}
}
src/main/java/com/zhiwei/brandkbs2/service/CommonService.java
View file @
7ad4922d
...
@@ -59,6 +59,8 @@ public interface CommonService {
...
@@ -59,6 +59,8 @@ public interface CommonService {
*/
*/
void
addMtagBatch
(
List
<
MarkInfo
>
markInfos
);
void
addMtagBatch
(
List
<
MarkInfo
>
markInfos
);
Long
[]
getTimeRangeYear
();
Long
[]
getTimeRangeMonth
();
Long
[]
getTimeRangeMonth
();
Long
[]
getTimeRangeWeek
();
Long
[]
getTimeRangeWeek
();
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/CommonServiceImpl.java
View file @
7ad4922d
...
@@ -132,6 +132,13 @@ public class CommonServiceImpl implements CommonService {
...
@@ -132,6 +132,13 @@ public class CommonServiceImpl implements CommonService {
}
}
@Override
@Override
public
Long
[]
getTimeRangeYear
()
{
long
endTime
=
Tools
.
truncDate
(
new
Date
(),
Constant
.
DAY_PATTERN
).
getTime
();
long
startTime
=
DateUtils
.
addYears
(
new
Date
(
endTime
),
-
1
).
getTime
();
return
new
Long
[]{
startTime
,
endTime
};
}
@Override
public
Long
[]
getTimeRangeMonth
()
{
public
Long
[]
getTimeRangeMonth
()
{
long
endTime
=
Tools
.
truncDate
(
new
Date
(),
Constant
.
DAY_PATTERN
).
getTime
();
long
endTime
=
Tools
.
truncDate
(
new
Date
(),
Constant
.
DAY_PATTERN
).
getTime
();
long
startTime
=
DateUtils
.
addMonths
(
new
Date
(
endTime
),
-
1
).
getTime
();
long
startTime
=
DateUtils
.
addMonths
(
new
Date
(
endTime
),
-
1
).
getTime
();
...
...
src/main/java/com/zhiwei/brandkbs2/util/RedisUtil.java
View file @
7ad4922d
...
@@ -2,6 +2,7 @@ package com.zhiwei.brandkbs2.util;
...
@@ -2,6 +2,7 @@ package com.zhiwei.brandkbs2.util;
import
com.zhiwei.brandkbs2.common.RedisKeyPrefix
;
import
com.zhiwei.brandkbs2.common.RedisKeyPrefix
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.HashOperations
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -92,15 +93,35 @@ public class RedisUtil {
...
@@ -92,15 +93,35 @@ public class RedisUtil {
return
stringRedisTemplate
.
keys
(
key
);
return
stringRedisTemplate
.
keys
(
key
);
}
}
public
void
setListLeft
(
String
key
,
String
value
)
{
public
List
<
Object
>
getMapValueAll
(
String
key
)
{
if
(
null
==
key
)
{
return
stringRedisTemplate
.
opsForHash
().
values
(
key
);
return
;
}
public
boolean
setMapValue
(
String
key
,
String
field
,
String
value
)
{
HashOperations
<
String
,
Object
,
Object
>
operations
=
stringRedisTemplate
.
opsForHash
();
Boolean
result
=
operations
.
putIfAbsent
(
key
,
field
,
value
);
return
Boolean
.
TRUE
.
equals
(
result
);
}
public
boolean
resetMapValue
(
String
key
,
String
field
,
String
newField
,
String
value
)
{
HashOperations
<
String
,
Object
,
Object
>
operations
=
stringRedisTemplate
.
opsForHash
();
if
(
operations
.
hasKey
(
key
,
field
))
{
operations
.
put
(
key
,
newField
,
value
);
deleteMapValue
(
key
,
field
);
return
true
;
}
return
false
;
}
public
void
deleteMapValue
(
String
key
,
String
field
)
{
HashOperations
<
String
,
Object
,
Object
>
operations
=
stringRedisTemplate
.
opsForHash
();
if
(
operations
.
hasKey
(
key
,
field
))
{
operations
.
delete
(
key
,
field
);
}
}
stringRedisTemplate
.
opsForList
().
leftPush
(
key
,
value
);
}
}
public
List
<
String
>
getListAll
(
String
key
)
{
public
long
getMapSize
(
String
key
)
{
return
stringRedisTemplate
.
opsFor
List
().
range
(
key
,
0
,
-
1
);
return
stringRedisTemplate
.
opsFor
Hash
().
size
(
key
);
}
}
public
void
remove
(
String
key
)
{
public
void
remove
(
String
key
)
{
...
...
src/main/resources/application-dev.properties
View file @
7ad4922d
...
@@ -84,7 +84,9 @@ crisis.event.url =https://crisis.zhiweidata.com/event/{1}/general?share={2}
...
@@ -84,7 +84,9 @@ crisis.event.url =https://crisis.zhiweidata.com/event/{1}/general?share={2}
trends.longTimeInListSearchByInner.url
=
https://trends.zhiweidata.com/hotSearchTrend/inner/longTimeInListSearchByInner?sortType={1}&type={2}&day={3}
trends.longTimeInListSearchByInner.url
=
https://trends.zhiweidata.com/hotSearchTrend/inner/longTimeInListSearchByInner?sortType={1}&type={2}&day={3}
trends.findHotSearchESDataInTimeByInner.url
=
https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/findHotSearchESDataInTimeByInner?limit={1}&page={2}&type={3}&word={4}
trends.findHotSearchESDataInTimeByInner.url
=
https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/findHotSearchESDataInTimeByInner?limit={1}&page={2}&type={3}&word={4}
trends.longTimeInListSearch.url
=
https://trends.zhiweidata.com/hotSearchTrend/search/longTimeInListSearch?type={1}&sortType=realTime
trends.longTimeInListSearch.url
=
https://trends.zhiweidata.com/hotSearchTrend/search/longTimeInListSearch?type={1}&sortType=realTime
trends.getHotSearchFromEsInTimeAndTypeOrWord.url
=
https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/getHotSearchFromEsInTimeAndTypeOrWord?limit={1}&page={2}&type={3}&word={4}&sort={5}
trends.getHotSearchFromEsInTimeAndTypeOrWord.url
=
https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/getHotSearchFromEsInTimeAndTypeOrWord?limit={1}&page={2}&type={3}&word={4}&sort={5
\}
&accurateWord={6}
trends.queryHotSearchTrendInner.url
=
https://trends.zhiweidata.com/hotSearchTrend/inner/queryHotSearchTrendInner?name={1}&startTime={2}&type={3}
trends.getHotSearchSnapshot.url
=
https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/getHotSearchSnapshot?type={1}&time={2}&rank={3}
#\u4E8B\u4EF6\u5E93\u5916\u90E8\u63A5\u53E3
#\u4E8B\u4EF6\u5E93\u5916\u90E8\u63A5\u53E3
ef.search.url
=
https://ef.zhiweidata.com/external/search.do?name={1}&page={2}
ef.search.url
=
https://ef.zhiweidata.com/external/search.do?name={1}&page={2}
ef.searchCriteria.url
=
https://ef.zhiweidata.com/index/getSearchKey.do
ef.searchCriteria.url
=
https://ef.zhiweidata.com/index/getSearchKey.do
...
...
src/main/resources/application-local.properties
View file @
7ad4922d
...
@@ -87,7 +87,10 @@ crisis.event.url =https://crisis.zhiweidata.com/event/{1}/general?share={2}
...
@@ -87,7 +87,10 @@ crisis.event.url =https://crisis.zhiweidata.com/event/{1}/general?share={2}
trends.longTimeInListSearchByInner.url
=
https://trends.zhiweidata.com/hotSearchTrend/inner/longTimeInListSearchByInner?sortType={1}&type={2}&day={3}
trends.longTimeInListSearchByInner.url
=
https://trends.zhiweidata.com/hotSearchTrend/inner/longTimeInListSearchByInner?sortType={1}&type={2}&day={3}
trends.findHotSearchESDataInTimeByInner.url
=
https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/findHotSearchESDataInTimeByInner?limit={1}&page={2}&type={3}&word={4}
trends.findHotSearchESDataInTimeByInner.url
=
https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/findHotSearchESDataInTimeByInner?limit={1}&page={2}&type={3}&word={4}
trends.longTimeInListSearch.url
=
https://trends.zhiweidata.com/hotSearchTrend/search/longTimeInListSearch?type={1}&sortType=realTime
trends.longTimeInListSearch.url
=
https://trends.zhiweidata.com/hotSearchTrend/search/longTimeInListSearch?type={1}&sortType=realTime
trends.getHotSearchFromEsInTimeAndTypeOrWord.url
=
https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/getHotSearchFromEsInTimeAndTypeOrWord?limit={1}&page={2}&type={3}&word={4}&sort={5}
trends.getHotSearchFromEsInTimeAndTypeOrWord.url
=
http://192.168.0.192:9091/hotsearch/hotSearch/getHotSearchFromEsInTimeAndTypeOrWord?limit={1}&page={2}&type={3}&word={4}&sort={5}&accurateWord={6}
trends.queryHotSearchTrendInner.url
=
http://192.168.27.203:9094/hotSearchTrend/inner/queryHotSearchTrendInner?name={1}&startTime={2}&type={3}
trends.getHotSearchSnapshot.url
=
https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/getHotSearchSnapshot?type={1}&time={2}&rank={3}
#\u4E8B\u4EF6\u5E93\u5916\u90E8\u63A5\u53E3
#\u4E8B\u4EF6\u5E93\u5916\u90E8\u63A5\u53E3
ef.search.url
=
https://ef.zhiweidata.com/external/search.do?name={1}&page={2}&size={3}
ef.search.url
=
https://ef.zhiweidata.com/external/search.do?name={1}&page={2}&size={3}
ef.searchCriteria.url
=
https://ef.zhiweidata.com/index/getSearchKey.do
ef.searchCriteria.url
=
https://ef.zhiweidata.com/index/getSearchKey.do
...
...
src/main/resources/application-prod.properties
View file @
7ad4922d
...
@@ -84,7 +84,9 @@ crisis.event.url =https://crisis.zhiweidata.com/event/{1}/general?share={2}
...
@@ -84,7 +84,9 @@ crisis.event.url =https://crisis.zhiweidata.com/event/{1}/general?share={2}
trends.longTimeInListSearchByInner.url
=
https://trends.zhiweidata.com/hotSearchTrend/inner/longTimeInListSearchByInner?sortType={1}&type={2}&day={3}
trends.longTimeInListSearchByInner.url
=
https://trends.zhiweidata.com/hotSearchTrend/inner/longTimeInListSearchByInner?sortType={1}&type={2}&day={3}
trends.findHotSearchESDataInTimeByInner.url
=
https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/findHotSearchESDataInTimeByInner?limit={1}&page={2}&type={3}&word={4}
trends.findHotSearchESDataInTimeByInner.url
=
https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/findHotSearchESDataInTimeByInner?limit={1}&page={2}&type={3}&word={4}
trends.longTimeInListSearch.url
=
https://trends.zhiweidata.com/hotSearchTrend/search/longTimeInListSearch?type={1}&sortType=realTime
trends.longTimeInListSearch.url
=
https://trends.zhiweidata.com/hotSearchTrend/search/longTimeInListSearch?type={1}&sortType=realTime
trends.getHotSearchFromEsInTimeAndTypeOrWord.url
=
https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/getHotSearchFromEsInTimeAndTypeOrWord?limit={1}&page={2}&type={3}&word={4}&sort={5}
trends.getHotSearchFromEsInTimeAndTypeOrWord.url
=
https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/getHotSearchFromEsInTimeAndTypeOrWord?limit={1}&page={2}&type={3}&word={4}&sort={5}&accurateWord={6}
trends.queryHotSearchTrendInner.url
=
https://trends.zhiweidata.com/hotSearchTrend/inner/queryHotSearchTrendInner?name={1}&startTime={2}&type={3}
trends.getHotSearchSnapshot.url
=
https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/getHotSearchSnapshot?type={1}&time={2}&rank={3}
#\u4E8B\u4EF6\u5E93\u5916\u90E8\u63A5\u53E3
#\u4E8B\u4EF6\u5E93\u5916\u90E8\u63A5\u53E3
ef.search.url
=
https://ef.zhiweidata.com/external/search.do?name={1}&page={2}
ef.search.url
=
https://ef.zhiweidata.com/external/search.do?name={1}&page={2}
ef.searchCriteria.url
=
https://ef.zhiweidata.com/index/getSearchKey.do
ef.searchCriteria.url
=
https://ef.zhiweidata.com/index/getSearchKey.do
...
...
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