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
a03528a4
Commit
a03528a4
authored
Jan 29, 2024
by
陈健智
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
舆情分析-舆情驾驶舱
parent
51723f75
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
387 additions
and
7 deletions
+387
-7
src/main/java/com/zhiwei/brandkbs2/common/GenericAttribute.java
+2
-0
src/main/java/com/zhiwei/brandkbs2/common/RedisKeyPrefix.java
+11
-0
src/main/java/com/zhiwei/brandkbs2/controller/CommonController.java
+10
-0
src/main/java/com/zhiwei/brandkbs2/controller/app/AppArticleController.java
+85
-0
src/main/java/com/zhiwei/brandkbs2/es/EsQueryTools.java
+12
-0
src/main/java/com/zhiwei/brandkbs2/pojo/dto/MarkSearchDTO.java
+12
-1
src/main/java/com/zhiwei/brandkbs2/pojo/vo/ProjectVO.java
+2
-2
src/main/java/com/zhiwei/brandkbs2/service/MarkDataService.java
+123
-0
src/main/java/com/zhiwei/brandkbs2/service/TaskService.java
+10
-0
src/main/java/com/zhiwei/brandkbs2/service/impl/EsSearchServiceImpl.java
+16
-0
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkDataServiceImpl.java
+0
-0
src/main/java/com/zhiwei/brandkbs2/service/impl/TaskServiceImpl.java
+62
-4
src/main/java/com/zhiwei/brandkbs2/task/ControlCenter.java
+13
-0
src/main/java/com/zhiwei/brandkbs2/util/RedisUtil.java
+29
-0
No files found.
src/main/java/com/zhiwei/brandkbs2/common/GenericAttribute.java
View file @
a03528a4
...
...
@@ -47,6 +47,7 @@ public class GenericAttribute {
* es gid
**/
public
static
final
String
ES_GID
=
"gid"
;
public
static
final
String
ES_MGID
=
"mgid"
;
public
static
final
String
ES_PROJECT_ID
=
"project_id"
;
public
static
final
String
ES_CONTEND_ID
=
"contend_id"
;
public
static
final
String
ES_CHANNEL_FID
=
"fid"
;
...
...
@@ -88,6 +89,7 @@ public class GenericAttribute {
* es mtime
**/
public
static
final
String
ES_MTIME
=
"mtime"
;
public
static
final
String
ES_STIME
=
"stime"
;
/**
* es mtag
**/
...
...
src/main/java/com/zhiwei/brandkbs2/common/RedisKeyPrefix.java
View file @
a03528a4
...
...
@@ -102,6 +102,17 @@ public class RedisKeyPrefix {
public
static
final
String
NON_MANUAL_PROJECT_MARK_MAX_GID
=
"BRANDKBS:NON_MANUAL:PROJECT:MARK:MAX_GID:"
;
/**
* 新舆情分析页面相关缓存
*/
public
static
final
String
YUQING_ANALYZE_PROJECT_AVG_COUNT
=
"BRANDKBS:YUQING:ANALYZE:AMOUNT:AVG:"
;
public
static
final
String
YUQING_ANALYZE_EMOTION_DISTRIBUTION_AVG
=
"BRANDKBS:YUQING:ANALYZE:EMOTION:AVG:"
;
public
static
final
String
YUQING_ANALYZE_PLATFORM_AVG_COUNT
=
"BRANDKBS:YUQING:ANALYZE:PLATFORM:AVG:"
;
public
static
final
String
YUQING_ANALYZE_HIGH_WORD
=
"BRANDKBS:YUQING:ANALYZE:HIGH:WORD:"
;
public
static
String
projectWarnHotTopKeyAll
(
String
projectId
,
String
type
)
{
return
RedisKeyPrefix
.
generateRedisKey
(
RedisKeyPrefix
.
PROJECT_WARN_HOT_TOP
,
projectId
,
Tools
.
concat
(
type
,
"*"
));
}
...
...
src/main/java/com/zhiwei/brandkbs2/controller/CommonController.java
View file @
a03528a4
...
...
@@ -54,6 +54,16 @@ public class CommonController extends BaseController {
}
}
@ApiOperation
(
"获取平台类型及id"
)
@GetMapping
(
"/get/platform-id"
)
public
ResponseResult
getPlatformWithId
()
{
try
{
return
ResponseResult
.
success
(
commonService
.
getQbjcPlatform
(
"id"
,
"name"
));
}
catch
(
Exception
e
)
{
return
ResponseResult
.
failure
(
e
.
getMessage
());
}
}
@ApiOperation
(
"获取当前用户拥有的所有项目及品牌列表"
)
@GetMapping
(
"/user/getUserAllProjects"
)
@Auth
(
role
=
RoleEnum
.
CUSTOMER
)
...
...
src/main/java/com/zhiwei/brandkbs2/controller/app/AppArticleController.java
View file @
a03528a4
...
...
@@ -440,6 +440,91 @@ public class AppArticleController extends BaseController {
return
ResponseResult
.
success
(
markDataService
.
getNonManualMarkAggreeList
(
markSearchDTO
));
}
@ApiOperation
(
"获取方案列表"
)
@GetMapping
(
"/analyze/plan/list"
)
public
ResponseResult
getNonManualPlanList
(){
return
ResponseResult
.
success
(
markDataService
.
getNonManualPlanList
());
}
@ApiOperation
(
"新-舆情分析-舆情总量"
)
@GetMapping
(
"/analyze/amount"
)
public
ResponseResult
getYuqingAmount
(
@RequestParam
(
value
=
"startTime"
)
Long
startTime
,
@RequestParam
(
value
=
"endTime"
)
Long
endTime
,
@RequestParam
(
value
=
"planId"
,
required
=
false
)
String
planId
)
{
return
ResponseResult
.
success
(
markDataService
.
getYuqingAmount
(
startTime
,
endTime
,
planId
));
}
@ApiOperation
(
"新-舆情分析-情感分布"
)
@GetMapping
(
"/analyze/emotion"
)
public
ResponseResult
getYuqingEmotionDistribution
(
@RequestParam
(
value
=
"startTime"
)
Long
startTime
,
@RequestParam
(
value
=
"endTime"
)
Long
endTime
,
@RequestParam
(
value
=
"planId"
,
required
=
false
)
String
planId
)
{
return
ResponseResult
.
success
(
markDataService
.
getYuqingEmotionDistribution
(
startTime
,
endTime
,
planId
));
}
@ApiOperation
(
"新-舆情分析-重点平台"
)
@GetMapping
(
"/analyze/important-platform"
)
public
ResponseResult
getImportantPlatformPercentage
(
@RequestParam
(
value
=
"startTime"
)
Long
startTime
,
@RequestParam
(
value
=
"endTime"
)
Long
endTime
,
@RequestParam
(
value
=
"planId"
,
required
=
false
)
String
planId
)
{
return
ResponseResult
.
success
(
markDataService
.
getImportantPlatformPercentage
(
startTime
,
endTime
,
planId
));
}
@ApiOperation
(
"新-舆情分析-平台占比"
)
@GetMapping
(
"/analyze/platform-percent"
)
public
ResponseResult
getPlatformPercentage
(
@RequestParam
(
value
=
"startTime"
)
Long
startTime
,
@RequestParam
(
value
=
"endTime"
)
Long
endTime
,
@RequestParam
(
value
=
"planId"
,
required
=
false
)
String
planId
)
{
return
ResponseResult
.
success
(
markDataService
.
getPlatformPercentage
(
startTime
,
endTime
,
planId
));
}
@ApiOperation
(
"新-舆情分析-舆情走势图"
)
@GetMapping
(
"/analyze/tendency"
)
public
ResponseResult
getSpreadTendency
(
@RequestParam
(
value
=
"startTime"
)
Long
startTime
,
@RequestParam
(
value
=
"endTime"
)
Long
endTime
,
@RequestParam
(
value
=
"planId"
,
required
=
false
)
String
planId
)
{
return
ResponseResult
.
success
(
markDataService
.
getSpreadTendency
(
startTime
,
endTime
,
planId
));
}
@ApiOperation
(
"新-舆情分析-活跃渠道"
)
@GetMapping
(
"/analyze/active-channel"
)
public
ResponseResult
getActiveChannels
(
@RequestParam
(
value
=
"startTime"
)
Long
startTime
,
@RequestParam
(
value
=
"endTime"
)
Long
endTime
,
@RequestParam
(
value
=
"planId"
,
required
=
false
)
String
planId
)
{
return
ResponseResult
.
success
(
markDataService
.
getActiveChannels
(
startTime
,
endTime
,
planId
));
}
@ApiOperation
(
"新-舆情分析-ip分布"
)
@GetMapping
(
"/analyze/ip-located"
)
public
ResponseResult
getArticleIpLocated
(
@RequestParam
(
value
=
"startTime"
)
Long
startTime
,
@RequestParam
(
value
=
"endTime"
)
Long
endTime
,
@RequestParam
(
value
=
"planId"
,
required
=
false
)
String
planId
,
@RequestParam
(
value
=
"size"
)
int
size
)
{
return
ResponseResult
.
success
(
markDataService
.
getArticleIpLocated
(
startTime
,
endTime
,
planId
,
size
));
}
@ApiOperation
(
"新-舆情分析-词云"
)
@GetMapping
(
"/analyze/high-word"
)
public
ResponseResult
getHighWord
(
@RequestParam
(
value
=
"startTime"
)
Long
startTime
,
@RequestParam
(
value
=
"endTime"
)
Long
endTime
,
@RequestParam
(
value
=
"planId"
,
required
=
false
)
String
planId
)
{
return
ResponseResult
.
success
(
markDataService
.
getHighWord
(
startTime
,
endTime
,
planId
,
true
));
}
@ApiOperation
(
"新-舆情分析-高频标题"
)
@GetMapping
(
"/analyze/frequent-title"
)
public
ResponseResult
getLastNews
(
@RequestParam
(
value
=
"startTime"
)
Long
startTime
,
@RequestParam
(
value
=
"endTime"
)
Long
endTime
,
@RequestParam
(
value
=
"planId"
,
required
=
false
)
String
planId
)
{
return
ResponseResult
.
success
(
markDataService
.
getLastNews
(
startTime
,
endTime
,
planId
,
5
,
true
));
}
@ApiOperation
(
"新-舆情分析-活跃渠道、ip分布、词云详情页面,社媒平台发文"
)
@PostMapping
(
"/analyze/mark-data"
)
public
ResponseResult
getYuqingAnalyzeDetail
(
@RequestBody
MarkSearchDTO
markSearchDTO
)
{
return
ResponseResult
.
success
(
markDataService
.
getYuqingAnalyzeDetail
(
markSearchDTO
));
}
private
boolean
checkMTagIllegal
(
StringBuilder
mtag
)
{
List
<
MarkerTag
>
hitTags
=
projectService
.
getProjectById
(
UserThreadLocal
.
getProjectId
()).
getHitTags
();
if
(!
Tools
.
isEmpty
(
hitTags
))
{
...
...
src/main/java/com/zhiwei/brandkbs2/es/EsQueryTools.java
View file @
a03528a4
...
...
@@ -311,6 +311,18 @@ public class EsQueryTools {
}
/**
* ip查询
*
* @param ip ip地址
* @return
*/
public
static
BoolQueryBuilder
assembleIpQuery
(
String
ip
)
{
BoolQueryBuilder
queryBuilder
=
QueryBuilders
.
boolQuery
();
queryBuilder
.
should
(
QueryBuilders
.
termQuery
(
"ip_location.keyword"
,
ip
));
return
queryBuilder
;
}
/**
* 字段不拆封,多字段 同关键词
*
* @param @param boolQueryBuilder
...
...
src/main/java/com/zhiwei/brandkbs2/pojo/dto/MarkSearchDTO.java
View file @
a03528a4
...
...
@@ -181,7 +181,18 @@ public class MarkSearchDTO {
@ApiModelProperty
(
value
=
"数据类型(1:长文本, 2:短文本, 3:问答, 5:视频)"
)
private
Integer
dataType
;
/**
*
gid用于未读已读筛选,仅非人工项目
*
ip地址
*/
@ApiModelProperty
(
value
=
"ip地址"
)
private
String
ip
;
/**
* gid用于未读已读筛选,非人工项目舆情数据用
*/
@ApiModelProperty
(
value
=
"gid"
)
private
Long
gid
;
/**
* gid限制 舆情分析页面滚动翻页用
*/
@ApiModelProperty
(
value
=
"gid限制"
)
private
Long
pageGid
;
}
src/main/java/com/zhiwei/brandkbs2/pojo/vo/ProjectVO.java
View file @
a03528a4
...
...
@@ -163,7 +163,7 @@ public class ProjectVO {
project
.
setPositiveChannelParams
((
this
.
getPositiveChannelParams
()));
project
.
setBlackChannelGroup
(
this
.
getBlackChannelGroup
());
project
.
setShow
(
true
);
project
.
setStart
(
fals
e
);
project
.
setStart
(
tru
e
);
project
.
setManual
(
true
);
project
.
setCTime
(
time
.
getTime
());
project
.
setUTime
(
time
.
getTime
());
...
...
@@ -189,7 +189,7 @@ public class ProjectVO {
// 非人工项目
project
.
setManual
(
false
);
project
.
setShow
(
true
);
project
.
setStart
(
fals
e
);
project
.
setStart
(
tru
e
);
project
.
setCTime
(
System
.
currentTimeMillis
());
project
.
setUTime
(
System
.
currentTimeMillis
());
return
project
;
...
...
src/main/java/com/zhiwei/brandkbs2/service/MarkDataService.java
View file @
a03528a4
...
...
@@ -436,6 +436,12 @@ public interface MarkDataService {
PageVO
<
JSONObject
>
getNonManualProjectPlanList
();
/**
* 获取方案列表
* @return
*/
List
<
JSONObject
>
getNonManualPlanList
();
/**
* 获取方案设置-方案列表-昨日,今日数据消耗量
* @return
*/
...
...
@@ -511,4 +517,121 @@ public interface MarkDataService {
* @return
*/
List
<
JSONObject
>
getNonManualMarkCountList
();
/**
* 计算近一年舆情总量项目日均
* @param projectId
* @param planId
* @return
* @throws IOException
*/
void
countYuqingAmountAvg
(
Long
startTime
,
Long
endTime
,
String
projectId
,
String
planId
)
throws
IOException
;
/**
* 计算近一年情感分布均值
* @param projectId
* @param planId
* @throws IOException
*/
void
countEmotionDistributionAvg
(
Long
startTime
,
Long
endTime
,
String
projectId
,
String
planId
)
throws
IOException
;
/**
* 计算项目近一年重点平台均值
* @param projectId
* @param planId
* @throws IOException
*/
void
countImportantPlatformPercentageAvg
(
Long
startTime
,
Long
endTime
,
String
projectId
,
String
planId
)
throws
IOException
;
/**
* 新-舆情分析-舆情总量
* @param startTime
* @param endTime
* @param planId
* @return
* @throws IOException
*/
JSONObject
getYuqingAmount
(
Long
startTime
,
Long
endTime
,
String
planId
);
/**
* 新-舆情分析-情感分布
* @param startTime
* @param endTime
* @param planId
* @return
* @throws IOException
*/
JSONObject
getYuqingEmotionDistribution
(
Long
startTime
,
Long
endTime
,
String
planId
);
/**
* 新-舆情分析-重点平台
* @param startTime
* @param endTime
* @param planId
* @return
*/
JSONObject
getImportantPlatformPercentage
(
Long
startTime
,
Long
endTime
,
String
planId
);
/**
* 新-舆情分析-平台占比
* @param startTime
* @param endTime
* @param planId
* @return
*/
List
<
JSONObject
>
getPlatformPercentage
(
Long
startTime
,
Long
endTime
,
String
planId
);
/**
* 新-舆情分析-舆情走势图
* @param startTime
* @param endTime
* @param planId
* @return
*/
JSONObject
getSpreadTendency
(
Long
startTime
,
Long
endTime
,
String
planId
);
/**
* 新-舆情分析-活跃渠道
* @param startTime
* @param endTime
* @param planId
* @return
*/
List
<
JSONObject
>
getActiveChannels
(
Long
startTime
,
Long
endTime
,
String
planId
);
/**
* 新-舆情分析-ip分布
* @param startTime
* @param endTime
* @param planId
* @return
*/
List
<
JSONObject
>
getArticleIpLocated
(
Long
startTime
,
Long
endTime
,
String
planId
,
int
size
);
/**
* 新-舆情分析-活跃渠道、ip分布、词云详情页面
* @param dto
* @return
*/
PageVO
<
MarkFlowEntity
>
getYuqingAnalyzeDetail
(
MarkSearchDTO
dto
);
/**
* 新-舆情分析-词云
* @param startTime
* @param endTime
* @param planId
* @return
*/
List
<
JSONObject
>
getHighWord
(
Long
startTime
,
Long
endTime
,
String
planId
,
boolean
cache
);
/**
* 新-舆情分析-高频标题
* @param startTime
* @param endTime
* @param planId
* @param size
* @param include
* @return
*/
List
<
JSONObject
>
getLastNews
(
Long
startTime
,
Long
endTime
,
String
planId
,
int
size
,
boolean
include
);
}
src/main/java/com/zhiwei/brandkbs2/service/TaskService.java
View file @
a03528a4
...
...
@@ -42,4 +42,14 @@ public interface TaskService{
* 事件相关更新
*/
void
eventUpdate
();
/**
* 计算项目舆情总量、情感分布、重点平台均值
*/
void
calculateProjectAvg
();
/**
* 生成舆情分析词云缓存
*/
void
yuqingAnalyzeHighWordCache
();
}
src/main/java/com/zhiwei/brandkbs2/service/impl/EsSearchServiceImpl.java
View file @
a03528a4
...
...
@@ -131,6 +131,14 @@ public class EsSearchServiceImpl implements EsSearchService {
if
(
StringUtils
.
isNotEmpty
(
dto
.
getHostKeyword
()))
{
postFilter
.
must
(
EsQueryTools
.
assembleFiledKeywordQuery
(
"host"
,
dto
.
getHostKeyword
()));
}
// ip
if
(
StringUtils
.
isNotEmpty
(
dto
.
getIp
())){
postFilter
.
must
(
EsQueryTools
.
assembleIpQuery
(
dto
.
getIp
()));
}
// mgid限制 舆情分析页面滚动翻页用
if
(
Objects
.
nonNull
(
dto
.
getPageGid
())){
postFilter
.
must
(
QueryBuilders
.
rangeQuery
(
GenericAttribute
.
ES_MGID
).
lt
(
dto
.
getPageGid
()));
}
helper
.
setPostFilter
(
postFilter
);
// helper.setQuery(query);
// sort
...
...
@@ -315,6 +323,14 @@ public class EsSearchServiceImpl implements EsSearchService {
if
(
Objects
.
nonNull
(
dto
.
getDataType
())){
postFilter
.
must
(
EsQueryTools
.
assembleC2Query
(
dto
.
getDataType
()));
}
// ip
if
(
StringUtils
.
isNotEmpty
(
dto
.
getIp
())){
postFilter
.
must
(
EsQueryTools
.
assembleIpQuery
(
dto
.
getIp
()));
}
// mgid限制 舆情分析页面滚动翻页用
if
(
Objects
.
nonNull
(
dto
.
getPageGid
())){
postFilter
.
must
(
QueryBuilders
.
rangeQuery
(
GenericAttribute
.
ES_MGID
).
lt
(
dto
.
getPageGid
()));
}
helper
.
setPostFilter
(
postFilter
);
// sort
FieldSortBuilder
sort
=
null
;
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkDataServiceImpl.java
View file @
a03528a4
This diff is collapsed.
Click to expand it.
src/main/java/com/zhiwei/brandkbs2/service/impl/TaskServiceImpl.java
View file @
a03528a4
...
...
@@ -3,14 +3,13 @@ package com.zhiwei.brandkbs2.service.impl;
import
com.zhiwei.brandkbs2.auth.UserThreadLocal
;
import
com.zhiwei.brandkbs2.common.GlobalPojo
;
import
com.zhiwei.brandkbs2.config.Constant
;
import
com.zhiwei.brandkbs2.dao.AggreeResultDao
;
import
com.zhiwei.brandkbs2.dao.BrandkbsTaskDao
;
import
com.zhiwei.brandkbs2.dao.ChannelDao
;
import
com.zhiwei.brandkbs2.dao.ReportSettingsDao
;
import
com.zhiwei.brandkbs2.dao.*
;
import
com.zhiwei.brandkbs2.enmus.ReportTypeEnum
;
import
com.zhiwei.brandkbs2.es.ChannelEsDao
;
import
com.zhiwei.brandkbs2.es.EsClientDao
;
import
com.zhiwei.brandkbs2.exception.ExceptionCast
;
import
com.zhiwei.brandkbs2.listener.ApplicationProjectListener
;
import
com.zhiwei.brandkbs2.model.CommonCodeEnum
;
import
com.zhiwei.brandkbs2.pojo.*
;
import
com.zhiwei.brandkbs2.service.*
;
import
com.zhiwei.brandkbs2.util.Tools
;
...
...
@@ -19,6 +18,8 @@ import org.apache.commons.lang3.tuple.Pair;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.elasticsearch.ElasticsearchStatusException
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
;
import
org.springframework.stereotype.Service
;
...
...
@@ -28,6 +29,7 @@ import java.util.concurrent.CompletableFuture;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ThreadPoolExecutor
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.concurrent.atomic.AtomicLong
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -61,6 +63,9 @@ public class TaskServiceImpl implements TaskService {
@Resource
(
name
=
"aggreeResultDaoImpl"
)
AggreeResultDao
aggreeResultDao
;
@Resource
(
name
=
"nonManualProjectPlanDao"
)
NonManualProjectPlanDao
nonManualProjectPlanDao
;
@Resource
(
name
=
"brandkbsTaskServiceImpl"
)
BrandkbsTaskService
brandkbsTaskService
;
...
...
@@ -82,6 +87,9 @@ public class TaskServiceImpl implements TaskService {
@Resource
(
name
=
"customEventServiceImpl"
)
CustomEventService
customEventService
;
@Resource
(
name
=
"markDataServiceImpl"
)
MarkDataService
markDataService
;
@Resource
(
name
=
"taskServiceExecutor"
)
ThreadPoolTaskExecutor
taskServiceExecutor
;
...
...
@@ -324,6 +332,56 @@ public class TaskServiceImpl implements TaskService {
}
}
@Override
public
void
calculateProjectAvg
()
{
AtomicLong
total
=
new
AtomicLong
();
GlobalPojo
.
PROJECT_MAP
.
forEach
((
projectId
,
project
)
->{
try
{
// 取近一年
long
endTime
=
System
.
currentTimeMillis
();
long
startTime
=
endTime
-
Constant
.
ONE_YEAR
;
// 项目创建时间在近一年内则取项目创建时间
startTime
=
project
.
getCTime
()
>
startTime
?
project
.
getCTime
()
:
startTime
;
// 同时计算非人工项目各方案均值
if
(!
project
.
isManual
())
{
List
<
NonManualProjectPlan
>
plans
=
nonManualProjectPlanDao
.
findList
(
new
Query
(
Criteria
.
where
(
"projectId"
).
is
(
projectId
)));
for
(
NonManualProjectPlan
plan
:
plans
)
{
markDataService
.
countYuqingAmountAvg
(
startTime
,
endTime
,
projectId
,
plan
.
getId
());
markDataService
.
countEmotionDistributionAvg
(
startTime
,
endTime
,
projectId
,
plan
.
getId
());
markDataService
.
countImportantPlatformPercentageAvg
(
startTime
,
endTime
,
projectId
,
plan
.
getId
());
}
}
markDataService
.
countYuqingAmountAvg
(
startTime
,
endTime
,
projectId
,
null
);
markDataService
.
countEmotionDistributionAvg
(
startTime
,
endTime
,
projectId
,
null
);
markDataService
.
countImportantPlatformPercentageAvg
(
startTime
,
endTime
,
projectId
,
null
);
log
.
info
(
"项目:{}-均值计算已完成:{}个"
,
project
.
getProjectName
(),
total
.
incrementAndGet
());
}
catch
(
Exception
e
){
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"calculateProjectAvg异常-projectId:"
+
projectId
,
e
);
}
});
}
@Override
public
void
yuqingAnalyzeHighWordCache
()
{
AtomicInteger
total
=
new
AtomicInteger
();
Long
[]
time
=
commonService
.
getTimeRangeMonth
();
List
<
CompletableFuture
<
Object
>>
projectFutures
=
GlobalPojo
.
PROJECT_MAP
.
values
().
stream
().
map
(
project
->
CompletableFuture
.
supplyAsync
(()
->
{
UserThreadLocal
.
set
(
new
UserInfo
().
setProjectId
(
project
.
getId
()));
markDataService
.
getHighWord
(
time
[
0
],
time
[
1
],
null
,
false
);
log
.
info
(
"项目:{}-{}-词云缓存已完成:{}个"
,
project
.
getProjectName
(),
project
.
getId
(),
total
.
incrementAndGet
());
return
null
;
},
cacheServiceExecutor
)).
collect
(
Collectors
.
toList
());
AtomicInteger
total2
=
new
AtomicInteger
();
List
<
CompletableFuture
<
Object
>>
planFutures
=
nonManualProjectPlanDao
.
findList
(
new
Query
()).
stream
().
map
(
plan
->
CompletableFuture
.
supplyAsync
(()
->
{
UserThreadLocal
.
set
(
new
UserInfo
().
setProjectId
(
plan
.
getProjectId
()));
markDataService
.
getHighWord
(
time
[
0
],
time
[
1
],
plan
.
getId
(),
false
);
log
.
info
(
"方案:{}-{}-词云缓存已完成:{}个"
,
plan
.
getName
(),
plan
.
getId
(),
total2
.
incrementAndGet
());
return
null
;
},
cacheServiceExecutor
)).
collect
(
Collectors
.
toList
());
projectFutures
.
addAll
(
planFutures
);
CompletableFuture
.
allOf
(
projectFutures
.
toArray
(
new
CompletableFuture
[
0
])).
join
();
}
private
boolean
reportSendByProject
(
Project
project
)
{
boolean
flag
=
false
;
// 扫描setting信息并生成对应报告
...
...
src/main/java/com/zhiwei/brandkbs2/task/ControlCenter.java
View file @
a03528a4
...
...
@@ -45,6 +45,7 @@ public class ControlCenter {
try
{
taskService
.
messageFlowCache
();
taskService
.
customEventCache
();
taskService
.
yuqingAnalyzeHighWordCache
();
}
catch
(
Exception
e
)
{
log
.
error
(
"定时按天缓存数据-出错"
,
e
);
}
finally
{
...
...
@@ -91,4 +92,16 @@ public class ControlCenter {
}
}
@Async
(
"scheduledExecutor"
)
@Scheduled
(
cron
=
"0 0 3 ? * SUN"
)
public
void
calculateProjectAvg
()
{
log
.
info
(
"定时每周计算项目均值-启动"
);
try
{
taskService
.
calculateProjectAvg
();
}
catch
(
Exception
e
)
{
log
.
error
(
"定时按周计算项目均值-出错"
,
e
);
}
finally
{
log
.
info
(
"定时按周计算项目均值-结束"
);
}
}
}
src/main/java/com/zhiwei/brandkbs2/util/RedisUtil.java
View file @
a03528a4
...
...
@@ -7,6 +7,7 @@ import org.springframework.data.redis.core.StringRedisTemplate;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Set
;
import
java.util.concurrent.TimeUnit
;
...
...
@@ -82,6 +83,34 @@ public class RedisUtil {
return
RedisKeyPrefix
.
NON_MANUAL_PROJECT_MARK_MAX_GID
+
Tools
.
concat
(
projectId
,
planId
,
userId
);
}
public
static
String
getYuqingAnalyzeProjectAvgCountKey
(
String
projectId
,
String
contendId
,
String
planId
){
if
(
Objects
.
isNull
(
planId
)){
return
RedisKeyPrefix
.
YUQING_ANALYZE_PROJECT_AVG_COUNT
+
Tools
.
concat
(
projectId
,
contendId
);
}
return
RedisKeyPrefix
.
YUQING_ANALYZE_PROJECT_AVG_COUNT
+
Tools
.
concat
(
projectId
,
contendId
,
planId
);
}
public
static
String
getYuqingAnalyzeEmotionDistributionAvgKey
(
String
projectId
,
String
contendId
,
String
emotion
,
String
planId
){
if
(
Objects
.
isNull
(
planId
)){
return
RedisKeyPrefix
.
YUQING_ANALYZE_EMOTION_DISTRIBUTION_AVG
+
Tools
.
concat
(
projectId
,
contendId
,
emotion
);
}
return
RedisKeyPrefix
.
YUQING_ANALYZE_EMOTION_DISTRIBUTION_AVG
+
Tools
.
concat
(
projectId
,
contendId
,
emotion
,
planId
);
}
public
static
String
getYuqingAnalyzePlatformAvgCountKey
(
String
projectId
,
String
contendId
,
String
planId
){
if
(
Objects
.
isNull
(
planId
)){
return
RedisKeyPrefix
.
YUQING_ANALYZE_PLATFORM_AVG_COUNT
+
Tools
.
concat
(
projectId
,
contendId
);
}
return
RedisKeyPrefix
.
YUQING_ANALYZE_PLATFORM_AVG_COUNT
+
Tools
.
concat
(
projectId
,
contendId
,
planId
);
}
public
static
String
getYuqingAnalyzeHighWordKey
(
String
projectId
,
String
contendId
,
String
planId
,
Long
startTime
,
Long
endTime
){
if
(
Objects
.
isNull
(
planId
)){
return
RedisKeyPrefix
.
YUQING_ANALYZE_HIGH_WORD
+
Tools
.
concat
(
projectId
,
contendId
,
startTime
,
endTime
);
}
return
RedisKeyPrefix
.
YUQING_ANALYZE_HIGH_WORD
+
Tools
.
concat
(
projectId
,
contendId
,
planId
,
startTime
,
endTime
);
}
public
void
setExpire
(
String
key
,
String
value
,
long
timeout
,
TimeUnit
unit
)
{
stringRedisTemplate
.
opsForValue
().
set
(
key
,
value
,
timeout
,
unit
);
}
...
...
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