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
9859622c
Commit
9859622c
authored
May 31, 2023
by
shenjunjie
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature' into 'release'
新增情报方案和关键词配置 See merge request
!340
parents
26c9066d
aaf91644
Show whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
498 additions
and
195 deletions
+498
-195
pom.xml
+6
-0
src/main/java/com/zhiwei/brandkbs2/common/ChannelType.java
+1
-1
src/main/java/com/zhiwei/brandkbs2/common/GlobalPojo.java
+28
-3
src/main/java/com/zhiwei/brandkbs2/controller/admin/BaseModuleController.java
+52
-8
src/main/java/com/zhiwei/brandkbs2/controller/app/AppWarnController.java
+69
-30
src/main/java/com/zhiwei/brandkbs2/dao/HighlightWordDao.java
+12
-0
src/main/java/com/zhiwei/brandkbs2/dao/impl/HighlightWordDaoImpl.java
+20
-0
src/main/java/com/zhiwei/brandkbs2/easyexcel/dto/ExportWordDTO.java
+4
-4
src/main/java/com/zhiwei/brandkbs2/pojo/AbstractBaseWord.java
+53
-0
src/main/java/com/zhiwei/brandkbs2/pojo/HighWord.java
+1
-40
src/main/java/com/zhiwei/brandkbs2/pojo/HighlightWord.java
+17
-0
src/main/java/com/zhiwei/brandkbs2/pojo/Project.java
+5
-0
src/main/java/com/zhiwei/brandkbs2/service/HighWordService.java
+2
-38
src/main/java/com/zhiwei/brandkbs2/service/HighlightWordService.java
+10
-0
src/main/java/com/zhiwei/brandkbs2/service/ProjectService.java
+8
-0
src/main/java/com/zhiwei/brandkbs2/service/TableWordService.java
+49
-0
src/main/java/com/zhiwei/brandkbs2/service/impl/HighWordServiceImpl.java
+4
-54
src/main/java/com/zhiwei/brandkbs2/service/impl/HighlightWordServiceImpl.java
+21
-0
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkDataServiceImpl.java
+8
-4
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkFlowServiceImpl.java
+35
-3
src/main/java/com/zhiwei/brandkbs2/service/impl/ProjectServiceImpl.java
+6
-0
src/main/java/com/zhiwei/brandkbs2/service/impl/TableWordServiceImpl.java
+76
-0
src/main/java/com/zhiwei/brandkbs2/service/impl/UserServiceImpl.java
+3
-2
src/main/resources/application-dev.properties
+1
-1
src/main/resources/application-local.properties
+1
-1
src/main/resources/application-prod.properties
+1
-1
src/test/java/com/zhiwei/brandkbs2/HighWordServiceTest.java
+5
-5
No files found.
pom.xml
View file @
9859622c
...
...
@@ -40,6 +40,12 @@
</properties>
<dependencies>
<!-- 自动化中间件客户端 -->
<dependency>
<groupId>
com.zhiwei.middleware
</groupId>
<artifactId>
automaticmark-client
</artifactId>
<version>
2.3.1.1-SNAPSHOT
</version>
</dependency>
<!-- 去重 -->
<dependency>
<groupId>
com.zhiwei.middleware
</groupId>
...
...
src/main/java/com/zhiwei/brandkbs2/common/ChannelType.java
View file @
9859622c
...
...
@@ -16,7 +16,7 @@ public class ChannelType {
private
static
final
List
<
String
>
MAIN_BODY_TYPES
=
Arrays
.
asList
(
"媒体"
,
"团体"
,
"普通用户"
,
"企业"
,
"名人"
,
"政务机构"
);
public
static
final
List
<
String
>
POLITICS_LEVELS
=
Arrays
.
asList
(
"央级"
,
"省级"
,
"地级"
);
private
static
final
List
<
String
>
FIELDS
=
Arrays
.
asList
(
"
情感"
,
"综合"
,
"财经"
,
"家居"
,
"社会"
,
"时尚"
,
"文化"
,
"历史"
,
"母婴育儿"
,
"体育"
,
"娱乐"
,
"动漫"
,
"汽车"
,
"美食"
,
"健康养生"
,
"国际"
,
"音乐"
,
"游戏"
,
"科技"
,
"旅游"
,
"军事"
,
"时事"
,
"教育
"
);
private
static
final
List
<
String
>
FIELDS
=
Arrays
.
asList
(
"
时政"
,
"财经"
,
"科技"
,
"社会民生"
,
"交通"
,
"综合"
,
"娱乐"
,
"生活"
,
"体育"
,
"教育"
,
"文化"
,
"母婴育儿"
,
"健康
"
);
private
static
final
JSONArray
REGION
=
GlobalPojo
.
CHINA_AREA_TAGS
;
public
static
JSONObject
channelOption
=
new
JSONObject
();
public
static
final
List
<
String
>
COMMON_FIELDS
=
Arrays
.
asList
(
"财经"
,
"科技"
,
"时政"
,
"社会民生"
,
"交通"
);
...
...
src/main/java/com/zhiwei/brandkbs2/common/GlobalPojo.java
View file @
9859622c
...
...
@@ -3,14 +3,19 @@ package com.zhiwei.brandkbs2.common;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.zhiwei.brandkbs2.pojo.ChannelTag
;
import
com.zhiwei.brandkbs2.pojo.HighlightWord
;
import
com.zhiwei.brandkbs2.pojo.Project
;
import
com.zhiwei.brandkbs2.service.SystemInfoService
;
import
com.zhiwei.brandkbs2.util.Tools
;
import
com.zhiwei.middleware.automaticmark.graphs.Graphs
;
import
com.zhiwei.qbjc.bean.pojo.common.MessagePlatform
;
import
com.zhiwei.qbjc.bean.pojo.common.Tag
;
import
com.zhiwei.brandkbs2.dao.HighlightWordDao
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
...
...
@@ -18,9 +23,7 @@ import org.springframework.stereotype.Component;
import
javax.annotation.PostConstruct
;
import
javax.annotation.Resource
;
import
java.io.IOException
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -40,6 +43,9 @@ public class GlobalPojo {
@Resource
(
name
=
"systemInfoServiceImpl"
)
private
SystemInfoService
systemInfoService
;
@Resource
(
name
=
"highlightWordDao"
)
private
HighlightWordDao
highlightWordDao
;
/**
* 监测系统平台
**/
...
...
@@ -72,6 +78,10 @@ public class GlobalPojo {
public
static
JSONArray
CHINA_AREA_TAGS
;
public
static
Map
<
String
,
List
<
String
>>
HIGHLIGHT_MAP
=
new
HashMap
<>();
public
static
Map
<
String
,
Graphs
>
PROJECT_GRAPHS
=
new
HashMap
<>();
public
static
final
List
<
String
>
PERMANENT_PLATFORM_NAMES
=
Arrays
.
asList
(
"网媒"
,
"微博"
,
"微信"
,
"今日头条"
);
public
static
final
String
ELSE_PLATFORM_NAME
=
"其他自媒体"
;
...
...
@@ -109,6 +119,7 @@ public class GlobalPojo {
MEDIA_TYPE
=
systemInfoService
.
getMediaTypes
();
PROJECT_MAP
=
systemInfoService
.
getProjects
();
YU_QING_PROJECTS
=
systemInfoService
.
getYuQingProjects
();
updateHighlightGraphs
();
log
.
info
(
"{}-获取PLATFORMS-size:{},TAGS-size:{},LINKED_GROUP_ID_TAGS:{},CHANNEL_TAGS:{},MEDIA_TYPE:{},PROJECT_MAP:{},YUQING-PROJECTS-size:{}"
,
logMsg
,
PLATFORMS
.
size
(),
TAGS
.
size
(),
LINKED_GROUP_ID_TAGS
.
size
(),
CHANNEL_TAGS
.
size
(),
MEDIA_TYPE
.
size
(),
PROJECT_MAP
.
size
(),
YU_QING_PROJECTS
.
size
());
}
catch
(
Exception
e
)
{
...
...
@@ -116,6 +127,20 @@ public class GlobalPojo {
}
}
private
void
updateHighlightGraphs
()
{
PROJECT_MAP
.
forEach
((
key
,
project
)
->
{
String
id
=
project
.
getId
();
List
<
String
>
list
=
highlightWordDao
.
findList
(
Query
.
query
(
Criteria
.
where
(
"projectId"
).
is
(
id
))).
stream
().
map
(
HighlightWord:
:
getKeyword
).
collect
(
Collectors
.
toList
());
List
<
String
>
keywords
=
new
ArrayList
<>();
// 拆分关键词中的且逻辑
list
.
forEach
(
word
->
keywords
.
addAll
(
Arrays
.
asList
(
word
.
trim
().
split
(
" +"
))));
Graphs
graphs
=
new
Graphs
();
graphs
.
addGraph
(
keywords
);
HIGHLIGHT_MAP
.
put
(
id
,
list
);
PROJECT_GRAPHS
.
put
(
id
,
graphs
);
});
}
public
static
String
getPlatformIdByName
(
String
platformName
)
{
for
(
MessagePlatform
platform
:
PLATFORMS
)
{
if
(
platform
.
getName
().
equals
(
platformName
))
{
...
...
src/main/java/com/zhiwei/brandkbs2/controller/admin/BaseModuleController.java
View file @
9859622c
...
...
@@ -5,12 +5,13 @@ 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.Export
High
WordDTO
;
import
com.zhiwei.brandkbs2.easyexcel.dto.ExportWordDTO
;
import
com.zhiwei.brandkbs2.enmus.RoleEnum
;
import
com.zhiwei.brandkbs2.model.ResponseResult
;
import
com.zhiwei.brandkbs2.pojo.dto.TagFilterDTO
;
import
com.zhiwei.brandkbs2.pojo.vo.ProjectVO
;
import
com.zhiwei.brandkbs2.service.HighWordService
;
import
com.zhiwei.brandkbs2.service.HighlightWordService
;
import
com.zhiwei.brandkbs2.service.ProjectService
;
import
com.zhiwei.brandkbs2.service.TagFilterService
;
import
com.zhiwei.brandkbs2.util.Tools
;
...
...
@@ -42,6 +43,9 @@ public class BaseModuleController extends BaseController {
@Resource
(
name
=
"highWordServiceImpl"
)
HighWordService
highWordService
;
@Resource
(
name
=
"highlightWordServiceImpl"
)
HighlightWordService
highlightWordService
;
@Resource
(
name
=
"projectServiceImpl"
)
ProjectService
projectService
;
...
...
@@ -68,7 +72,7 @@ public class BaseModuleController extends BaseController {
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"page"
,
value
=
"页码"
,
defaultValue
=
"1"
,
paramType
=
"query"
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"size"
,
value
=
"每页记录数"
,
defaultValue
=
"10"
,
paramType
=
"query"
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"keyword"
,
value
=
"搜索关键字"
,
paramType
=
"query"
,
dataType
=
"string"
)})
@GetMapping
(
"/highWord/list"
)
public
ResponseResult
findHighWordList
(
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
int
page
,
@RequestParam
(
value
=
"size"
,
defaultValue
=
"10"
)
int
size
,
@RequestParam
(
value
=
"keyword"
,
defaultValue
=
""
)
String
keyword
)
{
return
ResponseResult
.
success
(
highWordService
.
find
High
Word
(
page
,
size
,
keyword
));
return
ResponseResult
.
success
(
highWordService
.
findWord
(
page
,
size
,
keyword
));
}
@ApiOperation
(
"添加高频关键词列表"
)
...
...
@@ -76,14 +80,13 @@ public class BaseModuleController extends BaseController {
@PostMapping
(
"/highWord/add"
)
public
ResponseResult
addHighWordList
(
@RequestBody
JSONObject
info
)
{
List
<
String
>
highWords
=
info
.
getJSONArray
(
"list"
).
toJavaList
(
String
.
class
);
highWordService
.
addHighWordList
(
highWords
);
return
ResponseResult
.
success
();
return
highWordService
.
addWordList
(
highWords
,
UserThreadLocal
.
getProjectId
(),
UserThreadLocal
.
getNickname
());
}
@ApiOperation
(
"高频关键词删除"
)
@DeleteMapping
(
value
=
"/highWord/delete/{id}"
)
public
ResponseResult
deleteHighWord
(
@PathVariable
String
id
)
{
highWordService
.
delete
High
Word
(
id
);
highWordService
.
deleteWord
(
id
);
return
ResponseResult
.
success
();
}
...
...
@@ -96,9 +99,50 @@ public class BaseModuleController extends BaseController {
@ApiOperation
(
"高频关键词下载"
)
@GetMapping
(
value
=
"/highWord/download"
)
public
ResponseResult
downloadHighWord
()
{
List
<
ExportHighWordDTO
>
list
=
highWordService
.
downloadHighWord
();
ProjectVO
projectVO
=
projectService
.
getProjectVOById
(
UserThreadLocal
.
getProjectId
());
EasyExcelUtil
.
download
(
projectVO
.
getBrandName
()
+
"_高频关键词"
,
"sheet1"
,
ExportHighWordDTO
.
class
,
list
,
response
);
String
projectId
=
UserThreadLocal
.
getProjectId
();
List
<
ExportWordDTO
>
list
=
highWordService
.
downloadWord
(
projectId
);
ProjectVO
projectVO
=
projectService
.
getProjectVOById
(
projectId
);
EasyExcelUtil
.
download
(
projectVO
.
getBrandName
()
+
"_高频关键词"
,
"sheet1"
,
ExportWordDTO
.
class
,
list
,
response
);
return
ResponseResult
.
success
();
}
@ApiOperation
(
"获取舆情列表高亮关键词"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"page"
,
value
=
"页码"
,
defaultValue
=
"1"
,
paramType
=
"query"
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"size"
,
value
=
"每页记录数"
,
defaultValue
=
"10"
,
paramType
=
"query"
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"keyword"
,
value
=
"搜索关键字"
,
paramType
=
"query"
,
dataType
=
"string"
)})
@GetMapping
(
"/highlightWord/list"
)
public
ResponseResult
findHighlightKeywordList
(
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
int
page
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"10"
)
int
pageSize
,
@RequestParam
(
value
=
"keyword"
,
defaultValue
=
""
)
String
keyword
)
{
return
ResponseResult
.
success
(
highlightWordService
.
findWord
(
page
,
pageSize
,
keyword
));
}
@ApiOperation
(
"添加舆情列表高亮关键词列表"
)
@ApiImplicitParams
(
@ApiImplicitParam
(
name
=
"list"
,
value
=
"高亮关键词列表"
,
paramType
=
"body"
,
dataType
=
"list"
))
@PostMapping
(
"/highlightWord/add"
)
public
ResponseResult
addHighlightWordList
(
@RequestBody
JSONObject
info
)
{
List
<
String
>
highWords
=
info
.
getJSONArray
(
"list"
).
toJavaList
(
String
.
class
);
return
highlightWordService
.
addWordList
(
highWords
,
UserThreadLocal
.
getProjectId
(),
UserThreadLocal
.
getNickname
());
}
@ApiOperation
(
"舆情列表高亮关键词删除"
)
@DeleteMapping
(
value
=
"/highlightWord/delete/{id}"
)
public
ResponseResult
deleteHighlightWord
(
@PathVariable
String
id
)
{
highlightWordService
.
deleteWord
(
id
);
return
ResponseResult
.
success
();
}
@ApiOperation
(
"舆情列表高亮关键词excel解析"
)
@PostMapping
(
value
=
"/highlightWord/excel/parse"
,
headers
=
"content-type=multipart/form-data"
)
public
ResponseResult
parseExcelHighlightWord
(
@RequestParam
(
"file"
)
MultipartFile
file
)
{
return
Tools
.
parseExcelInfo
(
file
);
}
@ApiOperation
(
"舆情列表高亮关键词下载"
)
@GetMapping
(
value
=
"/highlightWord/download"
)
public
ResponseResult
downloadHighlightWord
()
{
String
projectId
=
UserThreadLocal
.
getProjectId
();
List
<
ExportWordDTO
>
list
=
highlightWordService
.
downloadWord
(
projectId
);
ProjectVO
projectVO
=
projectService
.
getProjectVOById
(
projectId
);
EasyExcelUtil
.
download
(
projectVO
.
getBrandName
()
+
"_舆情列表高亮关键词"
,
"sheet1"
,
ExportWordDTO
.
class
,
list
,
response
);
return
ResponseResult
.
success
();
}
...
...
src/main/java/com/zhiwei/brandkbs2/controller/app/AppWarnController.java
View file @
9859622c
...
...
@@ -28,6 +28,7 @@ import org.springframework.web.bind.annotation.*;
import
org.springframework.web.client.RestTemplate
;
import
javax.annotation.Resource
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLEncoder
;
import
java.util.Map
;
...
...
@@ -92,33 +93,42 @@ public class AppWarnController extends BaseController {
@Value
(
"${warn.taskSwitch.url}"
)
private
String
warnTaskSwitchUrl
;
@ApiOperation
(
"情报预警-推送任务获取
/新增
"
)
@ApiOperation
(
"情报预警-推送任务获取"
)
@GetMapping
(
"/project"
)
public
ResponseResult
getPushTaskId
()
{
try
{
String
projectId
=
UserThreadLocal
.
getProjectId
();
String
projectName
=
projectService
.
getProjectById
(
projectId
).
getProjectName
();
String
userId
=
JwtUtil
.
unsign
(
request
.
getHeader
(
jwtKey
),
Map
.
class
).
get
(
GenericAttribute
.
USER_ID
).
toString
();
// header不支持中文 故对userName进行encode操作
String
userName
=
URLEncoder
.
encode
(
userService
.
queryUserInfo
(
userId
,
projectId
).
getNickname
(),
"UTF-8"
);
// 请求头参数设置
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
add
(
"token"
,
token
);
headers
.
add
(
"userId"
,
userId
);
headers
.
add
(
"userName"
,
userName
);
HttpEntity
<
Object
>
request
=
new
HttpEntity
<>(
headers
);
return
pushTaskId
(
null
,
null
,
HttpMethod
.
GET
);
}
catch
(
Exception
e
)
{
log
.
error
(
"情报预警-推送任务获取失败"
,
e
);
return
ResponseResult
.
failure
(
"情报预警-推送任务获取失败"
);
}
}
JSONObject
data
=
restTemplate
.
exchange
(
warnProjectUrl
,
HttpMethod
.
GET
,
request
,
JSONObject
.
class
,
projectId
,
projectName
).
getBody
().
getJSONObject
(
"data"
);
return
ResponseResult
.
success
(
data
);
}
catch
(
Exception
e
){
log
.
error
(
"情报预警-推送任务获取/新增失败"
,
e
);
return
ResponseResult
.
failure
(
"情报预警-推送任务获取/新增失败"
);
@ApiOperation
(
"情报预警-推送任务新增"
)
@PostMapping
(
"/project"
)
public
ResponseResult
postPushTaskId
(
@RequestBody
JSONObject
json
)
{
try
{
return
pushTaskId
(
null
,
json
.
getString
(
"planName"
),
HttpMethod
.
POST
);
}
catch
(
Exception
e
)
{
log
.
error
(
"情报预警-推送任务新增失败"
,
e
);
return
ResponseResult
.
failure
(
"情报预警-推送任务新增失败"
);
}
}
@ApiOperation
(
"情报预警-推送任务修改"
)
@PutMapping
(
"/project"
)
public
ResponseResult
putPushTaskId
(
@RequestBody
JSONObject
json
)
{
try
{
return
pushTaskId
(
json
.
getString
(
"taskId"
),
json
.
getString
(
"planName"
),
HttpMethod
.
PUT
);
}
catch
(
Exception
e
)
{
log
.
error
(
"情报预警-推送任务修改失败"
,
e
);
return
ResponseResult
.
failure
(
"情报预警-推送任务修改失败"
);
}
}
@ApiOperation
(
"情报预警-获取项目预警更新条件"
)
@GetMapping
(
"/warnCriteria"
)
public
ResponseResult
getProjectWarnCriteria
(
@RequestParam
(
value
=
"type"
)
String
type
){
public
ResponseResult
getProjectWarnCriteria
(
@RequestParam
(
value
=
"type"
)
String
type
)
{
return
ResponseResult
.
success
(
projectWarnService
.
getProjectWarnCriteria
(
UserThreadLocal
.
getProjectId
(),
type
));
}
...
...
@@ -136,7 +146,7 @@ public class AppWarnController extends BaseController {
@ApiOperation
(
"情报预警-已扫码推送名单获取"
)
@GetMapping
(
"/pushRecipientsList"
)
public
ResponseResult
pushRecipientList
(
@RequestParam
(
value
=
"pushTaskId"
)
String
pushTaskId
){
public
ResponseResult
pushRecipientList
(
@RequestParam
(
value
=
"pushTaskId"
)
String
pushTaskId
)
{
// 请求头
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
add
(
"token"
,
token
);
...
...
@@ -149,7 +159,7 @@ public class AppWarnController extends BaseController {
@ApiOperation
(
"情报预警-删除推送人"
)
@GetMapping
(
"/deletePushRecipients"
)
public
ResponseResult
deletePushRecipients
(
@RequestParam
(
value
=
"recipientsId"
)
String
recipientsId
,
@RequestParam
(
value
=
"pushTaskId"
)
String
pushTaskId
){
@RequestParam
(
value
=
"pushTaskId"
)
String
pushTaskId
)
{
// 请求头
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
add
(
"token"
,
token
);
...
...
@@ -163,7 +173,7 @@ public class AppWarnController extends BaseController {
@PutMapping
(
"/channel/{pushTaskId}"
)
public
ResponseResult
channel
(
@ApiParam
(
name
=
"channelConfig"
,
value
=
"情报预警-渠道参与配置-json:{\"channel\": \"string\", \"configName\": \"string\", \"duplicate\": true, \"friendlyChannel\": true, \"markerTags\": [\"string\"], \"primary\": [true], \"pushInterval\": 0, \"threshold\": 0, \"used\": true}"
,
required
=
true
)
@RequestBody
JSONObject
channelConfig
,
@PathVariable
(
value
=
"pushTaskId"
)
String
pushTaskId
){
@PathVariable
(
value
=
"pushTaskId"
)
String
pushTaskId
)
{
try
{
String
userId
=
JwtUtil
.
unsign
(
request
.
getHeader
(
jwtKey
),
Map
.
class
).
get
(
GenericAttribute
.
USER_ID
).
toString
();
String
userName
=
URLEncoder
.
encode
(
userService
.
queryUserInfo
(
userId
,
UserThreadLocal
.
getProjectId
()).
getNickname
(),
"UTF-8"
);
...
...
@@ -178,7 +188,7 @@ public class AppWarnController extends BaseController {
JSONObject
data
=
restTemplate
.
exchange
(
warnChannelUrl
,
HttpMethod
.
PUT
,
request
,
JSONObject
.
class
,
pushTaskId
).
getBody
().
getJSONObject
(
"data"
);
return
ResponseResult
.
success
(
data
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"情报预警-渠道参与配置失败"
,
e
);
return
ResponseResult
.
failure
(
"情报预警-渠道参与配置失败"
);
}
...
...
@@ -188,7 +198,7 @@ public class AppWarnController extends BaseController {
@PutMapping
(
"/hotTop/{pushTaskId}"
)
public
ResponseResult
hotTop
(
@ApiParam
(
name
=
"hotTopConfig"
,
value
=
"情报预警-热点榜单配置-json:{\"configName\": \"string\", \"filterKeyword\": \"string\", \"firstTop\": true, \"introduction\": true,\"listType\": [\"string\"], \"newHeight\": true, \"pushInterval\": 0, \"topNewHeight\": 0, \"topOnceAgain\": true, \"used\": true, \"warnKeyword\": \"string\"}"
,
required
=
true
)
@RequestBody
JSONObject
hotTopConfig
,
@PathVariable
(
value
=
"pushTaskId"
)
String
pushTaskId
){
@PathVariable
(
value
=
"pushTaskId"
)
String
pushTaskId
)
{
try
{
String
userId
=
JwtUtil
.
unsign
(
request
.
getHeader
(
jwtKey
),
Map
.
class
).
get
(
GenericAttribute
.
USER_ID
).
toString
();
String
userName
=
URLEncoder
.
encode
(
userService
.
queryUserInfo
(
userId
,
UserThreadLocal
.
getProjectId
()).
getNickname
(),
"UTF-8"
);
...
...
@@ -203,7 +213,7 @@ public class AppWarnController extends BaseController {
JSONObject
data
=
restTemplate
.
exchange
(
warnHotTopUrl
,
HttpMethod
.
PUT
,
request
,
JSONObject
.
class
,
pushTaskId
).
getBody
().
getJSONObject
(
"data"
);
return
ResponseResult
.
success
(
data
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"情报预警-热点榜单配置失败"
,
e
);
return
ResponseResult
.
failure
(
"情报预警-热点榜单配置失败"
);
}
...
...
@@ -213,7 +223,7 @@ public class AppWarnController extends BaseController {
@PutMapping
(
"/hotEvent/{pushTaskId}"
)
public
ResponseResult
hotEvent
(
@ApiParam
(
name
=
"hotEventConfig"
,
value
=
"情报预警-热点事件配置-json:{\"configName\": \"string\", \"contendsEvent\": [\"string\"], \"eventTop\": 0, \"ownEvent\": [\"string\"], \"timeCycles\": 0,\"used\": true, \"zhiWeiEvent\": [\"string\"]}"
,
required
=
true
)
@RequestBody
JSONObject
hotEventConfig
,
@PathVariable
(
value
=
"pushTaskId"
)
String
pushTaskId
){
@PathVariable
(
value
=
"pushTaskId"
)
String
pushTaskId
)
{
try
{
String
userId
=
JwtUtil
.
unsign
(
request
.
getHeader
(
jwtKey
),
Map
.
class
).
get
(
GenericAttribute
.
USER_ID
).
toString
();
String
userName
=
URLEncoder
.
encode
(
userService
.
queryUserInfo
(
userId
,
UserThreadLocal
.
getProjectId
()).
getNickname
(),
"UTF-8"
);
...
...
@@ -228,7 +238,7 @@ public class AppWarnController extends BaseController {
JSONObject
data
=
restTemplate
.
exchange
(
warnHotEventUrl
,
HttpMethod
.
PUT
,
request
,
JSONObject
.
class
,
pushTaskId
).
getBody
().
getJSONObject
(
"data"
);
return
ResponseResult
.
success
(
data
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"情报预警-热点事件配置失败- "
,
e
);
return
ResponseResult
.
failure
(
"情报预警-热点事件配置失败"
);
}
...
...
@@ -238,7 +248,7 @@ public class AppWarnController extends BaseController {
@PutMapping
(
"/yuQing/{pushTaskId}"
)
public
ResponseResult
yuQing
(
@ApiParam
(
name
=
"yuQingConfig"
,
value
=
"情报预警-舆情动态配置-json:{\"channelTypes\": [\"string\"], \"configName\": \"string\", \"contends\": [\"string\"], \"duplicate\": true, \"keyword\": \"string\", \"markerTags\": [\"string\"], \"primary\": [true], \"pushInterval\": 0, \"used\": true}"
,
required
=
true
)
@RequestBody
JSONObject
yuQingConfig
,
@PathVariable
(
value
=
"pushTaskId"
)
String
pushTaskId
){
@PathVariable
(
value
=
"pushTaskId"
)
String
pushTaskId
)
{
try
{
String
userId
=
JwtUtil
.
unsign
(
request
.
getHeader
(
jwtKey
),
Map
.
class
).
get
(
GenericAttribute
.
USER_ID
).
toString
();
String
userName
=
URLEncoder
.
encode
(
userService
.
queryUserInfo
(
userId
,
UserThreadLocal
.
getProjectId
()).
getNickname
(),
"UTF-8"
);
...
...
@@ -253,7 +263,7 @@ public class AppWarnController extends BaseController {
JSONObject
data
=
restTemplate
.
exchange
(
warnYuQingUrl
,
HttpMethod
.
PUT
,
request
,
JSONObject
.
class
,
pushTaskId
).
getBody
().
getJSONObject
(
"data"
);
return
ResponseResult
.
success
(
data
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"情报预警-舆情动态配置失败"
,
e
);
return
ResponseResult
.
failure
(
"情报预警-舆情动态配置失败"
);
}
...
...
@@ -262,7 +272,7 @@ public class AppWarnController extends BaseController {
@ApiOperation
(
"情报预警-任务开关"
)
@PutMapping
(
"/taskSwitch"
)
public
ResponseResult
taskSwitch
(
@ApiParam
(
name
=
"info"
,
value
=
"推送任务-开关-json:{id:, used:true|false, configType:HOT_EVENT}"
,
required
=
true
)
@RequestBody
JSONObject
info
){
@RequestBody
JSONObject
info
)
{
try
{
String
userId
=
JwtUtil
.
unsign
(
request
.
getHeader
(
jwtKey
),
Map
.
class
).
get
(
GenericAttribute
.
USER_ID
).
toString
();
String
userName
=
URLEncoder
.
encode
(
userService
.
queryUserInfo
(
userId
,
UserThreadLocal
.
getProjectId
()).
getNickname
(),
"UTF-8"
);
...
...
@@ -277,9 +287,38 @@ public class AppWarnController extends BaseController {
JSONObject
data
=
restTemplate
.
exchange
(
warnTaskSwitchUrl
,
HttpMethod
.
PUT
,
request
,
JSONObject
.
class
).
getBody
().
getJSONObject
(
"data"
);
return
ResponseResult
.
success
(
data
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"情报预警-任务开关失败"
,
e
);
return
ResponseResult
.
failure
(
"情报预警-任务开关失败"
);
}
}
private
ResponseResult
pushTaskId
(
String
taskId
,
String
planName
,
HttpMethod
httpMethod
)
throws
UnsupportedEncodingException
{
String
projectId
=
UserThreadLocal
.
getProjectId
();
String
projectName
=
projectService
.
getProjectById
(
projectId
).
getProjectName
();
String
userId
=
JwtUtil
.
unsign
(
request
.
getHeader
(
jwtKey
),
Map
.
class
).
get
(
GenericAttribute
.
USER_ID
).
toString
();
// header不支持中文 故对userName进行encode操作
String
userName
=
URLEncoder
.
encode
(
userService
.
queryUserInfo
(
userId
,
projectId
).
getNickname
(),
"UTF-8"
);
// 请求头参数设置
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
add
(
"token"
,
token
);
headers
.
add
(
"userId"
,
userId
);
headers
.
add
(
"userName"
,
userName
);
HttpEntity
<
Object
>
request
;
if
(
HttpMethod
.
GET
==
httpMethod
)
{
request
=
new
HttpEntity
<>(
headers
);
return
ResponseResult
.
success
(
restTemplate
.
exchange
(
warnProjectUrl
+
"?projectId={1}&projectName={2}"
,
httpMethod
,
request
,
JSONObject
.
class
,
projectId
,
projectName
).
getBody
().
getJSONArray
(
"data"
));
}
JSONObject
paramMap
=
new
JSONObject
();
paramMap
.
put
(
"planName"
,
planName
);
if
(
HttpMethod
.
PUT
==
httpMethod
)
{
paramMap
.
put
(
"taskId"
,
taskId
);
}
else
{
paramMap
.
put
(
"projectId"
,
projectId
);
paramMap
.
put
(
"projectName"
,
projectName
);
}
request
=
new
HttpEntity
<>(
paramMap
,
headers
);
return
ResponseResult
.
success
(
restTemplate
.
exchange
(
warnProjectUrl
,
httpMethod
,
request
,
JSONObject
.
class
).
getBody
().
getJSONArray
(
"data"
));
}
}
src/main/java/com/zhiwei/brandkbs2/dao/HighlightWordDao.java
0 → 100644
View file @
9859622c
package
com
.
zhiwei
.
brandkbs2
.
dao
;
import
com.zhiwei.brandkbs2.pojo.HighlightWord
;
/**
* @ClassName: HighlightWordDao
* @Description HighlightWordDao
* @author: sjj
* @date: 2022-06-06 09:47
*/
public
interface
HighlightWordDao
extends
BaseMongoDao
<
HighlightWord
>{
}
src/main/java/com/zhiwei/brandkbs2/dao/impl/HighlightWordDaoImpl.java
0 → 100644
View file @
9859622c
package
com
.
zhiwei
.
brandkbs2
.
dao
.
impl
;
import
com.zhiwei.brandkbs2.dao.HighlightWordDao
;
import
com.zhiwei.brandkbs2.pojo.HighlightWord
;
import
org.springframework.stereotype.Component
;
/**
* @ClassName: HighlightWordDaoImpl
* @Description HighlightWordDaoImpl
* @author: sjj
* @date: 2022-06-06 09:48
*/
@Component
(
"highlightWordDao"
)
public
class
HighlightWordDaoImpl
extends
BaseMongoDaoImpl
<
HighlightWord
>
implements
HighlightWordDao
{
private
static
final
String
COLLECTION_NAME
=
"brandkbs_highlight_word"
;
public
HighlightWordDaoImpl
()
{
super
(
COLLECTION_NAME
);
}
}
src/main/java/com/zhiwei/brandkbs2/easyexcel/dto/Export
High
WordDTO.java
→
src/main/java/com/zhiwei/brandkbs2/easyexcel/dto/ExportWordDTO.java
View file @
9859622c
package
com
.
zhiwei
.
brandkbs2
.
easyexcel
.
dto
;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
com.zhiwei.brandkbs2.pojo.
High
Word
;
import
com.zhiwei.brandkbs2.pojo.
AbstractBase
Word
;
import
com.zhiwei.brandkbs2.util.Tools
;
import
lombok.Data
;
import
lombok.ToString
;
...
...
@@ -16,7 +16,7 @@ import java.util.Date;
*/
@Data
@ToString
public
class
Export
High
WordDTO
{
public
class
ExportWordDTO
{
/**
* 名称
...
...
@@ -36,8 +36,8 @@ public class ExportHighWordDTO {
@ExcelProperty
(
"上传人"
)
private
String
submitter
;
public
static
Export
HighWordDTO
createFromHighWord
(
HighWord
highWord
)
{
return
Tools
.
convertMap
(
highWord
,
ExportHigh
WordDTO
.
class
);
public
static
Export
WordDTO
createFromWord
(
AbstractBaseWord
word
)
{
return
Tools
.
convertMap
(
word
,
Export
WordDTO
.
class
);
}
}
src/main/java/com/zhiwei/brandkbs2/pojo/AbstractBaseWord.java
0 → 100644
View file @
9859622c
package
com
.
zhiwei
.
brandkbs2
.
pojo
;
import
lombok.Getter
;
import
lombok.Setter
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* @ClassName: AbstractBaseWord
* @Description AbstractBaseWord
* @author: sjj
* @date: 2023-05-25 14:41
*/
@Setter
@Getter
public
abstract
class
AbstractBaseWord
extends
AbstractBaseMongo
{
/**
* 名称
*/
private
String
keyword
;
/**
* 创建时间
*/
private
Long
cTime
;
/**
* 上传人
*/
private
String
submitter
;
/**
* 项目ID
*/
private
String
projectId
;
public
static
<
T
>
List
<
T
>
createFromList
(
List
<
String
>
keywords
,
String
projectId
,
String
submitter
)
{
List
<
T
>
res
=
new
ArrayList
<>();
Long
now
=
System
.
currentTimeMillis
();
for
(
String
keyword
:
keywords
)
{
AbstractBaseWord
word
=
new
HighWord
();
word
.
setKeyword
(
keyword
);
word
.
setCTime
(
now
);
word
.
setProjectId
(
projectId
);
word
.
setSubmitter
(
submitter
);
res
.
add
((
T
)
word
);
}
return
res
;
}
}
src/main/java/com/zhiwei/brandkbs2/pojo/HighWord.java
View file @
9859622c
...
...
@@ -4,10 +4,6 @@ import lombok.Getter;
import
lombok.Setter
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
/**
* @ClassName: HighWord
* @Description 高频词实体
...
...
@@ -17,40 +13,5 @@ import java.util.List;
@Getter
@Setter
@Document
(
collection
=
"brandkbs_high_word"
)
public
class
HighWord
extends
AbstractBaseMongo
{
/**
* 名称
*/
private
String
keyword
;
/**
* 创建时间
*/
private
Long
cTime
;
/**
* 上传人
*/
private
String
submitter
;
/**
* 项目ID
*/
private
String
projectId
;
public
static
List
<
HighWord
>
createFromList
(
List
<
String
>
keywords
,
String
projectId
,
String
submitter
)
{
List
<
HighWord
>
res
=
new
ArrayList
<>();
Long
now
=
new
Date
().
getTime
();
for
(
String
keyword
:
keywords
)
{
HighWord
highWord
=
new
HighWord
();
highWord
.
setKeyword
(
keyword
);
highWord
.
setCTime
(
now
);
highWord
.
setProjectId
(
projectId
);
highWord
.
setSubmitter
(
submitter
);
res
.
add
(
highWord
);
}
return
res
;
}
public
class
HighWord
extends
AbstractBaseWord
{
}
src/main/java/com/zhiwei/brandkbs2/pojo/HighlightWord.java
0 → 100644
View file @
9859622c
package
com
.
zhiwei
.
brandkbs2
.
pojo
;
import
lombok.Getter
;
import
lombok.Setter
;
import
org.springframework.data.mongodb.core.mapping.Document
;
/**
* @ClassName: HighWord
* @Description 高频词实体
* @author: sjj
* @date: 2022-06-06 09:36
*/
@Getter
@Setter
@Document
(
collection
=
"brandkbs_highlight_word"
)
public
class
HighlightWord
extends
AbstractBaseWord
{
}
src/main/java/com/zhiwei/brandkbs2/pojo/Project.java
View file @
9859622c
...
...
@@ -87,6 +87,11 @@ public class Project extends AbstractProject {
private
Long
uTime
;
/**
* 高亮关键词
*/
private
List
<
String
>
highlightKeyword
;
/**
* 项目主品牌配置信息转换
*
* @return 项目对象
...
...
src/main/java/com/zhiwei/brandkbs2/service/HighWordService.java
View file @
9859622c
package
com
.
zhiwei
.
brandkbs2
.
service
;
import
com.alibaba.fastjson.JSONObject
;
import
com.zhiwei.brandkbs2.easyexcel.dto.ExportHighWordDTO
;
import
com.zhiwei.brandkbs2.pojo.vo.PageVO
;
import
java.util.List
;
/**
* @ClassName: HighWordService
* @Description 高频词服务接口
* @author: sjj
* @date: 2022-06-06 09:59
*/
public
interface
HighWordService
{
/**
* 分页查询高频词列表
*
* @param page 页码
* @param size 页码大小
* @param keyword 关键词
* @return PageVO<JSONObject>
*/
PageVO
<
JSONObject
>
findHighWord
(
int
page
,
int
size
,
String
keyword
);
/**
* 添加高频关键词
*
* @param highWords 高频词
*/
void
addHighWordList
(
List
<
String
>
highWords
);
/**
* 删除高频关键词
*
* @param id 高频词id
*/
void
deleteHighWord
(
String
id
);
/**
* 下载高频关键词
*
* @return List<ExportHighWordDTO>
*/
List
<
ExportHighWordDTO
>
downloadHighWord
();
public
interface
HighWordService
extends
TableWordService
{
}
\ No newline at end of file
src/main/java/com/zhiwei/brandkbs2/service/HighlightWordService.java
0 → 100644
View file @
9859622c
package
com
.
zhiwei
.
brandkbs2
.
service
;
/**
* @ClassName: HighlightWordService
* @Description HighlightWordService
* @author: sjj
* @date: 2023-05-25 15:10
*/
public
interface
HighlightWordService
extends
TableWordService
{
}
src/main/java/com/zhiwei/brandkbs2/service/ProjectService.java
View file @
9859622c
...
...
@@ -133,4 +133,12 @@ public interface ProjectService {
* @return
*/
ResponseResult
getHitTagsByLinkedGroupId
(
String
linkedGroupId
);
/**
*
* @param projectId 项目id
* @return 高亮关键词
*/
List
<
String
>
getHighlightKeyword
(
String
projectId
);
}
src/main/java/com/zhiwei/brandkbs2/service/TableWordService.java
0 → 100644
View file @
9859622c
package
com
.
zhiwei
.
brandkbs2
.
service
;
import
com.alibaba.fastjson.JSONObject
;
import
com.zhiwei.brandkbs2.easyexcel.dto.ExportWordDTO
;
import
com.zhiwei.brandkbs2.model.ResponseResult
;
import
com.zhiwei.brandkbs2.pojo.vo.PageVO
;
import
java.util.List
;
/**
* @ClassName: TableWordService
* @Description TableWordService
* @author: sjj
* @date: 2023-05-25 14:13
*/
public
interface
TableWordService
{
/**
* 分页查询词组列表
*
* @param page 页码
* @param size 页码大小
* @param keyword 关键词
* @return PageVO<JSONObject>
*/
PageVO
<
JSONObject
>
findWord
(
int
page
,
int
size
,
String
keyword
);
/**
* 添加词组
*
* @param words 词组
*/
ResponseResult
addWordList
(
List
<
String
>
words
,
String
projectId
,
String
submitter
);
/**
* 删除词组
*
* @param id 词组id
*/
void
deleteWord
(
String
id
);
/**
* 导出词组
*
* @return List<ExportWordDTO>
*/
List
<
ExportWordDTO
>
downloadWord
(
String
projectId
);
}
src/main/java/com/zhiwei/brandkbs2/service/impl/HighWordServiceImpl.java
View file @
9859622c
package
com
.
zhiwei
.
brandkbs2
.
service
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.zhiwei.brandkbs2.auth.UserThreadLocal
;
import
com.zhiwei.brandkbs2.dao.HighWordDao
;
import
com.zhiwei.brandkbs2.easyexcel.dto.ExportHighWordDTO
;
import
com.zhiwei.brandkbs2.pojo.HighWord
;
import
com.zhiwei.brandkbs2.pojo.vo.PageVO
;
import
com.zhiwei.brandkbs2.service.HighWordService
;
import
com.zhiwei.brandkbs2.util.MongoUtil
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* @ClassName: HighWordServiceImpl
* @Description 高频词服务接口实现类
...
...
@@ -23,49 +13,9 @@ import java.util.stream.Collectors;
* @date: 2022-06-06 10:02
*/
@Service
(
"highWordServiceImpl"
)
public
class
HighWordServiceImpl
implements
HighWordService
{
@Resource
(
name
=
"highWordDao"
)
HighWordDao
highWordDao
;
@Resource
(
name
=
"mongoUtil"
)
private
com
.
zhiwei
.
brandkbs2
.
util
.
MongoUtil
mongoUtil
;
@Override
public
PageVO
<
JSONObject
>
findHighWord
(
int
page
,
int
size
,
String
keyword
)
{
String
projectId
=
UserThreadLocal
.
getProjectId
();
Query
query
=
Query
.
query
(
Criteria
.
where
(
"projectId"
).
is
(
projectId
));
long
count
=
highWordDao
.
count
(
query
);
mongoUtil
.
start
(
page
,
size
,
query
);
List
<
HighWord
>
highWordList
=
highWordDao
.
findListByKeywordFuzz
(
query
,
keyword
,
new
String
[]{
"keyword"
});
List
<
JSONObject
>
resList
=
highWordList
.
stream
().
map
(
highWord
->
{
JSONObject
result
=
new
JSONObject
();
result
.
put
(
"id"
,
highWord
.
getId
());
result
.
put
(
"keyword"
,
highWord
.
getKeyword
());
result
.
put
(
"cTime"
,
highWord
.
getCTime
());
result
.
put
(
"submitter"
,
highWord
.
getSubmitter
());
return
result
;
}).
collect
(
Collectors
.
toList
());
MongoUtil
.
PageHelper
<
JSONObject
>
pageHelper
=
mongoUtil
.
pageHelper
(
count
,
resList
);
return
PageVO
.
createPageVo
(
pageHelper
,
resList
);
}
public
class
HighWordServiceImpl
extends
TableWordServiceImpl
implements
HighWordService
{
@Override
public
void
addHighWordList
(
List
<
String
>
highWords
)
{
List
<
String
>
existList
=
highWordDao
.
findList
(
null
).
stream
().
map
(
HighWord:
:
getKeyword
).
collect
(
Collectors
.
toList
());
// 去除重复数据
List
<
String
>
newList
=
highWords
.
stream
().
filter
(
word
->
!
existList
.
contains
(
word
)).
collect
(
Collectors
.
toList
());
highWordDao
.
insertMany
(
HighWord
.
createFromList
(
newList
,
UserThreadLocal
.
getProjectId
(),
UserThreadLocal
.
getNickname
()));
public
HighWordServiceImpl
(
@Qualifier
(
"highWordDao"
)
HighWordDao
highWordDao
,
@Qualifier
(
"mongoUtil"
)
MongoUtil
mongoUtil
)
{
super
(
highWordDao
,
mongoUtil
);
}
@Override
public
void
deleteHighWord
(
String
id
)
{
highWordDao
.
deleteOneById
(
id
);
}
@Override
public
List
<
ExportHighWordDTO
>
downloadHighWord
()
{
return
highWordDao
.
findList
(
null
).
stream
().
map
(
ExportHighWordDTO:
:
createFromHighWord
).
collect
(
Collectors
.
toList
());
}
}
src/main/java/com/zhiwei/brandkbs2/service/impl/HighlightWordServiceImpl.java
0 → 100644
View file @
9859622c
package
com
.
zhiwei
.
brandkbs2
.
service
.
impl
;
import
com.zhiwei.brandkbs2.dao.HighlightWordDao
;
import
com.zhiwei.brandkbs2.service.HighlightWordService
;
import
com.zhiwei.brandkbs2.util.MongoUtil
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.stereotype.Service
;
/**
* @ClassName: HighlightWordServiceImpl
* @Description HighlightWordServiceImpl
* @author: sjj
* @date: 2023-05-25 15:11
*/
@Service
(
"highlightWordServiceImpl"
)
public
class
HighlightWordServiceImpl
extends
TableWordServiceImpl
implements
HighlightWordService
{
public
HighlightWordServiceImpl
(
@Qualifier
(
"highlightWordDao"
)
HighlightWordDao
highlightWordDao
,
@Qualifier
(
"mongoUtil"
)
MongoUtil
mongoUtil
)
{
super
(
highlightWordDao
,
mongoUtil
);
}
}
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkDataServiceImpl.java
View file @
9859622c
...
...
@@ -15,6 +15,7 @@ import com.zhiwei.brandkbs2.common.RedisKeyPrefix;
import
com.zhiwei.brandkbs2.config.Constant
;
import
com.zhiwei.brandkbs2.dao.AggreeResultDao
;
import
com.zhiwei.brandkbs2.dao.ChannelDao
;
import
com.zhiwei.brandkbs2.dao.HighlightWordDao
;
import
com.zhiwei.brandkbs2.enmus.ChannelEmotion
;
import
com.zhiwei.brandkbs2.enmus.EmotionEnum
;
import
com.zhiwei.brandkbs2.enmus.ImportantChannelEnum
;
...
...
@@ -149,6 +150,9 @@ public class MarkDataServiceImpl implements MarkDataService {
@Resource
(
name
=
"esSearchServiceImpl"
)
EsSearchService
esSearchService
;
@Resource
(
name
=
"highlightWordDao"
)
HighlightWordDao
highlightWordDao
;
@Override
public
PageVO
<
MarkFlowEntity
>
getOriginList
(
MarkSearchDTO
markSearchDTO
)
{
try
{
...
...
@@ -168,7 +172,7 @@ public class MarkDataServiceImpl implements MarkDataService {
// 返回分页结果并设置平台count
return
PageVO
.
createPageVo
(
total
,
markSearchDTO
.
getPage
(),
markSearchDTO
.
getPageSize
(),
flowEntityList
)
// 各平台计量
.
setInfo
(
new
JSONObject
(
ImmutableMap
.
of
(
"
platformCount"
,
hitsAndCounts
.
getRight
(
))));
.
setInfo
(
new
JSONObject
(
ImmutableMap
.
of
(
"
highlightWord"
,
highlightWordDao
.
findList
(
Query
.
query
(
Criteria
.
where
(
"projectId"
).
is
(
UserThreadLocal
.
getProjectId
()))).
stream
().
map
(
HighlightWord:
:
getKeyword
).
collect
(
Collectors
.
toList
()
))));
}
catch
(
IOException
e
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"es查询异常"
);
}
...
...
@@ -247,10 +251,10 @@ public class MarkDataServiceImpl implements MarkDataService {
long
total
=
hitsAndCounts
.
getLeft
()[
0
].
getTotalHits
().
value
;
// 消息列表
List
<
MarkFlowEntity
>
flowEntityList
=
getMarkFlowEntity
(
markSearchDTO
,
hitsAndCounts
.
getLeft
()[
0
]);
// 返回分页结果并
设置平台count
// 返回分页结果并
返回高亮关键词
return
PageVO
.
createPageVo
(
total
,
markSearchDTO
.
getPage
(),
markSearchDTO
.
getPageSize
(),
flowEntityList
)
//
各平台计量
.
setInfo
(
new
JSONObject
(
ImmutableMap
.
of
(
"
platformCount"
,
hitsAndCounts
.
getRight
(
))));
//
高亮关键词
.
setInfo
(
new
JSONObject
(
ImmutableMap
.
of
(
"
highlightWord"
,
GlobalPojo
.
HIGHLIGHT_MAP
.
get
(
UserThreadLocal
.
getProjectId
()
))));
}
catch
(
IOException
e
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"es查询异常"
);
}
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkFlowServiceImpl.java
View file @
9859622c
...
...
@@ -10,6 +10,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.HighlightWordDao
;
import
com.zhiwei.brandkbs2.enmus.ChannelEmotion
;
import
com.zhiwei.brandkbs2.exception.ExceptionCast
;
import
com.zhiwei.brandkbs2.model.CommonCodeEnum
;
...
...
@@ -17,6 +18,7 @@ import com.zhiwei.brandkbs2.pojo.MarkFlowEntity;
import
com.zhiwei.brandkbs2.service.MarkFlowService
;
import
com.zhiwei.brandkbs2.util.RedisUtil
;
import
com.zhiwei.brandkbs2.util.Tools
;
import
com.zhiwei.middleware.automaticmark.vo.Keyword
;
import
com.zhiwei.middleware.cleaner.filter.UnifiedFilterClient
;
import
com.zhiwei.middleware.mark.service.MarkerClient
;
import
com.zhiwei.middleware.mark.vo.QueryResult
;
...
...
@@ -57,9 +59,11 @@ public class MarkFlowServiceImpl implements MarkFlowService {
@Resource
(
name
=
"filterClient"
)
UnifiedFilterClient
filterClient
;
@Resource
(
name
=
"highlightWordDao"
)
HighlightWordDao
highlightWordDao
;
@Override
public
JSONObject
createMarkFlowInfo
(
MarkInfoSource
markInfoSource
)
{
JSONObject
resultInfo
=
createInfoWithEmotion
(
markInfoSource
.
getJson
());
resultInfo
.
put
(
"sourceDetails"
,
getSourceDetails
(
markInfoSource
));
return
resultInfo
;
...
...
@@ -70,7 +74,7 @@ public class MarkFlowServiceImpl implements MarkFlowService {
JSONObject
json
=
markInfoSource
.
getJson
();
String
linkedGroupId
=
markInfoSource
.
getLinkedGroupId
();
JSONObject
resultInfo
=
createInfoWithEmotion
(
json
);
resultInfo
.
put
(
"sourceDetails"
,
getSourceDetails4Origin
(
json
,
linkedGroupId
));
resultInfo
.
put
(
"sourceDetails"
,
getSourceDetails4Origin
(
json
,
UserThreadLocal
.
getProjectId
(),
linkedGroupId
));
String
zip
=
Tools
.
gzip
(
JSON
.
toJSONString
(
json
));
resultInfo
.
put
(
"zip"
,
zip
);
return
resultInfo
;
...
...
@@ -229,10 +233,11 @@ public class MarkFlowServiceImpl implements MarkFlowService {
// 保留两位小数
sourceDetails
.
put
(
"channelInfluence"
,
new
BigDecimal
(
channelValue
).
setScale
(
2
,
RoundingMode
.
UP
));
}
sourceDetails
.
put
(
"highlightWordMap"
,
getHighlightWordMap
(
markInfoSource
.
getProjectId
(),
tJson
));
return
sourceDetails
;
}
private
JSONObject
getSourceDetails4Origin
(
JSONObject
tJson
,
String
linkedGroupId
)
{
private
JSONObject
getSourceDetails4Origin
(
JSONObject
tJson
,
String
projectId
,
String
linkedGroupId
)
{
JSONObject
sourceDetails
=
new
JSONObject
();
String
source
=
tJson
.
getString
(
GenericAttribute
.
ES_SOURCE
);
// 是否原创
...
...
@@ -251,9 +256,36 @@ public class MarkFlowServiceImpl implements MarkFlowService {
if
(
followersNum
>
0
)
{
sourceDetails
.
put
(
"followersNum"
,
followersNum
);
}
sourceDetails
.
put
(
"highlightWordMap"
,
getHighlightWordMap
(
projectId
,
tJson
));
return
sourceDetails
;
}
private
Map
<
String
,
Integer
>
getHighlightWordMap
(
String
projectId
,
JSONObject
json
)
{
List
<
Keyword
>
hitKeywords
=
GlobalPojo
.
PROJECT_GRAPHS
.
get
(
projectId
).
find
(
json
.
getString
(
GenericAttribute
.
ES_IND_FULL_TEXT
));
List
<
String
>
preWords
=
GlobalPojo
.
HIGHLIGHT_MAP
.
get
(
projectId
);
if
(
null
!=
preWords
&&
!
hitKeywords
.
isEmpty
())
{
Map
<
String
,
Integer
>
resMap
=
new
HashMap
<>();
Map
<
String
,
Integer
>
hitMap
=
new
HashMap
<>();
hitKeywords
.
forEach
(
keyword
->
hitMap
.
compute
(
keyword
.
getKey
(),
(
k
,
v
)
->
null
==
v
?
1
:
++
v
));
outer:
for
(
String
preWord
:
preWords
)
{
Integer
count
=
null
;
String
[]
split
=
preWord
.
trim
().
split
(
" +"
);
for
(
String
s
:
split
)
{
Integer
rate
=
hitMap
.
get
(
s
);
// 未命中词语
if
(
null
==
rate
)
{
continue
outer
;
}
count
=
count
==
null
?
rate
:
Math
.
min
(
count
,
rate
);
}
resMap
.
put
(
preWord
,
count
);
}
return
Tools
.
sortMap
(
resMap
,
null
);
}
return
null
;
}
/**
* 按c4、origin获取ClientFrom
*
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/ProjectServiceImpl.java
View file @
9859622c
...
...
@@ -427,6 +427,12 @@ public class ProjectServiceImpl implements ProjectService {
}
}
@Override
public
List
<
String
>
getHighlightKeyword
(
String
projectId
)
{
Project
project
=
projectDao
.
findOneById
(
projectId
);
return
Objects
.
requireNonNull
(
project
).
getHighlightKeyword
();
}
/**
* 获取舆情对应项目的情感标签
* @param brandName
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/TableWordServiceImpl.java
0 → 100644
View file @
9859622c
package
com
.
zhiwei
.
brandkbs2
.
service
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.zhiwei.brandkbs2.auth.UserThreadLocal
;
import
com.zhiwei.brandkbs2.dao.BaseMongoDao
;
import
com.zhiwei.brandkbs2.easyexcel.dto.ExportWordDTO
;
import
com.zhiwei.brandkbs2.model.ResponseResult
;
import
com.zhiwei.brandkbs2.pojo.AbstractBaseWord
;
import
com.zhiwei.brandkbs2.pojo.HighWord
;
import
com.zhiwei.brandkbs2.pojo.vo.PageVO
;
import
com.zhiwei.brandkbs2.service.TableWordService
;
import
com.zhiwei.brandkbs2.util.MongoUtil
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* @ClassName: TableWordServiceImpl
* @Description TableWordServiceImpl
* @author: sjj
* @date: 2023-05-25 14:35
*/
public
class
TableWordServiceImpl
implements
TableWordService
{
final
BaseMongoDao
<?
extends
AbstractBaseWord
>
baseMongoDao
;
final
MongoUtil
mongoUtil
;
public
TableWordServiceImpl
(
BaseMongoDao
<?
extends
AbstractBaseWord
>
baseMongoDao
,
MongoUtil
mongoUtil
)
{
this
.
baseMongoDao
=
baseMongoDao
;
this
.
mongoUtil
=
mongoUtil
;
}
@Override
public
PageVO
<
JSONObject
>
findWord
(
int
page
,
int
size
,
String
keyword
)
{
String
projectId
=
UserThreadLocal
.
getProjectId
();
Query
query
=
Query
.
query
(
Criteria
.
where
(
"projectId"
).
is
(
projectId
));
long
count
=
baseMongoDao
.
count
(
query
);
mongoUtil
.
start
(
page
,
size
,
query
);
List
<?
extends
AbstractBaseWord
>
highWordList
=
baseMongoDao
.
findListByKeywordFuzz
(
query
,
keyword
,
new
String
[]{
"keyword"
});
List
<
JSONObject
>
resList
=
highWordList
.
stream
().
map
(
highWord
->
{
JSONObject
result
=
new
JSONObject
();
result
.
put
(
"id"
,
highWord
.
getId
());
result
.
put
(
"keyword"
,
highWord
.
getKeyword
());
result
.
put
(
"cTime"
,
highWord
.
getCTime
());
result
.
put
(
"submitter"
,
highWord
.
getSubmitter
());
return
result
;
}).
collect
(
Collectors
.
toList
());
MongoUtil
.
PageHelper
<
JSONObject
>
pageHelper
=
mongoUtil
.
pageHelper
(
count
,
resList
);
return
PageVO
.
createPageVo
(
pageHelper
,
resList
);
}
@Override
public
ResponseResult
addWordList
(
List
<
String
>
words
,
String
projectId
,
String
submitter
)
{
List
<
String
>
existList
=
baseMongoDao
.
findList
(
Query
.
query
(
Criteria
.
where
(
"projectId"
).
is
(
projectId
))).
stream
().
map
(
AbstractBaseWord:
:
getKeyword
).
collect
(
Collectors
.
toList
());
// 去除重复数据
List
<
String
>
newList
=
words
.
stream
().
filter
(
word
->
!
existList
.
contains
(
word
)).
collect
(
Collectors
.
toList
());
// 关键词100上限
if
(
newList
.
size
()
+
existList
.
size
()
>
100
)
{
return
ResponseResult
.
failure
(
"关键词添加超过上限值100"
);
}
baseMongoDao
.
insertMany
(
HighWord
.
createFromList
(
newList
,
projectId
,
submitter
));
return
ResponseResult
.
success
();
}
@Override
public
void
deleteWord
(
String
id
)
{
baseMongoDao
.
deleteOneById
(
id
);
}
@Override
public
List
<
ExportWordDTO
>
downloadWord
(
String
projectId
)
{
return
baseMongoDao
.
findList
(
Query
.
query
(
Criteria
.
where
(
"projectId"
).
is
(
projectId
))).
stream
().
map
(
ExportWordDTO:
:
createFromWord
).
collect
(
Collectors
.
toList
());
}
}
src/main/java/com/zhiwei/brandkbs2/service/impl/UserServiceImpl.java
View file @
9859622c
...
...
@@ -171,11 +171,12 @@ public class UserServiceImpl implements UserService {
newUser
.
setNickname
(
userDTO
.
getNickname
());
newUser
.
setRoles
(
Collections
.
singletonList
(
UserRole
.
createFromUserDto
(
userDTO
)));
newUser
.
setSuperAdmin
(
false
);
userDao
.
insertOne
(
newUser
);
userCenterService
.
addProduct
(
newUser
.
getId
());
}
else
{
newUser
=
User
.
createFromUserDTO
(
userDTO
,
nickname
);
}
userDao
.
insertOne
(
newUser
);
userCenterService
.
addProduct
(
newUser
.
getId
());
}
return
ResponseResult
.
success
();
}
List
<
UserRole
>
roles
=
user
.
getRoles
();
...
...
src/main/resources/application-dev.properties
View file @
9859622c
...
...
@@ -99,7 +99,7 @@ whole.searchCriteria.url=https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface
whole.extraParam.url
=
https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface/middleware/search/extra/param
#\u60C5\u62A5\u9884\u8B66\u5916\u90E8\u63A5\u53E3
warn.pushTask.token
=
AoJ0ooy3H2BpHmuaviYObTKw/Xfw/oA5aKccNYhYnoJFJQ/BgeW/
warn.project.url
=
https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/brandkbs/project
?projectId={1}&projectName={2}
warn.project.url
=
https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/brandkbs/project
warn.ticket.url
=
https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/code?pushId={1}&taskType={2}
warn.pushRecipientsList.url
=
https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/pushRecipients/{1}?taskType={2}
warn.deletePushRecipients.url
=
https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/pushRecipients/?pushId={1}&recipientsId={2}&taskType={3}
...
...
src/main/resources/application-local.properties
View file @
9859622c
...
...
@@ -102,7 +102,7 @@ whole.searchCriteria.url=https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface
whole.extraParam.url
=
https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface/middleware/search/extra/param
#\u60C5\u62A5\u9884\u8B66\u5916\u90E8\u63A5\u53E3
warn.pushTask.token
=
AoJ0ooy3H2BpHmuaviYObTKw/Xfw/oA5aKccNYhYnoJFJQ/BgeW/
warn.project.url
=
http://192.168.0.225:11003/qbjc/brandkbsPush/interface/brandkbs/project
?projectId={1}&projectName={2}
warn.project.url
=
http://192.168.0.225:11003/qbjc/brandkbsPush/interface/brandkbs/project
warn.ticket.url
=
http://192.168.0.225:11003/qbjc/brandkbsPush/interface/code?pushId={1}&taskType={2}
warn.pushRecipientsList.url
=
http://192.168.0.225:11003/qbjc/brandkbsPush/interface/pushRecipients/{1}?taskType={2}
warn.deletePushRecipients.url
=
http://192.168.0.225:11003/qbjc/brandkbsPush/interface/pushRecipients/?pushId={1}&recipientsId={2}&taskType={3}
...
...
src/main/resources/application-prod.properties
View file @
9859622c
...
...
@@ -99,7 +99,7 @@ whole.searchCriteria.url=https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface
whole.extraParam.url
=
https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface/middleware/search/extra/param
#\u60C5\u62A5\u9884\u8B66\u5916\u90E8\u63A5\u53E3
warn.pushTask.token
=
AoJ0ooy3H2BpHmuaviYObTKw/Xfw/oA5aKccNYhYnoJFJQ/BgeW/
warn.project.url
=
https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/brandkbs/project
?projectId={1}&projectName={2}
warn.project.url
=
https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/brandkbs/project
warn.ticket.url
=
https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/code?pushId={1}&taskType={2}
warn.pushRecipientsList.url
=
https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/pushRecipients/{1}?taskType={2}
warn.deletePushRecipients.url
=
https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/pushRecipients/?pushId={1}&recipientsId={2}&taskType={3}
...
...
src/test/java/com/zhiwei/brandkbs2/HighWordServiceTest.java
View file @
9859622c
package
com
.
zhiwei
.
brandkbs2
;
import
com.alibaba.fastjson.JSONObject
;
import
com.zhiwei.brandkbs2.easyexcel.dto.ExportHighWordDTO
;
import
com.zhiwei.brandkbs2.config.Constant
;
import
com.zhiwei.brandkbs2.easyexcel.dto.ExportWordDTO
;
import
com.zhiwei.brandkbs2.pojo.vo.PageVO
;
import
com.zhiwei.brandkbs2.service.HighWordService
;
import
org.junit.Test
;
import
org.junit.jupiter.api.Tags
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
...
...
@@ -21,7 +21,7 @@ public class HighWordServiceTest {
@Test
public
void
findHighWordTest
(){
PageVO
<
JSONObject
>
ls
=
highWordService
.
find
High
Word
(
1
,
10
,
"里"
);
PageVO
<
JSONObject
>
ls
=
highWordService
.
findWord
(
1
,
10
,
"里"
);
for
(
JSONObject
jsonObject
:
ls
.
getList
())
{
System
.
out
.
println
(
jsonObject
);
}
...
...
@@ -29,8 +29,8 @@ public class HighWordServiceTest {
@Test
public
void
downloadHighWordTest
(){
List
<
Export
HighWordDTO
>
exportHighWordDTOS
=
highWordService
.
downloadHighWord
(
);
for
(
Export
High
WordDTO
exportHighWordDTO
:
exportHighWordDTOS
)
{
List
<
Export
WordDTO
>
exportHighWordDTOS
=
highWordService
.
downloadWord
(
Constant
.
DEFAULT_PROJECT_ID
);
for
(
ExportWordDTO
exportHighWordDTO
:
exportHighWordDTOS
)
{
System
.
out
.
println
(
exportHighWordDTO
);
}
}
...
...
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