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
34d25fdf
Commit
34d25fdf
authored
Aug 01, 2022
by
shentao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2022/8/1 前台品牌事件筛选、品牌事件列表
parent
0e7e2f1a
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
277 additions
and
3 deletions
+277
-3
src/main/java/com/zhiwei/brandkbs2/controller/app/AppEventController.java
+51
-0
src/main/java/com/zhiwei/brandkbs2/pojo/Event.java
+8
-0
src/main/java/com/zhiwei/brandkbs2/pojo/vo/EventListInfoVO.java
+82
-0
src/main/java/com/zhiwei/brandkbs2/service/EventService.java
+9
-0
src/main/java/com/zhiwei/brandkbs2/service/impl/EventServiceImpl.java
+125
-3
src/main/java/com/zhiwei/brandkbs2/util/Tools.java
+2
-0
No files found.
src/main/java/com/zhiwei/brandkbs2/controller/app/AppEventController.java
0 → 100644
View file @
34d25fdf
package
com
.
zhiwei
.
brandkbs2
.
controller
.
app
;
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.service.EventService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* @Description: 前台事件库
* @Author: shentao
* @Date: 2022/7/26 17:36
*/
@RestController
@RequestMapping
(
"/app/event"
)
@Api
(
tags
=
"前台事件库"
,
description
=
"提供前台事件相关信息展示"
)
@Auth
(
role
=
RoleEnum
.
CUSTOMER
)
public
class
AppEventController
extends
BaseController
{
private
final
EventService
eventService
;
public
AppEventController
(
EventService
eventService
)
{
this
.
eventService
=
eventService
;
}
@ApiOperation
(
"前台事件库-搜索条件"
)
@GetMapping
(
"/search/criteria"
)
public
ResponseResult
getEventsSearchCriteria
()
{
return
ResponseResult
.
success
(
eventService
.
getEventsSearchCriteria
());
}
@ApiOperation
(
"前台事件库-品牌事件库"
)
@GetMapping
(
"/list"
)
public
ResponseResult
getEventList
(
@RequestParam
(
value
=
"brandLinkedGroupId"
,
required
=
false
)
String
linkedGroupId
,
@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
(
linkedGroupId
,
emotion
,
startTime
,
endTime
,
page
,
pageSize
,
sorter
));
}
}
src/main/java/com/zhiwei/brandkbs2/pojo/Event.java
View file @
34d25fdf
...
...
@@ -74,6 +74,14 @@ public class Event extends AbstractBaseMongo {
* 是否是舆情事件
*/
private
String
yqEventId
;
/**
* 总传播量
*/
private
Long
totalDisseminationVolume
;
/**
* 参与渠道数
*/
private
Long
totalChannelVolume
;
public
static
Event
createFromYqEventDTO
(
YqEventDTO
yqEventDTO
,
String
collectionName
,
String
projectId
,
String
linkedGroupId
)
{
Event
event
=
new
Event
();
...
...
src/main/java/com/zhiwei/brandkbs2/pojo/vo/EventListInfoVO.java
0 → 100644
View file @
34d25fdf
package
com
.
zhiwei
.
brandkbs2
.
pojo
.
vo
;
import
com.zhiwei.brandkbs2.pojo.Event
;
import
com.zhiwei.brandkbs2.pojo.EventData
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.ToString
;
import
java.util.Date
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* @Description: 事件库列表VO
* @Author: shentao
* @Date: 2022/8/1 11:21
*/
@Data
@ToString
@ApiModel
(
"事件库列表事件信息展示类"
)
public
class
EventListInfoVO
{
/**
* 事件ID
*/
@ApiModelProperty
(
"事件ID"
)
private
String
id
;
/**
* 标题
*/
@ApiModelProperty
(
"标题"
)
private
String
title
;
/**
* 开始时间
*/
@ApiModelProperty
(
"开始时间"
)
private
Long
startTime
;
/**
* 影响力
*/
@ApiModelProperty
(
"影响力"
)
private
Double
influence
;
/**
* 总传播量
*/
@ApiModelProperty
(
"总传播量"
)
private
Long
totalDisseminationVolume
;
/**
* 参与渠道数
*/
@ApiModelProperty
(
"参与渠道数"
)
private
Long
totalChannelVolume
;
/**
* 事件调性
*/
@ApiModelProperty
(
"事件调性"
)
private
String
emotion
;
/**
* 事件标签
*/
@ApiModelProperty
(
"事件标签"
)
private
String
eventTag
;
/**
* 事件首发稿件
*/
@ApiModelProperty
(
"事件首发稿件"
)
private
EventData
firstEventData
;
public
EventListInfoVO
(
Event
event
)
{
this
.
id
=
event
.
getId
();
this
.
title
=
event
.
getTitle
();
this
.
startTime
=
event
.
getStartTime
();
this
.
influence
=
event
.
getInfluence
();
this
.
totalDisseminationVolume
=
event
.
getTotalDisseminationVolume
();
this
.
totalChannelVolume
=
event
.
getTotalChannelVolume
();
this
.
emotion
=
event
.
getEmotion
();
this
.
eventTag
=
event
.
getEventTag
().
entrySet
().
stream
()
.
map
(
entry
->
String
.
valueOf
(
entry
.
getValue
()))
.
collect
(
Collectors
.
joining
(
"|"
));
}
}
src/main/java/com/zhiwei/brandkbs2/service/EventService.java
View file @
34d25fdf
...
...
@@ -7,6 +7,7 @@ import com.zhiwei.brandkbs2.easyexcel.dto.UploadEventDTO;
import
com.zhiwei.brandkbs2.pojo.Event
;
import
com.zhiwei.brandkbs2.pojo.dto.EventDataDTO
;
import
com.zhiwei.brandkbs2.pojo.dto.YqEventDTO
;
import
com.zhiwei.brandkbs2.pojo.vo.EventListInfoVO
;
import
com.zhiwei.brandkbs2.pojo.vo.EventVO
;
import
com.zhiwei.brandkbs2.pojo.vo.PageVO
;
import
com.zhiwei.brandkbs2.pojo.vo.YqEventSearchVO
;
...
...
@@ -212,4 +213,12 @@ public interface EventService {
* @return 事件标签组名列表
*/
List
<
String
>
findEventTagGroupName
(
String
linkedGroupId
);
/**
* 获取品牌事件搜索条件
* @return
*/
JSONObject
getEventsSearchCriteria
();
PageVO
<
EventListInfoVO
>
getEventList
(
String
linkedGroupId
,
String
emotion
,
Long
startTime
,
Long
endTime
,
int
page
,
int
pageSize
,
String
sorter
);
}
src/main/java/com/zhiwei/brandkbs2/service/impl/EventServiceImpl.java
View file @
34d25fdf
...
...
@@ -15,6 +15,7 @@ import com.zhiwei.brandkbs2.easyexcel.dto.UploadEventDTO;
import
com.zhiwei.brandkbs2.easyexcel.dto.UploadEventDataDTO
;
import
com.zhiwei.brandkbs2.easyexcel.listener.EventDataListener
;
import
com.zhiwei.brandkbs2.easyexcel.listener.EventFileListener
;
import
com.zhiwei.brandkbs2.enmus.EmotionEnum
;
import
com.zhiwei.brandkbs2.enmus.EventTagEnum
;
import
com.zhiwei.brandkbs2.exception.ExceptionCast
;
import
com.zhiwei.brandkbs2.listener.ApplicationProjectListener
;
...
...
@@ -23,9 +24,7 @@ import com.zhiwei.brandkbs2.pojo.Event;
import
com.zhiwei.brandkbs2.pojo.EventData
;
import
com.zhiwei.brandkbs2.pojo.dto.EventDataDTO
;
import
com.zhiwei.brandkbs2.pojo.dto.YqEventDTO
;
import
com.zhiwei.brandkbs2.pojo.vo.EventVO
;
import
com.zhiwei.brandkbs2.pojo.vo.PageVO
;
import
com.zhiwei.brandkbs2.pojo.vo.YqEventSearchVO
;
import
com.zhiwei.brandkbs2.pojo.vo.*
;
import
com.zhiwei.brandkbs2.service.EventDataService
;
import
com.zhiwei.brandkbs2.service.EventService
;
import
com.zhiwei.brandkbs2.service.ProjectService
;
...
...
@@ -39,6 +38,7 @@ import org.apache.logging.log4j.LogManager;
import
org.apache.logging.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.data.mongodb.core.query.Update
;
...
...
@@ -49,6 +49,7 @@ import org.springframework.web.client.RestTemplate;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.annotation.Resource
;
import
java.text.ParseException
;
import
java.util.*
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.concurrent.TimeUnit
;
...
...
@@ -488,6 +489,127 @@ public class EventServiceImpl implements EventService {
return
Objects
.
requireNonNull
(
entity
.
getBody
()).
getJSONObject
(
"data"
).
getJSONArray
(
"tagNameList"
).
toJavaList
(
String
.
class
);
}
@Override
public
JSONObject
getEventsSearchCriteria
()
{
String
projectId
=
UserThreadLocal
.
getProjectId
();
JSONObject
result
=
new
JSONObject
();
// 品牌
result
.
put
(
"brands"
,
getBrands
(
projectId
));
// 事件调性
result
.
put
(
"emotions"
,
getEventEmotions
());
// 事件类型 todo 后续用筛选器配置,和品牌关联
// 时间
result
.
put
(
"times"
,
getDefaultTimes
());
// 传播量
result
.
put
(
"articleAmount"
,
Arrays
.
asList
(
"全部"
,
"1-100"
,
"100-500"
,
"1000-5000"
,
">5000"
));
return
result
;
}
@Override
public
PageVO
<
EventListInfoVO
>
getEventList
(
String
linkedGroupId
,
String
emotion
,
Long
startTime
,
Long
endTime
,
int
page
,
int
pageSize
,
String
sorter
)
{
String
projectId
=
UserThreadLocal
.
getProjectId
();
// 查询条件
Query
query
=
Query
.
query
(
Criteria
.
where
(
"projectId"
).
is
(
projectId
).
and
(
"linkedGroupId"
).
is
(
linkedGroupId
));
if
(
Objects
.
nonNull
(
emotion
)
&&
!
"全部"
.
equals
(
emotion
))
{
query
.
addCriteria
(
Criteria
.
where
(
"emotion"
).
is
(
emotion
));
}
if
(
Objects
.
nonNull
(
startTime
)
&&
Objects
.
nonNull
(
endTime
))
{
query
.
addCriteria
(
Criteria
.
where
(
"startTime"
).
gte
(
new
Date
(
startTime
)).
lt
(
new
Date
(
endTime
)));
}
// 排序
JSONObject
sortJson
=
JSONObject
.
parseObject
(
sorter
);
sortJson
.
entrySet
().
forEach
(
sortEntry
->
{
String
sort
=
String
.
valueOf
(
sortEntry
.
getValue
()).
replace
(
"end"
,
""
);
String
sortField
=
sortEntry
.
getKey
();
if
(
Sort
.
Direction
.
ASC
.
name
().
equalsIgnoreCase
(
sort
))
{
query
.
with
(
Sort
.
by
(
Sort
.
Direction
.
ASC
,
sortField
));
}
else
{
query
.
with
(
Sort
.
by
(
Sort
.
Direction
.
DESC
,
sortField
));
}
});
// 总数
long
total
=
eventDao
.
count
(
query
);
int
start
=
pageSize
*
(
page
-
1
);
query
.
limit
(
pageSize
).
skip
(
start
);
// 数据
List
<
Event
>
eventList
=
eventDao
.
findList
(
query
);
// vo封装
List
<
EventListInfoVO
>
eventListInfoVOList
=
eventList
.
stream
()
.
map
(
event
->
{
EventListInfoVO
vo
=
new
EventListInfoVO
(
event
);
// 放入首发稿件
vo
.
setFirstEventData
(
eventDataDao
.
findFirstData
(
event
.
getId
(),
event
.
getCollectionName
()));
return
vo
;
})
.
collect
(
Collectors
.
toList
());
PageVO
<
EventListInfoVO
>
pageVo
=
PageVO
.
createPageVo
(
total
,
page
,
pageSize
,
eventListInfoVOList
);
return
pageVo
;
}
/**
* 获取时间筛选条件
*
* @return
*/
private
List
<
JSONObject
>
getDefaultTimes
()
{
String
year
=
Tools
.
DF_YEAR
.
format
(
new
Date
());
int
yearInt
=
Integer
.
parseInt
(
year
);
List
<
Integer
>
years
=
Arrays
.
asList
(
yearInt
,
yearInt
-
1
,
yearInt
-
2
);
List
<
JSONObject
>
collect
=
years
.
stream
()
.
map
(
yearInfo
->
{
JSONObject
result
=
new
JSONObject
();
try
{
String
yearStr
=
String
.
valueOf
(
yearInfo
);
result
.
put
(
"name"
,
yearStr
);
result
.
put
(
"startTime"
,
Tools
.
DF_YEAR
.
parse
(
yearStr
));
result
.
put
(
"endTime"
,
Tools
.
DF_YEAR
.
parse
(
yearStr
));
}
catch
(
ParseException
e
)
{
throw
new
RuntimeException
(
e
);
}
return
result
;
})
.
collect
(
Collectors
.
toList
());
return
collect
;
}
/**
* 获取事件调性筛选条件
*
* @return
*/
private
List
<
JSONObject
>
getEventEmotions
()
{
List
<
EmotionEnum
>
emotionEnums
=
Arrays
.
asList
(
EmotionEnum
.
ALL
,
EmotionEnum
.
POSITIVE
,
EmotionEnum
.
NEUTRAL
,
EmotionEnum
.
NEGATIVE
);
return
emotionEnums
.
stream
().
map
(
emotion
->
{
JSONObject
result
=
new
JSONObject
();
result
.
put
(
"id"
,
emotion
.
getState
());
result
.
put
(
"name"
,
emotion
.
getName
());
return
result
;
}).
collect
(
Collectors
.
toList
());
}
/**
* 获取项目品牌信息s
*
* @param projectId
* @return
*/
private
List
<
JSONObject
>
getBrands
(
String
projectId
)
{
ProjectVO
projectVO
=
projectService
.
getProjectVOById
(
projectId
);
JSONObject
priBrandResult
=
new
JSONObject
();
priBrandResult
.
put
(
"id"
,
projectVO
.
getBrandLinkedGroupId
());
priBrandResult
.
put
(
"name"
,
projectVO
.
getBrandLinkedGroup
());
List
<
JSONObject
>
resultList
=
projectVO
.
getContendList
().
stream
()
.
map
(
contend
->
{
JSONObject
result
=
new
JSONObject
();
result
.
put
(
"id"
,
contend
.
getBrandLinkedGroupId
());
result
.
put
(
"name"
,
contend
.
getBrandName
());
return
result
;
})
.
collect
(
Collectors
.
toList
());
resultList
.
add
(
0
,
priBrandResult
);
return
resultList
;
}
private
boolean
isFirstData
(
Event
event
,
String
eventDataId
)
{
EventData
firstData
=
eventDataDao
.
findFirstData
(
event
.
getId
(),
event
.
getCollectionName
());
if
(
null
==
firstData
)
{
...
...
src/main/java/com/zhiwei/brandkbs2/util/Tools.java
View file @
34d25fdf
...
...
@@ -59,6 +59,8 @@ public class Tools {
private
static
final
FastDateFormat
DF
=
FastDateFormat
.
getInstance
(
"yyyyMMddHHmmss"
);
public
static
final
FastDateFormat
DF_YEAR
=
FastDateFormat
.
getInstance
(
"yyyy"
);
private
static
final
Pattern
PATTERN
=
Pattern
.
compile
(
"[^a-zA-Z0-9\\u4E00-\\u9FA5]"
);
private
static
final
DozerBeanMapper
DOZER_BEAN_MAPPER
=
new
DozerBeanMapper
();
...
...
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