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
6fe16ea2
Commit
6fe16ea2
authored
Apr 19, 2024
by
shenjunjie
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature' into 'dev'
Feature See merge request
!488
parents
c60988a4
65dc384b
Hide whitespace changes
Inline
Side-by-side
Showing
42 changed files
with
1038 additions
and
716 deletions
+1038
-716
pom.xml
+13
-2
src/main/java/com/zhiwei/brandkbs2/common/GlobalPojo.java
+9
-6
src/main/java/com/zhiwei/brandkbs2/common/RedisKeyPrefix.java
+1
-0
src/main/java/com/zhiwei/brandkbs2/controller/InterfaceController.java
+0
-9
src/main/java/com/zhiwei/brandkbs2/controller/app/AppArticleController.java
+46
-73
src/main/java/com/zhiwei/brandkbs2/controller/app/AppDownloadController.java
+15
-8
src/main/java/com/zhiwei/brandkbs2/controller/app/AppEventController.java
+44
-0
src/main/java/com/zhiwei/brandkbs2/controller/app/AppIndexController.java
+10
-0
src/main/java/com/zhiwei/brandkbs2/dao/BytedanceCustomChannelLevelInfoDao.java
+12
-0
src/main/java/com/zhiwei/brandkbs2/dao/MarkSearchAnalyzeTaskDao.java
+7
-0
src/main/java/com/zhiwei/brandkbs2/dao/impl/BytedanceCustomChannelLevelInfoDaoImpl.java
+14
-0
src/main/java/com/zhiwei/brandkbs2/dao/impl/MarkSearchAnalyzeTaskDaoImpl.java
+14
-0
src/main/java/com/zhiwei/brandkbs2/easyexcel/dto/ExportBytedanceEventComputeResultDTO.java
+5
-3
src/main/java/com/zhiwei/brandkbs2/easyexcel/dto/UploadBytedanceEventDTO.java
+33
-13
src/main/java/com/zhiwei/brandkbs2/easyexcel/listener/BytedanceEventListener.java
+9
-12
src/main/java/com/zhiwei/brandkbs2/es/EsQueryTools.java
+8
-8
src/main/java/com/zhiwei/brandkbs2/exception/ExceptionCatch.java
+1
-1
src/main/java/com/zhiwei/brandkbs2/pojo/BytedanceCustomChannel.java
+1
-0
src/main/java/com/zhiwei/brandkbs2/pojo/BytedanceCustomChannelInfluence.java
+5
-0
src/main/java/com/zhiwei/brandkbs2/pojo/BytedanceCustomChannelLevelInfo.java
+39
-0
src/main/java/com/zhiwei/brandkbs2/pojo/BytedanceCustomEventUpdateTask.java
+6
-12
src/main/java/com/zhiwei/brandkbs2/pojo/BytedanceCustomEventUpdateTaskData.java
+8
-8
src/main/java/com/zhiwei/brandkbs2/pojo/MarkSearchAnalyzeTask.java
+37
-0
src/main/java/com/zhiwei/brandkbs2/pojo/dto/MarkSearchDTO.java
+5
-0
src/main/java/com/zhiwei/brandkbs2/pojo/external/BrandkbsYuQingConfigNew.java
+10
-0
src/main/java/com/zhiwei/brandkbs2/service/IndexService.java
+8
-0
src/main/java/com/zhiwei/brandkbs2/service/MarkDataService.java
+38
-41
src/main/java/com/zhiwei/brandkbs2/service/ProjectWarnService.java
+0
-8
src/main/java/com/zhiwei/brandkbs2/service/SystemInfoService.java
+7
-0
src/main/java/com/zhiwei/brandkbs2/service/impl/ChannelServiceImpl.java
+64
-63
src/main/java/com/zhiwei/brandkbs2/service/impl/EventServiceImpl.java
+1
-1
src/main/java/com/zhiwei/brandkbs2/service/impl/IndexServiceImpl.java
+52
-0
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkDataServiceImpl.java
+301
-134
src/main/java/com/zhiwei/brandkbs2/service/impl/ProjectWarnServiceImpl.java
+9
-143
src/main/java/com/zhiwei/brandkbs2/service/impl/SystemInfoServiceImpl.java
+13
-8
src/main/java/com/zhiwei/brandkbs2/service/impl/TaskServiceImpl.java
+4
-2
src/main/java/com/zhiwei/brandkbs2/service/impl/ToolsetServiceImpl.java
+149
-154
src/main/java/com/zhiwei/brandkbs2/util/RedisUtil.java
+4
-0
src/main/java/com/zhiwei/brandkbs2/util/Tools.java
+30
-1
src/main/resources/application-dev.properties
+2
-2
src/main/resources/application-local.properties
+2
-2
src/main/resources/application-prod.properties
+2
-2
No files found.
pom.xml
View file @
6fe16ea2
...
...
@@ -27,7 +27,7 @@
<qbjc.bean.version>
1.1.7.1-SNAPSHOT
</qbjc.bean.version>
<springfox.version>
2.9.2
</springfox.version>
<fastjson.version>
1.2.47
</fastjson.version>
<easyexcel.version>
3.
0.5
</easyexcel.version>
<easyexcel.version>
3.
3.4
</easyexcel.version>
<marker.client.version>
1.1.9-SNAPSHOT
</marker.client.version>
<base-objects.version>
2.1.6.1-SNAPSHOT
</base-objects.version>
<es.version>
7.9.2
</es.version>
...
...
@@ -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.9.
8
-SNAPSHOT
</event-client.version>
<event-client.version>
1.0.9.
9
-SNAPSHOT
</event-client.version>
<cleaner-unified-filter.version>
1.1.5-SNAPSHOT
</cleaner-unified-filter.version>
</properties>
...
...
@@ -187,6 +187,17 @@
<groupId>
com.alibaba
</groupId>
<artifactId>
easyexcel
</artifactId>
<version>
${easyexcel.version}
</version>
<exclusions>
<exclusion>
<groupId>
net.sf.ehcache
</groupId>
<artifactId>
ehcache
</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>
org.ehcache
</groupId>
<artifactId>
ehcache
</artifactId>
<version>
3.7.1
</version>
</dependency>
<!-- lombok -->
<dependency>
...
...
src/main/java/com/zhiwei/brandkbs2/common/GlobalPojo.java
View file @
6fe16ea2
...
...
@@ -2,10 +2,7 @@ package com.zhiwei.brandkbs2.common;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.zhiwei.brandkbs2.pojo.ChannelTag
;
import
com.zhiwei.brandkbs2.pojo.HighlightWord
;
import
com.zhiwei.brandkbs2.pojo.Project
;
import
com.zhiwei.brandkbs2.pojo.SensitiveChannel
;
import
com.zhiwei.brandkbs2.pojo.*
;
import
com.zhiwei.brandkbs2.service.ChannelService
;
import
com.zhiwei.brandkbs2.service.SystemInfoService
;
import
com.zhiwei.brandkbs2.util.Tools
;
...
...
@@ -103,6 +100,11 @@ public class GlobalPojo {
*/
public
static
Map
<
String
,
SensitiveChannel
>
COMMON_SENSITIVE_CHANNEL
=
new
HashMap
<>();
/**
* 字节定制指定渠道影响力信息
*/
public
static
Map
<
String
,
BytedanceCustomChannelInfluence
>
BYTEDANCE_CHANNEL_INFLUENCE
=
new
HashMap
<>();
@PostConstruct
public
void
start
()
{
try
{
...
...
@@ -139,9 +141,10 @@ public class GlobalPojo {
PROJECT_EMOTION_CHANNEL_DATA
=
channelService
.
getProjectEmotionChannelListData
();
PROJECT_SENSITIVE_CHANNEL
=
systemInfoService
.
getProjectSensitiveChannel
();
COMMON_SENSITIVE_CHANNEL
=
systemInfoService
.
getCommonSensitiveChannel
();
BYTEDANCE_CHANNEL_INFLUENCE
=
systemInfoService
.
getByteDanceChannelInfluence
();
updateHighlightGraphs
();
log
.
info
(
"{}-获取PLATFORMS-size:{},TAGS-size:{},LINKED_GROUP_ID_TAGS:{},CHANNEL_TAGS:{},MEDIA_TYPE:{},PROJECT_MAP:{},YUQING-PROJECTS-size:{},PROJECT_EMOTION_CHANNEL_DATA-size:{},PROJECT_SENSITIVE_CHANNEL-size:{}, COMMON_SENSITIVE_CHANNEL-size:{}"
,
logMsg
,
PLATFORMS
.
size
(),
TAGS
.
size
(),
LINKED_GROUP_ID_TAGS
.
size
(),
CHANNEL_TAGS
.
size
(),
MEDIA_TYPE
.
size
(),
PROJECT_MAP
.
size
(),
YU_QING_PROJECTS
.
size
(),
PROJECT_EMOTION_CHANNEL_DATA
.
size
(),
PROJECT_SENSITIVE_CHANNEL
.
size
(),
COMMON_SENSITIVE_CHANNEL
.
size
());
log
.
info
(
"{}-获取PLATFORMS-size:{},TAGS-size:{},LINKED_GROUP_ID_TAGS:{},CHANNEL_TAGS:{},MEDIA_TYPE:{},PROJECT_MAP:{},YUQING-PROJECTS-size:{},PROJECT_EMOTION_CHANNEL_DATA-size:{},PROJECT_SENSITIVE_CHANNEL-size:{}, COMMON_SENSITIVE_CHANNEL-size:{}
,BYTEDANCE_CHANNEL_INFLUENCE-size:{}
"
,
logMsg
,
PLATFORMS
.
size
(),
TAGS
.
size
(),
LINKED_GROUP_ID_TAGS
.
size
(),
CHANNEL_TAGS
.
size
(),
MEDIA_TYPE
.
size
(),
PROJECT_MAP
.
size
(),
YU_QING_PROJECTS
.
size
(),
PROJECT_EMOTION_CHANNEL_DATA
.
size
(),
PROJECT_SENSITIVE_CHANNEL
.
size
(),
COMMON_SENSITIVE_CHANNEL
.
size
()
,
BYTEDANCE_CHANNEL_INFLUENCE
.
size
()
);
}
catch
(
Exception
e
)
{
log
.
info
(
"{}-获取缓存值异常"
,
logMsg
,
e
);
}
...
...
src/main/java/com/zhiwei/brandkbs2/common/RedisKeyPrefix.java
View file @
6fe16ea2
...
...
@@ -27,6 +27,7 @@ public class RedisKeyPrefix {
public
static
final
String
INDEX_PLATFORM
=
"BRANDKBS:INDEX:PLATFORM:"
;
public
static
final
String
INDEX_SPREAD
=
"BRANDKBS:INDEX:SPREAD:"
;
public
static
final
String
INDEX_COMPARE_SUMMARY_MOBILE
=
"BRANDKBS:INDEX:COMPARE_SUMMARY:MOBILE:"
;
public
static
final
String
INDEX_EMOTION
=
"BRANDKBS:INDEX:EMOTION:"
;
/**
* 渠道榜单缓存
*/
...
...
src/main/java/com/zhiwei/brandkbs2/controller/InterfaceController.java
View file @
6fe16ea2
...
...
@@ -55,17 +55,8 @@ public class InterfaceController {
@ApiOperation
(
"获取舆情动态-预警结果"
)
@PostMapping
(
"/warn/yuqing"
)
@Deprecated
public
ResponseResult
getYuqingWaring
(
@RequestBody
JSONObject
json
)
{
String
projectId
=
json
.
getString
(
"projectId"
);
BrandkbsYuQingConfig
config
=
json
.
getObject
(
"config"
,
BrandkbsYuQingConfig
.
class
);
return
projectWarnService
.
getYuqingWaring
(
projectId
,
config
);
}
@ApiOperation
(
"获取舆情动态-预警结果"
)
@PostMapping
(
"/warn/yuqingNew"
)
public
ResponseResult
getYuqingWaringNew
(
@RequestBody
JSONObject
json
)
{
String
projectId
=
json
.
getString
(
"projectId"
);
BrandkbsYuQingConfigNew
config
=
json
.
getObject
(
"config"
,
BrandkbsYuQingConfigNew
.
class
);
return
projectWarnService
.
getYuqingWaringNew
(
projectId
,
config
);
}
...
...
src/main/java/com/zhiwei/brandkbs2/controller/app/AppArticleController.java
View file @
6fe16ea2
...
...
@@ -168,6 +168,7 @@ public class AppArticleController extends BaseController {
@ApiOperation
(
"舆情分析-舆情概览"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"startTime"
,
value
=
"开始时间"
,
paramType
=
"query"
,
dataType
=
"long"
),
@ApiImplicitParam
(
name
=
"endTime"
,
value
=
"结束时间"
,
paramType
=
"query"
,
dataType
=
"long"
)})
@GetMapping
(
"/analyze/summary"
)
@Deprecated
public
ResponseResult
getAnalyzeSummary
(
@RequestParam
(
value
=
"startTime"
,
required
=
false
)
Long
startTime
,
@RequestParam
(
value
=
"endTime"
,
required
=
false
)
Long
endTime
)
{
return
ResponseResult
.
success
(
markDataService
.
getAnalyzeSummary
(
startTime
,
endTime
,
true
));
}
...
...
@@ -447,77 +448,58 @@ public class AppArticleController extends BaseController {
}
@ApiOperation
(
"新-舆情分析-舆情总量"
)
@
Ge
tMapping
(
"/analyze/amount"
)
@
Pos
tMapping
(
"/analyze/amount"
)
@LogRecord
(
description
=
"舆情库-舆情分析"
)
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
));
public
ResponseResult
getYuqingAmount
(
@RequestBody
MarkSearchDTO
markSearchDTO
)
{
return
ResponseResult
.
success
(
markDataService
.
getYuqingAmount
(
markSearchDTO
));
}
@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
));
@PostMapping
(
"/analyze/emotion"
)
public
ResponseResult
getYuqingEmotionDistribution
(
@RequestBody
MarkSearchDTO
markSearchDTO
)
{
return
ResponseResult
.
success
(
markDataService
.
getYuqingEmotionDistribution
(
markSearchDTO
));
}
@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
));
@PostMapping
(
"/analyze/important-platform"
)
public
ResponseResult
getImportantPlatformPercentage
(
@RequestBody
MarkSearchDTO
markSearchDTO
)
{
return
ResponseResult
.
success
(
markDataService
.
getImportantPlatformPercentage
(
markSearchDTO
));
}
@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
));
@PostMapping
(
"/analyze/platform-percent"
)
public
ResponseResult
getPlatformPercentage
(
@RequestBody
MarkSearchDTO
markSearchDTO
)
{
return
ResponseResult
.
success
(
markDataService
.
geAnalyzePlatformPercentage
(
markSearchDTO
));
}
@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
));
@PostMapping
(
"/analyze/tendency"
)
public
ResponseResult
getSpreadTendency
(
@RequestBody
MarkSearchDTO
markSearchDTO
)
{
return
ResponseResult
.
success
(
markDataService
.
getSpreadTendency
(
markSearchDTO
));
}
@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
));
@PostMapping
(
"/analyze/active-channel"
)
public
ResponseResult
getActiveChannels
(
@RequestBody
MarkSearchDTO
markSearchDTO
)
{
return
ResponseResult
.
success
(
markDataService
.
getActiveChannels
(
markSearchDTO
));
}
@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
));
@PostMapping
(
"/analyze/ip-located"
)
public
ResponseResult
getArticleIpLocated
(
@RequestBody
MarkSearchDTO
markSearchDTO
)
{
return
ResponseResult
.
success
(
markDataService
.
getArticleIpLocated
(
markSearchDTO
));
}
@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
));
@PostMapping
(
"/analyze/high-word"
)
public
ResponseResult
getHighWord
(
@RequestBody
MarkSearchDTO
markSearchDTO
)
{
return
ResponseResult
.
success
(
markDataService
.
getAnalyzeHighWord
(
markSearchDTO
,
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
));
@PostMapping
(
"/analyze/frequent-title"
)
public
ResponseResult
getLastNews
(
@RequestBody
MarkSearchDTO
markSearchDTO
)
{
return
ResponseResult
.
success
(
markDataService
.
getLastNews
(
markSearchDTO
,
5
));
}
@ApiOperation
(
"新-舆情分析-活跃渠道、ip分布、词云详情页面,社媒平台发文"
)
...
...
@@ -527,42 +509,33 @@ public class AppArticleController extends BaseController {
}
@ApiOperation
(
"新-舆情分析-高频标题-基础信息"
)
@GetMapping
(
"/analyze/frequent-title/info"
)
public
ResponseResult
getAggTitleBaseInfo
(
@RequestParam
(
value
=
"startTime"
)
Long
startTime
,
@RequestParam
(
value
=
"endTime"
)
Long
endTime
,
@RequestParam
(
value
=
"aggTitle"
)
String
aggTitle
,
@RequestParam
(
value
=
"planId"
,
required
=
false
)
String
planId
)
{
return
ResponseResult
.
success
(
markDataService
.
getAggTitleBaseInfo
(
aggTitle
,
startTime
,
endTime
,
planId
));
@PostMapping
(
"/analyze/frequent-title/info"
)
public
ResponseResult
getAggTitleBaseInfo
(
@RequestBody
MarkSearchDTO
markSearchDTO
)
{
return
ResponseResult
.
success
(
markDataService
.
getAggTitleBaseInfo
(
markSearchDTO
));
}
@ApiOperation
(
"新-舆情分析-高频标题-发布节点"
)
@GetMapping
(
"/analyze/frequent-title/article-point"
)
public
ResponseResult
getArticlePoints
(
@RequestParam
(
value
=
"startTime"
)
Long
startTime
,
@RequestParam
(
value
=
"endTime"
)
Long
endTime
,
@RequestParam
(
value
=
"aggTitle"
)
String
aggTitle
,
@RequestParam
(
value
=
"planId"
,
required
=
false
)
String
planId
)
{
return
ResponseResult
.
success
(
markDataService
.
getAggTitleArticlePoints
(
aggTitle
,
startTime
,
endTime
,
planId
));
@PostMapping
(
"/analyze/frequent-title/article-point"
)
public
ResponseResult
getArticlePoints
(
@RequestBody
MarkSearchDTO
markSearchDTO
)
{
return
ResponseResult
.
success
(
markDataService
.
getAggTitleArticlePoints
(
markSearchDTO
));
}
@ApiOperation
(
"新-舆情分析-高频标题-平台分布"
)
@GetMapping
(
"/analyze/frequent-title/platform-percent"
)
public
ResponseResult
getAggTitlePlatformPercentage
(
@RequestParam
(
value
=
"startTime"
)
Long
startTime
,
@RequestParam
(
value
=
"endTime"
)
Long
endTime
,
@RequestParam
(
value
=
"aggTitle"
)
String
aggTitle
,
@RequestParam
(
value
=
"planId"
,
required
=
false
)
String
planId
)
{
return
ResponseResult
.
success
(
markDataService
.
getAggTitlePlatformPercentage
(
aggTitle
,
startTime
,
endTime
,
planId
));
@PostMapping
(
"/analyze/frequent-title/platform-percent"
)
public
ResponseResult
getAggTitlePlatformPercentage
(
@RequestBody
MarkSearchDTO
markSearchDTO
)
{
return
ResponseResult
.
success
(
markDataService
.
getAggTitlePlatformPercentage
(
markSearchDTO
));
}
@ApiOperation
(
"新-舆情分析-高频标题-发文列表"
)
@
Ge
tMapping
(
"/analyze/frequent-title/articles"
)
public
ResponseResult
getArticleList
(
@Request
Param
(
value
=
"startTime"
)
Long
startTime
,
@RequestParam
(
value
=
"endTime"
)
Long
endTime
,
@RequestParam
(
value
=
"aggTitle"
)
String
aggTitle
,
@RequestParam
(
value
=
"platform"
)
String
platform
,
@RequestParam
(
value
=
"planId"
,
required
=
false
)
String
planId
,
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"10"
)
Integer
pageSize
)
{
return
ResponseResult
.
success
(
markDataService
.
get
ArticleList
(
aggTitle
,
startTime
,
endTime
,
planId
,
platform
,
page
,
pageSize
));
@
Pos
tMapping
(
"/analyze/frequent-title/articles"
)
public
ResponseResult
getArticleList
(
@Request
Body
MarkSearchDTO
markSearchDTO
)
{
return
ResponseResult
.
success
(
markDataService
.
getArticleList
(
markSearchDTO
));
}
@ApiOperation
(
"新-(查舆情)舆情分析-词云"
)
@PostMapping
(
"/analyze/search/high-word"
)
public
ResponseResult
generateSearchAnalyzeHighWord
(
@RequestBody
MarkSearchDTO
markSearchDTO
)
{
return
ResponseResult
.
success
(
markDataService
.
get
SearchAnalyzeHighWord
(
markSearchDTO
));
}
private
boolean
checkMTagIllegal
(
StringBuilder
mtag
)
{
...
...
src/main/java/com/zhiwei/brandkbs2/controller/app/AppDownloadController.java
View file @
6fe16ea2
...
...
@@ -519,15 +519,22 @@ public class AppDownloadController extends BaseController {
@DownloadTask
(
taskName
=
"事件影响力更新模板下载"
,
description
=
"事件影响力更新模板"
)
public
ResponseResult
downloadEventUpdateTemplate
(){
List
<
List
<
String
>>
head
=
new
ArrayList
<>();
head
.
add
(
Collections
.
singletonList
(
"序号"
));
head
.
add
(
Collections
.
singletonList
(
"平台类型"
));
head
.
add
(
Collections
.
singletonList
(
"渠道名称"
));
head
.
add
(
Collections
.
singletonList
(
"链接"
));
head
.
add
(
Collections
.
singletonList
(
"事件名"
));
head
.
add
(
Collections
.
singletonList
(
"微博转发"
));
head
.
add
(
Collections
.
singletonList
(
"微博评论"
));
head
.
add
(
Collections
.
singletonList
(
"微博点赞"
));
head
.
add
(
Collections
.
singletonList
(
"微信阅读"
));
head
.
add
(
Collections
.
singletonList
(
"微信在看"
));
head
.
add
(
Collections
.
singletonList
(
"发布平台"
));
head
.
add
(
Collections
.
singletonList
(
"渠道"
));
head
.
add
(
Collections
.
singletonList
(
"时间"
));
head
.
add
(
Collections
.
singletonList
(
"标题"
));
head
.
add
(
Collections
.
singletonList
(
"文本"
));
head
.
add
(
Collections
.
singletonList
(
"地址"
));
head
.
add
(
Collections
.
singletonList
(
"命中词"
));
head
.
add
(
Collections
.
singletonList
(
"情感倾向"
));
head
.
add
(
Collections
.
singletonList
(
"事件标签"
));
head
.
add
(
Collections
.
singletonList
(
"在看"
));
head
.
add
(
Collections
.
singletonList
(
"阅读"
));
head
.
add
(
Collections
.
singletonList
(
"点赞"
));
head
.
add
(
Collections
.
singletonList
(
"评论"
));
head
.
add
(
Collections
.
singletonList
(
"转发"
));
// excel写入至指定路径
String
projectName
=
projectService
.
getProjectById
(
UserThreadLocal
.
getProjectId
()).
getProjectName
();
String
filePath
=
EasyExcelUtil
.
generateExcelFilePath
(
brandkbsFilePath
,
projectName
,
UserThreadLocal
.
getNickname
(),
"事件更新模板"
);
...
...
src/main/java/com/zhiwei/brandkbs2/controller/app/AppEventController.java
View file @
6fe16ea2
...
...
@@ -9,6 +9,7 @@ import com.zhiwei.brandkbs2.enmus.RoleEnum;
import
com.zhiwei.brandkbs2.model.ResponseResult
;
import
com.zhiwei.brandkbs2.pojo.dto.EventSearchDTO
;
import
com.zhiwei.brandkbs2.service.EventService
;
import
com.zhiwei.brandkbs2.service.MarkDataService
;
import
com.zhiwei.middleware.event.pojo.dto.BrandkbsEventSearchDTO
;
import
com.zhiwei.middleware.event.pojo.dto.EventDTO
;
import
io.swagger.annotations.Api
;
...
...
@@ -20,6 +21,7 @@ import org.springframework.http.ResponseEntity;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.client.RestTemplate
;
import
javax.annotation.Resource
;
import
java.util.List
;
/**
...
...
@@ -64,6 +66,9 @@ public class AppEventController extends BaseController {
private
final
EventService
eventService
;
@Resource
(
name
=
"markDataServiceImpl"
)
MarkDataService
markDataService
;
public
AppEventController
(
EventService
eventService
)
{
this
.
eventService
=
eventService
;
}
...
...
@@ -355,4 +360,43 @@ public class AppEventController extends BaseController {
public
ResponseResult
aggTitleAnalyze
(
@RequestBody
EventDTO
dto
){
return
eventService
.
aggTitleAnalyze
(
dto
);
}
@ApiOperation
(
"新-舆情分析-高频标题-基础信息"
)
@GetMapping
(
"/analyze/frequent-title/info"
)
public
ResponseResult
getAggTitleBaseInfo
(
@RequestParam
(
value
=
"startTime"
)
Long
startTime
,
@RequestParam
(
value
=
"endTime"
)
Long
endTime
,
@RequestParam
(
value
=
"aggTitle"
)
String
aggTitle
,
@RequestParam
(
value
=
"planId"
,
required
=
false
)
String
planId
)
{
return
ResponseResult
.
success
(
markDataService
.
getAggTitleBaseInfo
(
aggTitle
,
startTime
,
endTime
,
planId
));
}
@ApiOperation
(
"新-舆情分析-高频标题-发布节点"
)
@GetMapping
(
"/analyze/frequent-title/article-point"
)
public
ResponseResult
getArticlePoints
(
@RequestParam
(
value
=
"startTime"
)
Long
startTime
,
@RequestParam
(
value
=
"endTime"
)
Long
endTime
,
@RequestParam
(
value
=
"aggTitle"
)
String
aggTitle
,
@RequestParam
(
value
=
"planId"
,
required
=
false
)
String
planId
)
{
return
ResponseResult
.
success
(
markDataService
.
getAggTitleArticlePoints
(
aggTitle
,
startTime
,
endTime
,
planId
));
}
@ApiOperation
(
"新-舆情分析-高频标题-平台分布"
)
@GetMapping
(
"/analyze/frequent-title/platform-percent"
)
public
ResponseResult
getAggTitlePlatformPercentage
(
@RequestParam
(
value
=
"startTime"
)
Long
startTime
,
@RequestParam
(
value
=
"endTime"
)
Long
endTime
,
@RequestParam
(
value
=
"aggTitle"
)
String
aggTitle
,
@RequestParam
(
value
=
"planId"
,
required
=
false
)
String
planId
)
{
return
ResponseResult
.
success
(
markDataService
.
getAggTitlePlatformPercentage
(
aggTitle
,
startTime
,
endTime
,
planId
));
}
@ApiOperation
(
"新-舆情分析-高频标题-发文列表"
)
@GetMapping
(
"/analyze/frequent-title/articles"
)
public
ResponseResult
getArticleList
(
@RequestParam
(
value
=
"startTime"
)
Long
startTime
,
@RequestParam
(
value
=
"endTime"
)
Long
endTime
,
@RequestParam
(
value
=
"aggTitle"
)
String
aggTitle
,
@RequestParam
(
value
=
"platform"
)
String
platform
,
@RequestParam
(
value
=
"planId"
,
required
=
false
)
String
planId
,
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"10"
)
Integer
pageSize
)
{
return
ResponseResult
.
success
(
markDataService
.
getArticleList
(
aggTitle
,
startTime
,
endTime
,
planId
,
platform
,
page
,
pageSize
));
}
}
src/main/java/com/zhiwei/brandkbs2/controller/app/AppIndexController.java
View file @
6fe16ea2
...
...
@@ -90,5 +90,15 @@ public class AppIndexController extends BaseController {
return
ResponseResult
.
success
(
indexService
.
getSpreadingTend
(
startTime
,
endTime
,
true
));
}
@ApiOperation
(
"首页-净情感度"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"startTime"
,
value
=
"开始时间"
,
paramType
=
"query"
,
dataType
=
"long"
),
@ApiImplicitParam
(
name
=
"endTime"
,
value
=
"结束时间"
,
paramType
=
"query"
,
dataType
=
"long"
)
})
@GetMapping
(
"/emotion-percent"
)
public
ResponseResult
getEmotionPercent
(
@RequestParam
(
value
=
"startTime"
,
required
=
false
)
Long
startTime
,
@RequestParam
(
value
=
"endTime"
,
required
=
false
)
Long
endTime
)
{
return
ResponseResult
.
success
(
indexService
.
getEmotionPercent
(
startTime
,
endTime
,
true
));
}
}
src/main/java/com/zhiwei/brandkbs2/dao/BytedanceCustomChannelLevelInfoDao.java
0 → 100644
View file @
6fe16ea2
package
com
.
zhiwei
.
brandkbs2
.
dao
;
import
com.zhiwei.brandkbs2.pojo.BytedanceCustomChannelLevelInfo
;
/**
* @ClassName: BytedanceCustomChannelDao
* @Description BytedanceCustomChannelDao
* @author: cjz
* @date: 2023-10-13 15:43
*/
public
interface
BytedanceCustomChannelLevelInfoDao
extends
BaseMongoDao
<
BytedanceCustomChannelLevelInfo
>{
}
src/main/java/com/zhiwei/brandkbs2/dao/MarkSearchAnalyzeTaskDao.java
0 → 100644
View file @
6fe16ea2
package
com
.
zhiwei
.
brandkbs2
.
dao
;
import
com.zhiwei.brandkbs2.pojo.MarkSearchAnalyzeTask
;
public
interface
MarkSearchAnalyzeTaskDao
extends
BaseMongoDao
<
MarkSearchAnalyzeTask
>{
}
src/main/java/com/zhiwei/brandkbs2/dao/impl/BytedanceCustomChannelLevelInfoDaoImpl.java
0 → 100644
View file @
6fe16ea2
package
com
.
zhiwei
.
brandkbs2
.
dao
.
impl
;
import
com.zhiwei.brandkbs2.dao.BytedanceCustomChannelLevelInfoDao
;
import
com.zhiwei.brandkbs2.pojo.BytedanceCustomChannelLevelInfo
;
import
org.springframework.stereotype.Component
;
@Component
(
"bytedanceCustomChannelLevelInfoDao"
)
public
class
BytedanceCustomChannelLevelInfoDaoImpl
extends
BaseMongoDaoImpl
<
BytedanceCustomChannelLevelInfo
>
implements
BytedanceCustomChannelLevelInfoDao
{
private
static
final
String
COLLECTION_NAME
=
"brandkbs_bytedance_custom_channel_level_info"
;
public
BytedanceCustomChannelLevelInfoDaoImpl
()
{
super
(
COLLECTION_NAME
);
}
}
src/main/java/com/zhiwei/brandkbs2/dao/impl/MarkSearchAnalyzeTaskDaoImpl.java
0 → 100644
View file @
6fe16ea2
package
com
.
zhiwei
.
brandkbs2
.
dao
.
impl
;
import
com.zhiwei.brandkbs2.dao.MarkSearchAnalyzeTaskDao
;
import
com.zhiwei.brandkbs2.pojo.MarkSearchAnalyzeTask
;
import
org.springframework.stereotype.Component
;
@Component
(
"markSearchAnalyzeTaskDao"
)
public
class
MarkSearchAnalyzeTaskDaoImpl
extends
BaseMongoDaoImpl
<
MarkSearchAnalyzeTask
>
implements
MarkSearchAnalyzeTaskDao
{
private
static
final
String
COLLECTION_NAME
=
"brandkbs_search_analyze_task"
;
public
MarkSearchAnalyzeTaskDaoImpl
()
{
super
(
COLLECTION_NAME
);
}
}
src/main/java/com/zhiwei/brandkbs2/easyexcel/dto/ExportBytedanceEventComputeResultDTO.java
View file @
6fe16ea2
...
...
@@ -16,13 +16,15 @@ public class ExportBytedanceEventComputeResultDTO {
@ExcelProperty
(
"事件名"
)
private
String
name
;
@ExcelProperty
(
"
影响力指数
"
)
@ExcelProperty
(
"
渠道指标
"
)
private
Double
inf
;
@ExcelProperty
(
"
实时传播力
"
)
@ExcelProperty
(
"
流量指标
"
)
private
Double
RMI
;
@ExcelProperty
(
"
传播
影响力"
)
@ExcelProperty
(
"
综合
影响力"
)
private
Double
finalInf
;
@ExcelProperty
(
"传播量"
)
private
Integer
dataCount
;
}
src/main/java/com/zhiwei/brandkbs2/easyexcel/dto/UploadBytedanceEventDTO.java
View file @
6fe16ea2
...
...
@@ -11,31 +11,51 @@ import lombok.Data;
*/
@Data
public
class
UploadBytedanceEventDTO
{
@ExcelProperty
(
"序号"
)
private
String
number
;
@ExcelProperty
(
"平台类型"
)
private
String
platformType
;
@ExcelProperty
(
"发布平台"
)
private
String
platform
;
@ExcelProperty
(
"渠道
名称
"
)
@ExcelProperty
(
"渠道"
)
private
String
channel
;
@ExcelProperty
(
"链接"
)
@ExcelProperty
(
"时间"
)
private
String
time
;
@ExcelProperty
(
"标题"
)
private
String
title
;
@ExcelProperty
(
"文本"
)
private
String
content
;
@ExcelProperty
(
"地址"
)
private
String
url
;
@ExcelProperty
(
"事件名"
)
@ExcelProperty
(
"命中词"
)
private
String
hitWord
;
@ExcelProperty
(
"情感倾向"
)
private
String
emotion
;
@ExcelProperty
(
"事件标签"
)
private
String
eventName
;
@ExcelProperty
(
"
微博转发
"
)
private
Integer
weiboForward
;
@ExcelProperty
(
"
在看
"
)
private
String
reading
;
@ExcelProperty
(
"
微博评论
"
)
private
Integer
weiboComment
;
@ExcelProperty
(
"
阅读
"
)
private
String
read
;
@ExcelProperty
(
"
微博
点赞"
)
private
Integer
weiboL
ike
;
@ExcelProperty
(
"点赞"
)
private
String
l
ike
;
@ExcelProperty
(
"
微信阅读
"
)
private
Integer
wechatRead
;
@ExcelProperty
(
"
评论
"
)
private
String
comment
;
@ExcelProperty
(
"
微信在看
"
)
private
Integer
wechatReading
;
@ExcelProperty
(
"
转发
"
)
private
String
forward
;
}
src/main/java/com/zhiwei/brandkbs2/easyexcel/listener/BytedanceEventListener.java
View file @
6fe16ea2
...
...
@@ -4,11 +4,8 @@ import com.alibaba.excel.context.AnalysisContext;
import
com.alibaba.excel.event.AnalysisEventListener
;
import
com.zhiwei.brandkbs2.easyexcel.dto.UploadBytedanceEventDTO
;
import
com.zhiwei.brandkbs2.pojo.BytedanceCustomEventUpdateTaskData
;
import
com.zhiwei.brandkbs2.util.Tools
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
/**
...
...
@@ -33,20 +30,20 @@ public class BytedanceEventListener extends AnalysisEventListener<UploadBytedanc
public
void
invoke
(
UploadBytedanceEventDTO
dto
,
AnalysisContext
context
)
{
BytedanceCustomEventUpdateTaskData
taskData
=
new
BytedanceCustomEventUpdateTaskData
();
taskData
.
setTaskId
(
taskId
);
taskData
.
setEventName
(
dto
.
getEventName
());
taskData
.
setChannel
(
dto
.
getChannel
());
taskData
.
setPlatformType
(
dto
.
getPlatformType
());
taskData
.
setPlatform
(
dto
.
getPlatform
());
taskData
.
setUrl
(
dto
.
getUrl
());
taskData
.
setWeiboComment
(
dto
.
getWeiboComment
());
taskData
.
setWeiboForward
(
dto
.
getWeiboForward
());
taskData
.
setWeiboLike
(
dto
.
getWeiboLike
());
taskData
.
setWechatRead
(
dto
.
getWechatRead
());
taskData
.
setWechatReading
(
dto
.
getWechatReading
());
taskData
.
setChannel
(
dto
.
getChannel
());
taskData
.
setEventName
(
dto
.
getEventName
());
// 填 "/" 当作0处理
taskData
.
setReading
(
Objects
.
isNull
(
dto
.
getReading
())
||
Objects
.
equals
(
"/"
,
dto
.
getReading
())
?
0
:
Integer
.
parseInt
(
dto
.
getReading
()));
taskData
.
setRead
(
Objects
.
isNull
(
dto
.
getRead
())
||
Objects
.
equals
(
"/"
,
dto
.
getRead
())
?
0
:
Integer
.
parseInt
(
dto
.
getRead
()));
taskData
.
setLike
(
Objects
.
isNull
(
dto
.
getLike
())
||
Objects
.
equals
(
"/"
,
dto
.
getLike
())
?
0
:
Integer
.
parseInt
(
dto
.
getLike
()));
taskData
.
setComment
(
Objects
.
isNull
(
dto
.
getComment
())
||
Objects
.
equals
(
"/"
,
dto
.
getComment
())
?
0
:
Integer
.
parseInt
(
dto
.
getComment
()));
taskData
.
setForward
(
Objects
.
isNull
(
dto
.
getForward
())
||
Objects
.
equals
(
"/"
,
dto
.
getForward
())
?
0
:
Integer
.
parseInt
(
dto
.
getForward
()));
data
.
add
(
taskData
);
}
@Override
public
void
doAfterAllAnalysed
(
AnalysisContext
context
)
{
}
}
src/main/java/com/zhiwei/brandkbs2/es/EsQueryTools.java
View file @
6fe16ea2
...
...
@@ -417,18 +417,18 @@ public class EsQueryTools {
public
static
void
addSensitiveChannel
(
BrandkbsYuQingConfigNew
config
,
BoolQueryBuilder
boolQueryBuilder
)
{
BoolQueryBuilder
hitBoolQuery
=
QueryBuilders
.
boolQuery
();
if
(!
Tools
.
isEmpty
(
config
.
getPoliticsLevels
()))
{
if
(!
Tools
.
isEmpty
(
config
.
getPoliticsLevels
())
&&
!
config
.
getPoliticsLevels
().
contains
(
"全部"
)
)
{
List
<
String
>
hitList
=
config
.
getPoliticsLevels
();
if
(
config
.
getPoliticsLevels
().
contains
(
"全部"
))
{
hitList
=
ChannelType
.
POLITICS_LEVELS
;
}
//
if (config.getPoliticsLevels().contains("全部")) {
//
hitList = ChannelType.POLITICS_LEVELS;
//
}
hitList
.
forEach
(
politicsLevel
->
hitBoolQuery
.
should
(
QueryBuilders
.
termQuery
(
GenericAttribute
.
ES_SENSITIVE_CHANNEL
+
"."
+
GenericAttribute
.
ES_POLITICS_LEVEL
+
".keyword"
,
politicsLevel
)));
}
if
(!
Tools
.
isEmpty
(
config
.
getFields
()))
{
if
(!
Tools
.
isEmpty
(
config
.
getFields
())
&&
!
config
.
getFields
().
contains
(
"全部"
)
)
{
List
<
String
>
hitList
=
config
.
getFields
();
if
(
config
.
getFields
().
contains
(
"全部"
))
{
hitList
=
ChannelType
.
COMMON_FIELDS
;
}
//
if (config.getFields().contains("全部")) {
//
hitList = ChannelType.COMMON_FIELDS;
//
}
hitList
.
forEach
(
field
->
hitBoolQuery
.
should
(
QueryBuilders
.
termQuery
(
GenericAttribute
.
ES_SENSITIVE_CHANNEL
+
"."
+
GenericAttribute
.
ES_FIELD
+
".keyword"
,
field
)));
}
boolQueryBuilder
.
must
(
hitBoolQuery
);
...
...
src/main/java/com/zhiwei/brandkbs2/exception/ExceptionCatch.java
View file @
6fe16ea2
...
...
@@ -50,7 +50,7 @@ public class ExceptionCatch {
@ExceptionHandler
(
Exception
.
class
)
public
ResponseResult
exception
(
Exception
exception
)
{
//记录日志
log
.
info
(
"catch exception:"
,
exception
);
log
.
error
(
"catch exception:"
,
exception
);
//返回400操作失败
return
new
ResponseResult
(
CommonCodeEnum
.
FAIL
,
Collections
.
EMPTY_LIST
);
}
...
...
src/main/java/com/zhiwei/brandkbs2/pojo/BytedanceCustomChannel.java
View file @
6fe16ea2
...
...
@@ -11,6 +11,7 @@ import lombok.Setter;
*/
@Getter
@Setter
@Deprecated
// 2024.3.22 计算公式调整 弃用
public
class
BytedanceCustomChannel
extends
AbstractBaseMongo
{
/**
...
...
src/main/java/com/zhiwei/brandkbs2/pojo/BytedanceCustomChannelInfluence.java
View file @
6fe16ea2
...
...
@@ -27,4 +27,9 @@ public class BytedanceCustomChannelInfluence extends AbstractBaseMongo{
* 影响力
*/
private
double
influence
;
/**
* 渠道等级
*/
private
String
level
;
}
src/main/java/com/zhiwei/brandkbs2/pojo/BytedanceCustomChannelLevelInfo.java
0 → 100644
View file @
6fe16ea2
package
com
.
zhiwei
.
brandkbs2
.
pojo
;
import
lombok.Getter
;
import
lombok.Setter
;
/**
* @ClassName: BytedanceCustomChannelLevelInfo
* @Description 字节定制渠道等级、拐点、极值、权重对照表
* @author: cjz
* @date: 2024-3-20 14:09
*/
@Getter
@Setter
public
class
BytedanceCustomChannelLevelInfo
extends
AbstractBaseMongo
{
/**
* 等级
*/
private
String
level
;
/**
* HMax
*/
private
double
HMax
;
/**
* 权重
*/
private
double
weight
;
/**
* 临界
*/
private
double
threshold
;
/**
* 系数
*/
private
double
coefficient
;
}
src/main/java/com/zhiwei/brandkbs2/pojo/BytedanceCustomEventUpdateTask.java
View file @
6fe16ea2
package
com
.
zhiwei
.
brandkbs2
.
pojo
;
import
com.zhiwei.brandkbs2.auth.UserThreadLocal
;
import
com.zhiwei.brandkbs2.easyexcel.dto.UploadBytedanceEventDTO
;
import
lombok.*
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
/**
* @ClassName: BytedanceCustomEventInfluenceTask
...
...
@@ -40,14 +38,6 @@ public class BytedanceCustomEventUpdateTask extends AbstractBaseMongo{
*/
private
List
<
EventInfo
>
eventInfo
;
/**
* 事件数据
*/
// private Map<String, List<UploadBytedanceEventDTO>> eventData;
/**
* 报错数据
*/
private
List
<
BytedanceCustomEventUpdateTaskData
>
errorData
;
/**
* 竞品影响力指数
*/
private
Double
contendInfluence
;
...
...
@@ -88,6 +78,10 @@ public class BytedanceCustomEventUpdateTask extends AbstractBaseMongo{
*/
private
String
name
;
/**
* 传播量(该事件的数据量)
*/
private
Integer
dataCount
;
/**
* 影响力指数
*/
private
Double
influence
;
...
...
@@ -145,7 +139,7 @@ public class BytedanceCustomEventUpdateTask extends AbstractBaseMongo{
task
.
setProcessStatus
(
ProcessStatus
.
CHANNEL_MATCH
.
getStatus
());
task
.
setExtraCompute
(
extraCompute
);
task
.
setEventInfo
(
new
ArrayList
<>());
task
.
setErrorData
(
new
ArrayList
<>());
//
task.setErrorData(new ArrayList<>());
task
.
setCancel
(
false
);
task
.
setSchedule
(
0
);
task
.
setTotalSchedule
(
0
);
...
...
@@ -165,7 +159,7 @@ public class BytedanceCustomEventUpdateTask extends AbstractBaseMongo{
task
.
setProcessStatus
(
ProcessStatus
.
QUERY_YUQING
.
getStatus
());
task
.
setExtraCompute
(
false
);
task
.
setEventInfo
(
null
);
task
.
setErrorData
(
null
);
//
task.setErrorData(null);
task
.
setCancel
(
false
);
task
.
setSchedule
(
0
);
task
.
setTotalSchedule
(
0
);
...
...
src/main/java/com/zhiwei/brandkbs2/pojo/BytedanceCustomEventUpdateTaskData.java
View file @
6fe16ea2
...
...
@@ -6,7 +6,7 @@ import lombok.Setter;
/**
* @ClassName: BytedanceCustomEventInfluenceTask
* @Description 字节定制事件影响力计算
rw
* @Description 字节定制事件影响力计算
* @author: cjz
* @date: 2023-10-16 15:12
*/
...
...
@@ -16,21 +16,21 @@ import lombok.Setter;
public
class
BytedanceCustomEventUpdateTaskData
extends
AbstractBaseMongo
{
private
String
taskId
;
private
String
platformType
;
private
String
platform
;
private
String
channel
;
private
String
url
;
private
String
eventName
;
private
Integer
weiboForward
;
private
Integer
reading
;
private
Integer
weiboComment
;
private
Integer
read
;
private
Integer
weiboL
ike
;
private
Integer
l
ike
;
private
Integer
wechatRead
;
private
Integer
comment
;
private
Integer
wechatReading
;
private
Integer
forward
;
}
src/main/java/com/zhiwei/brandkbs2/pojo/MarkSearchAnalyzeTask.java
0 → 100644
View file @
6fe16ea2
package
com
.
zhiwei
.
brandkbs2
.
pojo
;
import
com.alibaba.fastjson.JSONObject
;
import
com.zhiwei.brandkbs2.pojo.dto.MarkSearchDTO
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
lombok.Setter
;
import
java.util.List
;
/**
* @ClassName: YuqingSearchAnalyzeTask
* @Description 查舆情数据分析任务
* @author: cjz
* @date: 2024-04-16 14:21
*/
@Getter
@Setter
@AllArgsConstructor
public
class
MarkSearchAnalyzeTask
extends
AbstractBaseMongo
{
/**
* 查舆情搜索条件
*/
private
MarkSearchDTO
markSearchDTO
;
/**
* 数据分析结果-词云
*/
List
<
JSONObject
>
highWord
;
/**
* 词云计算是否已完成
*/
private
Boolean
finish
;
/**
* 创建时间
*/
private
Long
cTime
;
}
src/main/java/com/zhiwei/brandkbs2/pojo/dto/MarkSearchDTO.java
View file @
6fe16ea2
...
...
@@ -195,4 +195,9 @@ public class MarkSearchDTO {
*/
@ApiModelProperty
(
value
=
"gid限制"
)
private
Long
pageGid
;
/**
* 聚合标题
*/
@ApiModelProperty
(
value
=
"聚合标题"
)
private
String
aggTitle
;
}
src/main/java/com/zhiwei/brandkbs2/pojo/external/BrandkbsYuQingConfigNew.java
View file @
6fe16ea2
...
...
@@ -19,6 +19,16 @@ public class BrandkbsYuQingConfigNew {
private
String
channel
;
/**
* 屏蔽关键字命中
*/
private
String
noiseKeyword
;
/**
* 屏蔽自定义渠道
*/
private
String
noiseChannel
;
/**
* 行政级别
*/
private
List
<
String
>
politicsLevels
;
...
...
src/main/java/com/zhiwei/brandkbs2/service/IndexService.java
View file @
6fe16ea2
...
...
@@ -81,4 +81,12 @@ public interface IndexService {
*/
JSONObject
getMobileWholeCriteria
(
Long
startTime
,
Long
endTime
);
/**
* 获取主品牌净情感度
* @param startTime 开始时间
* @param endTime 结束时间
* @param cache 是否优先读取缓存
* @return
*/
JSONObject
getEmotionPercent
(
Long
startTime
,
Long
endTime
,
boolean
cache
);
}
src/main/java/com/zhiwei/brandkbs2/service/MarkDataService.java
View file @
6fe16ea2
...
...
@@ -5,11 +5,7 @@ import com.zhiwei.brandkbs2.model.ResponseResult;
import
com.zhiwei.brandkbs2.pojo.BaseMap
;
import
com.zhiwei.brandkbs2.pojo.Event
;
import
com.zhiwei.brandkbs2.pojo.MarkFlowEntity
;
import
com.zhiwei.brandkbs2.pojo.dto.ExportAppYuqingDTO
;
import
com.zhiwei.brandkbs2.pojo.dto.ExportSearchWholeDTO
;
import
com.zhiwei.brandkbs2.pojo.dto.MarkSearchDTO
;
import
com.zhiwei.brandkbs2.pojo.dto.SearchFilterDTO
;
import
com.zhiwei.brandkbs2.pojo.dto.NonManualProjectPlanDTO
;
import
com.zhiwei.brandkbs2.pojo.dto.*
;
import
com.zhiwei.brandkbs2.pojo.vo.LineVO
;
import
com.zhiwei.brandkbs2.pojo.vo.PageVO
;
import
org.apache.commons.lang3.tuple.Pair
;
...
...
@@ -545,95 +541,88 @@ public interface MarkDataService {
/**
* 新-舆情分析-舆情总量
* @param startTime
* @param endTime
* @param planId
* @param dto 标注数据搜索传输类
* @return
* @throws IOException
*/
JSONObject
getYuqingAmount
(
Long
startTime
,
Long
endTime
,
String
planId
);
JSONObject
getYuqingAmount
(
MarkSearchDTO
dto
);
/**
* 新-舆情分析-情感分布
* @param startTime
* @param endTime
* @param planId
* @param dto 标注数据搜索传输类
* @return
* @throws IOException
*/
JSONObject
getYuqingEmotionDistribution
(
Long
startTime
,
Long
endTime
,
String
planId
);
JSONObject
getYuqingEmotionDistribution
(
MarkSearchDTO
dto
);
/**
* 新-舆情分析-重点平台
* @param startTime
* @param endTime
* @param planId
* @param dto 标注数据搜索传输类
* @return
*/
JSONObject
getImportantPlatformPercentage
(
Long
startTime
,
Long
endTime
,
String
planId
);
JSONObject
getImportantPlatformPercentage
(
MarkSearchDTO
dto
);
/**
* 新-舆情分析-平台占比
* @param startTime
* @param endTime
* @param planId
* @param dto 标注数据搜索传输类
* @return
*/
List
<
JSONObject
>
ge
tPlatformPercentage
(
Long
startTime
,
Long
endTime
,
String
planId
);
List
<
JSONObject
>
ge
AnalyzePlatformPercentage
(
MarkSearchDTO
dto
);
/**
* 新-舆情分析-舆情走势图
* @param startTime
* @param endTime
* @param planId
* @param dto 标注数据搜索传输类
* @return
*/
JSONObject
getSpreadTendency
(
Long
startTime
,
Long
endTime
,
String
planId
);
JSONObject
getSpreadTendency
(
MarkSearchDTO
dto
);
/**
* 新-舆情分析-活跃渠道
* @param startTime
* @param endTime
* @param planId
* @param dto 标注数据搜索传输类
* @return
*/
List
<
JSONObject
>
getActiveChannels
(
Long
startTime
,
Long
endTime
,
String
planId
);
List
<
JSONObject
>
getActiveChannels
(
MarkSearchDTO
dto
);
/**
* 新-舆情分析-ip分布
* @param startTime
* @param endTime
* @param planId
* @param dto 标注数据搜索传输类
* @return
*/
List
<
JSONObject
>
getArticleIpLocated
(
Long
startTime
,
Long
endTime
,
String
planId
,
int
size
);
List
<
JSONObject
>
getArticleIpLocated
(
MarkSearchDTO
dto
);
/**
* 新-舆情分析-活跃渠道、ip分布、词云详情页面
* @param dto
* @param dto
标注数据搜索传输类
* @return
*/
PageVO
<
MarkFlowEntity
>
getYuqingAnalyzeDetail
(
MarkSearchDTO
dto
);
void
cacheHighWord
(
Long
startTime
,
Long
endTime
,
String
planId
,
boolean
cache
);
/**
* 新-舆情分析-词云
* @param startTime
* @param endTime
* @param planId
* @param dto 标注数据搜索传输类
* @return
*/
List
<
JSONObject
>
getHighWord
(
Long
startTime
,
Long
endTime
,
String
planId
,
boolean
cache
);
List
<
JSONObject
>
getAnalyzeHighWord
(
MarkSearchDTO
dto
,
boolean
cache
);
/**
* 查舆情-数据分析-生成词云
* @param dto
* @return
*/
List
<
JSONObject
>
getSearchAnalyzeHighWord
(
MarkSearchDTO
dto
);
/**
* 新-舆情分析-高频标题
* @param startTime
* @param endTime
* @param planId
* @param size
* @param include
* @return
*/
List
<
JSONObject
>
getLastNews
(
Long
startTime
,
Long
endTime
,
String
planId
,
int
size
,
boolean
include
);
List
<
JSONObject
>
getLastNews
(
Long
startTime
,
Long
endTime
,
int
size
);
List
<
JSONObject
>
getLastNews
(
MarkSearchDTO
dto
,
int
size
);
/**
* 舆情分析-高频标题详情页-基础信息
...
...
@@ -645,6 +634,8 @@ public interface MarkDataService {
*/
JSONObject
getAggTitleBaseInfo
(
String
aggTitle
,
Long
startTime
,
Long
endTime
,
String
planId
);
JSONObject
getAggTitleBaseInfo
(
MarkSearchDTO
dto
);
/**
* 舆情分析-高频标题详情页-发布节点
* @param aggTitle
...
...
@@ -655,6 +646,8 @@ public interface MarkDataService {
*/
List
<
JSONObject
>
getAggTitleArticlePoints
(
String
aggTitle
,
Long
startTime
,
Long
endTime
,
String
planId
);
List
<
JSONObject
>
getAggTitleArticlePoints
(
MarkSearchDTO
dto
);
/**
* 舆情分析-高频标题详情页-平台分布
* @param aggTitle
...
...
@@ -665,6 +658,8 @@ public interface MarkDataService {
*/
List
<
JSONObject
>
getAggTitlePlatformPercentage
(
String
aggTitle
,
Long
startTime
,
Long
endTime
,
String
planId
);
List
<
JSONObject
>
getAggTitlePlatformPercentage
(
MarkSearchDTO
dto
);
/**
* 舆情分析-高频标题详情页-发文列表
* @param aggTitle
...
...
@@ -676,4 +671,6 @@ public interface MarkDataService {
* @return
*/
PageVO
<
JSONObject
>
getArticleList
(
String
aggTitle
,
Long
startTime
,
Long
endTime
,
String
planId
,
String
platform
,
int
page
,
int
pageSize
);
PageVO
<
JSONObject
>
getArticleList
(
MarkSearchDTO
dto
);
}
src/main/java/com/zhiwei/brandkbs2/service/ProjectWarnService.java
View file @
6fe16ea2
...
...
@@ -23,14 +23,6 @@ public interface ProjectWarnService {
ResponseResult
getProjectWarnCriteriaDefault
(
String
projectId
,
String
type
);
/**
* 获取舆情动态预警
* @param projectId
* @param brandkbsYuQingConfig
* @return
*/
ResponseResult
getYuqingWaring
(
String
projectId
,
BrandkbsYuQingConfig
brandkbsYuQingConfig
);
/**
* 获取舆情动态预警-新
* @param projectId
* @param brandkbsYuQingConfigNew
...
...
src/main/java/com/zhiwei/brandkbs2/service/SystemInfoService.java
View file @
6fe16ea2
package
com
.
zhiwei
.
brandkbs2
.
service
;
import
com.alibaba.fastjson.JSONObject
;
import
com.zhiwei.brandkbs2.pojo.BytedanceCustomChannelInfluence
;
import
com.zhiwei.brandkbs2.pojo.ChannelTag
;
import
com.zhiwei.brandkbs2.pojo.Project
;
import
com.zhiwei.brandkbs2.pojo.SensitiveChannel
;
...
...
@@ -70,4 +71,10 @@ public interface SystemInfoService {
* @return
*/
Map
<
String
,
SensitiveChannel
>
getCommonSensitiveChannel
();
/**
* 获取字节定制指定渠道影响力信息
* @return
*/
Map
<
String
,
BytedanceCustomChannelInfluence
>
getByteDanceChannelInfluence
();
}
src/main/java/com/zhiwei/brandkbs2/service/impl/ChannelServiceImpl.java
View file @
6fe16ea2
...
...
@@ -994,69 +994,70 @@ public class ChannelServiceImpl implements ChannelService {
@Override
public
Channel
calculateChannelEmotionIndex
(
Channel
channel
)
{
try
{
Project
project
=
projectService
.
getProjectById
(
channel
.
getProjectId
());
// 数据格式变化未含有contendId部分
if
(
null
==
channel
.
getContendId
())
{
channel
.
setContendId
(
"0"
);
}
// 不做统计
if
(!
hasEmotion
(
channel
))
{
return
channel
;
}
// 该渠道发布正面稿件
Long
positiveCount
=
markCountByEmotion
(
channel
,
EmotionEnum
.
POSITIVE
.
getName
());
// 该渠道发布中性稿件
Long
neutralCount
=
markCountByEmotion
(
channel
,
EmotionEnum
.
NEUTRAL
.
getName
());
// 该渠道发布负面稿件
Long
negativeCount
=
markCountByEmotion
(
channel
,
EmotionEnum
.
NEGATIVE
.
getName
());
// 是否友好渠道
boolean
isPositive
=
false
;
boolean
isNegative
=
false
;
long
specNegativeCount
=
eventMiddlewareDao
.
getEventCount
(
new
ChannelIndex
(
channel
).
getFid
(),
Arrays
.
asList
(
EmotionEnum
.
POSITIVE
.
getName
(),
EmotionEnum
.
NEUTRAL
.
getName
()),
EmotionEnum
.
NEGATIVE
.
getName
());
long
specPositiveCount
=
eventMiddlewareDao
.
getEventCount
(
new
ChannelIndex
(
channel
).
getFid
(),
Collections
.
singletonList
(
EmotionEnum
.
NEGATIVE
.
getName
()),
EmotionEnum
.
POSITIVE
.
getName
());
// 特殊情况:若皆有发布过反常稿件
if
(
specNegativeCount
>
0
&&
specPositiveCount
>
0
)
{
// 正面稿件数>负面稿件数,为正面
if
(
positiveCount
>
negativeCount
)
{
isPositive
=
true
;
// 正面稿件数<负面稿件数,为负面
}
else
if
(
positiveCount
<
negativeCount
)
{
isNegative
=
true
;
}
}
else
{
// 在正/中性事件中发布负面稿件||负面报道数>正面报道数(满足任一条件)
if
(
negativeCount
>
positiveCount
)
{
isNegative
=
true
;
// 如果有在正面事件中发布负面稿件
}
else
if
(
specNegativeCount
>
0
)
{
// 或满足三者复合条件:发布正面稿件>负面稿件&&正面稿件>=中性稿件&&月均参与正面事件数≥4.64
if
(
positiveCount
>
negativeCount
&&
positiveCount
>=
neutralCount
&&
(
this
.
inEventCountMonthAverage
(
channel
,
EmotionEnum
.
POSITIVE
.
getName
())
>=
4.64
))
{
isPositive
=
true
;
}
else
{
isNegative
=
true
;
}
}
else
{
// 在负面事件中发布过正面稿件即满足
if
(
specPositiveCount
>
0
)
{
isPositive
=
true
;
// 或满足三者复合条件:发布正面稿件>负面稿件&&正面稿件>=中性稿件&&月均参与正面事件数≥4.64
}
else
if
(
positiveCount
>
negativeCount
&&
positiveCount
>=
neutralCount
&&
(
this
.
inEventCountMonthAverage
(
channel
,
EmotionEnum
.
POSITIVE
.
getName
())
>=
4.64
))
{
isPositive
=
true
;
}
}
}
// 更新渠道指数,渠道等级,情感倾向并记录变化
this
.
updateChannel
(
channel
,
project
,
positiveCount
,
neutralCount
,
negativeCount
,
isPositive
,
isNegative
,
specPositiveCount
,
specNegativeCount
);
}
catch
(
Exception
e
)
{
log
.
error
(
"calculateChannelEmotionIndex-"
,
e
);
}
// 渠道倾向及渠道影响力指数计算关闭
// try {
// Project project = projectService.getProjectById(channel.getProjectId());
// // 数据格式变化未含有contendId部分
// if (null == channel.getContendId()) {
// channel.setContendId("0");
// }
// // 不做统计
// if (!hasEmotion(channel)) {
// return channel;
// }
// // 该渠道发布正面稿件
// Long positiveCount = markCountByEmotion(channel, EmotionEnum.POSITIVE.getName());
// // 该渠道发布中性稿件
// Long neutralCount = markCountByEmotion(channel, EmotionEnum.NEUTRAL.getName());
// // 该渠道发布负面稿件
// Long negativeCount = markCountByEmotion(channel, EmotionEnum.NEGATIVE.getName());
// // 是否友好渠道
// boolean isPositive = false;
// boolean isNegative = false;
// long specNegativeCount = eventMiddlewareDao.getEventCount(new ChannelIndex(channel).getFid(),
// Arrays.asList(EmotionEnum.POSITIVE.getName(), EmotionEnum.NEUTRAL.getName()),
// EmotionEnum.NEGATIVE.getName());
// long specPositiveCount = eventMiddlewareDao.getEventCount(new ChannelIndex(channel).getFid(),
// Collections.singletonList(EmotionEnum.NEGATIVE.getName()), EmotionEnum.POSITIVE.getName());
// // 特殊情况:若皆有发布过反常稿件
// if (specNegativeCount > 0 && specPositiveCount > 0) {
// // 正面稿件数>负面稿件数,为正面
// if (positiveCount > negativeCount) {
// isPositive = true;
// // 正面稿件数<负面稿件数,为负面
// } else if (positiveCount < negativeCount) {
// isNegative = true;
// }
// } else {
// // 在正/中性事件中发布负面稿件||负面报道数>正面报道数(满足任一条件)
// if (negativeCount > positiveCount) {
// isNegative = true;
// // 如果有在正面事件中发布负面稿件
// } else if (specNegativeCount > 0) {
// // 或满足三者复合条件:发布正面稿件>负面稿件&&正面稿件>=中性稿件&&月均参与正面事件数≥4.64
// if (positiveCount > negativeCount && positiveCount >= neutralCount
// && (this.inEventCountMonthAverage(channel, EmotionEnum.POSITIVE.getName()) >= 4.64)) {
// isPositive = true;
// } else {
// isNegative = true;
// }
// } else {
// // 在负面事件中发布过正面稿件即满足
// if (specPositiveCount > 0) {
// isPositive = true;
// // 或满足三者复合条件:发布正面稿件>负面稿件&&正面稿件>=中性稿件&&月均参与正面事件数≥4.64
// } else if (positiveCount > negativeCount && positiveCount >= neutralCount
// && (this.inEventCountMonthAverage(channel, EmotionEnum.POSITIVE.getName()) >= 4.64)) {
// isPositive = true;
// }
// }
// }
// // 更新渠道指数,渠道等级,情感倾向并记录变化
// this.updateChannel(channel, project, positiveCount, neutralCount, negativeCount, isPositive, isNegative,
// specPositiveCount, specNegativeCount);
// } catch (Exception e) {
// log.error("calculateChannelEmotionIndex-", e);
// }
return
channel
;
}
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/EventServiceImpl.java
View file @
6fe16ea2
...
...
@@ -903,7 +903,7 @@ public class EventServiceImpl implements EventService {
if
(
cache
&&
StringUtils
.
isNotEmpty
(
resultStr
))
{
return
JSON
.
parseArray
(
resultStr
,
JSONObject
.
class
);
}
List
<
JSONObject
>
resultList
=
markDataService
.
getLastNews
(
startTime
,
endTime
,
null
,
50
,
true
);
List
<
JSONObject
>
resultList
=
markDataService
.
getLastNews
(
startTime
,
endTime
,
50
);
redisUtil
.
setExpire
(
redisKey
,
JSON
.
toJSONString
(
resultList
));
return
resultList
;
}
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/IndexServiceImpl.java
View file @
6fe16ea2
...
...
@@ -334,6 +334,58 @@ public class IndexServiceImpl implements IndexService {
return
result
;
}
@Override
public
JSONObject
getEmotionPercent
(
Long
startTime
,
Long
endTime
,
boolean
cache
)
{
if
(
Objects
.
isNull
(
startTime
)
||
Objects
.
isNull
(
endTime
))
{
Long
[]
timeRangeMonth
=
commonService
.
getTimeRangeMonth
();
startTime
=
timeRangeMonth
[
0
];
endTime
=
timeRangeMonth
[
1
];
}
String
projectId
=
UserThreadLocal
.
getProjectId
();
String
redisKey
=
RedisUtil
.
getIndexEmotionKey
(
projectId
,
startTime
,
endTime
);
String
resultStr
;
// 返回缓存
if
(
cache
&&
StringUtils
.
isNotEmpty
(
resultStr
=
redisUtil
.
get
(
redisKey
)))
{
return
JSON
.
parseObject
(
resultStr
);
}
JSONObject
jsonObject
=
new
JSONObject
();
try
{
// 关于NSR计算:NSR净情感度=(正面-负面)/(正面+负面)*100%
// 项目总正面稿件数
long
totalPositiveCount
=
markDataService
.
getYuqingMarkCount
(
null
,
null
,
EmotionEnum
.
POSITIVE
.
getName
(),
projectId
,
Constant
.
PRIMARY_CONTEND_ID
);
// 项目总负面稿件数
long
totalNegativeCount
=
markDataService
.
getYuqingMarkCount
(
null
,
null
,
EmotionEnum
.
NEGATIVE
.
getName
(),
projectId
,
Constant
.
PRIMARY_CONTEND_ID
);
// 项目均值NSR
double
avg
=
0
==
totalPositiveCount
+
totalNegativeCount
?
0
:(
totalPositiveCount
-
totalNegativeCount
)
/
(
double
)
(
totalPositiveCount
+
totalNegativeCount
);
jsonObject
.
put
(
"avgNSR"
,
avg
);
// 正面稿件数
long
positiveCount
=
markDataService
.
getYuqingMarkCount
(
startTime
,
endTime
,
EmotionEnum
.
POSITIVE
.
getName
(),
projectId
,
Constant
.
PRIMARY_CONTEND_ID
);
jsonObject
.
put
(
"positiveCount"
,
positiveCount
);
// 负面稿件数
long
negativeCount
=
markDataService
.
getYuqingMarkCount
(
startTime
,
endTime
,
EmotionEnum
.
NEGATIVE
.
getName
(),
projectId
,
Constant
.
PRIMARY_CONTEND_ID
);
jsonObject
.
put
(
"negativeCount"
,
negativeCount
);
// 本次NSR
double
NSR
=
0
==
positiveCount
+
negativeCount
?
0
:(
positiveCount
-
negativeCount
)
/
(
double
)
(
positiveCount
+
negativeCount
);
jsonObject
.
put
(
"NSR"
,
NSR
);
// 上一周期开始时间
long
previousStartTime
=
startTime
-
(
endTime
-
startTime
);
// 上一周期正面稿件数
long
previousPositiveCount
=
markDataService
.
getYuqingMarkCount
(
previousStartTime
,
startTime
,
EmotionEnum
.
POSITIVE
.
getName
(),
projectId
,
Constant
.
PRIMARY_CONTEND_ID
);
// 上一周期负面稿件数
long
previousNegativeCount
=
markDataService
.
getYuqingMarkCount
(
previousStartTime
,
startTime
,
EmotionEnum
.
NEGATIVE
.
getName
(),
projectId
,
Constant
.
PRIMARY_CONTEND_ID
);
// 上一周期NSR
double
previousNSR
=
0
==
previousPositiveCount
+
previousNegativeCount
?
0
:(
previousPositiveCount
-
previousNegativeCount
)
/
(
double
)
(
previousPositiveCount
+
previousNegativeCount
);
// 环比
jsonObject
.
put
(
"compare"
,
NSR
-
previousNSR
);
redisUtil
.
setExpire
(
redisKey
,
JSON
.
toJSONString
(
jsonObject
));
}
catch
(
Exception
e
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"getEmotionPercent异常"
,
e
);
}
return
jsonObject
;
}
public
List
<
JSONObject
>
getPlatformProportionWithPlatform
(
Long
startTime
,
Long
endTime
,
String
emotion
,
String
projectId
,
String
contendId
,
long
normalCount
)
{
List
<
String
>
platformIds
=
GlobalPojo
.
PLATFORMS
.
stream
().
map
(
MessagePlatform:
:
getId
).
collect
(
Collectors
.
toList
());
List
<
JSONObject
>
resultList
=
new
ArrayList
<>(
platformIds
.
size
());
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkDataServiceImpl.java
View file @
6fe16ea2
...
...
@@ -13,10 +13,7 @@ import com.zhiwei.brandkbs2.common.GenericAttribute;
import
com.zhiwei.brandkbs2.common.GlobalPojo
;
import
com.zhiwei.brandkbs2.common.RedisKeyPrefix
;
import
com.zhiwei.brandkbs2.config.Constant
;
import
com.zhiwei.brandkbs2.dao.AggreeResultDao
;
import
com.zhiwei.brandkbs2.dao.ChannelDao
;
import
com.zhiwei.brandkbs2.dao.HighlightWordDao
;
import
com.zhiwei.brandkbs2.dao.NonManualProjectPlanDao
;
import
com.zhiwei.brandkbs2.dao.*
;
import
com.zhiwei.brandkbs2.easyexcel.EasyExcelUtil
;
import
com.zhiwei.brandkbs2.easyexcel.dto.ExportYuqingInteractionUpdateDTO
;
import
com.zhiwei.brandkbs2.enmus.ChannelEmotion
;
...
...
@@ -73,6 +70,7 @@ import org.joda.time.PeriodType;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.data.mongodb.core.query.Update
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.MediaType
;
...
...
@@ -173,6 +171,9 @@ public class MarkDataServiceImpl implements MarkDataService {
@Resource
(
name
=
"nonManualProjectPlanDao"
)
NonManualProjectPlanDao
nonManualProjectPlanDao
;
@Resource
(
name
=
"markSearchAnalyzeTaskDao"
)
MarkSearchAnalyzeTaskDao
markSearchAnalyzeTaskDao
;
@Resource
(
name
=
"toolsetServiceImpl"
)
private
ToolsetService
toolsetService
;
...
...
@@ -828,7 +829,7 @@ public class MarkDataServiceImpl implements MarkDataService {
public
List
<
Map
.
Entry
<
String
,
Integer
>>
getMarkTopTitle
(
Long
startTime
,
Long
endTime
,
String
emotion
,
String
projectId
,
String
contendId
,
int
size
,
boolean
include
)
throws
IOException
{
// 索引
String
[]
indexes
=
esClientDao
.
getIndexes
();
TermsAggregationBuilder
aggregationBuilder
=
AggregationBuilders
.
terms
(
"titles"
).
field
(
"agg_title.keyword"
).
size
(
size
+
1
);
TermsAggregationBuilder
aggregationBuilder
=
AggregationBuilders
.
terms
(
"titles"
).
field
(
"agg_title.keyword"
).
size
(
size
+
Tools
.
FILTER_TITLE
.
size
()
);
// query
BoolQueryBuilder
query
;
if
(
include
)
{
...
...
@@ -848,8 +849,8 @@ public class MarkDataServiceImpl implements MarkDataService {
ParsedStringTerms
teamAgg
=
(
ParsedStringTerms
)
aggMap
.
get
(
"titles"
);
for
(
Terms
.
Bucket
bucket
:
teamAgg
.
getBuckets
())
{
String
title
=
bucket
.
getKeyAsString
();
// 过滤 “分享一篇文章” 的标题
if
(
"分享一篇文章"
.
equals
(
title
))
{
// 过滤 “分享一篇文章”
,”暂无标题“,”Notitle“
的标题
if
(
Tools
.
filterUselessTitle
(
title
))
{
continue
;
}
int
num
=
(
int
)
bucket
.
getDocCount
();
...
...
@@ -858,31 +859,22 @@ public class MarkDataServiceImpl implements MarkDataService {
return
result
.
entrySet
().
stream
().
sorted
(
Map
.
Entry
.
comparingByValue
(
Comparator
.
reverseOrder
())).
limit
(
size
).
collect
(
Collectors
.
toList
());
}
private
List
<
JSONObject
>
getMarkTopTitle
(
Long
startTime
,
Long
endTime
,
String
emotion
,
String
projectId
,
String
contendId
,
String
planId
,
int
size
)
throws
IOException
{
private
List
<
JSONObject
>
getMarkTopTitle
(
MarkSearchDTO
dto
,
int
size
)
throws
IOException
{
// 索引
String
[]
indexes
=
esClientDao
.
getIndexes
();
TermsAggregationBuilder
aggregationBuilder
=
AggregationBuilders
.
terms
(
"titles"
).
field
(
"agg_title.keyword"
).
size
(
size
+
1
);
TermsAggregationBuilder
aggregationBuilder
=
AggregationBuilders
.
terms
(
"titles"
).
field
(
"agg_title.keyword"
).
size
(
size
+
Tools
.
FILTER_TITLE
.
size
()
);
TermsAggregationBuilder
sourceAggregationBuilder
=
AggregationBuilders
.
terms
(
"source"
).
field
(
"source"
).
size
(
10000
);
// query
BoolQueryBuilder
query
;
if
(
Objects
.
isNull
(
planId
))
{
query
=
projectContendIdQuery
(
projectId
,
contendId
);
}
else
{
query
=
EsQueryTools
.
assembleCacheMapsPlanQuery
(
projectId
,
planId
);
}
query
.
must
(
QueryBuilders
.
rangeQuery
(
"time"
).
gte
(
startTime
).
lt
(
endTime
))
BoolQueryBuilder
query
=
yuqingAnalyzeQuery
(
dto
);
// 过滤微博
.
mustNot
(
QueryBuilders
.
termQuery
(
"platform_id"
,
"5d02236e6395002a7c380b79"
));
if
(
null
!=
emotion
&&
!
Objects
.
equals
(
emotion
,
EmotionEnum
.
ALL
.
getName
()))
{
query
.
must
(
QueryBuilders
.
termQuery
(
"brandkbs_mark_cache_maps.name.keyword"
,
emotion
));
}
query
.
mustNot
(
QueryBuilders
.
termQuery
(
"platform_id"
,
"5d02236e6395002a7c380b79"
));
SearchResponse
searchResponse
;
// 单独处理buckets超过上限异常,出错时按时间分段查询
try
{
searchResponse
=
esClientDao
.
searchResponse
(
indexes
,
null
,
query
,
aggregationBuilder
.
subAggregation
(
sourceAggregationBuilder
),
null
,
null
,
0
,
0
,
null
);
}
catch
(
ElasticsearchStatusException
e
){
return
getMarkTopTitleDivided
(
query
,
indexes
,
aggregationBuilder
,
startTime
,
endTime
,
size
);
return
getMarkTopTitleDivided
(
query
,
indexes
,
aggregationBuilder
,
dto
.
getStartTime
(),
dto
.
getEndTime
()
,
size
);
}
List
<
JSONObject
>
res
=
new
ArrayList
<>();
Map
<
String
,
Aggregation
>
aggMap
=
searchResponse
.
getAggregations
().
asMap
();
...
...
@@ -890,8 +882,8 @@ public class MarkDataServiceImpl implements MarkDataService {
for
(
Terms
.
Bucket
bucket
:
teamAgg
.
getBuckets
())
{
JSONObject
jsonObject
=
new
JSONObject
();
String
title
=
bucket
.
getKeyAsString
();
// 过滤 “分享一篇文章” 的标题
if
(
"分享一篇文章"
.
equals
(
title
))
{
// 过滤 “分享一篇文章”
,”暂无标题“,”Notitle“
的标题
if
(
Tools
.
filterUselessTitle
(
title
))
{
continue
;
}
jsonObject
.
put
(
"title"
,
title
);
...
...
@@ -976,10 +968,6 @@ public class MarkDataServiceImpl implements MarkDataService {
return
getArticleSort
(
startTime
,
endTime
,
aggTitle
,
projectId
,
contendId
,
planId
,
include
,
"{\"time\" : \"asc\"}"
);
}
private
BaseMap
getLastArticle
(
Long
startTime
,
Long
endTime
,
String
aggTitle
,
String
projectId
,
String
contendId
,
String
planId
,
boolean
include
)
throws
IOException
{
return
getArticleSort
(
startTime
,
endTime
,
aggTitle
,
projectId
,
contendId
,
planId
,
include
,
"{\"time\" : \"desc\"}"
);
}
private
BaseMap
getArticleSort
(
Long
startTime
,
Long
endTime
,
String
aggTitle
,
String
projectId
,
String
contendId
,
String
planId
,
boolean
include
,
String
sorter
)
throws
IOException
{
// 索引
String
[]
indexes
=
esClientDao
.
getIndexes
();
...
...
@@ -1014,6 +1002,36 @@ public class MarkDataServiceImpl implements MarkDataService {
return
Tools
.
getBaseFromEsMap
(
hits
.
getAt
(
0
).
getSourceAsMap
());
}
private
BaseMap
getAnalyzeFirstArticle
(
MarkSearchDTO
dto
)
throws
IOException
{
return
getArticleSort
(
dto
,
"{\"time\" : \"asc\"}"
);
}
private
BaseMap
getAnalyzeLastArticle
(
MarkSearchDTO
dto
)
throws
IOException
{
return
getArticleSort
(
dto
,
"{\"time\" : \"desc\"}"
);
}
private
BaseMap
getArticleSort
(
MarkSearchDTO
dto
,
String
sorter
)
throws
IOException
{
// 索引
String
[]
indexes
=
esClientDao
.
getIndexes
();
BoolQueryBuilder
query
=
yuqingAnalyzeQuery
(
dto
);
//sort
FieldSortBuilder
sort
=
new
FieldSortBuilder
(
"time"
).
order
(
SortOrder
.
ASC
);
JSONObject
sortJson
=
JSONObject
.
parseObject
(
sorter
);
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
sortJson
.
entrySet
())
{
if
(
entry
.
getValue
().
toString
().
contains
(
"desc"
))
{
sort
=
SortBuilders
.
fieldSort
(
entry
.
getKey
()).
order
(
SortOrder
.
DESC
);
}
else
{
sort
=
SortBuilders
.
fieldSort
(
entry
.
getKey
()).
order
(
SortOrder
.
ASC
);
}
}
//hits
SearchHits
hits
=
esClientDao
.
searchHits
(
indexes
,
query
,
null
,
null
,
sort
,
0
,
1
,
null
);
if
(
0
==
hits
.
getTotalHits
().
value
)
{
return
new
BaseMap
();
}
return
Tools
.
getBaseFromEsMap
(
hits
.
getAt
(
0
).
getSourceAsMap
());
}
@Override
public
List
<
JSONObject
>
searchMarkDataByEvent
(
Event
event
)
{
Long
endTime
=
null
;
...
...
@@ -1720,7 +1738,9 @@ public class MarkDataServiceImpl implements MarkDataService {
result
.
put
(
"source"
,
channel
.
getSource
());
result
.
put
(
"platform"
,
channel
.
getPlatform
());
result
.
put
(
"num"
,
bucket
.
getDocCount
());
channelResultList
.
add
(
result
);
if
(!
Tools
.
filterUselessSource
(
channel
.
getSource
())){
channelResultList
.
add
(
result
);
}
}
}
});
...
...
@@ -2410,19 +2430,21 @@ public class MarkDataServiceImpl implements MarkDataService {
}
@Override
public
JSONObject
getYuqingAmount
(
Long
startTime
,
Long
endTime
,
String
planId
)
{
public
JSONObject
getYuqingAmount
(
MarkSearchDTO
dto
)
{
JSONObject
jsonObject
=
new
JSONObject
();
try
{
String
projectId
=
UserThreadLocal
.
getProjectId
();
String
planId
=
dto
.
getPlanId
();
dto
.
setProjectId
(
projectId
);
// 舆情总量
long
total
=
getYuqingAnalyzeCount
(
startTime
,
endTime
,
planId
,
EmotionEnum
.
ALL
.
getName
()
);
long
total
=
getYuqingAnalyzeCount
(
dto
);
jsonObject
.
put
(
"total"
,
total
);
// 项目日均
String
projectYuqingCountAvgKey
=
RedisUtil
.
getYuqingAnalyzeProjectAvgCountKey
(
projectId
,
Constant
.
PRIMARY_CONTEND_ID
,
planId
);
double
projectYuqingAvgCount
=
Objects
.
isNull
(
redisUtil
.
get
(
projectYuqingCountAvgKey
))
?
0
d
:
Double
.
parseDouble
(
redisUtil
.
get
(
projectYuqingCountAvgKey
));
jsonObject
.
put
(
"projectAvg"
,
projectYuqingAvgCount
);
// 本次日均
int
days
=
new
Period
(
startTime
,
endTime
,
PeriodType
.
days
()).
getDays
();
int
days
=
new
Period
(
dto
.
getStartTime
(),
dto
.
getEndTime
()
,
PeriodType
.
days
()).
getDays
();
days
=
0
==
days
?
1
:
days
;
double
yuqingAvgCount
=
total
==
0
?
0
d
:
total
/
(
double
)
days
;
jsonObject
.
put
(
"compare"
,
compare
(
yuqingAvgCount
,
projectYuqingAvgCount
));
...
...
@@ -2433,18 +2455,20 @@ public class MarkDataServiceImpl implements MarkDataService {
}
@Override
public
JSONObject
getYuqingEmotionDistribution
(
Long
startTime
,
Long
endTime
,
String
planId
)
{
public
JSONObject
getYuqingEmotionDistribution
(
MarkSearchDTO
dto
)
{
JSONObject
jsonObject
=
new
JSONObject
();
try
{
String
projectId
=
UserThreadLocal
.
getProjectId
();
String
planId
=
dto
.
getPlanId
();
dto
.
setProjectId
(
projectId
);
// 舆情总量
long
total
=
getYuqingAnalyzeCount
(
startTime
,
endTime
,
planId
,
EmotionEnum
.
ALL
.
getName
()
);
long
total
=
getYuqingAnalyzeCount
(
dto
);
// 正面舆情
long
positiveCount
=
getYuqingAnalyzeCount
(
startTime
,
endTime
,
planId
,
EmotionEnum
.
POSITIVE
.
getName
());
long
positiveCount
=
getYuqingAnalyzeCount
(
dto
,
EmotionEnum
.
POSITIVE
.
getName
());
// 中性舆情
long
neutralCount
=
getYuqingAnalyzeCount
(
startTime
,
endTime
,
planId
,
EmotionEnum
.
NEUTRAL
.
getName
());
long
neutralCount
=
getYuqingAnalyzeCount
(
dto
,
EmotionEnum
.
NEUTRAL
.
getName
());
// 负面舆情
long
negativeCount
=
getYuqingAnalyzeCount
(
startTime
,
endTime
,
planId
,
EmotionEnum
.
NEGATIVE
.
getName
());
long
negativeCount
=
getYuqingAnalyzeCount
(
dto
,
EmotionEnum
.
NEGATIVE
.
getName
());
// 各情感倾向占比
double
positivePercentage
=
total
==
0
?
0
d
:
positiveCount
/
(
double
)
total
;
double
neutralPercentage
=
total
==
0
?
0
d
:
neutralCount
/
(
double
)
total
;
...
...
@@ -2478,15 +2502,20 @@ public class MarkDataServiceImpl implements MarkDataService {
}
@Override
public
JSONObject
getImportantPlatformPercentage
(
Long
startTime
,
Long
endTime
,
String
planId
)
{
public
JSONObject
getImportantPlatformPercentage
(
MarkSearchDTO
dto
)
{
JSONObject
res
=
new
JSONObject
();
try
{
List
<
JSONObject
>
list
=
new
ArrayList
<>();
List
<
String
>
importantPlatforms
=
Arrays
.
asList
(
"微博"
,
"微信"
,
"抖音"
,
"小红书"
,
"今日头条"
,
"网媒"
);
List
<
String
>
importantPlatforms
=
new
ArrayList
<>(
);
String
projectId
=
UserThreadLocal
.
getProjectId
();
Long
total
=
getYuqingAnalyzeCount
(
startTime
,
endTime
,
planId
,
importantPlatforms
);
dto
.
setProjectId
(
projectId
);
for
(
String
platformNames
:
Arrays
.
asList
(
"微博"
,
"微信"
,
"抖音"
,
"小红书"
,
"今日头条"
,
"网媒"
))
{
importantPlatforms
.
add
(
GlobalPojo
.
getPlatformIdByName
(
platformNames
));
}
dto
.
setPlatforms
(
importantPlatforms
);
Long
total
=
getYuqingAnalyzeCount
(
dto
);
// 平台聚合
SearchResponse
searchResponse
=
platformAggSearchResponse
(
startTime
,
endTime
,
planId
,
importantPlatforms
,
null
);
SearchResponse
searchResponse
=
platformAggSearchResponse
(
dto
);
Map
<
String
,
Aggregation
>
aggMap
=
searchResponse
.
getAggregations
().
asMap
();
ParsedStringTerms
teamAgg
=
(
ParsedStringTerms
)
aggMap
.
get
(
"platform_count"
);
List
<?
extends
Terms
.
Bucket
>
buckets
=
teamAgg
.
getBuckets
();
...
...
@@ -2501,12 +2530,12 @@ public class MarkDataServiceImpl implements MarkDataService {
// 总量
overview
.
put
(
"total"
,
total
);
// 日均
int
days
=
new
Period
(
startTime
,
endTime
,
PeriodType
.
days
()).
getDays
();
int
days
=
new
Period
(
dto
.
getStartTime
(),
dto
.
getEndTime
()
,
PeriodType
.
days
()).
getDays
();
days
=
0
==
days
?
1
:
days
;
double
avg
=
total
==
0
?
0
d
:
total
/
(
double
)
days
;
overview
.
put
(
"avg"
,
avg
);
// 项目均值
String
key
=
RedisUtil
.
getYuqingAnalyzePlatformAvgCountKey
(
projectId
,
Constant
.
PRIMARY_CONTEND_ID
,
planId
);
String
key
=
RedisUtil
.
getYuqingAnalyzePlatformAvgCountKey
(
projectId
,
Constant
.
PRIMARY_CONTEND_ID
,
dto
.
getPlanId
()
);
double
projectAvg
=
Objects
.
isNull
(
redisUtil
.
get
(
key
))
?
0
d
:
Double
.
parseDouble
(
redisUtil
.
get
(
key
));
overview
.
put
(
"compare"
,
compare
(
avg
,
projectAvg
));
res
.
put
(
"overview"
,
overview
);
...
...
@@ -2532,9 +2561,9 @@ public class MarkDataServiceImpl implements MarkDataService {
}
@Override
public
List
<
JSONObject
>
ge
tPlatformPercentage
(
Long
startTime
,
Long
endTime
,
String
planId
)
{
public
List
<
JSONObject
>
ge
AnalyzePlatformPercentage
(
MarkSearchDTO
dto
)
{
try
{
return
getPlatformPercentage
(
null
,
startTime
,
endTime
,
planId
);
return
getPlatformPercentage
(
dto
);
}
catch
(
Exception
e
){
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"新舆情分析getPlatformPercentage异常-"
,
e
);
}
...
...
@@ -2543,22 +2572,19 @@ public class MarkDataServiceImpl implements MarkDataService {
/**
* 获取舆情分析平台分布
* @param aggTitle
* @param startTime
* @param endTime
* @param planId
* @param dto 标注数据搜索传输类
* @return
* @throws IOException
*/
private
List
<
JSONObject
>
getPlatformPercentage
(
String
aggTitle
,
Long
startTime
,
Long
endTime
,
String
planId
)
throws
IOException
{
List
<
String
>
platforms
=
commonService
.
getQbjcPlatformNames
();
private
List
<
JSONObject
>
getPlatformPercentage
(
MarkSearchDTO
dto
)
throws
IOException
{
List
<
String
>
platforms
=
commonService
.
getQbjcPlatform
().
stream
().
map
(
jsonObject
->
jsonObject
.
getString
(
"id"
)).
collect
(
Collectors
.
toList
());
dto
.
setPlatforms
(
platforms
);
List
<
JSONObject
>
list
=
new
ArrayList
<>();
// query
BoolQueryBuilder
query
=
yuqingAnalyzeQuery
(
startTime
,
endTime
,
null
,
planId
,
null
,
null
,
aggTitle
);
// total
Long
total
=
esClientDao
.
count
(
query
);
dto
.
setProjectId
(
UserThreadLocal
.
getProjectId
());
Long
total
=
getYuqingAnalyzeCount
(
dto
);
// 平台聚合
SearchResponse
searchResponse
=
platformAggSearchResponse
(
startTime
,
endTime
,
planId
,
platforms
,
aggTitle
);
SearchResponse
searchResponse
=
platformAggSearchResponse
(
dto
);
Map
<
String
,
Aggregation
>
aggMap
=
searchResponse
.
getAggregations
().
asMap
();
ParsedStringTerms
teamAgg
=
(
ParsedStringTerms
)
aggMap
.
get
(
"platform_count"
);
List
<?
extends
Terms
.
Bucket
>
buckets
=
teamAgg
.
getBuckets
();
...
...
@@ -2582,67 +2608,66 @@ public class MarkDataServiceImpl implements MarkDataService {
/**
* 平台聚合查询
* @param startTime
* @param endTime
* @param planId
* @param platforms
* @param dto 标注数据搜索传输类
* @return
* @throws IOException
*/
private
SearchResponse
platformAggSearchResponse
(
Long
startTime
,
Long
endTime
,
String
planId
,
List
<
String
>
platforms
,
String
aggTitle
)
throws
IOException
{
private
SearchResponse
platformAggSearchResponse
(
MarkSearchDTO
dto
)
throws
IOException
{
// 索引
String
[]
indexes
=
esClientDao
.
getIndexes
();
// 聚合请求
TermsAggregationBuilder
platformAggregationBuilder
=
AggregationBuilders
.
terms
(
"platform_count"
).
field
(
"platform_id"
).
order
(
BucketOrder
.
count
(
false
));
// query
BoolQueryBuilder
query
;
if
(
Objects
.
isNull
(
aggTitle
)){
query
=
yuqingAnalyzeQuery
(
startTime
,
endTime
,
planId
,
null
,
platforms
);
}
else
{
query
=
yuqingAnalyzeQuery
(
startTime
,
endTime
,
null
,
planId
,
null
,
null
,
aggTitle
);
}
BoolQueryBuilder
query
=
yuqingAnalyzeQuery
(
dto
);
return
esClientDao
.
searchResponse
(
indexes
,
null
,
query
,
platformAggregationBuilder
,
null
,
null
,
0
,
0
,
null
);
}
@Override
public
JSONObject
getSpreadTendency
(
Long
startTime
,
Long
endTime
,
String
planId
)
{
public
JSONObject
getSpreadTendency
(
MarkSearchDTO
dto
)
{
JSONObject
res
=
new
JSONObject
();
try
{
String
projectId
=
UserThreadLocal
.
getProjectId
();
Long
endTime
=
dto
.
getEndTime
();
String
planId
=
dto
.
getPlanId
();
dto
.
setProjectId
(
projectId
);
// 各平台趋势图
Map
<
String
,
List
<
LineVO
>>
platformSpreadTendency
=
getPlatformSpreadTendency
(
startTime
,
endTime
,
planId
);
Map
<
String
,
List
<
LineVO
>>
platformSpreadTendency
=
getPlatformSpreadTendency
(
dto
);
// 总趋势图
Pair
<
String
,
List
<
LineVO
>>
spreadTendency
=
get
SpreadTendency
(
startTime
,
endTime
,
planId
,
null
);
Pair
<
String
,
List
<
LineVO
>>
spreadTendency
=
get
EmotionSpreadTendency
(
dto
,
null
);
// 负面趋势图
Pair
<
String
,
List
<
LineVO
>>
negativeSpreadTendency
=
get
SpreadTendency
(
startTime
,
endTime
,
planId
,
EmotionEnum
.
NEGATIVE
.
getName
());
Pair
<
String
,
List
<
LineVO
>>
negativeSpreadTendency
=
get
EmotionSpreadTendency
(
dto
,
EmotionEnum
.
NEGATIVE
.
getName
());
Map
<
String
,
BaseMap
>
baseMaps
=
new
HashMap
<>(
2
);
BaseMap
totalBaseMaps
=
null
;
BaseMap
negativeBaseMaps
=
null
;
if
(
Objects
.
nonNull
(
negativeSpreadTendency
.
getLeft
())
&&
Objects
.
nonNull
(
spreadTendency
.
getLeft
()))
{
CompletableFuture
.
allOf
(
Stream
.
of
(
spreadTendency
.
getLeft
(),
negativeSpreadTendency
.
getLeft
()).
map
(
aggTitle
->
CompletableFuture
.
runAsync
(()
->
{
if
(
Objects
.
nonNull
(
negativeSpreadTendency
.
getLeft
())
||
Objects
.
nonNull
(
spreadTendency
.
getLeft
()))
{
CompletableFuture
.
allOf
(
Stream
.
of
(
spreadTendency
.
getLeft
(),
negativeSpreadTendency
.
getLeft
()).
filter
(
Objects:
:
nonNull
).
map
(
aggTitle
->
CompletableFuture
.
runAsync
(()
->
{
try
{
baseMaps
.
put
(
aggTitle
,
getFirstArticle
(
startTime
,
endTime
,
aggTitle
,
projectId
,
Constant
.
PRIMARY_CONTEND_ID
,
planId
,
true
));
dto
.
setAggTitle
(
aggTitle
);
baseMaps
.
put
(
aggTitle
,
getAnalyzeFirstArticle
(
dto
));
}
catch
(
IOException
ignored
)
{
}
},
executor
)).
toArray
(
CompletableFuture
[]::
new
)).
join
();
}
//
趋势图标题
为空,此时说明最高点的时间段发文平台全为微博,此时取最高点时间段内时间最早的微博发文
if
(
Objects
.
isNull
(
spreadTendency
.
getLeft
())
||
Objects
.
isNull
(
negativeSpreadTendency
.
getLef
t
())){
//
标题为空,但趋势图不
为空,此时说明最高点的时间段发文平台全为微博,此时取最高点时间段内时间最早的微博发文
if
(
Objects
.
isNull
(
spreadTendency
.
getLeft
())
&&
CollectionUtils
.
isNotEmpty
(
spreadTendency
.
getRigh
t
())){
totalBaseMaps
=
getWeiboFirstArticle
(
endTime
,
spreadTendency
.
getRight
(),
planId
,
projectId
,
null
);
}
if
(
Objects
.
isNull
(
negativeSpreadTendency
.
getLeft
())
&&
CollectionUtils
.
isNotEmpty
(
negativeSpreadTendency
.
getRight
())){
negativeBaseMaps
=
getWeiboFirstArticle
(
endTime
,
spreadTendency
.
getRight
(),
planId
,
projectId
,
EmotionEnum
.
NEGATIVE
.
getName
());
}
// 最高点
BaseMap
baseMap
=
Objects
.
isNull
(
baseMaps
.
get
(
spreadTendency
.
getLeft
()))
?
totalBaseMaps
:
baseMaps
.
get
(
spreadTendency
.
getLeft
());
JSONObject
highestJson
=
new
JSONObject
();
if
(
Objects
.
nonNull
(
baseMap
))
{
highestJson
.
put
(
"title"
,
baseMap
.
getTitle
());
highestJson
.
put
(
"title"
,
Tools
.
filterUselessTitle
(
baseMap
.
getTitle
())
?
StringUtils
.
substring
(
baseMap
.
getContent
(),
0
,
15
)
:
baseMap
.
getTitle
());
highestJson
.
put
(
"url"
,
baseMap
.
getUrl
());
}
// 负面最高点
BaseMap
negativeBaseMap
=
Objects
.
isNull
(
baseMaps
.
get
(
negativeSpreadTendency
.
getLeft
()))
?
negativeBaseMaps
:
baseMaps
.
get
(
negativeSpreadTendency
.
getLeft
());
JSONObject
negativeHighestJson
=
new
JSONObject
();
if
(
Objects
.
nonNull
(
negativeBaseMap
))
{
negativeHighestJson
.
put
(
"title"
,
negativeBaseMap
.
getTitle
());
negativeHighestJson
.
put
(
"title"
,
Tools
.
filterUselessTitle
(
negativeBaseMap
.
getTitle
())
?
StringUtils
.
substring
(
negativeBaseMap
.
getContent
(),
0
,
15
)
:
negativeBaseMap
.
getTitle
());
negativeHighestJson
.
put
(
"url"
,
negativeBaseMap
.
getUrl
());
}
res
.
putAll
(
platformSpreadTendency
);
...
...
@@ -2705,15 +2730,16 @@ public class MarkDataServiceImpl implements MarkDataService {
}
@Override
public
List
<
JSONObject
>
getActiveChannels
(
Long
startTime
,
Long
endTime
,
String
planId
)
{
public
List
<
JSONObject
>
getActiveChannels
(
MarkSearchDTO
dto
)
{
List
<
JSONObject
>
list
=
new
ArrayList
<>();
try
{
dto
.
setProjectId
(
UserThreadLocal
.
getProjectId
());
// 索引
String
[]
indexes
=
esClientDao
.
getIndexes
();
// query
BoolQueryBuilder
query
=
yuqingAnalyzeQuery
(
startTime
,
endTime
,
planId
,
null
,
null
);
BoolQueryBuilder
query
=
yuqingAnalyzeQuery
(
dto
);
// 渠道聚合,取前20
TermsAggregationBuilder
sourceAggregationBuilder
=
AggregationBuilders
.
terms
(
"source_count"
).
field
(
"source"
).
order
(
BucketOrder
.
count
(
false
)).
size
(
20
);
TermsAggregationBuilder
sourceAggregationBuilder
=
AggregationBuilders
.
terms
(
"source_count"
).
field
(
"source"
).
order
(
BucketOrder
.
count
(
false
)).
size
(
20
+
Tools
.
FILTER_SOURCE
.
size
()
);
// 情感倾向子聚合
TermsAggregationBuilder
emotionAggregationBuilder
=
AggregationBuilders
.
terms
(
"emotion_count"
).
field
(
"brandkbs_mark_cache_maps.name.keyword"
);
SearchResponse
searchResponse
=
esClientDao
.
searchResponse
(
indexes
,
null
,
query
,
...
...
@@ -2721,15 +2747,20 @@ public class MarkDataServiceImpl implements MarkDataService {
Map
<
String
,
Aggregation
>
aggMap
=
searchResponse
.
getAggregations
().
asMap
();
ParsedStringTerms
sourceCountTeam
=
(
ParsedStringTerms
)
aggMap
.
get
(
"source_count"
);
List
<?
extends
Terms
.
Bucket
>
buckets
=
sourceCountTeam
.
getBuckets
();
buckets
.
forEach
(
bucket
->
{
for
(
Terms
.
Bucket
bucket
:
buckets
)
{
JSONObject
jsonObject
=
new
JSONObject
();
Map
<
String
,
Aggregation
>
map
=
bucket
.
getAggregations
().
asMap
();
ParsedStringTerms
countTeam
=
(
ParsedStringTerms
)
map
.
get
(
"emotion_count"
);
List
<?
extends
Terms
.
Bucket
>
bucketList
=
countTeam
.
getBuckets
();
jsonObject
.
put
(
"source"
,
bucket
.
getKeyAsString
());
String
source
=
bucket
.
getKeyAsString
();
// 过滤渠道名:”匿名“
if
(
Tools
.
filterUselessSource
(
source
)){
continue
;
}
jsonObject
.
put
(
"source"
,
source
);
// 发文次数
jsonObject
.
put
(
"count"
,
bucket
.
getDocCount
());
// 负面发文次数
ParsedStringTerms
countTeam
=
(
ParsedStringTerms
)
map
.
get
(
"emotion_count"
);
List
<?
extends
Terms
.
Bucket
>
bucketList
=
countTeam
.
getBuckets
();
AtomicLong
negativeCount
=
new
AtomicLong
();
bucketList
.
forEach
(
data
->
{
if
(
Objects
.
equals
(
data
.
getKeyAsString
(),
EmotionEnum
.
NEGATIVE
.
getName
()))
{
...
...
@@ -2738,23 +2769,24 @@ public class MarkDataServiceImpl implements MarkDataService {
});
jsonObject
.
put
(
"negativeCount"
,
negativeCount
.
get
());
list
.
add
(
jsonObject
);
}
);
}
}
catch
(
Exception
e
){
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"新舆情分析getActiveChannels异常-"
,
e
);
}
return
list
;
return
list
.
stream
().
limit
(
20
).
collect
(
Collectors
.
toList
())
;
}
@Override
public
List
<
JSONObject
>
getArticleIpLocated
(
Long
startTime
,
Long
endTime
,
String
planId
,
int
size
)
{
public
List
<
JSONObject
>
getArticleIpLocated
(
MarkSearchDTO
dto
)
{
List
<
JSONObject
>
list
=
new
ArrayList
<>();
try
{
// 索引
String
[]
indexes
=
esClientDao
.
getIndexes
();
dto
.
setProjectId
(
UserThreadLocal
.
getProjectId
());
// query
BoolQueryBuilder
query
=
yuqingAnalyzeQuery
(
startTime
,
endTime
,
planId
,
null
,
null
);
BoolQueryBuilder
query
=
yuqingAnalyzeQuery
(
dto
);
// 聚合请求
TermsAggregationBuilder
ipAggregationBuilder
=
AggregationBuilders
.
terms
(
"ip_count"
).
field
(
"ip_location.keyword"
).
order
(
BucketOrder
.
count
(
false
)).
size
(
size
);
TermsAggregationBuilder
ipAggregationBuilder
=
AggregationBuilders
.
terms
(
"ip_count"
).
field
(
"ip_location.keyword"
).
order
(
BucketOrder
.
count
(
false
)).
size
(
10
);
// 情感倾向子聚合
TermsAggregationBuilder
emotionAggregationBuilder
=
AggregationBuilders
.
terms
(
"emotion_count"
).
field
(
"brandkbs_mark_cache_maps.name.keyword"
);
SearchResponse
searchResponse
=
esClientDao
.
searchResponse
(
indexes
,
null
,
query
,
...
...
@@ -2793,29 +2825,57 @@ public class MarkDataServiceImpl implements MarkDataService {
// 列表数据最小mgid
MarkFlowEntity
markFlowEntity
=
yuqingMarkList
.
getList
().
stream
()
.
min
(
Comparator
.
comparingLong
(
entity
->
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
entity
.
getData
())).
getLongValue
(
"mgid"
))).
orElse
(
null
);
// yuqingMarkList.getInfo().put("stime", Objects.isNull(markFlowEntity) ? Long.MAX_VALUE : JSONObject.parseObject(JSONObject.toJSONString(markFlowEntity.getData())).getLongValue("stime"));
yuqingMarkList
.
getInfo
().
put
(
"pageGid"
,
Objects
.
isNull
(
markFlowEntity
)
?
Long
.
MAX_VALUE
:
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
markFlowEntity
.
getData
())).
getLongValue
(
"mgid"
));
return
yuqingMarkList
;
}
@Override
public
List
<
JSONObject
>
getHighWord
(
Long
startTime
,
Long
endTime
,
String
planId
,
boolean
cache
)
{
public
void
cacheHighWord
(
Long
startTime
,
Long
endTime
,
String
planId
,
boolean
cache
)
{
getAnalyzeHighWord
(
convertedToMarkSearch
(
null
,
startTime
,
endTime
,
planId
),
cache
);
}
@Override
public
List
<
JSONObject
>
getAnalyzeHighWord
(
MarkSearchDTO
dto
,
boolean
cache
)
{
String
projectId
=
UserThreadLocal
.
getProjectId
();
dto
.
setProjectId
(
projectId
);
String
redisKey
=
RedisUtil
.
getYuqingAnalyzeHighWordKey
(
projectId
,
Constant
.
PRIMARY_CONTEND_ID
,
dto
.
getPlanId
(),
dto
.
getStartTime
(),
dto
.
getEndTime
());
String
resultStr
;
// 返回缓存
if
(
cache
&&
StringUtils
.
isNotEmpty
(
resultStr
=
redisUtil
.
get
(
redisKey
)))
{
return
JSONArray
.
parseArray
(
resultStr
,
JSONObject
.
class
);
}
List
<
JSONObject
>
res
=
generateHighWord
(
dto
);
redisUtil
.
setExpire
(
redisKey
,
JSONArray
.
toJSONString
(
res
));
return
res
;
}
@Override
public
List
<
JSONObject
>
getSearchAnalyzeHighWord
(
MarkSearchDTO
dto
)
{
dto
.
setProjectId
(
UserThreadLocal
.
getProjectId
());
MarkSearchAnalyzeTask
existTask
=
markSearchAnalyzeTaskDao
.
findOne
(
"markSearchDTO"
,
dto
);
if
(
Objects
.
nonNull
(
existTask
)){
return
existTask
.
getHighWord
();
}
MarkSearchAnalyzeTask
task
=
new
MarkSearchAnalyzeTask
(
dto
,
null
,
false
,
System
.
currentTimeMillis
());
markSearchAnalyzeTaskDao
.
insertOne
(
task
);
List
<
JSONObject
>
highWord
=
generateHighWord
(
dto
);
Update
update
=
new
Update
();
update
.
set
(
"finish"
,
true
);
update
.
set
(
"highWord"
,
highWord
);
markSearchAnalyzeTaskDao
.
updateOneByIdWithField
(
task
.
getId
(),
update
);
return
highWord
;
}
private
List
<
JSONObject
>
generateHighWord
(
MarkSearchDTO
dto
){
List
<
JSONObject
>
res
=
new
ArrayList
<>();
try
{
String
projectId
=
UserThreadLocal
.
getProjectId
();
String
redisKey
=
RedisUtil
.
getYuqingAnalyzeHighWordKey
(
projectId
,
Constant
.
PRIMARY_CONTEND_ID
,
planId
,
startTime
,
endTime
);
String
resultStr
;
// 返回缓存
if
(
cache
&&
StringUtils
.
isNotEmpty
(
resultStr
=
redisUtil
.
get
(
redisKey
)))
{
return
JSONArray
.
parseArray
(
resultStr
,
JSONObject
.
class
);
}
EsClientDao
.
SearchHelper
searchHelper
=
EsClientDao
.
createSearchHelper
();
// sort
searchHelper
.
setSort
(
SortBuilders
.
fieldSort
(
"time"
).
order
(
SortOrder
.
DESC
));
// fetchSource
searchHelper
.
setFetchSource
(
new
String
[]{
"ind_title"
,
"ind_full_text"
,
"c5"
,
"foreign"
,
"brandkbs_mark_cache_maps"
});
// postFilter
BoolQueryBuilder
postFilter
=
yuqingAnalyzeQuery
(
startTime
,
endTime
,
planId
,
null
,
null
);
BoolQueryBuilder
postFilter
=
yuqingAnalyzeQuery
(
dto
);
searchHelper
.
setPostFilter
(
postFilter
);
searchHelper
.
setSize
(
10000
);
List
<
String
>
textList
=
new
ArrayList
<>();
...
...
@@ -2830,7 +2890,6 @@ public class MarkDataServiceImpl implements MarkDataService {
}
}
res
=
textUtil
.
getHighWordsJsonDifferentFieldName
(
textList
,
20
);
redisUtil
.
setExpire
(
redisKey
,
JSONArray
.
toJSONString
(
res
));
}
catch
(
Exception
e
){
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"新舆情分析getHighWord异常-"
,
e
);
}
...
...
@@ -2838,13 +2897,19 @@ public class MarkDataServiceImpl implements MarkDataService {
}
@Override
public
List
<
JSONObject
>
getLastNews
(
Long
startTime
,
Long
endTime
,
String
planId
,
int
size
,
boolean
include
)
{
public
List
<
JSONObject
>
getLastNews
(
Long
startTime
,
Long
endTime
,
int
size
)
{
return
getLastNews
(
convertedToMarkSearch
(
null
,
startTime
,
endTime
,
null
),
size
);
}
@Override
public
List
<
JSONObject
>
getLastNews
(
MarkSearchDTO
dto
,
int
size
)
{
String
projectId
=
UserThreadLocal
.
getProjectId
();
try
{
List
<
JSONObject
>
markTopTitleList
=
getMarkTopTitle
(
startTime
,
endTime
,
null
,
projectId
,
Constant
.
PRIMARY_CONTEND_ID
,
planId
,
size
);
dto
.
setProjectId
(
projectId
);
List
<
JSONObject
>
markTopTitleList
=
getMarkTopTitle
(
dto
,
size
);
CompletableFuture
.
allOf
(
markTopTitleList
.
stream
().
map
(
json
->
CompletableFuture
.
supplyAsync
(()
->
{
try
{
BaseMap
firstArticle
=
get
FirstArticle
(
startTime
,
endTime
,
json
.
getString
(
"title"
),
projectId
,
Constant
.
PRIMARY_CONTEND_ID
,
planId
,
include
);
BaseMap
firstArticle
=
get
AnalyzeFirstArticle
(
dto
);
json
.
put
(
"content"
,
firstArticle
.
getContent
());
json
.
put
(
"url"
,
firstArticle
.
getUrl
());
json
.
put
(
"realSource"
,
firstArticle
.
getRealSource
());
...
...
@@ -2863,14 +2928,20 @@ public class MarkDataServiceImpl implements MarkDataService {
@Override
public
JSONObject
getAggTitleBaseInfo
(
String
aggTitle
,
Long
startTime
,
Long
endTime
,
String
planId
)
{
return
getAggTitleBaseInfo
(
convertedToMarkSearch
(
aggTitle
,
startTime
,
endTime
,
planId
));
}
@Override
public
JSONObject
getAggTitleBaseInfo
(
MarkSearchDTO
dto
)
{
JSONObject
res
=
new
JSONObject
();
try
{
String
projectId
=
UserThreadLocal
.
getProjectId
();
dto
.
setProjectId
(
projectId
);
String
linkedGroupId
=
projectService
.
getProjectById
(
projectId
).
getBrandLinkedGroupId
();
CompletableFuture
<
JSONObject
>
firstArticleFuture
=
CompletableFuture
.
supplyAsync
(()
->
{
try
{
// 最早发布
BaseMap
firstArticle
=
get
FirstArticle
(
startTime
,
endTime
,
aggTitle
,
projectId
,
Constant
.
PRIMARY_CONTEND_ID
,
planId
,
true
);
BaseMap
firstArticle
=
get
AnalyzeFirstArticle
(
dto
);
// 匹配重要渠道
JSONObject
firstSensitiveChannel
=
channelService
.
matchYuQingSensitiveChannel
(
linkedGroupId
,
firstArticle
.
getSource
());
JSONObject
firstArticleJson
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
firstArticle
));
...
...
@@ -2883,7 +2954,7 @@ public class MarkDataServiceImpl implements MarkDataService {
CompletableFuture
<
JSONObject
>
lastArticleFuture
=
CompletableFuture
.
supplyAsync
(()
->
{
try
{
// 最新发布
BaseMap
lastArticle
=
get
LastArticle
(
startTime
,
endTime
,
aggTitle
,
projectId
,
Constant
.
PRIMARY_CONTEND_ID
,
planId
,
true
);
BaseMap
lastArticle
=
get
AnalyzeLastArticle
(
dto
);
// 匹配重要渠道
JSONObject
lastSensitiveChannel
=
channelService
.
matchYuQingSensitiveChannel
(
linkedGroupId
,
lastArticle
.
getSource
());
JSONObject
lastArticleJson
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
lastArticle
));
...
...
@@ -2909,11 +2980,17 @@ public class MarkDataServiceImpl implements MarkDataService {
@Override
public
List
<
JSONObject
>
getAggTitleArticlePoints
(
String
aggTitle
,
Long
startTime
,
Long
endTime
,
String
planId
)
{
return
getAggTitleArticlePoints
(
convertedToMarkSearch
(
aggTitle
,
startTime
,
endTime
,
planId
));
}
@Override
public
List
<
JSONObject
>
getAggTitleArticlePoints
(
MarkSearchDTO
dto
)
{
List
<
JSONObject
>
jsonObject
=
new
ArrayList
<>();
try
{
String
[]
indexes
=
esClientDao
.
getIndexes
();
// query
BoolQueryBuilder
query
=
yuqingAnalyzeQuery
(
startTime
,
endTime
,
null
,
planId
,
null
,
null
,
aggTitle
);
dto
.
setProjectId
(
UserThreadLocal
.
getProjectId
());
BoolQueryBuilder
query
=
yuqingAnalyzeQuery
(
dto
);
DateHistogramAggregationBuilder
daysAggregationBuilder
=
AggregationBuilders
.
dateHistogram
(
"timeAgg"
).
field
(
"time"
).
calendarInterval
(
DateHistogramInterval
.
DAY
);
TermsAggregationBuilder
sourceAggregationBuilder
=
AggregationBuilders
.
terms
(
"sourceAgg"
).
field
(
"source"
).
size
(
10000
);
...
...
@@ -2958,8 +3035,13 @@ public class MarkDataServiceImpl implements MarkDataService {
@Override
public
List
<
JSONObject
>
getAggTitlePlatformPercentage
(
String
aggTitle
,
Long
startTime
,
Long
endTime
,
String
planId
)
{
return
getAggTitlePlatformPercentage
(
convertedToMarkSearch
(
aggTitle
,
startTime
,
endTime
,
planId
));
}
@Override
public
List
<
JSONObject
>
getAggTitlePlatformPercentage
(
MarkSearchDTO
dto
)
{
try
{
return
getPlatformPercentage
(
aggTitle
,
startTime
,
endTime
,
planId
);
return
getPlatformPercentage
(
dto
);
}
catch
(
Exception
e
){
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"新舆情分析getAggTitlePlatformPercentage异常-"
,
e
);
}
...
...
@@ -2968,15 +3050,31 @@ public class MarkDataServiceImpl implements MarkDataService {
@Override
public
PageVO
<
JSONObject
>
getArticleList
(
String
aggTitle
,
Long
startTime
,
Long
endTime
,
String
planId
,
String
platform
,
int
page
,
int
pageSize
)
{
MarkSearchDTO
dto
=
convertedToMarkSearch
(
aggTitle
,
startTime
,
endTime
,
planId
);
dto
.
setPlatforms
(
Collections
.
singletonList
(
platform
));
dto
.
setPage
(
page
);
dto
.
setPageSize
(
pageSize
);
return
getArticleList
(
dto
);
}
@Override
public
PageVO
<
JSONObject
>
getArticleList
(
MarkSearchDTO
dto
)
{
int
page
=
Objects
.
isNull
(
dto
.
getPage
())
?
1
:
dto
.
getPage
();
int
pageSize
=
Objects
.
isNull
(
dto
.
getPageSize
())
?
10
:
dto
.
getPageSize
();
try
{
String
[]
indexes
=
esClientDao
.
getIndexes
();
dto
.
setProjectId
(
UserThreadLocal
.
getProjectId
());
// query
BoolQueryBuilder
query
=
yuqingAnalyzeQuery
(
startTime
,
endTime
,
null
,
planId
,
null
,
Collections
.
singletonList
(
platform
),
aggTitle
);
if
(
Objects
.
equals
(
"其他"
,
platform
)){
List
<
String
>
platforms
=
getPlatformPercentage
(
aggTitle
,
startTime
,
endTime
,
planId
).
stream
().
map
(
json
->
json
.
getString
(
"platform"
)).
collect
(
Collectors
.
toList
());
if
(
Objects
.
nonNull
(
dto
.
getPlatforms
())
&&
Objects
.
nonNull
(
dto
.
getPlatforms
().
get
(
0
))){
dto
.
setPlatforms
(
Collections
.
singletonList
(
GlobalPojo
.
getPlatformIdByName
(
dto
.
getPlatforms
().
get
(
0
))));
}
BoolQueryBuilder
query
=
yuqingAnalyzeQuery
(
dto
);
if
(
Objects
.
equals
(
"其他"
,
dto
.
getPlatforms
().
get
(
0
))){
List
<
String
>
platforms
=
getPlatformPercentage
(
dto
).
stream
().
map
(
json
->
json
.
getString
(
"platform"
)).
collect
(
Collectors
.
toList
());
List
<
String
>
allPlatforms
=
GlobalPojo
.
PLATFORMS
.
stream
().
map
(
MessagePlatform:
:
getName
).
collect
(
Collectors
.
toList
());
allPlatforms
.
removeAll
(
platforms
);
query
=
yuqingAnalyzeQuery
(
startTime
,
endTime
,
null
,
planId
,
null
,
allPlatforms
,
aggTitle
);
dto
.
setPlatforms
(
allPlatforms
.
stream
().
map
(
GlobalPojo:
:
getPlatformIdByName
).
collect
(
Collectors
.
toList
()));
query
=
yuqingAnalyzeQuery
(
dto
);
}
// sort
FieldSortBuilder
sort
=
SortBuilders
.
fieldSort
(
"time"
).
order
(
SortOrder
.
DESC
);
...
...
@@ -3000,33 +3098,43 @@ public class MarkDataServiceImpl implements MarkDataService {
return
PageVO
.
createPageVo
(
0
,
page
,
pageSize
,
Collections
.
emptyList
());
}
private
MarkSearchDTO
convertedToMarkSearch
(
String
aggTitle
,
Long
startTime
,
Long
endTime
,
String
planId
){
MarkSearchDTO
dto
=
new
MarkSearchDTO
();
dto
.
setAggTitle
(
aggTitle
);
dto
.
setStartTime
(
startTime
);
dto
.
setEndTime
(
endTime
);
dto
.
setPlanId
(
planId
);
return
dto
;
}
/**
* 微博、微信、抖音、小红书平台趋势图
* @param startTime
* @param endTime
* @param planId
* @param dto
* @return
* @throws IOException
*/
private
Map
<
String
,
List
<
LineVO
>>
getPlatformSpreadTendency
(
Long
startTime
,
Long
endTime
,
String
planId
)
throws
IOException
{
private
Map
<
String
,
List
<
LineVO
>>
getPlatformSpreadTendency
(
MarkSearchDTO
dto
)
throws
IOException
{
Map
<
String
,
List
<
LineVO
>>
res
=
new
HashMap
<>(
4
);
// 平台
List
<
String
>
platforms
=
Arrays
.
asList
(
"微博"
,
"微信"
,
"抖音"
,
"小红书"
);
List
<
String
>
platforms
=
new
ArrayList
<>();
for
(
String
platformNames
:
Arrays
.
asList
(
"微博"
,
"微信"
,
"抖音"
,
"小红书"
))
{
platforms
.
add
(
GlobalPojo
.
getPlatformIdByName
(
platformNames
));
}
String
[]
indexes
=
esClientDao
.
getIndexes
();
// 聚合请求
TermsAggregationBuilder
platformAggregationBuilder
=
AggregationBuilders
.
terms
(
"platformAgg"
).
field
(
"platform_id"
).
order
(
BucketOrder
.
count
(
false
));
DateHistogramAggregationBuilder
daysAggregationBuilder
;
// 天级以小时为颗粒度,其他以天作为颗粒度
if
(
endTime
-
startTime
<=
Constant
.
ONE_DAY
){
if
(
dto
.
getEndTime
()
-
dto
.
getStartTime
()
<=
Constant
.
ONE_DAY
){
daysAggregationBuilder
=
AggregationBuilders
.
dateHistogram
(
"timeAgg"
).
field
(
"time"
).
calendarInterval
(
DateHistogramInterval
.
HOUR
);
}
else
{
daysAggregationBuilder
=
AggregationBuilders
.
dateHistogram
(
"timeAgg"
).
field
(
"time"
).
calendarInterval
(
DateHistogramInterval
.
DAY
);
}
dto
.
setPlatforms
(
platforms
);
// query
BoolQueryBuilder
query
=
yuqingAnalyzeQuery
(
startTime
,
endTime
,
planId
,
null
,
platforms
);
BoolQueryBuilder
query
=
yuqingAnalyzeQuery
(
dto
);
// response
SearchResponse
searchResponse
=
esClientDao
.
searchResponse
(
indexes
,
null
,
query
,
platformAggregationBuilder
.
subAggregation
(
daysAggregationBuilder
),
null
,
null
,
0
,
0
,
null
);
SearchResponse
searchResponse
=
esClientDao
.
searchResponse
(
indexes
,
null
,
query
,
platformAggregationBuilder
.
subAggregation
(
daysAggregationBuilder
),
null
,
null
,
0
,
0
,
null
);
Map
<
String
,
Aggregation
>
map
=
searchResponse
.
getAggregations
().
asMap
();
ParsedStringTerms
countTeam
=
(
ParsedStringTerms
)
map
.
get
(
"platformAgg"
);
List
<?
extends
Terms
.
Bucket
>
platformBuckets
=
countTeam
.
getBuckets
();
...
...
@@ -3048,26 +3156,24 @@ public class MarkDataServiceImpl implements MarkDataService {
/**
* 新舆情分析-舆情趋势图
* @param startTime
* @param endTime
* @param planId
* @param emotion
* @param dto 标注数据搜索传输类
* @return
* @throws IOException
*/
private
Pair
<
String
,
List
<
LineVO
>>
get
SpreadTendency
(
Long
startTime
,
Long
endTime
,
String
planId
,
String
emotion
)
throws
IOException
{
private
Pair
<
String
,
List
<
LineVO
>>
get
EmotionSpreadTendency
(
MarkSearchDTO
dto
,
String
emotion
)
throws
IOException
{
List
<
LineVO
>
res
=
new
ArrayList
<>();
String
[]
indexes
=
esClientDao
.
getIndexes
();
DateHistogramAggregationBuilder
daysAggregationBuilder
;
// 天级以小时为颗粒度,其他以天作为颗粒度
if
(
endTime
-
startTime
<=
Constant
.
ONE_DAY
){
if
(
dto
.
getEndTime
()
-
dto
.
getStartTime
()
<=
Constant
.
ONE_DAY
){
daysAggregationBuilder
=
AggregationBuilders
.
dateHistogram
(
"timeAgg"
).
field
(
"time"
).
calendarInterval
(
DateHistogramInterval
.
HOUR
);
}
else
{
daysAggregationBuilder
=
AggregationBuilders
.
dateHistogram
(
"timeAgg"
).
field
(
"time"
).
calendarInterval
(
DateHistogramInterval
.
DAY
);
}
TermsAggregationBuilder
titleAggregationBuilder
=
AggregationBuilders
.
terms
(
"titleAgg"
).
field
(
"agg_title.keyword"
).
order
(
BucketOrder
.
count
(
false
));
dto
.
setPlatforms
(
null
);
// query
BoolQueryBuilder
query
=
yuqingAnalyzeQuery
(
startTime
,
endTime
,
planId
,
emotion
,
null
);
BoolQueryBuilder
query
=
yuqingAnalyzeQuery
(
dto
,
emotion
);
// response
SearchResponse
searchResponse
=
esClientDao
.
searchResponse
(
indexes
,
null
,
query
,
daysAggregationBuilder
.
subAggregation
(
titleAggregationBuilder
),
null
,
null
,
0
,
0
,
null
);
...
...
@@ -3093,13 +3199,13 @@ public class MarkDataServiceImpl implements MarkDataService {
return
Pair
.
of
(
maxAggTitle
,
res
);
}
private
Long
getYuqingAnalyzeCount
(
Long
startTime
,
Long
endTime
,
String
planId
,
List
<
String
>
platforms
)
throws
IOException
{
BoolQueryBuilder
query
=
yuqingAnalyzeQuery
(
startTime
,
endTime
,
planId
,
null
,
platforms
);
private
Long
getYuqingAnalyzeCount
(
MarkSearchDTO
dto
)
throws
IOException
{
BoolQueryBuilder
query
=
yuqingAnalyzeQuery
(
dto
,
null
);
return
esClientDao
.
count
(
query
);
}
private
Long
getYuqingAnalyzeCount
(
Long
startTime
,
Long
endTime
,
String
planId
,
String
emotion
)
throws
IOException
{
BoolQueryBuilder
query
=
yuqingAnalyzeQuery
(
startTime
,
endTime
,
planId
,
emotion
,
null
);
private
Long
getYuqingAnalyzeCount
(
MarkSearchDTO
dto
,
String
emotion
)
throws
IOException
{
BoolQueryBuilder
query
=
yuqingAnalyzeQuery
(
dto
,
emotion
);
return
esClientDao
.
count
(
query
);
}
...
...
@@ -3108,10 +3214,6 @@ public class MarkDataServiceImpl implements MarkDataService {
return
esClientDao
.
count
(
query
);
}
private
BoolQueryBuilder
yuqingAnalyzeQuery
(
Long
startTime
,
Long
endTime
,
String
planId
,
String
emotion
,
List
<
String
>
platforms
){
return
yuqingAnalyzeQuery
(
startTime
,
endTime
,
null
,
planId
,
emotion
,
platforms
,
null
);
}
private
BoolQueryBuilder
yuqingAnalyzeQuery
(
Long
startTime
,
Long
endTime
,
String
projectId
,
String
planId
,
String
emotion
,
List
<
String
>
platforms
,
String
aggTitle
){
if
(
Objects
.
isNull
(
projectId
))
{
projectId
=
UserThreadLocal
.
getProjectId
();
...
...
@@ -3148,6 +3250,71 @@ public class MarkDataServiceImpl implements MarkDataService {
}
return
query
;
}
private
BoolQueryBuilder
yuqingAnalyzeQuery
(
MarkSearchDTO
dto
){
return
yuqingAnalyzeQuery
(
dto
,
null
);
}
private
BoolQueryBuilder
yuqingAnalyzeQuery
(
MarkSearchDTO
dto
,
String
emotion
){
// projectId、contendId
String
projectId
=
dto
.
getProjectId
();
String
contendId
=
dto
.
getContendId
();
// PostFilter 后置过滤器
// 新增channelEmotion
BoolQueryBuilder
postFilter
=
EsQueryTools
.
assembleCacheMapsQuery
(
projectId
,
contendId
,
dto
.
getPoliticsLevel
(),
dto
.
getField
(),
dto
.
getRegion
(),
dto
.
getMainBodyType
(),
dto
.
getChannelEmotion
());
if
(
Objects
.
nonNull
(
dto
.
getPlanId
())){
postFilter
=
EsQueryTools
.
assembleCacheMapsPlanQuery
(
projectId
,
dto
.
getPlanId
());
}
// time
postFilter
.
must
(
QueryBuilders
.
rangeQuery
(
"time"
).
gte
(
dto
.
getStartTime
()).
lt
(
dto
.
getEndTime
()));
// platform
if
(
CollectionUtils
.
isNotEmpty
(
dto
.
getPlatforms
()))
{
postFilter
.
must
(
EsQueryTools
.
assemblePlatformQuery
(
Tools
.
getPlatformByIds
(
dto
.
getPlatforms
())));
}
// tags
if
(
CollectionUtils
.
isNotEmpty
(
dto
.
getTags
()))
{
postFilter
.
must
(
EsQueryTools
.
assembleTagQuery
(
dto
.
getTags
()));
}
// customTags
if
(
CollectionUtils
.
isNotEmpty
(
dto
.
getCustomTags
()))
{
postFilter
.
must
(
EsQueryTools
.
assembleTagQuery
(
dto
.
getCustomTags
()));
}
// Query 查询条件
String
[]
fieldSearch
=
"仅标题"
.
equals
(
dto
.
getSearchField
())
?
new
String
[]{
GenericAttribute
.
ES_IND_TITLE
}
:
new
String
[]{
GenericAttribute
.
ES_IND_FULL_TEXT
};
// keyword
if
(
StringUtils
.
isNotEmpty
(
dto
.
getKeyword
()))
{
// Query
postFilter
.
must
(
EsQueryTools
.
assembleNormalKeywordQuery
(
dto
.
getKeyword
(),
fieldSearch
));
}
// emotion
if
(
StringUtils
.
isNotEmpty
(
emotion
)
&&
!
EmotionEnum
.
ALL
.
getName
().
equals
(
emotion
))
{
postFilter
.
must
(
QueryBuilders
.
termQuery
(
"brandkbs_mark_cache_maps.name.keyword"
,
emotion
));
}
// shieldWord
if
(
StringUtils
.
isNotEmpty
(
dto
.
getShieldWord
()))
{
postFilter
.
mustNot
(
EsQueryTools
.
assembleNormalKeywordQuery
(
dto
.
getShieldWord
(),
fieldSearch
));
}
// sourceKeyword
if
(
StringUtils
.
isNotEmpty
(
dto
.
getSourceKeyword
()))
{
postFilter
.
must
(
EsQueryTools
.
assembleSourceQuery
(
dto
.
getSourceKeyword
()));
}
// hostKeyword
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
()));
}
// 聚合标题
if
(
Objects
.
nonNull
(
dto
.
getAggTitle
())){
postFilter
.
must
(
QueryBuilders
.
termQuery
(
"agg_title.keyword"
,
dto
.
getAggTitle
()));
}
return
postFilter
;
}
/**
* 获取最大的gid
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/ProjectWarnServiceImpl.java
View file @
6fe16ea2
...
...
@@ -302,89 +302,6 @@ public class ProjectWarnServiceImpl implements ProjectWarnService {
return
new
BrandkbsWarnTemplate
(
firstCount
,
key1
,
key2
,
key3
,
key4
,
new
BrandkbsYuQingWarn
(
collect
));
}
@Deprecated
private
BrandkbsWarnTemplate
brandkbsWarnTemplate4Yuqing
(
BrandkbsYuQingConfig
config
,
List
<
BaseMap
>
datas
,
long
start
,
long
end
,
AbstractProject
project
)
{
if
(
datas
.
isEmpty
())
{
return
null
;
}
int
firstCount
=
datas
.
size
();
// key1
String
key1
=
"【品见】舆情动态-"
+
project
.
getProjectName
();
// key2
// String key2Header = "全部";
String
key2Header
=
""
;
StringBuilder
mediaChannel
=
new
StringBuilder
();
List
<
String
>
politicsLevels
=
config
.
getPoliticsLevels
();
List
<
String
>
fields
=
config
.
getFields
();
if
(
Tools
.
isEmpty
(
politicsLevels
)){
key2Header
+=
"【全部级别】"
;
}
else
if
(
politicsLevels
.
contains
(
"全部"
)){
key2Header
+=
"【重点级别】"
;
}
else
{
politicsLevels
.
forEach
(
politicsLevel
->
mediaChannel
.
append
(
politicsLevel
).
append
(
"、"
));
}
if
(
Tools
.
isEmpty
(
fields
))
{
if
(
0
!=
key2Header
.
length
())
{
key2Header
+=
"、"
;
key2Header
+=
"【全部领域】,"
;
}
else
{
key2Header
+=
"【全部领域】"
;
}
}
else
if
(
fields
.
contains
(
"全部"
))
{
if
(
0
!=
key2Header
.
length
())
{
key2Header
+=
"、"
;
key2Header
+=
"【重点领域】,"
;
}
else
{
key2Header
+=
"【重点领域】"
;
}
}
else
{
fields
.
forEach
(
field
->
mediaChannel
.
append
(
field
).
append
(
"、"
));
}
if
(
0
!=
mediaChannel
.
length
())
{
if
(
0
!=
key2Header
.
length
())
{
key2Header
+=
"、"
;
}
// 替换“全部” 并去掉末位的、
key2Header
+=
mediaChannel
.
deleteCharAt
(
mediaChannel
.
length
()
-
1
).
toString
();
key2Header
+=
"媒体,"
;
}
StringBuilder
dataType
=
new
StringBuilder
();
config
.
getMarkerTags
().
forEach
(
emotion
->
dataType
.
append
(
emotion
).
append
(
" "
));
dataType
.
append
(
"(本品)"
);
// 如果有竞品
if
(
CollectionUtils
.
isNotEmpty
(
config
.
getContends
()))
{
dataType
.
append
(
","
);
config
.
getContends
().
forEach
(
contend
->
dataType
.
append
(
projectService
.
getProjectByContendId
(
project
.
getId
(),
contend
).
getBrandName
()).
append
(
" "
));
dataType
.
append
(
"(竞品)"
);
}
String
key2
=
key2Header
+
dataType
;
// key3
String
key3
=
Constant
.
SPEC_MINUTE_FORMAT
.
format
(
start
)
+
" ~ "
+
Constant
.
SPEC_MINUTE_FORMAT
.
format
(
end
);
// key4
String
key4
;
StringBuilder
keyBuilder4
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
Math
.
min
(
datas
.
size
(),
2
);
i
++)
{
BaseMap
baseMap
=
datas
.
get
(
i
);
String
platform
=
baseMap
.
getPlatform
();
String
source
=
baseMap
.
getSource
();
String
title
=
baseMap
.
getTitle
();
keyBuilder4
.
append
(
platform
).
append
(
"-"
).
append
(
source
).
append
(
"\r\n"
);
// 最后一条
if
(
datas
.
size
()
==
i
+
1
)
{
keyBuilder4
.
append
(
i
+
1
).
append
(
"、"
).
append
(
title
);
}
else
{
keyBuilder4
.
append
(
i
+
1
).
append
(
"、"
).
append
(
title
).
append
(
"\r\n"
);
}
}
if
(
datas
.
size
()
>
2
)
{
key4
=
keyBuilder4
.
append
(
"..."
).
toString
();
}
else
{
key4
=
keyBuilder4
.
toString
();
}
List
<
BaseMapCompound
>
collect
=
datas
.
stream
().
map
(
baseMap
->
BaseMapCompound
.
createFromBaseMap
(
baseMap
,
project
.
getId
())).
collect
(
Collectors
.
toList
());
return
new
BrandkbsWarnTemplate
(
firstCount
,
key1
,
key2
,
key3
,
key4
,
new
BrandkbsYuQingWarn
(
collect
));
}
private
BrandkbsWarnTemplate
brandkbsWarnTemplate4Channel
(
BrandkbsChannelConfig
config
,
List
<
BaseMap
>
datas
,
long
start
,
long
end
,
AbstractProject
project
)
{
if
(
datas
.
isEmpty
())
{
return
null
;
...
...
@@ -703,65 +620,6 @@ public class ProjectWarnServiceImpl implements ProjectWarnService {
}
@Override
@Deprecated
public
ResponseResult
getYuqingWaring
(
String
projectId
,
BrandkbsYuQingConfig
config
)
{
Project
project
=
null
;
long
end
=
System
.
currentTimeMillis
();
long
start
=
end
-
config
.
getPushInterval
();
try
{
project
=
projectService
.
getProjectById
(
projectId
);
log
.
info
(
"获取舆情动态预警开始,project:{}"
,
project
.
getProjectName
());
EsClientDao
.
SearchHelper
helper
=
EsClientDao
.
createSearchHelper
();
// 发声渠道
BoolQueryBuilder
postFilter
=
EsQueryTools
.
assembleCacheMapsQueryWithProject
(
projectId
,
config
);
// 时间(标注时间)
postFilter
.
must
(
QueryBuilders
.
rangeQuery
(
"mtime"
).
gte
(
start
).
lt
(
end
));
// 文章类型
if
(
CollectionUtils
.
isNotEmpty
(
config
.
getPrimary
())
&&
config
.
getPrimary
().
size
()
==
1
)
{
postFilter
.
must
(
EsQueryTools
.
assembleForwardQuery
(
config
.
getPrimary
().
get
(
0
)));
}
// 本品舆情+竞品舆情
BoolQueryBuilder
sourceBuilder
=
QueryBuilders
.
boolQuery
();
if
(
CollectionUtils
.
isNotEmpty
(
config
.
getMarkerTags
()))
{
config
.
getMarkerTags
().
forEach
(
tagName
->
sourceBuilder
.
should
(
QueryBuilders
.
termQuery
(
"brandkbs_mark_cache_maps.name.keyword"
,
tagName
)));
}
postFilter
.
must
(
sourceBuilder
);
EsQueryTools
.
assembleContendsQuery
(
postFilter
,
config
.
getContends
());
// postFilter.must(EsQueryTools.assembleNormalKeywordQuery(config.getKeyword(), new String[]{GenericAttribute.ES_IND_FULL_TEXT}));
helper
.
setPostFilter
(
postFilter
);
SearchHits
searchHits
=
esClientDao
.
searchHits
(
helper
);
log
.
info
(
"获取舆情动态预警-es搜索到数据:{}条,剩余关键词筛选未进行,project:{}"
,
searchHits
.
getHits
().
length
,
project
.
getProjectName
());
List
<
BaseMap
>
datas
=
Arrays
.
stream
(
searchHits
.
getHits
()).
map
(
hit
->
{
Map
<
String
,
Object
>
sourceMap
=
hit
.
getSourceAsMap
();
BaseMap
baseMap
=
Tools
.
getBaseFromEsMap
(
sourceMap
);
// 关键词命中
if
(!
Tools
.
isContains
(
config
.
getKeyword
(),
baseMap
.
getTitle
()
+
baseMap
.
getContent
()))
{
return
null
;
}
JSONObject
hitMap
=
Tools
.
getBrandkbsHitMapWithProjectId
(
sourceMap
,
projectId
);
String
contendId
=
hitMap
.
getString
(
"contend_id"
);
if
(!
hitMap
.
isEmpty
()
&&
(
null
!=
config
.
getContends
()
&&
config
.
getContends
().
contains
(
contendId
)))
{
baseMap
.
setBrandName
(
projectService
.
getProjectByContendId
(
projectId
,
contendId
).
getBrandName
());
}
baseMap
.
setTitle
(
baseMap
.
getTitleNullOptionalContent
());
baseMap
.
subStringContentTop
();
return
baseMap
;
}).
filter
(
Objects:
:
nonNull
).
collect
(
Collectors
.
toList
());
// 开启去重
if
(
Boolean
.
TRUE
.
equals
(
config
.
getDuplicate
()))
{
datas
=
duplicateBaseMapList
(
datas
);
}
log
.
info
(
"获取舆情动态预警结束,project:{}"
,
project
.
getProjectName
());
// 封装返回值
return
ResponseResult
.
success
(
brandkbsWarnTemplate4Yuqing
(
config
,
datas
,
start
,
end
,
project
));
}
catch
(
Exception
e
)
{
log
.
info
(
"获取舆情动态预警失败,project:{}"
,
project
.
getProjectName
(),
e
);
}
return
ResponseResult
.
failure
(
"获取舆情动态预警失败"
);
}
@Override
public
ResponseResult
getYuqingWaringNew
(
String
projectId
,
BrandkbsYuQingConfigNew
config
)
{
Project
project
;
long
end
=
System
.
currentTimeMillis
();
...
...
@@ -788,6 +646,10 @@ public class ProjectWarnServiceImpl implements ProjectWarnService {
if
(
StringUtils
.
isNotBlank
(
config
.
getChannel
())){
postFilter
.
must
(
EsQueryTools
.
assembleSourceQuery
(
config
.
getChannel
()));
}
// 屏蔽渠道
if
(
StringUtils
.
isNotBlank
(
config
.
getNoiseChannel
())){
postFilter
.
mustNot
(
EsQueryTools
.
assembleSourceQuery
(
config
.
getNoiseChannel
()));
}
helper
.
setPostFilter
(
postFilter
);
SearchHits
searchHits
=
esClientDao
.
searchHits
(
helper
);
log
.
info
(
"获取新舆情动态预警-es搜索到数据:{}条,剩余关键词筛选未进行,project:{}"
,
searchHits
.
getHits
().
length
,
project
.
getProjectName
());
...
...
@@ -795,7 +657,11 @@ public class ProjectWarnServiceImpl implements ProjectWarnService {
Map
<
String
,
Object
>
sourceMap
=
hit
.
getSourceAsMap
();
BaseMap
baseMap
=
Tools
.
getBaseFromEsMap
(
sourceMap
);
// 关键词命中
if
(!
Tools
.
isContains
(
config
.
getKeyword
(),
baseMap
.
getTitle
()
+
baseMap
.
getContent
()))
{
if
(!
Tools
.
isEmpty
(
config
.
getKeyword
())
&&
!
Tools
.
isContains
(
config
.
getKeyword
(),
baseMap
.
getTitle
()
+
baseMap
.
getContent
()))
{
return
null
;
}
// 屏蔽关键词命中
if
(!
Tools
.
isEmpty
(
config
.
getNoiseKeyword
())
&&
Tools
.
isContains
(
config
.
getNoiseKeyword
(),
baseMap
.
getTitle
()
+
baseMap
.
getContent
()))
{
return
null
;
}
baseMap
.
setTitle
(
baseMap
.
getTitleNullOptionalContent
());
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/SystemInfoServiceImpl.java
View file @
6fe16ea2
...
...
@@ -3,19 +3,15 @@ package com.zhiwei.brandkbs2.service.impl;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.common.collect.Maps
;
import
com.zhiwei.brandkbs2.dao.ChannelTagDao
;
import
com.zhiwei.brandkbs2.dao.MediaTypeDao
;
import
com.zhiwei.brandkbs2.dao.ProjectDao
;
import
com.zhiwei.brandkbs2.dao.QbjcPojoDao
;
import
com.zhiwei.brandkbs2.pojo.ChannelTag
;
import
com.zhiwei.brandkbs2.pojo.MediaType
;
import
com.zhiwei.brandkbs2.pojo.Project
;
import
com.zhiwei.brandkbs2.pojo.SensitiveChannel
;
import
com.zhiwei.brandkbs2.dao.*
;
import
com.zhiwei.brandkbs2.pojo.*
;
import
com.zhiwei.brandkbs2.service.SystemInfoService
;
import
com.zhiwei.brandkbs2.util.Tools
;
import
com.zhiwei.qbjc.bean.pojo.common.MessagePlatform
;
import
com.zhiwei.qbjc.bean.pojo.common.Tag
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.client.RestTemplate
;
...
...
@@ -48,6 +44,9 @@ public class SystemInfoServiceImpl implements SystemInfoService {
@Resource
private
ProjectDao
projectDao
;
@Resource
(
name
=
"bytedanceCustomChannelInfluenceDao"
)
private
BytedanceCustomChannelInfluenceDao
bytedanceCustomChannelInfluenceDao
;
@Autowired
private
RestTemplate
restTemplate
;
...
...
@@ -132,4 +131,10 @@ public class SystemInfoServiceImpl implements SystemInfoService {
List
<
SensitiveChannel
>
commonSensitiveChannel
=
qbjcPojoDao
.
findCommonSensitiveChannel
();
return
commonSensitiveChannel
.
stream
().
collect
(
Collectors
.
toMap
(
SensitiveChannel:
:
getName
,
o
->
o
,
(
k1
,
k2
)
->
k1
));
}
@Override
public
Map
<
String
,
BytedanceCustomChannelInfluence
>
getByteDanceChannelInfluence
()
{
return
bytedanceCustomChannelInfluenceDao
.
findList
(
new
Query
())
.
stream
().
collect
(
Collectors
.
toMap
(
data
->
Tools
.
concat
(
data
.
getPlatform
(),
data
.
getChannel
()),
o
->
o
,
(
v1
,
v2
)
->
v1
));
}
}
src/main/java/com/zhiwei/brandkbs2/service/impl/TaskServiceImpl.java
View file @
6fe16ea2
...
...
@@ -188,6 +188,8 @@ public class TaskServiceImpl implements TaskService {
indexService
.
getPlatformInfo
(
null
,
null
,
false
);
// 首页-传播趋势
indexService
.
getSpreadingTend
(
null
,
null
,
false
);
// 首页-净情感度
indexService
.
getEmotionPercent
(
null
,
null
,
false
);
log
.
info
(
"项目:{}-首页缓存已完成:{}个"
,
project
.
getProjectName
(),
total
.
incrementAndGet
());
return
null
;
},
cacheServiceExecutor
)).
toArray
(
CompletableFuture
[]::
new
)).
join
();
...
...
@@ -382,14 +384,14 @@ public class TaskServiceImpl implements TaskService {
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
.
get
HighWord
(
time
[
0
],
time
[
1
],
null
,
false
);
markDataService
.
cache
HighWord
(
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
.
get
HighWord
(
time
[
0
],
time
[
1
],
plan
.
getId
(),
false
);
markDataService
.
cache
HighWord
(
time
[
0
],
time
[
1
],
plan
.
getId
(),
false
);
log
.
info
(
"方案:{}-{}-词云缓存已完成:{}个"
,
plan
.
getName
(),
plan
.
getId
(),
total2
.
incrementAndGet
());
return
null
;
},
cacheServiceExecutor
)).
collect
(
Collectors
.
toList
());
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/ToolsetServiceImpl.java
View file @
6fe16ea2
package
com
.
zhiwei
.
brandkbs2
.
service
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.zhiwei.brandkbs2.auth.UserThreadLocal
;
import
com.zhiwei.brandkbs2.common.GenericAttribute
;
import
com.zhiwei.brandkbs2.common.GlobalPojo
;
import
com.zhiwei.brandkbs2.controller.app.AppToolsetController
;
import
com.zhiwei.brandkbs2.dao.*
;
import
com.zhiwei.brandkbs2.easyexcel.EasyExcelUtil
;
...
...
@@ -109,6 +109,9 @@ public class ToolsetServiceImpl implements ToolsetService {
@Resource
(
name
=
"BytedanceCustomPlatformWeightDao"
)
private
BytedanceCustomPlatformWeightDao
bytedanceCustomPlatformWeightDao
;
@Resource
(
name
=
"bytedanceCustomChannelLevelInfoDao"
)
private
BytedanceCustomChannelLevelInfoDao
bytedanceCustomChannelLevelInfoDao
;
@Resource
(
name
=
"bytedanceCustomEventUpdateTaskDao"
)
private
BytedanceCustomEventUpdateTaskDao
bytedanceCustomEventUpdateTaskDao
;
...
...
@@ -388,6 +391,7 @@ public class ToolsetServiceImpl implements ToolsetService {
}
@Override
@Deprecated
// 2024.3.27 由于不再进行互动量更新故不再进行补充计算
public
void
eventAdditionalUpdate
(
MultipartFile
file
,
String
taskId
)
{
BytedanceCustomEventUpdateTask
task
=
bytedanceCustomEventUpdateTaskDao
.
findOneById
(
taskId
);
updateStatus
(
taskId
,
BytedanceCustomEventUpdateTask
.
TaskStatus
.
CALCULATING
,
BytedanceCustomEventUpdateTask
.
ProcessStatus
.
CHANNEL_MATCH
);
...
...
@@ -400,11 +404,9 @@ public class ToolsetServiceImpl implements ToolsetService {
// 将旧数据与新数据合并
List
<
BytedanceCustomEventUpdateTaskData
>
taskData
=
bytedanceCustomEventUpdateTaskDataDao
.
findList
(
new
Query
(
Criteria
.
where
(
"taskId"
).
is
(
taskId
)));
taskData
.
addAll
(
data
);
// 清空错误旧数据
task
.
getErrorData
().
clear
();
// 更新进度
resetProcessSchedule
(
task
.
getId
(),
taskD
ata
.
size
());
ApplicationProjectListener
.
getThreadPool
().
execute
(()
->
processEventUpdate
(
taskD
ata
,
task
,
task
.
getExtraCompute
()));
resetProcessSchedule
(
task
.
getId
(),
d
ata
.
size
());
ApplicationProjectListener
.
getThreadPool
().
execute
(()
->
processEventUpdate
(
d
ata
,
task
,
task
.
getExtraCompute
()));
}
@Override
...
...
@@ -451,7 +453,7 @@ public class ToolsetServiceImpl implements ToolsetService {
return
jsonObject
;
}).
collect
(
Collectors
.
toList
());
JSONObject
info
=
new
JSONObject
();
info
.
put
(
"error"
,
CollectionUtils
.
isNotEmpty
(
task
.
getErrorData
()));
//
info.put("error", CollectionUtils.isNotEmpty(task.getErrorData()));
PageVO
<
JSONObject
>
pageVo
=
PageVO
.
createPageVo
(
task
.
getEventInfo
().
size
(),
page
,
pageSize
,
list
);
pageVo
.
setInfo
(
info
);
return
pageVo
;
...
...
@@ -475,6 +477,7 @@ public class ToolsetServiceImpl implements ToolsetService {
dto
.
setInf
(
event
.
getInfluence
());
dto
.
setRMI
(
event
.
getRMI
());
dto
.
setFinalInf
(
event
.
getFinalInfluence
());
dto
.
setDataCount
(
event
.
getDataCount
());
return
dto
;
}).
collect
(
Collectors
.
toList
());
// excel写入至指定路径
...
...
@@ -485,13 +488,14 @@ public class ToolsetServiceImpl implements ToolsetService {
}
@Override
@Deprecated
// 2024.3.27 由于不再进行互动量更新故不会出现错误数据,无需再下载
public
String
downloadPrimaryErrorData
(
String
taskId
)
{
BytedanceCustomEventUpdateTask
task
=
bytedanceCustomEventUpdateTaskDao
.
findOneById
(
taskId
);
// excel写入至指定路径
String
projectName
=
projectService
.
getProjectById
(
UserThreadLocal
.
getProjectId
()).
getProjectName
();
String
filePath
=
EasyExcelUtil
.
generateExcelFilePath
(
brandkbsFilePath
,
projectName
,
UserThreadLocal
.
getNickname
(),
"报错数据"
);
List
<
UploadBytedanceEventDTO
>
collect
=
task
.
getErrorData
().
stream
().
map
(
errorData
->
Tools
.
convertMap
(
errorData
,
UploadBytedanceEventDTO
.
class
)).
collect
(
Collectors
.
toList
());
EasyExcelUtil
.
write
(
filePath
,
"sheet1"
,
UploadBytedanceEventDTO
.
class
,
collect
);
//
List<UploadBytedanceEventDTO> collect = task.getErrorData().stream().map(errorData -> Tools.convertMap(errorData, UploadBytedanceEventDTO.class)).collect(Collectors.toList());
EasyExcelUtil
.
write
(
filePath
,
"sheet1"
,
UploadBytedanceEventDTO
.
class
,
Collections
.
emptyList
()
);
return
filePath
;
}
...
...
@@ -546,15 +550,20 @@ public class ToolsetServiceImpl implements ToolsetService {
private
void
processEventUpdate
(
List
<
BytedanceCustomEventUpdateTaskData
>
taskData
,
BytedanceCustomEventUpdateTask
task
,
Boolean
extraCompute
){
String
taskId
=
task
.
getId
();
try
{
List
<
BytedanceCustomEventUpdateTask
.
EventInfo
>
eventInfos
=
new
ArrayList
<>();
Map
<
String
,
BytedanceCustomEventUpdateTask
.
EventInfo
>
eventInfoMap
=
new
HashMap
<>();
Map
<
String
,
List
<
BytedanceCustomEventUpdateTaskData
>>
map
=
taskData
.
stream
().
collect
(
Collectors
.
groupingBy
(
BytedanceCustomEventUpdateTaskData:
:
getEventName
));
// 渠道等级对照表
Map
<
String
,
BytedanceCustomChannelLevelInfo
>
levelInfoMap
=
bytedanceCustomChannelLevelInfoDao
.
findList
(
new
Query
()).
stream
()
.
collect
(
Collectors
.
toMap
(
BytedanceCustomChannelLevelInfo:
:
getLevel
,
o
->
o
,
(
v1
,
v2
)
->
v1
));
for
(
Map
.
Entry
<
String
,
List
<
BytedanceCustomEventUpdateTaskData
>>
entry
:
map
.
entrySet
())
{
String
eventName
=
entry
.
getKey
();
List
<
BytedanceCustomEventUpdateTaskData
>
data
=
entry
.
getValue
();
BytedanceCustomEventUpdateTask
.
EventInfo
eventInfo
=
new
BytedanceCustomEventUpdateTask
.
EventInfo
();
eventInfo
.
setName
(
entry
.
getKey
());
eventInfo
.
setName
(
eventName
);
eventInfo
.
setDataCount
(
data
.
size
());
// 计算影响力指数
eventInfo
.
setInfluence
(
computeInf
(
data
));
eventInfo
s
.
add
(
eventInfo
);
eventInfo
.
setInfluence
(
computeInf
(
data
,
levelInfoMap
));
eventInfo
Map
.
put
(
eventName
,
eventInfo
);
// 更新渠道匹配处理进度
addProcessSchedule
(
taskId
,
data
.
size
());
}
...
...
@@ -562,20 +571,19 @@ public class ToolsetServiceImpl implements ToolsetService {
if
(
extraCompute
)
{
// 更新为互动量更新处理状态
updateStatus
(
taskId
,
BytedanceCustomEventUpdateTask
.
TaskStatus
.
CALCULATING
,
BytedanceCustomEventUpdateTask
.
ProcessStatus
.
INTERACTION_UPDATE
);
long
count
=
taskData
.
stream
().
filter
(
data
->
Objects
.
isNull
(
data
.
getWechatRead
())
&&
Objects
.
isNull
(
data
.
getWechatReading
())
&&
Objects
.
isNull
(
data
.
getWeiboForward
())
&&
Objects
.
isNull
(
data
.
getWeiboComment
())
&&
Objects
.
isNull
(
data
.
getWeiboLike
())).
count
();
// 更新互动量更新处理进度
resetProcessSchedule
(
taskId
,
(
int
)
count
);
for
(
BytedanceCustomEventUpdateTask
.
EventInfo
eventInfo
:
eventInfos
)
{
List
<
BytedanceCustomEventUpdateTaskData
>
data
=
map
.
get
(
eventInfo
.
getName
());
resetProcessSchedule
(
taskId
,
taskData
.
size
());
for
(
Map
.
Entry
<
String
,
BytedanceCustomEventUpdateTask
.
EventInfo
>
entry
:
eventInfoMap
.
entrySet
())
{
List
<
BytedanceCustomEventUpdateTaskData
>
data
=
map
.
get
(
entry
.
getKey
());
BytedanceCustomEventUpdateTask
.
EventInfo
eventInfo
=
entry
.
getValue
();
// 计算实时传播力
eventInfo
.
setRMI
(
computeRMI
(
data
,
task
));
eventInfo
.
setRMI
(
computeRMI
(
data
));
// 计算传播影响力
eventInfo
.
setFinalInfluence
(
computeFinalInf
(
eventInfo
.
getInfluence
(),
eventInfo
.
getRMI
()));
}
updateStatus
(
taskId
,
BytedanceCustomEventUpdateTask
.
TaskStatus
.
CALCULATING
,
BytedanceCustomEventUpdateTask
.
ProcessStatus
.
INFLUENCE_COMPUTE
);
}
task
.
setEventInfo
(
eventInfos
);
task
.
setEventInfo
(
new
ArrayList
<>(
eventInfoMap
.
values
())
);
updateStatus
(
task
,
BytedanceCustomEventUpdateTask
.
TaskStatus
.
FINISH
,
BytedanceCustomEventUpdateTask
.
ProcessStatus
.
FINISH
);
}
catch
(
Exception
e
){
log
.
info
(
"本品字节事件影响力补充计算出错-taskId:{}"
,
taskId
,
e
);
...
...
@@ -622,15 +630,18 @@ public class ToolsetServiceImpl implements ToolsetService {
for
(
SearchHit
hit
:
searchResponse
.
getHits
().
getHits
())
{
BaseMap
baseMap
=
Tools
.
getBaseFromEsMap
(
hit
.
getSourceAsMap
());
BytedanceCustomEventUpdateTaskData
dto
=
new
BytedanceCustomEventUpdateTaskData
();
dto
.
setPlatform
(
baseMap
.
getPlatform
());
dto
.
setPlatform
Type
(
baseMap
.
getPlatform
());
dto
.
setChannel
(
baseMap
.
getSource
());
data
.
add
(
dto
);
}
}
updateStatus
(
taskId
,
null
,
BytedanceCustomEventUpdateTask
.
ProcessStatus
.
INFLUENCE_COMPUTE
);
resetProcessSchedule
(
taskId
,
data
.
size
());
// 渠道等级对照表
Map
<
String
,
BytedanceCustomChannelLevelInfo
>
levelInfoMap
=
bytedanceCustomChannelLevelInfoDao
.
findList
(
new
Query
()).
stream
()
.
collect
(
Collectors
.
toMap
(
BytedanceCustomChannelLevelInfo:
:
getLevel
,
o
->
o
,
(
v1
,
v2
)
->
v1
));
// 计算影响力指数
task
.
setContendInfluence
(
computeInf
(
data
));
task
.
setContendInfluence
(
computeInf
(
data
,
levelInfoMap
));
addProcessSchedule
(
taskId
,
data
.
size
());
updateStatus
(
task
,
BytedanceCustomEventUpdateTask
.
TaskStatus
.
FINISH
,
BytedanceCustomEventUpdateTask
.
ProcessStatus
.
FINISH
);
}
catch
(
Exception
e
){
...
...
@@ -698,49 +709,45 @@ public class ToolsetServiceImpl implements ToolsetService {
/**
* 计算影响力指数(Inf)
* @param data
* @param data
s
* @return
*/
private
double
computeInf
(
List
<
BytedanceCustomEventUpdateTaskData
>
data
){
double
sumH
=
0
;
if
(
CollectionUtils
.
isEmpty
(
data
)){
return
sumH
;
}
for
(
BytedanceCustomEventUpdateTaskData
datum
:
data
)
{
// 网媒、平媒、外媒和自媒体四个平台类型的渠道,匹配重要渠道表,如果匹配成功,则按照“网媒”算影响力值。
if
(
COMMON_MEDIA
.
contains
(
datum
.
getPlatform
())
&&
bytedanceCustomChannelDao
.
exist
(
new
Query
(
Criteria
.
where
(
"channel"
).
is
(
datum
.
getChannel
())))){
datum
.
setPlatform
(
"网媒"
);
}
// 匹配表中的渠道影响力
Query
query
=
new
Query
();
query
.
addCriteria
(
Criteria
.
where
(
"platform"
).
is
(
datum
.
getPlatform
()));
query
.
addCriteria
(
Criteria
.
where
(
"channel"
).
is
(
datum
.
getChannel
()));
BytedanceCustomChannelInfluence
channelInfluence
=
bytedanceCustomChannelInfluenceDao
.
findOne
(
query
);
private
Double
computeInf
(
List
<
BytedanceCustomEventUpdateTaskData
>
datas
,
Map
<
String
,
BytedanceCustomChannelLevelInfo
>
levelInfoMap
){
Map
<
String
,
Double
>
levelSumH
=
new
HashMap
<>(
5
);
if
(
CollectionUtils
.
isEmpty
(
datas
)){
return
0
d
;
}
for
(
BytedanceCustomEventUpdateTaskData
data
:
datas
)
{
// 匹配渠道影响力,微博、微信以外的平台一律按照”网媒“处理
BytedanceCustomChannelInfluence
channelInfluence
=
GlobalPojo
.
BYTEDANCE_CHANNEL_INFLUENCE
.
get
(
concat
(
Objects
.
equals
(
"微博"
,
data
.
getPlatformType
())
&&
Objects
.
equals
(
"微信"
,
data
.
getPlatformType
())
?
data
.
getPlatformType
()
:
"网媒"
,
data
.
getChannel
()));
// 1.分别将等级为S,A,B,C的渠道各自加和
if
(
Objects
.
nonNull
(
channelInfluence
)){
sumH
=
BigDecimal
.
valueOf
(
sumH
).
add
(
BigDecimal
.
valueOf
(
channelInfluence
.
getInfluence
())).
doubleValue
();
}
else
{
// 如果表中没有匹配,则取事见渠道库中的值
ResponseEntity
<
String
>
response
=
restTemplate
.
getForEntity
(
channelInfluenceUrl
,
String
.
class
,
datum
.
getPlatform
(),
datum
.
getChannel
());
JSONObject
jsonObject
=
JSON
.
parseObject
(
response
.
getBody
());
if
(!
jsonObject
.
getBoolean
(
"status"
)
&&
Objects
.
nonNull
(
jsonObject
.
getBigDecimal
(
"data"
))
&&
-
1
!=
jsonObject
.
getBigDecimal
(
"data"
).
doubleValue
()){
sumH
=
BigDecimal
.
valueOf
(
sumH
).
add
(
jsonObject
.
getBigDecimal
(
"data"
)).
doubleValue
();
}
else
{
// 库中没有的结果取值为:1
sumH
=
BigDecimal
.
valueOf
(
sumH
).
add
(
BigDecimal
.
valueOf
(
1
)).
doubleValue
();
}
levelSumH
.
compute
(
channelInfluence
.
getLevel
(),
(
k
,
v
)
->
Objects
.
isNull
(
v
)
?
channelInfluence
.
getInfluence
()
:
BigDecimal
.
valueOf
(
v
).
add
(
BigDecimal
.
valueOf
(
channelInfluence
.
getInfluence
())).
doubleValue
());
}
else
{
// 如果表中没有匹配,则,影响力取1,渠道等级取D
levelSumH
.
compute
(
"D"
,
(
k
,
v
)
->
Objects
.
isNull
(
v
)
?
1
d
:
BigDecimal
.
valueOf
(
v
).
add
(
BigDecimal
.
valueOf
(
1
)).
doubleValue
());
}
}
BigDecimal
lnSumH
=
BigDecimal
.
valueOf
(
Math
.
log
(
sumH
));
BigDecimal
lnSumMaxAll
=
BigDecimal
.
valueOf
(
Math
.
log
(
SUM_MAX_ALL
));
BigDecimal
partResult
=
lnSumH
.
divide
(
lnSumMaxAll
,
9
,
RoundingMode
.
HALF_UP
).
multiply
(
BigDecimal
.
valueOf
(
100
));
// 若sumH<2000,inf=ln(sumH)/ln(sumMaxAll)*100*0.5+sumH/4268*100*0.5
if
(
sumH
<
2000
){
BigDecimal
denominator
=
BigDecimal
.
valueOf
(
4268
).
multiply
(
BigDecimal
.
valueOf
(
100
)).
multiply
(
BigDecimal
.
valueOf
(
0.5
));
BigDecimal
leftResult
=
partResult
.
multiply
(
BigDecimal
.
valueOf
(
0.5
));
BigDecimal
rightResult
=
BigDecimal
.
valueOf
(
sumH
).
divide
(
denominator
,
9
,
RoundingMode
.
HALF_UP
);
return
leftResult
.
add
(
rightResult
).
setScale
(
7
,
RoundingMode
.
HALF_UP
).
doubleValue
();
// 2.分类各自的影响力计算
double
result
=
0
;
BigDecimal
bigDecimal100
=
BigDecimal
.
valueOf
(
100
);
for
(
Map
.
Entry
<
String
,
Double
>
entry
:
levelSumH
.
entrySet
())
{
BytedanceCustomChannelLevelInfo
levelInfo
=
levelInfoMap
.
get
(
entry
.
getKey
());
Double
sumH
=
entry
.
getValue
();
BigDecimal
INF
;
// A.当相应等级的SUMH大于等于临界值 INF=LN(H)/LN(Hmax)*100
if
(
sumH
>=
levelInfo
.
getThreshold
()){
INF
=
BigDecimal
.
valueOf
(
Math
.
log
(
sumH
)).
divide
(
BigDecimal
.
valueOf
(
Math
.
log
(
levelInfo
.
getHMax
())),
20
,
RoundingMode
.
HALF_UP
).
multiply
(
bigDecimal100
);
}
else
{
// B.当相应等级的SUMH小于临界值 INF=sumH/系数*100
INF
=
BigDecimal
.
valueOf
(
sumH
).
divide
(
BigDecimal
.
valueOf
(
levelInfo
.
getCoefficient
()),
20
,
RoundingMode
.
HALF_UP
).
multiply
(
bigDecimal100
);
}
// 3.各自乘以权重 结果相加
result
=
INF
.
multiply
(
BigDecimal
.
valueOf
(
levelInfo
.
getWeight
())).
add
(
BigDecimal
.
valueOf
(
result
)).
doubleValue
();
}
// 否则,inf=ln(sumH)/ln(sumMaxAll)*100
return
partResult
.
setScale
(
7
,
RoundingMode
.
HALF_UP
).
doubleValue
();
return
BigDecimal
.
valueOf
(
result
).
setScale
(
1
,
RoundingMode
.
HALF_UP
).
doubleValue
();
}
/**
...
...
@@ -748,124 +755,112 @@ public class ToolsetServiceImpl implements ToolsetService {
* @param data
* @return
*/
private
double
computeRMI
(
List
<
BytedanceCustomEventUpdateTaskData
>
data
,
BytedanceCustomEventUpdateTask
task
){
List
<
BytedanceCustomEventUpdateTaskData
>
willBeInteractionUpdateData
=
new
ArrayList
<>();
int
weiboForward
=
0
;
int
we
iboComment
=
0
;
int
weiboLike
=
0
;
private
Double
computeRMI
(
List
<
BytedanceCustomEventUpdateTaskData
>
data
){
// 1、初始值
// 微信文章数
int
we
chatArticle
=
(
int
)
data
.
stream
().
filter
(
article
->
Objects
.
equals
(
"微信"
,
article
.
getPlatformType
())).
count
()
;
// 微信阅读数
int
wechatRead
=
0
;
// 微信在看数
int
wechatReading
=
0
;
// 微博消息数
int
weiboArticle
=
(
int
)
data
.
stream
().
filter
(
article
->
Objects
.
equals
(
"微博"
,
article
.
getPlatform
())).
count
();
// 微信文章数
int
wechatArticle
=
(
int
)
data
.
stream
().
filter
(
article
->
Objects
.
equals
(
"微信"
,
article
.
getPlatform
())).
count
();
// 网媒文章数
int
normalMediaArticle
=
(
int
)
data
.
stream
().
filter
(
article
->
Objects
.
equals
(
"网媒"
,
article
.
getPlatform
())).
count
();
// 其他平台文章数
int
otherPlatformArticle
=
(
int
)
data
.
stream
().
filter
(
article
->
!
Objects
.
equals
(
"网媒"
,
article
.
getPlatform
())
&&
!
Objects
.
equals
(
"微博"
,
article
.
getPlatform
())
&&
!
Objects
.
equals
(
"微信"
,
article
.
getPlatform
())).
count
();
// 微博消息数(文章数)
int
weiboArticle
=
(
int
)
data
.
stream
().
filter
(
article
->
Objects
.
equals
(
"微博"
,
article
.
getPlatformType
())).
count
();
// 微博互动数=转发+评论+点赞
int
weiboInteraction
=
0
;
// 头条文章数
int
toutiaoArticle
=
(
int
)
data
.
stream
().
filter
(
article
->
Objects
.
equals
(
"今日头条"
,
article
.
getPlatformType
())).
count
();
// 头条阅读数
int
toutiaoRead
=
0
;
// 头条互动数=点赞+pc评论
int
toutiaoInteraction
=
0
;
// 网媒文章数=外媒+平媒+网媒+自媒体
int
normalMediaArticle
=
(
int
)
data
.
stream
().
filter
(
article
->
Objects
.
equals
(
"网媒"
,
article
.
getPlatformType
())
||
Objects
.
equals
(
"外媒"
,
article
.
getPlatformType
())
||
Objects
.
equals
(
"平媒"
,
article
.
getPlatformType
())
||
Objects
.
equals
(
"自媒体"
,
article
.
getPlatformType
())).
count
();
// 其他平台文章数 除以上平台以外
int
otherPlatformArticle
=
(
int
)
data
.
stream
().
filter
(
article
->
!
Objects
.
equals
(
"网媒"
,
article
.
getPlatformType
())
&&
!
Objects
.
equals
(
"微博"
,
article
.
getPlatformType
())
&&
!
Objects
.
equals
(
"微信"
,
article
.
getPlatformType
())
&&
!
Objects
.
equals
(
"今日头条"
,
article
.
getPlatformType
())
&&
!
Objects
.
equals
(
"外媒"
,
article
.
getPlatformType
())
&&
!
Objects
.
equals
(
"平媒"
,
article
.
getPlatformType
())
&&
!
Objects
.
equals
(
"自媒体"
,
article
.
getPlatformType
())).
count
();
// 2、统计数值
for
(
BytedanceCustomEventUpdateTaskData
datum
:
data
)
{
// 选填字段全部未填,后续走互动量更新
if
(
Objects
.
isNull
(
datum
.
getWechatRead
())
&&
Objects
.
isNull
(
datum
.
getWechatReading
())
&&
Objects
.
isNull
(
datum
.
getWeiboForward
())
&&
Objects
.
isNull
(
datum
.
getWeiboComment
())
&&
Objects
.
isNull
(
datum
.
getWeiboLike
())){
willBeInteractionUpdateData
.
add
(
datum
);
continue
;
if
(
Objects
.
equals
(
"微信"
,
datum
.
getPlatformType
()))
{
wechatRead
=
wechatRead
+
datum
.
getRead
();
wechatReading
=
wechatReading
+
datum
.
getReading
();
}
weiboForward
=
weiboForward
+
datum
.
getWeiboForward
();
weiboComment
=
weiboComment
+
datum
.
getWeiboComment
();
weiboLike
=
weiboLike
+
datum
.
getWeiboLike
();
wechatRead
=
wechatRead
+
datum
.
getWechatRead
();
wechatReading
=
wechatReading
+
datum
.
getWechatReading
();
}
data
.
removeAll
(
willBeInteractionUpdateData
);
// 选填字段全部未填的链接互动量更新结果
try
{
List
<
String
>
successUrl
=
new
ArrayList
<>();
List
<
String
>
urls
=
willBeInteractionUpdateData
.
stream
().
map
(
BytedanceCustomEventUpdateTaskData:
:
getUrl
).
collect
(
Collectors
.
toList
());
Map
<
String
,
BytedanceCustomEventUpdateTaskData
>
urlMap
=
willBeInteractionUpdateData
.
stream
().
collect
(
Collectors
.
toMap
(
BytedanceCustomEventUpdateTaskData:
:
getUrl
,
o
->
o
,
(
v1
,
v2
)
->
v1
));
// 互动量更新
List
<
JSONObject
>
jsonObjects
=
urlInteractionUpdate
(
urls
,
task
.
getId
());
for
(
JSONObject
jsonObject
:
jsonObjects
)
{
if
(
200
==
jsonObject
.
getInteger
(
"code"
))
{
// 成功的链接
String
url
=
jsonObject
.
getString
(
"url"
);
successUrl
.
add
(
url
);
// 转发数
int
repostCount
=
Objects
.
isNull
(
jsonObject
.
getInteger
(
"repostCount"
))
?
0
:
jsonObject
.
getIntValue
(
"repostCount"
);
urlMap
.
get
(
url
).
setWeiboForward
(
repostCount
);
// 评论数
int
commentCount
=
Objects
.
isNull
(
jsonObject
.
getInteger
(
"commentCount"
))
?
0
:
jsonObject
.
getIntValue
(
"commentCount"
);
urlMap
.
get
(
url
).
setWeiboComment
(
commentCount
);
// 点赞数
int
likeCount
=
Objects
.
isNull
(
jsonObject
.
getInteger
(
"likeCount"
))
?
0
:
jsonObject
.
getIntValue
(
"likeCount"
);
urlMap
.
get
(
url
).
setWeiboLike
(
likeCount
);
// 阅读数
int
readCount
=
Objects
.
isNull
(
jsonObject
.
getInteger
(
"readCount"
))
?
0
:
jsonObject
.
getIntValue
(
"readCount"
);
urlMap
.
get
(
url
).
setWechatRead
(
readCount
);
// 在看数,实际使用的是返回结果中的分享数
int
shareCount
=
Objects
.
isNull
(
jsonObject
.
getInteger
(
"shareCount"
))
?
0
:
jsonObject
.
getIntValue
(
"shareCount"
);
urlMap
.
get
(
url
).
setWechatReading
(
shareCount
);
// 累加
weiboForward
=
weiboForward
+
repostCount
;
weiboComment
=
weiboComment
+
commentCount
;
weiboLike
=
weiboLike
+
likeCount
;
wechatRead
=
wechatRead
+
readCount
;
wechatReading
=
wechatReading
+
shareCount
;
if
(
Objects
.
equals
(
"微博"
,
datum
.
getPlatformType
()))
{
// 微博互动数=转发+评论+点赞
weiboInteraction
=
weiboInteraction
+
datum
.
getForward
()
+
datum
.
getComment
()
+
datum
.
getLike
();
}
if
(
Objects
.
equals
(
"今日头条"
,
datum
.
getPlatformType
()))
{
// 头条阅读数中不包含微头条的数值
if
(!
Objects
.
equals
(
"微头条"
,
datum
.
getPlatform
())){
toutiaoRead
=
toutiaoRead
+
datum
.
getRead
();
}
// 头条互动数=点赞+pc评论
toutiaoInteraction
=
toutiaoInteraction
+
datum
.
getLike
()
+
datum
.
getComment
();
}
// 报错数据
urls
.
removeAll
(
successUrl
);
// 去除成功数据,剩余即为失败数据
List
<
BytedanceCustomEventUpdateTaskData
>
errorData
=
urls
.
stream
().
map
(
urlMap:
:
get
).
collect
(
Collectors
.
toList
());
List
<
BytedanceCustomEventUpdateTaskData
>
error
=
task
.
getErrorData
();
error
.
addAll
(
errorData
);
task
.
setErrorData
(
error
);
// 互动量更新成功数据
List
<
BytedanceCustomEventUpdateTaskData
>
successData
=
successUrl
.
stream
().
map
(
urlMap:
:
get
).
collect
(
Collectors
.
toList
());
data
.
addAll
(
successData
);
}
catch
(
Exception
e
){
log
.
info
(
"字节事件影响力更新-互动量更新出错-id:{}"
,
task
.
getId
(),
e
);
List
<
BytedanceCustomEventUpdateTaskData
>
errorData
=
task
.
getErrorData
();
errorData
.
addAll
(
willBeInteractionUpdateData
);
task
.
setErrorData
(
errorData
);
}
// 存储数据以用于补充计算
bytedanceCustomEventUpdateTaskDataDao
.
deleteOneByQuery
(
new
Query
(
Criteria
.
where
(
"taskId"
).
is
(
task
.
getId
())));
bytedanceCustomEventUpdateTaskDataDao
.
insertMany
(
data
);
}
// 3、根据公式计算结果
// 平台指标权重,常量
Map
<
String
,
BytedanceCustomPlatformWeight
>
weightMap
=
bytedanceCustomPlatformWeightDao
.
findList
(
new
Query
())
.
stream
()
.
collect
(
Collectors
.
toMap
(
BytedanceCustomPlatformWeight:
:
getType
,
o
->
o
));
BytedanceCustomPlatformWeight
normalMediaArticleWeight
=
weightMap
.
get
(
"网媒文章数"
);
BytedanceCustomPlatformWeight
otherPlatformArticleWeight
=
weightMap
.
get
(
"其他平台文章数"
);
BytedanceCustomPlatformWeight
wechatArticleWeight
=
weightMap
.
get
(
"微信文章数"
);
BytedanceCustomPlatformWeight
wechatReadWeight
=
weightMap
.
get
(
"微信阅读数"
);
BytedanceCustomPlatformWeight
wechatReadingWeight
=
weightMap
.
get
(
"微信在看数"
);
BytedanceCustomPlatformWeight
weiboArticleWeight
=
weightMap
.
get
(
"微博消息数"
);
BytedanceCustomPlatformWeight
weiboForwardWeight
=
weightMap
.
get
(
"微博转发数"
);
BytedanceCustomPlatformWeight
weiboCommentWeight
=
weightMap
.
get
(
"微博评论数"
);
BytedanceCustomPlatformWeight
weiboLikeWeight
=
weightMap
.
get
(
"微博点赞数"
);
BytedanceCustomPlatformWeight
weiboInteractionWeight
=
weightMap
.
get
(
"微博互动数"
);
BytedanceCustomPlatformWeight
toutiaoArticleWeight
=
weightMap
.
get
(
"头条文章数"
);
BytedanceCustomPlatformWeight
toutiaoReadWeight
=
weightMap
.
get
(
"头条阅读数"
);
BytedanceCustomPlatformWeight
toutiaoInteractionWeight
=
weightMap
.
get
(
"头条互动数"
);
// 标准值计算
BigDecimal
bigDecimal100
=
BigDecimal
.
valueOf
(
100
);
BigDecimal
NM
=
BigDecimal
.
valueOf
(
normalMediaArticle
).
divide
(
BigDecimal
.
valueOf
(
normalMediaArticleWeight
.
getConstant
()),
9
,
RoundingMode
.
HALF_UP
).
multiply
(
bigDecimal100
);
BigDecimal
OP
=
BigDecimal
.
valueOf
(
otherPlatformArticle
).
divide
(
BigDecimal
.
valueOf
(
otherPlatformArticleWeight
.
getConstant
()),
9
,
RoundingMode
.
HALF_UP
).
multiply
(
bigDecimal100
);
BigDecimal
WC
=
BigDecimal
.
valueOf
(
wechatArticle
).
divide
(
BigDecimal
.
valueOf
(
wechatArticleWeight
.
getConstant
()),
9
,
RoundingMode
.
HALF_UP
).
multiply
(
bigDecimal100
);
BigDecimal
WCR
=
BigDecimal
.
valueOf
(
Math
.
log
(
wechatRead
+
1
)).
divide
(
BigDecimal
.
valueOf
(
Math
.
log
(
wechatReadWeight
.
getConstant
()
+
1
)),
9
,
RoundingMode
.
HALF_UP
).
multiply
(
bigDecimal100
);
BigDecimal
WCL
=
BigDecimal
.
valueOf
(
Math
.
log
(
wechatReading
+
1
)).
divide
(
BigDecimal
.
valueOf
(
Math
.
log
(
wechatReadingWeight
.
getConstant
()
+
1
)),
9
,
RoundingMode
.
HALF_UP
).
multiply
(
bigDecimal100
);
BigDecimal
WB
=
BigDecimal
.
valueOf
(
weiboArticle
).
divide
(
BigDecimal
.
valueOf
(
weiboArticleWeight
.
getConstant
()),
9
,
RoundingMode
.
HALF_UP
).
multiply
(
bigDecimal100
);
BigDecimal
WBF
=
BigDecimal
.
valueOf
(
Math
.
log
(
weiboForward
+
1
)).
divide
(
BigDecimal
.
valueOf
(
Math
.
log
(
weiboForwardWeight
.
getConstant
()
+
1
)),
9
,
RoundingMode
.
HALF_UP
).
multiply
(
bigDecimal100
);
BigDecimal
WBC
=
BigDecimal
.
valueOf
(
Math
.
log
(
weiboComment
+
1
)).
divide
(
BigDecimal
.
valueOf
(
Math
.
log
(
weiboCommentWeight
.
getConstant
()
+
1
)),
9
,
RoundingMode
.
HALF_UP
).
multiply
(
bigDecimal100
);
BigDecimal
WBL
=
BigDecimal
.
valueOf
(
Math
.
log
(
weiboLike
+
1
)).
divide
(
BigDecimal
.
valueOf
(
Math
.
log
(
weiboLikeWeight
.
getConstant
()
+
1
)),
9
,
RoundingMode
.
HALF_UP
).
multiply
(
bigDecimal100
);
// 标准值与权重计算得RMI
// 网媒文章数:NM标= NM/NM常*100.0
BigDecimal
NM
=
BigDecimal
.
valueOf
(
normalMediaArticle
).
divide
(
BigDecimal
.
valueOf
(
normalMediaArticleWeight
.
getConstant
()),
20
,
RoundingMode
.
HALF_UP
).
multiply
(
bigDecimal100
);
// 其他平台文章数:OM标= OM/OM常*100.0
BigDecimal
OM
=
BigDecimal
.
valueOf
(
otherPlatformArticle
).
divide
(
BigDecimal
.
valueOf
(
otherPlatformArticleWeight
.
getConstant
()),
20
,
RoundingMode
.
HALF_UP
).
multiply
(
bigDecimal100
);
// 微信文章数:WC标= WC/WC常*100.0
BigDecimal
WC
=
BigDecimal
.
valueOf
(
wechatArticle
).
divide
(
BigDecimal
.
valueOf
(
wechatArticleWeight
.
getConstant
()),
20
,
RoundingMode
.
HALF_UP
).
multiply
(
bigDecimal100
);
// 微信阅读数:WCR标= ln(WCR+1)/ln(WCR常+1)*100.0
BigDecimal
WCR
=
BigDecimal
.
valueOf
(
Math
.
log
(
wechatRead
+
1
)).
divide
(
BigDecimal
.
valueOf
(
Math
.
log
(
wechatReadWeight
.
getConstant
()
+
1
)),
20
,
RoundingMode
.
HALF_UP
).
multiply
(
bigDecimal100
);
// 微信在看数:WCL标= ln(WCL+1)/ln(WCL常+1)*100.0
BigDecimal
WCL
=
BigDecimal
.
valueOf
(
Math
.
log
(
wechatReading
+
1
)).
divide
(
BigDecimal
.
valueOf
(
Math
.
log
(
wechatReadingWeight
.
getConstant
()
+
1
)),
20
,
RoundingMode
.
HALF_UP
).
multiply
(
bigDecimal100
);
// 微博消息数:WB标= ln(WB+1)/ln(WB常+1)*100.0
BigDecimal
WB
=
BigDecimal
.
valueOf
(
Math
.
log
(
weiboArticle
+
1
)).
divide
(
BigDecimal
.
valueOf
(
Math
.
log
(
weiboArticleWeight
.
getConstant
()
+
1
)),
20
,
RoundingMode
.
HALF_UP
).
multiply
(
bigDecimal100
);
// 微博互动数:WBI标= ln(WBI+1)/ln(WBI常+1)*100.0
BigDecimal
WBI
=
BigDecimal
.
valueOf
(
Math
.
log
(
weiboInteraction
+
1
)).
divide
(
BigDecimal
.
valueOf
(
Math
.
log
(
weiboInteractionWeight
.
getConstant
()
+
1
)),
20
,
RoundingMode
.
HALF_UP
).
multiply
(
bigDecimal100
);
// 头条文章数:T标= T/T常*100.0
BigDecimal
T
=
BigDecimal
.
valueOf
(
toutiaoArticle
).
divide
(
BigDecimal
.
valueOf
(
toutiaoArticleWeight
.
getConstant
()),
20
,
RoundingMode
.
HALF_UP
).
multiply
(
bigDecimal100
);
// 头条阅读数:TR标=ln(TR+1)/ln(TR常+1)*100.0
BigDecimal
TR
=
BigDecimal
.
valueOf
(
Math
.
log
(
toutiaoRead
+
1
)).
divide
(
BigDecimal
.
valueOf
(
Math
.
log
(
toutiaoReadWeight
.
getConstant
()
+
1
)),
20
,
RoundingMode
.
HALF_UP
).
multiply
(
bigDecimal100
);
// 头条互动数:TI标= ln(TI+1)/ln(TI常+1)*100.0
BigDecimal
TI
=
BigDecimal
.
valueOf
(
Math
.
log
(
toutiaoInteraction
+
1
)).
divide
(
BigDecimal
.
valueOf
(
Math
.
log
(
toutiaoInteractionWeight
.
getConstant
()
+
1
)),
20
,
RoundingMode
.
HALF_UP
).
multiply
(
bigDecimal100
);
// 标准值与权重计算取和得RMI
return
NM
.
multiply
(
BigDecimal
.
valueOf
(
normalMediaArticleWeight
.
getWeight
()))
.
add
(
O
P
.
multiply
(
BigDecimal
.
valueOf
(
otherPlatformArticleWeight
.
getWeight
())))
.
add
(
O
M
.
multiply
(
BigDecimal
.
valueOf
(
otherPlatformArticleWeight
.
getWeight
())))
.
add
(
WC
.
multiply
(
BigDecimal
.
valueOf
(
wechatArticleWeight
.
getWeight
())))
.
add
(
WCR
.
multiply
(
BigDecimal
.
valueOf
(
wechatReadWeight
.
getWeight
())))
.
add
(
WCL
.
multiply
(
BigDecimal
.
valueOf
(
wechatReadingWeight
.
getWeight
())))
.
add
(
WB
.
multiply
(
BigDecimal
.
valueOf
(
weiboArticleWeight
.
getWeight
())))
.
add
(
WBF
.
multiply
(
BigDecimal
.
valueOf
(
weiboForwardWeight
.
getWeight
())))
.
add
(
WBC
.
multiply
(
BigDecimal
.
valueOf
(
weiboCommentWeight
.
getWeight
())))
.
add
(
WBL
.
multiply
(
BigDecimal
.
valueOf
(
weiboLikeWeight
.
getWeight
())))
.
setScale
(
7
,
RoundingMode
.
HALF_UP
)
.
add
(
WBI
.
multiply
(
BigDecimal
.
valueOf
(
weiboInteractionWeight
.
getWeight
())))
.
add
(
T
.
multiply
(
BigDecimal
.
valueOf
(
toutiaoArticleWeight
.
getWeight
())))
.
add
(
TR
.
multiply
(
BigDecimal
.
valueOf
(
toutiaoReadWeight
.
getWeight
())))
.
add
(
TI
.
multiply
(
BigDecimal
.
valueOf
(
toutiaoInteractionWeight
.
getWeight
())))
.
setScale
(
1
,
RoundingMode
.
HALF_UP
)
.
doubleValue
();
}
...
...
@@ -876,7 +871,7 @@ public class ToolsetServiceImpl implements ToolsetService {
* @return
*/
private
double
computeFinalInf
(
double
inf
,
double
RMI
){
return
BigDecimal
.
valueOf
(
inf
).
add
(
BigDecimal
.
valueOf
(
RMI
)).
divide
(
BigDecimal
.
valueOf
(
2
),
7
,
RoundingMode
.
HALF_UP
).
doubleValue
();
return
BigDecimal
.
valueOf
(
inf
).
add
(
BigDecimal
.
valueOf
(
RMI
)).
divide
(
BigDecimal
.
valueOf
(
2
),
1
,
RoundingMode
.
HALF_UP
).
doubleValue
();
}
/**
...
...
src/main/java/com/zhiwei/brandkbs2/util/RedisUtil.java
View file @
6fe16ea2
...
...
@@ -59,6 +59,10 @@ public class RedisUtil {
return
RedisKeyPrefix
.
INDEX_SPREAD
+
Tools
.
concat
(
projectId
,
startTime
,
endTime
);
}
public
static
String
getIndexEmotionKey
(
String
projectId
,
Long
startTime
,
Long
endTime
)
{
return
RedisKeyPrefix
.
INDEX_EMOTION
+
Tools
.
concat
(
projectId
,
startTime
,
endTime
);
}
public
static
String
getChannelRecordList
(
String
projectId
,
Long
startTime
,
Long
endTime
,
String
platform
,
int
emotion
)
{
return
RedisKeyPrefix
.
CHANNEL_RECORD_LIST
+
Tools
.
concat
(
projectId
,
startTime
,
endTime
,
platform
,
emotion
);
}
...
...
src/main/java/com/zhiwei/brandkbs2/util/Tools.java
View file @
6fe16ea2
...
...
@@ -52,7 +52,7 @@ import java.util.stream.Stream;
import
java.util.zip.GZIPInputStream
;
import
java.util.zip.GZIPOutputStream
;
import
static
com
.
zhiwei
.
brandkbs2
.
common
.
GenericAttribute
.
ES_MARK_CACHE_MAPS
;
import
static
com
.
zhiwei
.
brandkbs2
.
common
.
GenericAttribute
.
*
;
import
static
com
.
zhiwei
.
brandkbs2
.
config
.
Constant
.*;
import
static
java
.
util
.
Objects
.
nonNull
;
...
...
@@ -75,6 +75,16 @@ public class Tools {
private
static
final
DozerBeanMapper
DOZER_BEAN_MAPPER
=
new
DozerBeanMapper
();
/**
* 须过滤的标题
*/
public
static
final
List
<
String
>
FILTER_TITLE
=
Arrays
.
asList
(
"Notitle"
,
"分享一篇文章"
,
"分享一篇文章。"
,
"暂无标题"
);
/**
* 须过滤的渠道
*/
public
static
final
List
<
String
>
FILTER_SOURCE
=
Arrays
.
asList
(
"匿名"
);
/**
* 上传文件
...
...
@@ -1345,4 +1355,22 @@ public class Tools {
}
return
Arrays
.
stream
(
str
.
split
(
"[\\u007c]+"
)).
filter
(
StringUtils:
:
isNotBlank
).
collect
(
Collectors
.
joining
(
"|"
));
}
/**
* 过滤 “分享一篇文章”,”暂无标题“,”Notitle“ 的无用标题
* @param title
* @return
*/
public
static
Boolean
filterUselessTitle
(
String
title
){
return
FILTER_TITLE
.
contains
(
title
);
}
/**
* 过滤 “匿名“ 的无用渠道
* @param source
* @return
*/
public
static
Boolean
filterUselessSource
(
String
source
){
return
FILTER_SOURCE
.
contains
(
source
);
}
}
\ No newline at end of file
src/main/resources/application-dev.properties
View file @
6fe16ea2
...
...
@@ -2,9 +2,9 @@ application.name = brandkbs2
server.port
=
8888
spring.flyway.encoding
=
UTF-8
#\u5355\u4E2A\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u8BBE\u7F6E
spring.servlet.multipart.max-file-size
=
10MB
spring.servlet.multipart.max-file-size
=
10
0
MB
#\u603B\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u8BBE\u7F6E
spring.servlet.multipart.max-request-size
=
20MB
spring.servlet.multipart.max-request-size
=
20
0
MB
server.servlet.context-path
=
/brandkbs
#jwt
jwt.key
=
Token
...
...
src/main/resources/application-local.properties
View file @
6fe16ea2
...
...
@@ -2,9 +2,9 @@ application.name = brandkbs2
server.port
=
8888
spring.flyway.encoding
=
UTF-8
#\u5355\u4E2A\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u8BBE\u7F6E
spring.servlet.multipart.max-file-size
=
10MB
spring.servlet.multipart.max-file-size
=
10
0
MB
#\u603B\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u8BBE\u7F6E
spring.servlet.multipart.max-request-size
=
20MB
spring.servlet.multipart.max-request-size
=
20
0
MB
server.servlet.context-path
=
/brandkbs
#jwt
jwt.key
=
Token
...
...
src/main/resources/application-prod.properties
View file @
6fe16ea2
...
...
@@ -2,9 +2,9 @@ application.name = brandkbs2
server.port
=
8888
spring.flyway.encoding
=
UTF-8
#\u5355\u4E2A\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u8BBE\u7F6E
spring.servlet.multipart.max-file-size
=
10MB
spring.servlet.multipart.max-file-size
=
10
0
MB
#\u603B\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u8BBE\u7F6E
spring.servlet.multipart.max-request-size
=
20MB
spring.servlet.multipart.max-request-size
=
20
0
MB
server.servlet.context-path
=
/brandkbs
#jwt
jwt.key
=
Token
...
...
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