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
aaeb0883
Commit
aaeb0883
authored
Aug 22, 2022
by
shenjunjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2022/8/22 15:41
parent
628bd882
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
114 additions
and
48 deletions
+114
-48
src/main/java/com/zhiwei/brandkbs2/controller/app/AppEventController.java
+4
-9
src/main/java/com/zhiwei/brandkbs2/pojo/dto/EventSearchDTO.java
+45
-13
src/main/java/com/zhiwei/brandkbs2/pojo/vo/EventListInfoVO.java
+2
-3
src/main/java/com/zhiwei/brandkbs2/service/EventService.java
+3
-8
src/main/java/com/zhiwei/brandkbs2/service/impl/EventServiceImpl.java
+43
-10
src/main/java/com/zhiwei/brandkbs2/service/impl/IndexServiceImpl.java
+16
-4
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkDataServiceImpl.java
+1
-1
No files found.
src/main/java/com/zhiwei/brandkbs2/controller/app/AppEventController.java
View file @
aaeb0883
...
...
@@ -6,6 +6,7 @@ import com.zhiwei.brandkbs2.auth.Auth;
import
com.zhiwei.brandkbs2.controller.BaseController
;
import
com.zhiwei.brandkbs2.enmus.RoleEnum
;
import
com.zhiwei.brandkbs2.model.ResponseResult
;
import
com.zhiwei.brandkbs2.pojo.dto.EventSearchDTO
;
import
com.zhiwei.brandkbs2.service.EventService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
...
...
@@ -56,15 +57,9 @@ public class AppEventController extends BaseController {
}
@ApiOperation
(
"前台事件库-品牌事件库"
)
@GetMapping
(
"/list"
)
public
ResponseResult
getEventList
(
@RequestParam
(
value
=
"contendId"
,
defaultValue
=
"0"
)
String
contendId
,
@RequestParam
(
value
=
"emotion"
,
defaultValue
=
"全部"
)
String
emotion
,
@RequestParam
(
value
=
"startTime"
,
required
=
false
)
Long
startTime
,
@RequestParam
(
value
=
"endTime"
,
required
=
false
)
Long
endTime
,
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
int
page
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"50"
)
int
pageSize
,
@RequestParam
(
value
=
"sorter"
,
required
=
false
)
String
sorter
)
{
return
ResponseResult
.
success
(
eventService
.
getEventList
(
contendId
,
emotion
,
startTime
,
endTime
,
page
,
pageSize
,
sorter
));
@PostMapping
(
"/list"
)
public
ResponseResult
getEventList
(
@RequestBody
EventSearchDTO
eventSearchDTO
)
{
return
ResponseResult
.
success
(
eventService
.
getEventList
(
eventSearchDTO
));
}
@ApiOperation
(
"前台事件库-事件详情-基础信息"
)
...
...
src/main/java/com/zhiwei/brandkbs2/pojo/dto/EventSearchDTO.java
View file @
aaeb0883
package
com
.
zhiwei
.
brandkbs2
.
pojo
.
dto
;
import
com.alibaba.fastjson.JSONObject
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.ToString
;
import
java.util.List
;
import
java.util.Map
;
/**
* @ClassName: EventSearchDto
...
...
@@ -19,18 +19,50 @@ import java.util.Map;
@ApiModel
(
"事件信息传输类"
)
public
class
EventSearchDTO
{
private
Map
<
String
,
List
<
String
>>
tags
;
@ApiModelProperty
(
"搜索条件"
)
private
String
searchInfo
;
private
Integer
page
;
private
Integer
pageSize
;
private
Integer
brandId
;
/**
* 页码
*/
@ApiModelProperty
(
"页码"
)
private
Integer
page
=
1
;
/**
* 大小
*/
@ApiModelProperty
(
"页码大小"
)
private
Integer
pageSize
=
50
;
/**
* 开始时间
*/
@ApiModelProperty
(
"开始时间"
)
private
Long
startTime
;
/**
* 结束时间
*/
@ApiModelProperty
(
"结束时间"
)
private
Long
endTime
;
/**
* 品牌ID结合
*/
@ApiModelProperty
(
value
=
"品牌ID"
)
private
String
contendId
=
"0"
;
/**
* 情感倾向集合
*/
@ApiModelProperty
(
value
=
"情感倾向集合"
)
private
List
<
String
>
emotions
;
/**
* 排序字段
*/
@ApiModelProperty
(
value
=
"排序字段"
)
private
JSONObject
sorter
=
JSONObject
.
parseObject
(
"{\"startTime\":\"descend\"}"
);
/**
* 搜索关键词
*/
@ApiModelProperty
(
value
=
"关键词"
)
private
String
keyword
;
/**
* 传播量
*/
@ApiModelProperty
(
value
=
"传播量"
)
private
Long
[]
totalDisseminationVolumes
;
}
src/main/java/com/zhiwei/brandkbs2/pojo/vo/EventListInfoVO.java
View file @
aaeb0883
package
com
.
zhiwei
.
brandkbs2
.
pojo
.
vo
;
import
com.alibaba.fastjson.JSONObject
;
import
com.zhiwei.brandkbs2.enmus.EventTagEnum
;
import
com.zhiwei.brandkbs2.pojo.Event
;
import
com.zhiwei.brandkbs2.pojo.EventData
;
import
io.swagger.annotations.ApiModel
;
...
...
@@ -8,8 +9,6 @@ import io.swagger.annotations.ApiModelProperty;
import
lombok.Data
;
import
lombok.ToString
;
import
java.util.stream.Collectors
;
/**
* @Description: 事件库列表VO
* @Author: shentao
...
...
@@ -89,7 +88,7 @@ public class EventListInfoVO {
this
.
totalDisseminationVolume
=
event
.
getTotalDisseminationVolume
();
this
.
totalChannelVolume
=
event
.
getTotalChannelVolume
();
this
.
emotion
=
event
.
getEmotion
();
this
.
eventTag
=
event
.
getEventTag
().
values
().
stream
().
map
(
String:
:
valueOf
).
collect
(
Collectors
.
joining
(
"|"
));
this
.
eventTag
=
null
==
event
.
getEventTag
()
?
null
:
event
.
getEventTag
().
getString
(
EventTagEnum
.
EVENT_TYPE
.
getName
(
));
this
.
negativeArticleVolume
=
event
.
getNegativeArticleVolume
();
this
.
articleEmotionProportions
=
event
.
getArticleEmotionProportions
();
this
.
articlePlatformProportions
=
event
.
getArticlePlatformProportions
();
...
...
src/main/java/com/zhiwei/brandkbs2/service/EventService.java
View file @
aaeb0883
...
...
@@ -7,6 +7,7 @@ import com.zhiwei.brandkbs2.easyexcel.dto.UploadEventDTO;
import
com.zhiwei.brandkbs2.pojo.Event
;
import
com.zhiwei.brandkbs2.pojo.EventDisseminationTrend
;
import
com.zhiwei.brandkbs2.pojo.dto.EventDataDTO
;
import
com.zhiwei.brandkbs2.pojo.dto.EventSearchDTO
;
import
com.zhiwei.brandkbs2.pojo.dto.YqEventDTO
;
import
com.zhiwei.brandkbs2.pojo.vo.EventListInfoVO
;
import
com.zhiwei.brandkbs2.pojo.vo.EventVO
;
...
...
@@ -223,16 +224,10 @@ public interface EventService {
/**
* 获取品牌事件列表信息
* @param contendId
* @param emotion
* @param startTime
* @param endTime
* @param page
* @param pageSize
* @param sorter
* @param eventSearchDTO 事件搜索类
* @return
*/
PageVO
<
EventListInfoVO
>
getEventList
(
String
contendId
,
String
emotion
,
Long
startTime
,
Long
endTime
,
int
page
,
int
pageSize
,
String
sorter
);
PageVO
<
EventListInfoVO
>
getEventList
(
EventSearchDTO
eventSearchDTO
);
/**
* 事件详情-基础静态信息
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/EventServiceImpl.java
View file @
aaeb0883
...
...
@@ -27,6 +27,7 @@ import com.zhiwei.brandkbs2.pojo.EventData;
import
com.zhiwei.brandkbs2.pojo.EventDisseminationTrend
;
import
com.zhiwei.brandkbs2.pojo.EventTopArticlesAnalysis
;
import
com.zhiwei.brandkbs2.pojo.dto.EventDataDTO
;
import
com.zhiwei.brandkbs2.pojo.dto.EventSearchDTO
;
import
com.zhiwei.brandkbs2.pojo.dto.YqEventDTO
;
import
com.zhiwei.brandkbs2.pojo.vo.*
;
import
com.zhiwei.brandkbs2.service.EventDataService
;
...
...
@@ -522,26 +523,35 @@ public class EventServiceImpl implements EventService {
// 时间
result
.
put
(
"times"
,
getDefaultTimes
());
// 传播量
result
.
put
(
"
articleAmount"
,
Arrays
.
asList
(
"全部"
,
"1-100"
,
"100-500"
,
"1000-5000"
,
">5000"
));
result
.
put
(
"
totalDisseminationVolume"
,
getDefaultVolumes
(
));
return
result
;
}
@Override
public
PageVO
<
EventListInfoVO
>
getEventList
(
String
contendId
,
String
emotion
,
Long
startTime
,
Long
endTime
,
int
page
,
int
pageSize
,
String
sorter
)
{
public
PageVO
<
EventListInfoVO
>
getEventList
(
EventSearchDTO
eventSearchDTO
)
{
String
projectId
=
UserThreadLocal
.
getProjectId
();
// 查询条件
Query
query
=
Query
.
query
(
Criteria
.
where
(
"projectId"
).
is
(
projectId
).
and
(
"contendId"
).
is
(
contendId
));
if
(
Objects
.
nonNull
(
emotion
)
&&
!
"全部"
.
equals
(
emotion
))
{
query
.
addCriteria
(
Criteria
.
where
(
"emotion"
).
is
(
emotion
));
Query
query
=
Query
.
query
(
Criteria
.
where
(
"projectId"
).
is
(
projectId
).
and
(
"contendId"
).
is
(
eventSearchDTO
.
getContendId
()));
if
(!(
Objects
.
isNull
(
eventSearchDTO
.
getEmotions
())
||
eventSearchDTO
.
getEmotions
().
contains
(
"全部"
)))
{
query
.
addCriteria
(
Criteria
.
where
(
"emotion"
).
in
(
eventSearchDTO
.
getEmotions
()));
}
if
(
Objects
.
nonNull
(
eventSearchDTO
.
getStartTime
())
&&
Objects
.
nonNull
(
eventSearchDTO
.
getEndTime
()))
{
query
.
addCriteria
(
Criteria
.
where
(
"startTime"
).
gte
(
eventSearchDTO
.
getStartTime
()).
lt
(
eventSearchDTO
.
getEndTime
()));
}
// 传播量
if
(
Objects
.
nonNull
(
eventSearchDTO
.
getTotalDisseminationVolumes
()))
{
Long
[]
totalDisseminationVolumes
=
eventSearchDTO
.
getTotalDisseminationVolumes
();
Criteria
volumeCriteria
=
Criteria
.
where
(
"totalDisseminationVolume"
).
gte
(
totalDisseminationVolumes
[
0
]);
if
(-
1
!=
totalDisseminationVolumes
[
1
])
{
volumeCriteria
.
lt
(
totalDisseminationVolumes
[
1
]);
}
if
(
Objects
.
nonNull
(
startTime
)
&&
Objects
.
nonNull
(
endTime
))
{
query
.
addCriteria
(
Criteria
.
where
(
"startTime"
).
gte
(
startTime
).
lt
(
endTime
));
query
.
addCriteria
(
volumeCriteria
);
}
// 总数
long
total
=
eventDao
.
count
(
query
);
// 排序
eventDao
.
addSort
(
query
,
sorter
);
mongoUtil
.
start
(
page
,
pageSize
,
query
);
eventDao
.
addSort
(
query
,
eventSearchDTO
.
getSorter
().
toJSONString
()
);
mongoUtil
.
start
(
eventSearchDTO
.
getPage
(),
eventSearchDTO
.
getPageSize
()
,
query
);
// 数据
List
<
Event
>
eventList
=
eventDao
.
findList
(
query
);
// vo封装
...
...
@@ -558,7 +568,8 @@ public class EventServiceImpl implements EventService {
sortMap
.
get
(
event
.
getId
()).
setFirstEventData
(
r
);
return
null
;
})).
toArray
(
CompletableFuture
[]::
new
)).
join
();
return
PageVO
.
createPageVo
(
total
,
page
,
pageSize
,
eventList
.
stream
().
map
(
event
->
sortMap
.
get
(
event
.
getId
())).
collect
(
Collectors
.
toList
()));
return
PageVO
.
createPageVo
(
total
,
eventSearchDTO
.
getPage
(),
eventSearchDTO
.
getPageSize
(),
eventList
.
stream
().
map
(
event
->
sortMap
.
get
(
event
.
getId
())).
collect
(
Collectors
.
toList
()));
}
@Override
...
...
@@ -659,6 +670,28 @@ public class EventServiceImpl implements EventService {
}).
collect
(
Collectors
.
toList
());
}
private
List
<
JSONObject
>
getDefaultVolumes
()
{
List
<
JSONObject
>
res
=
new
ArrayList
<>();
for
(
String
name
:
Arrays
.
asList
(
"全部"
,
"1-100"
,
"100-1000"
,
"1000-5000"
,
">=5000"
))
{
JSONObject
json
=
new
JSONObject
();
json
.
put
(
"name"
,
name
);
switch
(
name
)
{
case
"全部"
:
json
.
put
(
"totalDisseminationVolumes"
,
null
);
break
;
case
">=5000"
:
json
.
put
(
"totalDisseminationVolumes"
,
new
Long
[]{
5000L
,
-
1L
});
break
;
default
:
String
[]
split
=
name
.
split
(
"-"
);
json
.
put
(
"totalDisseminationVolumes"
,
new
Long
[]{
Long
.
parseLong
(
split
[
0
]),
Long
.
parseLong
(
split
[
1
])});
}
res
.
add
(
json
);
}
return
res
;
}
/**
* 获取事件调性筛选条件
*
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/IndexServiceImpl.java
View file @
aaeb0883
...
...
@@ -428,13 +428,25 @@ public class IndexServiceImpl implements IndexService {
*/
private
JSONObject
getTopSource
(
long
startTime
,
long
endTime
,
String
projectId
,
String
linkedGroupId
,
String
contendId
)
throws
IOException
{
JSONObject
result
=
new
JSONObject
();
List
<
Map
<
String
,
Object
>>
positiveList
=
markDataService
.
getEsTopSource
(
startTime
,
endTime
,
projectId
,
linkedGroupId
,
contendId
,
EmotionEnum
.
POSITIVE
.
getName
(),
3
);
List
<
Map
<
String
,
Object
>>
negativeList
=
markDataService
.
getEsTopSource
(
startTime
,
endTime
,
projectId
,
linkedGroupId
,
contendId
,
EmotionEnum
.
NEGATIVE
.
getName
(),
1
);
result
.
put
(
"positiveList"
,
positiveList
);
result
.
put
(
"negativeList"
,
negativeList
);
// TODO 等待线上es数据格式调整
// List<Map<String, Object>> positiveList = markDataService.getEsTopSource(startTime, endTime, projectId, linkedGroupId, contendId, EmotionEnum.POSITIVE.getName(), 3);
// List<Map<String, Object>> negativeList = markDataService.getEsTopSource(startTime, endTime, projectId, linkedGroupId, contendId, EmotionEnum.NEGATIVE.getName(), 1);
result
.
put
(
"positiveList"
,
tempTopSource
());
result
.
put
(
"negativeList"
,
tempTopSource
());
return
result
;
}
private
List
<
Map
<
String
,
Object
>>
tempTopSource
()
{
List
<
Map
<
String
,
Object
>>
channelResultList
=
new
ArrayList
<>();
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
result
.
put
(
"id"
,
"testId"
);
result
.
put
(
"source"
,
"source"
);
result
.
put
(
"platform"
,
"微信"
);
result
.
put
(
"num"
,
"1"
);
channelResultList
.
add
(
result
);
return
channelResultList
;
}
/**
* 传播趋势
*
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkDataServiceImpl.java
View file @
aaeb0883
...
...
@@ -1302,7 +1302,7 @@ public class MarkDataServiceImpl implements MarkDataService {
public
List
<
Map
<
String
,
Object
>>
getEsTopSource
(
Long
startTime
,
Long
endTime
,
String
projectId
,
String
linkedGroupId
,
String
contendId
,
String
emotion
,
int
size
)
throws
IOException
{
EsClientDao
.
SearchHelper
searchHelper
=
EsClientDao
.
createSearchHelper
();
// 聚合条件
Script
script
=
new
Script
(
"doc['platform_id'].
keyword +'_' +doc['real_source'].keyword+'_' +doc['source'].keyword
"
);
Script
script
=
new
Script
(
"doc['platform_id'].
value +'_' +doc['real_source'].value+'_' +doc['source'].value
"
);
TermsAggregationBuilder
aggregationBuilder
=
AggregationBuilders
.
terms
(
"agg"
).
script
(
script
).
order
(
BucketOrder
.
count
(
false
));
searchHelper
.
setAggregationBuilder
(
aggregationBuilder
);
// query
...
...
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