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
6c536246
Commit
6c536246
authored
Mar 09, 2023
by
shenjunjie
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature' into 'dev'
Feature See merge request
!240
parents
574c80df
a8d2485a
Show whitespace changes
Inline
Side-by-side
Showing
32 changed files
with
912 additions
and
181 deletions
+912
-181
pom.xml
+1
-1
src/main/java/com/zhiwei/brandkbs2/aop/AopLogRecord.java
+55
-5
src/main/java/com/zhiwei/brandkbs2/config/Constant.java
+1
-0
src/main/java/com/zhiwei/brandkbs2/controller/CommonController.java
+13
-6
src/main/java/com/zhiwei/brandkbs2/controller/InterfaceController.java
+12
-0
src/main/java/com/zhiwei/brandkbs2/controller/admin/ProjectController.java
+5
-8
src/main/java/com/zhiwei/brandkbs2/controller/app/AppEventController.java
+9
-5
src/main/java/com/zhiwei/brandkbs2/controller/app/AppSearchController.java
+22
-0
src/main/java/com/zhiwei/brandkbs2/dao/EventMiddlewareDao.java
+306
-0
src/main/java/com/zhiwei/brandkbs2/dao/impl/EventMiddlewareDaoImpl.java
+213
-0
src/main/java/com/zhiwei/brandkbs2/model/ResponseResult.java
+5
-3
src/main/java/com/zhiwei/brandkbs2/pojo/Behavior.java
+5
-0
src/main/java/com/zhiwei/brandkbs2/pojo/Report.java
+1
-1
src/main/java/com/zhiwei/brandkbs2/pojo/dto/ExportSearchWholeDTO.java
+5
-3
src/main/java/com/zhiwei/brandkbs2/pojo/external/BrandkbsHotEventWarn.java
+5
-1
src/main/java/com/zhiwei/brandkbs2/pojo/vo/BehaviorVO.java
+5
-0
src/main/java/com/zhiwei/brandkbs2/service/EventService.java
+22
-0
src/main/java/com/zhiwei/brandkbs2/service/ReportService.java
+1
-1
src/main/java/com/zhiwei/brandkbs2/service/TaskService.java
+5
-0
src/main/java/com/zhiwei/brandkbs2/service/impl/BehaviorServiceImpl.java
+2
-2
src/main/java/com/zhiwei/brandkbs2/service/impl/ChannelServiceImpl.java
+25
-26
src/main/java/com/zhiwei/brandkbs2/service/impl/CommonServiceImpl.java
+1
-1
src/main/java/com/zhiwei/brandkbs2/service/impl/EventServiceImpl.java
+37
-30
src/main/java/com/zhiwei/brandkbs2/service/impl/IndexServiceImpl.java
+14
-13
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkDataServiceImpl.java
+38
-20
src/main/java/com/zhiwei/brandkbs2/service/impl/ProjectServiceImpl.java
+9
-8
src/main/java/com/zhiwei/brandkbs2/service/impl/ProjectWarnServiceImpl.java
+6
-5
src/main/java/com/zhiwei/brandkbs2/service/impl/ReportServiceImpl.java
+39
-28
src/main/java/com/zhiwei/brandkbs2/service/impl/TaskServiceImpl.java
+31
-10
src/main/java/com/zhiwei/brandkbs2/task/ControlCenter.java
+4
-3
src/main/java/com/zhiwei/brandkbs2/util/Tools.java
+14
-0
src/test/java/com/zhiwei/brandkbs2/ReportServiceTest.java
+1
-1
No files found.
pom.xml
View file @
6c536246
...
...
@@ -35,7 +35,7 @@
<dubbo.version>
2.7.4.1
</dubbo.version>
<curator.version>
2.12.0
</curator.version>
<push.log.version>
2.17.0-SNAPSHOT
</push.log.version>
<event-client.version>
1.0.
7
-SNAPSHOT
</event-client.version>
<event-client.version>
1.0.
8
-SNAPSHOT
</event-client.version>
</properties>
<dependencies>
...
...
src/main/java/com/zhiwei/brandkbs2/aop/AopLogRecord.java
View file @
6c536246
package
com
.
zhiwei
.
brandkbs2
.
aop
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.zhiwei.brandkbs2.common.GenericAttribute
;
import
com.zhiwei.brandkbs2.dao.BehaviorDao
;
import
com.zhiwei.brandkbs2.model.ResponseResult
;
import
com.zhiwei.brandkbs2.pojo.Behavior
;
import
com.zhiwei.brandkbs2.service.UserService
;
import
com.zhiwei.brandkbs2.util.Tools
;
...
...
@@ -9,8 +12,8 @@ import com.zhiwei.middleware.auth.util.JwtUtil;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.annotation.AfterReturning
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Before
;
import
org.aspectj.lang.reflect.MethodSignature
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
...
...
@@ -45,8 +48,8 @@ public class AopLogRecord {
private
static
final
List
<
String
>
URL_PATTERNS
=
Arrays
.
asList
(
"/getNewAll"
,
"/getNew"
,
"/schedule"
);
@
Before
(
"execution(public * com..controller..admin..*Controller.*(..)) || execution(* com..controller..app..*Controller.*(..))
"
)
private
void
beforeLog
(
JoinPoint
joinPoint
)
throws
UnknownHostException
,
ClassNotFoundException
,
NoSuchMethodException
{
@
AfterReturning
(
value
=
"execution(public * com..controller..admin..*Controller.*(..)) || execution(* com..controller..app..*Controller.*(..))"
,
returning
=
"ResponseResult
"
)
private
void
beforeLog
(
JoinPoint
joinPoint
,
ResponseResult
ResponseResult
)
throws
UnknownHostException
,
ClassNotFoundException
{
long
now
=
System
.
currentTimeMillis
();
// RequestContextHolder 顾名思义 持有 request 上下文的容器
ServletRequestAttributes
requestAttributes
=
(
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
();
...
...
@@ -87,8 +90,9 @@ public class AopLogRecord {
String
ipAddress
=
Tools
.
getIpAddress
(
request
);
// 接口传参信息
List
<
Map
<
String
,
Object
>>
arguments
=
getRequestArguments
(
joinPoint
);
Behavior
behavior
=
new
Behavior
(
userId
,
projectId
,
nickName
,
ipAddress
,
now
,
controller
,
method
,
backstage
,
uri
,
methodName
,
httpMethod
,
arguments
,
now
,
severAddress
);
Behavior
behavior
=
new
Behavior
(
userId
,
projectId
,
nickName
,
ipAddress
,
now
,
controller
,
method
,
backstage
,
uri
,
methodName
,
httpMethod
,
arguments
,
now
,
severAddress
,
null
);
setInfo
(
behavior
,
uri
,
joinPoint
,
methodSignature
,
arguments
,
ResponseResult
);
String
collectionName
=
behaviorDao
.
generateCollectionName
();
behaviorDao
.
insertOneWithoutId
(
behavior
,
collectionName
);
}
...
...
@@ -96,6 +100,52 @@ public class AopLogRecord {
}
/**
* 用户行为实体搜索关键词、渠道库渠道、事件详情事件名赋值
*
* @param behavior
* @param uri
* @param joinPoint
* @param methodSignature
* @param arguments
* @param ResponseResult
*/
private
void
setInfo
(
Behavior
behavior
,
String
uri
,
JoinPoint
joinPoint
,
MethodSignature
methodSignature
,
List
<
Map
<
String
,
Object
>>
arguments
,
ResponseResult
ResponseResult
)
{
String
record
=
null
;
Object
[]
args
=
joinPoint
.
getArgs
();
// 搜索接口关键词记录
if
(
uri
.
contains
(
"/app/search"
)
&&
!
Tools
.
isEmpty
(
args
))
{
if
(
1
==
arguments
.
size
())
{
if
(!(
args
[
0
]
instanceof
Integer
)
&&
!(
args
[
0
]
instanceof
String
))
{
JSONObject
jsonObject
=
(
JSONObject
)
JSON
.
toJSON
(
args
[
0
]);
record
=
Objects
.
nonNull
(
jsonObject
.
get
(
"keyword"
))
?
String
.
valueOf
(
jsonObject
.
get
(
"keyword"
))
:
String
.
valueOf
(
jsonObject
.
get
(
"search"
));
}
}
else
{
String
[]
parameterNames
=
methodSignature
.
getParameterNames
();
for
(
int
i
=
0
;
i
<
parameterNames
.
length
;
i
++)
{
if
(
Objects
.
equals
(
parameterNames
[
i
],
"keyword"
))
{
record
=
String
.
valueOf
(
args
[
i
]);
}
}
}
behavior
.
setRecord
(
record
);
return
;
}
// 渠道记录
if
(
uri
.
contains
(
"/app/channel/baseInfo"
))
{
JSONObject
jsonObject
=
(
JSONObject
)
JSONObject
.
toJSON
(
ResponseResult
.
getData
());
record
=
Tools
.
concat
(
jsonObject
.
get
(
"platform"
),
jsonObject
.
get
(
"realSource"
),
jsonObject
.
get
(
"source"
));
behavior
.
setRecord
(
record
);
return
;
}
// 事件标题记录
if
(
uri
.
contains
(
"/app/event/detail/baseInfo"
))
{
JSONObject
jsonObject
=
(
JSONObject
)
JSON
.
toJSON
(
ResponseResult
.
getData
());
record
=
String
.
valueOf
(
jsonObject
.
get
(
"title"
));
behavior
.
setRecord
(
record
);
}
}
/**
* 获取接口传参信息
* @param joinPoint
* @return
...
...
src/main/java/com/zhiwei/brandkbs2/config/Constant.java
View file @
6c536246
...
...
@@ -14,6 +14,7 @@ public class Constant {
public
static
final
Long
EIGHT_HOUR
=
8
*
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_MONTH
=
30
*
24
*
60
*
60
*
1000L
;
public
static
final
String
SPEC_MINUTE_PATTERN
=
"yyyy.MM.dd HH:mm"
;
...
...
src/main/java/com/zhiwei/brandkbs2/controller/CommonController.java
View file @
6c536246
...
...
@@ -69,18 +69,25 @@ public class CommonController extends BaseController {
return
ResponseResult
.
success
(
projectService
.
getUserAllProjects
());
}
// @ApiOperation("获取默认
月
间隔时间节点")
// @GetMapping("/time/
month
")
// @ApiOperation("获取默认
天
间隔时间节点")
// @GetMapping("/time/
format/day
")
// @Auth(role = RoleEnum.CUSTOMER)
// public ResponseResult getTimeRange
Month
() {
// return ResponseResult.success(commonService.getTimeRange
Month
());
// public ResponseResult getTimeRange
Day
() {
// return ResponseResult.success(commonService.getTimeRange
Day
());
// }
//
// @ApiOperation("获取默认周间隔时间节点")
// @GetMapping("/time/week")
// @GetMapping("/time/
format/
week")
// @Auth(role = RoleEnum.CUSTOMER)
// public ResponseResult getTimeRangeWeek() {
// return ResponseResult.success(commonService.getTimeRangeWeek());
// return ResponseResult.success(commonService.getTimeRangeFormatWeek());
// }
//
// @ApiOperation("获取默认月间隔时间节点")
// @GetMapping("/time/format/month")
// @Auth(role = RoleEnum.CUSTOMER)
// public ResponseResult getTimeRangeMonth() {
// return ResponseResult.success(commonService.getTimeRangeFormatMonth());
// }
}
src/main/java/com/zhiwei/brandkbs2/controller/InterfaceController.java
View file @
6c536246
...
...
@@ -9,8 +9,10 @@ import com.zhiwei.brandkbs2.pojo.external.BrandkbsYuQingConfig;
import
com.zhiwei.brandkbs2.pojo.vo.CrisisCaseWarnVO
;
import
com.zhiwei.brandkbs2.service.ProjectService
;
import
com.zhiwei.brandkbs2.service.ProjectWarnService
;
import
com.zhiwei.brandkbs2.util.TextUtil
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
...
...
@@ -33,6 +35,9 @@ public class InterfaceController {
@Resource
(
name
=
"projectWarnServiceImpl"
)
private
ProjectWarnService
projectWarnService
;
@Autowired
TextUtil
textUtil
;
@ApiOperation
(
"获取项目预警详细信息"
)
@GetMapping
(
"/getProjectWarnCriteria"
)
public
ResponseResult
getProjectWarnCriteria
(
String
projectId
,
String
type
)
{
...
...
@@ -101,4 +106,11 @@ public class InterfaceController {
public
ResponseResult
getHitTagsByLinkedGroupId
(
String
linkedGroupId
)
{
return
projectService
.
getHitTagsByLinkedGroupId
(
linkedGroupId
);
}
@ApiOperation
(
"获取事件详情页面词云(事件中间件项目调用)"
)
@PostMapping
(
"/highWord"
)
public
ResponseResult
getEventDataHighWord
(
@RequestBody
String
texts
){
List
<
String
>
list
=
JSONObject
.
parseObject
(
texts
).
getJSONArray
(
"texts"
).
toJavaList
(
String
.
class
);
return
ResponseResult
.
success
(
textUtil
.
getHighWordsJson
(
list
,
30
));
}
}
src/main/java/com/zhiwei/brandkbs2/controller/admin/ProjectController.java
View file @
6c536246
...
...
@@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONArray;
import
com.alibaba.fastjson.JSONObject
;
import
com.zhiwei.brandkbs2.auth.Auth
;
import
com.zhiwei.brandkbs2.auth.UserThreadLocal
;
import
com.zhiwei.brandkbs2.common.GenericAttribute
;
import
com.zhiwei.brandkbs2.controller.BaseController
;
import
com.zhiwei.brandkbs2.easyexcel.EasyExcelUtil
;
import
com.zhiwei.brandkbs2.easyexcel.dto.UploadKeywordDTO
;
...
...
@@ -14,11 +13,9 @@ import com.zhiwei.brandkbs2.pojo.Behavior;
import
com.zhiwei.brandkbs2.pojo.vo.ProjectVO
;
import
com.zhiwei.brandkbs2.service.BehaviorService
;
import
com.zhiwei.brandkbs2.service.CommonService
;
import
com.zhiwei.brandkbs2.service.EventService
;
import
com.zhiwei.brandkbs2.service.ProjectService
;
import
com.zhiwei.brandkbs2.util.Tools
;
import
com.zhiwei.middleware.auth.util.JwtUtil
;
import
com.zhiwei.middleware.event.core.EventTagClient
;
import
com.zhiwei.middleware.event.pojo.dto.EventTagRelatedDTO
;
import
com.zhiwei.middleware.mark.vo.MarkerTag
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
...
...
@@ -53,9 +50,6 @@ public class ProjectController extends BaseController {
@Autowired
private
RestTemplate
restTemplate
;
@Autowired
private
EventTagClient
eventTagClient
;
@Resource
(
name
=
"projectServiceImpl"
)
private
ProjectService
ProjectService
;
...
...
@@ -65,6 +59,9 @@ public class ProjectController extends BaseController {
@Resource
(
name
=
"commonServiceImpl"
)
private
CommonService
commonService
;
@Resource
(
name
=
"eventServiceImpl"
)
private
EventService
eventService
;
private
static
final
Behavior
.
Operation
OPERATION
=
new
Behavior
.
Operation
(
"项目管理"
,
true
);
@Value
(
"${brandkbs.img.url}"
)
...
...
@@ -216,7 +213,7 @@ public class ProjectController extends BaseController {
@ApiImplicitParam
(
name
=
"yuQingProjectId"
,
value
=
"舆情项目id"
,
required
=
true
,
paramType
=
"query"
,
dataType
=
"string"
)
@GetMapping
(
"/get/eventTags"
)
public
ResponseResult
getEventTagsInfo
(
@RequestParam
(
value
=
"yuQingProjectId"
)
String
yuQingProjectId
){
Object
eventTags
=
event
TagClient
.
getEventTagGroupInfoBrandkbsWithoutEmotion
(
yuQingProjectId
).
getData
();
Object
eventTags
=
event
Service
.
getEventTagGroupInfoBrandkbsWithoutEmotion
(
yuQingProjectId
).
getData
();
return
ResponseResult
.
success
(
eventTags
);
}
...
...
src/main/java/com/zhiwei/brandkbs2/controller/app/AppEventController.java
View file @
6c536246
...
...
@@ -49,9 +49,6 @@ public class AppEventController extends BaseController {
@Value
(
"${ef.checkCaptcha.url}"
)
private
String
efCheckCaptchaUrl
;
@Autowired
private
EventMonitorClient
eventMonitorClient
;
private
final
EventService
eventService
;
public
AppEventController
(
EventService
eventService
)
{
...
...
@@ -186,7 +183,7 @@ public class AppEventController extends BaseController {
@ApiOperation
(
"前台事件库-事件监测-新增事件监测"
)
@PostMapping
(
"/addEventMonitor"
)
public
ResponseResult
addEventMonitor
(
@RequestBody
EventDTO
dto
){
if
(
event
MonitorClient
.
countMonitoringEventsBrandkbs
(
UserThreadLocal
.
getProjectId
()
)
>=
10
){
if
(
event
Service
.
getMonitoringEventsCount
(
)
>=
10
){
return
ResponseResult
.
failure
(
"监测事件数量不得超过10"
);
}
eventService
.
addEventMonitor
(
dto
);
...
...
@@ -241,7 +238,7 @@ public class AppEventController extends BaseController {
public
ResponseResult
eventChannelVoices
(
@RequestParam
(
value
=
"eventId"
)
String
eventId
,
@RequestParam
(
value
=
"type"
,
defaultValue
=
"重要渠道"
)
String
type
,
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
int
page
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"
5
0"
)
int
pageSize
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"
1
0"
)
int
pageSize
,
@RequestParam
(
value
=
"sorter"
,
required
=
false
)
String
sorter
){
return
ResponseResult
.
success
(
eventService
.
eventChannelVoices
(
eventId
,
type
,
page
,
pageSize
,
sorter
));
}
...
...
@@ -256,6 +253,13 @@ public class AppEventController extends BaseController {
return
ResponseResult
.
success
(
eventService
.
eventTopArticlesAnalysis
(
eventId
,
type
,
emotion
,
aggTitle
));
}
@ApiOperation
(
"前台事件库-事件详情-热门渠道发声、上榜热搜、词云"
)
@GetMapping
(
"/detail/additional-info"
)
@Auth
(
role
=
RoleEnum
.
NO_AUTHORISE
)
public
ResponseResult
eventDetailAdditionalInfo
(
@RequestParam
(
value
=
"eventId"
)
String
eventId
){
return
ResponseResult
.
success
(
eventService
.
eventDetailAdditionalInfo
(
eventId
));
}
@ApiOperation
(
"前台事件库-事件详情-持续事件"
)
@GetMapping
(
"/detail/continue-event"
)
public
ResponseResult
continueEvent
(
@RequestParam
(
value
=
"eventId"
)
String
eventId
){
...
...
src/main/java/com/zhiwei/brandkbs2/controller/app/AppSearchController.java
View file @
6c536246
...
...
@@ -4,6 +4,7 @@ package com.zhiwei.brandkbs2.controller.app;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.zhiwei.brandkbs2.auth.Auth
;
import
com.zhiwei.brandkbs2.auth.UserThreadLocal
;
import
com.zhiwei.brandkbs2.config.Constant
;
import
com.zhiwei.brandkbs2.controller.BaseController
;
import
com.zhiwei.brandkbs2.easyexcel.EasyExcelUtil
;
...
...
@@ -71,6 +72,9 @@ public class AppSearchController extends BaseController {
@Resource
(
name
=
"commonServiceImpl"
)
CommonService
commonService
;
@Resource
(
name
=
"projectServiceImpl"
)
ProjectService
projectService
;
@ApiOperation
(
"搜索-查热点"
)
@GetMapping
(
"/hot/list"
)
public
ResponseResult
searchHotList
(
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"10"
)
Integer
limit
,
...
...
@@ -129,6 +133,8 @@ public class AppSearchController extends BaseController {
@ApiOperation
(
"搜索-全网搜"
)
@PostMapping
(
"/searchWhole"
)
public
ResponseResult
searchWholeNetwork
(
@RequestBody
SearchFilterDTO
dto
)
{
// 针对商业数据库做限制
if
(
2
==
projectService
.
getProjectById
(
UserThreadLocal
.
getProjectId
()).
getWholeSearchDataSource
())
{
long
time
=
DateUtils
.
addDays
(
Tools
.
truncDate
(
new
Date
(),
Constant
.
DAY_PATTERN
),
-
89
).
getTime
();
if
(
time
>
dto
.
getStartTime
())
{
// 仅对查商业数据库时限制时间,查舆情库时本质上无时间限制
...
...
@@ -139,16 +145,26 @@ public class AppSearchController extends BaseController {
// 仅对查商业数据库时限制时间,查舆情库时本质上无时间限制
return
ResponseResult
.
failure
(
"时间跨度不能超过30天"
);
}
}
return
ResponseResult
.
success
(
markDataService
.
searchWholeNetwork
(
dto
));
}
@ApiOperation
(
"搜索-全网搜-舆情导出"
)
@PostMapping
(
"/exportSearchWhole"
)
public
ResponseResult
exportSearchWhole
(
@RequestBody
SearchFilterDTO
dto
)
{
// 针对商业数据库做限制
if
(
2
==
projectService
.
getProjectById
(
UserThreadLocal
.
getProjectId
()).
getWholeSearchDataSource
())
{
long
time
=
DateUtils
.
addDays
(
Tools
.
truncDate
(
new
Date
(),
Constant
.
DAY_PATTERN
),
-
89
).
getTime
();
if
(
time
>
dto
.
getStartTime
())
{
// 仅对查商业数据库时限制时间,查舆情库时本质上无时间限制
return
ResponseResult
.
failure
(
"仅能导出近3个月内信息"
);
}
Period
periodDay
=
new
Period
(
dto
.
getStartTime
(),
dto
.
getEndTime
(),
PeriodType
.
days
());
if
(
periodDay
.
getDays
()
>
30
)
{
// 仅对查商业数据库时限制时间,查舆情库时本质上无时间限制
return
ResponseResult
.
failure
(
"时间跨度不能超过30天"
);
}
}
List
<
ExportSearchWholeDTO
>
exportList
=
markDataService
.
exportSearchWhole
(
dto
);
EasyExcelUtil
.
download
(
"全网搜舆情列表数据"
,
"sheet1"
,
ExportSearchWholeDTO
.
class
,
exportList
,
response
);
return
ResponseResult
.
success
();
...
...
@@ -197,6 +213,12 @@ public class AppSearchController extends BaseController {
return
ResponseResult
.
success
(
eventService
.
getLastEventTop
(
null
,
5
));
}
@ApiOperation
(
"搜索-热门事件"
)
@GetMapping
(
"/lastEventTop"
)
public
ResponseResult
getLastEventTopMiddleware
()
{
return
ResponseResult
.
success
(
eventService
.
getLastEventTopMiddleware
(
null
,
5
));
}
@ApiOperation
(
"搜索-前台事件库-搜索条件"
)
@GetMapping
(
"/event/list/criteria"
)
public
ResponseResult
getEventsSearchCriteria
()
{
...
...
src/main/java/com/zhiwei/brandkbs2/dao/EventMiddlewareDao.java
0 → 100644
View file @
6c536246
package
com
.
zhiwei
.
brandkbs2
.
dao
;
import
com.alibaba.fastjson.JSONObject
;
import
com.zhiwei.middleware.event.pojo.PageData
;
import
com.zhiwei.middleware.event.pojo.ReturnData
;
import
com.zhiwei.middleware.event.pojo.dto.BrandkbsEventSearchDTO
;
import
com.zhiwei.middleware.event.pojo.dto.EventBaseInfoDTO
;
import
com.zhiwei.middleware.event.pojo.dto.EventDTO
;
import
com.zhiwei.middleware.event.pojo.dto.EventTagRelatedDTO
;
import
com.zhiwei.middleware.event.pojo.entity.*
;
import
com.zhiwei.middleware.event.pojo.vo.EventListInfoVO
;
import
com.zhiwei.middleware.event.pojo.vo.EventVO
;
import
java.util.List
;
import
java.util.Map
;
/**
* @ClassName: EventMiddlewareDao
* @Description 事件中间件
* @author: cjz
* @date: 2023-02-08 10:45
*/
public
interface
EventMiddlewareDao
{
/**
* 按筛选条件获取事件列表
* @param dto
* @return
*/
PageData
<
EventListInfoVO
>
getEventListBrandkbs
(
BrandkbsEventSearchDTO
dto
);
/**
* 根据id删除事件
* @param eventId
* @return
*/
ReturnData
deleteEvent
(
String
eventId
);
/**
* 获取事件基础信息
* @param eventId
* @return
*/
EventBaseInfoDTO
eventBaseInfo
(
String
eventId
);
/**
* 获取传播趋势
* @param eventId
* @param type
* @return
*/
EventDisseminationTrend
eventDisseminationTrends
(
String
eventId
,
String
type
);
/**
* 持续事件
* @param eventId
* @param submitter
* @param submitterId
* @return
*/
ReturnData
continueEvent
(
String
eventId
,
String
submitter
,
String
submitterId
);
/**
* 获取事件热门文章分析
* @param eventId
* @param type
* @param emotion
* @param aggTitle
* @return
*/
JSONObject
eventTopArticlesAnalysis
(
String
eventId
,
String
type
,
String
emotion
,
String
aggTitle
);
/**
* 获取事件渠道发声
* @param eventId
* @param type
* @param page
* @param pageSize
* @param sorter
* @return
*/
PageData
<
JSONObject
>
eventChannelVoices
(
String
eventId
,
String
type
,
int
page
,
int
pageSize
,
String
sorter
);
/**
* 统计事件数量
* @param eventIds
* @return
*/
Long
countInEventIds
(
List
<
String
>
eventIds
);
/**
* 统计事件数据数量
* @param event
* @return
*/
Long
countEventDataByEventId
(
Event
event
);
/**
* 统计事件数据数量
* @param event
* @return
*/
Long
countEventDataByEventIdAndFid
(
Event
event
,
String
fid
);
/**
* 获取事件列表
* @param eventIds
* @return
*/
List
<
Event
>
findListInEventIds
(
List
<
String
>
eventIds
,
int
page
,
int
pageSize
);
/**
* 获取事件列表
* @param eventIds
* @return
*/
List
<
Event
>
findListInEventIds
(
List
<
String
>
eventIds
);
/**
* 获取参与事件数
*
* @param fid
* @return 参与事件数
*/
List
<
String
>
getEvents
(
String
fid
);
/**
* 获取参与事件数
*
* @param fid
* @return 参与事件数
*/
Map
<
Long
,
List
<
Event
>>
getEventDay
(
String
fid
,
Long
startTime
,
Long
endTime
);
/**
* 获取参与事件数
*
* @param fid
* @return 参与事件数
*/
Map
<
Long
,
List
<
Event
>>
getEventMonth
(
String
fid
,
Long
startTime
,
Long
endTime
);
/**
* 获取参与的反常事件数
*
* @param fid 渠道标识
* @param eventEmotions 事件情感倾向
* @param articleEmotion 文章情感倾向
* @return 参与的反常事件数
*/
Long
getEventCount
(
String
fid
,
List
<
String
>
eventEmotions
,
String
articleEmotion
);
/**
* 根据特征值获取事件数
*
* @param startTime
* @param endTime
* @param emotion
* @param projectId
* @param contendId
* @return
*/
Long
getEventCountByProjectIdAndContendId
(
Long
startTime
,
Long
endTime
,
String
emotion
,
String
projectId
,
String
contendId
);
/**
* 根据特征值获取事件
*
* @param startTime
* @param endTime
* @param emotion
* @param projectId
* @param contendId
* @return
*/
List
<
Event
>
getEventsByProjectIdAndContendId
(
Long
startTime
,
Long
endTime
,
String
emotion
,
String
projectId
,
String
contendId
,
int
limit
);
/**
* 根据特征值获取事件
*
* @param startTime
* @param endTime
* @param emotions
* @param projectId
* @param contendId
* @return
*/
List
<
Event
>
getEventsByProjectIdAndContendId
(
Long
startTime
,
Long
endTime
,
List
<
String
>
emotions
,
String
projectId
,
String
contendId
,
int
limit
);
List
<
Event
>
getEventsByTotalChannelVolumeTop
(
Long
startTime
,
Long
endTime
,
String
emotion
,
String
projectId
,
String
contendId
,
int
limit
);
/**
* 获得最新的事件
*
* @return
*/
List
<
JSONObject
>
getLastEventTop
(
String
keyword
,
int
limit
,
String
brandkbsProjectId
);
/**
* 获取传播量
*
* @param event 事件
* @return 传播量
*/
Long
getEventArticleCount
(
Event
event
);
/**
* 获取渠道参与传播量
*
* @param event 事件
* @return 传播量
*/
Long
getEventArticleWithChannelCount
(
Event
event
,
String
source
,
String
realSource
,
String
platform
);
/**
* 获取事件监测列表
* @param brandkbsBrandId
* @param page
* @param pageSize
* @return
*/
PageData
<
EventVO
>
getEventMonitorBrandkbs
(
String
brandkbsBrandId
,
int
page
,
int
pageSize
);
/**
* 新增事件监测
* @param eventDTO
* @return
*/
ReturnData
addEventMonitor
(
EventDTO
eventDTO
);
/**
* 编辑单个监测事件
* @param eventId
* @param eventDTO
* @param brandkbsInfos
* @return
*/
ReturnData
modifyEventMonitor
(
String
eventId
,
EventDTO
eventDTO
,
List
<
BrandkbsBasicInfo
>
brandkbsInfos
);
/**
* 结束事件监测
* @param eventId
* @param submitter
* @param submitterId
* @return
*/
ReturnData
endEventMonitor
(
String
eventId
,
String
submitter
,
String
submitterId
);
/**
* 统计状态为监测中的事件数量
* @param brandId
* @return
*/
Long
countMonitoringEventsBrandkbs
(
String
brandId
);
/**
* 获取标签组信息
* @param projectId
* @return
*/
ReturnData
getEventTagGroupInfoBrandkbs
(
String
projectId
);
/**
*
* @param yuQingProject
* @param yuQingProjectId
* @param eventTags
* @param brandkbsProject
* @param brandkbsProjectId
* @param brandkbsBrand
* @param brandkbsBrandId
* @param submitter
* @param submitterId
* @return
*/
ReturnData
bindBrandkbs
(
String
yuQingProject
,
String
yuQingProjectId
,
List
<
EventTagRelatedDTO
>
eventTags
,
String
brandkbsProject
,
String
brandkbsProjectId
,
String
brandkbsBrand
,
String
brandkbsBrandId
,
String
submitter
,
String
submitterId
);
/**
* 获取品见项目标签绑定情况
* @param brandkbsProjectId
* @return
*/
ReturnData
getBrandkbsBindingEventTags
(
String
brandkbsProjectId
);
/**
* 修改品见关联关系,若存在则修改,否则新增
* @param yuQingProject
* @param yuQingProjectId
* @param eventTags
* @param brandkbsProject
* @param brandkbsProjectId
* @param brandkbsBrand
* @param brandkbsBrandId
* @param submitter
* @param submitterId
* @return
*/
ReturnData
modifyBrandkbsEventTags
(
String
yuQingProject
,
String
yuQingProjectId
,
List
<
EventTagRelatedDTO
>
eventTags
,
String
brandkbsProject
,
String
brandkbsProjectId
,
String
brandkbsBrand
,
String
brandkbsBrandId
,
String
submitter
,
String
submitterId
);
/**
* 获取标签组信息
* @param projectId
* @return
*/
ReturnData
getEventTagGroupInfoBrandkbsWithoutEmotion
(
String
projectId
);
/**
* 事件详情页面高频渠道发声、词云、上榜热搜
* @param eventId 事件id
* @return EventDetailAdditionalInfo
*/
EventDetailAdditionalInfo
eventDetailAdditionalInfo
(
String
eventId
);
}
src/main/java/com/zhiwei/brandkbs2/dao/impl/EventMiddlewareDaoImpl.java
0 → 100644
View file @
6c536246
package
com
.
zhiwei
.
brandkbs2
.
dao
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.zhiwei.brandkbs2.dao.EventMiddlewareDao
;
import
com.zhiwei.middleware.event.core.EventClient
;
import
com.zhiwei.middleware.event.core.EventMonitorClient
;
import
com.zhiwei.middleware.event.core.EventTagClient
;
import
com.zhiwei.middleware.event.pojo.PageData
;
import
com.zhiwei.middleware.event.pojo.ReturnData
;
import
com.zhiwei.middleware.event.pojo.dto.BrandkbsEventSearchDTO
;
import
com.zhiwei.middleware.event.pojo.dto.EventBaseInfoDTO
;
import
com.zhiwei.middleware.event.pojo.dto.EventDTO
;
import
com.zhiwei.middleware.event.pojo.dto.EventTagRelatedDTO
;
import
com.zhiwei.middleware.event.pojo.entity.BrandkbsBasicInfo
;
import
com.zhiwei.middleware.event.pojo.entity.Event
;
import
com.zhiwei.middleware.event.pojo.entity.EventDetailAdditionalInfo
;
import
com.zhiwei.middleware.event.pojo.entity.EventDisseminationTrend
;
import
com.zhiwei.middleware.event.pojo.vo.EventListInfoVO
;
import
com.zhiwei.middleware.event.pojo.vo.EventVO
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
import
java.util.Map
;
/**
* @ClassName: EventMiddlewareDaoImpl
* @Description 事件中间件业务实现类
* @author: cjz
* @date: 2023-02-08 10:45
*/
@Component
(
"eventMiddlewareDao"
)
public
class
EventMiddlewareDaoImpl
implements
EventMiddlewareDao
{
@Autowired
private
EventClient
eventClient
;
@Autowired
private
EventTagClient
eventTagClient
;
@Autowired
private
EventMonitorClient
eventMonitorClient
;
@Override
public
PageData
<
EventListInfoVO
>
getEventListBrandkbs
(
BrandkbsEventSearchDTO
dto
)
{
return
eventClient
.
getEventListBrandkbs
(
dto
);
}
@Override
public
ReturnData
deleteEvent
(
String
eventId
)
{
return
eventClient
.
deleteEvent
(
eventId
);
}
@Override
public
EventBaseInfoDTO
eventBaseInfo
(
String
eventId
)
{
return
eventClient
.
eventBaseInfo
(
eventId
);
}
@Override
public
EventDisseminationTrend
eventDisseminationTrends
(
String
eventId
,
String
type
)
{
return
eventClient
.
eventDisseminationTrends
(
eventId
,
type
);
}
@Override
public
ReturnData
continueEvent
(
String
eventId
,
String
submitter
,
String
submitterId
)
{
return
eventClient
.
continueEvent
(
eventId
,
submitter
,
submitterId
);
}
@Override
public
JSONObject
eventTopArticlesAnalysis
(
String
eventId
,
String
type
,
String
emotion
,
String
aggTitle
)
{
return
eventClient
.
eventTopArticlesAnalysis
(
eventId
,
type
,
emotion
,
aggTitle
);
}
@Override
public
PageData
<
JSONObject
>
eventChannelVoices
(
String
eventId
,
String
type
,
int
page
,
int
pageSize
,
String
sorter
)
{
return
eventClient
.
eventChannelVoices
(
eventId
,
type
,
page
,
pageSize
,
sorter
);
}
@Override
public
Long
countInEventIds
(
List
<
String
>
eventIds
)
{
return
eventClient
.
countInEventIds
(
eventIds
);
}
@Override
public
Long
countEventDataByEventId
(
Event
event
)
{
return
eventClient
.
countEventDataByEventId
(
event
);
}
@Override
public
Long
countEventDataByEventIdAndFid
(
Event
event
,
String
fid
)
{
return
eventClient
.
countEventDataByEventIdAndFid
(
event
,
fid
);
}
@Override
public
List
<
Event
>
findListInEventIds
(
List
<
String
>
eventIds
,
int
page
,
int
pageSize
)
{
return
eventClient
.
findListInEventIds
(
eventIds
,
page
,
pageSize
);
}
@Override
public
List
<
Event
>
findListInEventIds
(
List
<
String
>
eventIds
)
{
return
eventClient
.
findListInEventIds
(
eventIds
);
}
@Override
public
List
<
String
>
getEvents
(
String
fid
)
{
return
eventClient
.
getEvents
(
fid
);
}
@Override
public
Map
<
Long
,
List
<
Event
>>
getEventDay
(
String
fid
,
Long
startTime
,
Long
endTime
)
{
return
eventClient
.
getEventDay
(
fid
,
startTime
,
endTime
);
}
@Override
public
Map
<
Long
,
List
<
Event
>>
getEventMonth
(
String
fid
,
Long
startTime
,
Long
endTime
)
{
return
eventClient
.
getEventMonth
(
fid
,
startTime
,
endTime
);
}
@Override
public
Long
getEventCount
(
String
fid
,
List
<
String
>
eventEmotions
,
String
articleEmotion
)
{
return
eventClient
.
getEventCount
(
fid
,
eventEmotions
,
articleEmotion
);
}
@Override
public
Long
getEventCountByProjectIdAndContendId
(
Long
startTime
,
Long
endTime
,
String
emotion
,
String
projectId
,
String
contendId
)
{
return
eventClient
.
getEventCountByProjectIdAndContendId
(
startTime
,
endTime
,
emotion
,
projectId
,
contendId
);
}
@Override
public
List
<
Event
>
getEventsByProjectIdAndContendId
(
Long
startTime
,
Long
endTime
,
String
emotion
,
String
projectId
,
String
contendId
,
int
limit
)
{
return
eventClient
.
getEventsByProjectIdAndContendId
(
startTime
,
endTime
,
emotion
,
projectId
,
contendId
,
limit
);
}
@Override
public
List
<
Event
>
getEventsByProjectIdAndContendId
(
Long
startTime
,
Long
endTime
,
List
<
String
>
emotions
,
String
projectId
,
String
contendId
,
int
limit
)
{
return
eventClient
.
getEventsByProjectIdAndContendId
(
startTime
,
endTime
,
emotions
,
projectId
,
contendId
,
limit
);
}
@Override
public
List
<
Event
>
getEventsByTotalChannelVolumeTop
(
Long
startTime
,
Long
endTime
,
String
emotion
,
String
projectId
,
String
contendId
,
int
limit
)
{
return
eventClient
.
getEventsByTotalChannelVolumeTop
(
startTime
,
endTime
,
emotion
,
projectId
,
contendId
,
limit
);
}
@Override
public
List
<
JSONObject
>
getLastEventTop
(
String
keyword
,
int
limit
,
String
brandkbsProjectId
)
{
return
eventClient
.
getLastEventTop
(
keyword
,
limit
,
brandkbsProjectId
);
}
@Override
public
Long
getEventArticleCount
(
Event
event
)
{
return
eventClient
.
getEventArticleCount
(
event
);
}
@Override
public
Long
getEventArticleWithChannelCount
(
Event
event
,
String
source
,
String
realSource
,
String
platform
)
{
return
eventClient
.
getEventArticleWithChannelCount
(
event
,
source
,
realSource
,
platform
);
}
@Override
public
PageData
<
EventVO
>
getEventMonitorBrandkbs
(
String
brandkbsBrandId
,
int
page
,
int
pageSize
)
{
return
eventMonitorClient
.
getEventMonitorBrandkbs
(
brandkbsBrandId
,
page
,
pageSize
);
}
@Override
public
ReturnData
addEventMonitor
(
EventDTO
eventDTO
)
{
return
eventMonitorClient
.
addEventMonitor
(
eventDTO
);
}
@Override
public
ReturnData
modifyEventMonitor
(
String
eventId
,
EventDTO
eventDTO
,
List
<
BrandkbsBasicInfo
>
brandkbsInfos
)
{
return
eventMonitorClient
.
modifyEventMonitor
(
eventId
,
eventDTO
,
brandkbsInfos
);
}
@Override
public
ReturnData
endEventMonitor
(
String
eventId
,
String
submitter
,
String
submitterId
)
{
return
eventMonitorClient
.
endEventMonitor
(
eventId
,
submitter
,
submitterId
);
}
@Override
public
Long
countMonitoringEventsBrandkbs
(
String
brandId
)
{
return
eventMonitorClient
.
countMonitoringEventsBrandkbs
(
brandId
);
}
@Override
public
ReturnData
getEventTagGroupInfoBrandkbs
(
String
projectId
)
{
return
eventTagClient
.
getEventTagGroupInfoBrandkbs
(
projectId
);
}
@Override
public
ReturnData
bindBrandkbs
(
String
yuQingProject
,
String
yuQingProjectId
,
List
<
EventTagRelatedDTO
>
eventTags
,
String
brandkbsProject
,
String
brandkbsProjectId
,
String
brandkbsBrand
,
String
brandkbsBrandId
,
String
submitter
,
String
submitterId
)
{
return
eventTagClient
.
bindBrandkbs
(
yuQingProject
,
yuQingProjectId
,
eventTags
,
brandkbsProject
,
brandkbsProjectId
,
brandkbsBrand
,
brandkbsBrandId
,
submitter
,
submitterId
);
}
@Override
public
ReturnData
getBrandkbsBindingEventTags
(
String
brandkbsProjectId
)
{
return
eventTagClient
.
getBrandkbsBindingEventTags
(
brandkbsProjectId
);
}
@Override
public
ReturnData
modifyBrandkbsEventTags
(
String
yuQingProject
,
String
yuQingProjectId
,
List
<
EventTagRelatedDTO
>
eventTags
,
String
brandkbsProject
,
String
brandkbsProjectId
,
String
brandkbsBrand
,
String
brandkbsBrandId
,
String
submitter
,
String
submitterId
)
{
return
eventTagClient
.
modifyBrandkbsEventTags
(
yuQingProject
,
yuQingProjectId
,
eventTags
,
brandkbsProject
,
brandkbsProjectId
,
brandkbsBrand
,
brandkbsBrandId
,
submitter
,
submitterId
);
}
@Override
public
ReturnData
getEventTagGroupInfoBrandkbsWithoutEmotion
(
String
projectId
)
{
return
eventTagClient
.
getEventTagGroupInfoBrandkbsWithoutEmotion
(
projectId
);
}
@Override
public
EventDetailAdditionalInfo
eventDetailAdditionalInfo
(
String
eventId
)
{
return
eventClient
.
eventDetailAdditionalInfo
(
eventId
);
}
}
src/main/java/com/zhiwei/brandkbs2/model/ResponseResult.java
View file @
6c536246
...
...
@@ -85,11 +85,13 @@ public class ResponseResult {
/**
* 操作失败带返回数据
*
* @param
data 返回数据
* @param
message 失败信息
* @return 操作失败带返回数据
*/
public
static
ResponseResult
failure
(
Object
data
)
{
return
new
ResponseResult
(
CommonCodeEnum
.
FAIL
,
data
);
public
static
ResponseResult
failure
(
String
message
)
{
ResponseResult
responseResult
=
new
ResponseResult
(
CommonCodeEnum
.
FAIL
,
null
);
responseResult
.
setMessage
(
message
);
return
responseResult
;
}
/**
...
...
src/main/java/com/zhiwei/brandkbs2/pojo/Behavior.java
View file @
6c536246
...
...
@@ -74,6 +74,11 @@ public class Behavior extends AbstractBaseMongo {
*/
private
String
severAddress
;
/**
* 需要的记录
*/
private
String
record
;
@Getter
public
static
class
Operation
{
...
...
src/main/java/com/zhiwei/brandkbs2/pojo/Report.java
View file @
6c536246
...
...
@@ -93,7 +93,7 @@ public class Report extends AbstractBaseMongo {
case
MONTH:
report
.
setTitle
(
project
.
getBrandName
()
+
Constant
.
DAY_FORMAT
.
format
(
now
)
+
reportSettings
.
getType
());
now
=
Tools
.
truncDate
(
new
Date
(),
Constant
.
DAY_PATTERN
);
report
.
setStartTime
(
DateUtils
.
addMonths
(
now
,
1
).
getTime
());
report
.
setStartTime
(
DateUtils
.
addMonths
(
now
,
-
1
).
getTime
());
report
.
setEndTime
(
now
.
getTime
());
break
;
case
CUSTOM:
...
...
src/main/java/com/zhiwei/brandkbs2/pojo/dto/ExportSearchWholeDTO.java
View file @
6c536246
...
...
@@ -5,6 +5,7 @@ import com.alibaba.excel.annotation.write.style.ColumnWidth;
import
com.alibaba.fastjson.JSONObject
;
import
lombok.Data
;
import
lombok.ToString
;
import
org.apache.commons.lang3.StringUtils
;
import
java.util.Date
;
...
...
@@ -43,9 +44,10 @@ public class ExportSearchWholeDTO {
dto
.
setTime
(
new
Date
((
Long
)
jsonObject
.
get
(
"time"
)));
dto
.
setPlatform
(
jsonObject
.
getString
(
"platform"
));
dto
.
setChannel
(
jsonObject
.
getString
(
"channel"
));
dto
.
setTitle
(
jsonObject
.
getString
(
"title"
));
dto
.
setContent
(
jsonObject
.
getString
(
"content"
));
dto
.
setUrl
(
jsonObject
.
getString
(
"url"
));
// 截取为excel单元格允许的最大长度
dto
.
setTitle
(
StringUtils
.
substring
(
jsonObject
.
getString
(
"title"
),
0
,
32767
));
dto
.
setContent
(
StringUtils
.
substring
(
jsonObject
.
getString
(
"content"
),
0
,
32767
));
dto
.
setUrl
(
StringUtils
.
substring
(
jsonObject
.
getString
(
"url"
),
0
,
32767
));
return
dto
;
}
}
src/main/java/com/zhiwei/brandkbs2/pojo/external/BrandkbsHotEventWarn.java
View file @
6c536246
...
...
@@ -4,6 +4,7 @@ import com.zhiwei.middleware.event.pojo.entity.Event;
import
com.zhiwei.middleware.event.pojo.entity.EventTagBasicInfo
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
org.apache.commons.collections4.CollectionUtils
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -74,8 +75,11 @@ public class BrandkbsHotEventWarn {
hotEvent
.
setInfluence
(
event
.
getInfluence
());
// List<String> tagList = event.getEventTag().entrySet().stream().filter(entry -> !"情感倾向".equals(entry.getKey()))
// .map(entry -> String.valueOf(entry.getValue())).collect(Collectors.toList());
List
<
String
>
tagList
=
event
.
getEventTags
().
stream
().
filter
(
eventTagBasicInfo
->
!
"情感倾向"
.
equals
(
eventTagBasicInfo
.
getGroupName
()))
List
<
String
>
tagList
=
null
;
if
(
CollectionUtils
.
isNotEmpty
(
event
.
getEventTags
()))
{
tagList
=
event
.
getEventTags
().
stream
().
filter
(
eventTagBasicInfo
->
!
"情感倾向"
.
equals
(
eventTagBasicInfo
.
getGroupName
()))
.
map
(
EventTagBasicInfo:
:
getName
).
collect
(
Collectors
.
toList
());
}
hotEvent
.
setTagList
(
tagList
);
return
hotEvent
;
}
...
...
src/main/java/com/zhiwei/brandkbs2/pojo/vo/BehaviorVO.java
View file @
6c536246
...
...
@@ -44,6 +44,11 @@ public class BehaviorVO {
*/
private
Integer
roleId
;
/**
* 需要的纪录
*/
private
String
record
;
public
static
BehaviorVO
createFromBehavior
(
Behavior
behavior
,
Integer
roleId
)
{
BehaviorVO
behaviorVO
=
Tools
.
convertMap
(
behavior
,
BehaviorVO
.
class
);
// 补充role
...
...
src/main/java/com/zhiwei/brandkbs2/service/EventService.java
View file @
6c536246
...
...
@@ -14,9 +14,11 @@ import com.zhiwei.brandkbs2.pojo.vo.EventVO;
import
com.zhiwei.brandkbs2.pojo.vo.PageVO
;
import
com.zhiwei.brandkbs2.pojo.vo.YqEventSearchVO
;
import
com.zhiwei.middleware.event.pojo.PageData
;
import
com.zhiwei.middleware.event.pojo.ReturnData
;
import
com.zhiwei.middleware.event.pojo.dto.BrandkbsEventSearchDTO
;
import
com.zhiwei.middleware.event.pojo.dto.EventBaseInfoDTO
;
import
com.zhiwei.middleware.event.pojo.dto.EventDTO
;
import
com.zhiwei.middleware.event.pojo.entity.EventDetailAdditionalInfo
;
import
com.zhiwei.middleware.event.pojo.vo.EventTagBrandkbsVO
;
import
org.apache.commons.lang3.tuple.Pair
;
import
org.springframework.web.multipart.MultipartFile
;
...
...
@@ -290,6 +292,19 @@ public interface EventService {
List
<
JSONObject
>
getLastEventTop
(
String
keyword
,
int
limit
);
/**
* 事件中间件获得最新的事件
*
* @return
*/
List
<
JSONObject
>
getLastEventTopMiddleware
(
String
keyword
,
int
limit
);
/**
* 事件中间件获取标签组信息
* @return
*/
ReturnData
getEventTagGroupInfoBrandkbsWithoutEmotion
(
String
yuqingProjectId
);
/**
* 获取未结束的事件
* @param projectId
* @return
...
...
@@ -396,6 +411,13 @@ public interface EventService {
JSONObject
eventTopArticlesAnalysis
(
String
eventId
,
String
type
,
String
emotion
,
String
aggTitle
);
/**
* 事件详情页面高频渠道发声、词云、上榜热搜
* @param eventId 事件id
* @return EventDetailAdditionalInfo
*/
EventDetailAdditionalInfo
eventDetailAdditionalInfo
(
String
eventId
);
/**
* 持续事件
* @param eventId 事件id
*/
...
...
src/main/java/com/zhiwei/brandkbs2/service/ReportService.java
View file @
6c536246
...
...
@@ -29,7 +29,7 @@ public interface ReportService {
*/
Map
<
String
,
ReportSettingsDTO
>
getReportSettings
();
List
<
Report
>
get
Custom
ReportByStatus
(
String
projectId
,
boolean
status
);
List
<
Report
>
getReportByStatus
(
String
projectId
,
boolean
status
);
/**
* 保存报告配置
...
...
src/main/java/com/zhiwei/brandkbs2/service/TaskService.java
View file @
6c536246
...
...
@@ -24,6 +24,11 @@ public interface TaskService{
void
messageFlowCache
();
/**
* 自定义事件标题聚合分析缓存
*/
void
customEventCache
();
/**
* 生成简报任务并推送
*/
void
generateReportAndSend
();
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/BehaviorServiceImpl.java
View file @
6c536246
...
...
@@ -11,8 +11,6 @@ import com.zhiwei.brandkbs2.pojo.UserRole;
import
com.zhiwei.brandkbs2.pojo.vo.BehaviorVO
;
import
com.zhiwei.brandkbs2.pojo.vo.PageVO
;
import
com.zhiwei.brandkbs2.service.BehaviorService
;
import
com.zhiwei.brandkbs2.util.MongoUtil
;
import
com.zhiwei.brandkbs2.util.Tools
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.logging.log4j.LogManager
;
...
...
@@ -123,6 +121,8 @@ public class BehaviorServiceImpl implements BehaviorService {
Date
end
=
new
Date
(
endTime
);
Query
query
=
new
Query
();
query
.
addCriteria
(
Criteria
.
where
(
"cTime"
).
gte
(
startTime
).
lt
(
endTime
).
and
(
"backstage"
).
is
(
backstage
));
query
.
addCriteria
(
Criteria
.
where
(
"projectId"
).
is
(
UserThreadLocal
.
getProjectId
()));
behaviorDao
.
addSort
(
query
,
"{\"cTime\":\"descend\"}"
);
List
<
Behavior
>
behaviorList
=
behaviorDao
.
findList
(
query
,
behaviorDao
.
generateCollectionNames
(
start
,
end
));
List
<
ExportBehaviorDTO
>
resList
=
new
ArrayList
<>(
behaviorList
.
size
());
behaviorList
.
forEach
(
behavior
->
{
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/ChannelServiceImpl.java
View file @
6c536246
...
...
@@ -32,7 +32,6 @@ import com.zhiwei.brandkbs2.service.ProjectService;
import
com.zhiwei.brandkbs2.util.MongoUtil
;
import
com.zhiwei.brandkbs2.util.RedisUtil
;
import
com.zhiwei.brandkbs2.util.Tools
;
import
com.zhiwei.middleware.event.core.EventClient
;
import
com.zhiwei.middleware.event.pojo.entity.Event
;
import
com.zhiwei.middleware.event.pojo.entity.EventTagBasicInfo
;
import
org.apache.commons.collections4.CollectionUtils
;
...
...
@@ -55,7 +54,6 @@ import org.elasticsearch.search.sort.SortBuilders;
import
org.elasticsearch.search.sort.SortOrder
;
import
org.joda.time.Period
;
import
org.joda.time.PeriodType
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.data.mongodb.core.query.Update
;
...
...
@@ -110,6 +108,9 @@ public class ChannelServiceImpl implements ChannelService {
@Resource
(
name
=
"markDataServiceImpl"
)
MarkDataService
markDataService
;
@Resource
(
name
=
"eventMiddlewareDao"
)
EventMiddlewareDao
eventMiddlewareDao
;
@Resource
(
name
=
"mongoUtil"
)
MongoUtil
mongoUtil
;
...
...
@@ -119,9 +120,6 @@ public class ChannelServiceImpl implements ChannelService {
@Resource
(
name
=
"esSearchExecutor"
)
ThreadPoolTaskExecutor
esSearchExecutor
;
@Autowired
private
EventClient
eventClient
;
@Override
public
PageVO
<
JSONObject
>
findChannelList
(
int
page
,
int
size
,
String
contendId
,
String
emotion
,
String
platform
,
Boolean
show
,
String
keyword
,
String
sorter
)
{
...
...
@@ -236,10 +234,10 @@ public class ChannelServiceImpl implements ChannelService {
@Override
public
PageVO
<
JSONObject
>
findEventList
(
int
page
,
int
size
,
String
channelId
)
{
Channel
channel
=
channelDao
.
findOneById
(
channelId
);
List
<
String
>
eventIds
=
event
Client
.
getEvents
(
channel
.
getChannelIndex
().
getFid
());
long
total
=
event
Client
.
countInEventIds
(
eventIds
);
List
<
String
>
eventIds
=
event
MiddlewareDao
.
getEvents
(
channel
.
getChannelIndex
().
getFid
());
long
total
=
event
MiddlewareDao
.
countInEventIds
(
eventIds
);
// mongoUtil.start(page, size, query);
List
<
com
.
zhiwei
.
middleware
.
event
.
pojo
.
entity
.
Event
>
list
=
event
Client
.
findListInEventIds
(
eventIds
,
page
,
size
);
List
<
com
.
zhiwei
.
middleware
.
event
.
pojo
.
entity
.
Event
>
list
=
event
MiddlewareDao
.
findListInEventIds
(
eventIds
,
page
,
size
);
List
<
JSONObject
>
resList
=
new
ArrayList
<>();
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
resList
=
list
.
stream
().
map
(
event
->
{
...
...
@@ -250,10 +248,10 @@ public class ChannelServiceImpl implements ChannelService {
json
.
put
(
"emotion"
,
event
.
getEmotionEventTag
().
getName
());
// Query query1 = new Query();
// query1.addCriteria(Criteria.where("eventId").is(event.getId()));
json
.
put
(
"total"
,
event
Client
.
countEventDataByEventId
(
event
));
json
.
put
(
"total"
,
event
MiddlewareDao
.
countEventDataByEventId
(
event
));
// query1.addCriteria(channelDao.addChannelIndex(channel.getChannelIndex()));
// query1.addCriteria(Criteria.where("eventBrandkbsChannels.channelFid").is(channel.getChannelIndex().getFid()));
json
.
put
(
"channelTotal"
,
event
Client
.
countEventDataByEventIdAndFid
(
event
,
channel
.
getChannelIndex
().
getFid
()));
json
.
put
(
"channelTotal"
,
event
MiddlewareDao
.
countEventDataByEventIdAndFid
(
event
,
channel
.
getChannelIndex
().
getFid
()));
return
json
;
}).
collect
(
Collectors
.
toList
());
}
...
...
@@ -336,11 +334,11 @@ public class ChannelServiceImpl implements ChannelService {
public
List
<
ExportAdminChannelEventDTO
>
findDownloadChannelEventList
(
String
channelId
)
{
List
<
ExportAdminChannelEventDTO
>
resList
=
new
ArrayList
<>();
Channel
channel
=
channelDao
.
findOneById
(
channelId
);
List
<
String
>
eventIds
=
event
Client
.
getEvents
(
channel
.
getChannelIndex
().
getFid
());
List
<
String
>
eventIds
=
event
MiddlewareDao
.
getEvents
(
channel
.
getChannelIndex
().
getFid
());
if
(
CollectionUtils
.
isEmpty
(
eventIds
))
{
return
resList
;
}
List
<
com
.
zhiwei
.
middleware
.
event
.
pojo
.
entity
.
Event
>
events
=
event
Client
.
findListInEventIds
(
eventIds
);
List
<
com
.
zhiwei
.
middleware
.
event
.
pojo
.
entity
.
Event
>
events
=
event
MiddlewareDao
.
findListInEventIds
(
eventIds
);
return
events
.
stream
().
map
(
event
->
{
ExportAdminChannelEventDTO
dto
=
Tools
.
convertMap
(
event
,
ExportAdminChannelEventDTO
.
class
);
dto
.
setTitle
(
event
.
getName
());
...
...
@@ -351,9 +349,9 @@ public class ChannelServiceImpl implements ChannelService {
dto
.
setFirstRealSource
(
firstData
.
getRealSource
());
dto
.
setFirstSource
(
firstData
.
getSource
());
}
dto
.
setEventArticleCount
(
event
Client
.
getEventArticleCount
(
event
));
dto
.
setEventArticleCount
(
event
MiddlewareDao
.
getEventArticleCount
(
event
));
ChannelIndex
channelIndex
=
Tools
.
convertMap
(
channel
,
ChannelIndex
.
class
);
dto
.
setChannelArticleCount
(
event
Client
.
getEventArticleWithChannelCount
(
event
,
channelIndex
.
getSource
(),
channelIndex
.
getRealSource
(),
channelIndex
.
getPlatform
()));
dto
.
setChannelArticleCount
(
event
MiddlewareDao
.
getEventArticleWithChannelCount
(
event
,
channelIndex
.
getSource
(),
channelIndex
.
getRealSource
(),
channelIndex
.
getPlatform
()));
dto
.
setEventType
(
null
);
for
(
EventTagBasicInfo
eventTag
:
event
.
getEventTags
())
{
if
(
eventTag
.
getGroupName
().
equals
(
EventTagEnum
.
EVENT_TYPE
.
getName
())){
...
...
@@ -594,6 +592,7 @@ public class ChannelServiceImpl implements ChannelService {
jsonObject
.
put
(
"id"
,
channel
.
getId
());
jsonObject
.
put
(
"avatarUrl"
,
channel
.
getAvatarUrl
());
jsonObject
.
put
(
"platform"
,
channel
.
getPlatform
());
jsonObject
.
put
(
"realSource"
,
channel
.
getRealSource
());
jsonObject
.
put
(
"source"
,
channel
.
getSource
());
jsonObject
.
put
(
"emotion"
,
ChannelEmotion
.
getNameFromState
(
channel
.
getEmotion
()));
jsonObject
.
put
(
"emotionIndex"
,
BigDecimal
.
valueOf
(
channel
.
getEmotionIndex
()).
setScale
(
2
,
RoundingMode
.
UP
));
...
...
@@ -820,7 +819,7 @@ public class ChannelServiceImpl implements ChannelService {
List
<
JSONObject
>
dayList
=
new
ArrayList
<>();
Channel
channel
=
channelDao
.
findOneById
(
channelId
);
Map
<
Long
,
List
<
com
.
zhiwei
.
middleware
.
event
.
pojo
.
entity
.
Event
>>
eventDay
=
event
Client
.
getEventDay
(
new
ChannelIndex
(
channel
,
contendId
).
getFid
(),
startTime
,
endTime
);
event
MiddlewareDao
.
getEventDay
(
new
ChannelIndex
(
channel
,
contendId
).
getFid
(),
startTime
,
endTime
);
eventDay
=
Tools
.
sortTimeKeyMap
(
eventDay
,
true
);
eventDay
.
forEach
((
time
,
list
)
->
dayList
.
add
(
getDayResultWithEvent
(
list
,
page
,
pageSize
,
time
)));
res
.
put
(
"list"
,
dayList
);
...
...
@@ -833,7 +832,7 @@ public class ChannelServiceImpl implements ChannelService {
List
<
ExportAppChannelEventDTO
>
res
=
new
ArrayList
<>();
Channel
channel
=
channelDao
.
findOneById
(
channelId
);
Map
<
Long
,
List
<
com
.
zhiwei
.
middleware
.
event
.
pojo
.
entity
.
Event
>>
eventDay
=
event
Client
.
getEventDay
(
new
ChannelIndex
(
channel
,
contendId
).
getFid
(),
startTime
,
endTime
);
event
MiddlewareDao
.
getEventDay
(
new
ChannelIndex
(
channel
,
contendId
).
getFid
(),
startTime
,
endTime
);
Tools
.
sortTimeKeyMap
(
eventDay
,
true
).
values
().
forEach
(
events
->
{
events
.
forEach
(
event
->
{
res
.
add
(
ExportAppChannelEventDTO
.
createFromEvent
(
event
));
...
...
@@ -863,10 +862,10 @@ public class ChannelServiceImpl implements ChannelService {
// 是否友好渠道
boolean
isPositive
=
false
;
boolean
isNegative
=
false
;
long
specNegativeCount
=
event
Client
.
getEventCount
(
new
ChannelIndex
(
channel
).
getFid
(),
long
specNegativeCount
=
event
MiddlewareDao
.
getEventCount
(
new
ChannelIndex
(
channel
).
getFid
(),
Arrays
.
asList
(
EmotionEnum
.
POSITIVE
.
getName
(),
EmotionEnum
.
NEUTRAL
.
getName
()),
EmotionEnum
.
NEGATIVE
.
getName
());
long
specPositiveCount
=
event
Client
.
getEventCount
(
new
ChannelIndex
(
channel
).
getFid
(),
long
specPositiveCount
=
event
MiddlewareDao
.
getEventCount
(
new
ChannelIndex
(
channel
).
getFid
(),
Collections
.
singletonList
(
EmotionEnum
.
NEGATIVE
.
getName
()),
EmotionEnum
.
POSITIVE
.
getName
());
// 特殊情况:若皆有发布过反常稿件
if
(
specNegativeCount
>
0
&&
specPositiveCount
>
0
)
{
...
...
@@ -1128,7 +1127,7 @@ public class ChannelServiceImpl implements ChannelService {
}
channel
.
setEmotionIndex
(
index
);
channel
.
setEmotion
(
emotion
);
channel
.
setEventCount
(
event
Client
.
getEvents
(
new
ChannelIndex
(
channel
).
getFid
()).
size
());
channel
.
setEventCount
(
event
MiddlewareDao
.
getEvents
(
new
ChannelIndex
(
channel
).
getFid
()).
size
());
}
/**
...
...
@@ -1152,7 +1151,7 @@ public class ChannelServiceImpl implements ChannelService {
// 正面-负面得分
double
negativeScore
=
this
.
getNegativeScore
(
value
);
// 正面事件
value
=
event
Client
.
getEventCount
(
new
ChannelIndex
(
channel
).
getFid
(),
value
=
event
MiddlewareDao
.
getEventCount
(
new
ChannelIndex
(
channel
).
getFid
(),
Collections
.
singletonList
(
EmotionEnum
.
POSITIVE
.
getName
()),
null
);
// 正面事件得分
double
positiveEventScore
=
this
.
getPositiveEventScore
(
value
);
...
...
@@ -1329,7 +1328,7 @@ public class ChannelServiceImpl implements ChannelService {
// 负面稿件数得分
double
negativeArticlesScore
=
this
.
getNegativeArticlesScore
(
value
);
// 参与负面事件
value
=
event
Client
.
getEventCount
(
channel
.
getFid
(),
Collections
.
singletonList
(
EmotionEnum
.
NEGATIVE
.
getName
()),
null
);
value
=
event
MiddlewareDao
.
getEventCount
(
channel
.
getFid
(),
Collections
.
singletonList
(
EmotionEnum
.
NEGATIVE
.
getName
()),
null
);
// 参与负面事件得分
double
negativeEventScore
=
this
.
getNegativeEventScore
(
value
);
// 特殊稿件
...
...
@@ -1450,7 +1449,7 @@ public class ChannelServiceImpl implements ChannelService {
}
private
double
inEventCountMonthAverage
(
Channel
channel
,
String
eventEmotion
)
{
long
eventCount
=
event
Client
.
getEventCount
(
new
ChannelIndex
(
channel
).
getFid
(),
Collections
.
singletonList
(
eventEmotion
),
null
);
long
eventCount
=
event
MiddlewareDao
.
getEventCount
(
new
ChannelIndex
(
channel
).
getFid
(),
Collections
.
singletonList
(
eventEmotion
),
null
);
Period
periodDays
=
new
Period
(
channel
.
getCTime
(),
System
.
currentTimeMillis
(),
PeriodType
.
months
());
return
(
double
)
eventCount
/
periodDays
.
getMonths
();
}
...
...
@@ -1512,9 +1511,9 @@ public class ChannelServiceImpl implements ChannelService {
JSONObject
res
=
new
JSONObject
();
Map
<
Long
,
List
<
com
.
zhiwei
.
middleware
.
event
.
pojo
.
entity
.
Event
>>
eventCount
;
if
(
endTime
-
startTime
>
Constant
.
ONE_MONTH
)
{
eventCount
=
event
Client
.
getEventMonth
(
new
ChannelIndex
(
channel
,
contendId
).
getFid
(),
startTime
,
endTime
);
eventCount
=
event
MiddlewareDao
.
getEventMonth
(
new
ChannelIndex
(
channel
,
contendId
).
getFid
(),
startTime
,
endTime
);
}
else
{
eventCount
=
event
Client
.
getEventDay
(
new
ChannelIndex
(
channel
,
contendId
).
getFid
(),
startTime
,
endTime
);
eventCount
=
event
MiddlewareDao
.
getEventDay
(
new
ChannelIndex
(
channel
,
contendId
).
getFid
(),
startTime
,
endTime
);
}
// 事件部分
long
positiveEventCount
=
0
;
...
...
@@ -1552,9 +1551,9 @@ public class ChannelServiceImpl implements ChannelService {
private
List
<
JSONObject
>
spreadingTendEvent
(
Long
startTime
,
Long
endTime
,
Channel
channel
,
String
contendId
,
String
timePattern
)
{
Map
<
Long
,
List
<
Event
>>
eventCount
=
completeTimes
(
startTime
,
endTime
,
timePattern
);
if
(
Constant
.
MONTH_PATTERN
.
equals
(
timePattern
))
{
eventCount
.
putAll
(
event
Client
.
getEventMonth
(
new
ChannelIndex
(
channel
,
contendId
).
getFid
(),
startTime
,
endTime
));
eventCount
.
putAll
(
event
MiddlewareDao
.
getEventMonth
(
new
ChannelIndex
(
channel
,
contendId
).
getFid
(),
startTime
,
endTime
));
}
else
{
eventCount
.
putAll
(
event
Client
.
getEventDay
(
new
ChannelIndex
(
channel
,
contendId
).
getFid
(),
startTime
,
endTime
));
eventCount
.
putAll
(
event
MiddlewareDao
.
getEventDay
(
new
ChannelIndex
(
channel
,
contendId
).
getFid
(),
startTime
,
endTime
));
}
return
eventCount
.
entrySet
().
stream
().
sorted
(
Comparator
.
comparingLong
(
Map
.
Entry
::
getKey
)).
map
(
e
->
{
JSONObject
spreadJson
=
new
JSONObject
();
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/CommonServiceImpl.java
View file @
6c536246
...
...
@@ -113,7 +113,7 @@ public class CommonServiceImpl implements CommonService {
@Override
public
Long
[]
getTimeRangeMonth
()
{
long
endTime
=
DateUtils
.
addDays
(
Tools
.
truncDate
(
new
Date
(),
Constant
.
DAY_PATTERN
),
1
).
getTime
();
long
endTime
=
Tools
.
truncDate
(
new
Date
(),
Constant
.
DAY_PATTERN
).
getTime
();
long
startTime
=
DateUtils
.
addMonths
(
new
Date
(
endTime
),
-
1
).
getTime
();
return
new
Long
[]{
startTime
,
endTime
};
}
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/EventServiceImpl.java
View file @
6c536246
...
...
@@ -7,10 +7,7 @@ import com.zhiwei.brandkbs2.auth.UserThreadLocal;
import
com.zhiwei.brandkbs2.common.GenericAttribute
;
import
com.zhiwei.brandkbs2.common.RedisKeyPrefix
;
import
com.zhiwei.brandkbs2.config.Constant
;
import
com.zhiwei.brandkbs2.dao.EventDao
;
import
com.zhiwei.brandkbs2.dao.EventDataDao
;
import
com.zhiwei.brandkbs2.dao.EventDisseminationTrendDao
;
import
com.zhiwei.brandkbs2.dao.EventTopArticlesAnalysisDao
;
import
com.zhiwei.brandkbs2.dao.*
;
import
com.zhiwei.brandkbs2.easyexcel.EasyExcelUtil
;
import
com.zhiwei.brandkbs2.easyexcel.config.ReadExcelDTO
;
import
com.zhiwei.brandkbs2.easyexcel.dto.ExportEventDTO
;
...
...
@@ -39,14 +36,13 @@ import com.zhiwei.brandkbs2.util.MongoUtil;
import
com.zhiwei.brandkbs2.util.RedisUtil
;
import
com.zhiwei.brandkbs2.util.Tools
;
import
com.zhiwei.middleware.auth.util.JwtUtil
;
import
com.zhiwei.middleware.event.core.EventClient
;
import
com.zhiwei.middleware.event.core.EventMonitorClient
;
import
com.zhiwei.middleware.event.core.EventTagClient
;
import
com.zhiwei.middleware.event.pojo.PageData
;
import
com.zhiwei.middleware.event.pojo.ReturnData
;
import
com.zhiwei.middleware.event.pojo.dto.BrandkbsEventSearchDTO
;
import
com.zhiwei.middleware.event.pojo.dto.EventBaseInfoDTO
;
import
com.zhiwei.middleware.event.pojo.dto.EventDTO
;
import
com.zhiwei.middleware.event.pojo.entity.BrandkbsBasicInfo
;
import
com.zhiwei.middleware.event.pojo.entity.EventDetailAdditionalInfo
;
import
com.zhiwei.middleware.event.pojo.vo.EventTagBrandkbsVO
;
import
lombok.Data
;
import
org.apache.commons.collections4.CollectionUtils
;
...
...
@@ -101,6 +97,9 @@ public class EventServiceImpl implements EventService {
@Resource
(
name
=
"eventDao"
)
private
EventDao
eventDao
;
@Resource
(
name
=
"eventMiddlewareDao"
)
private
EventMiddlewareDao
eventMiddlewareDao
;
@Resource
(
name
=
"eventDataDao"
)
private
EventDataDao
eventDataDao
;
...
...
@@ -131,15 +130,6 @@ public class EventServiceImpl implements EventService {
@Autowired
private
StringRedisTemplate
stringRedisTemplate
;
@Autowired
private
EventMonitorClient
eventMonitorClient
;
@Autowired
private
EventClient
eventClient
;
@Autowired
private
EventTagClient
eventTagClient
;
@Resource
private
RedisUtil
redisUtil
;
...
...
@@ -711,6 +701,17 @@ public class EventServiceImpl implements EventService {
}
@Override
public
List
<
JSONObject
>
getLastEventTopMiddleware
(
String
keyword
,
int
limit
)
{
return
eventMiddlewareDao
.
getLastEventTop
(
keyword
,
limit
,
UserThreadLocal
.
getProjectId
());
}
@Override
public
ReturnData
getEventTagGroupInfoBrandkbsWithoutEmotion
(
String
yuqingProjectId
)
{
return
eventMiddlewareDao
.
getEventTagGroupInfoBrandkbsWithoutEmotion
(
yuqingProjectId
);
}
@Override
public
List
<
Event
>
findNotEndEventByProjectId
(
String
projectId
)
{
Query
query
=
Query
.
query
(
Criteria
.
where
(
"projectId"
).
is
(
projectId
).
and
(
"endStatus"
).
is
(
false
));
return
eventDao
.
findList
(
query
);
...
...
@@ -751,7 +752,7 @@ public class EventServiceImpl implements EventService {
result
.
put
(
"brands"
,
projectService
.
getBrands
(
projectId
,
true
));
// 事件调性
AbstractProject
abstractProject
=
projectService
.
getProjectByContendId
(
UserThreadLocal
.
getProjectId
(),
brandId
);
List
<
EventTagBrandkbsVO
>
eventTags
=
(
List
<
EventTagBrandkbsVO
>)
event
TagClient
.
getEventTagGroupInfoBrandkbs
(
abstractProject
.
getBrandLinkedGroupId
()).
getData
();
List
<
EventTagBrandkbsVO
>
eventTags
=
(
List
<
EventTagBrandkbsVO
>)
event
MiddlewareDao
.
getEventTagGroupInfoBrandkbs
(
abstractProject
.
getBrandLinkedGroupId
()).
getData
();
List
<
EventTagBrandkbsVO
>
emotion
=
eventTags
.
stream
().
filter
(
eventTag
->
EventTagEnum
.
EVENT_ATTRIBUTE
.
getName
().
equals
(
eventTag
.
getGroupName
())).
collect
(
Collectors
.
toList
());
result
.
put
(
"emotions"
,
emotion
);
// 时间
...
...
@@ -763,21 +764,22 @@ public class EventServiceImpl implements EventService {
@Override
public
PageData
<
com
.
zhiwei
.
middleware
.
event
.
pojo
.
vo
.
EventListInfoVO
>
getEventListMiddleware
(
BrandkbsEventSearchDTO
dto
)
{
dto
.
setProjectId
(
UserThreadLocal
.
getProjectId
());
if
(
Constant
.
PRIMARY_CONTEND_ID
.
equals
(
dto
.
getBrandId
())){
dto
.
setBrandId
(
UserThreadLocal
.
getProjectId
());
}
return
event
Client
.
getEventListBrandkbs
(
dto
);
return
event
MiddlewareDao
.
getEventListBrandkbs
(
dto
);
}
@Override
public
List
<
EventTagBrandkbsVO
>
getEventTagsCriteria
()
{
Project
project
=
projectService
.
getProjectById
(
UserThreadLocal
.
getProjectId
());
return
(
List
<
EventTagBrandkbsVO
>)
event
TagClient
.
getEventTagGroupInfoBrandkbs
(
project
.
getBrandLinkedGroupId
()).
getData
();
return
(
List
<
EventTagBrandkbsVO
>)
event
MiddlewareDao
.
getEventTagGroupInfoBrandkbs
(
project
.
getBrandLinkedGroupId
()).
getData
();
}
@Override
public
PageData
<
com
.
zhiwei
.
middleware
.
event
.
pojo
.
vo
.
EventVO
>
getEventMonitor
(
int
page
,
int
pageSize
)
{
return
eventM
onitorClient
.
getEventMonitorBrandkbs
(
UserThreadLocal
.
getProjectId
(),
page
,
pageSize
);
return
eventM
iddlewareDao
.
getEventMonitorBrandkbs
(
UserThreadLocal
.
getProjectId
(),
page
,
pageSize
);
}
@Override
...
...
@@ -805,7 +807,7 @@ public class EventServiceImpl implements EventService {
brandkbsBasicInfo
.
setBrandkbsBrandId
(
project
.
getId
());
brandkbsBasicInfos
.
add
(
brandkbsBasicInfo
);
dto
.
setBrandkbsInfos
(
brandkbsBasicInfos
);
eventM
onitorClient
.
addEventMonitor
(
dto
);
eventM
iddlewareDao
.
addEventMonitor
(
dto
);
}
@Override
...
...
@@ -819,7 +821,7 @@ public class EventServiceImpl implements EventService {
dto
.
setProjectId
(
project
.
getBrandLinkedGroupId
());
dto
.
setSubmitter
(
submitter
);
dto
.
setSubmitterId
(
submitterId
);
eventM
onitorClient
.
modifyEventMonitor
(
dto
.
getId
(),
dto
,
null
);
eventM
iddlewareDao
.
modifyEventMonitor
(
dto
.
getId
(),
dto
,
null
);
}
@Override
...
...
@@ -829,37 +831,42 @@ public class EventServiceImpl implements EventService {
String
submitterId
=
JwtUtil
.
unsign
(
request
.
getHeader
(
jwtKey
),
Map
.
class
).
get
(
GenericAttribute
.
USER_ID
).
toString
();
String
submitter
=
userService
.
queryUserInfo
(
submitterId
,
UserThreadLocal
.
getProjectId
()).
getNickname
();
eventM
onitorClient
.
endEventMonitor
(
eventId
,
submitter
,
submitterId
);
eventM
iddlewareDao
.
endEventMonitor
(
eventId
,
submitter
,
submitterId
);
}
@Override
public
void
deleteEventMonitor
(
String
eventId
)
{
event
Client
.
deleteEvent
(
eventId
);
event
MiddlewareDao
.
deleteEvent
(
eventId
);
}
@Override
public
Long
getMonitoringEventsCount
()
{
return
eventM
onitorClient
.
countMonitoringEventsBrandkbs
(
UserThreadLocal
.
getProjectId
());
return
eventM
iddlewareDao
.
countMonitoringEventsBrandkbs
(
UserThreadLocal
.
getProjectId
());
}
@Override
public
EventBaseInfoDTO
eventBaseInfo
(
String
eventId
)
{
return
event
Client
.
eventBaseInfo
(
eventId
);
return
event
MiddlewareDao
.
eventBaseInfo
(
eventId
);
}
@Override
public
com
.
zhiwei
.
middleware
.
event
.
pojo
.
entity
.
EventDisseminationTrend
eventDisseminationTrends
(
String
eventId
,
String
type
)
{
return
event
Client
.
eventDisseminationTrends
(
eventId
,
type
);
return
event
MiddlewareDao
.
eventDisseminationTrends
(
eventId
,
type
);
}
@Override
public
PageData
<
JSONObject
>
eventChannelVoices
(
String
eventId
,
String
type
,
int
page
,
int
pageSize
,
String
sorter
)
{
return
event
Client
.
eventChannelVoices
(
eventId
,
type
,
page
,
pageSize
,
sorter
);
return
event
MiddlewareDao
.
eventChannelVoices
(
eventId
,
type
,
page
,
pageSize
,
sorter
);
}
@Override
public
JSONObject
eventTopArticlesAnalysis
(
String
eventId
,
String
type
,
String
emotion
,
String
aggTitle
)
{
return
eventClient
.
eventTopArticlesAnalysis
(
eventId
,
type
,
emotion
,
aggTitle
);
return
eventMiddlewareDao
.
eventTopArticlesAnalysis
(
eventId
,
type
,
emotion
,
aggTitle
);
}
@Override
public
EventDetailAdditionalInfo
eventDetailAdditionalInfo
(
String
eventId
)
{
return
eventMiddlewareDao
.
eventDetailAdditionalInfo
(
eventId
);
}
@Override
...
...
@@ -869,7 +876,7 @@ public class EventServiceImpl implements EventService {
String
submitterId
=
JwtUtil
.
unsign
(
request
.
getHeader
(
jwtKey
),
Map
.
class
).
get
(
GenericAttribute
.
USER_ID
).
toString
();
String
submitter
=
userService
.
queryUserInfo
(
submitterId
,
UserThreadLocal
.
getProjectId
()).
getNickname
();
event
Client
.
continueEvent
(
eventId
,
submitter
,
submitterId
);
event
MiddlewareDao
.
continueEvent
(
eventId
,
submitter
,
submitterId
);
}
@Data
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/IndexServiceImpl.java
View file @
6c536246
...
...
@@ -7,6 +7,7 @@ import com.zhiwei.brandkbs2.common.GlobalPojo;
import
com.zhiwei.brandkbs2.config.Constant
;
import
com.zhiwei.brandkbs2.dao.EventDao
;
import
com.zhiwei.brandkbs2.dao.EventDataDao
;
import
com.zhiwei.brandkbs2.dao.EventMiddlewareDao
;
import
com.zhiwei.brandkbs2.enmus.EmotionEnum
;
import
com.zhiwei.brandkbs2.exception.ExceptionCast
;
import
com.zhiwei.brandkbs2.listener.ApplicationProjectListener
;
...
...
@@ -60,12 +61,12 @@ public class IndexServiceImpl implements IndexService {
@Resource
private
EventDataDao
eventDataDao
;
@Resource
(
name
=
"eventMiddlewareDao"
)
EventMiddlewareDao
eventMiddlewareDao
;
@Resource
private
RedisUtil
redisUtil
;
@Autowired
private
EventClient
eventClient
;
@Override
public
JSONObject
getYuqingAmount
(
Long
startTime
,
Long
endTime
,
boolean
cache
)
{
if
(
null
==
startTime
||
null
==
endTime
)
{
...
...
@@ -190,9 +191,9 @@ public class IndexServiceImpl implements IndexService {
int
selectMonths
=
new
Period
(
startTime
,
endTime
,
PeriodType
.
months
()).
getMonths
();
selectMonths
=
0
==
selectMonths
?
1
:
selectMonths
;
// 调用事件中间件时,主品牌id使用项目id
long
total
=
event
Client
.
getEventCountByProjectIdAndContendId
(
null
,
null
,
EmotionEnum
.
ALL
.
getName
(),
projectId
,
projectId
);
long
eventTotal
=
event
Client
.
getEventCountByProjectIdAndContendId
(
startTime
,
endTime
,
EmotionEnum
.
ALL
.
getName
(),
projectId
,
projectId
);
long
oldEventTotal
=
event
Client
.
getEventCountByProjectIdAndContendId
(
oldStartTime
,
endTime
,
EmotionEnum
.
ALL
.
getName
(),
projectId
,
projectId
);
long
total
=
event
MiddlewareDao
.
getEventCountByProjectIdAndContendId
(
null
,
null
,
EmotionEnum
.
ALL
.
getName
(),
projectId
,
projectId
);
long
eventTotal
=
event
MiddlewareDao
.
getEventCountByProjectIdAndContendId
(
startTime
,
endTime
,
EmotionEnum
.
ALL
.
getName
(),
projectId
,
projectId
);
long
oldEventTotal
=
event
MiddlewareDao
.
getEventCountByProjectIdAndContendId
(
oldStartTime
,
endTime
,
EmotionEnum
.
ALL
.
getName
(),
projectId
,
projectId
);
jsonObject
.
put
(
"eventTotal"
,
eventTotal
);
jsonObject
.
put
(
"avgEventTotal"
,
total
*
selectMonths
/
(
totalMonths
+
1
));
jsonObject
.
put
(
"compare"
,
oldEventTotal
==
0
?
0
d
:
(
eventTotal
-
oldEventTotal
)
/
(
double
)
oldEventTotal
);
...
...
@@ -424,10 +425,10 @@ public class IndexServiceImpl implements IndexService {
JSONObject
result
=
new
JSONObject
();
contendId
=
Objects
.
equals
(
contendId
,
Constant
.
PRIMARY_CONTEND_ID
)
?
projectId
:
contendId
;
List
<
com
.
zhiwei
.
middleware
.
event
.
pojo
.
entity
.
Event
>
eventList
=
event
Client
.
getEventsByProjectIdAndContendId
(
startTime
,
endTime
,
EmotionEnum
.
ALL
.
getName
(),
projectId
,
contendId
,
1
);
event
MiddlewareDao
.
getEventsByProjectIdAndContendId
(
startTime
,
endTime
,
EmotionEnum
.
ALL
.
getName
(),
projectId
,
contendId
,
1
);
if
(
CollectionUtils
.
isNotEmpty
(
eventList
))
{
com
.
zhiwei
.
middleware
.
event
.
pojo
.
entity
.
Event
event
=
eventList
.
get
(
0
);
long
articleCount
=
event
Client
.
getEventArticleCount
(
event
);
long
articleCount
=
event
MiddlewareDao
.
getEventArticleCount
(
event
);
result
.
put
(
"id"
,
event
.
getId
());
result
.
put
(
"title"
,
event
.
getName
());
result
.
put
(
"influence"
,
event
.
getInfluence
());
...
...
@@ -542,7 +543,7 @@ public class IndexServiceImpl implements IndexService {
result
.
put
(
"time"
,
startTime
);
//统计时间段总事件数
// 调用事件中间件时,主品牌id使用项目id
long
eventCount
=
event
Client
.
getEventCountByProjectIdAndContendId
(
startTime
,
endTime
,
EmotionEnum
.
ALL
.
getName
(),
projectId
,
projectId
);
long
eventCount
=
event
MiddlewareDao
.
getEventCountByProjectIdAndContendId
(
startTime
,
endTime
,
EmotionEnum
.
ALL
.
getName
(),
projectId
,
projectId
);
result
.
put
(
"eventCount"
,
eventCount
);
lineList
.
add
(
result
);
}
...
...
@@ -564,10 +565,10 @@ public class IndexServiceImpl implements IndexService {
Long
endTime
=
map
.
get
(
"endTime"
);
//统计时间段总事件数
// 调用事件中间件时,主品牌id使用项目id
long
totalEventCount
=
event
Client
.
getEventCountByProjectIdAndContendId
(
startTime
,
endTime
,
EmotionEnum
.
ALL
.
getName
(),
projectId
,
projectId
);
long
posEventCount
=
event
Client
.
getEventCountByProjectIdAndContendId
(
startTime
,
endTime
,
EmotionEnum
.
POSITIVE
.
getName
(),
projectId
,
projectId
);
long
neuEventCount
=
event
Client
.
getEventCountByProjectIdAndContendId
(
startTime
,
endTime
,
EmotionEnum
.
NEUTRAL
.
getName
(),
projectId
,
projectId
);
long
negEventCount
=
event
Client
.
getEventCountByProjectIdAndContendId
(
startTime
,
endTime
,
EmotionEnum
.
NEGATIVE
.
getName
(),
projectId
,
projectId
);
long
totalEventCount
=
event
MiddlewareDao
.
getEventCountByProjectIdAndContendId
(
startTime
,
endTime
,
EmotionEnum
.
ALL
.
getName
(),
projectId
,
projectId
);
long
posEventCount
=
event
MiddlewareDao
.
getEventCountByProjectIdAndContendId
(
startTime
,
endTime
,
EmotionEnum
.
POSITIVE
.
getName
(),
projectId
,
projectId
);
long
neuEventCount
=
event
MiddlewareDao
.
getEventCountByProjectIdAndContendId
(
startTime
,
endTime
,
EmotionEnum
.
NEUTRAL
.
getName
(),
projectId
,
projectId
);
long
negEventCount
=
event
MiddlewareDao
.
getEventCountByProjectIdAndContendId
(
startTime
,
endTime
,
EmotionEnum
.
NEGATIVE
.
getName
(),
projectId
,
projectId
);
JSONObject
result
=
new
JSONObject
();
result
.
put
(
"totalCount"
,
totalEventCount
);
result
.
put
(
"posCount"
,
posEventCount
);
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkDataServiceImpl.java
View file @
6c536246
...
...
@@ -131,6 +131,9 @@ public class MarkDataServiceImpl implements MarkDataService {
@Resource
(
name
=
"channelDao"
)
ChannelDao
channelDao
;
@Resource
(
name
=
"userServiceImpl"
)
private
UserService
userService
;
@Resource
(
name
=
"redisUtil"
)
RedisUtil
redisUtil
;
...
...
@@ -1125,19 +1128,18 @@ public class MarkDataServiceImpl implements MarkDataService {
return
JSON
.
parseObject
(
result
);
}
}
List
<
Map
<
String
,
Long
>>
dayList
=
Tools
.
parseToDays
(
startTime
,
endTime
);
List
<
JSONObject
>
resList
=
new
ArrayList
<>(
2
);
JSONObject
result
=
new
JSONObject
();
// 开始时间
result
.
put
(
"startTime"
,
startTime
);
// 结束时间
result
.
put
(
"endTime"
,
endTime
);
List
<
Map
<
String
,
Long
>>
cutList
=
Tools
.
getCutList
(
startTime
,
endTime
).
getRight
();
// 主品牌图谱
JSONObject
primaryLine
=
new
JSONObject
();
primaryLine
.
put
(
"id"
,
Constant
.
PRIMARY_CONTEND_ID
);
primaryLine
.
put
(
"brand"
,
project
.
getBrandName
());
List
<
LineVO
>
primarySpread
=
getArticleSpread
(
projectId
,
project
.
getBrandLinkedGroupId
(),
Constant
.
PRIMARY_CONTEND_ID
,
day
List
);
List
<
LineVO
>
primarySpread
=
getArticleSpread
(
projectId
,
project
.
getBrandLinkedGroupId
(),
Constant
.
PRIMARY_CONTEND_ID
,
cut
List
);
primaryLine
.
put
(
"spread"
,
primarySpread
);
resList
.
add
(
primaryLine
);
result
.
put
(
"days"
,
primarySpread
.
size
());
...
...
@@ -1146,7 +1148,7 @@ public class MarkDataServiceImpl implements MarkDataService {
JSONObject
contendLine
=
new
JSONObject
();
contendLine
.
put
(
"id"
,
contendId
);
contendLine
.
put
(
"brand"
,
brandName
);
List
<
LineVO
>
contendSpread
=
getArticleSpread
(
projectId
,
contendLinkedGroupId
,
contendId
,
day
List
);
List
<
LineVO
>
contendSpread
=
getArticleSpread
(
projectId
,
contendLinkedGroupId
,
contendId
,
cut
List
);
contendLine
.
put
(
"spread"
,
contendSpread
);
resList
.
add
(
contendLine
);
result
.
put
(
"spread"
,
resList
);
...
...
@@ -1161,10 +1163,10 @@ public class MarkDataServiceImpl implements MarkDataService {
result
.
put
(
"priGtAvg"
,
priGreaterThanAvg
);
// 获取主品牌传播峰值时信息
LineVO
primaryMax
=
primarySpread
.
stream
().
max
(
Comparator
.
comparing
(
LineVO:
:
getCount
)).
orElse
(
new
LineVO
());
result
.
put
(
"priMaxTime"
,
sdf
.
format
(
primaryMax
.
getDate
()
));
result
.
put
(
"priMaxTime"
,
primaryMax
.
getDate
(
));
result
.
put
(
"priMaxCount"
,
primaryMax
.
getCount
());
long
priMaxDayStartTime
=
primaryMax
.
getDate
(
);
long
priMaxDayEndTime
=
DateUtils
.
addDays
(
new
Date
(
pri
maryMax
.
getDate
()
),
1
).
getTime
();
long
priMaxDayStartTime
=
Tools
.
truncDate
(
primaryMax
.
getDate
(),
Constant
.
DAY_PATTERN
);
long
priMaxDayEndTime
=
DateUtils
.
addDays
(
new
Date
(
pri
MaxDayStartTime
),
1
).
getTime
();
// 获取时间段某情感数据最多的标题
List
<
Map
.
Entry
<
String
,
Integer
>>
priTopTitle
=
getMarkTopTitle
(
priMaxDayStartTime
,
priMaxDayEndTime
,
EmotionEnum
.
ALL
.
getName
(),
projectId
,
project
.
getBrandLinkedGroupId
(),
Constant
.
PRIMARY_CONTEND_ID
,
1
);
...
...
@@ -1176,7 +1178,8 @@ public class MarkDataServiceImpl implements MarkDataService {
result
.
put
(
"priTopTitleUrl"
,
priFirstArticle
.
getUrl
());
}
// 获取主品牌热门媒体方向
List
<
Map
.
Entry
<
String
,
Integer
>>
priHotTitles
=
getMarkTopTitle
(
priMaxDayStartTime
,
priMaxDayEndTime
,
EmotionEnum
.
ALL
.
getName
(),
projectId
,
project
.
getBrandLinkedGroupId
(),
Constant
.
PRIMARY_CONTEND_ID
,
hotArticleSize
);
List
<
Map
.
Entry
<
String
,
Integer
>>
priHotTitles
=
getMarkTopTitle
(
startTime
,
endTime
,
EmotionEnum
.
ALL
.
getName
(),
projectId
,
project
.
getBrandLinkedGroupId
(),
Constant
.
PRIMARY_CONTEND_ID
,
hotArticleSize
);
if
(
CollectionUtils
.
isNotEmpty
(
priHotTitles
))
{
List
<
JSONObject
>
priHotArticle
=
priHotTitles
.
stream
().
map
(
map
->
{
JSONObject
jsonObject
=
new
JSONObject
();
...
...
@@ -1207,10 +1210,11 @@ public class MarkDataServiceImpl implements MarkDataService {
result
.
put
(
"conGtAvg"
,
conGreaterThanAvg
);
//获取竞品传播峰值信息
LineVO
contendMax
=
contendSpread
.
stream
().
max
(
Comparator
.
comparing
(
LineVO:
:
getCount
)).
orElse
(
new
LineVO
());
result
.
put
(
"conMaxTime"
,
sdf
.
format
(
contendMax
.
getDate
()
));
result
.
put
(
"conMaxTime"
,
contendMax
.
getDate
(
));
result
.
put
(
"conMaxCount"
,
contendMax
.
getCount
());
long
conMaxDayStartTime
=
contendMax
.
getDate
();
long
conMaxDayEndTime
=
DateUtils
.
addDays
(
new
Date
(
contendMax
.
getDate
()),
1
).
getTime
();
long
conMaxDayStartTime
=
Tools
.
truncDate
(
contendMax
.
getDate
(),
Constant
.
DAY_PATTERN
);
long
conMaxDayEndTime
=
DateUtils
.
addDays
(
new
Date
(
conMaxDayStartTime
),
1
).
getTime
();
List
<
Map
.
Entry
<
String
,
Integer
>>
conTopTitle
=
getMarkTopTitle
(
conMaxDayStartTime
,
conMaxDayEndTime
,
EmotionEnum
.
ALL
.
getName
(),
projectId
,
contendLinkedGroupId
,
contendId
,
1
);
if
(
CollectionUtils
.
isNotEmpty
(
conTopTitle
))
{
...
...
@@ -1221,7 +1225,7 @@ public class MarkDataServiceImpl implements MarkDataService {
result
.
put
(
"conTopTitleUrl"
,
conFirstArticle
.
getUrl
());
}
// 获取竞品热门媒体方向
List
<
Map
.
Entry
<
String
,
Integer
>>
conHotTitles
=
getMarkTopTitle
(
conMaxDayStartTime
,
conMaxDayE
ndTime
,
EmotionEnum
.
ALL
.
getName
(),
projectId
,
List
<
Map
.
Entry
<
String
,
Integer
>>
conHotTitles
=
getMarkTopTitle
(
startTime
,
e
ndTime
,
EmotionEnum
.
ALL
.
getName
(),
projectId
,
contendLinkedGroupId
,
contendId
,
hotArticleSize
);
if
(
CollectionUtils
.
isNotEmpty
(
conHotTitles
))
{
List
<
JSONObject
>
conHotArticle
=
conHotTitles
.
stream
().
map
(
map
->
{
...
...
@@ -1336,8 +1340,24 @@ public class MarkDataServiceImpl implements MarkDataService {
@Override
public
List
<
ExportSearchWholeDTO
>
exportSearchWhole
(
SearchFilterDTO
dto
)
{
Integer
exportAmount
=
userService
.
queryUserInfo
(
UserThreadLocal
.
getUserId
(),
UserThreadLocal
.
getProjectId
()).
getExportAmount
();
exportAmount
=
Objects
.
isNull
(
exportAmount
)
?
10000
:
exportAmount
;
JSONArray
jsonArray
=
new
JSONArray
();
dto
.
setPageSize
(
50
);
dto
.
setPage
(
1
);
while
(
true
){
if
(
dto
.
getPage
()
*
dto
.
getPageSize
()
>
exportAmount
){
break
;
}
// 获取当页数据
JSONObject
jsonObject
=
searchWholeNetwork
(
dto
);
JSONArray
jsonArray
=
jsonObject
.
getJSONArray
(
"list"
);
JSONArray
array
=
jsonObject
.
getJSONArray
(
"list"
);
if
(
Objects
.
isNull
(
array
)
||
0
==
array
.
size
()){
break
;
}
jsonArray
.
addAll
(
array
);
dto
.
setPage
(
dto
.
getPage
()
+
1
);
}
return
jsonArray
.
stream
().
map
(
json
->
ExportSearchWholeDTO
.
creatExportSearchWholeDTO
((
JSONObject
)
json
)).
collect
(
Collectors
.
toList
());
}
...
...
@@ -1574,16 +1594,16 @@ public class MarkDataServiceImpl implements MarkDataService {
* @param projectId 项目ID
* @param linkedGroupId 关联组Id
* @param contendId 竞品ID
* @param
dayList 以天为最小单位分割的时间
* @param
cutList 拆分list
* @return
*/
private
List
<
LineVO
>
getArticleSpread
(
String
projectId
,
String
linkedGroupId
,
String
contendId
,
List
<
Map
<
String
,
Long
>>
day
List
)
{
List
<
LineVO
>
lineList
=
new
ArrayList
<>(
day
List
.
size
());
day
List
.
forEach
(
day
->
{
private
List
<
LineVO
>
getArticleSpread
(
String
projectId
,
String
linkedGroupId
,
String
contendId
,
List
<
Map
<
String
,
Long
>>
cut
List
)
{
List
<
LineVO
>
lineList
=
new
ArrayList
<>(
cut
List
.
size
());
cut
List
.
forEach
(
day
->
{
LineVO
lineVO
=
new
LineVO
();
Long
startTime
=
day
.
get
(
"startTime"
);
Long
endTime
=
day
.
get
(
"endTime"
);
Long
articleCount
=
null
;
Long
articleCount
;
try
{
articleCount
=
getMarkArticleCount
(
startTime
,
endTime
,
projectId
,
linkedGroupId
,
contendId
);
}
catch
(
IOException
e
)
{
...
...
@@ -1905,5 +1925,4 @@ public class MarkDataServiceImpl implements MarkDataService {
return
instance
;
}
}
\ No newline at end of file
src/main/java/com/zhiwei/brandkbs2/service/impl/ProjectServiceImpl.java
View file @
6c536246
...
...
@@ -5,6 +5,7 @@ import com.zhiwei.brandkbs2.auth.UserThreadLocal;
import
com.zhiwei.brandkbs2.common.GenericAttribute
;
import
com.zhiwei.brandkbs2.common.GlobalPojo
;
import
com.zhiwei.brandkbs2.config.Constant
;
import
com.zhiwei.brandkbs2.dao.EventMiddlewareDao
;
import
com.zhiwei.brandkbs2.dao.ProjectDao
;
import
com.zhiwei.brandkbs2.dao.QbjcPojoDao
;
import
com.zhiwei.brandkbs2.dao.UserDao
;
...
...
@@ -79,12 +80,12 @@ public class ProjectServiceImpl implements ProjectService {
@Resource
(
name
=
"userServiceImpl"
)
private
UserService
userService
;
@Resource
(
name
=
"eventMiddlewareDao"
)
private
EventMiddlewareDao
eventMiddlewareDao
;
@Value
(
"${jwt.key}"
)
private
String
jwtKey
;
@Autowired
private
EventTagClient
eventTagClient
;
@Value
(
"${brandkbs.file.url}"
)
private
String
brandkbsFileUrl
;
...
...
@@ -116,14 +117,14 @@ public class ProjectServiceImpl implements ProjectService {
// 主品牌绑定事件标签,主品牌品牌id使用项目id
List
<
EventTagRelatedDTO
>
eventTagsList
=
projectVO
.
getEventTagsList
();
event
TagClient
.
bindBrandkbs
(
project
.
getBrandLinkedGroup
(),
project
.
getBrandLinkedGroupId
(),
eventTagsList
,
event
MiddlewareDao
.
bindBrandkbs
(
project
.
getBrandLinkedGroup
(),
project
.
getBrandLinkedGroupId
(),
eventTagsList
,
project
.
getProjectName
(),
project
.
getId
(),
project
.
getBrandName
(),
project
.
getId
(),
submitter
,
submitterId
);
// 竞品绑定事件标签
List
<
Contend
>
contendList
=
project
.
getContendList
();
if
(
CollectionUtils
.
isNotEmpty
(
contendList
))
{
for
(
Contend
contend
:
contendList
)
{
List
<
EventTagRelatedDTO
>
contendEventTagsList
=
contend
.
getEventTagsList
();
event
TagClient
.
bindBrandkbs
(
contend
.
getBrandLinkedGroup
(),
contend
.
getBrandLinkedGroupId
(),
contendEventTagsList
,
project
.
getProjectName
(),
event
MiddlewareDao
.
bindBrandkbs
(
contend
.
getBrandLinkedGroup
(),
contend
.
getBrandLinkedGroupId
(),
contendEventTagsList
,
project
.
getProjectName
(),
project
.
getId
(),
contend
.
getBrandName
(),
contend
.
getId
(),
submitter
,
submitterId
);
}
}
...
...
@@ -165,7 +166,7 @@ public class ProjectServiceImpl implements ProjectService {
@Override
public
ProjectVO
getProjectVOWithEventTagsById
(
String
pid
)
{
ProjectVO
projectVO
=
getProjectVOById
(
pid
);
Map
<
String
,
List
<
EventTagRelatedDTO
>>
eventTagsMap
=
(
Map
<
String
,
List
<
EventTagRelatedDTO
>>)
event
TagClient
.
getBrandkbsBindingEventTags
(
pid
).
getData
();
Map
<
String
,
List
<
EventTagRelatedDTO
>>
eventTagsMap
=
(
Map
<
String
,
List
<
EventTagRelatedDTO
>>)
event
MiddlewareDao
.
getBrandkbsBindingEventTags
(
pid
).
getData
();
List
<
EventTagRelatedDTO
>
eventTagsList
=
new
ArrayList
<>();
if
(!
Tools
.
isEmpty
(
eventTagsMap
))
{
// 获取主品牌标签
...
...
@@ -210,14 +211,14 @@ public class ProjectServiceImpl implements ProjectService {
// 主品牌修改绑定事件标签, 主品牌id使用项目id
List
<
EventTagRelatedDTO
>
eventTagsList
=
projectVO
.
getEventTagsList
();
event
TagClient
.
modifyBrandkbsEventTags
(
project
.
getBrandLinkedGroup
(),
project
.
getBrandLinkedGroupId
(),
eventTagsList
,
event
MiddlewareDao
.
modifyBrandkbsEventTags
(
project
.
getBrandLinkedGroup
(),
project
.
getBrandLinkedGroupId
(),
eventTagsList
,
project
.
getProjectName
(),
project
.
getId
(),
project
.
getBrandName
(),
project
.
getId
(),
submitter
,
submitterId
);
// 竞品修改绑定事件标签
List
<
Contend
>
contendList
=
project
.
getContendList
();
if
(
CollectionUtils
.
isNotEmpty
(
contendList
))
{
for
(
Contend
contend
:
contendList
)
{
List
<
EventTagRelatedDTO
>
contendEventTagsList
=
contend
.
getEventTagsList
();
event
TagClient
.
modifyBrandkbsEventTags
(
contend
.
getBrandLinkedGroup
(),
contend
.
getBrandLinkedGroupId
(),
contendEventTagsList
,
project
.
getProjectName
(),
event
MiddlewareDao
.
modifyBrandkbsEventTags
(
contend
.
getBrandLinkedGroup
(),
contend
.
getBrandLinkedGroupId
(),
contendEventTagsList
,
project
.
getProjectName
(),
project
.
getId
(),
contend
.
getBrandName
(),
contend
.
getId
(),
submitter
,
submitterId
);
}
}
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/ProjectWarnServiceImpl.java
View file @
6c536246
...
...
@@ -7,6 +7,7 @@ import com.zhiwei.brandkbs2.common.RedisKeyPrefix;
import
com.zhiwei.brandkbs2.config.Constant
;
import
com.zhiwei.brandkbs2.dao.ChannelDao
;
import
com.zhiwei.brandkbs2.dao.EventDao
;
import
com.zhiwei.brandkbs2.dao.EventMiddlewareDao
;
import
com.zhiwei.brandkbs2.enmus.EmotionEnum
;
import
com.zhiwei.brandkbs2.es.EsClientDao
;
import
com.zhiwei.brandkbs2.es.EsQueryTools
;
...
...
@@ -78,12 +79,12 @@ public class ProjectWarnServiceImpl implements ProjectWarnService {
@Resource
(
name
=
"eventDao"
)
EventDao
eventDao
;
@Resource
(
name
=
"eventMiddlewareDao"
)
EventMiddlewareDao
eventMiddlewareDao
;
@Resource
(
name
=
"redisUtil"
)
RedisUtil
redisUtil
;
@Autowired
private
EventClient
eventClient
;
private
static
final
Map
<
String
,
String
>
TYPE_SEARCH
=
new
HashMap
<>();
static
{
...
...
@@ -729,14 +730,14 @@ public class ProjectWarnServiceImpl implements ProjectWarnService {
if
(
CollectionUtils
.
isNotEmpty
(
config
.
getOwnEvent
()))
{
// 调用事件中间件时,使用项目id作为主品牌id
List
<
com
.
zhiwei
.
middleware
.
event
.
pojo
.
entity
.
Event
>
ownEvents
=
event
Client
.
getEventsByProjectIdAndContendId
(
start
,
end
,
config
.
getOwnEvent
(),
projectId
,
projectId
,
config
.
getEventTop
());
event
MiddlewareDao
.
getEventsByProjectIdAndContendId
(
start
,
end
,
config
.
getOwnEvent
(),
projectId
,
projectId
,
config
.
getEventTop
());
eventMap
.
put
(
"品牌动态"
,
ownEvents
);
}
if
(
CollectionUtils
.
isNotEmpty
(
config
.
getContendsEvent
()))
{
List
<
com
.
zhiwei
.
middleware
.
event
.
pojo
.
entity
.
Event
>
contentEvents
=
new
ArrayList
<>();
for
(
String
contendId
:
config
.
getContendsEvent
())
{
contendId
=
Objects
.
equals
(
Constant
.
PRIMARY_CONTEND_ID
,
contendId
)
?
projectId
:
contendId
;
contentEvents
.
addAll
(
event
Client
.
getEventsByProjectIdAndContendId
(
start
,
end
,
config
.
getOwnEvent
(),
projectId
,
contendId
,
config
.
getEventTop
()));
contentEvents
.
addAll
(
event
MiddlewareDao
.
getEventsByProjectIdAndContendId
(
start
,
end
,
config
.
getOwnEvent
(),
projectId
,
contendId
,
config
.
getEventTop
()));
}
eventMap
.
put
(
"友商动态"
,
contentEvents
);
}
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/ReportServiceImpl.java
View file @
6c536246
...
...
@@ -5,10 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import
com.google.common.collect.Maps
;
import
com.zhiwei.brandkbs2.auth.UserThreadLocal
;
import
com.zhiwei.brandkbs2.common.RedisKeyPrefix
;
import
com.zhiwei.brandkbs2.dao.EventDao
;
import
com.zhiwei.brandkbs2.dao.EventDataDao
;
import
com.zhiwei.brandkbs2.dao.ReportDao
;
import
com.zhiwei.brandkbs2.dao.ReportSettingsDao
;
import
com.zhiwei.brandkbs2.dao.*
;
import
com.zhiwei.brandkbs2.enmus.EmotionEnum
;
import
com.zhiwei.brandkbs2.enmus.ReportTypeEnum
;
import
com.zhiwei.brandkbs2.enmus.response.ReportCodeEnum
;
...
...
@@ -31,7 +28,6 @@ import com.zhiwei.brandkbs2.service.ReportService;
import
com.zhiwei.brandkbs2.util.MongoUtil
;
import
com.zhiwei.brandkbs2.util.RedisUtil
;
import
com.zhiwei.brandkbs2.util.Tools
;
import
com.zhiwei.middleware.event.core.EventClient
;
import
com.zhiwei.middleware.event.pojo.entity.BrandkbsBasicInfo
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -82,6 +78,9 @@ public class ReportServiceImpl implements ReportService {
@Resource
(
name
=
"indexServiceImpl"
)
IndexService
indexService
;
@Resource
(
name
=
"eventMiddlewareDao"
)
EventMiddlewareDao
eventMiddlewareDao
;
@Resource
(
name
=
"mongoUtil"
)
com
.
zhiwei
.
brandkbs2
.
util
.
MongoUtil
mongoUtil
;
...
...
@@ -91,9 +90,6 @@ public class ReportServiceImpl implements ReportService {
@Autowired
StringRedisTemplate
stringRedisTemplate
;
@Autowired
private
EventClient
eventClient
;
@Override
public
Map
<
String
,
ReportSettingsDTO
>
getReportSettings
()
{
Map
<
String
,
ReportSettingsDTO
>
res
=
new
HashMap
<>();
...
...
@@ -104,7 +100,17 @@ public class ReportServiceImpl implements ReportService {
}
ReportSettingsDTO
reportSettingsDTO
=
ReportSettingsDTO
.
createFromReportSettings
(
settings
);
if
(!
CollectionUtils
.
isEmpty
(
reportSettingsDTO
.
getContendIds
()))
{
reportSettingsDTO
.
setContendBrandNames
(
reportSettingsDTO
.
getContendIds
().
stream
().
map
(
contendId
->
projectService
.
getProjectByContendId
(
UserThreadLocal
.
getProjectId
(),
contendId
).
getBrandName
()).
collect
(
Collectors
.
toList
()));
List
<
String
>
collect
=
reportSettingsDTO
.
getContendIds
().
stream
().
map
(
contendId
->
{
AbstractProject
project
=
projectService
.
getProjectByContendId
(
UserThreadLocal
.
getProjectId
(),
contendId
);
if
(
null
!=
project
)
{
return
project
.
getBrandName
();
}
return
null
;
}).
filter
(
Objects:
:
nonNull
).
collect
(
Collectors
.
toList
());
// 历史竞品信息已失效
if
(!
collect
.
isEmpty
())
{
reportSettingsDTO
.
setContendBrandNames
(
collect
);
}
}
res
.
put
(
key
,
reportSettingsDTO
);
}
...
...
@@ -112,8 +118,8 @@ public class ReportServiceImpl implements ReportService {
}
@Override
public
List
<
Report
>
get
Custom
ReportByStatus
(
String
projectId
,
boolean
status
)
{
Criteria
criteria
=
Criteria
.
where
(
"projectId"
).
is
(
projectId
).
and
(
"status"
).
is
(
status
)
.
and
(
"type"
).
is
(
ReportTypeEnum
.
CUSTOM
.
getState
())
;
public
List
<
Report
>
getReportByStatus
(
String
projectId
,
boolean
status
)
{
Criteria
criteria
=
Criteria
.
where
(
"projectId"
).
is
(
projectId
).
and
(
"status"
).
is
(
status
);
return
reportDao
.
findList
(
Query
.
query
(
criteria
));
}
...
...
@@ -240,8 +246,9 @@ public class ReportServiceImpl implements ReportService {
JSONObject
result
=
null
;
try
{
result
=
getPcReportResult
(
report
);
}
catch
(
IOException
e
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"es查询异常"
);
}
catch
(
Exception
e
)
{
log
.
error
(
"生成报告数据异常,id:{}"
,
report
.
getId
(),
e
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"生成报告数据异常"
);
}
redisUtil
.
set
(
redisKey
,
JSON
.
toJSONString
(
result
));
return
result
;
...
...
@@ -333,7 +340,7 @@ public class ReportServiceImpl implements ReportService {
* @param report 报告对象
* @return 月报结果
*/
private
JSONObject
getPcReportResult
(
Report
report
)
throws
IO
Exception
{
private
JSONObject
getPcReportResult
(
Report
report
)
throws
Exception
{
switchReportStatus
(
report
.
getId
(),
false
);
log
.
info
(
"getPcReportResult-生成报告开始,id:{}"
,
report
.
getId
());
Long
startTime
=
report
.
getStartTime
();
...
...
@@ -349,21 +356,26 @@ public class ReportServiceImpl implements ReportService {
result
.
put
(
"status"
,
true
);
result
.
put
(
"type"
,
ReportTypeEnum
.
getInstanceByState
(
report
.
getType
()).
getDescribe
());
result
.
put
(
"brandSummary"
,
this
.
getPcBrandSummary
(
startTime
,
endTime
,
lastStartTimeStr
,
projectId
,
linkedGroupId
,
contendId
));
List
<
Map
<
String
,
Long
>>
dayList
=
Tools
.
parseToDays
(
startTime
,
DateUtils
.
addDays
(
new
Date
(
endTime
),
-
1
).
getTime
());
result
.
put
(
"brandSpread"
,
this
.
getPcBrandSpread
(
dayList
,
projectId
,
linkedGroupId
,
contendId
));
Pair
<
Boolean
,
List
<
Map
<
String
,
Long
>>>
pair
=
Tools
.
getCutList
(
startTime
,
endTime
);
result
.
put
(
"timeType"
,
pair
.
getLeft
()
?
"day"
:
"hour"
);
result
.
put
(
"brandSpread"
,
this
.
getPcBrandSpread
(
pair
.
getRight
(),
projectId
,
linkedGroupId
,
contendId
));
result
.
put
(
"brandEvent"
,
this
.
getPcBrandEvent
(
startTime
,
endTime
,
projectId
,
contendId
));
List
<
JSONObject
>
contendCompare
=
report
.
getContends
().
stream
().
map
(
brandContendId
->
{
JSONObject
json
=
new
JSONObject
();
AbstractProject
abstractProject
=
projectService
.
getProjectByContendId
(
projectId
,
brandContendId
);
// 历史竞品信息已失效
if
(
null
!=
abstractProject
)
{
json
.
put
(
"id"
,
brandContendId
);
json
.
put
(
"brand"
,
abstractProject
.
getBrandName
());
try
{
json
.
put
(
"brandCompare"
,
markDataService
.
getContendSpreadAnalyze
(
startTime
,
endTime
,
projectId
,
brandContendId
,
5
,
tru
e
));
}
catch
(
IO
Exception
e
)
{
json
.
put
(
"brandCompare"
,
markDataService
.
getContendSpreadAnalyze
(
startTime
,
endTime
,
projectId
,
brandContendId
,
5
,
fals
e
));
}
catch
(
Exception
e
)
{
log
.
error
(
"getPcReportResult-brandCompare-"
,
e
);
}
return
json
;
}).
collect
(
Collectors
.
toList
());
}
return
null
;
}).
filter
(
Objects:
:
nonNull
).
collect
(
Collectors
.
toList
());
result
.
put
(
"contendCompare"
,
contendCompare
);
log
.
info
(
"getPcReportResult-生成报告结束,id:{}"
,
report
.
getId
());
switchReportStatus
(
report
.
getId
(),
true
);
...
...
@@ -395,12 +407,12 @@ public class ReportServiceImpl implements ReportService {
//正面事件传播量top
// 调用事件中间件时,主品牌id使用项目id
List
<
com
.
zhiwei
.
middleware
.
event
.
pojo
.
entity
.
Event
>
topPosEventList
=
event
Client
.
getEventsByTotalChannelVolumeTop
(
startTime
,
endTime
,
EmotionEnum
.
POSITIVE
.
getName
(),
projectId
,
projectId
,
3
);
event
MiddlewareDao
.
getEventsByTotalChannelVolumeTop
(
startTime
,
endTime
,
EmotionEnum
.
POSITIVE
.
getName
(),
projectId
,
projectId
,
3
);
if
(
CollectionUtils
.
isEmpty
(
topPosEventList
))
{
List
<
Map
.
Entry
<
String
,
Integer
>>
topPosArticleList
=
markDataService
.
getMarkTopTitle
(
startTime
,
endTime
,
EmotionEnum
.
POSITIVE
.
getName
(),
projectId
,
linkedGroupId
,
contendId
,
3
);
result
.
put
(
"topPosSummary"
,
this
.
getTopArticlesMsg
(
startTime
,
endTime
,
projectId
,
linkedGroupId
,
contendId
,
topPosArticleList
));
}
else
{
result
.
put
(
"topPosSummary"
,
this
.
getTopEventMsg
(
topPosEventList
));
result
.
put
(
"topPosSummary"
,
this
.
getTopEventMsg
(
topPosEventList
,
projectId
));
}
//获取上个周期时间范围内总正面稿件数
long
lastPositiveTotal
=
markDataService
.
getYuqingMarkCount
(
lastStartTime
,
startTime
,
EmotionEnum
.
POSITIVE
.
getName
(),
projectId
,
contendId
);
...
...
@@ -413,12 +425,12 @@ public class ReportServiceImpl implements ReportService {
//中性事件传播量top
// 调用事件中间件时,主品牌id使用项目id
List
<
com
.
zhiwei
.
middleware
.
event
.
pojo
.
entity
.
Event
>
topNeuEventList
=
event
Client
.
getEventsByTotalChannelVolumeTop
(
startTime
,
endTime
,
EmotionEnum
.
NEUTRAL
.
getName
(),
projectId
,
projectId
,
4
);
event
MiddlewareDao
.
getEventsByTotalChannelVolumeTop
(
startTime
,
endTime
,
EmotionEnum
.
NEUTRAL
.
getName
(),
projectId
,
projectId
,
4
);
if
(
CollectionUtils
.
isEmpty
(
topNeuEventList
))
{
List
<
Map
.
Entry
<
String
,
Integer
>>
topNeuArticleList
=
markDataService
.
getMarkTopTitle
(
startTime
,
endTime
,
EmotionEnum
.
NEUTRAL
.
getName
(),
projectId
,
linkedGroupId
,
contendId
,
4
);
result
.
put
(
"topNeuSummary"
,
this
.
getTopArticlesMsg
(
startTime
,
endTime
,
projectId
,
linkedGroupId
,
contendId
,
topNeuArticleList
));
}
else
{
result
.
put
(
"topNeuSummary"
,
this
.
getTopEventMsg
(
topNeuEventList
));
result
.
put
(
"topNeuSummary"
,
this
.
getTopEventMsg
(
topNeuEventList
,
projectId
));
}
//获取上个周期时间范围内总中性稿件数
long
lastNeutralTotal
=
markDataService
.
getYuqingMarkCount
(
lastStartTime
,
startTime
,
EmotionEnum
.
NEUTRAL
.
getName
(),
projectId
,
contendId
);
...
...
@@ -431,12 +443,12 @@ public class ReportServiceImpl implements ReportService {
//中性事件传播量top
// 调用事件中间件时,主品牌id使用项目id
List
<
com
.
zhiwei
.
middleware
.
event
.
pojo
.
entity
.
Event
>
topNegEventList
=
event
Client
.
getEventsByTotalChannelVolumeTop
(
startTime
,
endTime
,
EmotionEnum
.
NEGATIVE
.
getName
(),
projectId
,
projectId
,
4
);
event
MiddlewareDao
.
getEventsByTotalChannelVolumeTop
(
startTime
,
endTime
,
EmotionEnum
.
NEGATIVE
.
getName
(),
projectId
,
projectId
,
4
);
if
(
CollectionUtils
.
isEmpty
(
topNegEventList
))
{
List
<
Map
.
Entry
<
String
,
Integer
>>
topNegArticleList
=
markDataService
.
getMarkTopTitle
(
startTime
,
endTime
,
EmotionEnum
.
NEGATIVE
.
getName
(),
projectId
,
linkedGroupId
,
contendId
,
4
);
result
.
put
(
"topNegSummary"
,
this
.
getTopArticlesMsg
(
startTime
,
endTime
,
projectId
,
linkedGroupId
,
contendId
,
topNegArticleList
));
}
else
{
result
.
put
(
"topNegSummary"
,
this
.
getTopEventMsg
(
topNegEventList
));
result
.
put
(
"topNegSummary"
,
this
.
getTopEventMsg
(
topNegEventList
,
projectId
));
}
//获取上个周期时间范围内总负面稿件数
long
lastNegativeTotal
=
markDataService
.
getYuqingMarkCount
(
lastStartTime
,
startTime
,
EmotionEnum
.
NEGATIVE
.
getName
(),
projectId
,
contendId
);
...
...
@@ -510,7 +522,7 @@ public class ReportServiceImpl implements ReportService {
result
.
put
(
"name"
,
Objects
.
equals
(
emotion
,
EmotionEnum
.
POSITIVE
.
getName
())
?
"正面事件"
:
Objects
.
equals
(
emotion
,
EmotionEnum
.
NEGATIVE
.
getName
())
?
"负面事件"
:
"中性事件"
);
// 调用事件中间件时,主品牌id使用项目id
List
<
com
.
zhiwei
.
middleware
.
event
.
pojo
.
entity
.
Event
>
topEventList
=
event
Client
.
getEventsByTotalChannelVolumeTop
(
startTime
,
endTime
,
emotion
,
projectId
,
projectId
,
10
);
event
MiddlewareDao
.
getEventsByTotalChannelVolumeTop
(
startTime
,
endTime
,
emotion
,
projectId
,
projectId
,
10
);
result
.
put
(
"events"
,
topEventList
.
stream
().
map
(
event
->
{
JSONObject
topEvent
=
new
JSONObject
();
boolean
hasAnalyze
=
false
;
...
...
@@ -574,8 +586,7 @@ public class ReportServiceImpl implements ReportService {
* @param topEventList top事件集合
* @return top事件信息
*/
private
List
<
JSONObject
>
getTopEventMsg
(
List
<
com
.
zhiwei
.
middleware
.
event
.
pojo
.
entity
.
Event
>
topEventList
)
{
String
projectId
=
UserThreadLocal
.
getProjectId
();
private
List
<
JSONObject
>
getTopEventMsg
(
List
<
com
.
zhiwei
.
middleware
.
event
.
pojo
.
entity
.
Event
>
topEventList
,
String
projectId
)
{
return
topEventList
.
stream
().
map
(
event
->
{
boolean
hasAnalyze
=
false
;
for
(
BrandkbsBasicInfo
brandkbsInfo
:
event
.
getBrandkbsInfos
())
{
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/TaskServiceImpl.java
View file @
6c536246
...
...
@@ -78,6 +78,9 @@ public class TaskServiceImpl implements TaskService {
@Resource
(
name
=
"eventServiceImpl"
)
EventService
eventService
;
@Resource
(
name
=
"customEventServiceImpl"
)
CustomEventService
customEventService
;
@Resource
(
name
=
"taskServiceExecutor"
)
ThreadPoolTaskExecutor
taskServiceExecutor
;
...
...
@@ -121,7 +124,7 @@ public class TaskServiceImpl implements TaskService {
Long
[]
timeMinMax
=
Tools
.
timeMinMax
(
rangeTimeRecords
.
stream
().
map
(
Pair:
:
getLeft
).
collect
(
Collectors
.
toList
()));
List
<
ChannelRecord
>
channelRecords
=
ChannelRecord
.
createChannelRecords
(
timeMinMax
[
0
],
timeMinMax
[
1
],
channelIndexRecordMap
);
channelEsDao
.
upsertChannelRecord
(
channelRecords
);
// 同步
channelCopy
// 同步
ES-channelCopy,区分insertList和updateList
ListUtils
.
partition
(
insertList
,
1000
).
forEach
(
list
->
{
channelEsDao
.
batchInsert
(
list
.
stream
().
map
(
Channel:
:
createChannelCopyMap
).
collect
(
Collectors
.
toList
()));
});
...
...
@@ -145,7 +148,6 @@ public class TaskServiceImpl implements TaskService {
channelService
.
getPositiveList
(
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
);
});
log
.
info
(
"项目:{}-渠道榜单缓存已完成:{}个"
,
project
.
getProjectName
(),
total
.
incrementAndGet
());
return
null
;
...
...
@@ -172,6 +174,23 @@ public class TaskServiceImpl implements TaskService {
},
cacheServiceExecutor
)).
toArray
(
CompletableFuture
[]::
new
)).
join
();
}
@Override
public
void
customEventCache
()
{
AtomicInteger
total
=
new
AtomicInteger
();
Long
[]
timeRangeFormatWeek
=
commonService
.
getTimeRangeFormatWeek
();
Long
[]
timeRangeLastWeek
=
new
Long
[]{
timeRangeFormatWeek
[
0
]
-
Constant
.
ONE_WEEK
,
timeRangeFormatWeek
[
1
]
-
Constant
.
ONE_WEEK
};
List
<
Long
[]>
timeList
=
Arrays
.
asList
(
commonService
.
getTimeRangeDay
(),
timeRangeLastWeek
);
CompletableFuture
.
allOf
(
GlobalPojo
.
PROJECT_MAP
.
values
().
stream
().
map
(
project
->
CompletableFuture
.
supplyAsync
(()
->
{
UserThreadLocal
.
set
(
new
UserInfo
().
setProjectId
(
project
.
getId
()));
timeList
.
forEach
(
times
->
{
// 自定义事件标题缓存
customEventService
.
getCustomEventRankList
(
times
[
0
],
times
[
1
]);
});
log
.
info
(
"项目:{}-自定义事件标题缓存已完成:{}个"
,
project
.
getProjectName
(),
total
.
incrementAndGet
());
return
null
;
},
cacheServiceExecutor
)).
toArray
(
CompletableFuture
[]::
new
)).
join
();
}
private
Pair
<
List
<
Channel
>,
List
<
Channel
>>
batchHandle
(
List
<
Map
.
Entry
<
ChannelIndex
,
ChannelIndex
.
Record
>>
batchList
,
Map
<
ChannelIndex
,
ChannelIndex
.
Record
>
newRecordMap
)
{
List
<
Channel
>
insertList
=
Collections
.
synchronizedList
(
new
ArrayList
<>());
...
...
@@ -296,24 +315,26 @@ public class TaskServiceImpl implements TaskService {
private
boolean
reportSendByProject
(
Project
project
)
{
boolean
flag
=
false
;
// 扫描setting信息
// 扫描setting信息
并生成对应报告
for
(
ReportSettings
reportSettings
:
reportSettingsDao
.
getReportSettingByProjectWithUsed
(
project
.
getId
()))
{
ReportTypeEnum
reportType
=
ReportTypeEnum
.
getInstanceByState
(
reportSettings
.
getType
());
if
(
ReportTypeEnum
.
canPublishNow
(
reportType
))
{
Pair
<
Boolean
,
Report
>
booleanReportPair
=
reportService
.
generateReportBySettings
(
reportSettings
,
project
);
// 生成新的简报之后的处理
if
(
booleanReportPair
.
getLeft
())
{
Report
report
=
booleanReportPair
.
getRight
();
// 用作生成缓存
reportService
.
getPcReportAnalyze
(
report
.
getId
(),
false
);
}
// if (booleanReportPair.getLeft()) {
// Report report = booleanReportPair.getRight();
// // 用作生成缓存
// reportService.getPcReportAnalyze(report.getId(), false);
// reportService.switchReportStatus(report.getId(), true);
// }
flag
=
true
;
}
}
//
自定义简报不通过setting生效
for
(
Report
report
:
reportService
.
get
Custom
ReportByStatus
(
project
.
getId
(),
false
))
{
//
生成对应报告
for
(
Report
report
:
reportService
.
getReportByStatus
(
project
.
getId
(),
false
))
{
// 用作生成缓存
reportService
.
getPcReportAnalyze
(
report
.
getId
(),
false
);
reportService
.
switchReportStatus
(
report
.
getId
(),
true
);
}
return
flag
;
}
...
...
src/main/java/com/zhiwei/brandkbs2/task/ControlCenter.java
View file @
6c536246
...
...
@@ -41,13 +41,14 @@ public class ControlCenter {
@Async
(
"scheduledExecutor"
)
@Scheduled
(
cron
=
"0 0 1 * * ?"
)
public
void
messageFlowCache
()
{
log
.
info
(
"定时按天缓存
消息流信息
-启动"
);
log
.
info
(
"定时按天缓存
数据
-启动"
);
try
{
taskService
.
messageFlowCache
();
taskService
.
customEventCache
();
}
catch
(
Exception
e
)
{
log
.
error
(
"定时按天缓存
消息流信息
-出错"
,
e
);
log
.
error
(
"定时按天缓存
数据
-出错"
,
e
);
}
finally
{
log
.
info
(
"定时按天缓存
消息流信息
-结束"
);
log
.
info
(
"定时按天缓存
数据
-结束"
);
}
}
...
...
src/main/java/com/zhiwei/brandkbs2/util/Tools.java
View file @
6c536246
...
...
@@ -24,6 +24,7 @@ import org.apache.commons.collections4.MapUtils;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.time.DateUtils
;
import
org.apache.commons.lang3.time.FastDateFormat
;
import
org.apache.commons.lang3.tuple.Pair
;
import
org.dozer.DozerBeanMapper
;
import
org.joda.time.Period
;
import
org.joda.time.PeriodType
;
...
...
@@ -853,6 +854,19 @@ public class Tools {
return
dayList
;
}
public
static
Pair
<
Boolean
,
List
<
Map
<
String
,
Long
>>>
getCutList
(
Long
startTime
,
Long
endTime
)
{
// 时间超过三天则选用day
boolean
dayType
=
true
;
List
<
Map
<
String
,
Long
>>
cutList
;
if
(
endTime
-
startTime
>
Constant
.
ONE_DAY
*
3
)
{
cutList
=
Tools
.
parseToDays
(
startTime
,
endTime
);
}
else
{
cutList
=
Tools
.
parseToHours
(
startTime
,
endTime
);
dayType
=
false
;
}
return
Pair
.
of
(
dayType
,
cutList
);
}
public
static
boolean
isContains
(
String
keyword
,
String
content
)
{
if
(
null
==
keyword
)
{
return
true
;
...
...
src/test/java/com/zhiwei/brandkbs2/ReportServiceTest.java
View file @
6c536246
...
...
@@ -32,7 +32,7 @@ public class ReportServiceTest {
@Test
public
void
getCustomReportByStatusTest
(){
List
<
Report
>
customReportByStatus
=
reportService
.
get
Custom
ReportByStatus
(
UserThreadLocal
.
getProjectId
(),
false
);
List
<
Report
>
customReportByStatus
=
reportService
.
getReportByStatus
(
UserThreadLocal
.
getProjectId
(),
false
);
for
(
Report
reportByStatus
:
customReportByStatus
)
{
System
.
out
.
println
(
reportByStatus
);
}
...
...
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