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
1c1bad6b
Commit
1c1bad6b
authored
Sep 06, 2022
by
shenjunjie
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature' into 'dev'
Feature See merge request
!32
parents
898b9f72
cfdc79ca
Show whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
265 additions
and
112 deletions
+265
-112
src/main/java/com/zhiwei/brandkbs2/common/GenericAttribute.java
+3
-1
src/main/java/com/zhiwei/brandkbs2/controller/LoginController.java
+1
-2
src/main/java/com/zhiwei/brandkbs2/controller/app/AppEventController.java
+0
-6
src/main/java/com/zhiwei/brandkbs2/controller/app/AppHotController.java
+1
-1
src/main/java/com/zhiwei/brandkbs2/controller/app/AppSearchController.java
+45
-12
src/main/java/com/zhiwei/brandkbs2/enmus/ChannelEmotion.java
+12
-0
src/main/java/com/zhiwei/brandkbs2/es/ChannelEsDao.java
+1
-1
src/main/java/com/zhiwei/brandkbs2/pojo/AggreeResult.java
+7
-6
src/main/java/com/zhiwei/brandkbs2/pojo/Channel.java
+13
-12
src/main/java/com/zhiwei/brandkbs2/pojo/ChannelRecord.java
+1
-1
src/main/java/com/zhiwei/brandkbs2/pojo/CustomEvent.java
+1
-1
src/main/java/com/zhiwei/brandkbs2/pojo/UserInfo.java
+6
-3
src/main/java/com/zhiwei/brandkbs2/pojo/vo/ChannelVO.java
+74
-0
src/main/java/com/zhiwei/brandkbs2/service/ChannelService.java
+3
-1
src/main/java/com/zhiwei/brandkbs2/service/CommonService.java
+2
-0
src/main/java/com/zhiwei/brandkbs2/service/MarkDataService.java
+1
-1
src/main/java/com/zhiwei/brandkbs2/service/UserService.java
+8
-0
src/main/java/com/zhiwei/brandkbs2/service/impl/ChannelServiceImpl.java
+32
-23
src/main/java/com/zhiwei/brandkbs2/service/impl/CommonServiceImpl.java
+7
-0
src/main/java/com/zhiwei/brandkbs2/service/impl/CustomEventServiceImpl.java
+4
-3
src/main/java/com/zhiwei/brandkbs2/service/impl/EventDataServiceImpl.java
+4
-0
src/main/java/com/zhiwei/brandkbs2/service/impl/EventServiceImpl.java
+1
-1
src/main/java/com/zhiwei/brandkbs2/service/impl/IndexServiceImpl.java
+14
-14
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkDataServiceImpl.java
+18
-22
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkFlowServiceImpl.java
+0
-1
src/main/java/com/zhiwei/brandkbs2/service/impl/UserServiceImpl.java
+6
-0
No files found.
src/main/java/com/zhiwei/brandkbs2/common/GenericAttribute.java
View file @
1c1bad6b
...
...
@@ -33,7 +33,7 @@ public class GenericAttribute {
/**
* es media_type
*/
public
static
final
String
ES_MEDIA_TYPE
=
"media_type"
;
//
public static final String ES_MEDIA_TYPE = "media_type";
// es platform_id
public
static
final
String
ES_PLATFORM_ID
=
"platform_id"
;
// es channel_influence
...
...
@@ -122,6 +122,8 @@ public class GenericAttribute {
public
static
final
String
ROLE_ID
=
"roleId"
;
public
static
final
String
PROJECT_ID
=
"projectId"
;
public
static
final
String
AVATAR_URL
=
"avatarUrl"
;
public
static
final
String
EXPORT_AMOUNT
=
"exportAmount"
;
public
static
final
String
EXPIRED_TIME
=
"expiredTime"
;
// public enum ChannelParam{
// 负面稿件数("negativeArticles"),
...
...
src/main/java/com/zhiwei/brandkbs2/controller/LoginController.java
View file @
1c1bad6b
...
...
@@ -2,7 +2,6 @@ package com.zhiwei.brandkbs2.controller;
import
com.alibaba.fastjson.JSONObject
;
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.ProjectService
;
...
...
@@ -51,7 +50,7 @@ public class LoginController extends BaseController {
@GetMapping
(
"/user/getLoginInfo"
)
@Auth
(
role
=
RoleEnum
.
CUSTOMER
)
public
ResponseResult
getLoginInfo
()
{
return
ResponseResult
.
success
(
User
ThreadLocal
.
get
());
return
ResponseResult
.
success
(
User
Service
.
getLoginInfo
());
}
@ApiOperation
(
"重置绑定关系(本地测试)"
)
...
...
src/main/java/com/zhiwei/brandkbs2/controller/app/AppEventController.java
View file @
1c1bad6b
...
...
@@ -140,12 +140,6 @@ public class AppEventController extends BaseController {
return
ResponseResult
.
success
(
jsonObject
);
}
@ApiOperation
(
"最新事件"
)
@GetMapping
(
"/getLastEventTop"
)
public
ResponseResult
getLastEventTop
()
{
return
ResponseResult
.
success
(
eventService
.
getLastEventTop
(
null
,
5
));
}
@ApiOperation
(
"关联事件"
)
@ApiImplicitParam
(
name
=
"keyword"
,
value
=
"关键词"
,
paramType
=
"query"
,
dataType
=
"String"
)
@GetMapping
(
"/getRelevanceEvent"
)
...
...
src/main/java/com/zhiwei/brandkbs2/controller/app/AppHotController.java
View file @
1c1bad6b
...
...
@@ -118,7 +118,7 @@ public class AppHotController extends BaseController {
@ApiOperation
(
"热点库-最新资讯"
)
@GetMapping
(
"/latestNews"
)
public
ResponseResult
latestNews
(
@RequestParam
(
value
=
"
pageS
ize"
,
defaultValue
=
"5"
)
Integer
size
)
throws
IOException
{
public
ResponseResult
latestNews
(
@RequestParam
(
value
=
"
s
ize"
,
defaultValue
=
"5"
)
Integer
size
)
throws
IOException
{
String
projectId
=
UserThreadLocal
.
getProjectId
();
String
linkedGroupId
=
projectService
.
getProjectVOById
(
projectId
).
getBrandLinkedGroupId
();
Date
endDate
=
new
Date
();
...
...
src/main/java/com/zhiwei/brandkbs2/controller/app/AppSearchController.java
View file @
1c1bad6b
...
...
@@ -7,9 +7,12 @@ import com.zhiwei.brandkbs2.auth.Auth;
import
com.zhiwei.brandkbs2.config.Constant
;
import
com.zhiwei.brandkbs2.enmus.RoleEnum
;
import
com.zhiwei.brandkbs2.model.ResponseResult
;
import
com.zhiwei.brandkbs2.pojo.dto.EventSearchDTO
;
import
com.zhiwei.brandkbs2.pojo.dto.MarkSearchDTO
;
import
com.zhiwei.brandkbs2.pojo.dto.SearchFilterDTO
;
import
com.zhiwei.brandkbs2.service.ChannelService
;
import
com.zhiwei.brandkbs2.service.CommonService
;
import
com.zhiwei.brandkbs2.service.EventService
;
import
com.zhiwei.brandkbs2.service.MarkDataService
;
import
com.zhiwei.brandkbs2.util.Tools
;
import
io.swagger.annotations.Api
;
...
...
@@ -57,13 +60,19 @@ public class AppSearchController {
@Resource
(
name
=
"channelServiceImpl"
)
ChannelService
channelService
;
@Resource
(
name
=
"eventServiceImpl"
)
EventService
eventService
;
@Resource
(
name
=
"commonServiceImpl"
)
CommonService
commonService
;
@ApiOperation
(
"搜索-查热点"
)
@GetMapping
(
"/hot/list"
)
public
ResponseResult
searchHotList
(
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"10"
)
Integer
limit
,
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
value
=
"type"
,
defaultValue
=
"weibo"
)
String
type
,
@RequestParam
(
value
=
"
word"
)
String
word
)
{
ResponseEntity
<
JSONObject
>
jsonObjectResponseEntity
=
restTemplate
.
getForEntity
(
trendsSearchUrl
,
JSONObject
.
class
,
limit
,
page
,
type
,
word
);
@RequestParam
(
value
=
"
keyword"
)
String
key
word
)
{
ResponseEntity
<
JSONObject
>
jsonObjectResponseEntity
=
restTemplate
.
getForEntity
(
trendsSearchUrl
,
JSONObject
.
class
,
limit
,
page
,
type
,
key
word
);
JSONObject
result
=
jsonObjectResponseEntity
.
getBody
();
if
(
Objects
.
nonNull
(
result
))
{
return
ResponseResult
.
success
(
result
);
...
...
@@ -106,46 +115,70 @@ public class AppSearchController {
return
ResponseResult
.
success
(
markDataService
.
searchWholeNetwork
(
dto
));
}
@ApiOperation
(
"舆情列表"
)
@ApiOperation
(
"
搜索-
舆情列表"
)
@PostMapping
(
"/mark/list"
)
public
ResponseResult
getYuqingMarkList
(
@RequestBody
MarkSearchDTO
markSearchDTO
)
{
return
ResponseResult
.
success
(
markDataService
.
getYuqingMarkList
(
markSearchDTO
));
}
@ApiOperation
(
"舆情列表-搜索条件"
)
@ApiOperation
(
"
搜索-
舆情列表-搜索条件"
)
@GetMapping
(
"/mark/list/criteria"
)
public
ResponseResult
getYuqingMarkCriteria
(
@RequestParam
(
required
=
false
)
String
linkedGroupId
)
{
return
ResponseResult
.
success
(
markDataService
.
getYuqingMarkCriteria
(
linkedGroupId
));
}
@ApiOperation
(
"搜索-活跃渠道"
)
@GetMapping
(
"channel/list/active"
)
public
ResponseResult
getActiveChannelList
(
@RequestParam
(
value
=
"size"
,
defaultValue
=
"2"
)
int
size
)
{
Long
[]
timeRangeDay
=
commonService
.
getTimeRangeDay
();
return
ResponseResult
.
success
(
channelService
.
getActiveChannelList
(
"0"
,
null
,
null
,
timeRangeDay
[
0
],
timeRangeDay
[
1
],
size
));
}
@ApiOperation
(
"渠道搜索条件"
)
@ApiOperation
(
"
搜索-
渠道搜索条件"
)
@GetMapping
(
"/channel/getChannelSearchCriteria"
)
public
ResponseResult
getChannelSearchCriteria
()
{
return
ResponseResult
.
success
(
channelService
.
getChannelSearchCriteria
());
}
@ApiOperation
(
"
查渠道 渠道库
"
)
@
Ge
tMapping
(
value
=
"/channel/channelList"
)
@ApiOperation
(
"
搜索-渠道列表
"
)
@
Pos
tMapping
(
value
=
"/channel/channelList"
)
public
ResponseResult
getChannelList
(
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
int
page
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"20"
)
int
pageSize
,
@RequestParam
(
value
=
"keyword"
,
required
=
false
)
String
keyword
,
@RequestParam
(
value
=
"platforms"
,
defaultValue
=
"全部"
)
List
<
String
>
platforms
,
@RequestParam
(
value
=
"emotions"
,
defaultValue
=
""
)
List
<
Integer
>
emotions
,
@RequestParam
(
value
=
"mediaTypes"
,
defaultValue
=
"全部"
)
List
<
String
>
mediaTypes
,
@RequestParam
(
value
=
"platforms"
,
required
=
false
)
List
<
String
>
platforms
,
@RequestParam
(
value
=
"emotions"
,
required
=
false
)
List
<
Integer
>
emotions
,
@RequestParam
(
value
=
"mediaTypes"
,
required
=
false
)
List
<
String
>
mediaTypes
,
@RequestParam
(
value
=
"articlesCount"
,
required
=
false
)
String
[]
articlesCount
,
@RequestParam
(
value
=
"sorter"
,
defaultValue
=
"{\"influence\":\"descend\"}"
)
String
sorter
)
{
return
ResponseResult
.
success
(
channelService
.
getChannelList
(
page
,
pageSize
,
keyword
,
platforms
,
emotions
,
mediaTypes
,
articlesCount
,
sorter
));
}
@ApiOperation
(
"查竞品"
)
@ApiOperation
(
"搜索-热门事件"
)
@GetMapping
(
"/getLastEventTop"
)
public
ResponseResult
getLastEventTop
()
{
return
ResponseResult
.
success
(
eventService
.
getLastEventTop
(
null
,
5
));
}
@ApiOperation
(
"搜索-前台事件库-搜索条件"
)
@GetMapping
(
"/event/list/criteria"
)
public
ResponseResult
getEventsSearchCriteria
()
{
return
ResponseResult
.
success
(
eventService
.
getEventsSearchCriteria
());
}
@ApiOperation
(
"搜索-前台事件库-品牌事件库"
)
@PostMapping
(
"/event/list"
)
public
ResponseResult
getEventList
(
@RequestBody
EventSearchDTO
eventSearchDTO
)
{
return
ResponseResult
.
success
(
eventService
.
getEventList
(
eventSearchDTO
));
}
@ApiOperation
(
"搜索-查竞品"
)
@PostMapping
(
"/contend/list"
)
public
ResponseResult
getContendSearchList
(
@RequestBody
MarkSearchDTO
markSearchDTO
)
{
return
ResponseResult
.
success
(
markDataService
.
getContendSearchList
(
markSearchDTO
));
}
@ApiOperation
(
"查竞品-搜索条件"
)
@ApiOperation
(
"
搜索-
查竞品-搜索条件"
)
@GetMapping
(
"/contend/list/criteria"
)
public
ResponseResult
getContendSearchCriteria
(
@RequestParam
(
required
=
false
)
String
contendId
)
{
return
ResponseResult
.
success
(
markDataService
.
getContendSearchCriteria
(
contendId
));
...
...
src/main/java/com/zhiwei/brandkbs2/enmus/ChannelEmotion.java
View file @
1c1bad6b
...
...
@@ -54,4 +54,16 @@ public enum ChannelEmotion {
throw
new
IllegalArgumentException
(
"不识别的类型:"
+
state
);
}
public
static
int
getEmotionRank
(
Double
emotionIndex
)
{
int
rank
;
if
(
emotionIndex
>=
80
)
{
rank
=
1
;
}
else
if
(
emotionIndex
>=
60
)
{
rank
=
2
;
}
else
{
rank
=
3
;
}
return
rank
;
}
}
src/main/java/com/zhiwei/brandkbs2/es/ChannelEsDao.java
View file @
1c1bad6b
...
...
@@ -73,7 +73,7 @@ public class ChannelEsDao extends EsClientDao {
BulkRequest
bulkRequest
=
new
BulkRequest
();
Long
startTime
=
null
;
Long
endTime
=
null
;
for
(
List
<
ChannelRecord
>
records
:
ListUtils
.
partition
(
channelRecords
,
100
0
))
{
for
(
List
<
ChannelRecord
>
records
:
ListUtils
.
partition
(
channelRecords
,
100
))
{
for
(
ChannelRecord
record
:
records
)
{
startTime
=
null
==
startTime
?
record
.
getRangeStartTime
()
:
Math
.
min
(
startTime
,
record
.
getRangeStartTime
());
endTime
=
null
==
endTime
?
record
.
getRangeEndTime
()
:
Math
.
max
(
endTime
,
record
.
getRangeEndTime
());
...
...
src/main/java/com/zhiwei/brandkbs2/pojo/AggreeResult.java
View file @
1c1bad6b
...
...
@@ -2,6 +2,7 @@ package com.zhiwei.brandkbs2.pojo;
import
com.alibaba.fastjson.JSONObject
;
import
com.zhiwei.brandkbs2.common.GenericAttribute
;
import
com.zhiwei.brandkbs2.common.GlobalPojo
;
import
com.zhiwei.brandkbs2.util.Tools
;
import
lombok.Getter
;
import
lombok.Setter
;
...
...
@@ -82,16 +83,16 @@ public class AggreeResult extends AbstractBaseMongo {
*/
private
boolean
isFather
;
public
static
AggreeResult
createFather
(
JSONObject
json
,
String
taskId
,
Integer
aggreeSize
)
{
AggreeResult
aggreeResult
=
getInstance
(
json
,
taskId
);
public
static
AggreeResult
createFather
(
JSONObject
json
,
String
taskId
,
String
projectId
,
Integer
aggreeSize
)
{
AggreeResult
aggreeResult
=
getInstance
(
json
,
taskId
,
projectId
);
aggreeResult
.
setFather
(
true
);
aggreeResult
.
setAggreeSize
(
aggreeSize
);
aggreeResult
.
setCTime
(
System
.
currentTimeMillis
());
return
aggreeResult
;
}
public
static
AggreeResult
createSon
(
JSONObject
json
,
String
taskId
,
String
fatherId
,
String
fatherTitle
)
{
AggreeResult
aggreeResult
=
getInstance
(
json
,
taskId
);
public
static
AggreeResult
createSon
(
JSONObject
json
,
String
taskId
,
String
projectId
,
String
fatherId
,
String
fatherTitle
)
{
AggreeResult
aggreeResult
=
getInstance
(
json
,
taskId
,
projectId
);
aggreeResult
.
setFatherId
(
fatherId
);
// 使用父聚合标题
aggreeResult
.
setAggreeTitle
(
fatherTitle
);
...
...
@@ -99,13 +100,13 @@ public class AggreeResult extends AbstractBaseMongo {
return
aggreeResult
;
}
private
static
AggreeResult
getInstance
(
JSONObject
json
,
String
taskId
)
{
private
static
AggreeResult
getInstance
(
JSONObject
json
,
String
taskId
,
String
projectId
)
{
AggreeResult
aggreeResult
=
new
AggreeResult
();
aggreeResult
.
setTaskId
(
taskId
);
BaseMap
baseMap
=
Tools
.
getBaseFromEsMap
(
json
);
aggreeResult
.
setTime
(
baseMap
.
getTime
());
aggreeResult
.
setPlatformId
(
json
.
getString
(
GenericAttribute
.
ES_PLATFORM_ID
));
String
mediaType
=
json
.
getString
(
GenericAttribute
.
ES_MEDIA_TYPE
);
String
mediaType
=
GlobalPojo
.
getMediaType
(
projectId
,
baseMap
.
getPlatform
(),
baseMap
.
getSource
()
);
if
(
StringUtils
.
isNotEmpty
(
mediaType
))
{
aggreeResult
.
setMediaTypes
(
Arrays
.
asList
(
mediaType
.
split
(
","
)));
}
...
...
src/main/java/com/zhiwei/brandkbs2/pojo/Channel.java
View file @
1c1bad6b
package
com
.
zhiwei
.
brandkbs2
.
pojo
;
import
com.zhiwei.brandkbs2.enmus.ChannelEmotion
;
import
com.zhiwei.brandkbs2.util.Tools
;
import
lombok.Getter
;
import
lombok.Setter
;
...
...
@@ -63,6 +62,8 @@ public class Channel extends ChannelIndex {
*/
private
Long
collectTime
;
private
Double
influence
;
public
void
setLastTime
(
Long
lastTime
)
{
if
(
null
==
this
.
lastTime
||
this
.
lastTime
<
lastTime
)
{
this
.
lastTime
=
lastTime
;
...
...
@@ -101,17 +102,17 @@ public class Channel extends ChannelIndex {
channel
.
setLastTime
(
record
.
getLastTime
());
channel
.
setRecord
(
record
);
// TODO 调性随机分配
double
random
=
Math
.
random
();
if
(
random
<
0.3
)
{
channel
.
setEmotion
(
ChannelEmotion
.
POSITIVE
.
getState
());
}
else
if
(
random
<
0.6
)
{
channel
.
setEmotion
(
ChannelEmotion
.
NEGATIVE
.
getState
());
}
else
{
channel
.
setEmotion
(
ChannelEmotion
.
NEUTRAL
.
getState
());
}
// TODO 情感指数随机分配
channel
.
setEmotionIndex
(
Math
.
random
()
*
100
);
//
// TODO 调性随机分配
//
double random = Math.random();
//
if (random < 0.3) {
//
channel.setEmotion(ChannelEmotion.POSITIVE.getState());
//
} else if (random < 0.6) {
//
channel.setEmotion(ChannelEmotion.NEGATIVE.getState());
//
} else {
//
channel.setEmotion(ChannelEmotion.NEUTRAL.getState());
//
}
//
// TODO 情感指数随机分配
//
channel.setEmotionIndex(Math.random() * 100);
return
channel
;
}
...
...
src/main/java/com/zhiwei/brandkbs2/pojo/ChannelRecord.java
View file @
1c1bad6b
...
...
@@ -145,7 +145,7 @@ public class ChannelRecord {
Long
lastTime
=
templateRecord
.
getLastTime
();
List
<
ChannelIndex
.
Article
>
articles
=
templateRecord
.
getArticles
();
int
shards
=
0
;
// 防止数据量过大无法存储,故按
10
0 拆分
// 防止数据量过大无法存储,故按
5
0 拆分
for
(
List
<
ChannelIndex
.
Article
>
partList
:
Lists
.
partition
(
articles
,
SHARDS_LIMIT
))
{
ChannelRecord
channelRecord
=
new
ChannelRecord
(
rangeStartTime
,
rangeEndTime
,
entry
.
getKey
(),
entry
.
getValue
());
// 保留最近发文时间,更新partList,articleCount和shards
...
...
src/main/java/com/zhiwei/brandkbs2/pojo/CustomEvent.java
View file @
1c1bad6b
...
...
@@ -48,7 +48,7 @@ public class CustomEvent extends AbstractBaseMongo {
/**
* 关联项目组ID
*/
private
String
linkedGroup
Id
;
private
String
contend
Id
;
/**
* 将自定义事件传输对象转换为自定义事件对象
...
...
src/main/java/com/zhiwei/brandkbs2/pojo/UserInfo.java
View file @
1c1bad6b
...
...
@@ -19,15 +19,16 @@ public class UserInfo {
private
String
userId
;
private
Integer
roleId
;
private
String
projectId
;
private
Integer
exportAmount
;
private
String
avatarUrl
;
private
Integer
exportAmount
;
private
Long
expiredTime
;
public
UserInfo
setUserId
(
String
userId
){
public
UserInfo
setUserId
(
String
userId
)
{
this
.
userId
=
userId
;
return
this
;
}
public
UserInfo
setProjectId
(
String
projectId
){
public
UserInfo
setProjectId
(
String
projectId
)
{
this
.
projectId
=
projectId
;
return
this
;
}
...
...
@@ -39,6 +40,8 @@ public class UserInfo {
res
.
put
(
GenericAttribute
.
USER_ID
,
this
.
userId
);
res
.
put
(
GenericAttribute
.
ROLE_ID
,
this
.
roleId
);
res
.
put
(
GenericAttribute
.
AVATAR_URL
,
this
.
avatarUrl
);
res
.
put
(
GenericAttribute
.
EXPORT_AMOUNT
,
this
.
exportAmount
);
res
.
put
(
GenericAttribute
.
EXPIRED_TIME
,
this
.
expiredTime
);
return
res
;
}
...
...
src/main/java/com/zhiwei/brandkbs2/pojo/vo/ChannelVO.java
0 → 100644
View file @
1c1bad6b
package
com
.
zhiwei
.
brandkbs2
.
pojo
.
vo
;
import
com.alibaba.fastjson.JSONObject
;
import
com.zhiwei.brandkbs2.common.GlobalPojo
;
import
com.zhiwei.brandkbs2.enmus.ChannelEmotion
;
import
com.zhiwei.brandkbs2.pojo.Channel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.ToString
;
@Data
@ToString
public
class
ChannelVO
{
@ApiModelProperty
(
value
=
"id"
)
private
String
id
;
@ApiModelProperty
(
value
=
"渠道"
)
private
String
source
;
@ApiModelProperty
(
value
=
"真实来源"
)
private
String
realSource
;
@ApiModelProperty
(
value
=
"情感倾向"
)
private
String
emotion
;
@ApiModelProperty
(
value
=
"情感倾向等级"
)
private
Integer
emotionRank
;
@ApiModelProperty
(
value
=
"头像地址"
)
private
String
avatarUrl
;
@ApiModelProperty
(
value
=
"参与事件数"
)
private
Long
eventCount
;
@ApiModelProperty
(
value
=
"发布稿件数"
)
private
Long
articleCount
;
@ApiModelProperty
(
value
=
"影响力"
)
private
Double
influence
;
@ApiModelProperty
(
value
=
"媒体类型标签"
)
private
String
mediaType
;
@ApiModelProperty
(
value
=
"最近发文链接"
)
private
JSONObject
lastArticle
;
public
static
ChannelVO
createFromChannelInfo
(
JSONObject
channelInfo
,
String
projectId
)
{
Channel
channel
=
(
Channel
)
channelInfo
.
get
(
"channel"
);
JSONObject
lastArticle
=
channelInfo
.
getJSONObject
(
"lastArticle"
);
return
createFromChannelVO
(
channel
,
projectId
,
lastArticle
);
}
public
static
ChannelVO
createFromChannelVO
(
Channel
channel
,
String
projectId
,
JSONObject
lastArticle
)
{
ChannelVO
channelVO
=
new
ChannelVO
();
channelVO
.
setId
(
channel
.
getId
());
channelVO
.
setSource
(
channel
.
getSource
());
channelVO
.
setRealSource
(
channel
.
getRealSource
());
channelVO
.
setEmotion
(
ChannelEmotion
.
getNameFromState
(
channel
.
getEmotion
()));
channelVO
.
setEmotionRank
(
ChannelEmotion
.
getEmotionRank
(
channel
.
getEmotionIndex
()));
channelVO
.
setAvatarUrl
(
channel
.
getAvatarUrl
());
channelVO
.
setEventCount
(
channel
.
getEventCount
());
channelVO
.
setArticleCount
(
channel
.
getArticleCount
());
// TODO influence实现
channelVO
.
setInfluence
(
null
);
String
mediaType
=
GlobalPojo
.
getMediaType
(
projectId
,
channel
.
getPlatform
(),
channel
.
getSource
());
if
(
null
!=
mediaType
)
{
channelVO
.
setMediaType
(
mediaType
.
replaceAll
(
","
,
" "
));
}
channelVO
.
setLastArticle
(
lastArticle
);
return
channelVO
;
}
}
src/main/java/com/zhiwei/brandkbs2/service/ChannelService.java
View file @
1c1bad6b
...
...
@@ -9,6 +9,7 @@ import com.zhiwei.brandkbs2.pojo.Channel;
import
com.zhiwei.brandkbs2.pojo.dto.ChannelDTO
;
import
com.zhiwei.brandkbs2.pojo.dto.ExportAppChannelEventDTO
;
import
com.zhiwei.brandkbs2.pojo.vo.ChannelListVO
;
import
com.zhiwei.brandkbs2.pojo.vo.ChannelVO
;
import
com.zhiwei.brandkbs2.pojo.vo.PageVO
;
import
java.util.List
;
...
...
@@ -258,6 +259,7 @@ public interface ChannelService {
*/
JSONObject
getChannelSearchCriteria
();
PageVO
<
JSONObject
>
getChannelList
(
int
page
,
int
pageSize
,
String
keyword
,
List
<
String
>
platforms
,
List
<
Integer
>
emotions
,
List
<
String
>
mediaTypes
,
String
[]
articlesCount
,
String
sorter
);
PageVO
<
ChannelVO
>
getChannelList
(
int
page
,
int
pageSize
,
String
keyword
,
List
<
String
>
platforms
,
List
<
Integer
>
emotions
,
List
<
String
>
mediaTypes
,
String
[]
articlesCount
,
String
sorter
);
}
src/main/java/com/zhiwei/brandkbs2/service/CommonService.java
View file @
1c1bad6b
...
...
@@ -52,4 +52,6 @@ public interface CommonService {
Long
[]
getTimeRangeWeek
();
Long
[]
getTimeRangeDay
();
}
src/main/java/com/zhiwei/brandkbs2/service/MarkDataService.java
View file @
1c1bad6b
...
...
@@ -264,6 +264,6 @@ public interface MarkDataService {
*/
List
<
Map
<
String
,
Object
>>
getEsTopSource
(
Long
startTime
,
Long
endTime
,
String
projectId
,
String
linkedGroupId
,
String
contendId
,
String
emotion
,
int
size
)
throws
IOException
;
String
getLastMarkUrl
(
String
projectId
,
String
linkedGroupId
,
String
contendId
,
String
platform
,
String
realSource
,
String
source
);
JSONObject
getLastMarkData
(
String
projectId
,
String
linkedGroupId
,
String
contendId
,
String
platform
,
String
realSource
,
String
source
);
}
src/main/java/com/zhiwei/brandkbs2/service/UserService.java
View file @
1c1bad6b
...
...
@@ -6,6 +6,7 @@ import com.zhiwei.brandkbs2.pojo.dto.UserDTO;
import
com.zhiwei.brandkbs2.pojo.vo.PageVO
;
import
java.util.List
;
import
java.util.Map
;
/**
* @ClassName: UserService
...
...
@@ -23,6 +24,13 @@ public interface UserService {
UserInfo
login
();
/**
* 获取登录信息
*
* @return
*/
Map
<
String
,
Object
>
getLoginInfo
();
/**
* 查询用户信息
*
* @param userId
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/ChannelServiceImpl.java
View file @
1c1bad6b
...
...
@@ -22,6 +22,7 @@ import com.zhiwei.brandkbs2.pojo.*;
import
com.zhiwei.brandkbs2.pojo.dto.ChannelDTO
;
import
com.zhiwei.brandkbs2.pojo.dto.ExportAppChannelEventDTO
;
import
com.zhiwei.brandkbs2.pojo.vo.ChannelListVO
;
import
com.zhiwei.brandkbs2.pojo.vo.ChannelVO
;
import
com.zhiwei.brandkbs2.pojo.vo.PageVO
;
import
com.zhiwei.brandkbs2.service.ChannelService
;
import
com.zhiwei.brandkbs2.service.CommonService
;
...
...
@@ -781,13 +782,18 @@ public class ChannelServiceImpl implements ChannelService {
// 平台
result
.
put
(
"platformList"
,
commonService
.
getQbjcPlatform
(
"id"
,
"name"
));
//渠道倾向
List
<
EmotionEnum
>
emotionList
=
Arrays
.
asList
(
EmotionEnum
.
ALL
,
EmotionEnum
.
POSITIVE
,
EmotionEnum
.
NEUTRAL
,
EmotionEnum
.
NEGATIVE
);
result
.
put
(
"emotionList"
,
emotionList
.
stream
().
map
(
emotion
->
{
List
<
ChannelEmotion
>
emotionList
=
Arrays
.
asList
(
ChannelEmotion
.
POSITIVE
,
ChannelEmotion
.
NEUTRAL
,
ChannelEmotion
.
NEGATIVE
);
List
<
JSONObject
>
collect
=
emotionList
.
stream
().
map
(
emotion
->
{
JSONObject
json
=
new
JSONObject
();
json
.
put
(
"id"
,
emotion
.
getState
());
json
.
put
(
"name"
,
emotion
.
getName
());
return
json
;
}).
collect
(
Collectors
.
toList
()));
}).
collect
(
Collectors
.
toList
());
JSONObject
allEmotion
=
new
JSONObject
();
allEmotion
.
put
(
"id"
,
-
1
);
allEmotion
.
put
(
"name"
,
"全部"
);
collect
.
add
(
0
,
allEmotion
);
result
.
put
(
"emotionList"
,
collect
);
//渠道级别
List
<
String
>
mediaTypeList
=
ImportantChannelEnum
.
getAllTagExceptSpec
();
mediaTypeList
.
add
(
0
,
"全部"
);
...
...
@@ -798,36 +804,47 @@ public class ChannelServiceImpl implements ChannelService {
}
@Override
public
PageVO
<
JSONObject
>
getChannelList
(
int
page
,
int
pageSize
,
String
keyword
,
List
<
String
>
platforms
,
List
<
Integer
>
emotions
,
List
<
String
>
mediaTypes
,
public
PageVO
<
ChannelVO
>
getChannelList
(
int
page
,
int
pageSize
,
String
keyword
,
List
<
String
>
platforms
,
List
<
Integer
>
emotions
,
List
<
String
>
mediaTypes
,
String
[]
articlesCount
,
String
sorter
)
{
String
projectId
=
UserThreadLocal
.
getProjectId
();
String
contendId
=
"0"
;
String
linkedGroupId
=
projectService
.
getProjectByContendId
(
projectId
,
contendId
).
getBrandLinkedGroupId
();
Query
query
=
new
Query
(
Criteria
.
where
(
"projectId"
).
is
(
projectId
).
and
(
"contendId"
).
is
(
contendId
));
channelDao
.
addKeywordFuzz
(
query
,
keyword
,
"source"
);
if
(!
platforms
.
contains
(
"全部"
))
{
if
(!
(
null
==
platforms
||
platforms
.
contains
(
"全部"
)
))
{
query
.
addCriteria
(
Criteria
.
where
(
"platform"
).
in
(
platforms
));
}
if
(!
emotions
.
contains
(-
1
))
{
if
(!
(
null
==
emotions
||
emotions
.
contains
(-
1
)
))
{
query
.
addCriteria
(
Criteria
.
where
(
"emotion"
).
in
(
emotions
));
}
if
(!
mediaTypes
.
contains
(
"全部"
))
{
if
(!
(
null
==
mediaTypes
||
mediaTypes
.
contains
(
"全部"
)
))
{
// TODO
}
if
(
null
!=
articlesCount
)
{
query
.
addCriteria
(
Criteria
.
where
(
"articleCount"
).
gte
(
articlesCount
[
0
]).
lt
(
articlesCount
[
1
]));
}
mongoUtil
.
start
(
page
,
pageSize
,
query
);
long
total
=
channelDao
.
count
(
query
);
channelDao
.
addSort
(
query
,
sorter
);
List
<
Channel
>
channelList
=
channelDao
.
findList
(
query
);
List
<
JSONObject
>
resultList
=
channelList
.
stream
().
map
(
channel
->
{
List
<
CompletableFuture
<
JSONObject
>>
futureList
=
channelList
.
stream
().
map
(
channel
->
CompletableFuture
.
supplyAsync
(()
->
{
JSONObject
result
=
new
JSONObject
();
result
.
put
(
"channelInfo"
,
channel
);
result
.
put
(
"lastArticle"
,
markDataService
.
getLastMarkUrl
(
projectId
,
linkedGroupId
,
contendId
,
channel
.
getPlatform
(),
channel
.
getRealSource
(),
result
.
put
(
"id"
,
channel
.
getId
());
result
.
put
(
"channel"
,
channel
);
result
.
put
(
"lastArticle"
,
markDataService
.
getLastMarkData
(
projectId
,
linkedGroupId
,
contendId
,
channel
.
getPlatform
(),
channel
.
getRealSource
(),
channel
.
getSource
()));
return
result
;
}).
collect
(
Collectors
.
toList
());
return
PageVO
.
createPageVo
(
total
,
page
,
pageSize
,
resultList
);
},
esSearchExecutor
)).
collect
(
Collectors
.
toList
());
CompletableFuture
.
allOf
(
futureList
.
toArray
(
new
CompletableFuture
[
0
])).
join
();
Map
<
String
,
JSONObject
>
idMap
=
futureList
.
stream
().
map
(
CompletableFuture:
:
join
).
collect
(
Collectors
.
toMap
(
json
->
json
.
getString
(
"id"
),
a
->
a
));
// List<JSONObject> resultList = channelList.stream().map(channel -> {
// JSONObject result = new JSONObject();
// result.put("channelInfo", channel);
// result.put("lastArticle", markDataService.getLastMarkUrl(projectId, linkedGroupId, contendId, channel.getPlatform(), channel.getRealSource(), channel.getSource()));
// return result;
// }).collect(Collectors.toList());
return
PageVO
.
createPageVo
(
total
,
page
,
pageSize
,
channelList
.
stream
().
map
(
channel
->
ChannelVO
.
createFromChannelInfo
(
idMap
.
get
(
channel
.
getId
()),
projectId
)).
collect
(
Collectors
.
toList
()));
}
private
List
<
JSONObject
>
getArticleList
()
{
...
...
@@ -838,7 +855,7 @@ public class ChannelServiceImpl implements ChannelService {
if
(
"全部"
.
equals
(
name
))
{
json
.
put
(
"value"
,
null
);
}
else
{
String
[]
split
=
name
.
substring
(
name
.
length
()
-
1
).
split
(
"-"
);
String
[]
split
=
name
.
substring
(
0
,
name
.
length
()
-
1
).
split
(
"-"
);
json
.
put
(
"value"
,
new
Long
[]{
Long
.
parseLong
(
split
[
0
]),
Long
.
parseLong
(
split
[
1
])});
}
res
.
add
(
json
);
...
...
@@ -1424,7 +1441,7 @@ public class ChannelServiceImpl implements ChannelService {
private
String
[]
getTitleAndUrlById
(
String
id
)
{
try
{
BaseMap
baseMap
=
Tools
.
getBaseFromEsMap
(
esClientDao
.
searchById
(
id
));
return
new
String
[]{
baseMap
.
getTitle
(),
baseMap
.
getUrl
()};
return
new
String
[]{
baseMap
.
getTitle
NullOptionalContent
(),
baseMap
.
getUrl
()};
}
catch
(
IOException
ignored
)
{
}
return
new
String
[]{
null
,
null
};
...
...
@@ -1465,15 +1482,7 @@ public class ChannelServiceImpl implements ChannelService {
}
private
String
getChannelEmotionRank
(
Double
emotionIndex
,
int
emotion
)
{
int
rank
;
if
(
emotionIndex
>=
80
)
{
rank
=
1
;
}
else
if
(
emotionIndex
>=
60
)
{
rank
=
2
;
}
else
{
rank
=
3
;
}
return
rank
+
"级"
+
ChannelEmotion
.
getNameFromState
(
emotion
);
return
ChannelEmotion
.
getEmotionRank
(
emotionIndex
)
+
"级"
+
ChannelEmotion
.
getNameFromState
(
emotion
);
}
}
src/main/java/com/zhiwei/brandkbs2/service/impl/CommonServiceImpl.java
View file @
1c1bad6b
...
...
@@ -110,4 +110,11 @@ public class CommonServiceImpl implements CommonService {
return
new
Long
[]{
startTime
,
endTime
};
}
@Override
public
Long
[]
getTimeRangeDay
()
{
long
endTime
=
DateUtils
.
addDays
(
Tools
.
truncDate
(
new
Date
(),
Constant
.
DAY_PATTERN
),
1
).
getTime
();
long
startTime
=
DateUtils
.
addDays
(
new
Date
(
endTime
),
-
1
).
getTime
();
return
new
Long
[]{
startTime
,
endTime
};
}
}
src/main/java/com/zhiwei/brandkbs2/service/impl/CustomEventServiceImpl.java
View file @
1c1bad6b
...
...
@@ -118,11 +118,11 @@ public class CustomEventServiceImpl implements CustomEventService {
@Override
public
void
saveCustomEvent
(
CustomEventDTO
customEventDTO
)
{
String
projectId
=
UserThreadLocal
.
getProjectId
();
String
linkedGroupId
=
projectService
.
getProjectVOById
(
projectId
).
getBrandLinkedGroupId
()
;
String
contendId
=
"0"
;
CustomEvent
customEvent
=
CustomEvent
.
creatFromCustomEventDTO
(
customEventDTO
);
customEvent
.
setUpdateTime
(
System
.
currentTimeMillis
());
customEvent
.
setProjectId
(
projectId
);
customEvent
.
set
LinkedGroupId
(
linkedGroup
Id
);
customEvent
.
set
ContendId
(
contend
Id
);
customEventDao
.
insertOneWithoutId
(
customEvent
);
this
.
analyzeCustomEventData
(
customEvent
);
}
...
...
@@ -293,8 +293,9 @@ public class CustomEventServiceImpl implements CustomEventService {
customEventDao
.
updateOneByIdWithField
(
eventId
,
Update
.
update
(
"status"
,
false
));
ApplicationProjectListener
.
getThreadPool
().
execute
(()
->
{
try
{
String
linkedGroupId
=
projectService
.
getProjectByContendId
(
customEvent
.
getProjectId
(),
customEvent
.
getContendId
()).
getBrandLinkedGroupId
();
//查询符合该事件时间段的所有稿件信息
List
<
JSONObject
>
articles
=
markDataService
.
searchMarkDataByTime
(
customEvent
.
getProjectId
(),
customEvent
.
getLinkedGroupId
(),
"0"
,
List
<
JSONObject
>
articles
=
markDataService
.
searchMarkDataByTime
(
customEvent
.
getProjectId
(),
linkedGroupId
,
customEvent
.
getContendId
()
,
customEvent
.
getStartTime
(),
customEvent
.
getEndTime
());
log
.
info
(
"自定义事件:{} 查询到符合该事件时间段的所有稿件数{}个"
,
eventId
,
articles
.
size
());
List
<
String
>
keywords
=
customEvent
.
getKeywords
();
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/EventDataServiceImpl.java
View file @
1c1bad6b
...
...
@@ -224,6 +224,10 @@ public class EventDataServiceImpl implements EventDataService {
details
.
add
(
entry
.
getKey
());
details
.
add
(
new
BigDecimal
((
double
)
(
entry
.
getValue
().
get
()
*
100
)
/
sum
).
setScale
(
2
,
RoundingMode
.
UP
).
toString
());
});
if
(
details
.
size
()
==
2
)
{
details
.
add
(
"其他"
);
details
.
add
(
"0.00"
);
}
details
.
add
(
top8Titles
.
get
(
0
).
getKey
());
details
.
add
(
String
.
valueOf
(
top8Titles
.
get
(
0
).
getValue
().
size
()));
return
details
;
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/EventServiceImpl.java
View file @
1c1bad6b
...
...
@@ -546,11 +546,11 @@ public class EventServiceImpl implements EventService {
}
query
.
addCriteria
(
volumeCriteria
);
}
mongoUtil
.
start
(
eventSearchDTO
.
getPage
(),
eventSearchDTO
.
getPageSize
(),
query
);
// 总数
long
total
=
eventDao
.
count
(
query
);
// 排序
eventDao
.
addSort
(
query
,
eventSearchDTO
.
getSorter
().
toJSONString
());
mongoUtil
.
start
(
eventSearchDTO
.
getPage
(),
eventSearchDTO
.
getPageSize
(),
query
);
// 数据
List
<
Event
>
eventList
=
eventDao
.
findList
(
query
);
// vo封装
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/IndexServiceImpl.java
View file @
1c1bad6b
...
...
@@ -432,23 +432,23 @@ public class IndexServiceImpl implements IndexService {
private
JSONObject
getTopSource
(
long
startTime
,
long
endTime
,
String
projectId
,
String
linkedGroupId
,
String
contendId
)
throws
IOException
{
JSONObject
result
=
new
JSONObject
();
// TODO 等待线上es数据格式调整
//
List<Map<String, Object>> positiveList = markDataService.getEsTopSource(startTime, endTime, projectId, linkedGroupId, contendId, EmotionEnum.POSITIVE.getName(), 3);
//
List<Map<String, Object>> negativeList = markDataService.getEsTopSource(startTime, endTime, projectId, linkedGroupId, contendId, EmotionEnum.NEGATIVE.getName(), 1);
result
.
put
(
"positiveList"
,
tempTopSource
()
);
result
.
put
(
"negativeList"
,
tempTopSource
()
);
List
<
Map
<
String
,
Object
>>
positiveList
=
markDataService
.
getEsTopSource
(
startTime
,
endTime
,
projectId
,
linkedGroupId
,
contendId
,
EmotionEnum
.
POSITIVE
.
getName
(),
3
);
List
<
Map
<
String
,
Object
>>
negativeList
=
markDataService
.
getEsTopSource
(
startTime
,
endTime
,
projectId
,
linkedGroupId
,
contendId
,
EmotionEnum
.
NEGATIVE
.
getName
(),
1
);
result
.
put
(
"positiveList"
,
positiveList
);
result
.
put
(
"negativeList"
,
negativeList
);
return
result
;
}
private
List
<
Map
<
String
,
Object
>>
tempTopSource
()
{
List
<
Map
<
String
,
Object
>>
channelResultList
=
new
ArrayList
<>();
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
result
.
put
(
"id"
,
"testId"
);
result
.
put
(
"source"
,
"source"
);
result
.
put
(
"platform"
,
"微信"
);
result
.
put
(
"num"
,
"1"
);
channelResultList
.
add
(
result
);
return
channelResultList
;
}
//
private List<Map<String, Object>> tempTopSource() {
//
List<Map<String, Object>> channelResultList = new ArrayList<>();
//
Map<String, Object> result = new HashMap<>();
//
result.put("id", "testId");
//
result.put("source", "source");
//
result.put("platform", "微信");
//
result.put("num", "1");
//
channelResultList.add(result);
//
return channelResultList;
//
}
/**
* 传播趋势
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkDataServiceImpl.java
View file @
1c1bad6b
...
...
@@ -190,7 +190,7 @@ public class MarkDataServiceImpl implements MarkDataService {
List
<
List
<
JSONObject
>>
groupList
=
aggregation
(
hitsAndCounts
.
getLeft
(),
"id"
);
log
.
info
(
"taskId:{},聚合完成,聚合组:{}个"
,
uuid
,
groupList
.
size
());
// 入mongo缓存
cacheAggreeResult
(
groupList
,
uuid
);
cacheAggreeResult
(
groupList
,
uuid
,
projectId
);
redisUtil
.
setExpire
(
redisKey
,
"100"
);
}
catch
(
Exception
e
)
{
log
.
error
(
"generateYuqingMarkAggreeList-"
,
e
);
...
...
@@ -279,11 +279,11 @@ public class MarkDataServiceImpl implements MarkDataService {
query
.
addCriteria
((
orCriteria
.
orOperator
(
tagCriteria
.
toArray
(
new
Criteria
[
0
]))));
}
// 关键词模糊查询
aggreeResultDao
.
addKeywordFuzz
(
query
,
dto
.
getKeyword
(),
"
aggreeTitl
e"
);
aggreeResultDao
.
addKeywordFuzz
(
query
,
dto
.
getKeyword
(),
"
data.sourc
e"
);
return
query
;
}
private
void
cacheAggreeResult
(
List
<
List
<
JSONObject
>>
groupList
,
String
taskId
)
{
private
void
cacheAggreeResult
(
List
<
List
<
JSONObject
>>
groupList
,
String
taskId
,
String
projectId
)
{
int
count
=
0
;
int
percent
;
for
(
List
<
JSONObject
>
list
:
groupList
)
{
...
...
@@ -294,12 +294,12 @@ public class MarkDataServiceImpl implements MarkDataService {
AggreeResult
aggreeResult
;
// 父聚合处理
if
(
i
==
0
)
{
aggreeResult
=
AggreeResult
.
createFather
(
json
,
taskId
,
list
.
size
());
aggreeResult
=
AggreeResult
.
createFather
(
json
,
taskId
,
projectId
,
list
.
size
());
aggreeResultDao
.
insertOneWithoutId
(
aggreeResult
);
fatherId
=
aggreeResult
.
getId
();
fatherTitle
=
aggreeResult
.
getAggreeTitle
();
}
else
{
aggreeResult
=
AggreeResult
.
createSon
(
json
,
taskId
,
fatherId
,
fatherTitle
);
aggreeResult
=
AggreeResult
.
createSon
(
json
,
taskId
,
projectId
,
fatherId
,
fatherTitle
);
aggreeResultDao
.
insertOneWithoutId
(
aggreeResult
);
}
}
...
...
@@ -587,7 +587,8 @@ public class MarkDataServiceImpl implements MarkDataService {
// keyword
if
(
StringUtils
.
isNotEmpty
(
dto
.
getKeyword
()))
{
// Query
String
[]
fieldSearch
=
"标题"
.
equals
(
dto
.
getSearchField
())
?
new
String
[]{
GenericAttribute
.
ES_IND_TITLE
}
:
new
String
[]{
GenericAttribute
.
ES_IND_FULL_TEXT
};
String
[]
fieldSearch
=
"仅标题"
.
equals
(
dto
.
getSearchField
())
?
new
String
[]{
GenericAttribute
.
ES_IND_TITLE
}
:
new
String
[]{
GenericAttribute
.
ES_IND_FULL_TEXT
};
postFilter
.
must
(
EsQueryTools
.
assembleNormalKeywordQuery
(
dto
.
getKeyword
(),
fieldSearch
));
}
// sourceKeyword
...
...
@@ -973,7 +974,8 @@ public class MarkDataServiceImpl implements MarkDataService {
// keyword
if
(
StringUtils
.
isNotEmpty
(
dto
.
getKeyword
()))
{
// Query
String
[]
fieldSearch
=
"标题"
.
equals
(
dto
.
getSearchField
())
?
new
String
[]{
GenericAttribute
.
ES_IND_TITLE
}
:
new
String
[]{
GenericAttribute
.
ES_IND_FULL_TEXT
};
String
[]
fieldSearch
=
"仅标题"
.
equals
(
dto
.
getSearchField
())
?
new
String
[]{
GenericAttribute
.
ES_IND_TITLE
}
:
new
String
[]{
GenericAttribute
.
ES_IND_FULL_TEXT
};
postFilter
.
must
(
EsQueryTools
.
assembleNormalKeywordQuery
(
dto
.
getKeyword
(),
fieldSearch
));
}
// sourceKeyword
...
...
@@ -1431,38 +1433,32 @@ public class MarkDataServiceImpl implements MarkDataService {
}
@Override
public
String
getLastMarkUrl
(
String
projectId
,
String
linkedGroupId
,
String
contendId
,
String
platform
,
String
realSource
,
String
source
)
{
public
JSONObject
getLastMarkData
(
String
projectId
,
String
linkedGroupId
,
String
contendId
,
String
platform
,
String
realSource
,
String
source
)
{
try
{
EsClientDao
.
SearchHelper
searchHelper
=
EsClientDao
.
createSearchHelper
();
BoolQueryBuilder
query
=
projectLinkedGroupContendIdQuery
(
projectId
,
linkedGroupId
,
contendId
);
query
.
must
(
QueryBuilders
.
termQuery
(
"platform
"
,
platform
));
query
.
must
(
QueryBuilders
.
termQuery
(
"platform
_id"
,
GlobalPojo
.
getPlatformIdByName
(
platform
)
));
query
.
must
(
QueryBuilders
.
termQuery
(
"real_source"
,
realSource
));
query
.
must
(
QueryBuilders
.
termQuery
(
"source"
,
source
));
searchHelper
.
setQuery
(
query
);
searchHelper
.
setSort
(
SortBuilders
.
fieldSort
(
"time"
).
order
(
SortOrder
.
DESC
));
searchHelper
.
setSize
(
1
);
searchHelper
.
setFetchSource
(
new
String
[]{
"url"
,
"question_url"
,
"answer_url"
});
SearchHits
searchHits
=
esClientDao
.
searchHits
(
searchHelper
);
if
(
0
==
searchHits
.
getTotalHits
().
value
)
{
return
null
;
}
return
getUrl
(
searchHits
.
getAt
(
0
).
getSourceAsMap
());
return
get
TitleAnd
Url
(
searchHits
.
getAt
(
0
).
getSourceAsMap
());
}
catch
(
IOException
e
)
{
return
null
;
}
}
private
static
String
getUrl
(
Map
<
String
,
Object
>
map
)
{
JSONObject
json
=
new
JSONObject
(
map
);
String
url
=
json
.
getString
(
"url"
);
// 如果url为空,则查询QA类型url字段
if
(
null
==
url
)
{
url
=
json
.
getString
(
"answer_url"
);
}
if
(
null
==
url
)
{
url
=
json
.
getString
(
"question_url"
);
}
return
url
;
private
static
JSONObject
getTitleAndUrl
(
Map
<
String
,
Object
>
map
)
{
JSONObject
json
=
new
JSONObject
();
BaseMap
baseMap
=
Tools
.
getBaseFromEsMap
(
map
);
json
.
put
(
"title"
,
baseMap
.
getTitleNullOptionalContent
());
json
.
put
(
"url"
,
baseMap
.
getUrl
());
return
json
;
}
/**
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkFlowServiceImpl.java
View file @
1c1bad6b
...
...
@@ -118,7 +118,6 @@ public class MarkFlowServiceImpl implements MarkFlowService {
sourceDetails
.
put
(
"followersNum"
,
followersNum
);
}
// 渠道标签
String
channelTag
=
tJson
.
getString
(
"channel_tag"
);
if
(
null
!=
channelTag
)
{
sourceDetails
.
put
(
"channelTag"
,
channelTag
.
replaceAll
(
","
,
"|"
));
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/UserServiceImpl.java
View file @
1c1bad6b
...
...
@@ -98,6 +98,7 @@ public class UserServiceImpl implements UserService {
userInfo
.
setRoleId
(
userRole
.
getRoleId
());
userInfo
.
setAvatarUrl
(
user
.
getAvatarUrl
());
userInfo
.
setExportAmount
(
userRole
.
getExportAmount
());
userInfo
.
setExpiredTime
(
userRole
.
getExpiredTime
());
});
if
(!
hit
.
get
())
{
return
null
;
...
...
@@ -278,6 +279,11 @@ public class UserServiceImpl implements UserService {
userOldDao
.
updateOneByIdWithField
(
userOld
.
getId
(),
Update
.
update
(
"bindUser"
,
false
));
}
@Override
public
Map
<
String
,
Object
>
getLoginInfo
()
{
return
queryUserInfo
(
UserThreadLocal
.
getUserId
(),
UserThreadLocal
.
getProjectId
()).
toMap
();
}
private
User
createNewUser
(
UserDTO
userDTO
)
{
User
user
=
new
User
();
user
.
setId
(
userDTO
.
getId
());
...
...
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