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
4370639f
Commit
4370639f
authored
Aug 25, 2023
by
shenjunjie
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature' into 'release'
Feature See merge request
!382
parents
68532b6e
fac87a3b
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
436 additions
and
16 deletions
+436
-16
src/main/java/com/zhiwei/brandkbs2/controller/app/AppChannelController.java
+83
-4
src/main/java/com/zhiwei/brandkbs2/dao/QbjcPojoDao.java
+16
-0
src/main/java/com/zhiwei/brandkbs2/dao/impl/QbjcPojoDaoImpl.java
+15
-0
src/main/java/com/zhiwei/brandkbs2/pojo/SensitiveChannel.java
+100
-0
src/main/java/com/zhiwei/brandkbs2/service/ChannelService.java
+30
-0
src/main/java/com/zhiwei/brandkbs2/service/impl/ChannelServiceImpl.java
+182
-12
src/main/java/com/zhiwei/brandkbs2/service/impl/TaskServiceImpl.java
+3
-0
src/main/java/com/zhiwei/brandkbs2/util/RedisUtil.java
+4
-0
src/main/resources/application-dev.properties
+1
-0
src/main/resources/application-local.properties
+1
-0
src/main/resources/application-prod.properties
+1
-0
No files found.
src/main/java/com/zhiwei/brandkbs2/controller/app/AppChannelController.java
View file @
4370639f
package
com
.
zhiwei
.
brandkbs2
.
controller
.
app
;
import
com.alibaba.fastjson.JSONObject
;
import
com.zhiwei.brandkbs2.aop.LogRecord
;
import
com.zhiwei.brandkbs2.auth.Auth
;
import
com.zhiwei.brandkbs2.auth.UserThreadLocal
;
import
com.zhiwei.brandkbs2.controller.BaseController
;
import
com.zhiwei.brandkbs2.easyexcel.EasyExcelUtil
;
import
com.zhiwei.brandkbs2.easyexcel.dto.ExportAppChannelArticleDTO
;
...
...
@@ -9,14 +11,20 @@ import com.zhiwei.brandkbs2.enmus.RoleEnum;
import
com.zhiwei.brandkbs2.model.ResponseResult
;
import
com.zhiwei.brandkbs2.pojo.dto.ExportAppChannelEventDTO
;
import
com.zhiwei.brandkbs2.service.ChannelService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
com.zhiwei.brandkbs2.service.ProjectService
;
import
io.swagger.annotations.*
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.MediaType
;
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
;
import
java.util.Objects
;
/**
* @ClassName: AppChannelController
...
...
@@ -33,6 +41,14 @@ public class AppChannelController extends BaseController {
@Resource
(
name
=
"channelServiceImpl"
)
ChannelService
channelService
;
@Resource
(
name
=
"projectServiceImpl"
)
ProjectService
projectService
;
@Autowired
private
RestTemplate
restTemplate
;
@Value
(
"${qbjc.channel.application.url}"
)
private
String
channelApplicationUrl
;
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"contendId"
,
value
=
"品牌id"
,
defaultValue
=
"0"
,
paramType
=
"query"
,
dataType
=
"string"
),
@ApiImplicitParam
(
name
=
"platform"
,
value
=
"平台"
,
paramType
=
"query"
,
dataType
=
"string"
),
...
...
@@ -232,4 +248,67 @@ public class AppChannelController extends BaseController {
return
ResponseResult
.
success
();
}
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"contendId"
,
value
=
"品牌id"
,
defaultValue
=
"0"
,
paramType
=
"query"
,
dataType
=
"string"
),
@ApiImplicitParam
(
name
=
"startTime"
,
value
=
"起始时间"
,
paramType
=
"query"
,
dataType
=
"long"
),
@ApiImplicitParam
(
name
=
"endTime"
,
value
=
"结束时间"
,
paramType
=
"query"
,
dataType
=
"long"
),
@ApiImplicitParam
(
name
=
"pageSize"
,
value
=
"选取前几"
,
defaultValue
=
"50"
,
paramType
=
"query"
,
dataType
=
"int"
),
})
@ApiOperation
(
"渠道库-活跃渠道榜"
)
@LogRecord
(
description
=
"渠道库-活跃渠道榜"
)
@GetMapping
(
"/list/new/active"
)
public
ResponseResult
getActiveChannelList
(
@RequestParam
(
value
=
"contendId"
,
defaultValue
=
"0"
)
String
contendId
,
@RequestParam
(
value
=
"startTime"
,
required
=
false
)
Long
startTime
,
@RequestParam
(
value
=
"endTime"
,
required
=
false
)
Long
endTime
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"50"
)
int
size
)
{
return
ResponseResult
.
success
(
channelService
.
getActiveChannelList
(
contendId
,
startTime
,
endTime
,
size
,
true
));
}
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"contendId"
,
value
=
"品牌id"
,
defaultValue
=
"0"
,
paramType
=
"query"
,
dataType
=
"string"
),
@ApiImplicitParam
(
name
=
"startTime"
,
value
=
"起始时间"
,
paramType
=
"query"
,
dataType
=
"long"
),
@ApiImplicitParam
(
name
=
"endTime"
,
value
=
"结束时间"
,
paramType
=
"query"
,
dataType
=
"long"
),
@ApiImplicitParam
(
name
=
"pageSize"
,
value
=
"选取前几"
,
defaultValue
=
"50"
,
paramType
=
"query"
,
dataType
=
"int"
),
})
@ApiOperation
(
"渠道库-友好渠道榜"
)
@LogRecord
(
description
=
"渠道库-友好渠道榜"
)
@GetMapping
(
"/list/new/positive"
)
public
ResponseResult
getPositiveChannelList
(
@RequestParam
(
value
=
"contendId"
,
defaultValue
=
"0"
)
String
contendId
,
@RequestParam
(
value
=
"startTime"
,
required
=
false
)
Long
startTime
,
@RequestParam
(
value
=
"endTime"
,
required
=
false
)
Long
endTime
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"50"
)
int
size
)
{
return
ResponseResult
.
success
(
channelService
.
getPositiveChannelList
(
contendId
,
startTime
,
endTime
,
size
,
true
));
}
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"contendId"
,
value
=
"品牌id"
,
defaultValue
=
"0"
,
paramType
=
"query"
,
dataType
=
"string"
),
@ApiImplicitParam
(
name
=
"startTime"
,
value
=
"起始时间"
,
paramType
=
"query"
,
dataType
=
"long"
),
@ApiImplicitParam
(
name
=
"endTime"
,
value
=
"结束时间"
,
paramType
=
"query"
,
dataType
=
"long"
),
@ApiImplicitParam
(
name
=
"pageSize"
,
value
=
"选取前几"
,
defaultValue
=
"50"
,
paramType
=
"query"
,
dataType
=
"int"
),
})
@ApiOperation
(
"渠道库-敏感渠道榜"
)
@LogRecord
(
description
=
"渠道库-敏感渠道榜"
)
@GetMapping
(
"/list/new/negative"
)
public
ResponseResult
getNegativeChannelList
(
@RequestParam
(
value
=
"contendId"
,
defaultValue
=
"0"
)
String
contendId
,
@RequestParam
(
value
=
"startTime"
,
required
=
false
)
Long
startTime
,
@RequestParam
(
value
=
"endTime"
,
required
=
false
)
Long
endTime
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"50"
)
int
size
)
{
return
ResponseResult
.
success
(
channelService
.
getNegativeChannelList
(
contendId
,
startTime
,
endTime
,
size
,
true
));
}
@ApiOperation
(
"渠道库-渠道申请"
)
@PostMapping
(
"/channel-application"
)
public
ResponseResult
channelApplication
(
@ApiParam
(
name
=
"info"
,
value
=
"渠道申请-json:{source:中华网}"
,
required
=
true
)
@RequestBody
JSONObject
info
)
{
JSONObject
body
=
new
JSONObject
();
body
.
put
(
"name"
,
info
.
getString
(
"source"
));
body
.
put
(
"submitter"
,
UserThreadLocal
.
getNickname
());
String
linkedGroupId
=
projectService
.
getProjectById
(
UserThreadLocal
.
getProjectId
()).
getBrandLinkedGroupId
();
body
.
put
(
"projectId"
,
linkedGroupId
);
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setContentType
(
MediaType
.
APPLICATION_JSON
);
HttpEntity
<
String
>
request
=
new
HttpEntity
<>(
body
.
toJSONString
(),
headers
);
ResponseEntity
<
JSONObject
>
response
=
restTemplate
.
postForEntity
(
channelApplicationUrl
,
request
,
JSONObject
.
class
);
if
(
200
==
Objects
.
requireNonNull
(
response
.
getBody
()).
getIntValue
(
"code"
))
{
return
ResponseResult
.
success
();
}
return
ResponseResult
.
failure
(
"渠道申请失败"
);
}
}
src/main/java/com/zhiwei/brandkbs2/dao/QbjcPojoDao.java
View file @
4370639f
package
com
.
zhiwei
.
brandkbs2
.
dao
;
import
com.zhiwei.brandkbs2.pojo.SensitiveChannel
;
import
com.zhiwei.qbjc.bean.pojo.common.MessagePlatform
;
import
com.zhiwei.qbjc.bean.pojo.common.Tag
;
...
...
@@ -35,4 +36,19 @@ public interface QbjcPojoDao {
* @return tags
*/
List
<
Tag
>
findEmotionTagByLinkedGroupId
();
/**
* qbjc项目重要渠道
* @param linkedGroupId
* @param source
* @return
*/
SensitiveChannel
findSensitiveChannelBySource
(
String
linkedGroupId
,
String
source
);
/**
* qbjc通用重要渠道
* @param source
* @return
*/
SensitiveChannel
findSensitiveChannelBySource
(
String
source
);
}
src/main/java/com/zhiwei/brandkbs2/dao/impl/QbjcPojoDaoImpl.java
View file @
4370639f
package
com
.
zhiwei
.
brandkbs2
.
dao
.
impl
;
import
com.zhiwei.brandkbs2.dao.QbjcPojoDao
;
import
com.zhiwei.brandkbs2.pojo.SensitiveChannel
;
import
com.zhiwei.qbjc.bean.pojo.common.MessagePlatform
;
import
com.zhiwei.qbjc.bean.pojo.common.Tag
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.stereotype.Component
;
...
...
@@ -39,6 +41,19 @@ public class QbjcPojoDaoImpl implements QbjcPojoDao {
return
mongoTemplate
.
find
(
new
Query
(),
Tag
.
class
).
stream
().
filter
(
tag
->
tag
.
getGroupName
().
equals
(
"情感倾向"
)).
collect
(
Collectors
.
toList
());
}
@Override
public
SensitiveChannel
findSensitiveChannelBySource
(
String
linkedGroupId
,
String
source
)
{
Query
query
=
new
Query
();
query
.
addCriteria
(
Criteria
.
where
(
"projectId"
).
is
(
linkedGroupId
));
query
.
addCriteria
(
Criteria
.
where
(
"name"
).
is
(
source
));
return
mongoTemplate
.
findOne
(
query
,
SensitiveChannel
.
class
,
"qbjc_sensitive_channel"
);
}
@Override
public
SensitiveChannel
findSensitiveChannelBySource
(
String
source
)
{
Query
query
=
new
Query
();
query
.
addCriteria
(
Criteria
.
where
(
"name"
).
is
(
source
));
return
mongoTemplate
.
findOne
(
query
,
SensitiveChannel
.
class
,
"qbjc_sensitive_channel_system"
);
}
}
src/main/java/com/zhiwei/brandkbs2/pojo/SensitiveChannel.java
0 → 100644
View file @
4370639f
package
com
.
zhiwei
.
brandkbs2
.
pojo
;
import
lombok.Data
;
@Data
public
class
SensitiveChannel
{
private
String
id
;
/**
* 渠道名称
*/
private
String
name
;
/**
* 主体类型 央级
*/
private
String
mainBodyType
;
/**
* 地域
*/
private
String
region
;
/**
* 行政级别
*/
private
String
politicsLevel
;
/**
* 领域
*/
private
String
field
;
/**
* 主办单位
*/
private
String
sponsor
;
/**
* 矩阵归属
*/
private
String
matrixAttribution
;
/**
* 背景资料
*/
private
String
backgroundInfo
;
/**
* ccid
*/
private
String
ccid
;
/**
* 省份
*/
private
String
province
;
/**
* 细分领域
*/
private
String
subDividedField
;
/**
* 展现领域
*/
private
String
displayField
;
/**
* 项目标签
*/
private
String
projectTag
;
/**
* 类别身份
*/
private
String
identity
;
/**
* 更新渠道状态
*/
private
Boolean
updateStatus
;
/**
* 项目
*/
private
String
project
;
/**
* 项目id
*/
private
String
projectId
;
/**
* createAt 创建时间
*/
private
Long
createAt
;
/**
* creator 创建者
*/
private
String
creator
;
/**
* creatorId 创建者id
*/
private
String
creatorId
;
/**
* updateAt 更新时间
*/
private
Long
updateAt
;
/**
* submitter 最后提交人 用于呈现最后操作者
*/
private
String
submitter
;
/**
* submitterId 最后提交人id 用于记录最后操作者
*/
private
String
submitterId
;
}
src/main/java/com/zhiwei/brandkbs2/service/ChannelService.java
View file @
4370639f
...
...
@@ -152,6 +152,36 @@ public interface ChannelService {
List
<
ChannelListVO
>
getNegativeList
(
String
contendId
,
String
platform
,
String
keyword
,
String
sorter
,
Long
startTime
,
Long
endTime
,
int
size
,
boolean
cache
);
/**
* 新-活跃渠道榜
* @param contendId 品牌id
* @param startTime 开始时间
* @param endTime 结束时间
* @param size 数据量
* @return
*/
JSONObject
getActiveChannelList
(
String
contendId
,
Long
startTime
,
Long
endTime
,
int
size
,
boolean
cache
);
/**
* 新-友好渠道榜
* @param contendId 品牌id
* @param startTime 开始时间
* @param endTime 结束时间
* @param size 数据量
* @return
*/
JSONObject
getPositiveChannelList
(
String
contendId
,
Long
startTime
,
Long
endTime
,
int
size
,
boolean
cache
);
/**
* 新-敏感渠道榜
* @param contendId 品牌id
* @param startTime 开始时间
* @param endTime 结束时间
* @param size 数据量
* @return
*/
JSONObject
getNegativeChannelList
(
String
contendId
,
Long
startTime
,
Long
endTime
,
int
size
,
boolean
cache
);
/**
* 收藏渠道
*
* @param channelId
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/ChannelServiceImpl.java
View file @
4370639f
...
...
@@ -99,6 +99,9 @@ public class ChannelServiceImpl implements ChannelService {
@Resource
(
name
=
"channelTagDao"
)
ChannelTagDao
channelTagDao
;
@Resource
(
name
=
"qbjcPojoDao"
)
private
QbjcPojoDao
qbjcPojoDao
;
@Resource
(
name
=
"projectServiceImpl"
)
ProjectService
projectService
;
...
...
@@ -120,6 +123,8 @@ public class ChannelServiceImpl implements ChannelService {
@Resource
(
name
=
"esSearchExecutor"
)
ThreadPoolTaskExecutor
esSearchExecutor
;
private
static
final
List
<
String
>
PLATFORMS
=
Arrays
.
asList
(
"微博"
,
"微信"
,
"抖音"
,
"小红书"
,
"今日头条"
,
"网媒"
);
@Override
public
PageVO
<
JSONObject
>
findChannelList
(
int
page
,
int
size
,
String
contendId
,
String
emotion
,
String
platform
,
Boolean
show
,
String
keyword
,
String
sorter
)
{
...
...
@@ -189,12 +194,14 @@ public class ChannelServiceImpl implements ChannelService {
result
.
put
(
"eventCount"
,
json
.
getLong
(
"event_count"
));
result
.
put
(
"emotion"
,
EmotionEnum
.
state2Name
(
json
.
getInteger
(
"emotion"
)));
result
.
put
(
"emotionIndex"
,
json
.
getDouble
(
"emotion_index"
));
result
.
put
(
"experienceLevel"
,
ExperienceEnum
.
getValueFromDataBaseName
(
json
.
getString
(
"experience_level"
)));
result
.
put
(
"experienceLevel"
,
ExperienceEnum
.
getValueFromDataBaseName
(
json
.
getString
(
"experience_level"
)));
result
.
put
(
"lastTime"
,
json
.
getLong
(
"last_time"
));
result
.
put
(
"show"
,
json
.
getBoolean
(
"show"
));
result
.
put
(
"imgUrl"
,
json
.
getString
(
"avatar_url"
));
result
.
put
(
"tag"
,
channelTagDao
.
getTagByChannelName
(
json
.
getString
(
"source"
)));
// 重要渠道信息
String
brandLinkedGroupId
=
projectService
.
getProjectById
(
UserThreadLocal
.
getProjectId
()).
getBrandLinkedGroupId
();
result
.
put
(
"sensitiveChannelInfo"
,
matchYuQingSensitiveChannel
(
brandLinkedGroupId
,
json
.
getString
(
"source"
)));
return
result
;
}).
collect
(
Collectors
.
toList
());
return
PageVO
.
createPageVo
(
value
,
page
,
size
,
resList
);
...
...
@@ -290,6 +297,9 @@ public class ChannelServiceImpl implements ChannelService {
jsonObject
.
put
(
"source"
,
channel
.
getSource
());
jsonObject
.
put
(
"imgUrl"
,
channel
.
getAvatarUrl
());
jsonObject
.
put
(
"tag"
,
channelTagDao
.
getTagByChannelName
(
channel
.
getSource
()));
// 重要渠道信息
String
brandLinkedGroupId
=
projectService
.
getProjectById
(
UserThreadLocal
.
getProjectId
()).
getBrandLinkedGroupId
();
jsonObject
.
put
(
"sensitiveChannelInfo"
,
matchYuQingSensitiveChannel
(
brandLinkedGroupId
,
channel
.
getSource
()));
return
jsonObject
;
}
...
...
@@ -376,8 +386,7 @@ public class ChannelServiceImpl implements ChannelService {
@Override
public
List
<
ChannelListVO
>
getActiveChannelList
(
String
contendId
,
String
platform
,
String
keyword
,
Long
startTime
,
Long
endTime
,
int
size
,
boolean
cache
)
{
return
getEmotionList
(
contendId
,
platform
,
keyword
,
null
,
startTime
,
endTime
,
size
,
EmotionEnum
.
ALL
.
getState
(),
cache
);
return
getEmotionList
(
contendId
,
platform
,
keyword
,
null
,
startTime
,
endTime
,
size
,
EmotionEnum
.
ALL
.
getState
(),
cache
);
}
@Deprecated
...
...
@@ -431,15 +440,110 @@ public class ChannelServiceImpl implements ChannelService {
@Override
public
List
<
ChannelListVO
>
getPositiveList
(
String
contendId
,
String
platform
,
String
keyword
,
String
sorter
,
Long
startTime
,
Long
endTime
,
int
size
,
boolean
cache
)
{
return
getEmotionList
(
contendId
,
platform
,
keyword
,
sorter
,
startTime
,
endTime
,
size
,
EmotionEnum
.
POSITIVE
.
getState
(),
cache
);
return
getEmotionList
(
contendId
,
platform
,
keyword
,
sorter
,
startTime
,
endTime
,
size
,
EmotionEnum
.
POSITIVE
.
getState
(),
cache
);
}
@Override
public
List
<
ChannelListVO
>
getNegativeList
(
String
contendId
,
String
platform
,
String
keyword
,
String
sorter
,
Long
startTime
,
Long
endTime
,
int
size
,
boolean
cache
)
{
return
getEmotionList
(
contendId
,
platform
,
keyword
,
sorter
,
startTime
,
endTime
,
size
,
EmotionEnum
.
NEGATIVE
.
getState
(),
cache
);
return
getEmotionList
(
contendId
,
platform
,
keyword
,
sorter
,
startTime
,
endTime
,
size
,
EmotionEnum
.
NEGATIVE
.
getState
(),
cache
);
}
@Override
public
JSONObject
getActiveChannelList
(
String
contendId
,
Long
startTime
,
Long
endTime
,
int
size
,
boolean
cache
)
{
return
getChannelListCache
(
contendId
,
startTime
,
endTime
,
EmotionEnum
.
ALL
.
getState
(),
size
,
cache
);
}
@Override
public
JSONObject
getPositiveChannelList
(
String
contendId
,
Long
startTime
,
Long
endTime
,
int
size
,
boolean
cache
)
{
return
getChannelListCache
(
contendId
,
startTime
,
endTime
,
EmotionEnum
.
POSITIVE
.
getState
(),
size
,
cache
);
}
@Override
public
JSONObject
getNegativeChannelList
(
String
contendId
,
Long
startTime
,
Long
endTime
,
int
size
,
boolean
cache
)
{
return
getChannelListCache
(
contendId
,
startTime
,
endTime
,
EmotionEnum
.
NEGATIVE
.
getState
(),
size
,
cache
);
}
private
JSONObject
getChannelListCache
(
String
contendId
,
Long
startTime
,
Long
endTime
,
int
emotion
,
int
size
,
boolean
cache
)
{
JSONObject
res
=
new
JSONObject
();
try
{
String
projectId
=
UserThreadLocal
.
getProjectId
();
String
redisKey
=
RedisUtil
.
getChannelRecordList
(
projectId
,
contendId
,
startTime
,
endTime
,
emotion
);
String
resultStr
;
// 返回缓存
if
(
cache
&&
StringUtils
.
isNotEmpty
(
resultStr
=
redisUtil
.
get
(
redisKey
)))
{
return
JSONObject
.
parseObject
(
resultStr
);
}
res
=
getChannelList
(
projectId
,
contendId
,
startTime
,
endTime
,
emotion
,
size
);
// 配合天级缓存开启
redisUtil
.
setExpire
(
redisKey
,
JSON
.
toJSONString
(
res
));
}
catch
(
IOException
e
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"es查询异常"
);
}
return
res
;
}
private
JSONObject
getChannelList
(
String
projectId
,
String
contendId
,
Long
startTime
,
Long
endTime
,
int
emotion
,
int
size
)
throws
IOException
{
JSONObject
res
=
new
JSONObject
(
new
LinkedHashMap
<>());
Map
<
String
,
Pair
<
Long
,
ChannelRecord
>>
keyMap
=
new
HashMap
<>();
EsClientDao
.
SearchHelper
searchHelper
=
createSearchHelperByChannelCriteria
(
projectId
,
Collections
.
singleton
(
contendId
),
startTime
,
endTime
,
true
);
// 分页查询所有结果
List
<
SearchResponse
>
searchResponses
=
channelEsDao
.
searchScrollResponse
(
searchHelper
);
for
(
SearchResponse
searchResponse
:
searchResponses
)
{
for
(
SearchHit
hit
:
searchResponse
.
getHits
().
getHits
())
{
ChannelRecord
channelRecord
=
new
ChannelRecord
(
hit
.
getSourceAsMap
());
keyMap
.
compute
(
channelRecord
.
getKey
(),
(
k
,
v
)
->
{
if
(
null
==
v
)
{
return
Pair
.
of
(
channelRecord
.
getRangeEndTime
(),
channelRecord
);
}
else
{
// 比较数据时间
if
(
channelRecord
.
getRangeEndTime
()
>
v
.
getLeft
())
{
v
.
getRight
().
setChannelInfo
(
channelRecord
);
}
// 合并文章数据
v
.
getRight
().
getRecord
().
mergeRecord
(
channelRecord
.
getRecord
());
return
v
;
}
});
}
}
// 过滤掉不符合时间条件的数据并排序
Map
<
String
,
List
<
ChannelRecord
>>
channelRecords
=
keyMap
.
values
().
stream
().
map
(
pair
->
{
ChannelRecord
channelRecord
=
pair
.
getRight
();
// 情感过滤
if
(
emotion
==
EmotionEnum
.
ALL
.
getState
()
||
emotion
==
channelRecord
.
getEmotion
())
{
List
<
ChannelIndex
.
Article
>
articles
=
ChannelIndex
.
Record
.
filterArticles
(
startTime
,
endTime
,
channelRecord
.
getRecord
().
getArticles
());
articles
.
sort
(
Comparator
.
comparingLong
(
ChannelIndex
.
Article
::
getTime
).
reversed
());
channelRecord
.
getRecord
().
setArticles
(
articles
);
return
channelRecord
;
}
return
null
;
}).
filter
(
Objects:
:
nonNull
).
sorted
((
x
,
y
)
->
{
// 稿件数排序
if
(
x
.
getRecord
().
getArticles
().
size
()
>
y
.
getRecord
().
getArticles
().
size
())
{
return
-
1
;
}
else
if
(
Objects
.
equals
(
x
.
getRecord
().
getArticles
().
size
(),
y
.
getRecord
().
getArticles
().
size
()))
{
return
0
;
}
return
1
;
}).
collect
(
Collectors
.
groupingBy
(
ChannelRecord:
:
getPlatform
));
for
(
String
platformName
:
PLATFORMS
)
{
List
<
ChannelRecord
>
channelRecordList
=
channelRecords
.
getOrDefault
(
platformName
,
Collections
.
emptyList
()).
stream
().
limit
(
size
).
collect
(
Collectors
.
toList
());
List
<
ChannelListVO
>
list
=
new
ArrayList
<>(
size
);
Map
<
String
,
ChannelRecord
>
map
=
Maps
.
uniqueIndex
(
channelRecordList
,
ChannelRecord:
:
getChannelFid
);
Map
<
String
,
Channel
>
fidChannel
=
channelDao
.
queryUniqueAsync
(
map
.
keySet
());
map
.
forEach
((
fid
,
record
)
->
{
Channel
channel
=
fidChannel
.
get
(
fid
);
if
(
null
!=
channel
)
{
list
.
add
(
ChannelListVO
.
createFromChannel
(
channel
,
record
.
getRecord
().
getArticles
().
size
()));
}
else
{
list
.
add
(
ChannelListVO
.
createFromChannel
(
record
,
record
.
getRecord
().
getArticles
().
size
()));
}
});
res
.
put
(
platformName
,
list
);
}
return
res
;
}
private
List
<
ChannelListVO
>
getEmotionList
(
String
contendId
,
String
platform
,
String
keyword
,
String
sorter
,
...
...
@@ -604,15 +708,48 @@ public class ChannelServiceImpl implements ChannelService {
jsonObject
.
put
(
"emotionRank"
,
getChannelEmotionRank
(
channel
.
getEmotionIndex
(),
channel
.
getEmotion
()));
jsonObject
.
put
(
"articlesCount"
,
channel
.
getArticleCount
());
jsonObject
.
put
(
"eventCount"
,
channel
.
getEventCount
());
jsonObject
.
put
(
"channelTag"
,
channelTagDao
.
getTagByChannelName
(
channel
.
getSource
()));
//
jsonObject.put("channelTag", channelTagDao.getTagByChannelName(channel.getSource()));
if
(
Boolean
.
TRUE
.
equals
(
channel
.
getIsCollect
()))
{
jsonObject
.
put
(
"collectTime"
,
channel
.
getCollectTime
());
}
jsonObject
.
put
(
"lastTime"
,
channel
.
getLastTime
());
jsonObject
.
put
(
"lastTime"
,
channel
.
getLastTime
());
// 舆情重要渠道信息
String
linkedGroupId
=
projectService
.
getProjectById
(
UserThreadLocal
.
getProjectId
()).
getBrandLinkedGroupId
();
jsonObject
.
put
(
"sensitiveChannelInfo"
,
matchYuQingSensitiveChannel
(
linkedGroupId
,
channel
.
getSource
()));
// 渠道倾向变化 TODO
return
jsonObject
;
}
/**
* 获取舆情重要渠道信息
* @param linkedGroupId
* @param source
* @return
*/
private
JSONObject
matchYuQingSensitiveChannel
(
String
linkedGroupId
,
String
source
){
JSONObject
sensitiveChannelInfo
=
new
JSONObject
();
SensitiveChannel
sensitiveChannel
;
// 先匹配舆情项目重要渠道,未匹配上时转而匹配舆情通用重要渠道
SensitiveChannel
projectSensitiveChannel
=
qbjcPojoDao
.
findSensitiveChannelBySource
(
linkedGroupId
,
source
);
if
(
Objects
.
nonNull
(
projectSensitiveChannel
))
{
sensitiveChannel
=
projectSensitiveChannel
;
}
else
{
sensitiveChannel
=
qbjcPojoDao
.
findSensitiveChannelBySource
(
source
);
}
if
(
Objects
.
nonNull
(
sensitiveChannel
)){
sensitiveChannelInfo
.
put
(
"mainBodyType"
,
sensitiveChannel
.
getMainBodyType
());
sensitiveChannelInfo
.
put
(
"displayField"
,
sensitiveChannel
.
getDisplayField
());
sensitiveChannelInfo
.
put
(
"politicsLevel"
,
sensitiveChannel
.
getPoliticsLevel
());
sensitiveChannelInfo
.
put
(
"region"
,
sensitiveChannel
.
getRegion
());
sensitiveChannelInfo
.
put
(
"field"
,
sensitiveChannel
.
getField
());
sensitiveChannelInfo
.
put
(
"matrixAttribution"
,
sensitiveChannel
.
getMatrixAttribution
());
sensitiveChannelInfo
.
put
(
"projectTag"
,
sensitiveChannel
.
getProjectTag
());
sensitiveChannelInfo
.
put
(
"backgroundInfo"
,
sensitiveChannel
.
getBackgroundInfo
());
return
sensitiveChannelInfo
;
}
return
null
;
}
@Override
public
JSONObject
getSpreadingTend
(
String
channelId
,
String
type
,
String
contendIds
,
Long
startTime
,
Long
endTime
)
{
JSONObject
res
=
new
JSONObject
();
...
...
@@ -1668,8 +1805,7 @@ public class ChannelServiceImpl implements ChannelService {
private
EsClientDao
.
SearchHelper
createSearchHelperByChannelCriteria
(
String
projectId
,
String
channelId
,
Collection
<
String
>
contendIds
,
String
platform
,
String
keyword
,
Long
startTime
,
Long
endTime
)
{
return
createSearchHelperByChannelCriteria
(
projectId
,
channelId
,
contendIds
,
platform
,
keyword
,
startTime
,
endTime
,
true
);
return
createSearchHelperByChannelCriteria
(
projectId
,
channelId
,
contendIds
,
platform
,
keyword
,
startTime
,
endTime
,
true
);
}
private
EsClientDao
.
SearchHelper
createSearchHelperByChannelCriteria
(
String
projectId
,
String
channelId
,
...
...
@@ -1717,6 +1853,40 @@ public class ChannelServiceImpl implements ChannelService {
return
helper
;
}
private
EsClientDao
.
SearchHelper
createSearchHelperByChannelCriteria
(
String
projectId
,
Collection
<
String
>
contendIds
,
Long
startTime
,
Long
endTime
,
boolean
defaultTime
)
{
EsClientDao
.
SearchHelper
helper
=
EsClientDao
.
createSearchHelper
();
// query
BoolQueryBuilder
query
=
QueryBuilders
.
boolQuery
();
// project和contendId
query
.
must
(
QueryBuilders
.
termQuery
(
"project_id.keyword"
,
projectId
));
// 添加contends集合 查询
if
(
null
!=
contendIds
)
{
EsQueryTools
.
assembleContendsQuery4Channel
(
query
,
contendIds
);
}
// platformId
List
<
String
>
platformIds
=
new
ArrayList
<>(
6
);
for
(
String
platformName
:
PLATFORMS
)
{
platformIds
.
add
(
GlobalPojo
.
getPlatformIdByName
(
platformName
));
}
if
(
CollectionUtils
.
isNotEmpty
(
platformIds
))
{
query
.
must
(
QueryBuilders
.
termsQuery
(
GenericAttribute
.
ES_PLATFORM_ID
,
platformIds
));
}
// timeRange
// 默认搜索一周
if
(
defaultTime
&&
(
null
==
startTime
||
null
==
endTime
))
{
Long
[]
timeRangeWeek
=
commonService
.
getTimeRangeWeek
();
startTime
=
timeRangeWeek
[
0
];
endTime
=
timeRangeWeek
[
1
];
}
RangeQueryBuilder
timeRangeQuery
=
QueryBuilders
.
rangeQuery
(
"record.articles.time"
).
lt
(
endTime
);
if
(
null
!=
startTime
)
{
timeRangeQuery
.
gte
(
startTime
);
}
query
.
must
(
timeRangeQuery
);
helper
.
setQuery
(
query
);
return
helper
;
}
private
Query
channelListQuery
(
String
contendId
,
Boolean
show
,
String
emotion
,
String
platform
,
String
keyword
,
String
sorter
)
{
Query
query
=
new
Query
();
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/TaskServiceImpl.java
View file @
4370639f
...
...
@@ -152,10 +152,13 @@ public class TaskServiceImpl implements TaskService {
timeList
.
forEach
(
times
->
{
// 活跃渠道榜
channelService
.
getActiveChannelList
(
Constant
.
PRIMARY_CONTEND_ID
,
null
,
null
,
times
[
0
],
times
[
1
],
50
,
false
);
channelService
.
getActiveChannelList
(
Constant
.
PRIMARY_CONTEND_ID
,
times
[
0
],
times
[
1
],
50
,
false
);
// 友好渠道榜
channelService
.
getPositiveList
(
Constant
.
PRIMARY_CONTEND_ID
,
null
,
null
,
sorter
,
times
[
0
],
times
[
1
],
50
,
false
);
channelService
.
getPositiveChannelList
(
Constant
.
PRIMARY_CONTEND_ID
,
times
[
0
],
times
[
1
],
50
,
false
);
// 敏感渠道榜
channelService
.
getNegativeList
(
Constant
.
PRIMARY_CONTEND_ID
,
null
,
null
,
sorter
,
times
[
0
],
times
[
1
],
50
,
false
);
channelService
.
getNegativeChannelList
(
Constant
.
PRIMARY_CONTEND_ID
,
times
[
0
],
times
[
1
],
50
,
false
);
});
log
.
info
(
"项目:{}-渠道榜单缓存已完成:{}个"
,
project
.
getProjectName
(),
total
.
incrementAndGet
());
return
null
;
...
...
src/main/java/com/zhiwei/brandkbs2/util/RedisUtil.java
View file @
4370639f
...
...
@@ -58,6 +58,10 @@ public class RedisUtil {
return
RedisKeyPrefix
.
CHANNEL_RECORD_LIST
+
Tools
.
concat
(
projectId
,
startTime
,
endTime
,
platform
,
emotion
);
}
public
static
String
getChannelRecordList
(
String
projectId
,
String
contendId
,
Long
startTime
,
Long
endTime
,
int
emotion
)
{
return
RedisKeyPrefix
.
CHANNEL_RECORD_LIST
+
Tools
.
concat
(
projectId
,
contendId
,
startTime
,
endTime
,
emotion
);
}
public
static
String
getNewCrisisCaseListAllKey
()
{
return
RedisKeyPrefix
.
PROJECT_WARN_NEW_CASE_LIST
+
"*"
;
}
...
...
src/main/resources/application-dev.properties
View file @
4370639f
...
...
@@ -72,6 +72,7 @@ qbjc.event.tag.url=https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface/tag/e
qbjc.platform.url
=
https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface/platform/resource
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
#\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}
...
...
src/main/resources/application-local.properties
View file @
4370639f
...
...
@@ -75,6 +75,7 @@ qbjc.platform.url=https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface/platfo
#qbjc.userCenter.url=http://192.168.0.225:10000
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
#\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}
...
...
src/main/resources/application-prod.properties
View file @
4370639f
...
...
@@ -72,6 +72,7 @@ qbjc.event.tag.url=https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface/tag/e
qbjc.platform.url
=
https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface/platform/resource
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
#\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}
...
...
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