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
e62f3dcd
Commit
e62f3dcd
authored
Oct 23, 2023
by
shentao
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature' into 'dev'
工具库-事件影响力更新功能 See merge request
!406
parents
d6cb9456
c1036fc1
Hide whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
1302 additions
and
34 deletions
+1302
-34
src/main/java/com/zhiwei/brandkbs2/controller/admin/ProjectController.java
+12
-4
src/main/java/com/zhiwei/brandkbs2/controller/app/AppDownloadController.java
+38
-0
src/main/java/com/zhiwei/brandkbs2/controller/app/AppToolsetController.java
+67
-0
src/main/java/com/zhiwei/brandkbs2/dao/BytedanceCustomChannelDao.java
+15
-0
src/main/java/com/zhiwei/brandkbs2/dao/BytedanceCustomChannelInfluenceDao.java
+16
-0
src/main/java/com/zhiwei/brandkbs2/dao/BytedanceCustomEventUpdateTaskDao.java
+15
-0
src/main/java/com/zhiwei/brandkbs2/dao/BytedanceCustomPlatformWeightDao.java
+12
-0
src/main/java/com/zhiwei/brandkbs2/dao/impl/BytedanceCustomChannelDaoImpl.java
+27
-0
src/main/java/com/zhiwei/brandkbs2/dao/impl/BytedanceCustomChannelInfluenceDaoImpl.java
+28
-0
src/main/java/com/zhiwei/brandkbs2/dao/impl/BytedanceCustomEventUpdateTaskDaoImpl.java
+27
-0
src/main/java/com/zhiwei/brandkbs2/dao/impl/BytedanceCustomPlatformWeightDaoImpl.java
+21
-0
src/main/java/com/zhiwei/brandkbs2/easyexcel/dto/ExportBytedanceEventComputeResultDTO.java
+28
-0
src/main/java/com/zhiwei/brandkbs2/easyexcel/dto/UploadBytedanceEventDTO.java
+41
-0
src/main/java/com/zhiwei/brandkbs2/easyexcel/listener/BytedanceEventListener.java
+42
-0
src/main/java/com/zhiwei/brandkbs2/pojo/BytedanceCustomChannel.java
+21
-0
src/main/java/com/zhiwei/brandkbs2/pojo/BytedanceCustomChannelInfluence.java
+30
-0
src/main/java/com/zhiwei/brandkbs2/pojo/BytedanceCustomEventUpdateTask.java
+168
-0
src/main/java/com/zhiwei/brandkbs2/pojo/BytedanceCustomPlatformWeight.java
+24
-0
src/main/java/com/zhiwei/brandkbs2/pojo/Project.java
+9
-3
src/main/java/com/zhiwei/brandkbs2/pojo/vo/ProjectVO.java
+8
-0
src/main/java/com/zhiwei/brandkbs2/service/ProjectService.java
+8
-0
src/main/java/com/zhiwei/brandkbs2/service/ToolsetService.java
+79
-0
src/main/java/com/zhiwei/brandkbs2/service/impl/ProjectServiceImpl.java
+45
-3
src/main/java/com/zhiwei/brandkbs2/service/impl/ToolsetServiceImpl.java
+515
-21
src/main/resources/application-dev.properties
+2
-1
src/main/resources/application-local.properties
+2
-1
src/main/resources/application-prod.properties
+2
-1
No files found.
src/main/java/com/zhiwei/brandkbs2/controller/admin/ProjectController.java
View file @
e62f3dcd
...
...
@@ -14,10 +14,7 @@ import com.zhiwei.brandkbs2.pojo.vo.ProjectVO;
import
com.zhiwei.brandkbs2.service.*
;
import
com.zhiwei.brandkbs2.util.Tools
;
import
com.zhiwei.middleware.mark.vo.MarkerTag
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.*
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.http.ResponseEntity
;
...
...
@@ -207,6 +204,17 @@ public class ProjectController extends BaseController {
return
ResponseResult
.
success
(
eventTags
);
}
@ApiOperation
(
"获取项目模块配置-工具库-字节事件影响力详情"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"page"
,
value
=
"页码"
,
required
=
false
,
defaultValue
=
"1"
,
paramType
=
"query"
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"size"
,
value
=
"每页记录数"
,
required
=
false
,
defaultValue
=
"10"
,
paramType
=
"query"
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"type"
,
value
=
"详情类型"
,
required
=
true
,
defaultValue
=
""
,
paramType
=
"query"
,
dataType
=
"string"
)})
@GetMapping
(
"/bytedance/info"
)
public
ResponseResult
getToolsetBytedanceCustomInfo
(
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
int
page
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"10"
)
int
pageSize
,
@ApiParam
(
name
=
"type"
,
value
=
"重要媒体|平台权重|渠道影响力"
)
@RequestParam
(
value
=
"type"
)
String
type
)
{
return
ResponseResult
.
success
(
ProjectService
.
getToolsetBytedanceCustomInfo
(
page
,
pageSize
,
type
));
}
@ApiOperation
(
"产品公告-新建公告"
)
@PostMapping
(
"/notice/add"
)
public
ResponseResult
addNoticeInfo
(
@RequestBody
NoticeInfoDTO
noticeInfoDTO
){
...
...
src/main/java/com/zhiwei/brandkbs2/controller/app/AppDownloadController.java
View file @
e62f3dcd
...
...
@@ -66,6 +66,9 @@ public class AppDownloadController extends BaseController {
@Resource
(
name
=
"markDataServiceImpl"
)
MarkDataService
markDataService
;
@Resource
(
name
=
"toolsetServiceImpl"
)
private
ToolsetService
toolsetService
;
@Value
(
"${qbjc.interface.url}"
)
private
String
yuqingInterface
;
...
...
@@ -498,6 +501,41 @@ public class AppDownloadController extends BaseController {
return
ResponseResult
.
success
(
filePath
);
}
@ApiOperation
(
"工具库-事件影响力更新-模板下载"
)
@GetMapping
(
"/event-update/template"
)
@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
(
"微信在看"
));
// excel写入至指定路径
String
projectName
=
projectService
.
getProjectById
(
UserThreadLocal
.
getProjectId
()).
getProjectName
();
String
filePath
=
EasyExcelUtil
.
generateExcelFilePath
(
brandkbsFilePath
,
projectName
,
UserThreadLocal
.
getNickname
(),
"事件更新模板"
);
EasyExcelUtil
.
dynamicHeadWrite
(
filePath
,
"模板"
,
head
,
Collections
.
emptyList
());
return
ResponseResult
.
success
(
filePath
);
}
@ApiOperation
(
"工具库-事件影响力更新-本品更新结果下载"
)
@GetMapping
(
"/event-update/result"
)
@DownloadTask
(
taskName
=
"本品更新结果下载"
,
description
=
"本品更新结果"
)
public
ResponseResult
downloadPrimaryComputeResult
(
@RequestParam
(
name
=
"taskId"
)
String
taskId
){
return
ResponseResult
.
success
(
toolsetService
.
downloadPrimaryComputeResult
(
taskId
));
}
@ApiOperation
(
"工具库-事件影响力更新-本品报错数据下载"
)
@GetMapping
(
"/event-update/error-data"
)
@DownloadTask
(
taskName
=
"报错数据下载"
,
description
=
"报错数据"
)
public
ResponseResult
downloadPrimaryErrorData
(
@RequestParam
(
name
=
"taskId"
)
String
taskId
){
return
ResponseResult
.
success
(
toolsetService
.
downloadPrimaryErrorData
(
taskId
));
}
private
HttpHeaders
getHeaders
()
{
HttpHeaders
httpHeaders
=
new
HttpHeaders
();
httpHeaders
.
set
(
"token"
,
token
);
...
...
src/main/java/com/zhiwei/brandkbs2/controller/app/AppToolsetController.java
View file @
e62f3dcd
...
...
@@ -71,4 +71,71 @@ public class AppToolsetController {
@ApiParam
(
name
=
"type"
,
value
=
"关键词|文章"
)
@RequestParam
String
type
){
return
toolsetService
.
getHighWord
(
file
,
type
);
}
@ApiOperation
(
"工具库-事件影响力更新-本品更新"
)
@PostMapping
(
"/event-update/primary"
)
@LogRecord
(
description
=
"工具库-本品事件影响力更新"
)
public
ResponseResult
primaryEventUpdate
(
@RequestParam
MultipartFile
file
,
@RequestParam
Boolean
extraCompute
){
toolsetService
.
primaryEventUpdate
(
file
,
extraCompute
);
return
ResponseResult
.
success
();
}
@ApiOperation
(
"工具库-事件影响力更新-竞品更新"
)
@GetMapping
(
"/event-update/contend"
)
@LogRecord
(
description
=
"工具库-竞品事件影响力更新"
)
public
ResponseResult
contendEventUpdate
(
@RequestParam
(
name
=
"keyword"
)
String
keyword
,
@RequestParam
(
name
=
"startTime"
)
Long
startTime
,
@RequestParam
(
name
=
"endTime"
)
Long
endTime
){
toolsetService
.
contendEventUpdate
(
keyword
,
startTime
,
endTime
);
return
ResponseResult
.
success
();
}
@ApiOperation
(
"工具库-事件影响力更新-本品补充更新"
)
@PostMapping
(
"/event-update/primary/additional"
)
public
ResponseResult
eventAdditionalUpdate
(
@RequestParam
MultipartFile
file
,
@RequestParam
String
taskId
){
toolsetService
.
eventAdditionalUpdate
(
file
,
taskId
);
return
ResponseResult
.
success
();
}
@ApiOperation
(
"工具库-事件影响力更新-轮询事件更新处理状态"
)
@GetMapping
(
"/event-update/schedule"
)
public
ResponseResult
scheduleProcessStatus
(){
return
ResponseResult
.
success
(
toolsetService
.
scheduleProcessStatus
());
}
@ApiOperation
(
"工具库-事件影响力更新-本品更新结果"
)
@GetMapping
(
"/event-update/primary/result"
)
public
ResponseResult
getPrimaryComputeResult
(
@RequestParam
(
name
=
"taskId"
)
String
taskId
,
@RequestParam
(
name
=
"page"
)
int
page
,
@RequestParam
(
name
=
"pageSize"
)
int
pageSize
){
return
ResponseResult
.
success
(
toolsetService
.
getPrimaryComputeResult
(
taskId
,
page
,
pageSize
));
}
@ApiOperation
(
"工具库-事件影响力更新-竞品更新结果"
)
@PutMapping
(
"/event-update/contend/result/{taskId}"
)
public
ResponseResult
getContendComputeResult
(
@PathVariable
String
taskId
){
return
ResponseResult
.
success
(
toolsetService
.
getContendComputeResult
(
taskId
));
}
@ApiOperation
(
"工具库-事件影响力更新-历史记录"
)
@GetMapping
(
"/event-update/history"
)
public
ResponseResult
getEventUpdateTaskList
(
@RequestParam
(
name
=
"page"
)
int
page
,
@RequestParam
(
name
=
"pageSize"
)
int
pageSize
){
return
ResponseResult
.
success
(
toolsetService
.
getEventUpdateTaskList
(
page
,
pageSize
));
}
@ApiOperation
(
"工具库-事件影响力更新-取消任务"
)
@PutMapping
(
"/event-update/cancel/{taskId}"
)
public
ResponseResult
cancelTask
(
@PathVariable
String
taskId
){
toolsetService
.
cancelTask
(
taskId
);
return
ResponseResult
.
success
();
}
@ApiOperation
(
"工具库-事件影响力更新-获取是否有未读任务信息"
)
@GetMapping
(
"/event-update/getRead"
)
public
ResponseResult
getIfUnread
(){
return
ResponseResult
.
success
(
toolsetService
.
getIfUnread
());
}
}
src/main/java/com/zhiwei/brandkbs2/dao/BytedanceCustomChannelDao.java
0 → 100644
View file @
e62f3dcd
package
com
.
zhiwei
.
brandkbs2
.
dao
;
import
com.zhiwei.brandkbs2.pojo.BytedanceCustomChannel
;
import
org.springframework.data.mongodb.core.query.Query
;
/**
* @ClassName: BytedanceCustomChannelDao
* @Description BytedanceCustomChannelDao
* @author: cjz
* @date: 2023-10-13 15:43
*/
public
interface
BytedanceCustomChannelDao
extends
BaseMongoDao
<
BytedanceCustomChannel
>{
boolean
exist
(
Query
query
);
}
src/main/java/com/zhiwei/brandkbs2/dao/BytedanceCustomChannelInfluenceDao.java
0 → 100644
View file @
e62f3dcd
package
com
.
zhiwei
.
brandkbs2
.
dao
;
import
com.zhiwei.brandkbs2.pojo.BytedanceCustomChannelInfluence
;
import
org.springframework.data.mongodb.core.query.Query
;
/**
* @ClassName: BytedanceCustomChannelInfluenceDao
* @Description BytedanceCustomChannelInfluenceDao
* @author: cjz
* @date: 2023-10-13 15:45
*/
public
interface
BytedanceCustomChannelInfluenceDao
extends
BaseMongoDao
<
BytedanceCustomChannelInfluence
>{
BytedanceCustomChannelInfluence
findOne
(
Query
query
);
}
src/main/java/com/zhiwei/brandkbs2/dao/BytedanceCustomEventUpdateTaskDao.java
0 → 100644
View file @
e62f3dcd
package
com
.
zhiwei
.
brandkbs2
.
dao
;
import
com.zhiwei.brandkbs2.pojo.BytedanceCustomEventUpdateTask
;
import
org.springframework.data.mongodb.core.query.Query
;
/**
* @ClassName: BytedanceCustomEventUpdateTaskDao
* @Description BytedanceCustomEventUpdateTaskDao
* @author: cjz
* @date: 2023-10-17 09:30
*/
public
interface
BytedanceCustomEventUpdateTaskDao
extends
BaseMongoDao
<
BytedanceCustomEventUpdateTask
>{
BytedanceCustomEventUpdateTask
findOne
(
Query
query
);
}
src/main/java/com/zhiwei/brandkbs2/dao/BytedanceCustomPlatformWeightDao.java
0 → 100644
View file @
e62f3dcd
package
com
.
zhiwei
.
brandkbs2
.
dao
;
import
com.zhiwei.brandkbs2.pojo.BytedanceCustomPlatformWeight
;
/**
* @ClassName: BytedanceCustomChannelWeightDao
* @Description BytedanceCustomChannelWeightDao
* @author: cjz
* @date: 2023-10-13 15:47
*/
public
interface
BytedanceCustomPlatformWeightDao
extends
BaseMongoDao
<
BytedanceCustomPlatformWeight
>{
}
src/main/java/com/zhiwei/brandkbs2/dao/impl/BytedanceCustomChannelDaoImpl.java
0 → 100644
View file @
e62f3dcd
package
com
.
zhiwei
.
brandkbs2
.
dao
.
impl
;
import
com.zhiwei.brandkbs2.dao.BytedanceCustomChannelDao
;
import
com.zhiwei.brandkbs2.pojo.BytedanceCustomChannel
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.stereotype.Component
;
/**
* @ClassName: BytedanceCustomChannelDaoImpl
* @Description BytedanceCustomChannelDaoImpl
* @author: cjz
* @date: 2023-10-13 15:44
*/
@Component
(
"bytedanceCustomChannelDao"
)
public
class
BytedanceCustomChannelDaoImpl
extends
BaseMongoDaoImpl
<
BytedanceCustomChannel
>
implements
BytedanceCustomChannelDao
{
private
static
final
String
COLLECTION_NAME
=
"brandkbs_bytedance_custom_channel"
;
public
BytedanceCustomChannelDaoImpl
()
{
super
(
COLLECTION_NAME
);
}
@Override
public
boolean
exist
(
Query
query
)
{
return
mongoTemplate
.
exists
(
query
,
BytedanceCustomChannel
.
class
);
}
}
src/main/java/com/zhiwei/brandkbs2/dao/impl/BytedanceCustomChannelInfluenceDaoImpl.java
0 → 100644
View file @
e62f3dcd
package
com
.
zhiwei
.
brandkbs2
.
dao
.
impl
;
import
com.zhiwei.brandkbs2.dao.BytedanceCustomChannelInfluenceDao
;
import
com.zhiwei.brandkbs2.pojo.BytedanceCustomChannelInfluence
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.stereotype.Component
;
/**
* @ClassName: BytedanceCustomChannelInfluenceDaoImpl
* @Description BytedanceCustomChannelInfluenceDaoImpl
* @author: cjz
* @date: 2023-10-13 15:46
*/
@Component
(
"bytedanceCustomChannelInfluenceDao"
)
public
class
BytedanceCustomChannelInfluenceDaoImpl
extends
BaseMongoDaoImpl
<
BytedanceCustomChannelInfluence
>
implements
BytedanceCustomChannelInfluenceDao
{
private
static
final
String
COLLECTION_NAME
=
"brandkbs_bytedance_custom_channel_influence"
;
public
BytedanceCustomChannelInfluenceDaoImpl
()
{
super
(
COLLECTION_NAME
);
}
@Override
public
BytedanceCustomChannelInfluence
findOne
(
Query
query
)
{
return
mongoTemplate
.
findOne
(
query
,
BytedanceCustomChannelInfluence
.
class
,
COLLECTION_NAME
);
}
}
src/main/java/com/zhiwei/brandkbs2/dao/impl/BytedanceCustomEventUpdateTaskDaoImpl.java
0 → 100644
View file @
e62f3dcd
package
com
.
zhiwei
.
brandkbs2
.
dao
.
impl
;
import
com.zhiwei.brandkbs2.dao.BytedanceCustomEventUpdateTaskDao
;
import
com.zhiwei.brandkbs2.pojo.BytedanceCustomEventUpdateTask
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.stereotype.Component
;
/**
* @ClassName: BytedanceCustomEventUpdateTaskDaoImpl
* @Description BytedanceCustomEventUpdateTaskDaoImpl
* @author: cjz
* @date: 2023-10-17 09:31
*/
@Component
(
"bytedanceCustomEventUpdateTaskDao"
)
public
class
BytedanceCustomEventUpdateTaskDaoImpl
extends
BaseMongoDaoImpl
<
BytedanceCustomEventUpdateTask
>
implements
BytedanceCustomEventUpdateTaskDao
{
private
static
final
String
COLLECTION_NAME
=
"brandkbs_bytedance_custom_event_task"
;
public
BytedanceCustomEventUpdateTaskDaoImpl
()
{
super
(
COLLECTION_NAME
);
}
@Override
public
BytedanceCustomEventUpdateTask
findOne
(
Query
query
)
{
return
mongoTemplate
.
findOne
(
query
,
BytedanceCustomEventUpdateTask
.
class
,
COLLECTION_NAME
);
}
}
src/main/java/com/zhiwei/brandkbs2/dao/impl/BytedanceCustomPlatformWeightDaoImpl.java
0 → 100644
View file @
e62f3dcd
package
com
.
zhiwei
.
brandkbs2
.
dao
.
impl
;
import
com.zhiwei.brandkbs2.dao.BytedanceCustomPlatformWeightDao
;
import
com.zhiwei.brandkbs2.pojo.BytedanceCustomPlatformWeight
;
import
org.springframework.stereotype.Component
;
/**
* @ClassName: BytedanceCustomChannelWeightDaoImpl
* @Description BytedanceCustomChannelWeightDaoImpl
* @author: cjz
* @date: 2023-10-13 15:49
*/
@Component
(
"BytedanceCustomPlatformWeightDao"
)
public
class
BytedanceCustomPlatformWeightDaoImpl
extends
BaseMongoDaoImpl
<
BytedanceCustomPlatformWeight
>
implements
BytedanceCustomPlatformWeightDao
{
private
static
final
String
COLLECTION_NAME
=
"brandkbs_bytedance_custom_platform_weight"
;
public
BytedanceCustomPlatformWeightDaoImpl
()
{
super
(
COLLECTION_NAME
);
}
}
src/main/java/com/zhiwei/brandkbs2/easyexcel/dto/ExportBytedanceEventComputeResultDTO.java
0 → 100644
View file @
e62f3dcd
package
com
.
zhiwei
.
brandkbs2
.
easyexcel
.
dto
;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
lombok.Data
;
import
lombok.ToString
;
/**
* @author cjz
* @version 1.0
* @description 导出字节时间影响力更新结果
* @date 2023/9/14 15:31
*/
@Data
@ToString
public
class
ExportBytedanceEventComputeResultDTO
{
@ExcelProperty
(
"事件名"
)
private
String
name
;
@ExcelProperty
(
"影响力指数"
)
private
Double
inf
;
@ExcelProperty
(
"实时传播力"
)
private
Double
RMI
;
@ExcelProperty
(
"传播影响力"
)
private
Double
finalInf
;
}
src/main/java/com/zhiwei/brandkbs2/easyexcel/dto/UploadBytedanceEventDTO.java
0 → 100644
View file @
e62f3dcd
package
com
.
zhiwei
.
brandkbs2
.
easyexcel
.
dto
;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
lombok.Data
;
/**
* @author cjz
* @version 1.0
* @description 解析字节定制事件影响力更新上传文件
* @date 2023/10/16 09:45
*/
@Data
public
class
UploadBytedanceEventDTO
{
@ExcelProperty
(
"平台类型"
)
private
String
platform
;
@ExcelProperty
(
"渠道名称"
)
private
String
channel
;
@ExcelProperty
(
"链接"
)
private
String
url
;
@ExcelProperty
(
"事件名"
)
private
String
eventName
;
@ExcelProperty
(
"微博转发"
)
private
Integer
weiboForward
;
@ExcelProperty
(
"微博评论"
)
private
Integer
weiboComment
;
@ExcelProperty
(
"微博点赞"
)
private
Integer
weiboLike
;
@ExcelProperty
(
"微信阅读"
)
private
Integer
wechatRead
;
@ExcelProperty
(
"微信在看"
)
private
Integer
wechatReading
;
}
src/main/java/com/zhiwei/brandkbs2/easyexcel/listener/BytedanceEventListener.java
0 → 100644
View file @
e62f3dcd
package
com
.
zhiwei
.
brandkbs2
.
easyexcel
.
listener
;
import
com.alibaba.excel.context.AnalysisContext
;
import
com.alibaba.excel.event.AnalysisEventListener
;
import
com.zhiwei.brandkbs2.easyexcel.dto.UploadBytedanceEventDTO
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
/**
* @ClassName: BytedanceEventListener
* @Description 字节事件上传监听类
* @author: cjz
* @date: 2023-10-16 09:50
*/
public
class
BytedanceEventListener
extends
AnalysisEventListener
<
UploadBytedanceEventDTO
>
{
private
Map
<
String
,
List
<
UploadBytedanceEventDTO
>>
map
;
public
BytedanceEventListener
(
Map
<
String
,
List
<
UploadBytedanceEventDTO
>>
map
){
this
.
map
=
map
;
}
@Override
public
void
invoke
(
UploadBytedanceEventDTO
data
,
AnalysisContext
context
)
{
if
(
map
.
containsKey
(
data
.
getEventName
())){
map
.
get
(
data
.
getEventName
()).
add
(
data
);
}
else
{
List
<
UploadBytedanceEventDTO
>
list
=
new
ArrayList
<>();
list
.
add
(
data
);
map
.
put
(
data
.
getEventName
(),
list
);
}
}
@Override
public
void
doAfterAllAnalysed
(
AnalysisContext
context
)
{
}
}
src/main/java/com/zhiwei/brandkbs2/pojo/BytedanceCustomChannel.java
0 → 100644
View file @
e62f3dcd
package
com
.
zhiwei
.
brandkbs2
.
pojo
;
import
lombok.Getter
;
import
lombok.Setter
;
/**
* @ClassName: BytedanceCustomChannel
* @Description 字节定制重要媒体匹配
* @author: cjz
* @date: 2023-10-13 15:11
*/
@Getter
@Setter
public
class
BytedanceCustomChannel
extends
AbstractBaseMongo
{
/**
* 渠道名
*/
private
String
channel
;
}
src/main/java/com/zhiwei/brandkbs2/pojo/BytedanceCustomChannelInfluence.java
0 → 100644
View file @
e62f3dcd
package
com
.
zhiwei
.
brandkbs2
.
pojo
;
import
lombok.Getter
;
import
lombok.Setter
;
/**
* @ClassName: BytedanceCustomChannel
* @Description 字节定制指定渠道影响力
* @author: cjz
* @date: 2023-10-13 15:12
*/
@Getter
@Setter
public
class
BytedanceCustomChannelInfluence
extends
AbstractBaseMongo
{
/**
* 平台
*/
private
String
platform
;
/**
* 渠道
*/
private
String
channel
;
/**
* 影响力
*/
private
double
influence
;
}
src/main/java/com/zhiwei/brandkbs2/pojo/BytedanceCustomEventUpdateTask.java
0 → 100644
View file @
e62f3dcd
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
* @Description 字节定制事件影响力计算rw
* @author: cjz
* @date: 2023-10-16 15:12
*/
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public
class
BytedanceCustomEventUpdateTask
extends
AbstractBaseMongo
{
/**
* 类型 primary|contend
*/
private
String
type
;
/**
* 任务状态
*/
private
String
taskStatus
;
/**
* 处理状态
*/
private
String
processStatus
;
/**
* 是否计算实时传播力与传播影响力
*/
private
Boolean
extraCompute
;
/**
* 事件信息
*/
private
List
<
EventInfo
>
eventInfo
;
/**
* 事件数据
*/
private
Map
<
String
,
List
<
UploadBytedanceEventDTO
>>
eventData
;
/**
* 报错数据
*/
private
List
<
UploadBytedanceEventDTO
>
errorData
;
/**
* 竞品影响力指数
*/
private
Double
contendInfluence
;
/**
* 是否已读
*/
private
Boolean
read
;
/**
* 是否取消任务
*/
private
Boolean
cancel
;
/**
* 项目id
*/
private
String
projectId
;
private
String
userId
;
private
String
nickName
;
private
Long
cTime
;
private
Long
uTime
;
@Data
@NoArgsConstructor
public
static
class
EventInfo
{
/**
* 事件名
*/
private
String
name
;
/**
* 影响力指数
*/
private
Double
influence
;
/**
* 实时传播力
*/
private
Double
RMI
;
/**
* 传播影响力
*/
private
Double
finalInfluence
;
}
@Getter
public
enum
TaskStatus
{
FINISH
(
"finish"
,
"已完成"
),
CALCULATING
(
"calculating"
,
"进行中"
),
ERROR
(
"error"
,
"出错"
),
MANUAL_CANCEL
(
"manualCancel"
,
"手动取消任务"
);
private
final
String
status
;
private
final
String
description
;
TaskStatus
(
String
status
,
String
description
){
this
.
status
=
status
;
this
.
description
=
description
;
}
}
@Getter
public
enum
ProcessStatus
{
CHANNEL_MATCH
(
"channelMatch"
,
"渠道匹配"
),
INTERACTION_UPDATE
(
"interactionUpdate"
,
"互动量更新"
),
INFLUENCE_COMPUTE
(
"influenceCompute"
,
"影响力计算"
),
QUERY_YUQING
(
"queryYuqing"
,
"舆情库采集"
),
FINISH
(
"finish"
,
"计算完成"
);
private
final
String
status
;
private
final
String
description
;
ProcessStatus
(
String
status
,
String
description
){
this
.
status
=
status
;
this
.
description
=
description
;
}
}
public
static
BytedanceCustomEventUpdateTask
createTaskPrimary
(
Boolean
extraCompute
){
BytedanceCustomEventUpdateTask
task
=
new
BytedanceCustomEventUpdateTask
();
task
.
setType
(
"primary"
);
task
.
setTaskStatus
(
TaskStatus
.
CALCULATING
.
getStatus
());
task
.
setProcessStatus
(
ProcessStatus
.
CHANNEL_MATCH
.
getStatus
());
task
.
setExtraCompute
(
extraCompute
);
task
.
setEventInfo
(
null
);
task
.
setErrorData
(
new
ArrayList
<>());
task
.
setCancel
(
false
);
task
.
setProjectId
(
UserThreadLocal
.
getProjectId
());
task
.
setUserId
(
UserThreadLocal
.
getUserId
());
task
.
setNickName
(
UserThreadLocal
.
getNickname
());
task
.
setRead
(
false
);
task
.
setCTime
(
System
.
currentTimeMillis
());
task
.
setUTime
(
System
.
currentTimeMillis
());
return
task
;
}
public
static
BytedanceCustomEventUpdateTask
createTaskContend
(){
BytedanceCustomEventUpdateTask
task
=
new
BytedanceCustomEventUpdateTask
();
task
.
setType
(
"contend"
);
task
.
setTaskStatus
(
TaskStatus
.
CALCULATING
.
getStatus
());
task
.
setProcessStatus
(
ProcessStatus
.
QUERY_YUQING
.
getStatus
());
task
.
setExtraCompute
(
false
);
task
.
setEventInfo
(
null
);
task
.
setErrorData
(
null
);
task
.
setCancel
(
false
);
task
.
setProjectId
(
UserThreadLocal
.
getProjectId
());
task
.
setUserId
(
UserThreadLocal
.
getUserId
());
task
.
setNickName
(
UserThreadLocal
.
getNickname
());
task
.
setRead
(
false
);
task
.
setCTime
(
System
.
currentTimeMillis
());
task
.
setUTime
(
System
.
currentTimeMillis
());
return
task
;
}
}
src/main/java/com/zhiwei/brandkbs2/pojo/BytedanceCustomPlatformWeight.java
0 → 100644
View file @
e62f3dcd
package
com
.
zhiwei
.
brandkbs2
.
pojo
;
import
lombok.Getter
;
import
lombok.Setter
;
/**
* @ClassName: BytedanceCustomChannel
* @Description 字节定制平台指标权重
* @author: cjz
* @date: 2023-10-13 15:15
*/
@Getter
@Setter
public
class
BytedanceCustomPlatformWeight
extends
AbstractBaseMongo
{
/**
* 类型
*/
private
String
type
;
/**
* 权重
*/
private
double
weight
;
}
src/main/java/com/zhiwei/brandkbs2/pojo/Project.java
View file @
e62f3dcd
...
...
@@ -5,9 +5,7 @@ import lombok.Getter;
import
lombok.Setter
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
/**
* @author sjj
...
...
@@ -41,6 +39,11 @@ public class Project extends AbstractProject {
private
List
<
Integer
>
moduleShowList
;
/**
* 工具库功能入口展示列表(目前有:摘要提取,互动量更新,词云,字节影响力计算,其中前三者默认开启)
*/
private
List
<
String
>
toolsetShowList
;
/**
* 重要渠道文件路径
*/
private
String
channelFileUrl
;
...
...
@@ -120,6 +123,9 @@ public class Project extends AbstractProject {
projectVO
.
setContendList
(
this
.
getContendList
());
// 模块配置
projectVO
.
setModuleShowList
(
this
.
getModuleShowList
());
if
(
Objects
.
nonNull
(
this
.
getToolsetShowList
())){
projectVO
.
setToolsetShowList
(
this
.
getToolsetShowList
());
}
projectVO
.
setChannelFileUrl
(
this
.
getChannelFileUrl
());
projectVO
.
setNegativeChannelParams
(
this
.
getNegativeChannelParams
());
projectVO
.
setPositiveChannelParams
(
this
.
getPositiveChannelParams
());
...
...
src/main/java/com/zhiwei/brandkbs2/pojo/vo/ProjectVO.java
View file @
e62f3dcd
...
...
@@ -11,6 +11,7 @@ import lombok.Data;
import
lombok.ToString
;
import
org.bson.types.ObjectId
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -94,6 +95,12 @@ public class ProjectVO {
*/
@ApiModelProperty
(
"舆情数据源(模块展示列表(1:标注库 2:大库))"
)
private
List
<
Integer
>
moduleShowList
;
/**
* 工具库功能入口展示列表(目前有:摘要提取,互动量更新,词云,字节影响力计算,其中前三者默认开启)
*/
@ApiModelProperty
(
"工具库功能入口展示列表(目前有:摘要提取,互动量更新,词云,字节影响力计算,其中前三者默认开启)"
)
private
List
<
String
>
toolsetShowList
=
Arrays
.
asList
(
"articleSummary"
,
"interactionUpdate"
,
"highWord"
);
/**
* 黑渠道对应组
*/
...
...
@@ -152,6 +159,7 @@ public class ProjectVO {
}
}).
collect
(
Collectors
.
toList
()));
project
.
setModuleShowList
(
this
.
getModuleShowList
());
project
.
setToolsetShowList
(
this
.
getToolsetShowList
());
project
.
setChannelFileUrl
(
this
.
getChannelFileUrl
());
project
.
setNegativeChannelParams
((
this
.
getNegativeChannelParams
()));
project
.
setPositiveChannelParams
((
this
.
getPositiveChannelParams
()));
...
...
src/main/java/com/zhiwei/brandkbs2/service/ProjectService.java
View file @
e62f3dcd
...
...
@@ -141,4 +141,12 @@ public interface ProjectService {
*/
List
<
String
>
getHighlightKeyword
(
String
projectId
);
/**
* 获取工具库-事件影响力更新详情
* @param page
* @param pageSize
* @param type
* @return
*/
PageVO
<
JSONObject
>
getToolsetBytedanceCustomInfo
(
int
page
,
int
pageSize
,
String
type
);
}
src/main/java/com/zhiwei/brandkbs2/service/ToolsetService.java
View file @
e62f3dcd
...
...
@@ -2,6 +2,7 @@ package com.zhiwei.brandkbs2.service;
import
com.alibaba.fastjson.JSONObject
;
import
com.zhiwei.brandkbs2.model.ResponseResult
;
import
com.zhiwei.brandkbs2.pojo.vo.PageVO
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.util.List
;
...
...
@@ -69,4 +70,82 @@ public interface ToolsetService {
* @return
*/
ResponseResult
getHighWord
(
MultipartFile
file
,
String
type
);
/**
* 本品事件影响力计算
* @param file excel文件
* @param extraCompute 是否计算实时传播力与传播影响力
*/
void
primaryEventUpdate
(
MultipartFile
file
,
Boolean
extraCompute
);
/**
* 竞品事件影响力计算
* @param keyword 关键词
* @param startTime 开始时间
* @param endTime 结束时间
*/
void
contendEventUpdate
(
String
keyword
,
Long
startTime
,
Long
endTime
);
/**
* 本品事件影响力补充更新
* @param file excel文件
* @param taskId 任务id
*/
void
eventAdditionalUpdate
(
MultipartFile
file
,
String
taskId
);
/**
* 轮询事件更新处理状态
* @return
*/
JSONObject
scheduleProcessStatus
();
/**
* 获取本品更新结果
* @param taskId 任务id
* @param page 页码
* @param pageSize 每页数据量
* @return
*/
PageVO
<
JSONObject
>
getPrimaryComputeResult
(
String
taskId
,
int
page
,
int
pageSize
);
/**
* 获取竞品更新结果
* @param taskId 任务id
* @return
*/
double
getContendComputeResult
(
String
taskId
);
/**
* 本品更新结果下载
* @param taskId 任务id
* @return
*/
String
downloadPrimaryComputeResult
(
String
taskId
);
/**
* 本品报错数据下载
* @param taskId 任务id
* @return
*/
String
downloadPrimaryErrorData
(
String
taskId
);
/**
* 获取字节定制影响力更新历史记录
* @param page 页码
* @param pageSize 每页数据量
* @return
*/
PageVO
<
JSONObject
>
getEventUpdateTaskList
(
int
page
,
int
pageSize
);
/**
* 获取是否有未读任务信息
* @return
*/
Boolean
getIfUnread
();
/**
* 取消任务
* @param taskId 任务id
*/
void
cancelTask
(
String
taskId
);
}
src/main/java/com/zhiwei/brandkbs2/service/impl/ProjectServiceImpl.java
View file @
e62f3dcd
...
...
@@ -5,9 +5,7 @@ import com.zhiwei.brandkbs2.auth.UserThreadLocal;
import
com.zhiwei.brandkbs2.common.GenericAttribute
;
import
com.zhiwei.brandkbs2.common.GlobalPojo
;
import
com.zhiwei.brandkbs2.config.Constant
;
import
com.zhiwei.brandkbs2.dao.EventMiddlewareDao
;
import
com.zhiwei.brandkbs2.dao.ProjectDao
;
import
com.zhiwei.brandkbs2.dao.UserDao
;
import
com.zhiwei.brandkbs2.dao.*
;
import
com.zhiwei.brandkbs2.enmus.response.ProjectCodeEnum
;
import
com.zhiwei.brandkbs2.exception.ExceptionCast
;
import
com.zhiwei.brandkbs2.model.CommonCodeEnum
;
...
...
@@ -70,6 +68,15 @@ public class ProjectServiceImpl implements ProjectService {
@Resource
(
name
=
"eventMiddlewareDao"
)
private
EventMiddlewareDao
eventMiddlewareDao
;
@Resource
(
name
=
"bytedanceCustomChannelDao"
)
private
BytedanceCustomChannelDao
bytedanceCustomChannelDao
;
@Resource
(
name
=
"bytedanceCustomChannelInfluenceDao"
)
private
BytedanceCustomChannelInfluenceDao
bytedanceCustomChannelInfluenceDao
;
@Resource
(
name
=
"BytedanceCustomPlatformWeightDao"
)
private
BytedanceCustomPlatformWeightDao
bytedanceCustomPlatformWeightDao
;
@Value
(
"${jwt.key}"
)
private
String
jwtKey
;
...
...
@@ -433,6 +440,41 @@ public class ProjectServiceImpl implements ProjectService {
return
Objects
.
requireNonNull
(
project
).
getHighlightKeyword
();
}
@Override
public
PageVO
<
JSONObject
>
getToolsetBytedanceCustomInfo
(
int
page
,
int
size
,
String
type
)
{
Query
query
=
new
Query
();
query
.
limit
(
size
);
query
.
skip
((
long
)
(
page
-
1
)
*
size
);
switch
(
type
){
case
"重要媒体"
:
long
total
=
bytedanceCustomChannelDao
.
count
(
query
);
return
PageVO
.
createPageVo
(
total
,
page
,
size
,
bytedanceCustomChannelDao
.
findList
(
query
).
stream
().
map
(
data
->{
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"channel"
,
data
.
getChannel
());
return
jsonObject
;
}).
collect
(
Collectors
.
toList
()));
case
"平台权重"
:
long
total2
=
bytedanceCustomPlatformWeightDao
.
count
(
query
);
return
PageVO
.
createPageVo
(
total2
,
page
,
size
,
bytedanceCustomPlatformWeightDao
.
findList
(
query
).
stream
().
map
(
data
->{
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"type"
,
data
.
getType
());
jsonObject
.
put
(
"weight"
,
data
.
getWeight
());
return
jsonObject
;
}).
collect
(
Collectors
.
toList
()));
case
"渠道影响力"
:
long
total3
=
bytedanceCustomChannelInfluenceDao
.
count
(
query
);
return
PageVO
.
createPageVo
(
total3
,
page
,
size
,
bytedanceCustomChannelInfluenceDao
.
findList
(
query
).
stream
().
map
(
data
->{
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"platform"
,
data
.
getPlatform
());
jsonObject
.
put
(
"channel"
,
data
.
getChannel
());
jsonObject
.
put
(
"influence"
,
data
.
getInfluence
());
return
jsonObject
;
}).
collect
(
Collectors
.
toList
()));
default
:
return
PageVO
.
createPageVo
(
0
,
page
,
size
,
Collections
.
emptyList
());
}
}
/**
* 获取舆情对应项目的情感标签
* @param brandName
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/ToolsetServiceImpl.java
View file @
e62f3dcd
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.controller.app.AppToolsetController
;
import
com.zhiwei.brandkbs2.dao.BytedanceCustomChannelDao
;
import
com.zhiwei.brandkbs2.dao.BytedanceCustomChannelInfluenceDao
;
import
com.zhiwei.brandkbs2.dao.BytedanceCustomEventUpdateTaskDao
;
import
com.zhiwei.brandkbs2.dao.BytedanceCustomPlatformWeightDao
;
import
com.zhiwei.brandkbs2.easyexcel.EasyExcelUtil
;
import
com.zhiwei.brandkbs2.easyexcel.config.ReadExcelDTO
;
import
com.zhiwei.brandkbs2.easyexcel.dto.*
;
import
com.zhiwei.brandkbs2.easyexcel.listener.ArticleSummaryListener
;
import
com.zhiwei.brandkbs2.easyexcel.listener.HighWordArticleListener
;
import
com.zhiwei.brandkbs2.easyexcel.listener.HighWordKeywordListener
;
import
com.zhiwei.brandkbs2.easyexcel.listener.InteractionUpdateListener
;
import
com.zhiwei.brandkbs2.easyexcel.listener.*
;
import
com.zhiwei.brandkbs2.enmus.InteractionEnum
;
import
com.zhiwei.brandkbs2.es.EsClientDao
;
import
com.zhiwei.brandkbs2.es.EsQueryTools
;
import
com.zhiwei.brandkbs2.exception.ExceptionCast
;
import
com.zhiwei.brandkbs2.listener.ApplicationProjectListener
;
import
com.zhiwei.brandkbs2.model.CommonCodeEnum
;
import
com.zhiwei.brandkbs2.model.ResponseResult
;
import
com.zhiwei.brandkbs2.pojo.
InteractionUpdateRecord
;
import
com.zhiwei.brandkbs2.pojo.
Project
;
import
com.zhiwei.brandkbs2.pojo.
*
;
import
com.zhiwei.brandkbs2.pojo.
vo.PageVO
;
import
com.zhiwei.brandkbs2.service.ExtraService
;
import
com.zhiwei.brandkbs2.service.MarkDataService
;
import
com.zhiwei.brandkbs2.service.ProjectService
;
import
com.zhiwei.brandkbs2.service.ToolsetService
;
import
com.zhiwei.brandkbs2.util.RedisUtil
;
import
com.zhiwei.brandkbs2.util.TextUtil
;
import
com.zhiwei.brandkbs2.util.Tools
;
import
org.apache.commons.codec.digest.DigestUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.ListUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.elasticsearch.action.search.SearchResponse
;
import
org.elasticsearch.index.query.BoolQueryBuilder
;
import
org.elasticsearch.index.query.QueryBuilders
;
import
org.elasticsearch.search.SearchHit
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.MediaType
;
...
...
@@ -38,11 +53,16 @@ import org.springframework.web.client.RestTemplate;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.annotation.Resource
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.stream.Collectors
;
import
static
com
.
zhiwei
.
brandkbs2
.
es
.
EsQueryTools
.
cacheMapsNestedQuery
;
import
static
com
.
zhiwei
.
brandkbs2
.
util
.
Tools
.
concat
;
/**
* @ClassName: ToolsetServiceImpl
* @Description ToolsetServiceImpl
...
...
@@ -59,6 +79,9 @@ public class ToolsetServiceImpl implements ToolsetService {
@Resource
(
name
=
"projectServiceImpl"
)
private
ProjectService
projectService
;
@Resource
(
name
=
"markDataServiceImpl"
)
MarkDataService
markDataService
;
@Autowired
private
RestTemplate
restTemplate
;
...
...
@@ -77,9 +100,27 @@ public class ToolsetServiceImpl implements ToolsetService {
@Value
(
"${toolset.interactionResult.url}"
)
private
String
interactionResultUrl
;
@Value
(
"${qbjc.channel.influence}"
)
private
String
channelInfluenceUrl
;
@Resource
(
name
=
"extraServiceImpl"
)
private
ExtraService
extraService
;
@Resource
(
name
=
"bytedanceCustomChannelDao"
)
private
BytedanceCustomChannelDao
bytedanceCustomChannelDao
;
@Resource
(
name
=
"bytedanceCustomChannelInfluenceDao"
)
private
BytedanceCustomChannelInfluenceDao
bytedanceCustomChannelInfluenceDao
;
@Resource
(
name
=
"BytedanceCustomPlatformWeightDao"
)
private
BytedanceCustomPlatformWeightDao
bytedanceCustomPlatformWeightDao
;
@Resource
(
name
=
"bytedanceCustomEventUpdateTaskDao"
)
private
BytedanceCustomEventUpdateTaskDao
bytedanceCustomEventUpdateTaskDao
;
@Resource
(
name
=
"esClientDao"
)
private
EsClientDao
esClientDao
;
@Value
(
"${brandkbs.file.url}"
)
private
String
brandkbsFilePath
;
...
...
@@ -91,6 +132,10 @@ public class ToolsetServiceImpl implements ToolsetService {
private
static
final
String
USER
=
"brandkbs"
;
private
static
final
List
<
String
>
COMMON_MEDIA
=
Arrays
.
asList
(
"网媒"
,
"平媒"
,
"外媒"
,
"自媒体"
);
private
static
final
int
SUM_MAX_ALL
=
11056677
;
@Override
public
ResponseResult
getSingleArticleSummary
(
String
url
)
{
JSONObject
res
=
new
JSONObject
();
...
...
@@ -198,6 +243,30 @@ public class ToolsetServiceImpl implements ToolsetService {
if
(
interactionBalance
-
urls
.
size
()
<
0
){
return
ResponseResult
.
failure
(
"剩余可用次数不足"
);
}
// 链接互动量更新
List
<
JSONObject
>
result
=
urlInteractionUpdate
(
urls
);
AtomicInteger
id
=
new
AtomicInteger
(
0
);
Map
<
Object
,
JSONObject
>
urlMap
=
result
.
stream
().
collect
(
Collectors
.
toMap
(
jsonObject
->
jsonObject
.
get
(
"url"
),
o
->
o
));
List
<
ExportInteractionUpdateDTO
>
exportList
=
urls
.
stream
().
map
(
url
->
new
ExportInteractionUpdateDTO
(
String
.
valueOf
(
id
.
incrementAndGet
()),
urlMap
,
url
)).
collect
(
Collectors
.
toList
());
// excel输出到指定路径
String
projectName
=
projectService
.
getProjectById
(
UserThreadLocal
.
getProjectId
()).
getProjectName
();
String
filePath
=
EasyExcelUtil
.
generateExcelFilePath
(
brandkbsFilePath
,
projectName
,
UserThreadLocal
.
getNickname
(),
"链接互动量更新结果"
);
EasyExcelUtil
.
write
(
filePath
,
"sheet1"
,
ExportInteractionUpdateDTO
.
class
,
exportList
);
JSONObject
res
=
new
JSONObject
();
// 记录使用情况
extraService
.
decreaseInteractionRecord
(
InteractionUpdateRecord
.
UsedType
.
url
,
urls
.
size
());
res
.
put
(
"filePath"
,
filePath
);
res
.
put
(
"remainingCount"
,
interactionBalance
-
urls
.
size
());
return
ResponseResult
.
success
(
res
);
}
/**
* 链接互动量更新
* @param urls 链接
* @return
*/
private
List
<
JSONObject
>
urlInteractionUpdate
(
List
<
String
>
urls
){
// 通过url获取域名进而获取任务类型
Map
<
String
,
String
>
map
=
new
HashMap
<>();
urls
.
forEach
(
url
->
map
.
compute
(
url
,
(
key
,
value
)
->
{
...
...
@@ -209,8 +278,7 @@ public class ToolsetServiceImpl implements ToolsetService {
}));
// 分割map,list里每个map.size为100,目前品见最大链接限制为100,见知微tapd-wiki《互动量更新中间件使用》说明
List
<
Map
<
String
,
String
>>
mapList
=
Tools
.
splitMap
(
map
,
100
);
AtomicInteger
id
=
new
AtomicInteger
(
0
);
List
<
JSONObject
>
result
=
new
ArrayList
<>(
300
);
List
<
JSONObject
>
result
=
new
ArrayList
<>();
for
(
Map
<
String
,
String
>
urlTypeMap
:
mapList
)
{
List
<
String
>
taskIdList
=
new
ArrayList
<>(
100
);
for
(
Map
.
Entry
<
String
,
String
>
entry
:
urlTypeMap
.
entrySet
())
{
...
...
@@ -223,19 +291,7 @@ public class ToolsetServiceImpl implements ToolsetService {
result
.
addAll
(
getInteractionResult
(
ids
));
}
}
Map
<
Object
,
JSONObject
>
urlMap
=
result
.
stream
().
collect
(
Collectors
.
toMap
(
jsonObject
->
jsonObject
.
get
(
"url"
),
o
->
o
));
List
<
ExportInteractionUpdateDTO
>
exportList
=
urls
.
stream
().
map
(
url
->
new
ExportInteractionUpdateDTO
(
String
.
valueOf
(
id
.
incrementAndGet
()),
urlMap
,
url
)).
collect
(
Collectors
.
toList
());
// excel输出到指定路径
String
projectName
=
projectService
.
getProjectById
(
UserThreadLocal
.
getProjectId
()).
getProjectName
();
String
filePath
=
EasyExcelUtil
.
generateExcelFilePath
(
brandkbsFilePath
,
projectName
,
UserThreadLocal
.
getNickname
(),
"链接互动量更新结果"
);
EasyExcelUtil
.
write
(
filePath
,
"sheet1"
,
ExportInteractionUpdateDTO
.
class
,
exportList
);
JSONObject
res
=
new
JSONObject
();
// 记录使用情况
extraService
.
decreaseInteractionRecord
(
InteractionUpdateRecord
.
UsedType
.
url
,
urls
.
size
());
res
.
put
(
"filePath"
,
filePath
);
res
.
put
(
"remainingCount"
,
interactionBalance
-
urls
.
size
());
return
ResponseResult
.
success
(
res
);
return
result
;
}
@Override
...
...
@@ -298,6 +354,444 @@ public class ToolsetServiceImpl implements ToolsetService {
return
getArticleHighWord
(
file
);
}
@Override
public
void
primaryEventUpdate
(
MultipartFile
file
,
Boolean
extraCompute
)
{
BytedanceCustomEventUpdateTask
task
=
BytedanceCustomEventUpdateTask
.
createTaskPrimary
(
extraCompute
);
bytedanceCustomEventUpdateTaskDao
.
insertOne
(
task
);
Map
<
String
,
List
<
UploadBytedanceEventDTO
>>
map
=
new
HashMap
<>();
// excel信息提取
ReadExcelDTO
<
UploadBytedanceEventDTO
>
readExcel
=
new
ReadExcelDTO
<>();
readExcel
.
setClazz
(
UploadBytedanceEventDTO
.
class
);
readExcel
.
setAnalysisEventListener
(
new
BytedanceEventListener
(
map
));
EasyExcelUtil
.
read
(
file
,
readExcel
);
task
.
setEventData
(
map
);
ApplicationProjectListener
.
getThreadPool
().
execute
(()
->
processEventUpdate
(
task
,
extraCompute
));
}
@Override
public
void
contendEventUpdate
(
String
keyword
,
Long
startTime
,
Long
endTime
)
{
BytedanceCustomEventUpdateTask
task
=
BytedanceCustomEventUpdateTask
.
createTaskContend
();
bytedanceCustomEventUpdateTaskDao
.
insertOne
(
task
);
ApplicationProjectListener
.
getThreadPool
().
execute
(()
->
contendEventUpdate
(
task
,
keyword
,
startTime
,
endTime
));
}
@Override
public
void
eventAdditionalUpdate
(
MultipartFile
file
,
String
taskId
)
{
BytedanceCustomEventUpdateTask
task
=
bytedanceCustomEventUpdateTaskDao
.
findOneById
(
taskId
);
updateStatus
(
taskId
,
BytedanceCustomEventUpdateTask
.
TaskStatus
.
CALCULATING
,
BytedanceCustomEventUpdateTask
.
ProcessStatus
.
CHANNEL_MATCH
);
// excel信息提取
Map
<
String
,
List
<
UploadBytedanceEventDTO
>>
map
=
new
HashMap
<>();
ReadExcelDTO
<
UploadBytedanceEventDTO
>
readExcel
=
new
ReadExcelDTO
<>();
readExcel
.
setClazz
(
UploadBytedanceEventDTO
.
class
);
readExcel
.
setAnalysisEventListener
(
new
BytedanceEventListener
(
map
));
EasyExcelUtil
.
read
(
file
,
readExcel
);
// 将旧数据与新数据合并
Map
<
String
,
List
<
UploadBytedanceEventDTO
>>
eventData
=
task
.
getEventData
();
for
(
Map
.
Entry
<
String
,
List
<
UploadBytedanceEventDTO
>>
entry
:
map
.
entrySet
())
{
String
key
=
entry
.
getKey
();
List
<
UploadBytedanceEventDTO
>
value
=
entry
.
getValue
();
eventData
.
compute
(
key
,
(
k
,
v
)
->
{
if
(
Objects
.
nonNull
(
v
))
{
v
.
addAll
(
value
);
return
v
;
}
return
value
;
});
}
task
.
setEventData
(
eventData
);
ApplicationProjectListener
.
getThreadPool
().
execute
(()
->
processEventUpdate
(
task
,
task
.
getExtraCompute
()));
}
@Override
public
JSONObject
scheduleProcessStatus
()
{
Query
query
=
new
Query
(
Criteria
.
where
(
"projectId"
).
is
(
UserThreadLocal
.
getProjectId
()))
.
with
(
Sort
.
by
(
Sort
.
Direction
.
DESC
,
"uTime"
));
BytedanceCustomEventUpdateTask
task
=
bytedanceCustomEventUpdateTaskDao
.
findOne
(
query
);
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"type"
,
task
.
getType
());
jsonObject
.
put
(
"taskStatus"
,
task
.
getTaskStatus
());
jsonObject
.
put
(
"processStatus"
,
task
.
getProcessStatus
());
jsonObject
.
put
(
"taskId"
,
task
.
getId
());
jsonObject
.
put
(
"extraCompute"
,
task
.
getExtraCompute
());
jsonObject
.
put
(
"cTime"
,
task
.
getCTime
());
if
((
Objects
.
equals
(
task
.
getTaskStatus
(),
BytedanceCustomEventUpdateTask
.
TaskStatus
.
FINISH
.
getStatus
())
&&
Objects
.
equals
(
task
.
getProcessStatus
(),
BytedanceCustomEventUpdateTask
.
ProcessStatus
.
FINISH
.
getStatus
()))
||
Objects
.
equals
(
task
.
getTaskStatus
(),
BytedanceCustomEventUpdateTask
.
TaskStatus
.
ERROR
.
getStatus
())
||
Objects
.
equals
(
task
.
getTaskStatus
(),
BytedanceCustomEventUpdateTask
.
TaskStatus
.
MANUAL_CANCEL
.
getStatus
())
||
task
.
getCancel
()){
jsonObject
.
put
(
"stopSchedule"
,
true
);
}
else
{
jsonObject
.
put
(
"stopSchedule"
,
false
);
}
return
jsonObject
;
}
@Override
public
PageVO
<
JSONObject
>
getPrimaryComputeResult
(
String
taskId
,
int
page
,
int
pageSize
)
{
BytedanceCustomEventUpdateTask
task
=
bytedanceCustomEventUpdateTaskDao
.
findOneById
(
taskId
);
// 更新已读
task
.
setRead
(
true
);
bytedanceCustomEventUpdateTaskDao
.
updateOne
(
task
);
List
<
JSONObject
>
list
=
task
.
getEventInfo
().
stream
().
skip
((
long
)
(
page
-
1
)
*
pageSize
).
limit
(
pageSize
).
map
(
event
->
{
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"name"
,
event
.
getName
());
jsonObject
.
put
(
"inf"
,
event
.
getInfluence
());
jsonObject
.
put
(
"RMI"
,
event
.
getRMI
());
jsonObject
.
put
(
"finalInf"
,
event
.
getFinalInfluence
());
return
jsonObject
;
}).
collect
(
Collectors
.
toList
());
JSONObject
info
=
new
JSONObject
();
info
.
put
(
"error"
,
CollectionUtils
.
isNotEmpty
(
task
.
getErrorData
()));
PageVO
<
JSONObject
>
pageVo
=
PageVO
.
createPageVo
(
task
.
getEventInfo
().
size
(),
page
,
pageSize
,
list
);
pageVo
.
setInfo
(
info
);
return
pageVo
;
}
@Override
public
double
getContendComputeResult
(
String
taskId
)
{
BytedanceCustomEventUpdateTask
task
=
bytedanceCustomEventUpdateTaskDao
.
findOneById
(
taskId
);
// 更新已读
task
.
setRead
(
true
);
bytedanceCustomEventUpdateTaskDao
.
updateOne
(
task
);
return
task
.
getContendInfluence
();
}
@Override
public
String
downloadPrimaryComputeResult
(
String
taskId
)
{
BytedanceCustomEventUpdateTask
task
=
bytedanceCustomEventUpdateTaskDao
.
findOneById
(
taskId
);
List
<
ExportBytedanceEventComputeResultDTO
>
list
=
task
.
getEventInfo
().
stream
().
map
(
event
->
{
ExportBytedanceEventComputeResultDTO
dto
=
new
ExportBytedanceEventComputeResultDTO
();
dto
.
setName
(
event
.
getName
());
dto
.
setInf
(
event
.
getInfluence
());
dto
.
setRMI
(
event
.
getRMI
());
dto
.
setFinalInf
(
event
.
getFinalInfluence
());
return
dto
;
}).
collect
(
Collectors
.
toList
());
// excel写入至指定路径
String
projectName
=
projectService
.
getProjectById
(
UserThreadLocal
.
getProjectId
()).
getProjectName
();
String
filePath
=
EasyExcelUtil
.
generateExcelFilePath
(
brandkbsFilePath
,
projectName
,
UserThreadLocal
.
getNickname
(),
"事件计算结果"
);
EasyExcelUtil
.
write
(
filePath
,
"sheet1"
,
ExportBytedanceEventComputeResultDTO
.
class
,
list
);
return
filePath
;
}
@Override
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
(),
"报错数据"
);
EasyExcelUtil
.
write
(
filePath
,
"sheet1"
,
UploadBytedanceEventDTO
.
class
,
task
.
getErrorData
());
return
filePath
;
}
@Override
public
PageVO
<
JSONObject
>
getEventUpdateTaskList
(
int
page
,
int
pageSize
)
{
Query
query
=
new
Query
(
Criteria
.
where
(
"projectId"
).
is
(
UserThreadLocal
.
getProjectId
()))
.
with
(
Sort
.
by
(
Sort
.
Direction
.
DESC
,
"cTime"
));
query
.
addCriteria
(
Criteria
.
where
(
"taskStatus"
).
ne
(
BytedanceCustomEventUpdateTask
.
TaskStatus
.
MANUAL_CANCEL
.
getStatus
()));
long
total
=
bytedanceCustomEventUpdateTaskDao
.
count
(
query
);
query
.
skip
((
long
)
(
page
-
1
)
*
pageSize
);
query
.
limit
(
pageSize
);
List
<
BytedanceCustomEventUpdateTask
>
taskList
=
bytedanceCustomEventUpdateTaskDao
.
findList
(
query
);
List
<
JSONObject
>
list
=
taskList
.
stream
().
map
(
task
->
{
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"taskId"
,
task
.
getId
());
jsonObject
.
put
(
"extraCompute"
,
task
.
getExtraCompute
());
jsonObject
.
put
(
"type"
,
task
.
getType
());
jsonObject
.
put
(
"taskStatus"
,
task
.
getTaskStatus
());
jsonObject
.
put
(
"read"
,
task
.
getRead
());
jsonObject
.
put
(
"time"
,
task
.
getCTime
());
return
jsonObject
;
}).
collect
(
Collectors
.
toList
());
return
PageVO
.
createPageVo
(
total
,
page
,
pageSize
,
list
);
}
@Override
public
Boolean
getIfUnread
()
{
Query
query
=
new
Query
(
Criteria
.
where
(
"projectId"
).
is
(
UserThreadLocal
.
getProjectId
()));
query
.
addCriteria
(
Criteria
.
where
(
"taskStatus"
).
ne
(
BytedanceCustomEventUpdateTask
.
TaskStatus
.
MANUAL_CANCEL
.
getStatus
()));
List
<
BytedanceCustomEventUpdateTask
>
taskList
=
bytedanceCustomEventUpdateTaskDao
.
findList
(
query
);
return
taskList
.
stream
().
map
(
BytedanceCustomEventUpdateTask:
:
getRead
).
anyMatch
(
task
->
Objects
.
equals
(
task
,
Boolean
.
FALSE
));
}
@Override
public
void
cancelTask
(
String
taskId
)
{
BytedanceCustomEventUpdateTask
task
=
bytedanceCustomEventUpdateTaskDao
.
findOneById
(
taskId
);
task
.
setCancel
(
true
);
bytedanceCustomEventUpdateTaskDao
.
updateOne
(
task
);
}
/**
* 处理字节定制本品事件影响力更新
* @param task
* @param extraCompute
*/
private
void
processEventUpdate
(
BytedanceCustomEventUpdateTask
task
,
Boolean
extraCompute
){
String
taskId
=
task
.
getId
();
try
{
List
<
BytedanceCustomEventUpdateTask
.
EventInfo
>
eventInfos
=
new
ArrayList
<>();
Map
<
String
,
List
<
UploadBytedanceEventDTO
>>
map
=
task
.
getEventData
();
for
(
Map
.
Entry
<
String
,
List
<
UploadBytedanceEventDTO
>>
entry
:
map
.
entrySet
())
{
List
<
UploadBytedanceEventDTO
>
data
=
entry
.
getValue
();
BytedanceCustomEventUpdateTask
.
EventInfo
eventInfo
=
new
BytedanceCustomEventUpdateTask
.
EventInfo
();
eventInfo
.
setName
(
entry
.
getKey
());
// 计算影响力指数
eventInfo
.
setInfluence
(
computeInf
(
data
));
eventInfos
.
add
(
eventInfo
);
}
// 若需要计算实时传播力与传播影响力
if
(
extraCompute
)
{
// 更新为互动量更新处理状态
updateStatus
(
taskId
,
BytedanceCustomEventUpdateTask
.
TaskStatus
.
CALCULATING
,
BytedanceCustomEventUpdateTask
.
ProcessStatus
.
INTERACTION_UPDATE
);
for
(
BytedanceCustomEventUpdateTask
.
EventInfo
eventInfo
:
eventInfos
)
{
List
<
UploadBytedanceEventDTO
>
data
=
map
.
get
(
eventInfo
.
getName
());
// 计算实时传播力
eventInfo
.
setRMI
(
computeRMI
(
data
,
task
));
// 计算传播影响力
eventInfo
.
setFinalInfluence
(
computeFinalInf
(
eventInfo
.
getInfluence
(),
eventInfo
.
getRMI
()));
}
updateStatus
(
taskId
,
BytedanceCustomEventUpdateTask
.
TaskStatus
.
CALCULATING
,
BytedanceCustomEventUpdateTask
.
ProcessStatus
.
INFLUENCE_COMPUTE
);
}
// 移除数据中的错误数据
for
(
List
<
UploadBytedanceEventDTO
>
value
:
task
.
getEventData
().
values
())
{
if
(
CollectionUtils
.
isNotEmpty
(
task
.
getErrorData
()))
{
value
.
removeAll
(
task
.
getErrorData
());
}
}
task
.
setEventInfo
(
eventInfos
);
updateStatus
(
task
,
BytedanceCustomEventUpdateTask
.
TaskStatus
.
FINISH
,
BytedanceCustomEventUpdateTask
.
ProcessStatus
.
FINISH
);
}
catch
(
Exception
e
){
log
.
info
(
"本品字节事件影响力补充计算出错-taskId:{}"
,
taskId
,
e
);
if
(!
Objects
.
equals
(
e
.
getMessage
(),
"手动取消"
)){
updateStatus
(
task
,
BytedanceCustomEventUpdateTask
.
TaskStatus
.
ERROR
,
null
);
}
}
}
/**
* 处理竞品事件影响力更新
* @param task
* @param keyword
* @param startTime
* @param endTime
*/
private
void
contendEventUpdate
(
BytedanceCustomEventUpdateTask
task
,
String
keyword
,
Long
startTime
,
Long
endTime
)
{
String
taskId
=
task
.
getId
();
try
{
updateStatus
(
taskId
,
null
,
null
);
String
projectId
=
task
.
getProjectId
();
Project
project
=
projectService
.
getProjectById
(
projectId
);
List
<
String
>
keys
=
project
.
getContendList
().
stream
()
.
map
(
AbstractProject:
:
getId
)
.
map
(
contendId
->
concat
(
projectId
,
contendId
)).
collect
(
Collectors
.
toList
());
// 按条件拉取es数据
String
[]
indexes
=
esClientDao
.
getIndexes
();
BoolQueryBuilder
postFilter
=
QueryBuilders
.
boolQuery
();
// project contend
BoolQueryBuilder
nestedBoolBuilder
=
QueryBuilders
.
boolQuery
();
nestedBoolBuilder
.
must
(
QueryBuilders
.
termsQuery
(
"brandkbs_cache_maps.key.keyword"
,
keys
));
postFilter
.
must
(
cacheMapsNestedQuery
(
nestedBoolBuilder
));
// time
postFilter
.
must
(
QueryBuilders
.
rangeQuery
(
"time"
).
gte
(
startTime
).
lt
(
endTime
));
// keyword
postFilter
.
must
(
EsQueryTools
.
assembleNormalKeywordQuery
(
keyword
,
new
String
[]{
GenericAttribute
.
ES_IND_FULL_TEXT
}));
// searchHelper
EsClientDao
.
SearchHelper
searchHelper
=
new
EsClientDao
.
SearchHelper
();
searchHelper
.
setIndexes
(
indexes
);
searchHelper
.
setPostFilter
(
postFilter
);
List
<
SearchResponse
>
searchResponses
=
esClientDao
.
searchScrollResponse
(
searchHelper
);
List
<
UploadBytedanceEventDTO
>
data
=
new
ArrayList
<>();
for
(
SearchResponse
searchResponse
:
searchResponses
)
{
for
(
SearchHit
hit
:
searchResponse
.
getHits
().
getHits
())
{
BaseMap
baseMap
=
Tools
.
getBaseFromEsMap
(
hit
.
getSourceAsMap
());
UploadBytedanceEventDTO
dto
=
new
UploadBytedanceEventDTO
();
dto
.
setPlatform
(
baseMap
.
getPlatform
());
dto
.
setChannel
(
baseMap
.
getSource
());
data
.
add
(
dto
);
}
}
updateStatus
(
taskId
,
null
,
BytedanceCustomEventUpdateTask
.
ProcessStatus
.
INFLUENCE_COMPUTE
);
// 计算影响力指数
task
.
setContendInfluence
(
computeInf
(
data
));
updateStatus
(
task
,
BytedanceCustomEventUpdateTask
.
TaskStatus
.
FINISH
,
BytedanceCustomEventUpdateTask
.
ProcessStatus
.
FINISH
);
}
catch
(
Exception
e
){
log
.
info
(
"竞品字节事件影响力补充计算出错-taskId:{}"
,
taskId
,
e
);
if
(!
Objects
.
equals
(
e
.
getMessage
(),
"手动取消"
)){
updateStatus
(
task
,
BytedanceCustomEventUpdateTask
.
TaskStatus
.
ERROR
,
null
);
}
}
}
/**
* 更新状态
* @param taskId
* @param taskStatus
* @param processStatus
*/
private
void
updateStatus
(
String
taskId
,
BytedanceCustomEventUpdateTask
.
TaskStatus
taskStatus
,
BytedanceCustomEventUpdateTask
.
ProcessStatus
processStatus
){
BytedanceCustomEventUpdateTask
task
=
bytedanceCustomEventUpdateTaskDao
.
findOneById
(
taskId
);
task
.
setUTime
(
System
.
currentTimeMillis
());
// 任务被更新为手动取消状态 抛出异常结束任务
if
(
Objects
.
nonNull
(
task
.
getCancel
())
&&
task
.
getCancel
()){
updateStatus
(
task
,
BytedanceCustomEventUpdateTask
.
TaskStatus
.
MANUAL_CANCEL
,
null
);
throw
new
RuntimeException
(
"手动取消"
);
}
if
(
Objects
.
nonNull
(
taskStatus
)){
task
.
setTaskStatus
(
taskStatus
.
getStatus
());
}
if
(
Objects
.
nonNull
(
processStatus
)){
task
.
setProcessStatus
(
processStatus
.
getStatus
());
}
if
(
Objects
.
nonNull
(
taskStatus
)
&&
Objects
.
nonNull
(
processStatus
))
{
bytedanceCustomEventUpdateTaskDao
.
updateOne
(
task
);
}
}
private
void
updateStatus
(
BytedanceCustomEventUpdateTask
task
,
BytedanceCustomEventUpdateTask
.
TaskStatus
taskStatus
,
BytedanceCustomEventUpdateTask
.
ProcessStatus
processStatus
){
task
.
setUTime
(
System
.
currentTimeMillis
());
task
.
setTaskStatus
(
taskStatus
.
getStatus
());
if
(
Objects
.
nonNull
(
processStatus
))
{
task
.
setProcessStatus
(
processStatus
.
getStatus
());
}
bytedanceCustomEventUpdateTaskDao
.
updateOne
(
task
);
}
/**
* 计算影响力指数(Inf)
* @param data
* @return
*/
private
double
computeInf
(
List
<
UploadBytedanceEventDTO
>
data
){
double
sumH
=
0
;
if
(
CollectionUtils
.
isEmpty
(
data
)){
return
sumH
;
}
for
(
UploadBytedanceEventDTO
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
);
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
();
}
}
}
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
();
}
// 否则,inf=ln(sumH)/ln(sumMaxAll)*100
return
partResult
.
setScale
(
7
,
RoundingMode
.
HALF_UP
).
doubleValue
();
}
/**
* 计算实时传播力(RMI)
* @param data
* @return
*/
private
double
computeRMI
(
List
<
UploadBytedanceEventDTO
>
data
,
BytedanceCustomEventUpdateTask
task
){
List
<
UploadBytedanceEventDTO
>
willBeInteractionUpdateData
=
new
ArrayList
<>();
int
weiboForward
=
0
;
int
weiboComment
=
0
;
int
weiboLike
=
0
;
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
media
=
(
int
)
data
.
stream
().
filter
(
article
->
Objects
.
equals
(
"网媒"
,
article
.
getPlatform
())).
count
();
// 其他平台文章数
int
otherPlatform
=
(
int
)
data
.
stream
().
filter
(
article
->
!
Objects
.
equals
(
"网媒"
,
article
.
getPlatform
())
&&
!
Objects
.
equals
(
"微博"
,
article
.
getPlatform
())
&&
!
Objects
.
equals
(
"微信"
,
article
.
getPlatform
())).
count
();
for
(
UploadBytedanceEventDTO
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
;
}
weiboForward
=
weiboForward
+
datum
.
getWeiboForward
();
weiboComment
=
weiboComment
+
datum
.
getWeiboComment
();
weiboLike
=
weiboLike
+
datum
.
getWeiboLike
();
wechatRead
=
wechatRead
+
datum
.
getWechatRead
();
wechatReading
=
wechatReading
+
datum
.
getWechatReading
();
}
// 选填字段全部未填的链接互动量更新结果
try
{
List
<
String
>
urls
=
willBeInteractionUpdateData
.
stream
().
map
(
UploadBytedanceEventDTO:
:
getUrl
).
collect
(
Collectors
.
toList
());
List
<
JSONObject
>
jsonObjects
=
urlInteractionUpdate
(
urls
);
for
(
JSONObject
jsonObject
:
jsonObjects
)
{
// 转发数
int
repostCount
=
Objects
.
isNull
(
jsonObject
.
getInteger
(
"repostCount"
))
?
0
:
jsonObject
.
getIntValue
(
"repostCount"
);
// 评论数
int
commentCount
=
Objects
.
isNull
(
jsonObject
.
getInteger
(
"commentCount"
))
?
0
:
jsonObject
.
getIntValue
(
"commentCount"
);
// 点赞数
int
likeCount
=
Objects
.
isNull
(
jsonObject
.
getInteger
(
"likeCount"
))
?
0
:
jsonObject
.
getIntValue
(
"likeCount"
);
// 阅读数
int
readCount
=
Objects
.
isNull
(
jsonObject
.
getInteger
(
"readCount"
))
?
0
:
jsonObject
.
getIntValue
(
"readCount"
);
// 在看数
int
kanCount
=
Objects
.
isNull
(
jsonObject
.
getInteger
(
"kanCount"
))
?
0
:
jsonObject
.
getIntValue
(
"kanCount"
);
weiboForward
=
weiboForward
+
repostCount
;
weiboComment
=
weiboComment
+
commentCount
;
weiboLike
=
weiboLike
+
likeCount
;
wechatRead
=
wechatRead
+
readCount
;
wechatReading
=
wechatReading
+
kanCount
;
}
}
catch
(
Exception
e
){
// 报错数据:为互动量更新失败数据,更新失败数据不参与计算
log
.
info
(
"字节事件影响力更新-互动量更新出错-id:{}"
,
task
.
getId
(),
e
);
List
<
UploadBytedanceEventDTO
>
errorData
=
task
.
getErrorData
();
errorData
.
addAll
(
willBeInteractionUpdateData
);
task
.
setErrorData
(
errorData
);
}
// 平台指标权重
Map
<
String
,
Double
>
weightMap
=
bytedanceCustomPlatformWeightDao
.
findList
(
new
Query
())
.
stream
()
.
collect
(
Collectors
.
toMap
(
BytedanceCustomPlatformWeight:
:
getType
,
BytedanceCustomPlatformWeight:
:
getWeight
));
// 各平台数据指标与权重相乘求和
return
BigDecimal
.
valueOf
(
media
).
multiply
(
BigDecimal
.
valueOf
(
weightMap
.
get
(
"网媒文章数"
)))
.
add
(
BigDecimal
.
valueOf
(
otherPlatform
).
multiply
(
BigDecimal
.
valueOf
(
weightMap
.
get
(
"其他平台文章数"
))))
.
add
(
BigDecimal
.
valueOf
(
wechatArticle
).
multiply
(
BigDecimal
.
valueOf
(
weightMap
.
get
(
"微信文章数"
))))
.
add
(
BigDecimal
.
valueOf
(
wechatRead
).
multiply
(
BigDecimal
.
valueOf
(
weightMap
.
get
(
"微信阅读数"
))))
.
add
(
BigDecimal
.
valueOf
(
wechatReading
).
multiply
(
BigDecimal
.
valueOf
(
weightMap
.
get
(
"微信在看数"
))))
.
add
(
BigDecimal
.
valueOf
(
weiboArticle
).
multiply
(
BigDecimal
.
valueOf
(
weightMap
.
get
(
"微博消息数"
))))
.
add
(
BigDecimal
.
valueOf
(
weiboForward
).
multiply
(
BigDecimal
.
valueOf
(
weightMap
.
get
(
"微博转发数"
))))
.
add
(
BigDecimal
.
valueOf
(
weiboComment
).
multiply
(
BigDecimal
.
valueOf
(
weightMap
.
get
(
"微博评论数"
))))
.
add
(
BigDecimal
.
valueOf
(
weiboLike
).
multiply
(
BigDecimal
.
valueOf
(
weightMap
.
get
(
"微博点赞数"
))))
.
setScale
(
7
,
RoundingMode
.
HALF_UP
)
.
doubleValue
();
}
/**
* 计算传播影响力(Final Inf)
* @param inf 影响力指数
* @param RMI 实时传播力
* @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
();
}
/**
* 关键词词云提取
* @param file excel文件
...
...
src/main/resources/application-dev.properties
View file @
e62f3dcd
...
...
@@ -73,6 +73,7 @@ qbjc.platform.url=https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface/platfo
qbjc.userCenter.url
=
https://login.zhiweidata.com/plogin/center
qbjc.userCenter.token
=
AoJ0ooy3HV1EElWnvQw9YTS9b5Y+fmtkbM6DdpPgDO6D/OhNqH4qrJKarzMr
qbjc.channel.application.url
=
https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface/middleware/channel-application
qbjc.channel.influence
=
https://yuqing.test.zhiweidata.com/qbjcbackPhoenix/interface/middleware/channel-influence?platform={1}&channel={2}
#\u5371\u673A\u5E93\u5916\u90E8\u63A5\u53E3
crisis.search.url
=
https://crisis.zhiweidata.com/app/brandkbs/crisisSearch?page={1}&size={2}&keyword={3}
crisis.searchTags.url
=
https://crisis.zhiweidata.com/app/brandkbs/searchCrisisByTags?page={1}&size={2}&brand={3}&category={4}
...
...
@@ -80,7 +81,7 @@ crisis.top3.url=https://crisis.zhiweidata.com/app/brandkbs/event/online-top3
crisis.searchCriteria.url
=
https://crisis.zhiweidata.com/app/brandkbs/condition
crisis.list.url
=
https://crisis.zhiweidata.com/app/brandkbs/crisisList?page={1}&size={2}&startTime={3}&endTime={4}&category={5}
crisis.share.url
=
https://crisis.zhiweidata.com/app/brandkbs/share/{1}
crisis.event.url
=
https://crisis.zhiweidata.com/event/{1}/general?share={2}
crisis.event.url
=
https://crisis.zhiweidata.com/event/{1}/general?share={2}
#\u70ED\u70B9\u5E93\u5916\u90E8\u63A5\u53E3
trends.longTimeInListSearchByInner.url
=
https://trends.zhiweidata.com/hotSearchTrend/inner/longTimeInListSearchByInner?sortType={1}&type={2}&day={3}
trends.findHotSearchESDataInTimeByInner.url
=
https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/findHotSearchESDataInTimeByInner?limit={1}&page={2}&type={3}&word={4}
...
...
src/main/resources/application-local.properties
View file @
e62f3dcd
...
...
@@ -76,6 +76,7 @@ qbjc.platform.url=https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface/platfo
qbjc.userCenter.url
=
http://login.zhiweidata.top/plogin/center
qbjc.userCenter.token
=
AoJ0ooy3HV1EElWnvQw9YTS9b5Y+fmtkbM6DdpPgDO6D/OhNqH4qrJKarzMr
qbjc.channel.application.url
=
http://192.168.0.79:11000/qbjcbackPhoenix/interface/middleware/channel-application
qbjc.channel.influence
=
https://yuqing.test.zhiweidata.com/qbjcbackPhoenix/interface/middleware/channel-influence?platform={1}&channel={2}
#\u5371\u673A\u5E93\u5916\u90E8\u63A5\u53E3
crisis.search.url
=
https://crisis.zhiweidata.com/app/brandkbs/crisisSearch?page={1}&size={2}&keyword={3}
crisis.searchTags.url
=
https://crisis.zhiweidata.com/app/brandkbs/searchCrisisByTags?page={1}&size={2}&brand={3}&category={4}
...
...
@@ -83,7 +84,7 @@ crisis.top3.url=https://crisis.zhiweidata.com/app/brandkbs/event/online-top3
crisis.searchCriteria.url
=
https://crisis.zhiweidata.com/app/brandkbs/condition
crisis.list.url
=
https://crisis.zhiweidata.com/app/brandkbs/crisisList?page={1}&size={2}&startTime={3}&endTime={4}&category={5}
crisis.share.url
=
https://crisis.zhiweidata.com/app/brandkbs/share/{1}
crisis.event.url
=
https://crisis.zhiweidata.com/event/{1}/general?share={2}
crisis.event.url
=
https://crisis.zhiweidata.com/event/{1}/general?share={2}
#\u70ED\u70B9\u5E93\u5916\u90E8\u63A5\u53E3
trends.longTimeInListSearchByInner.url
=
https://trends.zhiweidata.com/hotSearchTrend/inner/longTimeInListSearchByInner?sortType={1}&type={2}&day={3}
trends.findHotSearchESDataInTimeByInner.url
=
https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/findHotSearchESDataInTimeByInner?limit={1}&page={2}&type={3}&word={4}
...
...
src/main/resources/application-prod.properties
View file @
e62f3dcd
...
...
@@ -73,6 +73,7 @@ qbjc.platform.url=https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface/platfo
qbjc.userCenter.url
=
https://login.zhiweidata.com/plogin/center
qbjc.userCenter.token
=
AoJ0ooy3HV1EElWnvQw9YTS9b5Y+fmtkbM6DdpPgDO6D/OhNqH4qrJKarzMr
qbjc.channel.application.url
=
https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface/middleware/channel-application
qbjc.channel.influence
=
https://yuqing.test.zhiweidata.com/qbjcbackPhoenix/interface/middleware/channel-influence?platform={1}&channel={2}
#\u5371\u673A\u5E93\u5916\u90E8\u63A5\u53E3
crisis.search.url
=
https://crisis.zhiweidata.com/app/brandkbs/crisisSearch?page={1}&size={2}&keyword={3}
crisis.searchTags.url
=
https://crisis.zhiweidata.com/app/brandkbs/searchCrisisByTags?page={1}&size={2}&brand={3}&category={4}
...
...
@@ -80,7 +81,7 @@ crisis.top3.url=https://crisis.zhiweidata.com/app/brandkbs/event/online-top3
crisis.searchCriteria.url
=
https://crisis.zhiweidata.com/app/brandkbs/condition
crisis.list.url
=
https://crisis.zhiweidata.com/app/brandkbs/crisisList?page={1}&size={2}&startTime={3}&endTime={4}&category={5}
crisis.share.url
=
https://crisis.zhiweidata.com/app/brandkbs/share/{1}
crisis.event.url
=
https://crisis.zhiweidata.com/event/{1}/general?share={2}
crisis.event.url
=
https://crisis.zhiweidata.com/event/{1}/general?share={2}
#\u70ED\u70B9\u5E93\u5916\u90E8\u63A5\u53E3
trends.longTimeInListSearchByInner.url
=
https://trends.zhiweidata.com/hotSearchTrend/inner/longTimeInListSearchByInner?sortType={1}&type={2}&day={3}
trends.findHotSearchESDataInTimeByInner.url
=
https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/findHotSearchESDataInTimeByInner?limit={1}&page={2}&type={3}&word={4}
...
...
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