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
78990915
Commit
78990915
authored
Mar 02, 2023
by
shenjunjie
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature' into 'release'
Feature See merge request
!228
parents
e0de219d
00b852a3
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
139 additions
and
30 deletions
+139
-30
src/main/java/com/zhiwei/brandkbs2/aop/AopLogRecord.java
+52
-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/pojo/Behavior.java
+12
-0
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/CommonServiceImpl.java
+1
-1
src/main/java/com/zhiwei/brandkbs2/service/impl/ReportServiceImpl.java
+22
-7
src/main/java/com/zhiwei/brandkbs2/service/impl/TaskServiceImpl.java
+27
-6
src/main/java/com/zhiwei/brandkbs2/task/ControlCenter.java
+4
-3
No files found.
src/main/java/com/zhiwei/brandkbs2/aop/AopLogRecord.java
View file @
78990915
package
com
.
zhiwei
.
brandkbs2
.
aop
;
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.common.GenericAttribute
;
import
com.zhiwei.brandkbs2.dao.BehaviorDao
;
import
com.zhiwei.brandkbs2.dao.BehaviorDao
;
import
com.zhiwei.brandkbs2.model.ResponseResult
;
import
com.zhiwei.brandkbs2.pojo.Behavior
;
import
com.zhiwei.brandkbs2.pojo.Behavior
;
import
com.zhiwei.brandkbs2.service.UserService
;
import
com.zhiwei.brandkbs2.service.UserService
;
import
com.zhiwei.brandkbs2.util.Tools
;
import
com.zhiwei.brandkbs2.util.Tools
;
...
@@ -9,8 +12,8 @@ import com.zhiwei.middleware.auth.util.JwtUtil;
...
@@ -9,8 +12,8 @@ import com.zhiwei.middleware.auth.util.JwtUtil;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.annotation.AfterReturning
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Before
;
import
org.aspectj.lang.reflect.MethodSignature
;
import
org.aspectj.lang.reflect.MethodSignature
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -45,8 +48,8 @@ public class AopLogRecord {
...
@@ -45,8 +48,8 @@ public class AopLogRecord {
private
static
final
List
<
String
>
URL_PATTERNS
=
Arrays
.
asList
(
"/getNewAll"
,
"/getNew"
,
"/schedule"
);
private
static
final
List
<
String
>
URL_PATTERNS
=
Arrays
.
asList
(
"/getNewAll"
,
"/getNew"
,
"/schedule"
);
@
Before
(
"execution(public * com..controller..admin..*Controller.*(..)) || execution(* com..controller..app..*Controller.*(..))
"
)
@
AfterReturning
(
value
=
"execution(public * com..controller..admin..*Controller.*(..)) || execution(* com..controller..app..*Controller.*(..))"
,
returning
=
"ResponseResult
"
)
private
void
beforeLog
(
JoinPoint
joinPoint
)
throws
UnknownHostException
,
ClassNotFoundException
{
private
void
beforeLog
(
JoinPoint
joinPoint
,
ResponseResult
ResponseResult
)
throws
UnknownHostException
,
ClassNotFoundException
{
long
now
=
System
.
currentTimeMillis
();
long
now
=
System
.
currentTimeMillis
();
// RequestContextHolder 顾名思义 持有 request 上下文的容器
// RequestContextHolder 顾名思义 持有 request 上下文的容器
ServletRequestAttributes
requestAttributes
=
(
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
();
ServletRequestAttributes
requestAttributes
=
(
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
();
...
@@ -87,8 +90,9 @@ public class AopLogRecord {
...
@@ -87,8 +90,9 @@ public class AopLogRecord {
String
ipAddress
=
Tools
.
getIpAddress
(
request
);
String
ipAddress
=
Tools
.
getIpAddress
(
request
);
// 接口传参信息
// 接口传参信息
List
<
Map
<
String
,
Object
>>
arguments
=
getRequestArguments
(
joinPoint
);
List
<
Map
<
String
,
Object
>>
arguments
=
getRequestArguments
(
joinPoint
);
Behavior
behavior
=
new
Behavior
(
userId
,
projectId
,
nickName
,
ipAddress
,
now
,
controller
,
method
,
backstage
,
Behavior
behavior
=
new
Behavior
(
userId
,
projectId
,
nickName
,
ipAddress
,
now
,
controller
,
method
,
backstage
,
uri
,
methodName
,
httpMethod
,
arguments
,
now
,
severAddress
);
uri
,
methodName
,
httpMethod
,
arguments
,
now
,
severAddress
,
null
,
null
,
null
);
setInfo
(
behavior
,
uri
,
joinPoint
,
methodSignature
,
arguments
,
ResponseResult
);
String
collectionName
=
behaviorDao
.
generateCollectionName
();
String
collectionName
=
behaviorDao
.
generateCollectionName
();
behaviorDao
.
insertOneWithoutId
(
behavior
,
collectionName
);
behaviorDao
.
insertOneWithoutId
(
behavior
,
collectionName
);
}
}
...
@@ -96,6 +100,49 @@ public class AopLogRecord {
...
@@ -96,6 +100,49 @@ 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
keyword
=
null
;
String
channel
=
null
;
String
title
=
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
]);
keyword
=
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"
)){
keyword
=
String
.
valueOf
(
args
[
i
]);
}
}
}
}
if
(
uri
.
contains
(
"/app/channel/baseInfo"
)){
JSONObject
jsonObject
=
(
JSONObject
)
JSONObject
.
toJSON
(
ResponseResult
.
getData
());
channel
=
jsonObject
.
get
(
"platform"
)
+
"_"
+
jsonObject
.
get
(
"source"
);
}
if
(
uri
.
contains
(
"/app/event/detail/baseInfo"
)){
JSONObject
jsonObject
=
(
JSONObject
)
JSON
.
toJSON
(
ResponseResult
.
getData
());
title
=
String
.
valueOf
(
jsonObject
.
get
(
"title"
));
}
behavior
.
setSearchKeyword
(
keyword
);
behavior
.
setChannel
(
channel
);
behavior
.
setEventTitle
(
title
);
}
/**
* 获取接口传参信息
* 获取接口传参信息
* @param joinPoint
* @param joinPoint
* @return
* @return
...
...
src/main/java/com/zhiwei/brandkbs2/config/Constant.java
View file @
78990915
...
@@ -14,6 +14,7 @@ public class Constant {
...
@@ -14,6 +14,7 @@ public class Constant {
public
static
final
Long
EIGHT_HOUR
=
8
*
60
*
60
*
1000L
;
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_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
Long
ONE_MONTH
=
30
*
24
*
60
*
60
*
1000L
;
public
static
final
String
SPEC_MINUTE_PATTERN
=
"yyyy.MM.dd HH:mm"
;
public
static
final
String
SPEC_MINUTE_PATTERN
=
"yyyy.MM.dd HH:mm"
;
...
...
src/main/java/com/zhiwei/brandkbs2/controller/CommonController.java
View file @
78990915
...
@@ -69,18 +69,25 @@ public class CommonController extends BaseController {
...
@@ -69,18 +69,25 @@ public class CommonController extends BaseController {
return
ResponseResult
.
success
(
projectService
.
getUserAllProjects
());
return
ResponseResult
.
success
(
projectService
.
getUserAllProjects
());
}
}
// @ApiOperation("获取默认
月
间隔时间节点")
// @ApiOperation("获取默认
天
间隔时间节点")
// @GetMapping("/time/
month
")
// @GetMapping("/time/
format/day
")
// @Auth(role = RoleEnum.CUSTOMER)
// @Auth(role = RoleEnum.CUSTOMER)
// public ResponseResult getTimeRange
Month
() {
// public ResponseResult getTimeRange
Day
() {
// return ResponseResult.success(commonService.getTimeRange
Month
());
// return ResponseResult.success(commonService.getTimeRange
Day
());
// }
// }
//
//
// @ApiOperation("获取默认周间隔时间节点")
// @ApiOperation("获取默认周间隔时间节点")
// @GetMapping("/time/week")
// @GetMapping("/time/
format/
week")
// @Auth(role = RoleEnum.CUSTOMER)
// @Auth(role = RoleEnum.CUSTOMER)
// public ResponseResult getTimeRangeWeek() {
// 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/pojo/Behavior.java
View file @
78990915
...
@@ -73,6 +73,18 @@ public class Behavior extends AbstractBaseMongo {
...
@@ -73,6 +73,18 @@ public class Behavior extends AbstractBaseMongo {
* 服务器地址
* 服务器地址
*/
*/
private
String
severAddress
;
private
String
severAddress
;
/**
* 搜索关键词
*/
private
String
searchKeyword
;
/**
* 渠道
*/
private
String
channel
;
/**
* 事件名
*/
private
String
eventTitle
;
@Getter
@Getter
public
static
class
Operation
{
public
static
class
Operation
{
...
...
src/main/java/com/zhiwei/brandkbs2/service/TaskService.java
View file @
78990915
...
@@ -24,6 +24,11 @@ public interface TaskService{
...
@@ -24,6 +24,11 @@ public interface TaskService{
void
messageFlowCache
();
void
messageFlowCache
();
/**
/**
* 自定义事件标题聚合分析缓存
*/
void
customEventCache
();
/**
* 生成简报任务并推送
* 生成简报任务并推送
*/
*/
void
generateReportAndSend
();
void
generateReportAndSend
();
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/BehaviorServiceImpl.java
View file @
78990915
...
@@ -11,8 +11,6 @@ import com.zhiwei.brandkbs2.pojo.UserRole;
...
@@ -11,8 +11,6 @@ import com.zhiwei.brandkbs2.pojo.UserRole;
import
com.zhiwei.brandkbs2.pojo.vo.BehaviorVO
;
import
com.zhiwei.brandkbs2.pojo.vo.BehaviorVO
;
import
com.zhiwei.brandkbs2.pojo.vo.PageVO
;
import
com.zhiwei.brandkbs2.pojo.vo.PageVO
;
import
com.zhiwei.brandkbs2.service.BehaviorService
;
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.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.LogManager
;
...
@@ -123,6 +121,8 @@ public class BehaviorServiceImpl implements BehaviorService {
...
@@ -123,6 +121,8 @@ public class BehaviorServiceImpl implements BehaviorService {
Date
end
=
new
Date
(
endTime
);
Date
end
=
new
Date
(
endTime
);
Query
query
=
new
Query
();
Query
query
=
new
Query
();
query
.
addCriteria
(
Criteria
.
where
(
"cTime"
).
gte
(
startTime
).
lt
(
endTime
).
and
(
"backstage"
).
is
(
backstage
));
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
<
Behavior
>
behaviorList
=
behaviorDao
.
findList
(
query
,
behaviorDao
.
generateCollectionNames
(
start
,
end
));
List
<
ExportBehaviorDTO
>
resList
=
new
ArrayList
<>(
behaviorList
.
size
());
List
<
ExportBehaviorDTO
>
resList
=
new
ArrayList
<>(
behaviorList
.
size
());
behaviorList
.
forEach
(
behavior
->
{
behaviorList
.
forEach
(
behavior
->
{
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/CommonServiceImpl.java
View file @
78990915
...
@@ -113,7 +113,7 @@ public class CommonServiceImpl implements CommonService {
...
@@ -113,7 +113,7 @@ public class CommonServiceImpl implements CommonService {
@Override
@Override
public
Long
[]
getTimeRangeMonth
()
{
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
();
long
startTime
=
DateUtils
.
addMonths
(
new
Date
(
endTime
),
-
1
).
getTime
();
return
new
Long
[]{
startTime
,
endTime
};
return
new
Long
[]{
startTime
,
endTime
};
}
}
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/ReportServiceImpl.java
View file @
78990915
...
@@ -100,7 +100,17 @@ public class ReportServiceImpl implements ReportService {
...
@@ -100,7 +100,17 @@ public class ReportServiceImpl implements ReportService {
}
}
ReportSettingsDTO
reportSettingsDTO
=
ReportSettingsDTO
.
createFromReportSettings
(
settings
);
ReportSettingsDTO
reportSettingsDTO
=
ReportSettingsDTO
.
createFromReportSettings
(
settings
);
if
(!
CollectionUtils
.
isEmpty
(
reportSettingsDTO
.
getContendIds
()))
{
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
);
res
.
put
(
key
,
reportSettingsDTO
);
}
}
...
@@ -236,8 +246,9 @@ public class ReportServiceImpl implements ReportService {
...
@@ -236,8 +246,9 @@ public class ReportServiceImpl implements ReportService {
JSONObject
result
=
null
;
JSONObject
result
=
null
;
try
{
try
{
result
=
getPcReportResult
(
report
);
result
=
getPcReportResult
(
report
);
}
catch
(
IOException
e
)
{
}
catch
(
Exception
e
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"es查询异常"
);
log
.
error
(
"生成报告数据异常"
,
e
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"生成报告数据异常"
);
}
}
redisUtil
.
set
(
redisKey
,
JSON
.
toJSONString
(
result
));
redisUtil
.
set
(
redisKey
,
JSON
.
toJSONString
(
result
));
return
result
;
return
result
;
...
@@ -329,7 +340,7 @@ public class ReportServiceImpl implements ReportService {
...
@@ -329,7 +340,7 @@ public class ReportServiceImpl implements ReportService {
* @param report 报告对象
* @param report 报告对象
* @return 月报结果
* @return 月报结果
*/
*/
private
JSONObject
getPcReportResult
(
Report
report
)
throws
IO
Exception
{
private
JSONObject
getPcReportResult
(
Report
report
)
throws
Exception
{
switchReportStatus
(
report
.
getId
(),
false
);
switchReportStatus
(
report
.
getId
(),
false
);
log
.
info
(
"getPcReportResult-生成报告开始,id:{}"
,
report
.
getId
());
log
.
info
(
"getPcReportResult-生成报告开始,id:{}"
,
report
.
getId
());
Long
startTime
=
report
.
getStartTime
();
Long
startTime
=
report
.
getStartTime
();
...
@@ -352,15 +363,19 @@ public class ReportServiceImpl implements ReportService {
...
@@ -352,15 +363,19 @@ public class ReportServiceImpl implements ReportService {
List
<
JSONObject
>
contendCompare
=
report
.
getContends
().
stream
().
map
(
brandContendId
->
{
List
<
JSONObject
>
contendCompare
=
report
.
getContends
().
stream
().
map
(
brandContendId
->
{
JSONObject
json
=
new
JSONObject
();
JSONObject
json
=
new
JSONObject
();
AbstractProject
abstractProject
=
projectService
.
getProjectByContendId
(
projectId
,
brandContendId
);
AbstractProject
abstractProject
=
projectService
.
getProjectByContendId
(
projectId
,
brandContendId
);
// 历史竞品信息已失效
if
(
null
!=
abstractProject
)
{
json
.
put
(
"id"
,
brandContendId
);
json
.
put
(
"id"
,
brandContendId
);
json
.
put
(
"brand"
,
abstractProject
.
getBrandName
());
json
.
put
(
"brand"
,
abstractProject
.
getBrandName
());
try
{
try
{
json
.
put
(
"brandCompare"
,
markDataService
.
getContendSpreadAnalyze
(
startTime
,
endTime
,
projectId
,
brandContendId
,
5
,
tru
e
));
json
.
put
(
"brandCompare"
,
markDataService
.
getContendSpreadAnalyze
(
startTime
,
endTime
,
projectId
,
brandContendId
,
5
,
fals
e
));
}
catch
(
IO
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"getPcReportResult-brandCompare-"
,
e
);
log
.
error
(
"getPcReportResult-brandCompare-"
,
e
);
}
}
return
json
;
return
json
;
}).
collect
(
Collectors
.
toList
());
}
return
null
;
}).
filter
(
Objects:
:
nonNull
).
collect
(
Collectors
.
toList
());
result
.
put
(
"contendCompare"
,
contendCompare
);
result
.
put
(
"contendCompare"
,
contendCompare
);
log
.
info
(
"getPcReportResult-生成报告结束,id:{}"
,
report
.
getId
());
log
.
info
(
"getPcReportResult-生成报告结束,id:{}"
,
report
.
getId
());
switchReportStatus
(
report
.
getId
(),
true
);
switchReportStatus
(
report
.
getId
(),
true
);
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/TaskServiceImpl.java
View file @
78990915
...
@@ -78,6 +78,9 @@ public class TaskServiceImpl implements TaskService {
...
@@ -78,6 +78,9 @@ public class TaskServiceImpl implements TaskService {
@Resource
(
name
=
"eventServiceImpl"
)
@Resource
(
name
=
"eventServiceImpl"
)
EventService
eventService
;
EventService
eventService
;
@Resource
(
name
=
"customEventServiceImpl"
)
CustomEventService
customEventService
;
@Resource
(
name
=
"taskServiceExecutor"
)
@Resource
(
name
=
"taskServiceExecutor"
)
ThreadPoolTaskExecutor
taskServiceExecutor
;
ThreadPoolTaskExecutor
taskServiceExecutor
;
...
@@ -113,14 +116,14 @@ public class TaskServiceImpl implements TaskService {
...
@@ -113,14 +116,14 @@ public class TaskServiceImpl implements TaskService {
}
}
// 替换成新的记录map
// 替换成新的记录map
channelIndexRecordMap
=
newRecordMap
;
channelIndexRecordMap
=
newRecordMap
;
ListUtils
.
partition
(
insertList
,
1000
).
forEach
(
list
->
{
//
ListUtils.partition(insertList, 1000).forEach(list -> {
channelDao
.
insertMany
(
list
);
//
channelDao.insertMany(list);
});
//
});
log
.
info
(
"渠道统计-渠道总计-录入完毕,新增渠道{}条,更新渠道{}条"
,
insertList
.
size
(),
channelIndexRecordMap
.
size
()
-
insertList
.
size
());
log
.
info
(
"渠道统计-渠道总计-录入完毕,新增渠道{}条,更新渠道{}条"
,
insertList
.
size
(),
channelIndexRecordMap
.
size
()
-
insertList
.
size
());
// 获得单位时间内最小最大时间戳
// 获得单位时间内最小最大时间戳
Long
[]
timeMinMax
=
Tools
.
timeMinMax
(
rangeTimeRecords
.
stream
().
map
(
Pair:
:
getLeft
).
collect
(
Collectors
.
toList
()));
Long
[]
timeMinMax
=
Tools
.
timeMinMax
(
rangeTimeRecords
.
stream
().
map
(
Pair:
:
getLeft
).
collect
(
Collectors
.
toList
()));
List
<
ChannelRecord
>
channelRecords
=
ChannelRecord
.
createChannelRecords
(
timeMinMax
[
0
],
timeMinMax
[
1
],
channelIndexRecordMap
);
List
<
ChannelRecord
>
channelRecords
=
ChannelRecord
.
createChannelRecords
(
timeMinMax
[
0
],
timeMinMax
[
1
],
channelIndexRecordMap
);
channelEsDao
.
upsertChannelRecord
(
channelRecords
);
//
channelEsDao.upsertChannelRecord(channelRecords);
// 同步channelCopy
// 同步channelCopy
ListUtils
.
partition
(
insertList
,
1000
).
forEach
(
list
->
{
ListUtils
.
partition
(
insertList
,
1000
).
forEach
(
list
->
{
channelEsDao
.
batchInsert
(
list
.
stream
().
map
(
Channel:
:
createChannelCopyMap
).
collect
(
Collectors
.
toList
()));
channelEsDao
.
batchInsert
(
list
.
stream
().
map
(
Channel:
:
createChannelCopyMap
).
collect
(
Collectors
.
toList
()));
...
@@ -145,7 +148,6 @@ public class TaskServiceImpl implements TaskService {
...
@@ -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
.
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
);
channelService
.
getNegativeList
(
Constant
.
PRIMARY_CONTEND_ID
,
null
,
null
,
sorter
,
times
[
0
],
times
[
1
],
50
,
false
);
});
});
log
.
info
(
"项目:{}-渠道榜单缓存已完成:{}个"
,
project
.
getProjectName
(),
total
.
incrementAndGet
());
log
.
info
(
"项目:{}-渠道榜单缓存已完成:{}个"
,
project
.
getProjectName
(),
total
.
incrementAndGet
());
return
null
;
return
null
;
...
@@ -172,6 +174,23 @@ public class TaskServiceImpl implements TaskService {
...
@@ -172,6 +174,23 @@ public class TaskServiceImpl implements TaskService {
},
cacheServiceExecutor
)).
toArray
(
CompletableFuture
[]::
new
)).
join
();
},
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
,
private
Pair
<
List
<
Channel
>,
List
<
Channel
>>
batchHandle
(
List
<
Map
.
Entry
<
ChannelIndex
,
ChannelIndex
.
Record
>>
batchList
,
Map
<
ChannelIndex
,
ChannelIndex
.
Record
>
newRecordMap
)
{
ChannelIndex
.
Record
>
newRecordMap
)
{
List
<
Channel
>
insertList
=
Collections
.
synchronizedList
(
new
ArrayList
<>());
List
<
Channel
>
insertList
=
Collections
.
synchronizedList
(
new
ArrayList
<>());
...
@@ -188,7 +207,7 @@ public class TaskServiceImpl implements TaskService {
...
@@ -188,7 +207,7 @@ public class TaskServiceImpl implements TaskService {
channel
.
setRecord
(
entry
.
getValue
());
channel
.
setRecord
(
entry
.
getValue
());
Channel
updateChannel
=
channelService
.
calculateChannelEmotionIndex
(
channel
);
Channel
updateChannel
=
channelService
.
calculateChannelEmotionIndex
(
channel
);
updateChannel
.
updateInfo
(
entry
.
getKey
(),
entry
.
getValue
());
updateChannel
.
updateInfo
(
entry
.
getKey
(),
entry
.
getValue
());
channelDao
.
updateOne
(
updateChannel
);
//
channelDao.updateOne(updateChannel);
updateList
.
add
(
channel
);
updateList
.
add
(
channel
);
}
}
// 设置查询数值
// 设置查询数值
...
@@ -306,6 +325,7 @@ public class TaskServiceImpl implements TaskService {
...
@@ -306,6 +325,7 @@ public class TaskServiceImpl implements TaskService {
Report
report
=
booleanReportPair
.
getRight
();
Report
report
=
booleanReportPair
.
getRight
();
// 用作生成缓存
// 用作生成缓存
reportService
.
getPcReportAnalyze
(
report
.
getId
(),
false
);
reportService
.
getPcReportAnalyze
(
report
.
getId
(),
false
);
reportService
.
switchReportStatus
(
report
.
getId
(),
true
);
}
}
flag
=
true
;
flag
=
true
;
}
}
...
@@ -314,6 +334,7 @@ public class TaskServiceImpl implements TaskService {
...
@@ -314,6 +334,7 @@ public class TaskServiceImpl implements TaskService {
for
(
Report
report
:
reportService
.
getCustomReportByStatus
(
project
.
getId
(),
false
))
{
for
(
Report
report
:
reportService
.
getCustomReportByStatus
(
project
.
getId
(),
false
))
{
// 用作生成缓存
// 用作生成缓存
reportService
.
getPcReportAnalyze
(
report
.
getId
(),
false
);
reportService
.
getPcReportAnalyze
(
report
.
getId
(),
false
);
reportService
.
switchReportStatus
(
report
.
getId
(),
true
);
}
}
return
flag
;
return
flag
;
}
}
...
...
src/main/java/com/zhiwei/brandkbs2/task/ControlCenter.java
View file @
78990915
...
@@ -41,13 +41,14 @@ public class ControlCenter {
...
@@ -41,13 +41,14 @@ public class ControlCenter {
@Async
(
"scheduledExecutor"
)
@Async
(
"scheduledExecutor"
)
@Scheduled
(
cron
=
"0 0 1 * * ?"
)
@Scheduled
(
cron
=
"0 0 1 * * ?"
)
public
void
messageFlowCache
()
{
public
void
messageFlowCache
()
{
log
.
info
(
"定时按天缓存
消息流信息
-启动"
);
log
.
info
(
"定时按天缓存
数据
-启动"
);
try
{
try
{
taskService
.
messageFlowCache
();
taskService
.
messageFlowCache
();
taskService
.
customEventCache
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"定时按天缓存
消息流信息
-出错"
,
e
);
log
.
error
(
"定时按天缓存
数据
-出错"
,
e
);
}
finally
{
}
finally
{
log
.
info
(
"定时按天缓存
消息流信息
-结束"
);
log
.
info
(
"定时按天缓存
数据
-结束"
);
}
}
}
}
...
...
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