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
fac87a3b
Commit
fac87a3b
authored
Aug 22, 2023
by
陈健智
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
渠道库榜单调整
parent
af665bc2
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
23 deletions
+54
-23
src/main/java/com/zhiwei/brandkbs2/controller/app/AppChannelController.java
+3
-3
src/main/java/com/zhiwei/brandkbs2/service/ChannelService.java
+3
-3
src/main/java/com/zhiwei/brandkbs2/service/impl/ChannelServiceImpl.java
+45
-17
src/main/java/com/zhiwei/brandkbs2/service/impl/TaskServiceImpl.java
+3
-0
No files found.
src/main/java/com/zhiwei/brandkbs2/controller/app/AppChannelController.java
View file @
fac87a3b
...
@@ -260,7 +260,7 @@ public class AppChannelController extends BaseController {
...
@@ -260,7 +260,7 @@ public class AppChannelController extends BaseController {
@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
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"50"
)
int
size
)
{
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"50"
)
int
size
)
{
return
ResponseResult
.
success
(
channelService
.
getActiveChannelList
(
contendId
,
startTime
,
endTime
,
size
));
return
ResponseResult
.
success
(
channelService
.
getActiveChannelList
(
contendId
,
startTime
,
endTime
,
size
,
true
));
}
}
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"contendId"
,
value
=
"品牌id"
,
defaultValue
=
"0"
,
paramType
=
"query"
,
dataType
=
"string"
),
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"contendId"
,
value
=
"品牌id"
,
defaultValue
=
"0"
,
paramType
=
"query"
,
dataType
=
"string"
),
...
@@ -275,7 +275,7 @@ public class AppChannelController extends BaseController {
...
@@ -275,7 +275,7 @@ public class AppChannelController extends BaseController {
@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
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"50"
)
int
size
)
{
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"50"
)
int
size
)
{
return
ResponseResult
.
success
(
channelService
.
getPositiveChannelList
(
contendId
,
startTime
,
endTime
,
size
));
return
ResponseResult
.
success
(
channelService
.
getPositiveChannelList
(
contendId
,
startTime
,
endTime
,
size
,
true
));
}
}
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"contendId"
,
value
=
"品牌id"
,
defaultValue
=
"0"
,
paramType
=
"query"
,
dataType
=
"string"
),
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"contendId"
,
value
=
"品牌id"
,
defaultValue
=
"0"
,
paramType
=
"query"
,
dataType
=
"string"
),
...
@@ -290,7 +290,7 @@ public class AppChannelController extends BaseController {
...
@@ -290,7 +290,7 @@ public class AppChannelController extends BaseController {
@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
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"50"
)
int
size
)
{
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"50"
)
int
size
)
{
return
ResponseResult
.
success
(
channelService
.
getNegativeChannelList
(
contendId
,
startTime
,
endTime
,
size
));
return
ResponseResult
.
success
(
channelService
.
getNegativeChannelList
(
contendId
,
startTime
,
endTime
,
size
,
true
));
}
}
@ApiOperation
(
"渠道库-渠道申请"
)
@ApiOperation
(
"渠道库-渠道申请"
)
...
...
src/main/java/com/zhiwei/brandkbs2/service/ChannelService.java
View file @
fac87a3b
...
@@ -159,7 +159,7 @@ public interface ChannelService {
...
@@ -159,7 +159,7 @@ public interface ChannelService {
* @param size 数据量
* @param size 数据量
* @return
* @return
*/
*/
JSONObject
getActiveChannelList
(
String
contendId
,
Long
startTime
,
Long
endTime
,
int
size
);
JSONObject
getActiveChannelList
(
String
contendId
,
Long
startTime
,
Long
endTime
,
int
size
,
boolean
cache
);
/**
/**
* 新-友好渠道榜
* 新-友好渠道榜
...
@@ -169,7 +169,7 @@ public interface ChannelService {
...
@@ -169,7 +169,7 @@ public interface ChannelService {
* @param size 数据量
* @param size 数据量
* @return
* @return
*/
*/
JSONObject
getPositiveChannelList
(
String
contendId
,
Long
startTime
,
Long
endTime
,
int
size
);
JSONObject
getPositiveChannelList
(
String
contendId
,
Long
startTime
,
Long
endTime
,
int
size
,
boolean
cache
);
/**
/**
* 新-敏感渠道榜
* 新-敏感渠道榜
...
@@ -179,7 +179,7 @@ public interface ChannelService {
...
@@ -179,7 +179,7 @@ public interface ChannelService {
* @param size 数据量
* @param size 数据量
* @return
* @return
*/
*/
JSONObject
getNegativeChannelList
(
String
contendId
,
Long
startTime
,
Long
endTime
,
int
size
);
JSONObject
getNegativeChannelList
(
String
contendId
,
Long
startTime
,
Long
endTime
,
int
size
,
boolean
cache
);
/**
/**
* 收藏渠道
* 收藏渠道
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/ChannelServiceImpl.java
View file @
fac87a3b
...
@@ -450,18 +450,18 @@ public class ChannelServiceImpl implements ChannelService {
...
@@ -450,18 +450,18 @@ public class ChannelServiceImpl implements ChannelService {
}
}
@Override
@Override
public
JSONObject
getActiveChannelList
(
String
contendId
,
Long
startTime
,
Long
endTime
,
int
size
)
{
public
JSONObject
getActiveChannelList
(
String
contendId
,
Long
startTime
,
Long
endTime
,
int
size
,
boolean
cache
)
{
return
getChannelListCache
(
contendId
,
startTime
,
endTime
,
EmotionEnum
.
ALL
.
getState
(),
size
,
tru
e
);
return
getChannelListCache
(
contendId
,
startTime
,
endTime
,
EmotionEnum
.
ALL
.
getState
(),
size
,
cach
e
);
}
}
@Override
@Override
public
JSONObject
getPositiveChannelList
(
String
contendId
,
Long
startTime
,
Long
endTime
,
int
size
)
{
public
JSONObject
getPositiveChannelList
(
String
contendId
,
Long
startTime
,
Long
endTime
,
int
size
,
boolean
cache
)
{
return
getChannelListCache
(
contendId
,
startTime
,
endTime
,
EmotionEnum
.
POSITIVE
.
getState
(),
size
,
tru
e
);
return
getChannelListCache
(
contendId
,
startTime
,
endTime
,
EmotionEnum
.
POSITIVE
.
getState
(),
size
,
cach
e
);
}
}
@Override
@Override
public
JSONObject
getNegativeChannelList
(
String
contendId
,
Long
startTime
,
Long
endTime
,
int
size
)
{
public
JSONObject
getNegativeChannelList
(
String
contendId
,
Long
startTime
,
Long
endTime
,
int
size
,
boolean
cache
)
{
return
getChannelListCache
(
contendId
,
startTime
,
endTime
,
EmotionEnum
.
NEGATIVE
.
getState
(),
size
,
tru
e
);
return
getChannelListCache
(
contendId
,
startTime
,
endTime
,
EmotionEnum
.
NEGATIVE
.
getState
(),
size
,
cach
e
);
}
}
private
JSONObject
getChannelListCache
(
String
contendId
,
Long
startTime
,
Long
endTime
,
int
emotion
,
int
size
,
boolean
cache
)
{
private
JSONObject
getChannelListCache
(
String
contendId
,
Long
startTime
,
Long
endTime
,
int
emotion
,
int
size
,
boolean
cache
)
{
...
@@ -486,8 +486,7 @@ public class ChannelServiceImpl implements ChannelService {
...
@@ -486,8 +486,7 @@ public class ChannelServiceImpl implements ChannelService {
private
JSONObject
getChannelList
(
String
projectId
,
String
contendId
,
Long
startTime
,
Long
endTime
,
int
emotion
,
int
size
)
throws
IOException
{
private
JSONObject
getChannelList
(
String
projectId
,
String
contendId
,
Long
startTime
,
Long
endTime
,
int
emotion
,
int
size
)
throws
IOException
{
JSONObject
res
=
new
JSONObject
(
new
LinkedHashMap
<>());
JSONObject
res
=
new
JSONObject
(
new
LinkedHashMap
<>());
Map
<
String
,
Pair
<
Long
,
ChannelRecord
>>
keyMap
=
new
HashMap
<>();
Map
<
String
,
Pair
<
Long
,
ChannelRecord
>>
keyMap
=
new
HashMap
<>();
EsClientDao
.
SearchHelper
searchHelper
=
createSearchHelperByChannelCriteria
(
projectId
,
null
,
EsClientDao
.
SearchHelper
searchHelper
=
createSearchHelperByChannelCriteria
(
projectId
,
Collections
.
singleton
(
contendId
),
startTime
,
endTime
,
true
);
Collections
.
singleton
(
contendId
),
null
,
null
,
startTime
,
endTime
);
// 分页查询所有结果
// 分页查询所有结果
List
<
SearchResponse
>
searchResponses
=
channelEsDao
.
searchScrollResponse
(
searchHelper
);
List
<
SearchResponse
>
searchResponses
=
channelEsDao
.
searchScrollResponse
(
searchHelper
);
for
(
SearchResponse
searchResponse
:
searchResponses
)
{
for
(
SearchResponse
searchResponse
:
searchResponses
)
{
...
@@ -1827,22 +1826,51 @@ public class ChannelServiceImpl implements ChannelService {
...
@@ -1827,22 +1826,51 @@ public class ChannelServiceImpl implements ChannelService {
query
.
must
(
QueryBuilders
.
termQuery
(
"channel_fid.keyword"
,
channel
.
getFid
()));
query
.
must
(
QueryBuilders
.
termQuery
(
"channel_fid.keyword"
,
channel
.
getFid
()));
}
}
// platformId
// platformId
String
platformId
=
GlobalPojo
.
getPlatformIdByName
(
platform
);
if
(
null
!=
platformId
)
{
query
.
must
(
QueryBuilders
.
termQuery
(
GenericAttribute
.
ES_PLATFORM_ID
,
platformId
));
}
else
if
(
GlobalPojo
.
ELSE_PLATFORM_NAME
.
equals
(
platform
))
{
// 不是 网媒,微博,微信,今日头条
EsQueryTools
.
platformMustNot
(
query
,
GlobalPojo
.
PERMANENT_PLATFORM_NAMES
.
toArray
(
new
String
[
0
]));
}
// keyword
if
(
StringUtils
.
isNotEmpty
(
keyword
))
{
query
.
must
(
EsQueryTools
.
assembleSourceQuery
(
keyword
));
}
// timeRange
// 默认搜索一周
if
(
defaultTime
&&
(
null
==
startTime
||
null
==
endTime
))
{
Long
[]
timeRangeWeek
=
commonService
.
getTimeRangeWeek
();
startTime
=
timeRangeWeek
[
0
];
endTime
=
timeRangeWeek
[
1
];
}
RangeQueryBuilder
timeRangeQuery
=
QueryBuilders
.
rangeQuery
(
"record.articles.time"
).
lt
(
endTime
);
if
(
null
!=
startTime
)
{
timeRangeQuery
.
gte
(
startTime
);
}
query
.
must
(
timeRangeQuery
);
helper
.
setQuery
(
query
);
return
helper
;
}
private
EsClientDao
.
SearchHelper
createSearchHelperByChannelCriteria
(
String
projectId
,
Collection
<
String
>
contendIds
,
Long
startTime
,
Long
endTime
,
boolean
defaultTime
)
{
EsClientDao
.
SearchHelper
helper
=
EsClientDao
.
createSearchHelper
();
// query
BoolQueryBuilder
query
=
QueryBuilders
.
boolQuery
();
// project和contendId
query
.
must
(
QueryBuilders
.
termQuery
(
"project_id.keyword"
,
projectId
));
// 添加contends集合 查询
if
(
null
!=
contendIds
)
{
EsQueryTools
.
assembleContendsQuery4Channel
(
query
,
contendIds
);
}
// platformId
List
<
String
>
platformIds
=
new
ArrayList
<>(
6
);
List
<
String
>
platformIds
=
new
ArrayList
<>(
6
);
for
(
String
platformName
:
PLATFORMS
)
{
for
(
String
platformName
:
PLATFORMS
)
{
platformIds
.
add
(
GlobalPojo
.
getPlatformIdByName
(
platformName
));
platformIds
.
add
(
GlobalPojo
.
getPlatformIdByName
(
platformName
));
}
}
// String platformId = GlobalPojo.getPlatformIdByName(platform);
if
(
CollectionUtils
.
isNotEmpty
(
platformIds
))
{
if
(
CollectionUtils
.
isNotEmpty
(
platformIds
))
{
query
.
must
(
QueryBuilders
.
termsQuery
(
GenericAttribute
.
ES_PLATFORM_ID
,
platformIds
));
query
.
must
(
QueryBuilders
.
termsQuery
(
GenericAttribute
.
ES_PLATFORM_ID
,
platformIds
));
}
}
// else if (GlobalPojo.ELSE_PLATFORM_NAME.equals(platform)) {
// // 不是 网媒,微博,微信,今日头条
// EsQueryTools.platformMustNot(query, GlobalPojo.PERMANENT_PLATFORM_NAMES.toArray(new String[0]));
// }
// keyword
if
(
StringUtils
.
isNotEmpty
(
keyword
))
{
query
.
must
(
EsQueryTools
.
assembleSourceQuery
(
keyword
));
}
// timeRange
// timeRange
// 默认搜索一周
// 默认搜索一周
if
(
defaultTime
&&
(
null
==
startTime
||
null
==
endTime
))
{
if
(
defaultTime
&&
(
null
==
startTime
||
null
==
endTime
))
{
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/TaskServiceImpl.java
View file @
fac87a3b
...
@@ -152,10 +152,13 @@ public class TaskServiceImpl implements TaskService {
...
@@ -152,10 +152,13 @@ public class TaskServiceImpl implements TaskService {
timeList
.
forEach
(
times
->
{
timeList
.
forEach
(
times
->
{
// 活跃渠道榜
// 活跃渠道榜
channelService
.
getActiveChannelList
(
Constant
.
PRIMARY_CONTEND_ID
,
null
,
null
,
times
[
0
],
times
[
1
],
50
,
false
);
channelService
.
getActiveChannelList
(
Constant
.
PRIMARY_CONTEND_ID
,
null
,
null
,
times
[
0
],
times
[
1
],
50
,
false
);
channelService
.
getActiveChannelList
(
Constant
.
PRIMARY_CONTEND_ID
,
times
[
0
],
times
[
1
],
50
,
false
);
// 友好渠道榜
// 友好渠道榜
channelService
.
getPositiveList
(
Constant
.
PRIMARY_CONTEND_ID
,
null
,
null
,
sorter
,
times
[
0
],
times
[
1
],
50
,
false
);
channelService
.
getPositiveList
(
Constant
.
PRIMARY_CONTEND_ID
,
null
,
null
,
sorter
,
times
[
0
],
times
[
1
],
50
,
false
);
channelService
.
getPositiveChannelList
(
Constant
.
PRIMARY_CONTEND_ID
,
times
[
0
],
times
[
1
],
50
,
false
);
// 敏感渠道榜
// 敏感渠道榜
channelService
.
getNegativeList
(
Constant
.
PRIMARY_CONTEND_ID
,
null
,
null
,
sorter
,
times
[
0
],
times
[
1
],
50
,
false
);
channelService
.
getNegativeList
(
Constant
.
PRIMARY_CONTEND_ID
,
null
,
null
,
sorter
,
times
[
0
],
times
[
1
],
50
,
false
);
channelService
.
getNegativeChannelList
(
Constant
.
PRIMARY_CONTEND_ID
,
times
[
0
],
times
[
1
],
50
,
false
);
});
});
log
.
info
(
"项目:{}-渠道榜单缓存已完成:{}个"
,
project
.
getProjectName
(),
total
.
incrementAndGet
());
log
.
info
(
"项目:{}-渠道榜单缓存已完成:{}个"
,
project
.
getProjectName
(),
total
.
incrementAndGet
());
return
null
;
return
null
;
...
...
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