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
a17d6c42
Commit
a17d6c42
authored
Sep 15, 2022
by
shenjunjie
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature' into 'dev'
Feature See merge request
!37
parents
15932139
79a94238
Hide whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
393 additions
and
190 deletions
+393
-190
src/main/java/com/zhiwei/brandkbs2/common/GlobalPojo.java
+5
-1
src/main/java/com/zhiwei/brandkbs2/controller/CommonController.java
+5
-3
src/main/java/com/zhiwei/brandkbs2/controller/admin/ArticleController.java
+16
-12
src/main/java/com/zhiwei/brandkbs2/controller/admin/ChannelController.java
+8
-7
src/main/java/com/zhiwei/brandkbs2/controller/admin/EventController.java
+22
-16
src/main/java/com/zhiwei/brandkbs2/enmus/response/LoginCodeEnum.java
+93
-0
src/main/java/com/zhiwei/brandkbs2/exception/CustomException.java
+5
-1
src/main/java/com/zhiwei/brandkbs2/exception/ExceptionCast.java
+6
-2
src/main/java/com/zhiwei/brandkbs2/model/CommonCodeEnum.java
+1
-6
src/main/java/com/zhiwei/brandkbs2/model/EventCodeEnum.java
+70
-0
src/main/java/com/zhiwei/brandkbs2/model/ResponseResult.java
+2
-2
src/main/java/com/zhiwei/brandkbs2/pojo/EventDisseminationTrend.java
+2
-2
src/main/java/com/zhiwei/brandkbs2/pojo/vo/YqEventSearchVO.java
+0
-3
src/main/java/com/zhiwei/brandkbs2/service/ChannelService.java
+3
-3
src/main/java/com/zhiwei/brandkbs2/service/EventService.java
+6
-7
src/main/java/com/zhiwei/brandkbs2/service/impl/ChannelServiceImpl.java
+19
-19
src/main/java/com/zhiwei/brandkbs2/service/impl/CommonServiceImpl.java
+20
-5
src/main/java/com/zhiwei/brandkbs2/service/impl/CustomEventServiceImpl.java
+8
-8
src/main/java/com/zhiwei/brandkbs2/service/impl/EventServiceImpl.java
+25
-20
src/main/java/com/zhiwei/brandkbs2/service/impl/IndexServiceImpl.java
+19
-9
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkDataServiceImpl.java
+29
-29
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkFlowServiceImpl.java
+1
-1
src/main/java/com/zhiwei/brandkbs2/service/impl/ProjectServiceImpl.java
+2
-2
src/main/java/com/zhiwei/brandkbs2/service/impl/ReportServiceImpl.java
+16
-23
src/main/java/com/zhiwei/brandkbs2/service/impl/UserServiceImpl.java
+9
-8
src/main/resources/application-local.properties
+1
-1
No files found.
src/main/java/com/zhiwei/brandkbs2/common/GlobalPojo.java
View file @
a17d6c42
...
...
@@ -106,7 +106,11 @@ public class GlobalPojo {
}
public
static
String
getMediaType
(
String
projectId
,
String
platform
,
String
source
)
{
return
MEDIA_TYPE
.
get
(
projectId
).
get
(
platform
+
source
);
Map
<
String
,
String
>
projectMap
=
MEDIA_TYPE
.
get
(
projectId
);
if
(
null
==
projectMap
)
{
return
null
;
}
return
projectMap
.
get
(
platform
+
source
);
}
}
src/main/java/com/zhiwei/brandkbs2/controller/CommonController.java
View file @
a17d6c42
package
com
.
zhiwei
.
brandkbs2
.
controller
;
import
com.zhiwei.brandkbs2.auth.Auth
;
import
com.zhiwei.brandkbs2.auth.UserThreadLocal
;
import
com.zhiwei.brandkbs2.enmus.RoleEnum
;
import
com.zhiwei.brandkbs2.model.ResponseResult
;
import
com.zhiwei.brandkbs2.service.CommonService
;
...
...
@@ -39,10 +40,11 @@ public class CommonController extends BaseController {
ProjectService
projectService
;
@ApiOperation
(
"获取情感倾向标签信息"
)
@ApiImplicitParam
(
name
=
"
linkedGroupId"
,
value
=
"关联项目ID
"
,
required
=
true
,
paramType
=
"path"
,
dataType
=
"string"
)
@GetMapping
(
"/get/tag/emotion/{
linkedGroup
Id}"
)
public
ResponseResult
getTagsWithEmotion
(
@PathVariable
(
value
=
"
linkedGroupId"
)
String
linkedGroup
Id
)
{
@ApiImplicitParam
(
name
=
"
contendId"
,
value
=
"品牌id
"
,
required
=
true
,
paramType
=
"path"
,
dataType
=
"string"
)
@GetMapping
(
"/get/tag/emotion/{
contend
Id}"
)
public
ResponseResult
getTagsWithEmotion
(
@PathVariable
(
value
=
"
contendId"
)
String
contend
Id
)
{
List
<
String
>
res
=
new
ArrayList
<>();
String
linkedGroupId
=
projectService
.
getProjectByContendId
(
UserThreadLocal
.
getProjectId
(),
contendId
).
getBrandLinkedGroupId
();
List
<
MarkerTag
>
tags
=
commonService
.
getQbjcTags
(
linkedGroupId
,
TagField
.
GROUP_NAME
.
is
(
"情感倾向"
));
if
(
null
!=
tags
)
{
res
=
tags
.
stream
().
map
(
MarkerTag:
:
getName
).
collect
(
Collectors
.
toList
());
...
...
src/main/java/com/zhiwei/brandkbs2/controller/admin/ArticleController.java
View file @
a17d6c42
...
...
@@ -6,6 +6,7 @@ import com.zhiwei.brandkbs2.auth.UserThreadLocal;
import
com.zhiwei.brandkbs2.controller.BaseController
;
import
com.zhiwei.brandkbs2.enmus.RoleEnum
;
import
com.zhiwei.brandkbs2.model.ResponseResult
;
import
com.zhiwei.brandkbs2.pojo.AbstractProject
;
import
com.zhiwei.brandkbs2.pojo.Behavior
;
import
com.zhiwei.brandkbs2.service.BehaviorService
;
import
com.zhiwei.brandkbs2.service.ProjectService
;
...
...
@@ -63,15 +64,16 @@ public class ArticleController extends BaseController {
private
static
final
Behavior
.
Operation
OPERATION
=
new
Behavior
.
Operation
(
"稿件上传"
,
true
);
@ApiOperation
(
"稿件上传-稿件模板下载"
)
@ApiImplicitParams
(
@ApiImplicitParam
(
name
=
"
linkedGroupId"
,
value
=
"绑定项目组名"
,
required
=
true
,
paramType
=
"query"
,
dataType
=
"string"
))
@ApiImplicitParams
(
@ApiImplicitParam
(
name
=
"
contendId"
,
value
=
"品牌id"
,
paramType
=
"query"
,
dataType
=
"string"
))
@GetMapping
(
"/upload/template/form"
)
public
ResponseResult
downloadTemplateForm
(
@RequestParam
String
linkedGroup
Id
)
{
public
ResponseResult
downloadTemplateForm
(
@RequestParam
(
defaultValue
=
"0"
)
String
contend
Id
)
{
try
{
String
group
=
projectService
.
getProjectByLinkedGroupId
(
linkedGroupId
).
getBrandLinkedGroup
(
);
AbstractProject
project
=
projectService
.
getProjectByContendId
(
UserThreadLocal
.
getProjectId
(),
contendId
);
HttpEntity
<
String
>
requestEntity
=
new
HttpEntity
<>(
getHeaders
());
HttpEntity
<
Resource
>
entity
=
restTemplate
.
exchange
(
yuqingInterface
+
"/upload/template/form?project="
+
group
,
HttpMethod
.
GET
,
requestEntity
,
Resource
.
class
);
HttpEntity
<
Resource
>
entity
=
restTemplate
.
exchange
(
yuqingInterface
+
"/upload/template/form?projectId="
+
project
.
getBrandLinkedGroupId
(),
HttpMethod
.
GET
,
requestEntity
,
Resource
.
class
);
if
(
null
!=
entity
.
getBody
())
{
Tools
.
download
(
entity
.
getBody
().
getInputStream
(),
response
.
getOutputStream
(),
group
+
"_稿件模板"
,
response
);
Tools
.
download
(
entity
.
getBody
().
getInputStream
(),
response
.
getOutputStream
(),
project
.
getBrandName
()
+
"_稿件模板"
,
response
);
}
return
ResponseResult
.
success
();
}
catch
(
Exception
e
)
{
...
...
@@ -125,16 +127,18 @@ public class ArticleController extends BaseController {
@ApiOperation
(
"稿件上传-获取列表"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"page"
,
value
=
"页码"
,
defaultValue
=
"1"
,
paramType
=
"query"
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"pageSize"
,
value
=
"每页记录数"
,
defaultValue
=
"10"
,
paramType
=
"query"
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"
linkedGroupId"
,
value
=
"绑定项目组ID"
,
required
=
true
,
paramType
=
"query"
,
dataType
=
"string"
)})
@ApiImplicitParam
(
name
=
"
contendId"
,
value
=
"品牌id"
,
paramType
=
"query"
,
dataType
=
"string"
)})
@GetMapping
(
"/upload/list"
)
public
ResponseResult
getList
(
@RequestParam
(
value
=
"linkedGroupId"
)
String
linkedGroupId
,
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
int
page
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"10"
)
int
pageSize
)
{
public
ResponseResult
getList
(
@RequestParam
(
value
=
"contendId"
,
defaultValue
=
"0"
)
String
contendId
,
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
int
page
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"10"
)
int
pageSize
)
{
try
{
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"page"
,
page
);
params
.
put
(
"pageSize"
,
pageSize
);
params
.
put
(
"project
"
,
projectService
.
getProjectByLinkedGroupId
(
linkedGroupId
).
getBrandLinkedGroup
());
params
.
put
(
"project
Id"
,
projectService
.
getProjectByContendId
(
UserThreadLocal
.
getProjectId
(),
contendId
).
getBrandLinkedGroupId
());
HttpEntity
<
JSONObject
>
requestEntity
=
new
HttpEntity
<>(
getHeaders
());
HttpEntity
<
JSONObject
>
entity
=
restTemplate
.
exchange
(
yuqingInterface
+
"/upload/list?page={page}&pageSize={pageSize}&project={project}"
,
HttpMethod
.
GET
,
requestEntity
,
JSONObject
.
class
,
params
);
HttpEntity
<
JSONObject
>
entity
=
restTemplate
.
exchange
(
yuqingInterface
+
"/upload/list?page={page}&pageSize={pageSize}&projectId={projectId}"
,
HttpMethod
.
GET
,
requestEntity
,
JSONObject
.
class
,
params
);
return
ResponseResult
.
convertFromYuQingInterface
(
entity
.
getBody
(),
pageSize
);
}
catch
(
Exception
e
)
{
log
.
error
(
"稿件上传-获取列表异常"
,
e
);
...
...
@@ -158,9 +162,9 @@ public class ArticleController extends BaseController {
@ApiOperation
(
"稿件上传-上传表格"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"file"
,
value
=
"上传表格"
,
required
=
true
,
paramType
=
"form"
,
dataType
=
"multipartFile"
),
@ApiImplicitParam
(
name
=
"
linkedGroupId"
,
value
=
"绑定项目组ID"
,
required
=
true
,
paramType
=
"form"
,
dataType
=
"string"
)})
@ApiImplicitParam
(
name
=
"
contendId"
,
value
=
"品牌id"
,
paramType
=
"form"
,
dataType
=
"string"
)})
@PostMapping
(
value
=
"/upload/form"
,
headers
=
"content-type=multipart/form-data"
)
public
ResponseResult
uploadForm
(
@RequestParam
(
"file"
)
MultipartFile
file
,
@RequestParam
String
linkedGroup
Id
)
{
public
ResponseResult
uploadForm
(
@RequestParam
(
"file"
)
MultipartFile
file
,
@RequestParam
(
defaultValue
=
"0"
)
String
contend
Id
)
{
try
{
MultiValueMap
<
String
,
Object
>
requestMap
=
new
LinkedMultiValueMap
<>(
1
);
ByteArrayResource
byteArrayResource
=
new
ByteArrayResource
(
file
.
getBytes
())
{
...
...
@@ -171,7 +175,7 @@ public class ArticleController extends BaseController {
};
requestMap
.
add
(
"file"
,
byteArrayResource
);
requestMap
.
add
(
"nickName"
,
UserThreadLocal
.
getNickname
());
requestMap
.
add
(
"project
"
,
projectService
.
getProjectByLinkedGroupId
(
linkedGroupId
).
getBrandLinkedGroup
());
requestMap
.
add
(
"project
Id"
,
projectService
.
getProjectByContendId
(
UserThreadLocal
.
getProjectId
(),
contendId
).
getBrandLinkedGroupId
());
HttpEntity
<
MultiValueMap
<
String
,
Object
>>
requestEntity
=
new
HttpEntity
<>(
requestMap
,
getHeadersForm
());
HttpEntity
<
JSONObject
>
entity
=
restTemplate
.
exchange
(
yuqingInterface
+
"/upload/form"
,
HttpMethod
.
POST
,
requestEntity
,
JSONObject
.
class
);
behaviorService
.
pushBehavior
(
OPERATION
,
"上传表格"
,
request
);
...
...
src/main/java/com/zhiwei/brandkbs2/controller/admin/ChannelController.java
View file @
a17d6c42
...
...
@@ -2,6 +2,7 @@ package com.zhiwei.brandkbs2.controller.admin;
import
com.alibaba.fastjson.JSONObject
;
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.ExportAdminChannelArticleDTO
;
...
...
@@ -56,7 +57,7 @@ public class ChannelController extends BaseController {
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"page"
,
value
=
"页码"
,
defaultValue
=
"1"
,
paramType
=
"query"
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"pageSize"
,
value
=
"每页记录数"
,
defaultValue
=
"10"
,
paramType
=
"query"
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"
linkedGroupId"
,
value
=
"关联项目组ID"
,
required
=
tru
e
,
paramType
=
"query"
,
dataType
=
"string"
),
@ApiImplicitParam
(
name
=
"
contendId"
,
value
=
"品牌id"
,
required
=
fals
e
,
paramType
=
"query"
,
dataType
=
"string"
),
@ApiImplicitParam
(
name
=
"emotion"
,
value
=
"倾向筛选"
,
paramType
=
"query"
,
dataType
=
"string"
),
@ApiImplicitParam
(
name
=
"platform"
,
value
=
"平台筛选"
,
paramType
=
"query"
,
dataType
=
"string"
),
@ApiImplicitParam
(
name
=
"show"
,
value
=
"是否展示"
,
paramType
=
"query"
,
dataType
=
"Boolean"
),
...
...
@@ -66,13 +67,13 @@ public class ChannelController extends BaseController {
@GetMapping
(
"/list"
)
public
ResponseResult
findChannelList
(
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
int
page
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"10"
)
int
size
,
@RequestParam
(
value
=
"
linkedGroupId"
)
String
linkedGroup
Id
,
@RequestParam
(
value
=
"
contendId"
,
defaultValue
=
"0"
)
String
contend
Id
,
@RequestParam
(
value
=
"emotion"
,
defaultValue
=
""
)
String
emotion
,
@RequestParam
(
value
=
"platform"
,
defaultValue
=
""
)
String
platform
,
@RequestParam
(
value
=
"show"
,
required
=
false
)
Boolean
show
,
@RequestParam
(
value
=
"keyword"
,
defaultValue
=
""
)
String
keyword
,
@RequestParam
(
value
=
"sorter"
,
defaultValue
=
"{\"lastTime\":\"descend\"}"
)
String
sorter
)
{
PageVO
<
JSONObject
>
channelList
=
channelService
.
findChannelList
(
page
,
size
,
linkedGroup
Id
,
emotion
,
platform
,
show
,
keyword
,
sorter
);
PageVO
<
JSONObject
>
channelList
=
channelService
.
findChannelList
(
page
,
size
,
contend
Id
,
emotion
,
platform
,
show
,
keyword
,
sorter
);
return
ResponseResult
.
success
(
channelList
);
}
...
...
@@ -152,20 +153,20 @@ public class ChannelController extends BaseController {
@ApiOperation
(
"下载渠道列表"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"
linkedGroupId"
,
value
=
"关联项目组ID
"
,
required
=
true
,
paramType
=
"query"
,
dataType
=
"string"
),
@ApiImplicitParam
(
name
=
"
contendId"
,
value
=
"品牌id
"
,
required
=
true
,
paramType
=
"query"
,
dataType
=
"string"
),
@ApiImplicitParam
(
name
=
"emotion"
,
value
=
"倾向筛选"
,
paramType
=
"query"
,
dataType
=
"string"
),
@ApiImplicitParam
(
name
=
"platform"
,
value
=
"平台筛选"
,
paramType
=
"query"
,
dataType
=
"string"
),
@ApiImplicitParam
(
name
=
"show"
,
value
=
"是否展示"
,
paramType
=
"query"
,
dataType
=
"boolean"
),
@ApiImplicitParam
(
name
=
"keyword"
,
value
=
"关键字搜索"
,
paramType
=
"query"
,
dataType
=
"string"
)
})
@GetMapping
(
"/list/download"
)
public
ResponseResult
downloadChannelList
(
@RequestParam
(
value
=
"
linkedGroupId"
)
String
linkedGroup
Id
,
public
ResponseResult
downloadChannelList
(
@RequestParam
(
value
=
"
contendId"
,
defaultValue
=
"0"
)
String
contend
Id
,
@RequestParam
(
value
=
"emotion"
,
defaultValue
=
""
)
String
emotion
,
@RequestParam
(
value
=
"platform"
,
defaultValue
=
""
)
String
platform
,
@RequestParam
(
value
=
"show"
,
required
=
false
)
Boolean
show
,
@RequestParam
(
value
=
"keyword"
,
defaultValue
=
""
)
String
keyword
)
{
List
<
ExportChannelDTO
>
downloadChannelList
=
channelService
.
findDownloadChannelList
(
linkedGroup
Id
,
emotion
,
platform
,
show
,
keyword
);
String
brandName
=
projectService
.
getProjectBy
LinkedGroupId
(
linkedGroup
Id
).
getBrandName
();
List
<
ExportChannelDTO
>
downloadChannelList
=
channelService
.
findDownloadChannelList
(
contend
Id
,
emotion
,
platform
,
show
,
keyword
);
String
brandName
=
projectService
.
getProjectBy
ContendId
(
UserThreadLocal
.
getProjectId
(),
contend
Id
).
getBrandName
();
EasyExcelUtil
.
download
(
brandName
+
"_渠道列表数据"
,
brandName
,
ExportChannelDTO
.
class
,
downloadChannelList
,
response
);
return
ResponseResult
.
success
();
}
...
...
src/main/java/com/zhiwei/brandkbs2/controller/admin/EventController.java
View file @
a17d6c42
...
...
@@ -61,10 +61,10 @@ public class EventController extends BaseController {
private
String
brandkbsFilePath
;
@ApiOperation
(
"舆情事件tag筛选"
)
@ApiImplicitParam
(
name
=
"
linkedGroupId"
,
value
=
"关联项目组
id"
,
paramType
=
"query"
,
dataType
=
"string"
)
@ApiImplicitParam
(
name
=
"
contendId"
,
value
=
"品牌
id"
,
paramType
=
"query"
,
dataType
=
"string"
)
@GetMapping
(
"/yq/tag"
)
public
ResponseResult
searchCriteria
(
@RequestParam
(
value
=
"
linkedGroupId"
)
String
linkedGroup
Id
)
{
return
ResponseResult
.
success
(
eventService
.
findEventTagListAll
(
linkedGroup
Id
));
public
ResponseResult
searchCriteria
(
@RequestParam
(
value
=
"
contendId"
,
defaultValue
=
"0"
)
String
contend
Id
)
{
return
ResponseResult
.
success
(
eventService
.
findEventTagListAll
(
contend
Id
));
}
@ApiOperation
(
"分页查询舆情事件列表"
)
...
...
@@ -78,16 +78,16 @@ public class EventController 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"
),
@ApiImplicitParam
(
name
=
"
linkedGroup
Id"
,
value
=
"关联项目组id"
,
paramType
=
"query"
,
dataType
=
"string"
),
@ApiImplicitParam
(
name
=
"
contend
Id"
,
value
=
"关联项目组id"
,
paramType
=
"query"
,
dataType
=
"string"
),
@ApiImplicitParam
(
name
=
"sorter"
,
defaultValue
=
"{\"startTime\":\"descend\"}"
,
value
=
"排序字段"
,
paramType
=
"query"
,
dataType
=
"string"
)
})
@GetMapping
(
"/list"
)
public
ResponseResult
findEventList
(
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
int
page
,
@RequestParam
(
value
=
"size"
,
defaultValue
=
"10"
)
int
size
,
@RequestParam
(
value
=
"
linkedGroupId"
)
String
linkedGroup
Id
,
@RequestParam
(
value
=
"
contendId"
,
defaultValue
=
"0"
)
String
contend
Id
,
@RequestParam
(
value
=
"keyword"
,
defaultValue
=
""
)
String
keyword
,
@RequestParam
(
value
=
"sorter"
,
defaultValue
=
"{\"startTime\":\"descend\"}"
)
String
sorter
)
{
return
ResponseResult
.
success
(
eventService
.
findEventList
(
page
,
size
,
linkedGroup
Id
,
keyword
,
sorter
));
return
ResponseResult
.
success
(
eventService
.
findEventList
(
page
,
size
,
contend
Id
,
keyword
,
sorter
));
}
@ApiOperation
(
"获取单个事件信息"
)
...
...
@@ -199,10 +199,10 @@ public class EventController extends BaseController {
}
@ApiOperation
(
"导出事件列表"
)
@ApiImplicitParam
(
name
=
"
linkedGroupId"
,
value
=
"关联项目组
id"
,
required
=
true
,
paramType
=
"query"
,
dataType
=
"string"
)
@ApiImplicitParam
(
name
=
"
contendId"
,
value
=
"品牌
id"
,
required
=
true
,
paramType
=
"query"
,
dataType
=
"string"
)
@GetMapping
(
"/download"
)
public
ResponseResult
downloadEvents
(
@RequestParam
(
"linkedGroupId"
)
String
linkedGroup
Id
)
{
Pair
<
String
,
List
<
ExportEventDTO
>>
result
=
eventService
.
downloadEvents
(
linkedGroup
Id
);
public
ResponseResult
downloadEvents
(
@RequestParam
(
value
=
"contendId"
,
defaultValue
=
"0"
)
String
contend
Id
)
{
Pair
<
String
,
List
<
ExportEventDTO
>>
result
=
eventService
.
downloadEvents
(
contend
Id
);
String
fileName
=
result
.
getLeft
();
EasyExcelUtil
.
download
(
fileName
+
"_事件列表数据"
,
fileName
,
ExportEventDTO
.
class
,
result
.
getRight
(),
response
);
return
ResponseResult
.
success
();
...
...
@@ -242,7 +242,7 @@ public class EventController extends BaseController {
value
=
"文件路径"
,
required
=
true
,
paramType
=
"form"
,
dataType
=
"string"
)})
@PostMapping
(
value
=
"/upload/file"
,
headers
=
"content-type=multipart/form-data"
)
@Auth
(
role
=
RoleEnum
.
SUPER_ADMIN
)
public
ResponseResult
addEventsByFile
(
@RequestParam
(
value
=
"contendId"
,
defaultValue
=
"0"
)
String
contendId
,
@RequestParam
(
"fileUrl"
)
String
fileUrl
)
{
public
ResponseResult
addEventsByFile
(
@RequestParam
(
value
=
"contendId"
,
defaultValue
=
"0"
)
String
contendId
,
@RequestParam
(
"fileUrl"
)
String
fileUrl
)
{
eventService
.
addFileEvents
(
contendId
,
fileUrl
);
behaviorService
.
pushBehavior
(
OPERATION
,
"文件上传事件"
,
request
);
return
ResponseResult
.
success
();
...
...
@@ -252,23 +252,29 @@ public class EventController extends BaseController {
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"file"
,
value
=
"上传表格"
,
paramType
=
"form"
,
dataType
=
"multipartFile"
),
@ApiImplicitParam
(
name
=
"contendId"
,
value
=
"竞品id"
,
paramType
=
"form"
,
dataType
=
"string"
)})
@PostMapping
(
value
=
"/data/upload"
,
headers
=
"content-type=multipart/form-data"
)
public
ResponseResult
uploadEventDatas
(
@RequestParam
(
value
=
"contendId"
,
defaultValue
=
"0"
)
String
contendId
,
@RequestParam
(
"file"
)
MultipartFile
file
)
{
public
ResponseResult
uploadEventDatas
(
@RequestParam
(
value
=
"contendId"
,
defaultValue
=
"0"
)
String
contendId
,
@RequestParam
(
"file"
)
MultipartFile
file
)
{
eventService
.
uploadEventDatas
(
contendId
,
file
);
behaviorService
.
pushBehavior
(
OPERATION
,
"事件数据上传"
,
request
);
return
ResponseResult
.
success
();
}
@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
=
"linkedGroupId"
,
value
=
"关联性项目组id"
,
required
=
true
,
paramType
=
"query"
,
dataType
=
"string"
),
@ApiImplicitParam
(
name
=
"tagGroupName"
,
value
=
"标签组名"
,
required
=
true
,
paramType
=
"query"
,
dataType
=
"string"
)})
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"page"
,
value
=
"页码"
,
defaultValue
=
"1"
,
paramType
=
"query"
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"size"
,
value
=
"每页记录数"
,
defaultValue
=
"10"
,
paramType
=
"query"
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"contendId"
,
value
=
"品牌id"
,
required
=
true
,
paramType
=
"query"
,
dataType
=
"string"
),
@ApiImplicitParam
(
name
=
"tagGroupName"
,
value
=
"标签组名"
,
required
=
true
,
paramType
=
"query"
,
dataType
=
"string"
)})
@GetMapping
(
"/tag/list"
)
public
ResponseResult
findEventTagList
(
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
int
page
,
@RequestParam
(
value
=
"size"
,
defaultValue
=
"10"
)
int
size
,
@RequestParam
(
value
=
"linkedGroupId"
)
String
linkedGroupId
,
@RequestParam
(
value
=
"tagGroupName"
)
String
tagGroupName
)
{
return
ResponseResult
.
success
(
eventService
.
findEventTagList
(
page
,
size
,
linkedGroupId
,
tagGroupName
));
public
ResponseResult
findEventTagList
(
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
int
page
,
@RequestParam
(
value
=
"size"
,
defaultValue
=
"10"
)
int
size
,
@RequestParam
(
value
=
"contendId"
,
defaultValue
=
"0"
)
String
contendId
,
@RequestParam
(
value
=
"tagGroupName"
)
String
tagGroupName
)
{
return
ResponseResult
.
success
(
eventService
.
findEventTagList
(
page
,
size
,
contendId
,
tagGroupName
));
}
@ApiOperation
(
"查询所有事件标签组名"
)
@GetMapping
(
"/tag/groupName"
)
public
ResponseResult
findEventTagGroupName
(
@RequestParam
(
value
=
"
linkedGroupId"
)
String
linkedGroup
Id
)
{
return
ResponseResult
.
success
(
eventService
.
findEventTagGroupName
(
linkedGroup
Id
));
public
ResponseResult
findEventTagGroupName
(
@RequestParam
(
value
=
"
contendId"
)
String
contend
Id
)
{
return
ResponseResult
.
success
(
eventService
.
findEventTagGroupName
(
contend
Id
));
}
}
src/main/java/com/zhiwei/brandkbs2/enmus/response/LoginCodeEnum.java
0 → 100644
View file @
a17d6c42
package
com
.
zhiwei
.
brandkbs2
.
enmus
.
response
;
import
com.zhiwei.brandkbs2.model.ResultCode
;
/**
* @author lxj
* @version 1.0
* @description 登录错误状态码及信息
* @date 2019/8/12 17:46
*/
public
enum
LoginCodeEnum
implements
ResultCode
{
/**
* 项目名输入错误
*/
LOGIN_PROJECT_NAME_ERROR
(
false
,
1001
,
"项目名输入错误!"
,
200
),
/**
* 账号或密码输入错误
*/
LOGIN_USERNAME_OR_PASSWORD_ERROR
(
false
,
1002
,
"账号或密码输入错误!"
,
200
),
/**
* 客户账号无法登陆后台管理系统
*/
LOGIN_NOT_ADMIN_ERROR
(
false
,
1003
,
"客户账号无法登陆后台管理系统!"
,
200
),
/**
* 获取授权微信认证失败
*/
LOGIN_WX_AUTH_ERROR
(
false
,
1004
,
"获取授权微信认证失败!"
,
200
),
/**
* 该微信已被其他账号绑定
*/
LOGIN_WX_WITH_USER_ERROR
(
false
,
1005
,
"该微信已被其他账号绑定,登陆失败!"
,
200
),
/**
* 该账号已被其他微信绑定
*/
LOGIN_USER_WITH_WX_ERROR
(
false
,
1006
,
"该账号已被其他微信绑定,登陆失败!"
,
200
),
/**
* 该微信未绑定账号
*/
LOGIN_WX_WITH_OUT_USER_ERROR
(
false
,
1007
,
"该微信未绑定账号"
,
200
),
/**
* 该账号已过期
*/
LOGIN_EXPIRED_ERROR
(
false
,
1008
,
"该账号已过期"
,
200
),
/**
* 项目已停用
*/
LOGIN_PROJECT_STOPPED_ERROR
(
false
,
1009
,
"当前项目已停用,请联系管理员恢复"
,
200
);
/**
* 操作是否成功
*/
final
boolean
success
;
/**
* 操作代码
*/
final
int
code
;
/**
* 提示信息
*/
final
String
message
;
/**
* 聚合状态码
*/
final
int
aggCode
;
LoginCodeEnum
(
boolean
success
,
int
code
,
String
message
,
int
aggCode
)
{
this
.
success
=
success
;
this
.
code
=
code
;
this
.
message
=
message
;
this
.
aggCode
=
aggCode
;
}
@Override
public
boolean
success
()
{
return
success
;
}
@Override
public
int
code
()
{
return
code
;
}
@Override
public
String
message
()
{
return
message
;
}
@Override
public
int
aggCode
()
{
return
aggCode
;
}
}
src/main/java/com/zhiwei/brandkbs2/exception/CustomException.java
View file @
a17d6c42
...
...
@@ -15,15 +15,19 @@ public class CustomException extends RuntimeException {
*/
private
final
ResultCode
resultCode
;
private
final
String
errorMessage
;
private
final
Exception
exception
;
public
CustomException
(
ResultCode
resultCode
)
{
this
.
resultCode
=
resultCode
;
this
.
errorMessage
=
null
;
this
.
exception
=
null
;
}
public
CustomException
(
ResultCode
resultCode
,
Exception
e
)
{
public
CustomException
(
ResultCode
resultCode
,
String
errorMessage
,
Exception
e
)
{
this
.
resultCode
=
resultCode
;
this
.
errorMessage
=
errorMessage
;
this
.
exception
=
e
;
}
...
...
src/main/java/com/zhiwei/brandkbs2/exception/ExceptionCast.java
View file @
a17d6c42
...
...
@@ -15,7 +15,11 @@ public class ExceptionCast {
throw
new
CustomException
(
resultCode
);
}
public
static
void
cast
(
ResultCode
resultCode
,
Exception
e
)
{
throw
new
CustomException
(
resultCode
,
e
);
public
static
void
cast
(
ResultCode
resultCode
,
String
errorMessage
)
{
throw
new
CustomException
(
resultCode
,
errorMessage
,
null
);
}
public
static
void
cast
(
ResultCode
resultCode
,
String
errorMessage
,
Exception
e
)
{
throw
new
CustomException
(
resultCode
,
errorMessage
,
e
);
}
}
src/main/java/com/zhiwei/brandkbs2/model/CommonCodeEnum.java
View file @
a17d6c42
...
...
@@ -47,7 +47,7 @@ public enum CommonCodeEnum implements ResultCode {
/**
* 提示信息
*/
String
message
;
final
String
message
;
/**
* 聚合状态码
*/
...
...
@@ -60,11 +60,6 @@ public enum CommonCodeEnum implements ResultCode {
this
.
aggCode
=
aggCode
;
}
public
CommonCodeEnum
message
(
String
message
){
this
.
message
=
message
;
return
this
;
}
@Override
public
boolean
success
()
{
return
success
;
...
...
src/main/java/com/zhiwei/brandkbs2/model/EventCodeEnum.java
0 → 100644
View file @
a17d6c42
package
com
.
zhiwei
.
brandkbs2
.
model
;
/**
* @author lxj
* @version 1.0
* @description 事件错误信息及状态码
* @date 2019/8/31 1:33
*/
public
enum
EventCodeEnum
implements
ResultCode
{
/**
* 该事件已结束
*/
EVENT_STATUS_ERROR
(
false
,
1401
,
"该事件已结束"
,
200
),
/**
* 该事件不存在
*/
EVENT_NOT_EXISTS_ERROR
(
false
,
1402
,
"该事件不存在"
,
200
),
/**
* 事件首发平台或渠道填写错误
*/
EVENT_NOT_EXISTS_FIRST_CHANNEL_ERROR
(
false
,
1403
,
"事件首发平台、来源、渠道填写错误"
,
200
),
/**
* 当前品牌已有进行任务
*/
HAS_TASK_ERROR
(
false
,
1401
,
"当前项目品牌已有进行任务"
,
200
);
/**
* 操作是否成功
*/
final
boolean
success
;
/**
* 操作代码
*/
final
int
code
;
/**
* 提示信息
*/
final
String
message
;
/**
* 聚合状态码
*/
final
int
aggCode
;
EventCodeEnum
(
boolean
success
,
int
code
,
String
message
,
int
aggCode
)
{
this
.
success
=
success
;
this
.
code
=
code
;
this
.
message
=
message
;
this
.
aggCode
=
aggCode
;
}
@Override
public
boolean
success
()
{
return
success
;
}
@Override
public
int
code
()
{
return
code
;
}
@Override
public
String
message
()
{
return
message
;
}
@Override
public
int
aggCode
()
{
return
aggCode
;
}
}
src/main/java/com/zhiwei/brandkbs2/model/ResponseResult.java
View file @
a17d6c42
...
...
@@ -25,7 +25,7 @@ public class ResponseResult {
* 操作是否成功
*/
@ApiModelProperty
(
"操作是否成功"
)
private
boolean
s
ucces
s
;
private
boolean
s
tatu
s
;
/**
* 操作状态码
...
...
@@ -56,7 +56,7 @@ public class ResponseResult {
}
public
ResponseResult
(
ResultCode
resultCode
,
Object
data
)
{
this
.
s
ucces
s
=
resultCode
.
success
();
this
.
s
tatu
s
=
resultCode
.
success
();
this
.
code
=
resultCode
.
code
();
this
.
message
=
resultCode
.
message
();
this
.
aggCode
=
resultCode
.
aggCode
();
...
...
src/main/java/com/zhiwei/brandkbs2/pojo/EventDisseminationTrend.java
View file @
a17d6c42
...
...
@@ -77,12 +77,12 @@ public class EventDisseminationTrend extends AbstractBaseMongo {
Map
<
String
,
Object
>
element
=
new
HashMap
<>();
element
.
put
(
"time"
,
start
);
element
.
put
(
"sum"
,
count
);
negative
Spread
.
add
(
element
);
total
Spread
.
add
(
element
);
// 负面统计
Map
<
String
,
Object
>
negElement
=
new
HashMap
<>();
negElement
.
put
(
"time"
,
start
);
negElement
.
put
(
"sum"
,
negCount
);
total
Spread
.
add
(
negElement
);
negative
Spread
.
add
(
negElement
);
// 推进节点并重置计量值
count
=
0
;
negCount
=
0
;
...
...
src/main/java/com/zhiwei/brandkbs2/pojo/vo/YqEventSearchVO.java
View file @
a17d6c42
...
...
@@ -21,9 +21,6 @@ public class YqEventSearchVO {
@ApiModelProperty
(
"每页记录数"
)
private
Integer
pageSize
;
@ApiModelProperty
(
"关联项目组id"
)
private
String
linkedGroupId
;
@ApiModelProperty
(
"关联品牌id"
)
private
String
contendId
=
"0"
;
...
...
src/main/java/com/zhiwei/brandkbs2/service/ChannelService.java
View file @
a17d6c42
...
...
@@ -27,7 +27,7 @@ public interface ChannelService {
*
* @param page 页码
* @param size 大小
* @param
linkedGroupId 关联项目ID
* @param
contendId 品牌id
* @param emotion 0:全部 1:友好 2:中性 3:不友好
* @param platform 平台
* @param show 展示
...
...
@@ -35,7 +35,7 @@ public interface ChannelService {
* @param sorter 排序字段
* @return 渠道列表
*/
PageVO
<
JSONObject
>
findChannelList
(
int
page
,
int
size
,
String
linkedGroup
Id
,
String
emotion
,
String
platform
,
Boolean
show
,
String
keyword
,
String
sorter
);
PageVO
<
JSONObject
>
findChannelList
(
int
page
,
int
size
,
String
contend
Id
,
String
emotion
,
String
platform
,
Boolean
show
,
String
keyword
,
String
sorter
);
/**
* 根据搜索条件查询稿件列表
...
...
@@ -90,7 +90,7 @@ public interface ChannelService {
/**
* 获取下载渠道列表
*/
List
<
ExportChannelDTO
>
findDownloadChannelList
(
String
linkedGroup
Id
,
String
emotion
,
String
platform
,
Boolean
show
,
String
keyword
);
List
<
ExportChannelDTO
>
findDownloadChannelList
(
String
contend
Id
,
String
emotion
,
String
platform
,
Boolean
show
,
String
keyword
);
/**
* 获取下载稿件列表
...
...
src/main/java/com/zhiwei/brandkbs2/service/EventService.java
View file @
a17d6c42
...
...
@@ -5,7 +5,6 @@ import com.zhiwei.brandkbs2.easyexcel.dto.ExportEventDTO;
import
com.zhiwei.brandkbs2.easyexcel.dto.ExportEventDataDTO
;
import
com.zhiwei.brandkbs2.easyexcel.dto.UploadEventDTO
;
import
com.zhiwei.brandkbs2.pojo.Event
;
import
com.zhiwei.brandkbs2.pojo.EventData
;
import
com.zhiwei.brandkbs2.pojo.EventDisseminationTrend
;
import
com.zhiwei.brandkbs2.pojo.dto.EventDataDTO
;
import
com.zhiwei.brandkbs2.pojo.dto.EventSearchDTO
;
...
...
@@ -55,12 +54,12 @@ public interface EventService {
*
* @param page 页码
* @param size 大小
* @param
linkedGroupId 关联项目组
id
* @param
contendId 品牌
id
* @param keyword 搜索关键字
* @param sorter 排序字段
* @return 事件列表信息
*/
PageVO
<
JSONObject
>
findEventList
(
int
page
,
int
size
,
String
linkedGroup
Id
,
String
keyword
,
String
sorter
);
PageVO
<
JSONObject
>
findEventList
(
int
page
,
int
size
,
String
contend
Id
,
String
keyword
,
String
sorter
);
/**
* 分页查询舆情监测系统的事件列表
...
...
@@ -161,10 +160,10 @@ public interface EventService {
/**
* 获取事件列表下载信息
*
* @param
linkedGroupId 关联项目组
id
* @param
contendId 品牌
id
* @return 事件列表下载信息
*/
Pair
<
String
,
List
<
ExportEventDTO
>>
downloadEvents
(
String
linkedGroup
Id
);
Pair
<
String
,
List
<
ExportEventDTO
>>
downloadEvents
(
String
contend
Id
);
/**
* 添加文件上传事件信息
...
...
@@ -212,10 +211,10 @@ public interface EventService {
/**
* 获取舆情事件标签组名
*
* @param
linkedGroupId 关联项目组ID
* @param
contendId 品牌id
* @return 事件标签组名列表
*/
List
<
String
>
findEventTagGroupName
(
String
linkedGroup
Id
);
List
<
String
>
findEventTagGroupName
(
String
contend
Id
);
/**
* 获取品牌事件搜索条件
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/ChannelServiceImpl.java
View file @
a17d6c42
...
...
@@ -110,8 +110,8 @@ public class ChannelServiceImpl implements ChannelService {
ThreadPoolTaskExecutor
esSearchExecutor
;
@Override
public
PageVO
<
JSONObject
>
findChannelList
(
int
page
,
int
size
,
String
linkedGroup
Id
,
String
emotion
,
String
platform
,
Boolean
show
,
String
keyword
,
String
sorter
)
{
Query
query
=
channelListQuery
(
linkedGroup
Id
,
show
,
emotion
,
platform
,
keyword
,
sorter
);
public
PageVO
<
JSONObject
>
findChannelList
(
int
page
,
int
size
,
String
contend
Id
,
String
emotion
,
String
platform
,
Boolean
show
,
String
keyword
,
String
sorter
)
{
Query
query
=
channelListQuery
(
contend
Id
,
show
,
emotion
,
platform
,
keyword
,
sorter
);
long
total
=
channelDao
.
count
(
query
);
// 开启分页
mongoUtil
.
start
(
page
,
size
,
query
);
...
...
@@ -159,7 +159,7 @@ public class ChannelServiceImpl implements ChannelService {
});
return
PageVO
.
createPageVoNew
(
articleIds
.
size
(),
page
,
size
,
resList
);
}
catch
(
IOException
e
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"查询异常"
)
,
e
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"查询异常"
,
e
);
}
return
null
;
}
...
...
@@ -193,7 +193,7 @@ public class ChannelServiceImpl implements ChannelService {
public
void
switchChannelShow
(
String
channelId
)
{
Channel
channel
=
channelDao
.
findOneById
(
channelId
);
if
(
Objects
.
isNull
(
channel
))
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
INVALID_PARAM
.
message
(
"渠道不存在"
)
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
INVALID_PARAM
,
"渠道不存在"
);
}
Update
update
=
new
Update
();
update
.
set
(
"show"
,
!
channel
.
isShow
());
...
...
@@ -212,7 +212,7 @@ public class ChannelServiceImpl implements ChannelService {
Channel
channel
=
channelDao
.
findOneById
(
channelId
);
if
(
Objects
.
isNull
(
channel
))
{
//抛出未查询到相关ID的渠道信息异常
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"渠道不存在"
)
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"渠道不存在"
);
}
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"id"
,
channel
.
getId
());
...
...
@@ -234,8 +234,8 @@ public class ChannelServiceImpl implements ChannelService {
}
@Override
public
List
<
ExportChannelDTO
>
findDownloadChannelList
(
String
linkedGroup
Id
,
String
emotion
,
String
platform
,
Boolean
show
,
String
keyword
)
{
Query
query
=
channelListQuery
(
linkedGroup
Id
,
show
,
emotion
,
platform
,
keyword
,
null
);
public
List
<
ExportChannelDTO
>
findDownloadChannelList
(
String
contend
Id
,
String
emotion
,
String
platform
,
Boolean
show
,
String
keyword
)
{
Query
query
=
channelListQuery
(
contend
Id
,
show
,
emotion
,
platform
,
keyword
,
null
);
List
<
Channel
>
list
=
channelDao
.
findList
(
query
);
return
list
.
stream
().
map
(
ExportChannelDTO:
:
createFromChannel
).
collect
(
Collectors
.
toList
());
}
...
...
@@ -255,7 +255,7 @@ public class ChannelServiceImpl implements ChannelService {
resList
.
add
(
dto
);
});
}
catch
(
IOException
e
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"查询异常"
)
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"查询异常"
);
}
return
resList
;
}
...
...
@@ -341,7 +341,7 @@ public class ChannelServiceImpl implements ChannelService {
}
});
}
catch
(
IOException
e
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"es查询异常"
)
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"es查询异常"
);
}
return
resList
;
}
...
...
@@ -432,7 +432,7 @@ public class ChannelServiceImpl implements ChannelService {
}
});
}
catch
(
IOException
e
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"es查询异常"
)
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"es查询异常"
);
}
return
resList
;
}
...
...
@@ -441,7 +441,7 @@ public class ChannelServiceImpl implements ChannelService {
public
boolean
collectChannel
(
String
channelId
)
{
Channel
channel
=
channelDao
.
findOneById
(
channelId
);
if
(
null
==
channel
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"该渠道不存在!"
)
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"该渠道不存在!"
);
}
Update
update
=
Update
.
update
(
"isCollect"
,
true
).
set
(
"collectTime"
,
System
.
currentTimeMillis
());
channelDao
.
updateOneByIdWithField
(
channelId
,
update
);
...
...
@@ -452,7 +452,7 @@ public class ChannelServiceImpl implements ChannelService {
public
boolean
removeCollectChannel
(
String
channelId
)
{
Channel
channel
=
channelDao
.
findOneById
(
channelId
);
if
(
null
==
channel
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"该渠道不存在!"
)
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"该渠道不存在!"
);
}
Update
update
=
Update
.
update
(
"isCollect"
,
false
);
channelDao
.
updateOneByIdWithField
(
channelId
,
update
);
...
...
@@ -477,7 +477,7 @@ public class ChannelServiceImpl implements ChannelService {
public
JSONObject
getBaseInfoByChannelId
(
String
channelId
)
{
Channel
channel
=
channelDao
.
findOneById
(
channelId
);
if
(
null
==
channel
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"该渠道不存在!"
)
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"该渠道不存在!"
);
}
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"id"
,
channel
.
getId
());
...
...
@@ -639,7 +639,7 @@ public class ChannelServiceImpl implements ChannelService {
return
channelRecord
.
getRecord
().
getArticles
().
stream
().
sorted
(
Comparator
.
comparingLong
(
ChannelIndex
.
Article
::
getTime
)).
limit
(
1
).
collect
(
Collectors
.
toList
()).
get
(
0
).
getTime
();
}
}
catch
(
IOException
e
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"es查询异常"
)
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"es查询异常"
);
}
return
null
;
}
...
...
@@ -1234,7 +1234,7 @@ public class ChannelServiceImpl implements ChannelService {
// 根据品牌分类
return
convert2ContendMap
(
searchResponses
,
startTime
,
endTime
,
contendIds
);
}
catch
(
IOException
e
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"es查询异常"
)
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"es查询异常"
);
}
return
Collections
.
emptyMap
();
}
...
...
@@ -1419,9 +1419,9 @@ public class ChannelServiceImpl implements ChannelService {
return
helper
;
}
private
Query
channelListQuery
(
String
linkedGroup
Id
,
Boolean
show
,
String
emotion
,
String
platform
,
String
keyword
,
String
sorter
)
{
private
Query
channelListQuery
(
String
contend
Id
,
Boolean
show
,
String
emotion
,
String
platform
,
String
keyword
,
String
sorter
)
{
Query
query
=
new
Query
();
query
.
addCriteria
(
Criteria
.
where
(
"
linkedGroupId"
).
is
(
linkedGroup
Id
));
query
.
addCriteria
(
Criteria
.
where
(
"
contendId"
).
is
(
contend
Id
));
if
(
null
!=
show
)
{
query
.
addCriteria
(
Criteria
.
where
(
"show"
).
is
(
show
));
}
...
...
@@ -1433,8 +1433,8 @@ public class ChannelServiceImpl implements ChannelService {
}
// 添加模糊匹配
channelDao
.
addKeywordFuzz
(
query
,
keyword
,
"source"
);
// 添加排序
channelDao
.
addSort
(
query
,
sorter
);
// 添加排序
TODO 2
//
channelDao.addSort(query, sorter);
return
query
;
}
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/CommonServiceImpl.java
View file @
a17d6c42
package
com
.
zhiwei
.
brandkbs2
.
service
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.zhiwei.brandkbs2.common.GlobalPojo
;
import
com.zhiwei.brandkbs2.config.Constant
;
import
com.zhiwei.brandkbs2.enmus.EmotionEnum
;
import
com.zhiwei.brandkbs2.service.CommonService
;
...
...
@@ -13,7 +14,6 @@ import com.zhiwei.middleware.mark.vo.TagSearch;
import
org.apache.commons.lang3.time.DateUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.client.RestTemplate
;
...
...
@@ -77,14 +77,18 @@ public class CommonServiceImpl implements CommonService {
@Override
public
List
<
String
>
getQbjcPlatformNames
()
{
HttpEntity
<
JSONObject
>
entity
=
restTemplate
.
getForEntity
(
qbjcPlatformUrl
,
JSONObject
.
class
);
return
Objects
.
requireNonNull
(
entity
.
getBody
()).
getJSONArray
(
"data"
).
toJavaList
(
JSONObject
.
class
).
stream
().
map
(
json
->
json
.
getString
(
"name"
)).
collect
(
Collectors
.
toList
());
return
getQbjcPlatform
(
"name"
).
stream
().
map
(
json
->
json
.
getString
(
"name"
)).
collect
(
Collectors
.
toList
());
}
@Override
public
List
<
JSONObject
>
getQbjcPlatform
(
String
...
includeFields
)
{
HttpEntity
<
JSONObject
>
entity
=
restTemplate
.
getForEntity
(
qbjcPlatformUrl
,
JSONObject
.
class
);
return
Objects
.
requireNonNull
(
entity
.
getBody
()).
getJSONArray
(
"data"
).
toJavaList
(
JSONObject
.
class
).
stream
().
map
(
json
->
{
List
<
JSONObject
>
collect
=
GlobalPojo
.
PLATFORMS
.
stream
().
filter
(
messagePlatform
->
!
"外媒"
.
equals
(
messagePlatform
.
getName
())).
map
(
messagePlatform
->
{
JSONObject
json
=
new
JSONObject
();
json
.
put
(
"id"
,
messagePlatform
.
getId
());
json
.
put
(
"name"
,
messagePlatform
.
getName
());
return
json
;
}).
collect
(
Collectors
.
toList
());
return
collect
.
stream
().
map
(
json
->
{
if
(
null
==
includeFields
)
{
return
json
;
}
...
...
@@ -94,6 +98,17 @@ public class CommonServiceImpl implements CommonService {
}
return
res
;
}).
collect
(
Collectors
.
toList
());
// HttpEntity<JSONObject> entity = restTemplate.getForEntity(qbjcPlatformUrl, JSONObject.class);
// return Objects.requireNonNull(entity.getBody()).getJSONArray("data").toJavaList(JSONObject.class).stream().map(json -> {
// if (null == includeFields) {
// return json;
// }
// JSONObject res = new JSONObject();
// for (String field : includeFields) {
// res.put(field, json.get(field));
// }
// return res;
// }).collect(Collectors.toList());
}
@Override
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/CustomEventServiceImpl.java
View file @
a17d6c42
...
...
@@ -110,7 +110,7 @@ public class CustomEventServiceImpl implements CustomEventService {
}).
collect
(
Collectors
.
toList
());
redisUtil
.
setExpire
(
redisKey
,
JSON
.
toJSONString
(
resultList
));
}
catch
(
IOException
e
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"es查询异常"
)
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"es查询异常"
);
}
return
resultList
;
}
...
...
@@ -131,10 +131,10 @@ public class CustomEventServiceImpl implements CustomEventService {
public
void
updateCustomEvent
(
CustomEventDTO
customEventDTO
)
{
CustomEvent
customEvent
=
customEventDao
.
findOneById
(
customEventDTO
.
getId
());
if
(
Objects
.
isNull
(
customEvent
))
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"自定义事件数据异常"
)
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"自定义事件数据异常"
);
}
if
(
Boolean
.
FALSE
.
equals
(
customEvent
.
getStatus
()))
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"该事件数据更新中,无法修改该事件信息!"
)
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"该事件数据更新中,无法修改该事件信息!"
);
}
// 修改自定义事件及清空历史数据
Update
update
=
Update
.
update
(
"title"
,
customEventDTO
.
getTitle
()).
set
(
"startTime"
,
customEventDTO
.
getStartTime
()).
...
...
@@ -177,10 +177,10 @@ public class CustomEventServiceImpl implements CustomEventService {
public
void
analyzeCustomEvent
(
String
id
)
{
CustomEvent
customEvent
=
customEventDao
.
findOneById
(
id
);
if
(
Objects
.
isNull
(
customEvent
))
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"自定义事件数据异常"
)
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"自定义事件数据异常"
);
}
if
(
Boolean
.
FALSE
.
equals
(
customEvent
.
getStatus
()))
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"该事件数据更新中!"
)
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"该事件数据更新中!"
);
}
customEvent
.
setStatus
(
false
);
Long
now
=
System
.
currentTimeMillis
();
...
...
@@ -195,7 +195,7 @@ public class CustomEventServiceImpl implements CustomEventService {
public
JSONObject
getCustomEventAnalyzeShareId
(
String
id
)
{
CustomEvent
customEvent
=
customEventDao
.
findOneById
(
id
);
if
(
Objects
.
isNull
(
customEvent
))
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"自定义事件数据异常"
)
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"自定义事件数据异常"
);
}
JSONObject
result
=
new
JSONObject
();
String
share
=
Tools
.
getUUID
();
...
...
@@ -218,7 +218,7 @@ public class CustomEventServiceImpl implements CustomEventService {
public
JSONObject
getShareCustomEventAnalyze
(
String
share
)
{
String
customEventId
=
redisUtil
.
get
(
RedisKeyPrefix
.
CUSTOM_EVENT_ANALYZE_SHARE
+
share
);
if
(
StringUtils
.
isEmpty
(
customEventId
))
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"自定义事件数据异常"
)
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"自定义事件数据异常"
);
}
return
this
.
getCustomEventAnalyze
(
customEventId
,
true
);
}
...
...
@@ -226,7 +226,7 @@ public class CustomEventServiceImpl implements CustomEventService {
private
JSONObject
getCustomEventAnalyzeInner
(
String
id
,
boolean
cache
)
throws
IOException
{
CustomEvent
customEvent
=
customEventDao
.
findOneById
(
id
);
if
(
Objects
.
isNull
(
customEvent
))
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"自定义事件数据异常"
)
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"自定义事件数据异常"
);
}
String
redisKey
=
RedisKeyPrefix
.
CUSTOM_EVENT_ANALYZE
+
id
;
if
(
cache
)
{
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/EventServiceImpl.java
View file @
a17d6c42
...
...
@@ -24,10 +24,8 @@ import com.zhiwei.brandkbs2.enmus.ImportantChannelEnum;
import
com.zhiwei.brandkbs2.exception.ExceptionCast
;
import
com.zhiwei.brandkbs2.listener.ApplicationProjectListener
;
import
com.zhiwei.brandkbs2.model.CommonCodeEnum
;
import
com.zhiwei.brandkbs2.pojo.Event
;
import
com.zhiwei.brandkbs2.pojo.EventData
;
import
com.zhiwei.brandkbs2.pojo.EventDisseminationTrend
;
import
com.zhiwei.brandkbs2.pojo.EventTopArticlesAnalysis
;
import
com.zhiwei.brandkbs2.model.EventCodeEnum
;
import
com.zhiwei.brandkbs2.pojo.*
;
import
com.zhiwei.brandkbs2.pojo.dto.EventDataDTO
;
import
com.zhiwei.brandkbs2.pojo.dto.EventSearchDTO
;
import
com.zhiwei.brandkbs2.pojo.dto.YqEventDTO
;
...
...
@@ -119,7 +117,7 @@ public class EventServiceImpl implements EventService {
Event
event
=
eventDao
.
findOneById
(
eventId
);
if
(
Objects
.
isNull
(
event
))
{
// 抛出事件不存在异常
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"该事件不存在"
)
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"该事件不存在"
);
}
return
event
;
}
...
...
@@ -133,7 +131,7 @@ public class EventServiceImpl implements EventService {
}
String
oldProgress
=
stringRedisTemplate
.
opsForValue
().
get
(
redisKey
);
if
(
null
!=
oldProgress
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"当前项目品牌已有进行任务"
)
);
ExceptionCast
.
cast
(
EventCodeEnum
.
HAS_TASK_ERROR
);
}
stringRedisTemplate
.
opsForValue
().
set
(
redisKey
,
"0"
);
String
collectionName
=
eventDataDao
.
generateCollectionName
();
...
...
@@ -185,8 +183,8 @@ public class EventServiceImpl implements EventService {
}
@Override
public
PageVO
<
JSONObject
>
findEventList
(
int
page
,
int
size
,
String
linkedGroup
Id
,
String
keyword
,
String
sorter
)
{
Query
query
=
new
Query
(
Criteria
.
where
(
"
linkedGroupId"
).
is
(
linkedGroup
Id
).
and
(
"projectId"
).
is
(
UserThreadLocal
.
getProjectId
()));
public
PageVO
<
JSONObject
>
findEventList
(
int
page
,
int
size
,
String
contend
Id
,
String
keyword
,
String
sorter
)
{
Query
query
=
new
Query
(
Criteria
.
where
(
"
contendId"
).
is
(
contend
Id
).
and
(
"projectId"
).
is
(
UserThreadLocal
.
getProjectId
()));
// 添加模糊匹配
eventDao
.
addKeywordFuzz
(
query
,
keyword
,
"title"
);
// 添加排序
...
...
@@ -263,7 +261,7 @@ public class EventServiceImpl implements EventService {
String
redisKey
=
RedisKeyPrefix
.
eventDataProgressKey
(
ticket
);
String
progress
=
stringRedisTemplate
.
opsForValue
().
get
(
redisKey
);
if
(
StringUtils
.
isEmpty
(
progress
))
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"文件解析进度获取失败"
)
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
);
}
return
Integer
.
parseInt
(
progress
);
}
...
...
@@ -410,9 +408,10 @@ public class EventServiceImpl implements EventService {
}
@Override
public
Pair
<
String
,
List
<
ExportEventDTO
>>
downloadEvents
(
String
linkedGroupId
)
{
String
fileName
=
projectService
.
getProjectByLinkedGroupId
(
linkedGroupId
).
getBrandName
();
public
Pair
<
String
,
List
<
ExportEventDTO
>>
downloadEvents
(
String
contendId
)
{
String
projectId
=
UserThreadLocal
.
getProjectId
();
String
linkedGroupId
=
projectService
.
getProjectByContendId
(
projectId
,
contendId
).
getBrandLinkedGroupId
();
String
fileName
=
projectService
.
getProjectByLinkedGroupId
(
linkedGroupId
).
getBrandName
();
List
<
Event
>
eventList
=
eventDao
.
findList
(
Query
.
query
(
Criteria
.
where
(
"projectId"
).
is
(
projectId
).
and
(
"linkedGroupId"
).
is
(
linkedGroupId
)));
if
(
eventList
.
isEmpty
())
{
return
Pair
.
of
(
fileName
,
Collections
.
emptyList
());
...
...
@@ -474,36 +473,38 @@ public class EventServiceImpl implements EventService {
}
@Override
public
JSONObject
findEventTagListAll
(
String
linkedGroup
Id
)
{
String
linkedGroup
=
projectService
.
getProjectBy
LinkedGroupId
(
linkedGroup
Id
).
getBrandLinkedGroup
();
public
JSONObject
findEventTagListAll
(
String
contend
Id
)
{
String
linkedGroup
=
projectService
.
getProjectBy
ContendId
(
UserThreadLocal
.
getProjectId
(),
contend
Id
).
getBrandLinkedGroup
();
ResponseEntity
<
JSONObject
>
entity
=
restTemplate
.
getForEntity
(
qbjcEventTagUrl
,
JSONObject
.
class
,
linkedGroup
);
return
Objects
.
requireNonNull
(
entity
.
getBody
()).
getJSONObject
(
"data"
);
}
@Override
public
PageVO
<
JSONObject
>
findEventTagList
(
int
page
,
int
size
,
String
linkedGroup
Id
,
String
tagGroupName
)
{
public
PageVO
<
JSONObject
>
findEventTagList
(
int
page
,
int
size
,
String
contend
Id
,
String
tagGroupName
)
{
if
(
page
<
1
)
{
page
=
1
;
}
if
(
size
<
0
||
size
>
50
)
{
size
=
10
;
}
String
group
=
projectService
.
getProjectByLinkedGroupId
(
linkedGroupId
).
getBrandLinkedGroup
();
ResponseEntity
<
JSONObject
>
entity
=
restTemplate
.
getForEntity
(
qbjcEventTagUrl
,
JSONObject
.
class
,
group
);
AbstractProject
projectByContendId
=
projectService
.
getProjectByContendId
(
UserThreadLocal
.
getProjectId
(),
contendId
);
String
linkedGroup
=
projectByContendId
.
getBrandLinkedGroup
();
ResponseEntity
<
JSONObject
>
entity
=
restTemplate
.
getForEntity
(
qbjcEventTagUrl
,
JSONObject
.
class
,
linkedGroup
);
List
<
JSONObject
>
tagGroupList
=
Objects
.
requireNonNull
(
entity
.
getBody
()).
getJSONObject
(
"data"
).
getJSONObject
(
"tagList"
).
getJSONArray
(
tagGroupName
).
toJavaList
(
JSONObject
.
class
);
List
<
List
<
JSONObject
>>
partition
=
Lists
.
partition
(
tagGroupList
,
size
);
List
<
JSONObject
>
resultList
=
partition
.
get
(
page
-
1
);
resultList
=
resultList
.
stream
().
peek
(
json
->
{
String
name
=
json
.
getString
(
"name"
);
Query
query
=
Query
.
query
(
Criteria
.
where
(
"eventTag."
+
tagGroupName
).
is
(
name
).
and
(
"projectId"
).
is
(
UserThreadLocal
.
getProjectId
()).
and
(
"linkedGroupId"
).
is
(
linkedGroupId
));
Query
query
=
Query
.
query
(
Criteria
.
where
(
"eventTag."
+
tagGroupName
).
is
(
name
).
and
(
"projectId"
).
is
(
UserThreadLocal
.
getProjectId
()).
and
(
"contendId"
).
is
(
contendId
));
json
.
put
(
"eventCount"
,
eventDao
.
count
(
query
));
}).
collect
(
Collectors
.
toList
());
return
PageVO
.
createPageVo
(
tagGroupList
.
size
(),
page
,
partition
.
size
(),
size
,
resultList
);
}
@Override
public
List
<
String
>
findEventTagGroupName
(
String
linkedGroup
Id
)
{
String
group
=
projectService
.
getProjectBy
LinkedGroupId
(
linkedGroup
Id
).
getBrandLinkedGroup
();
public
List
<
String
>
findEventTagGroupName
(
String
contend
Id
)
{
String
group
=
projectService
.
getProjectBy
ContendId
(
UserThreadLocal
.
getProjectId
(),
contend
Id
).
getBrandLinkedGroup
();
ResponseEntity
<
JSONObject
>
entity
=
restTemplate
.
getForEntity
(
qbjcEventTagUrl
,
JSONObject
.
class
,
group
);
return
Objects
.
requireNonNull
(
entity
.
getBody
()).
getJSONObject
(
"data"
).
getJSONArray
(
"tagNameList"
).
toJavaList
(
String
.
class
);
}
...
...
@@ -632,6 +633,9 @@ public class EventServiceImpl implements EventService {
boolean
highLight
=
null
==
aggTitle
||
Objects
.
equals
(
aggTitle
,
eventTopArticlesAnalysis
.
getAggTitle
());
return
new
EventTopArticlesAnalysisVO
(
eventTopArticlesAnalysis
,
highLight
);
}).
collect
(
Collectors
.
groupingBy
(
EventTopArticlesAnalysisVO:
:
getTimePoint
));
collect
.
forEach
((
k
,
v
)
->
{
v
.
sort
((
y
,
x
)
->
Integer
.
compare
(
x
.
getCount
(),
y
.
getCount
()));
});
res
.
put
(
"dataDay"
,
Tools
.
sortTimeKeyMap
(
collect
,
Constant
.
SPEC_DAY_FORMAT
,
false
));
res
.
put
(
"dataAmount"
,
null
);
return
res
;
...
...
@@ -824,7 +828,8 @@ public class EventServiceImpl implements EventService {
param
.
put
(
"startTime"
,
yqEventSearchVO
.
getStartTime
());
param
.
put
(
"endTime"
,
yqEventSearchVO
.
getEndTime
());
param
.
put
(
"timeType"
,
"startTime"
);
String
linkedGroup
=
projectService
.
getProjectByLinkedGroupId
(
yqEventSearchVO
.
getLinkedGroupId
()).
getBrandLinkedGroup
();
String
linkedGroup
=
projectService
.
getProjectByContendId
(
UserThreadLocal
.
getProjectId
(),
yqEventSearchVO
.
getContendId
()).
getBrandLinkedGroup
();
param
.
put
(
"project"
,
linkedGroup
);
ResponseEntity
<
JSONObject
>
entity
=
restTemplate
.
postForEntity
(
qbjcEventUrl
,
param
,
JSONObject
.
class
);
if
(
null
==
entity
.
getBody
())
{
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/IndexServiceImpl.java
View file @
a17d6c42
...
...
@@ -101,7 +101,7 @@ public class IndexServiceImpl implements IndexService {
jsonObject
.
put
(
"spread"
,
this
.
getArticleSpreadWithBrand
(
projectId
,
Constant
.
PRIMARY_CONTEND_ID
,
dayList
));
redisUtil
.
setExpire
(
redisKey
,
JSON
.
toJSONString
(
jsonObject
));
}
catch
(
Exception
e
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"getYuqingAmount异常"
)
,
e
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"getYuqingAmount异常"
,
e
);
}
return
jsonObject
;
}
...
...
@@ -158,7 +158,7 @@ public class IndexServiceImpl implements IndexService {
jsonObject
.
put
(
"avgPosPro"
,
avgPosPro
);
redisUtil
.
setExpire
(
redisKey
,
JSON
.
toJSONString
(
jsonObject
));
}
catch
(
IOException
e
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"es查询异常"
)
,
e
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"es查询异常"
,
e
);
}
return
jsonObject
;
}
...
...
@@ -214,7 +214,7 @@ public class IndexServiceImpl implements IndexService {
jsonObject
.
put
(
"spread"
,
lineList
);
redisUtil
.
setExpire
(
redisKey
,
JSONObject
.
toJSONString
(
jsonObject
));
}
catch
(
Exception
e
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"getEventAmount异常"
)
,
e
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"getEventAmount异常"
,
e
);
}
return
jsonObject
;
}
...
...
@@ -240,7 +240,7 @@ public class IndexServiceImpl implements IndexService {
redisUtil
.
setExpire
(
redisKey
,
JSON
.
toJSONString
(
platforms
));
return
platforms
;
}
catch
(
IOException
e
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"es查询异常"
)
,
e
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"es查询异常"
,
e
);
}
return
Collections
.
emptyList
();
}
...
...
@@ -292,7 +292,7 @@ public class IndexServiceImpl implements IndexService {
resJson
.
put
(
"summary"
,
summary
);
redisUtil
.
setExpire
(
redisKey
,
JSON
.
toJSONString
(
resJson
));
}
catch
(
IOException
e
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"es查询异常"
)
,
e
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"es查询异常"
,
e
);
}
return
resJson
;
}
...
...
@@ -300,17 +300,27 @@ public class IndexServiceImpl implements IndexService {
public
List
<
JSONObject
>
getPlatformProportionWithPlatform
(
Long
startTime
,
Long
endTime
,
String
emotion
,
String
projectId
,
String
contendId
,
long
normalCount
)
{
List
<
String
>
platformIds
=
GlobalPojo
.
PLATFORMS
.
stream
().
map
(
MessagePlatform:
:
getId
).
collect
(
Collectors
.
toList
());
List
<
JSONObject
>
resultList
=
new
ArrayList
<>(
platformIds
.
size
());
Map
<
String
,
Long
>
platformCount
=
new
HashMap
<>();
platformIds
.
forEach
(
platformId
->
{
JSONObject
result
=
new
JSONObject
();
long
count
;
try
{
count
=
markDataService
.
getYuqingMarkCount
(
startTime
,
endTime
,
emotion
,
platformId
,
projectId
,
contendId
);
}
catch
(
IOException
ignored
)
{
count
=
-
1
;
}
result
.
put
(
"platform"
,
GlobalPojo
.
getPermanentPlatformNameById
(
platformId
));
result
.
put
(
"num"
,
count
);
result
.
put
(
"proportion"
,
normalCount
==
0
?
0
d
:
count
/
(
double
)
normalCount
);
long
finalCount
=
count
;
platformCount
.
compute
(
GlobalPojo
.
getPermanentPlatformNameById
(
platformId
),
(
k
,
v
)
->
{
if
(
null
==
v
)
{
return
finalCount
;
}
return
v
+
finalCount
;
});
});
platformCount
.
forEach
((
k
,
v
)
->
{
JSONObject
result
=
new
JSONObject
();
result
.
put
(
"platform"
,
k
);
result
.
put
(
"num"
,
v
);
result
.
put
(
"proportion"
,
normalCount
==
0
?
0
d
:
v
/
(
double
)
normalCount
);
resultList
.
add
(
result
);
});
return
resultList
;
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkDataServiceImpl.java
View file @
a17d6c42
...
...
@@ -154,7 +154,7 @@ public class MarkDataServiceImpl implements MarkDataService {
// 各平台计量
.
setInfo
(
new
JSONObject
(
ImmutableMap
.
of
(
"platformCount"
,
hitsAndCounts
.
getRight
())));
}
catch
(
IOException
e
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"es检索异常"
)
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"es查询异常"
);
}
return
null
;
}
...
...
@@ -173,7 +173,7 @@ public class MarkDataServiceImpl implements MarkDataService {
return
Pair
.
of
(
project
.
getBrandName
()
+
"_"
+
markSearchDTO
.
getStartTime
()
+
"_"
+
markSearchDTO
.
getEndTime
(),
returnList
);
}
catch
(
IOException
e
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"es检索异常"
)
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"es查询异常"
);
}
return
null
;
}
...
...
@@ -213,7 +213,7 @@ public class MarkDataServiceImpl implements MarkDataService {
@Override
public
PageVO
<
MarkFlowEntity
>
getYuqingMarkAggreeList
(
MarkSearchDTO
dto
)
{
if
(
null
==
dto
.
getAggreeId
())
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
INVALID_PARAM
.
message
(
"聚合id不得为空"
)
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
INVALID_PARAM
);
}
defaultMarkSearch
(
dto
);
Query
query
=
assembleAggreeQuery
(
dto
);
...
...
@@ -392,7 +392,7 @@ public class MarkDataServiceImpl implements MarkDataService {
redisUtil
.
setExpire
(
redisKey
,
JSON
.
toJSONString
(
result
));
return
result
;
}
catch
(
IOException
e
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"es查询异常"
)
,
e
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"es查询异常"
,
e
);
}
return
null
;
}
...
...
@@ -403,7 +403,7 @@ public class MarkDataServiceImpl implements MarkDataService {
String
projectId
=
UserThreadLocal
.
getProjectId
();
return
getMarkSpread
(
startTime
,
endTime
,
projectId
,
cache
);
}
catch
(
IOException
e
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"es查询异常"
)
,
e
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"es查询异常"
,
e
);
}
return
null
;
}
...
...
@@ -438,7 +438,7 @@ public class MarkDataServiceImpl implements MarkDataService {
redisUtil
.
setExpire
(
redisKey
,
JSON
.
toJSONString
(
result
));
return
result
;
}
catch
(
IOException
e
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"es查询异常"
)
,
e
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"es查询异常"
,
e
);
}
return
null
;
}
...
...
@@ -462,7 +462,7 @@ public class MarkDataServiceImpl implements MarkDataService {
// 渠道标签占比
result
.
put
(
"importantChannelPercent"
,
getImportantChannelPercent
(
projectId
,
linkedGroupId
,
startTime
,
endTime
));
}
catch
(
IOException
e
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"es查询异常"
)
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"es查询异常"
,
e
);
}
redisUtil
.
setExpire
(
redisKey
,
JSON
.
toJSONString
(
result
));
return
result
;
...
...
@@ -480,7 +480,7 @@ public class MarkDataServiceImpl implements MarkDataService {
// 舆情库默认contendId为0
res
=
getMarkPlatformProportion
(
startTime
,
endTime
,
projectId
,
linkedGroupId
,
Constant
.
PRIMARY_CONTEND_ID
,
cache
);
}
catch
(
IOException
e
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"es查询异常"
)
,
e
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"es查询异常"
,
e
);
}
return
res
;
}
...
...
@@ -508,7 +508,7 @@ public class MarkDataServiceImpl implements MarkDataService {
redisUtil
.
setExpire
(
redisKey
,
JSON
.
toJSONString
(
highWords
));
return
highWords
;
}
catch
(
IOException
e
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"es查询异常"
)
,
e
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"es查询异常"
,
e
);
}
return
null
;
}
...
...
@@ -813,7 +813,7 @@ public class MarkDataServiceImpl implements MarkDataService {
BoolQueryBuilder
query
;
if
(
include
)
{
query
=
projectLinkedGroupContendIdQuery
(
projectId
,
linkedGroupId
,
contendId
);
}
else
{
}
else
{
query
=
EsQueryTools
.
assembleCacheMapsQueryExcludePrimaryId
(
projectId
);
}
query
.
must
(
QueryBuilders
.
rangeQuery
(
"time"
).
gte
(
startTime
).
lt
(
endTime
))
...
...
@@ -850,7 +850,7 @@ public class MarkDataServiceImpl implements MarkDataService {
BoolQueryBuilder
postFilter
;
if
(
include
)
{
postFilter
=
projectLinkedGroupContendIdQuery
(
projectId
,
linkedGroupId
,
contendId
);
}
else
{
}
else
{
postFilter
=
EsQueryTools
.
assembleCacheMapsQueryExcludePrimaryId
(
projectId
);
}
postFilter
.
must
(
QueryBuilders
.
rangeQuery
(
"time"
).
gte
(
startTime
).
lt
(
endTime
)).
must
(
QueryBuilders
.
termQuery
(
"agg_title.keyword"
,
aggTitle
));
...
...
@@ -945,7 +945,7 @@ public class MarkDataServiceImpl implements MarkDataService {
// 各平台计量
.
setInfo
(
new
JSONObject
(
ImmutableMap
.
of
(
"platformCount"
,
hitsAndCounts
.
getRight
())));
}
catch
(
IOException
e
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"es检索异常"
)
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"es查询异常"
);
}
return
null
;
}
...
...
@@ -1235,7 +1235,7 @@ public class MarkDataServiceImpl implements MarkDataService {
return
Pair
.
of
(
project
.
getBrandName
()
+
"_"
+
markSearchDTO
.
getStartTime
()
+
"_"
+
markSearchDTO
.
getEndTime
(),
returnList
);
}
catch
(
IOException
e
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"es检索异常"
)
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"es查询异常"
,
e
);
}
return
null
;
}
...
...
@@ -1248,7 +1248,7 @@ public class MarkDataServiceImpl implements MarkDataService {
// 搜索时间
result
.
put
(
"times"
,
Arrays
.
asList
(
"今天"
,
"24小时"
,
"三天"
,
"七天"
,
"近30天"
));
result
.
put
(
"ninetyDays"
,
DateUtils
.
addDays
(
Tools
.
truncDate
(
new
Date
(),
Constant
.
DAY_PATTERN
),
-
89
).
getTime
());
result
.
put
(
"ninetyDays"
,
DateUtils
.
addDays
(
Tools
.
truncDate
(
new
Date
(),
Constant
.
DAY_PATTERN
),
-
89
).
getTime
());
List
<
JSONObject
>
platformList
=
new
ArrayList
<>();
if
(
2
==
project
.
getWholeSearchDataSource
())
{
...
...
@@ -1260,36 +1260,36 @@ public class MarkDataServiceImpl implements MarkDataService {
platformJSONObject
.
put
(
"id"
,
entry
.
getValue
());
platformList
.
add
(
platformJSONObject
);
}
}
else
{
}
else
{
result
.
put
(
"origin"
,
"舆情"
);
ResponseEntity
<
String
>
responseEntity
=
restTemplate
.
getForEntity
(
wholeSearchCriteriaUrl
,
String
.
class
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
responseEntity
.
getBody
());
Map
data
=
(
Map
)
jsonObject
.
get
(
"data"
);
List
<
JSONObject
>
list
=
(
List
)
data
.
get
(
"list"
);
List
<
JSONObject
>
list
=
(
List
)
data
.
get
(
"list"
);
//发布平台删掉脉脉
List
<
JSONObject
>
collect
=
list
.
stream
().
filter
(
s
->
!
s
.
get
(
"name"
).
equals
(
"脉脉"
)).
collect
(
Collectors
.
toList
());
for
(
JSONObject
object
:
collect
)
{
JSONObject
platformJSONObject
=
new
JSONObject
();
platformJSONObject
.
put
(
"name"
,
object
.
get
(
"name"
));
platformJSONObject
.
put
(
"id"
,
object
.
get
(
"id"
));
platformJSONObject
.
put
(
"name"
,
object
.
get
(
"name"
));
platformJSONObject
.
put
(
"id"
,
object
.
get
(
"id"
));
platformList
.
add
(
platformJSONObject
);
}
}
result
.
put
(
"platformList"
,
platformList
);
result
.
put
(
"platformList"
,
platformList
);
return
result
;
}
private
JSONObject
getBackUpPlatform
(){
private
JSONObject
getBackUpPlatform
()
{
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"全部"
,
""
);
jsonObject
.
put
(
"微博"
,
"微博"
);
jsonObject
.
put
(
"微信"
,
"微信"
);
jsonObject
.
put
(
"网媒"
,
"新闻"
);
jsonObject
.
put
(
"平媒"
,
"平媒"
);
jsonObject
.
put
(
"自媒体"
,
"自媒体"
);
jsonObject
.
put
(
"贴吧论坛"
,
"论坛"
);
jsonObject
.
put
(
"视频"
,
"视频"
);
jsonObject
.
put
(
"短视频"
,
"短视频"
);
jsonObject
.
put
(
"全部"
,
""
);
jsonObject
.
put
(
"微博"
,
"微博"
);
jsonObject
.
put
(
"微信"
,
"微信"
);
jsonObject
.
put
(
"网媒"
,
"新闻"
);
jsonObject
.
put
(
"平媒"
,
"平媒"
);
jsonObject
.
put
(
"自媒体"
,
"自媒体"
);
jsonObject
.
put
(
"贴吧论坛"
,
"论坛"
);
jsonObject
.
put
(
"视频"
,
"视频"
);
jsonObject
.
put
(
"短视频"
,
"短视频"
);
return
jsonObject
;
}
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkFlowServiceImpl.java
View file @
a17d6c42
...
...
@@ -60,7 +60,7 @@ public class MarkFlowServiceImpl implements MarkFlowService {
String
key
=
RedisUtil
.
getShotPageKey
(
id
,
UserThreadLocal
.
getProjectId
());
String
data
=
redisUtil
.
get
(
key
);
if
(
null
==
data
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"缓存不存在或已过期"
)
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
);
}
return
JSON
.
parseObject
(
data
,
MarkFlowEntity
.
class
);
// JSONObject dataJson = JSON.parseObject(data);
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/ProjectServiceImpl.java
View file @
a17d6c42
...
...
@@ -94,7 +94,7 @@ public class ProjectServiceImpl implements ProjectService {
Project
project
=
projectDao
.
findOneById
(
id
);
if
(
Objects
.
isNull
(
project
))
{
//如果项目不存在,抛出非法参数异常
ExceptionCast
.
cast
(
CommonCodeEnum
.
INVALID_PARAM
.
message
(
"该项目不存在"
)
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
INVALID_PARAM
,
"该项目不存在"
);
}
return
project
.
creatProjectVo
();
}
...
...
@@ -157,7 +157,7 @@ public class ProjectServiceImpl implements ProjectService {
public
void
switchProjectStart
(
String
pid
)
{
Project
project
=
projectDao
.
findOneById
(
pid
);
if
(
Objects
.
isNull
(
project
))
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
INVALID_PARAM
.
message
(
"项目不存在"
)
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
INVALID_PARAM
,
"项目不存在"
);
}
Update
update
=
new
Update
();
update
.
set
(
"uTime"
,
new
Date
());
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/ReportServiceImpl.java
View file @
a17d6c42
...
...
@@ -210,7 +210,7 @@ public class ReportServiceImpl implements ReportService {
@Override
public
JSONObject
getPcReportAnalyze
(
Report
report
,
boolean
cache
)
{
if
(
Objects
.
isNull
(
report
))
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"获取报告数据异常"
)
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"获取报告数据异常"
);
}
String
redisKey
=
RedisKeyPrefix
.
REPORT_PC
+
report
.
getId
();
String
resultStr
;
...
...
@@ -232,7 +232,7 @@ public class ReportServiceImpl implements ReportService {
try
{
result
=
getPcReportResult
(
report
);
}
catch
(
IOException
e
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"es查询异常"
)
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"es查询异常"
);
}
redisUtil
.
set
(
redisKey
,
JSON
.
toJSONString
(
result
));
return
result
;
...
...
@@ -355,8 +355,7 @@ public class ReportServiceImpl implements ReportService {
result
.
put
(
"topPosSummary"
,
this
.
getTopEventMsg
(
topPosEventList
));
}
//获取上个周期时间范围内总正面稿件数
long
lastPositiveTotal
=
markDataService
.
getYuqingMarkCount
(
lastStartTime
,
startTime
,
EmotionEnum
.
POSITIVE
.
getName
(),
projectId
,
contendId
);
long
lastPositiveTotal
=
markDataService
.
getYuqingMarkCount
(
lastStartTime
,
startTime
,
EmotionEnum
.
POSITIVE
.
getName
(),
projectId
,
contendId
);
result
.
put
(
"lastPosTotal"
,
lastPositiveTotal
);
result
.
put
(
"posCompare"
,
lastPositiveTotal
==
0
?
0
:
(
curPositiveTotal
-
lastPositiveTotal
)
*
1.0
/
lastPositiveTotal
);
//获取时间范围内总中性稿件数
...
...
@@ -366,8 +365,7 @@ public class ReportServiceImpl implements ReportService {
//中性事件传播量top
List
<
Event
>
topNeuEventList
=
eventDao
.
getEventsByTotalChannelVolumeTop
(
startTime
,
endTime
,
EmotionEnum
.
NEUTRAL
.
getName
(),
projectId
,
contendId
,
4
);
if
(
CollectionUtils
.
isEmpty
(
topNeuEventList
))
{
List
<
Map
.
Entry
<
String
,
Integer
>>
topNeuArticleList
=
markDataService
.
getMarkTopTitle
(
startTime
,
endTime
,
EmotionEnum
.
NEUTRAL
.
getName
(),
projectId
,
linkedGroupId
,
contendId
,
4
);
List
<
Map
.
Entry
<
String
,
Integer
>>
topNeuArticleList
=
markDataService
.
getMarkTopTitle
(
startTime
,
endTime
,
EmotionEnum
.
NEUTRAL
.
getName
(),
projectId
,
linkedGroupId
,
contendId
,
4
);
result
.
put
(
"topNeuSummary"
,
this
.
getTopArticlesMsg
(
startTime
,
endTime
,
projectId
,
linkedGroupId
,
contendId
,
topNeuArticleList
));
}
else
{
result
.
put
(
"topNeuSummary"
,
this
.
getTopEventMsg
(
topNeuEventList
));
...
...
@@ -383,8 +381,7 @@ public class ReportServiceImpl implements ReportService {
//中性事件传播量top
List
<
Event
>
topNegEventList
=
eventDao
.
getEventsByTotalChannelVolumeTop
(
startTime
,
endTime
,
EmotionEnum
.
NEGATIVE
.
getName
(),
projectId
,
contendId
,
4
);
if
(
CollectionUtils
.
isEmpty
(
topNegEventList
))
{
List
<
Map
.
Entry
<
String
,
Integer
>>
topNegArticleList
=
markDataService
.
getMarkTopTitle
(
startTime
,
endTime
,
EmotionEnum
.
NEGATIVE
.
getName
(),
projectId
,
linkedGroupId
,
contendId
,
4
);
List
<
Map
.
Entry
<
String
,
Integer
>>
topNegArticleList
=
markDataService
.
getMarkTopTitle
(
startTime
,
endTime
,
EmotionEnum
.
NEGATIVE
.
getName
(),
projectId
,
linkedGroupId
,
contendId
,
4
);
result
.
put
(
"topNegSummary"
,
this
.
getTopArticlesMsg
(
startTime
,
endTime
,
projectId
,
linkedGroupId
,
contendId
,
topNegArticleList
));
}
else
{
result
.
put
(
"topNegSummary"
,
this
.
getTopEventMsg
(
topNegEventList
));
...
...
@@ -428,10 +425,7 @@ public class ReportServiceImpl implements ReportService {
}
result
.
put
(
"spread"
,
lineList
);
//获取稿件的传播峰值
List
<
Long
>
dateList
=
lineList
.
stream
()
.
sorted
((
o1
,
o2
)
->
o2
.
getInteger
(
"normalCount"
).
compareTo
(
o1
.
getInteger
(
"normalCount"
)))
.
map
(
json
->
json
.
getLong
(
"time"
))
.
collect
(
Collectors
.
toList
());
List
<
Long
>
dateList
=
lineList
.
stream
().
sorted
((
o1
,
o2
)
->
o2
.
getInteger
(
"normalCount"
).
compareTo
(
o1
.
getInteger
(
"normalCount"
))).
map
(
json
->
json
.
getLong
(
"time"
)).
collect
(
Collectors
.
toList
());
result
.
put
(
"normalMaxTimes"
,
dateList
.
size
()
>
2
?
dateList
.
subList
(
0
,
3
)
:
dateList
);
if
(
CollectionUtils
.
isNotEmpty
(
dateList
))
{
Long
startTime
=
dateList
.
get
(
0
);
...
...
@@ -485,7 +479,7 @@ public class ReportServiceImpl implements ReportService {
String
projectId
=
UserThreadLocal
.
getProjectId
();
List
<
ReportSettings
>
reports
=
reportSettingsDao
.
findList
(
Query
.
query
(
Criteria
.
where
(
"projectId"
).
is
(
projectId
)));
if
(
reports
.
size
()
>
2
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"获取报告配置信息异常"
)
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"获取报告配置信息异常"
);
}
return
reports
;
}
...
...
@@ -522,16 +516,15 @@ public class ReportServiceImpl implements ReportService {
* @return top事件信息
*/
private
List
<
JSONObject
>
getTopEventMsg
(
List
<
Event
>
topEventList
)
{
return
topEventList
.
stream
()
.
map
(
event
->
{
boolean
hasAnalyze
=
Objects
.
equals
(
event
.
getContendId
(),
Constant
.
PRIMARY_CONTEND_ID
);
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"id"
,
event
.
getId
());
String
title
=
event
.
getTitle
();
jsonObject
.
put
(
"title"
,
title
.
length
()
<=
30
?
title
:
title
.
substring
(
0
,
30
)
+
"..."
);
jsonObject
.
put
(
"hasAnalyze"
,
hasAnalyze
);
return
jsonObject
;
}).
collect
(
Collectors
.
toList
());
return
topEventList
.
stream
().
map
(
event
->
{
boolean
hasAnalyze
=
Objects
.
equals
(
event
.
getContendId
(),
Constant
.
PRIMARY_CONTEND_ID
);
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"id"
,
event
.
getId
());
String
title
=
event
.
getTitle
();
jsonObject
.
put
(
"title"
,
title
.
length
()
<=
30
?
title
:
title
.
substring
(
0
,
30
)
+
"..."
);
jsonObject
.
put
(
"hasAnalyze"
,
hasAnalyze
);
return
jsonObject
;
}).
collect
(
Collectors
.
toList
());
}
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/UserServiceImpl.java
View file @
a17d6c42
...
...
@@ -7,6 +7,7 @@ import com.zhiwei.brandkbs2.dao.UserDao;
import
com.zhiwei.brandkbs2.dao.impl.UserOldDaoImpl
;
import
com.zhiwei.brandkbs2.dao.impl.UserProjectOldDaoImpl
;
import
com.zhiwei.brandkbs2.enmus.RoleEnum
;
import
com.zhiwei.brandkbs2.enmus.response.LoginCodeEnum
;
import
com.zhiwei.brandkbs2.exception.ExceptionCast
;
import
com.zhiwei.brandkbs2.model.CommonCodeEnum
;
import
com.zhiwei.brandkbs2.pojo.User
;
...
...
@@ -119,7 +120,7 @@ public class UserServiceImpl implements UserService {
public
void
addUser
(
UserDTO
userDTO
)
{
if
(
Objects
.
isNull
(
userDTO
.
getRoleId
())
||
userDTO
.
getRoleId
()
<
RoleEnum
.
ADMIN
.
getState
())
{
// 抛出用户权限设置错误异常
ExceptionCast
.
cast
(
CommonCodeEnum
.
INVALID_PARAM
.
message
(
"用户权限设置异常"
)
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
INVALID_PARAM
,
"用户权限设置异常"
);
}
int
roleId
=
UserThreadLocal
.
getRoleId
();
// 只有超管能设置管理员
...
...
@@ -139,7 +140,7 @@ public class UserServiceImpl implements UserService {
}
else
{
if
(
roles
.
stream
().
map
(
UserRole:
:
getProjectId
).
collect
(
Collectors
.
toList
()).
contains
(
userDTO
.
getProjectId
()))
{
// 抛出用户权限设置错误异常
ExceptionCast
.
cast
(
CommonCodeEnum
.
INVALID_PARAM
.
message
(
"用户权限设置重复"
)
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
INVALID_PARAM
,
"用户权限设置重复"
);
}
}
roles
.
add
(
UserRole
.
createFromUserDto
(
userDTO
));
...
...
@@ -209,10 +210,10 @@ public class UserServiceImpl implements UserService {
public
List
<
JSONObject
>
bindUser
(
String
username
,
String
password
)
{
UserOldDaoImpl
.
UserOld
userOld
=
userOldDao
.
findOneByUsernameAndPassword
(
username
,
password
);
if
(
null
==
userOld
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
INVALID_PARAM
.
message
(
"账号密码错误"
)
);
ExceptionCast
.
cast
(
LoginCodeEnum
.
LOGIN_USERNAME_OR_PASSWORD_ERROR
);
}
if
(
userOld
.
isBindUser
())
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
INVALID_PARAM
.
message
(
"该账号已被绑定"
)
);
ExceptionCast
.
cast
(
LoginCodeEnum
.
LOGIN_WX_WITH_USER_ERROR
);
}
User
user
=
userDao
.
findOneById
(
UserThreadLocal
.
getUserId
());
if
(
null
==
user
)
{
...
...
@@ -220,10 +221,6 @@ public class UserServiceImpl implements UserService {
CenterUser
centerUser
=
userInfoClient
.
getUserById
(
Integer
.
parseInt
(
UserThreadLocal
.
getUserId
()));
user
=
User
.
createFromCenterUser
(
centerUser
);
}
List
<
UserProjectOldDaoImpl
.
UserProjectOld
>
userProjects
=
userProjectOldDao
.
findList
(
new
Query
(
Criteria
.
where
(
"userId"
).
is
(
user
.
getId
())));
if
(
userProjects
.
isEmpty
())
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
);
}
// 超级管理员
if
(
userOld
.
isSuperAdmin
())
{
user
.
setSuperAdmin
(
true
);
...
...
@@ -231,6 +228,10 @@ public class UserServiceImpl implements UserService {
userOldDao
.
updateOneByIdWithField
(
userOld
.
getId
(),
Update
.
update
(
"bindUser"
,
true
));
return
projectServiceImpl
.
getProjectListByUser
(
user
,
true
);
}
List
<
UserProjectOldDaoImpl
.
UserProjectOld
>
userProjects
=
userProjectOldDao
.
findList
(
new
Query
(
Criteria
.
where
(
"userId"
).
is
(
user
.
getId
())));
if
(
userProjects
.
isEmpty
())
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
);
}
List
<
UserRole
>
userRoles
=
user
.
getRoles
();
AtomicBoolean
hit
=
new
AtomicBoolean
(
false
);
// 遍历旧关系表
...
...
src/main/resources/application-local.properties
View file @
a17d6c42
...
...
@@ -47,7 +47,7 @@ channel.index.application.name=brandkbs2
hqd.groupAll.url
=
https://sensitive.zhiweidata.com/sensitive/planA/groupAll
#\u6807\u6CE8\u4E2D\u95F4\u4EF6
mark.registry.address
=
zookeeper://192.168.0.11:2181?backup=192.168.0.30:2181,192.168.0.35:2181
mark.provider.group
=
zhiwei-mark-
local-
liuyu
mark.provider.group
=
zhiwei-mark-
test_
liuyu
#\u7528\u6237\u4E2D\u5FC3
auth.center.client.consumer.group
=
zhiwei-auth-dev-liuyu
auth.center.client.registry.address
=
zookeeper://192.168.0.11:2181?backup=192.168.0.30:2181,192.168.0.35:2181
...
...
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