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
898b9f72
Commit
898b9f72
authored
Aug 30, 2022
by
shenjunjie
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature' into 'dev'
Feature See merge request
!31
parents
25a60ef4
fc95fd23
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
303 additions
and
105 deletions
+303
-105
src/main/java/com/zhiwei/brandkbs2/controller/app/AppSearchController.java
+65
-14
src/main/java/com/zhiwei/brandkbs2/enmus/ImportantChannelEnum.java
+7
-1
src/main/java/com/zhiwei/brandkbs2/pojo/EventData.java
+0
-4
src/main/java/com/zhiwei/brandkbs2/pojo/vo/LineVO.java
+26
-0
src/main/java/com/zhiwei/brandkbs2/service/ChannelService.java
+9
-0
src/main/java/com/zhiwei/brandkbs2/service/MarkDataService.java
+4
-0
src/main/java/com/zhiwei/brandkbs2/service/impl/ChannelServiceImpl.java
+76
-4
src/main/java/com/zhiwei/brandkbs2/service/impl/EventServiceImpl.java
+2
-6
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkDataServiceImpl.java
+111
-76
src/main/java/com/zhiwei/brandkbs2/util/Tools.java
+3
-0
No files found.
src/main/java/com/zhiwei/brandkbs2/controller/app/AppSearchController.java
View file @
898b9f72
...
@@ -7,7 +7,9 @@ import com.zhiwei.brandkbs2.auth.Auth;
...
@@ -7,7 +7,9 @@ import com.zhiwei.brandkbs2.auth.Auth;
import
com.zhiwei.brandkbs2.config.Constant
;
import
com.zhiwei.brandkbs2.config.Constant
;
import
com.zhiwei.brandkbs2.enmus.RoleEnum
;
import
com.zhiwei.brandkbs2.enmus.RoleEnum
;
import
com.zhiwei.brandkbs2.model.ResponseResult
;
import
com.zhiwei.brandkbs2.model.ResponseResult
;
import
com.zhiwei.brandkbs2.pojo.dto.MarkSearchDTO
;
import
com.zhiwei.brandkbs2.pojo.dto.SearchFilterDTO
;
import
com.zhiwei.brandkbs2.pojo.dto.SearchFilterDTO
;
import
com.zhiwei.brandkbs2.service.ChannelService
;
import
com.zhiwei.brandkbs2.service.MarkDataService
;
import
com.zhiwei.brandkbs2.service.MarkDataService
;
import
com.zhiwei.brandkbs2.util.Tools
;
import
com.zhiwei.brandkbs2.util.Tools
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
...
@@ -23,17 +25,18 @@ import org.springframework.web.client.RestTemplate;
...
@@ -23,17 +25,18 @@ import org.springframework.web.client.RestTemplate;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Objects
;
/**
/**
* @author cjz
* @ClassName AppSearchController
* @ClassName AppSearchController
* @Description 提供前台搜索相关功能
* @Description 提供前台搜索相关功能
* @author cjz
* @date 2022-08-15 16:17
* @date 2022-08-15 16:17
*/
*/
@RestController
@RestController
@RequestMapping
(
"/app/search"
)
@RequestMapping
(
"/app/search"
)
@Api
(
tags
=
"前台搜索相关接口"
,
description
=
"提供搜索相关功能"
)
@Api
(
tags
=
"前台搜索相关接口"
,
description
=
"提供搜索相关功能"
)
@Auth
(
role
=
RoleEnum
.
CUSTOMER
)
@Auth
(
role
=
RoleEnum
.
CUSTOMER
)
public
class
AppSearchController
{
public
class
AppSearchController
{
@Autowired
@Autowired
...
@@ -51,26 +54,29 @@ public class AppSearchController {
...
@@ -51,26 +54,29 @@ public class AppSearchController {
@Resource
(
name
=
"markDataServiceImpl"
)
@Resource
(
name
=
"markDataServiceImpl"
)
MarkDataService
markDataService
;
MarkDataService
markDataService
;
@Resource
(
name
=
"channelServiceImpl"
)
ChannelService
channelService
;
@ApiOperation
(
"搜索-查热点"
)
@ApiOperation
(
"搜索-查热点"
)
@GetMapping
(
"/hot/list"
)
@GetMapping
(
"/hot/list"
)
public
ResponseResult
searchHotList
(
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"10"
)
Integer
limit
,
public
ResponseResult
searchHotList
(
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"10"
)
Integer
limit
,
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
value
=
"type"
,
defaultValue
=
"weibo"
)
String
type
,
@RequestParam
(
value
=
"type"
,
defaultValue
=
"weibo"
)
String
type
,
@RequestParam
(
value
=
"word"
)
String
word
){
@RequestParam
(
value
=
"word"
)
String
word
)
{
ResponseEntity
<
JSONObject
>
jsonObjectResponseEntity
=
restTemplate
.
getForEntity
(
trendsSearchUrl
,
JSONObject
.
class
,
limit
,
page
,
type
,
word
);
ResponseEntity
<
JSONObject
>
jsonObjectResponseEntity
=
restTemplate
.
getForEntity
(
trendsSearchUrl
,
JSONObject
.
class
,
limit
,
page
,
type
,
word
);
JSONObject
result
=
jsonObjectResponseEntity
.
getBody
();
JSONObject
result
=
jsonObjectResponseEntity
.
getBody
();
if
(
Objects
.
nonNull
(
result
))
{
if
(
Objects
.
nonNull
(
result
))
{
return
ResponseResult
.
success
(
result
);
return
ResponseResult
.
success
(
result
);
}
else
{
}
else
{
return
ResponseResult
.
failure
(
"响应超时"
);
return
ResponseResult
.
failure
(
"响应超时"
);
}
}
}
}
@ApiOperation
(
"搜索-查危机"
)
@ApiOperation
(
"搜索-查危机"
)
@GetMapping
(
"/crisisSearch"
)
@GetMapping
(
"/crisisSearch"
)
public
ResponseResult
crisisSearch
(
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
public
ResponseResult
crisisSearch
(
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"3"
)
Integer
pageSize
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"3"
)
Integer
pageSize
,
@RequestParam
(
"keyword"
)
String
keyword
){
@RequestParam
(
"keyword"
)
String
keyword
)
{
ResponseEntity
<
String
>
responseEntity
=
restTemplate
.
getForEntity
(
crisisSearchUrl
,
String
.
class
,
page
,
pageSize
,
keyword
);
ResponseEntity
<
String
>
responseEntity
=
restTemplate
.
getForEntity
(
crisisSearchUrl
,
String
.
class
,
page
,
pageSize
,
keyword
);
Object
result
=
JSON
.
parseObject
(
responseEntity
.
getBody
()).
get
(
"data"
);
Object
result
=
JSON
.
parseObject
(
responseEntity
.
getBody
()).
get
(
"data"
);
return
ResponseResult
.
success
(
result
);
return
ResponseResult
.
success
(
result
);
...
@@ -79,7 +85,7 @@ public class AppSearchController {
...
@@ -79,7 +85,7 @@ public class AppSearchController {
@ApiOperation
(
"搜索-全网事件库-查事件"
)
@ApiOperation
(
"搜索-全网事件库-查事件"
)
@GetMapping
(
"/getWholeNetworkEvents"
)
@GetMapping
(
"/getWholeNetworkEvents"
)
public
ResponseResult
getWholeNetworkEvents
(
@RequestParam
(
"keyword"
)
String
keyword
,
public
ResponseResult
getWholeNetworkEvents
(
@RequestParam
(
"keyword"
)
String
keyword
,
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
Integer
page
)
{
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
Integer
page
)
{
String
name
=
keyword
.
trim
();
String
name
=
keyword
.
trim
();
ResponseEntity
<
String
>
responseEntity
=
restTemplate
.
getForEntity
(
getEfSearchUrl
,
String
.
class
,
name
,
page
);
ResponseEntity
<
String
>
responseEntity
=
restTemplate
.
getForEntity
(
getEfSearchUrl
,
String
.
class
,
name
,
page
);
JSONObject
result
=
JSON
.
parseObject
(
responseEntity
.
getBody
());
JSONObject
result
=
JSON
.
parseObject
(
responseEntity
.
getBody
());
...
@@ -88,9 +94,9 @@ public class AppSearchController {
...
@@ -88,9 +94,9 @@ public class AppSearchController {
@ApiOperation
(
"搜索-全网搜"
)
@ApiOperation
(
"搜索-全网搜"
)
@GetMapping
(
"/searchWhole"
)
@GetMapping
(
"/searchWhole"
)
public
ResponseResult
searchWholeNetwork
(
@RequestBody
SearchFilterDTO
dto
){
public
ResponseResult
searchWholeNetwork
(
@RequestBody
SearchFilterDTO
dto
)
{
long
time
=
DateUtils
.
addDays
(
Tools
.
truncDate
(
new
Date
(),
Constant
.
DAY_PATTERN
),
-
89
).
getTime
();
long
time
=
DateUtils
.
addDays
(
Tools
.
truncDate
(
new
Date
(),
Constant
.
DAY_PATTERN
),
-
89
).
getTime
();
if
(
time
>
dto
.
getStartTime
()){
if
(
time
>
dto
.
getStartTime
())
{
return
ResponseResult
.
failure
(
"仅能搜索近3个月内信息"
);
return
ResponseResult
.
failure
(
"仅能搜索近3个月内信息"
);
}
}
Period
periodDay
=
new
Period
(
dto
.
getStartTime
(),
dto
.
getEndTime
(),
PeriodType
.
days
());
Period
periodDay
=
new
Period
(
dto
.
getStartTime
(),
dto
.
getEndTime
(),
PeriodType
.
days
());
...
@@ -99,4 +105,49 @@ public class AppSearchController {
...
@@ -99,4 +105,49 @@ public class AppSearchController {
}
}
return
ResponseResult
.
success
(
markDataService
.
searchWholeNetwork
(
dto
));
return
ResponseResult
.
success
(
markDataService
.
searchWholeNetwork
(
dto
));
}
}
@ApiOperation
(
"舆情列表"
)
@PostMapping
(
"/mark/list"
)
public
ResponseResult
getYuqingMarkList
(
@RequestBody
MarkSearchDTO
markSearchDTO
)
{
return
ResponseResult
.
success
(
markDataService
.
getYuqingMarkList
(
markSearchDTO
));
}
@ApiOperation
(
"舆情列表-搜索条件"
)
@GetMapping
(
"/mark/list/criteria"
)
public
ResponseResult
getYuqingMarkCriteria
(
@RequestParam
(
required
=
false
)
String
linkedGroupId
)
{
return
ResponseResult
.
success
(
markDataService
.
getYuqingMarkCriteria
(
linkedGroupId
));
}
@ApiOperation
(
"渠道搜索条件"
)
@GetMapping
(
"/channel/getChannelSearchCriteria"
)
public
ResponseResult
getChannelSearchCriteria
()
{
return
ResponseResult
.
success
(
channelService
.
getChannelSearchCriteria
());
}
@ApiOperation
(
"查渠道 渠道库"
)
@GetMapping
(
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
=
"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
(
"查竞品"
)
@PostMapping
(
"/contend/list"
)
public
ResponseResult
getContendSearchList
(
@RequestBody
MarkSearchDTO
markSearchDTO
)
{
return
ResponseResult
.
success
(
markDataService
.
getContendSearchList
(
markSearchDTO
));
}
@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/ImportantChannelEnum.java
View file @
898b9f72
package
com
.
zhiwei
.
brandkbs2
.
enmus
;
package
com
.
zhiwei
.
brandkbs2
.
enmus
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -40,9 +41,14 @@ public enum ImportantChannelEnum {
...
@@ -40,9 +41,14 @@ public enum ImportantChannelEnum {
*/
*/
QITA
(
"其他"
);
QITA
(
"其他"
);
private
final
String
state
;
private
final
String
state
;
/**
* 重要渠道集合
*/
public
static
final
List
<
String
>
IMPORTANT_CHANNEL_LIST
=
new
ArrayList
<>(
Arrays
.
asList
(
YANGJI
.
getState
(),
KEJI
.
getState
(),
CAIJING
.
getState
(),
QITA
.
getState
()));
ImportantChannelEnum
(
String
state
)
{
ImportantChannelEnum
(
String
state
)
{
this
.
state
=
state
;
this
.
state
=
state
;
}
}
...
...
src/main/java/com/zhiwei/brandkbs2/pojo/EventData.java
View file @
898b9f72
...
@@ -71,10 +71,6 @@ public class EventData extends AbstractBaseMongo {
...
@@ -71,10 +71,6 @@ public class EventData extends AbstractBaseMongo {
*/
*/
private
String
projectId
;
private
String
projectId
;
/**
/**
* 关联项目组
*/
private
String
linkedGroupId
;
/**
* 品牌ID
* 品牌ID
*/
*/
private
String
contendId
;
private
String
contendId
;
...
...
src/main/java/com/zhiwei/brandkbs2/pojo/vo/LineVO.java
0 → 100644
View file @
898b9f72
package
com
.
zhiwei
.
brandkbs2
.
pojo
.
vo
;
import
lombok.Data
;
import
lombok.ToString
;
import
java.util.Date
;
/**
* @author lxj
* @version 1.0
* @description 传播趋势图展示类
* @date 2019/9/17 9:09
*/
@Data
@ToString
public
class
LineVO
{
/**
* 个数
*/
private
Long
count
;
/**
* 时间
*/
private
Long
date
;
}
src/main/java/com/zhiwei/brandkbs2/service/ChannelService.java
View file @
898b9f72
...
@@ -251,4 +251,13 @@ public interface ChannelService {
...
@@ -251,4 +251,13 @@ public interface ChannelService {
* @param channel 渠道
* @param channel 渠道
*/
*/
Channel
calculateChannelEmotionIndex
(
Channel
channel
);
Channel
calculateChannelEmotionIndex
(
Channel
channel
);
/**
* 获取渠道的删选条件
* @return
*/
JSONObject
getChannelSearchCriteria
();
PageVO
<
JSONObject
>
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/MarkDataService.java
View file @
898b9f72
...
@@ -202,6 +202,7 @@ public interface MarkDataService {
...
@@ -202,6 +202,7 @@ public interface MarkDataService {
/**
/**
* 竞品库-舆情导出
* 竞品库-舆情导出
*
* @param markSearchDTO 标注数据搜索传输类
* @param markSearchDTO 标注数据搜索传输类
* @return
* @return
*/
*/
...
@@ -209,6 +210,7 @@ public interface MarkDataService {
...
@@ -209,6 +210,7 @@ public interface MarkDataService {
/**
/**
* 搜索-全网搜
* 搜索-全网搜
*
* @param searchFilterDTO
* @param searchFilterDTO
* @return
* @return
*/
*/
...
@@ -262,4 +264,6 @@ public interface MarkDataService {
...
@@ -262,4 +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
;
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
);
}
}
src/main/java/com/zhiwei/brandkbs2/service/impl/ChannelServiceImpl.java
View file @
898b9f72
...
@@ -12,10 +12,7 @@ import com.zhiwei.brandkbs2.easyexcel.dto.ExportAdminChannelArticleDTO;
...
@@ -12,10 +12,7 @@ import com.zhiwei.brandkbs2.easyexcel.dto.ExportAdminChannelArticleDTO;
import
com.zhiwei.brandkbs2.easyexcel.dto.ExportAdminChannelEventDTO
;
import
com.zhiwei.brandkbs2.easyexcel.dto.ExportAdminChannelEventDTO
;
import
com.zhiwei.brandkbs2.easyexcel.dto.ExportAppChannelArticleDTO
;
import
com.zhiwei.brandkbs2.easyexcel.dto.ExportAppChannelArticleDTO
;
import
com.zhiwei.brandkbs2.easyexcel.dto.ExportChannelDTO
;
import
com.zhiwei.brandkbs2.easyexcel.dto.ExportChannelDTO
;
import
com.zhiwei.brandkbs2.enmus.ChannelEmotion
;
import
com.zhiwei.brandkbs2.enmus.*
;
import
com.zhiwei.brandkbs2.enmus.EmotionEnum
;
import
com.zhiwei.brandkbs2.enmus.EventTagEnum
;
import
com.zhiwei.brandkbs2.enmus.ExperienceEnum
;
import
com.zhiwei.brandkbs2.es.ChannelEsDao
;
import
com.zhiwei.brandkbs2.es.ChannelEsDao
;
import
com.zhiwei.brandkbs2.es.EsClientDao
;
import
com.zhiwei.brandkbs2.es.EsClientDao
;
import
com.zhiwei.brandkbs2.es.EsQueryTools
;
import
com.zhiwei.brandkbs2.es.EsQueryTools
;
...
@@ -28,6 +25,7 @@ import com.zhiwei.brandkbs2.pojo.vo.ChannelListVO;
...
@@ -28,6 +25,7 @@ import com.zhiwei.brandkbs2.pojo.vo.ChannelListVO;
import
com.zhiwei.brandkbs2.pojo.vo.PageVO
;
import
com.zhiwei.brandkbs2.pojo.vo.PageVO
;
import
com.zhiwei.brandkbs2.service.ChannelService
;
import
com.zhiwei.brandkbs2.service.ChannelService
;
import
com.zhiwei.brandkbs2.service.CommonService
;
import
com.zhiwei.brandkbs2.service.CommonService
;
import
com.zhiwei.brandkbs2.service.MarkDataService
;
import
com.zhiwei.brandkbs2.service.ProjectService
;
import
com.zhiwei.brandkbs2.service.ProjectService
;
import
com.zhiwei.brandkbs2.util.MongoUtil
;
import
com.zhiwei.brandkbs2.util.MongoUtil
;
import
com.zhiwei.brandkbs2.util.Tools
;
import
com.zhiwei.brandkbs2.util.Tools
;
...
@@ -101,6 +99,9 @@ public class ChannelServiceImpl implements ChannelService {
...
@@ -101,6 +99,9 @@ public class ChannelServiceImpl implements ChannelService {
@Resource
(
name
=
"commonServiceImpl"
)
@Resource
(
name
=
"commonServiceImpl"
)
CommonService
commonService
;
CommonService
commonService
;
@Resource
(
name
=
"markDataServiceImpl"
)
MarkDataService
markDataService
;
@Resource
(
name
=
"mongoUtil"
)
@Resource
(
name
=
"mongoUtil"
)
MongoUtil
mongoUtil
;
MongoUtil
mongoUtil
;
...
@@ -774,6 +775,77 @@ public class ChannelServiceImpl implements ChannelService {
...
@@ -774,6 +775,77 @@ public class ChannelServiceImpl implements ChannelService {
return
channel
;
return
channel
;
}
}
@Override
public
JSONObject
getChannelSearchCriteria
()
{
JSONObject
result
=
new
JSONObject
();
// 平台
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
->
{
JSONObject
json
=
new
JSONObject
();
json
.
put
(
"id"
,
emotion
.
getState
());
json
.
put
(
"name"
,
emotion
.
getName
());
return
json
;
}).
collect
(
Collectors
.
toList
()));
//渠道级别
List
<
String
>
mediaTypeList
=
ImportantChannelEnum
.
getAllTagExceptSpec
();
mediaTypeList
.
add
(
0
,
"全部"
);
result
.
put
(
"mediaTypeList"
,
mediaTypeList
);
//发文数量
result
.
put
(
"articleList"
,
getArticleList
());
return
result
;
}
@Override
public
PageVO
<
JSONObject
>
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
(
"全部"
))
{
query
.
addCriteria
(
Criteria
.
where
(
"platform"
).
in
(
platforms
));
}
if
(!
emotions
.
contains
(-
1
))
{
query
.
addCriteria
(
Criteria
.
where
(
"emotion"
).
in
(
emotions
));
}
if
(!
mediaTypes
.
contains
(
"全部"
))
{
// TODO
}
if
(
null
!=
articlesCount
)
{
query
.
addCriteria
(
Criteria
.
where
(
"articleCount"
).
gte
(
articlesCount
[
0
]).
lt
(
articlesCount
[
1
]));
}
long
total
=
channelDao
.
count
(
query
);
channelDao
.
addSort
(
query
,
sorter
);
List
<
Channel
>
channelList
=
channelDao
.
findList
(
query
);
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
,
resultList
);
}
private
List
<
JSONObject
>
getArticleList
()
{
List
<
JSONObject
>
res
=
new
ArrayList
<>();
for
(
String
name
:
Arrays
.
asList
(
"全部"
,
"1-10篇"
,
"11-15篇"
,
"51-100篇"
))
{
JSONObject
json
=
new
JSONObject
();
json
.
put
(
"name"
,
name
);
if
(
"全部"
.
equals
(
name
))
{
json
.
put
(
"value"
,
null
);
}
else
{
String
[]
split
=
name
.
substring
(
name
.
length
()
-
1
).
split
(
"-"
);
json
.
put
(
"value"
,
new
Long
[]{
Long
.
parseLong
(
split
[
0
]),
Long
.
parseLong
(
split
[
1
])});
}
res
.
add
(
json
);
}
return
res
;
}
/**
/**
* 更新渠道指数,渠道等级,情感倾向并记录变化
* 更新渠道指数,渠道等级,情感倾向并记录变化
*
*
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/EventServiceImpl.java
View file @
898b9f72
...
@@ -20,6 +20,7 @@ import com.zhiwei.brandkbs2.easyexcel.listener.EventDataListener;
...
@@ -20,6 +20,7 @@ import com.zhiwei.brandkbs2.easyexcel.listener.EventDataListener;
import
com.zhiwei.brandkbs2.easyexcel.listener.EventFileListener
;
import
com.zhiwei.brandkbs2.easyexcel.listener.EventFileListener
;
import
com.zhiwei.brandkbs2.enmus.EmotionEnum
;
import
com.zhiwei.brandkbs2.enmus.EmotionEnum
;
import
com.zhiwei.brandkbs2.enmus.EventTagEnum
;
import
com.zhiwei.brandkbs2.enmus.EventTagEnum
;
import
com.zhiwei.brandkbs2.enmus.ImportantChannelEnum
;
import
com.zhiwei.brandkbs2.exception.ExceptionCast
;
import
com.zhiwei.brandkbs2.exception.ExceptionCast
;
import
com.zhiwei.brandkbs2.listener.ApplicationProjectListener
;
import
com.zhiwei.brandkbs2.listener.ApplicationProjectListener
;
import
com.zhiwei.brandkbs2.model.CommonCodeEnum
;
import
com.zhiwei.brandkbs2.model.CommonCodeEnum
;
...
@@ -111,11 +112,6 @@ public class EventServiceImpl implements EventService {
...
@@ -111,11 +112,6 @@ public class EventServiceImpl implements EventService {
@Resource
@Resource
private
RedisUtil
redisUtil
;
private
RedisUtil
redisUtil
;
/**
* 重要渠道集合
*/
private
static
final
List
<
String
>
IMPORTANT_CHANNEL_LIST
=
new
ArrayList
<>(
Arrays
.
asList
(
"央级"
,
"科技"
,
"财经"
,
"其他"
));
// private static final Pattern PATTERN = Pattern.compile("[\ud83c\udc00-\ud83c\udfff]|[\ud83d\udc00-\ud83d\udfff]|[\u2600-\u27ff]");
// private static final Pattern PATTERN = Pattern.compile("[\ud83c\udc00-\ud83c\udfff]|[\ud83d\udc00-\ud83d\udfff]|[\u2600-\u27ff]");
@Override
@Override
...
@@ -595,7 +591,7 @@ public class EventServiceImpl implements EventService {
...
@@ -595,7 +591,7 @@ public class EventServiceImpl implements EventService {
Event
event
=
getEventById
(
eventId
);
Event
event
=
getEventById
(
eventId
);
Query
query
=
Query
.
query
(
Criteria
.
where
(
"eventId"
).
is
(
eventId
));
Query
query
=
Query
.
query
(
Criteria
.
where
(
"eventId"
).
is
(
eventId
));
if
(
Objects
.
equals
(
"重要渠道"
,
type
))
{
if
(
Objects
.
equals
(
"重要渠道"
,
type
))
{
query
.
addCriteria
(
Criteria
.
where
(
"mediaType"
).
in
(
IMPORTANT_CHANNEL_LIST
));
query
.
addCriteria
(
Criteria
.
where
(
"mediaType"
).
in
(
I
mportantChannelEnum
.
I
MPORTANT_CHANNEL_LIST
));
}
}
// 总量
// 总量
long
total
=
eventDataDao
.
count
(
query
,
event
.
getCollectionName
());
long
total
=
eventDataDao
.
count
(
query
,
event
.
getCollectionName
());
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkDataServiceImpl.java
View file @
898b9f72
...
@@ -25,6 +25,7 @@ import com.zhiwei.brandkbs2.pojo.dto.ExportAppYuqingDTO;
...
@@ -25,6 +25,7 @@ import com.zhiwei.brandkbs2.pojo.dto.ExportAppYuqingDTO;
import
com.zhiwei.brandkbs2.pojo.dto.MarkSearchDTO
;
import
com.zhiwei.brandkbs2.pojo.dto.MarkSearchDTO
;
import
com.zhiwei.brandkbs2.pojo.dto.SearchFilterDTO
;
import
com.zhiwei.brandkbs2.pojo.dto.SearchFilterDTO
;
import
com.zhiwei.brandkbs2.pojo.vo.CustomTagVo
;
import
com.zhiwei.brandkbs2.pojo.vo.CustomTagVo
;
import
com.zhiwei.brandkbs2.pojo.vo.LineVO
;
import
com.zhiwei.brandkbs2.pojo.vo.PageVO
;
import
com.zhiwei.brandkbs2.pojo.vo.PageVO
;
import
com.zhiwei.brandkbs2.pojo.vo.ProjectVO
;
import
com.zhiwei.brandkbs2.pojo.vo.ProjectVO
;
import
com.zhiwei.brandkbs2.service.*
;
import
com.zhiwei.brandkbs2.service.*
;
...
@@ -937,8 +938,7 @@ public class MarkDataServiceImpl implements MarkDataService {
...
@@ -937,8 +938,7 @@ public class MarkDataServiceImpl implements MarkDataService {
Map
<
String
,
Long
>
counts
=
new
HashMap
<>();
Map
<
String
,
Long
>
counts
=
new
HashMap
<>();
if
(
1
==
dto
.
getPage
()
&&
CollectionUtils
.
isEmpty
(
dto
.
getPlatforms
()))
{
if
(
1
==
dto
.
getPage
()
&&
CollectionUtils
.
isEmpty
(
dto
.
getPlatforms
()))
{
for
(
MessagePlatform
platform
:
GlobalPojo
.
PLATFORMS
)
{
for
(
MessagePlatform
platform
:
GlobalPojo
.
PLATFORMS
)
{
BoolQueryBuilder
queryBuilder
=
QueryBuilders
.
boolQuery
().
must
(
helper
.
getPostFilter
())
BoolQueryBuilder
queryBuilder
=
QueryBuilders
.
boolQuery
().
must
(
helper
.
getPostFilter
()).
must
(
EsQueryTools
.
assemblePlatformQuery
(
Collections
.
singletonList
(
platform
)));
.
must
(
EsQueryTools
.
assemblePlatformQuery
(
Collections
.
singletonList
(
platform
)));
Long
count
=
esClientDao
.
count
(
esClientDao
.
getIndexes
(),
queryBuilder
,
null
);
Long
count
=
esClientDao
.
count
(
esClientDao
.
getIndexes
(),
queryBuilder
,
null
);
counts
.
put
(
platform
.
getName
(),
count
);
counts
.
put
(
platform
.
getName
(),
count
);
}
}
...
@@ -1031,8 +1031,7 @@ public class MarkDataServiceImpl implements MarkDataService {
...
@@ -1031,8 +1031,7 @@ public class MarkDataServiceImpl implements MarkDataService {
result
.
put
(
"days"
,
new
Period
(
dto
.
getStartTime
(),
dto
.
getEndTime
(),
PeriodType
.
days
()).
getDays
());
result
.
put
(
"days"
,
new
Period
(
dto
.
getStartTime
(),
dto
.
getEndTime
(),
PeriodType
.
days
()).
getDays
());
result
.
put
(
"priName"
,
project
.
getBrandName
());
result
.
put
(
"priName"
,
project
.
getBrandName
());
// 获取时间段主品牌在每个平台传播量占比
// 获取时间段主品牌在每个平台传播量占比
List
<
JSONObject
>
primaryPlatformsProportion
=
List
<
JSONObject
>
primaryPlatformsProportion
=
getMarkPlatformProportion
(
dto
.
getStartTime
(),
dto
.
getEndTime
(),
dto
.
getProjectId
(),
dto
.
getLinkedGroupId
(),
Constant
.
PRIMARY_CONTEND_ID
,
true
);
getMarkPlatformProportion
(
dto
.
getStartTime
(),
dto
.
getEndTime
(),
dto
.
getProjectId
(),
dto
.
getLinkedGroupId
(),
Constant
.
PRIMARY_CONTEND_ID
,
true
);
// 获取时间段主品牌总传播量
// 获取时间段主品牌总传播量
long
primaryTotalCount
=
primaryPlatformsProportion
.
stream
().
mapToLong
(
platform
->
platform
.
getLongValue
(
"count"
)).
sum
();
long
primaryTotalCount
=
primaryPlatformsProportion
.
stream
().
mapToLong
(
platform
->
platform
.
getLongValue
(
"count"
)).
sum
();
result
.
put
(
"priNorTotal"
,
primaryTotalCount
);
result
.
put
(
"priNorTotal"
,
primaryTotalCount
);
...
@@ -1045,8 +1044,7 @@ public class MarkDataServiceImpl implements MarkDataService {
...
@@ -1045,8 +1044,7 @@ public class MarkDataServiceImpl implements MarkDataService {
result
.
put
(
"conName"
,
brandName
);
result
.
put
(
"conName"
,
brandName
);
// 获取时间段竞品在每个平台传播量
// 获取时间段竞品在每个平台传播量
String
contendLinkedGroupId
=
projectService
.
getProjectByContendId
(
dto
.
getProjectId
(),
dto
.
getContendId
()).
getBrandLinkedGroupId
();
String
contendLinkedGroupId
=
projectService
.
getProjectByContendId
(
dto
.
getProjectId
(),
dto
.
getContendId
()).
getBrandLinkedGroupId
();
List
<
JSONObject
>
contendPlatformsProportion
=
List
<
JSONObject
>
contendPlatformsProportion
=
getMarkPlatformProportion
(
dto
.
getStartTime
(),
dto
.
getEndTime
(),
dto
.
getProjectId
(),
contendLinkedGroupId
,
dto
.
getContendId
(),
true
);
getMarkPlatformProportion
(
dto
.
getStartTime
(),
dto
.
getEndTime
(),
dto
.
getProjectId
(),
contendLinkedGroupId
,
dto
.
getContendId
(),
true
);
// 获取时间段竞品总传播量
// 获取时间段竞品总传播量
long
contendTotalCount
=
contendPlatformsProportion
.
stream
().
mapToLong
(
platform
->
platform
.
getLongValue
(
"count"
)).
sum
();
long
contendTotalCount
=
contendPlatformsProportion
.
stream
().
mapToLong
(
platform
->
platform
.
getLongValue
(
"count"
)).
sum
();
result
.
put
(
"conNorTotal"
,
contendTotalCount
);
result
.
put
(
"conNorTotal"
,
contendTotalCount
);
...
@@ -1085,6 +1083,7 @@ public class MarkDataServiceImpl implements MarkDataService {
...
@@ -1085,6 +1083,7 @@ public class MarkDataServiceImpl implements MarkDataService {
return
JSON
.
parseObject
(
result
);
return
JSON
.
parseObject
(
result
);
}
}
}
}
List
<
Map
<
String
,
Long
>>
dayList
=
Tools
.
parseToDays
(
dto
.
getStartTime
(),
dto
.
getEndTime
());
List
<
JSONObject
>
resList
=
new
ArrayList
<>(
2
);
List
<
JSONObject
>
resList
=
new
ArrayList
<>(
2
);
JSONObject
result
=
new
JSONObject
();
JSONObject
result
=
new
JSONObject
();
// 开始时间
// 开始时间
...
@@ -1096,8 +1095,7 @@ public class MarkDataServiceImpl implements MarkDataService {
...
@@ -1096,8 +1095,7 @@ public class MarkDataServiceImpl implements MarkDataService {
JSONObject
primaryLine
=
new
JSONObject
();
JSONObject
primaryLine
=
new
JSONObject
();
primaryLine
.
put
(
"id"
,
Constant
.
PRIMARY_CONTEND_ID
);
primaryLine
.
put
(
"id"
,
Constant
.
PRIMARY_CONTEND_ID
);
primaryLine
.
put
(
"brand"
,
project
.
getBrandName
());
primaryLine
.
put
(
"brand"
,
project
.
getBrandName
());
List
<
JSONObject
>
primarySpread
=
List
<
LineVO
>
primarySpread
=
getArticleSpread
(
dto
.
getProjectId
(),
dto
.
getLinkedGroupId
(),
Constant
.
PRIMARY_CONTEND_ID
,
dayList
);
getDayMarkArticleCount
(
dto
.
getStartTime
(),
dto
.
getEndTime
(),
dto
.
getProjectId
(),
dto
.
getLinkedGroupId
(),
Constant
.
PRIMARY_CONTEND_ID
);
primaryLine
.
put
(
"spread"
,
primarySpread
);
primaryLine
.
put
(
"spread"
,
primarySpread
);
resList
.
add
(
primaryLine
);
resList
.
add
(
primaryLine
);
result
.
put
(
"days"
,
primarySpread
.
size
());
result
.
put
(
"days"
,
primarySpread
.
size
());
...
@@ -1106,8 +1104,7 @@ public class MarkDataServiceImpl implements MarkDataService {
...
@@ -1106,8 +1104,7 @@ public class MarkDataServiceImpl implements MarkDataService {
JSONObject
contendLine
=
new
JSONObject
();
JSONObject
contendLine
=
new
JSONObject
();
contendLine
.
put
(
"id"
,
dto
.
getContendId
());
contendLine
.
put
(
"id"
,
dto
.
getContendId
());
contendLine
.
put
(
"brand"
,
brandName
);
contendLine
.
put
(
"brand"
,
brandName
);
List
<
JSONObject
>
contendSpread
=
List
<
LineVO
>
contendSpread
=
getArticleSpread
(
dto
.
getProjectId
(),
contendLinkedGroupId
,
dto
.
getContendId
(),
dayList
);
getDayMarkArticleCount
(
dto
.
getStartTime
(),
dto
.
getEndTime
(),
dto
.
getProjectId
(),
contendLinkedGroupId
,
dto
.
getContendId
());
contendLine
.
put
(
"spread"
,
contendSpread
);
contendLine
.
put
(
"spread"
,
contendSpread
);
resList
.
add
(
contendLine
);
resList
.
add
(
contendLine
);
result
.
put
(
"spread"
,
resList
);
result
.
put
(
"spread"
,
resList
);
...
@@ -1115,36 +1112,32 @@ public class MarkDataServiceImpl implements MarkDataService {
...
@@ -1115,36 +1112,32 @@ public class MarkDataServiceImpl implements MarkDataService {
// 封装主品牌信息结果
// 封装主品牌信息结果
result
.
put
(
"priName"
,
project
.
getBrandName
());
result
.
put
(
"priName"
,
project
.
getBrandName
());
// 获取主品牌稿件传播平均值
// 获取主品牌稿件传播平均值
double
avgPrimaryNormalCount
=
primarySpread
.
stream
().
mapToLong
(
line
->
line
.
getLongValue
(
"count"
)
).
average
().
orElse
(
0
);
double
avgPrimaryNormalCount
=
primarySpread
.
stream
().
mapToLong
(
LineVO:
:
getCount
).
average
().
orElse
(
0
);
result
.
put
(
"priAvg"
,
(
int
)
avgPrimaryNormalCount
);
result
.
put
(
"priAvg"
,
(
int
)
avgPrimaryNormalCount
);
// 获取主品牌大于平均值的稿件天数
// 获取主品牌大于平均值的稿件天数
long
priGreaterThanAvg
=
primarySpread
.
stream
().
filter
(
line
->
line
.
get
LongValue
(
"count"
)
>
avgPrimaryNormalCount
).
count
();
long
priGreaterThanAvg
=
primarySpread
.
stream
().
filter
(
line
->
line
.
get
Count
(
)
>
avgPrimaryNormalCount
).
count
();
result
.
put
(
"priGtAvg"
,
priGreaterThanAvg
);
result
.
put
(
"priGtAvg"
,
priGreaterThanAvg
);
// 获取主品牌传播峰值时信息
// 获取主品牌传播峰值时信息
JSONObject
primaryMax
=
primarySpread
.
stream
().
max
(
Comparator
.
comparing
(
line
->
line
.
getLongValue
(
"count"
))).
get
(
);
LineVO
primaryMax
=
primarySpread
.
stream
().
max
(
Comparator
.
comparing
(
LineVO:
:
getCount
)).
orElse
(
new
LineVO
()
);
result
.
put
(
"priMaxTime"
,
sdf
.
format
(
Long
.
parseLong
(
primaryMax
.
getString
(
"date"
)
)));
result
.
put
(
"priMaxTime"
,
sdf
.
format
(
primaryMax
.
getDate
(
)));
result
.
put
(
"priMaxCount"
,
primaryMax
.
get
LongValue
(
"count"
));
result
.
put
(
"priMaxCount"
,
primaryMax
.
get
Count
(
));
long
priMaxDayStartTime
=
Long
.
parseLong
(
primaryMax
.
getString
(
"date"
)
);
long
priMaxDayStartTime
=
primaryMax
.
getDate
(
);
long
priMaxDayEndTime
=
DateUtils
.
addDays
(
new
Date
(
Long
.
parseLong
(
primaryMax
.
getString
(
"date"
)
)),
1
).
getTime
();
long
priMaxDayEndTime
=
DateUtils
.
addDays
(
new
Date
(
primaryMax
.
getDate
(
)),
1
).
getTime
();
// 获取时间段某情感数据最多的标题
// 获取时间段某情感数据最多的标题
List
<
Map
.
Entry
<
String
,
Integer
>>
priTopTitle
=
List
<
Map
.
Entry
<
String
,
Integer
>>
priTopTitle
=
getMarkTopTitle
(
priMaxDayStartTime
,
priMaxDayEndTime
,
EmotionEnum
.
ALL
.
getName
(),
dto
.
getProjectId
(),
dto
.
getLinkedGroupId
(),
Constant
.
PRIMARY_CONTEND_ID
,
1
);
getMarkTopTitle
(
priMaxDayStartTime
,
priMaxDayEndTime
,
EmotionEnum
.
ALL
.
getName
(),
dto
.
getProjectId
(),
dto
.
getLinkedGroupId
(),
Constant
.
PRIMARY_CONTEND_ID
,
1
);
if
(
CollectionUtils
.
isNotEmpty
(
priTopTitle
))
{
if
(
CollectionUtils
.
isNotEmpty
(
priTopTitle
))
{
// 首发稿件
// 首发稿件
BaseMap
priFirstArticle
=
BaseMap
priFirstArticle
=
getFirstArticle
(
priMaxDayStartTime
,
priMaxDayEndTime
,
priTopTitle
.
get
(
0
).
getKey
(),
dto
.
getProjectId
(),
dto
.
getLinkedGroupId
(),
Constant
.
PRIMARY_CONTEND_ID
);
getFirstArticle
(
priMaxDayStartTime
,
priMaxDayEndTime
,
priTopTitle
.
get
(
0
).
getKey
(),
dto
.
getProjectId
(),
dto
.
getLinkedGroupId
(),
Constant
.
PRIMARY_CONTEND_ID
);
result
.
put
(
"priTopTitle"
,
priFirstArticle
.
getTitle
());
result
.
put
(
"priTopTitle"
,
priFirstArticle
.
getTitle
());
result
.
put
(
"priTopTitleUrl"
,
priFirstArticle
.
getUrl
());
result
.
put
(
"priTopTitleUrl"
,
priFirstArticle
.
getUrl
());
}
}
// 获取主品牌热门媒体方向
// 获取主品牌热门媒体方向
List
<
Map
.
Entry
<
String
,
Integer
>>
priHotTitles
=
List
<
Map
.
Entry
<
String
,
Integer
>>
priHotTitles
=
getMarkTopTitle
(
priMaxDayStartTime
,
priMaxDayEndTime
,
EmotionEnum
.
ALL
.
getName
(),
dto
.
getProjectId
(),
dto
.
getLinkedGroupId
(),
Constant
.
PRIMARY_CONTEND_ID
,
hotArticleSize
);
getMarkTopTitle
(
priMaxDayStartTime
,
priMaxDayEndTime
,
EmotionEnum
.
ALL
.
getName
(),
dto
.
getProjectId
(),
dto
.
getLinkedGroupId
(),
Constant
.
PRIMARY_CONTEND_ID
,
hotArticleSize
);
if
(
CollectionUtils
.
isNotEmpty
(
priHotTitles
))
{
if
(
CollectionUtils
.
isNotEmpty
(
priHotTitles
))
{
List
<
JSONObject
>
priHotArticle
=
priHotTitles
.
stream
().
map
(
map
->
{
List
<
JSONObject
>
priHotArticle
=
priHotTitles
.
stream
().
map
(
map
->
{
JSONObject
jsonObject
=
new
JSONObject
();
JSONObject
jsonObject
=
new
JSONObject
();
try
{
try
{
BaseMap
priFirstArticle
=
BaseMap
priFirstArticle
=
getFirstArticle
(
dto
.
getStartTime
(),
dto
.
getEndTime
(),
map
.
getKey
(),
dto
.
getProjectId
(),
dto
.
getLinkedGroupId
(),
Constant
.
PRIMARY_CONTEND_ID
);
getFirstArticle
(
dto
.
getStartTime
(),
dto
.
getEndTime
(),
map
.
getKey
(),
dto
.
getProjectId
(),
dto
.
getLinkedGroupId
(),
Constant
.
PRIMARY_CONTEND_ID
);
if
(
null
!=
priFirstArticle
)
{
if
(
null
!=
priFirstArticle
)
{
jsonObject
.
put
(
"title"
,
priFirstArticle
.
getTitle
());
jsonObject
.
put
(
"title"
,
priFirstArticle
.
getTitle
());
jsonObject
.
put
(
"url"
,
priFirstArticle
.
getUrl
());
jsonObject
.
put
(
"url"
,
priFirstArticle
.
getUrl
());
...
@@ -1162,36 +1155,31 @@ public class MarkDataServiceImpl implements MarkDataService {
...
@@ -1162,36 +1155,31 @@ public class MarkDataServiceImpl implements MarkDataService {
// 竞品名
// 竞品名
result
.
put
(
"conName"
,
brandName
);
result
.
put
(
"conName"
,
brandName
);
// 获取竞品稿件传播平均值
// 获取竞品稿件传播平均值
double
avgContendSpreadNormalCount
=
contendSpread
.
stream
().
mapToLong
(
line
->
line
.
getLongValue
(
"count"
)
).
average
().
orElse
(
0
);
double
avgContendSpreadNormalCount
=
contendSpread
.
stream
().
mapToLong
(
LineVO:
:
getCount
).
average
().
orElse
(
0
);
result
.
put
(
"conAvg"
,
(
int
)
avgContendSpreadNormalCount
);
result
.
put
(
"conAvg"
,
(
int
)
avgContendSpreadNormalCount
);
// 获取竞品大于平均值的稿件天数
// 获取竞品大于平均值的稿件天数
long
conGreaterThanAvg
=
contendSpread
.
stream
().
filter
(
line
->
line
.
get
LongValue
(
"count"
)
>
avgContendSpreadNormalCount
).
count
();
long
conGreaterThanAvg
=
contendSpread
.
stream
().
filter
(
line
->
line
.
get
Count
(
)
>
avgContendSpreadNormalCount
).
count
();
result
.
put
(
"conGtAvg"
,
conGreaterThanAvg
);
result
.
put
(
"conGtAvg"
,
conGreaterThanAvg
);
//获取竞品传播峰值信息
//获取竞品传播峰值信息
JSONObject
contendMax
=
contendSpread
.
stream
().
max
(
Comparator
.
comparing
(
line
->
line
.
getLongValue
(
"count"
))).
get
();
LineVO
contendMax
=
contendSpread
.
stream
().
max
(
Comparator
.
comparing
(
LineVO:
:
getCount
)).
orElse
(
new
LineVO
());
result
.
put
(
"conMaxTime"
,
sdf
.
format
(
Long
.
parseLong
(
primaryMax
.
getString
(
"date"
))));
result
.
put
(
"conMaxTime"
,
sdf
.
format
(
contendMax
.
getDate
()));
result
.
put
(
"conMaxCount"
,
contendMax
.
getLongValue
(
"count"
));
result
.
put
(
"conMaxCount"
,
contendMax
.
getCount
());
long
conMaxDayStartTime
=
Long
.
parseLong
(
primaryMax
.
getString
(
"date"
));
long
conMaxDayStartTime
=
contendMax
.
getDate
();
long
conMaxDayEndTime
=
DateUtils
.
addDays
(
new
Date
(
Long
.
parseLong
(
primaryMax
.
getString
(
"date"
))),
1
).
getTime
();
long
conMaxDayEndTime
=
DateUtils
.
addDays
(
new
Date
(
contendMax
.
getDate
()),
1
).
getTime
();
List
<
Map
.
Entry
<
String
,
Integer
>>
conTopTitle
=
List
<
Map
.
Entry
<
String
,
Integer
>>
conTopTitle
=
getMarkTopTitle
(
conMaxDayStartTime
,
conMaxDayEndTime
,
EmotionEnum
.
ALL
.
getName
(),
dto
.
getProjectId
(),
contendLinkedGroupId
,
dto
.
getContendId
(),
1
);
getMarkTopTitle
(
conMaxDayStartTime
,
conMaxDayEndTime
,
EmotionEnum
.
ALL
.
getName
(),
dto
.
getProjectId
(),
contendLinkedGroupId
,
dto
.
getContendId
(),
1
);
if
(
CollectionUtils
.
isNotEmpty
(
conTopTitle
))
{
if
(
CollectionUtils
.
isNotEmpty
(
conTopTitle
))
{
// 首发稿件
// 首发稿件
BaseMap
conFirstArticle
=
BaseMap
conFirstArticle
=
getFirstArticle
(
conMaxDayStartTime
,
conMaxDayEndTime
,
conTopTitle
.
get
(
0
).
getKey
(),
dto
.
getProjectId
(),
contendLinkedGroupId
,
dto
.
getContendId
());
getFirstArticle
(
conMaxDayStartTime
,
conMaxDayEndTime
,
conTopTitle
.
get
(
0
).
getKey
(),
dto
.
getProjectId
(),
contendLinkedGroupId
,
dto
.
getContendId
());
result
.
put
(
"conTopTitle"
,
conFirstArticle
.
getTitle
());
result
.
put
(
"conTopTitle"
,
conFirstArticle
.
getTitle
());
result
.
put
(
"conTopTitleUrl"
,
conFirstArticle
.
getUrl
());
result
.
put
(
"conTopTitleUrl"
,
conFirstArticle
.
getUrl
());
}
}
// 获取竞品热门媒体方向
// 获取竞品热门媒体方向
List
<
Map
.
Entry
<
String
,
Integer
>>
conHotTitles
=
List
<
Map
.
Entry
<
String
,
Integer
>>
conHotTitles
=
getMarkTopTitle
(
conMaxDayStartTime
,
conMaxDayEndTime
,
EmotionEnum
.
ALL
.
getName
(),
dto
.
getProjectId
(),
contendLinkedGroupId
,
dto
.
getContendId
(),
hotArticleSize
);
getMarkTopTitle
(
conMaxDayStartTime
,
conMaxDayEndTime
,
EmotionEnum
.
ALL
.
getName
(),
dto
.
getProjectId
(),
contendLinkedGroupId
,
dto
.
getContendId
(),
hotArticleSize
);
if
(
CollectionUtils
.
isNotEmpty
(
conHotTitles
))
{
if
(
CollectionUtils
.
isNotEmpty
(
conHotTitles
))
{
List
<
JSONObject
>
conHotArticle
=
conHotTitles
.
stream
().
map
(
map
->
{
List
<
JSONObject
>
conHotArticle
=
conHotTitles
.
stream
().
map
(
map
->
{
JSONObject
jsonObject
=
new
JSONObject
();
JSONObject
jsonObject
=
new
JSONObject
();
try
{
try
{
BaseMap
conFirstArticle
=
BaseMap
conFirstArticle
=
getFirstArticle
(
dto
.
getStartTime
(),
dto
.
getEndTime
(),
map
.
getKey
(),
dto
.
getProjectId
(),
contendLinkedGroupId
,
dto
.
getContendId
());
getFirstArticle
(
dto
.
getStartTime
(),
dto
.
getEndTime
(),
map
.
getKey
(),
dto
.
getProjectId
(),
contendLinkedGroupId
,
dto
.
getContendId
());
if
(
null
!=
conFirstArticle
)
{
if
(
null
!=
conFirstArticle
)
{
jsonObject
.
put
(
"title"
,
conFirstArticle
.
getTitle
());
jsonObject
.
put
(
"title"
,
conFirstArticle
.
getTitle
());
jsonObject
.
put
(
"url"
,
conFirstArticle
.
getUrl
());
jsonObject
.
put
(
"url"
,
conFirstArticle
.
getUrl
());
...
@@ -1231,11 +1219,10 @@ public class MarkDataServiceImpl implements MarkDataService {
...
@@ -1231,11 +1219,10 @@ public class MarkDataServiceImpl implements MarkDataService {
public
JSONObject
searchWholeNetwork
(
SearchFilterDTO
dto
)
{
public
JSONObject
searchWholeNetwork
(
SearchFilterDTO
dto
)
{
Project
project
=
projectService
.
getProjectById
(
dto
.
getProjectId
());
Project
project
=
projectService
.
getProjectById
(
dto
.
getProjectId
());
JSONObject
jsonObject
=
new
JSONObject
();
JSONObject
jsonObject
=
new
JSONObject
();
if
(
2
==
project
.
getWholeSearchDataSource
()){
// 查商业数据库
if
(
2
==
project
.
getWholeSearchDataSource
())
{
// 查商业数据库
defaultSearchFilter
(
dto
);
defaultSearchFilter
(
dto
);
try
{
try
{
JSONObject
params
=
IstarShineUtil
.
getKSSearchParam
(
dto
.
getSearch
(),
null
,
dto
.
getStartTime
(),
dto
.
getEndTime
(),
dto
.
getPlatformsStr
(),
JSONObject
params
=
IstarShineUtil
.
getKSSearchParam
(
dto
.
getSearch
(),
null
,
dto
.
getStartTime
(),
dto
.
getEndTime
(),
dto
.
getPlatformsStr
(),
dto
.
getFilterForward
(),
dto
.
getSortOf
(),
dto
.
getPage
(),
dto
.
getPageSize
(),
dto
.
getMatchFields
(),
null
,
null
);
dto
.
getFilterForward
(),
dto
.
getSortOf
(),
dto
.
getPage
(),
dto
.
getPageSize
(),
dto
.
getMatchFields
(),
null
,
null
);
JSONObject
taskEntity
=
new
JSONObject
();
JSONObject
taskEntity
=
new
JSONObject
();
taskEntity
.
put
(
"appId"
,
"6183571e0d710000f6003a12"
);
// 应用id, 由张志伟提供给使用者
taskEntity
.
put
(
"appId"
,
"6183571e0d710000f6003a12"
);
// 应用id, 由张志伟提供给使用者
...
@@ -1247,17 +1234,17 @@ public class MarkDataServiceImpl implements MarkDataService {
...
@@ -1247,17 +1234,17 @@ public class MarkDataServiceImpl implements MarkDataService {
ResponseEntity
<
JSONObject
>
responseEntity
=
restTemplate
.
postForEntity
(
addIStarShineKSDataUrl
,
taskEntity
,
JSONObject
.
class
);
ResponseEntity
<
JSONObject
>
responseEntity
=
restTemplate
.
postForEntity
(
addIStarShineKSDataUrl
,
taskEntity
,
JSONObject
.
class
);
JSONObject
result
=
Objects
.
requireNonNull
(
responseEntity
.
getBody
()).
getJSONObject
(
"data"
);
JSONObject
result
=
Objects
.
requireNonNull
(
responseEntity
.
getBody
()).
getJSONObject
(
"data"
);
return
searchWholeBackUp
(
result
.
get
(
"id"
).
toString
());
return
searchWholeBackUp
(
result
.
get
(
"id"
).
toString
());
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"error searchWholeNetwork - "
,
e
);
log
.
error
(
"error searchWholeNetwork - "
,
e
);
}
}
}
else
{
// 查舆情库
}
else
{
// 查舆情库
ResponseEntity
<
JSONObject
>
responseEntity
=
restTemplate
.
postForEntity
(
wholeSearchUrl
,
dto
.
toMap
(),
JSONObject
.
class
);
ResponseEntity
<
JSONObject
>
responseEntity
=
restTemplate
.
postForEntity
(
wholeSearchUrl
,
dto
.
toMap
(),
JSONObject
.
class
);
return
searchWholeOpinion
(
responseEntity
,
jsonObject
);
return
searchWholeOpinion
(
responseEntity
,
jsonObject
);
}
}
return
jsonObject
;
return
jsonObject
;
}
}
private
JSONObject
searchWholeOpinion
(
ResponseEntity
<
JSONObject
>
responseEntity
,
JSONObject
jsonObject
){
private
JSONObject
searchWholeOpinion
(
ResponseEntity
<
JSONObject
>
responseEntity
,
JSONObject
jsonObject
)
{
JSONObject
bodyData
=
Objects
.
requireNonNull
(
responseEntity
.
getBody
()).
getJSONObject
(
"data"
);
JSONObject
bodyData
=
Objects
.
requireNonNull
(
responseEntity
.
getBody
()).
getJSONObject
(
"data"
);
JSONObject
data
=
bodyData
.
getJSONObject
(
"data"
);
JSONObject
data
=
bodyData
.
getJSONObject
(
"data"
);
JSONArray
listArray
=
data
.
getJSONArray
(
"list"
);
JSONArray
listArray
=
data
.
getJSONArray
(
"list"
);
...
@@ -1301,7 +1288,7 @@ public class MarkDataServiceImpl implements MarkDataService {
...
@@ -1301,7 +1288,7 @@ public class MarkDataServiceImpl implements MarkDataService {
ResponseEntity
<
JSONObject
>
responseEntity
=
restTemplate
.
getForEntity
(
getIStarShineKSInfoDataUrl
,
JSONObject
.
class
,
taskId
);
ResponseEntity
<
JSONObject
>
responseEntity
=
restTemplate
.
getForEntity
(
getIStarShineKSInfoDataUrl
,
JSONObject
.
class
,
taskId
);
JSONObject
data
=
Objects
.
requireNonNull
(
responseEntity
.
getBody
()).
getJSONObject
(
"data"
);
JSONObject
data
=
Objects
.
requireNonNull
(
responseEntity
.
getBody
()).
getJSONObject
(
"data"
);
JSONObject
task
=
data
.
getJSONObject
(
"task"
);
JSONObject
task
=
data
.
getJSONObject
(
"task"
);
if
(
1
==
task
.
getInteger
(
"crawlerFinish"
))
{
if
(
1
==
task
.
getInteger
(
"crawlerFinish"
))
{
//pageSize
//pageSize
Integer
receiveCount
=
task
.
getInteger
(
"receiveCount"
);
Integer
receiveCount
=
task
.
getInteger
(
"receiveCount"
);
Integer
searchCount
=
task
.
getInteger
(
"searchCount"
);
Integer
searchCount
=
task
.
getInteger
(
"searchCount"
);
...
@@ -1319,12 +1306,12 @@ public class MarkDataServiceImpl implements MarkDataService {
...
@@ -1319,12 +1306,12 @@ public class MarkDataServiceImpl implements MarkDataService {
result
.
put
(
"time"
,
list
.
get
(
"ctime"
));
result
.
put
(
"time"
,
list
.
get
(
"ctime"
));
resultList
.
add
(
result
);
resultList
.
add
(
result
);
}
}
jsonObject
.
put
(
"list"
,
resultList
);
jsonObject
.
put
(
"list"
,
resultList
);
//jsonObject.put("page",data1.get("page"));
//jsonObject.put("page",data1.get("page"));
jsonObject
.
put
(
"pageLimit"
,
receiveCount
);
jsonObject
.
put
(
"pageLimit"
,
receiveCount
);
jsonObject
.
put
(
"total"
,
searchCount
);
jsonObject
.
put
(
"total"
,
searchCount
);
jsonObject
.
put
(
"totalPage"
,
totalPage
);
jsonObject
.
put
(
"totalPage"
,
totalPage
);
jsonObject
.
put
(
"isBackUp"
,
true
);
jsonObject
.
put
(
"isBackUp"
,
true
);
return
jsonObject
;
return
jsonObject
;
}
}
Tools
.
sleep
(
500L
);
Tools
.
sleep
(
500L
);
...
@@ -1443,8 +1430,71 @@ public class MarkDataServiceImpl implements MarkDataService {
...
@@ -1443,8 +1430,71 @@ public class MarkDataServiceImpl implements MarkDataService {
return
channelResultList
;
return
channelResultList
;
}
}
@Override
public
String
getLastMarkUrl
(
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
(
"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
());
}
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
;
}
/**
* 获取传播图谱
*
* @param projectId 项目ID
* @param linkedGroupId 关联组Id
* @param contendId 竞品ID
* @param dayList 以天为最小单位分割的时间
* @return
*/
private
List
<
LineVO
>
getArticleSpread
(
String
projectId
,
String
linkedGroupId
,
String
contendId
,
List
<
Map
<
String
,
Long
>>
dayList
)
{
List
<
LineVO
>
lineList
=
new
ArrayList
<>(
dayList
.
size
());
dayList
.
forEach
(
day
->
{
LineVO
lineVO
=
new
LineVO
();
Long
startTime
=
day
.
get
(
"startTime"
);
Long
endTime
=
day
.
get
(
"endTime"
);
Long
articleCount
=
null
;
try
{
articleCount
=
getMarkArticleCount
(
startTime
,
endTime
,
projectId
,
linkedGroupId
,
contendId
);
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
lineVO
.
setCount
(
articleCount
);
lineVO
.
setDate
(
startTime
);
lineList
.
add
(
lineVO
);
});
return
lineList
;
}
/**
/**
* 获取
每日
稿件数量
* 获取稿件数量
*
*
* @param startTime 开始时间
* @param startTime 开始时间
* @param endTime 结束时间
* @param endTime 结束时间
...
@@ -1453,28 +1503,15 @@ public class MarkDataServiceImpl implements MarkDataService {
...
@@ -1453,28 +1503,15 @@ public class MarkDataServiceImpl implements MarkDataService {
* @param contendId 竞品ID
* @param contendId 竞品ID
* @return 每日稿件数量
* @return 每日稿件数量
*/
*/
private
List
<
JSONObject
>
getDayMarkArticleCount
(
Long
startTime
,
Long
endTime
,
String
projectId
,
String
linkedGroupId
,
String
contendId
)
throws
IOException
{
private
Long
getMarkArticleCount
(
Long
startTime
,
Long
endTime
,
String
projectId
,
String
linkedGroupId
,
String
contendId
)
throws
IOException
{
List
<
JSONObject
>
resultList
=
new
ArrayList
<>();
// index
// index
String
[]
indexes
=
esClientDao
.
getIndexes
();
String
[]
indexes
=
esClientDao
.
getIndexes
();
// dayAgg
DateHistogramAggregationBuilder
daysAggregation
=
AggregationBuilders
.
dateHistogram
(
"dayAgg"
).
field
(
"time"
).
calendarInterval
(
DateHistogramInterval
.
DAY
);
BoolQueryBuilder
query
=
projectLinkedGroupContendIdQuery
(
projectId
,
linkedGroupId
,
contendId
);
BoolQueryBuilder
postFilter
=
projectLinkedGroupContendIdQuery
(
projectId
,
linkedGroupId
,
contendId
);
// time range
// time range
query
.
must
(
QueryBuilders
.
rangeQuery
(
"time"
).
gte
(
startTime
).
lt
(
endTime
));
postFilter
.
must
(
QueryBuilders
.
rangeQuery
(
"time"
).
gte
(
startTime
).
lt
(
endTime
));
// response
//hits
SearchResponse
response
=
esClientDao
.
searchResponse
(
indexes
,
null
,
query
,
daysAggregation
,
null
,
null
,
0
,
0
,
null
);
return
esClientDao
.
count
(
postFilter
);
Map
<
String
,
Aggregation
>
aggMap
=
response
.
getAggregations
().
asMap
();
ParsedDateHistogram
dayAggTeam
=
(
ParsedDateHistogram
)
aggMap
.
get
(
"dayAgg"
);
List
<?
extends
Histogram
.
Bucket
>
buckets
=
dayAggTeam
.
getBuckets
();
buckets
.
forEach
(
bucket
->
{
JSONObject
result
=
new
JSONObject
();
result
.
put
(
"date"
,
bucket
.
getKeyAsString
());
result
.
put
(
"count"
,
bucket
.
getDocCount
());
resultList
.
add
(
result
);
});
return
resultList
;
}
}
/**
/**
...
@@ -1487,7 +1524,7 @@ public class MarkDataServiceImpl implements MarkDataService {
...
@@ -1487,7 +1524,7 @@ public class MarkDataServiceImpl implements MarkDataService {
Long
[]
timeRangeMonth
=
commonService
.
getTimeRangeMonth
();
Long
[]
timeRangeMonth
=
commonService
.
getTimeRangeMonth
();
dto
.
setEndTime
(
timeRangeMonth
[
1
]);
dto
.
setEndTime
(
timeRangeMonth
[
1
]);
dto
.
setStartTime
(
timeRangeMonth
[
0
]);
dto
.
setStartTime
(
timeRangeMonth
[
0
]);
}
else
{
}
else
{
dto
.
setStartTime
(
Tools
.
truncDate
(
dto
.
getStartTime
(),
Constant
.
DAY_PATTERN
));
dto
.
setStartTime
(
Tools
.
truncDate
(
dto
.
getStartTime
(),
Constant
.
DAY_PATTERN
));
dto
.
setEndTime
(
Tools
.
truncDate
(
dto
.
getEndTime
(),
Constant
.
DAY_PATTERN
));
dto
.
setEndTime
(
Tools
.
truncDate
(
dto
.
getEndTime
(),
Constant
.
DAY_PATTERN
));
}
}
...
@@ -1730,9 +1767,7 @@ public class MarkDataServiceImpl implements MarkDataService {
...
@@ -1730,9 +1767,7 @@ public class MarkDataServiceImpl implements MarkDataService {
}
}
protected
static
BoolQueryBuilder
projectLinkedGroupContendIdQuery
(
String
projectId
,
String
linkedGroupId
,
String
contendId
)
{
protected
static
BoolQueryBuilder
projectLinkedGroupContendIdQuery
(
String
projectId
,
String
linkedGroupId
,
String
contendId
)
{
return
QueryBuilders
.
boolQuery
().
must
(
QueryBuilders
.
termQuery
(
"brandkbs_cache_maps.key.keyword"
,
Tools
.
concat
(
projectId
,
linkedGroupId
,
contendId
)))
;
return
EsQueryTools
.
assembleCacheMapsQuery
(
projectId
,
linkedGroupId
,
contendId
);
// TODO 上线后开启
// return EsQueryTools.assembleCacheMapsQuery(projectId, linkedGroupId, contendId);
}
}
private
List
<
MarkFlowEntity
>
getMarkFlowEntity
(
MarkSearchDTO
markSearchDTO
,
SearchHits
searchHits
)
{
private
List
<
MarkFlowEntity
>
getMarkFlowEntity
(
MarkSearchDTO
markSearchDTO
,
SearchHits
searchHits
)
{
...
...
src/main/java/com/zhiwei/brandkbs2/util/Tools.java
View file @
898b9f72
...
@@ -319,6 +319,9 @@ public class Tools {
...
@@ -319,6 +319,9 @@ public class Tools {
}
}
public
static
BaseMap
getBaseFromEsMap
(
Map
<
String
,
Object
>
map
,
boolean
cacheSource
)
{
public
static
BaseMap
getBaseFromEsMap
(
Map
<
String
,
Object
>
map
,
boolean
cacheSource
)
{
if
(
null
==
map
)
{
return
new
BaseMap
();
}
// 设置source,forward,time
// 设置source,forward,time
BaseMap
res
=
Tools
.
convertMap
(
map
,
BaseMap
.
class
);
BaseMap
res
=
Tools
.
convertMap
(
map
,
BaseMap
.
class
);
if
(
cacheSource
)
{
if
(
cacheSource
)
{
...
...
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