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
859db12c
Commit
859db12c
authored
Dec 09, 2024
by
shenjunjie
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'release' into 'master'
Release See merge request
!602
parents
5512630b
7ca00f81
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
182 additions
and
33 deletions
+182
-33
src/main/java/com/zhiwei/brandkbs2/pojo/UserRole.java
+9
-3
src/main/java/com/zhiwei/brandkbs2/pojo/dto/UserDTO.java
+6
-0
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkDataServiceImpl.java
+57
-15
src/main/java/com/zhiwei/brandkbs2/service/impl/ProjectServiceImpl.java
+18
-2
src/main/java/com/zhiwei/brandkbs2/service/impl/SearchWholeServiceImpl.java
+53
-12
src/main/java/com/zhiwei/brandkbs2/service/impl/UserServiceImpl.java
+13
-1
src/main/java/com/zhiwei/brandkbs2/util/Tools.java
+26
-0
No files found.
src/main/java/com/zhiwei/brandkbs2/pojo/UserRole.java
View file @
859db12c
...
@@ -69,12 +69,17 @@ public class UserRole {
...
@@ -69,12 +69,17 @@ public class UserRole {
*/
*/
private
Integer
searchWholeRange
;
private
Integer
searchWholeRange
;
/**
* 方案设置参数,仅非人工项目(1:开启,2:关闭),默认值为:1
*/
private
Integer
planConfiguration
;
public
void
setRoleId
(
Integer
roleId
)
{
public
void
setRoleId
(
Integer
roleId
)
{
this
.
roleId
=
roleId
;
this
.
roleId
=
roleId
;
this
.
key
=
Tools
.
concat
(
projectId
,
roleId
);
this
.
key
=
Tools
.
concat
(
projectId
,
roleId
);
}
}
public
UserRole
(
String
projectId
,
int
roleId
,
Long
expiredTime
,
Integer
exportAmount
,
int
rights
,
int
range
)
{
public
UserRole
(
String
projectId
,
int
roleId
,
Long
expiredTime
,
Integer
exportAmount
,
Integer
rights
,
Integer
range
,
Integer
planConfiguration
)
{
this
.
projectId
=
projectId
;
this
.
projectId
=
projectId
;
this
.
roleId
=
roleId
;
this
.
roleId
=
roleId
;
this
.
expiredTime
=
expiredTime
;
this
.
expiredTime
=
expiredTime
;
...
@@ -82,6 +87,7 @@ public class UserRole {
...
@@ -82,6 +87,7 @@ public class UserRole {
this
.
key
=
Tools
.
concat
(
projectId
,
roleId
);
this
.
key
=
Tools
.
concat
(
projectId
,
roleId
);
this
.
searchWholeRights
=
rights
;
this
.
searchWholeRights
=
rights
;
this
.
searchWholeRange
=
range
;
this
.
searchWholeRange
=
range
;
this
.
planConfiguration
=
planConfiguration
;
}
}
public
static
UserRole
createFromUserDto
(
UserDTO
userDTO
)
{
public
static
UserRole
createFromUserDto
(
UserDTO
userDTO
)
{
...
@@ -100,10 +106,10 @@ public class UserRole {
...
@@ -100,10 +106,10 @@ public class UserRole {
calendar
.
set
(
Calendar
.
SECOND
,
59
);
calendar
.
set
(
Calendar
.
SECOND
,
59
);
expiredTime
=
calendar
.
getTime
().
getTime
();
expiredTime
=
calendar
.
getTime
().
getTime
();
}
}
return
new
UserRole
(
userDTO
.
getProjectId
(),
userDTO
.
getRoleId
(),
expiredTime
,
exportAmount
,
userDTO
.
getSearchWholeRights
(),
userDTO
.
getSearchWholeRange
());
return
new
UserRole
(
userDTO
.
getProjectId
(),
userDTO
.
getRoleId
(),
expiredTime
,
exportAmount
,
userDTO
.
getSearchWholeRights
(),
userDTO
.
getSearchWholeRange
()
,
userDTO
.
getPlanConfiguration
()
);
}
}
public
static
UserRole
defaultUserRole
(
Date
now
)
{
public
static
UserRole
defaultUserRole
(
Date
now
)
{
return
new
UserRole
(
DEFAULT_PROJECT_ID
,
DEFAULT_ROLE_ID
,
DateUtils
.
addDays
(
now
,
30
).
getTime
(),
DEFAULT_EXPORT_LIMIT
,
1
,
1
);
return
new
UserRole
(
DEFAULT_PROJECT_ID
,
DEFAULT_ROLE_ID
,
DateUtils
.
addDays
(
now
,
30
).
getTime
(),
DEFAULT_EXPORT_LIMIT
,
1
,
1
,
null
);
}
}
}
}
src/main/java/com/zhiwei/brandkbs2/pojo/dto/UserDTO.java
View file @
859db12c
...
@@ -85,4 +85,10 @@ public class UserDTO {
...
@@ -85,4 +85,10 @@ public class UserDTO {
*/
*/
@ApiModelProperty
(
"全网搜索数据跨度"
)
@ApiModelProperty
(
"全网搜索数据跨度"
)
private
Integer
searchWholeRange
;
private
Integer
searchWholeRange
;
/**
* 方案设置参数(1:开启,2:关闭),默认值为:1
*/
@ApiModelProperty
(
"方案设置参数(1:开启,2:关闭)"
)
private
Integer
planConfiguration
;
}
}
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkDataServiceImpl.java
View file @
859db12c
...
@@ -2390,9 +2390,9 @@ public class MarkDataServiceImpl implements MarkDataService {
...
@@ -2390,9 +2390,9 @@ public class MarkDataServiceImpl implements MarkDataService {
DateHistogramAggregationBuilder
daysAggregationBuilder
;
DateHistogramAggregationBuilder
daysAggregationBuilder
;
// 天级以小时为颗粒度,周、月级以天作为颗粒度
// 天级以小时为颗粒度,周、月级以天作为颗粒度
if
(
endTime
-
startTime
<=
Constant
.
ONE_DAY
){
if
(
endTime
-
startTime
<=
Constant
.
ONE_DAY
){
daysAggregationBuilder
=
AggregationBuilders
.
dateHistogram
(
"timeAgg"
).
field
(
"stime"
).
calendarInterval
(
DateHistogramInterval
.
HOUR
);
daysAggregationBuilder
=
AggregationBuilders
.
dateHistogram
(
"timeAgg"
).
field
(
"stime"
).
calendarInterval
(
DateHistogramInterval
.
HOUR
)
.
offset
(
"16h"
)
;
}
else
{
}
else
{
daysAggregationBuilder
=
AggregationBuilders
.
dateHistogram
(
"timeAgg"
).
field
(
"stime"
).
calendarInterval
(
DateHistogramInterval
.
DAY
);
daysAggregationBuilder
=
AggregationBuilders
.
dateHistogram
(
"timeAgg"
).
field
(
"stime"
).
calendarInterval
(
DateHistogramInterval
.
DAY
)
.
offset
(
"16h"
)
;
}
}
String
projectId
=
UserThreadLocal
.
getProjectId
();
String
projectId
=
UserThreadLocal
.
getProjectId
();
// project plan query
// project plan query
...
@@ -2857,6 +2857,9 @@ public class MarkDataServiceImpl implements MarkDataService {
...
@@ -2857,6 +2857,9 @@ public class MarkDataServiceImpl implements MarkDataService {
public
JSONObject
getSpreadTendency
(
MarkSearchDTO
dto
)
{
public
JSONObject
getSpreadTendency
(
MarkSearchDTO
dto
)
{
JSONObject
res
=
new
JSONObject
();
JSONObject
res
=
new
JSONObject
();
try
{
try
{
Long
[]
times
=
Tools
.
formatSpreadTendencyTime
(
dto
.
getStartTime
(),
dto
.
getEndTime
());
dto
.
setStartTime
(
times
[
0
]);
dto
.
setEndTime
(
times
[
1
]);
String
projectId
=
UserThreadLocal
.
getProjectId
();
String
projectId
=
UserThreadLocal
.
getProjectId
();
Long
endTime
=
dto
.
getEndTime
();
Long
endTime
=
dto
.
getEndTime
();
String
planId
=
dto
.
getPlanId
();
String
planId
=
dto
.
getPlanId
();
...
@@ -3244,6 +3247,9 @@ public class MarkDataServiceImpl implements MarkDataService {
...
@@ -3244,6 +3247,9 @@ public class MarkDataServiceImpl implements MarkDataService {
JSONObject
res
=
new
JSONObject
();
JSONObject
res
=
new
JSONObject
();
try
{
try
{
defaultXhsCustomSearchDTO
(
dto
);
defaultXhsCustomSearchDTO
(
dto
);
Long
[]
times
=
Tools
.
formatSpreadTendencyTime
(
dto
.
getStartTime
(),
dto
.
getEndTime
());
dto
.
setStartTime
(
times
[
0
]);
dto
.
setEndTime
(
times
[
1
]);
// 总趋势图
// 总趋势图
Pair
<
String
,
List
<
LineVO
>>
spreadTendency
=
getEmotionSpreadTendency
(
dto
,
null
);
Pair
<
String
,
List
<
LineVO
>>
spreadTendency
=
getEmotionSpreadTendency
(
dto
,
null
);
// 负面趋势图
// 负面趋势图
...
@@ -4434,12 +4440,19 @@ public class MarkDataServiceImpl implements MarkDataService {
...
@@ -4434,12 +4440,19 @@ public class MarkDataServiceImpl implements MarkDataService {
String
[]
indexes
=
esClientDao
.
getIndexes
();
String
[]
indexes
=
esClientDao
.
getIndexes
();
// 聚合请求
// 聚合请求
TermsAggregationBuilder
platformAggregationBuilder
=
AggregationBuilders
.
terms
(
"platformAgg"
).
field
(
"platform_id"
).
order
(
BucketOrder
.
count
(
false
));
TermsAggregationBuilder
platformAggregationBuilder
=
AggregationBuilders
.
terms
(
"platformAgg"
).
field
(
"platform_id"
).
order
(
BucketOrder
.
count
(
false
));
DateHistogramAggregationBuilder
daysAggregationBuilder
;
DateHistogramAggregationBuilder
daysAggregationBuilder
=
null
;
// 天级以小时为颗粒度,其他以天作为颗粒度
long
timeRange
=
dto
.
getEndTime
()
-
dto
.
getStartTime
();
if
(
dto
.
getEndTime
()
-
dto
.
getStartTime
()
<=
Constant
.
ONE_DAY
){
// 时间间隔≤7天,数据颗粒度为“小时级”
daysAggregationBuilder
=
AggregationBuilders
.
dateHistogram
(
"timeAgg"
).
field
(
"time"
).
calendarInterval
(
DateHistogramInterval
.
HOUR
);
if
(
timeRange
<=
Constant
.
ONE_WEEK
){
}
else
{
daysAggregationBuilder
=
AggregationBuilders
.
dateHistogram
(
"timeAgg"
).
field
(
"time"
).
calendarInterval
(
DateHistogramInterval
.
HOUR
).
offset
(
"16h"
);
daysAggregationBuilder
=
AggregationBuilders
.
dateHistogram
(
"timeAgg"
).
field
(
"time"
).
calendarInterval
(
DateHistogramInterval
.
DAY
);
}
// 7天<时间间隔≤180天,数据颗粒度为“天级”
if
(
timeRange
>
Constant
.
ONE_WEEK
&&
timeRange
<=
6
*
Constant
.
ONE_MONTH
){
daysAggregationBuilder
=
AggregationBuilders
.
dateHistogram
(
"timeAgg"
).
field
(
"time"
).
calendarInterval
(
DateHistogramInterval
.
DAY
).
offset
(
"16h"
);
}
// 180天<时间间隔,数据颗粒度为“月级”
if
(
timeRange
>
6
*
Constant
.
ONE_MONTH
){
daysAggregationBuilder
=
AggregationBuilders
.
dateHistogram
(
"timeAgg"
).
field
(
"time"
).
calendarInterval
(
DateHistogramInterval
.
MONTH
).
offset
(
"-8h"
);
}
}
// query
// query
BoolQueryBuilder
query
=
yuqingAnalyzeQuery
(
dto
);
BoolQueryBuilder
query
=
yuqingAnalyzeQuery
(
dto
);
...
@@ -4459,6 +4472,20 @@ public class MarkDataServiceImpl implements MarkDataService {
...
@@ -4459,6 +4472,20 @@ public class MarkDataServiceImpl implements MarkDataService {
long
count
=
timeBucket
.
getDocCount
();
long
count
=
timeBucket
.
getDocCount
();
line
.
add
(
new
LineVO
(
count
,
time
));
line
.
add
(
new
LineVO
(
count
,
time
));
}
}
// 由于结束点为开区间,将结束点数据补完
if
(
CollectionUtils
.
isNotEmpty
(
line
)){
line
.
get
(
0
).
setDate
(
dto
.
getStartTime
());
MarkSearchDTO
searchDTO
=
Tools
.
convertMap
(
dto
,
MarkSearchDTO
.
class
);
searchDTO
.
setPlatforms
(
Collections
.
singletonList
(
platformId
));
searchDTO
.
setStartTime
(
dto
.
getEndTime
());
searchDTO
.
setEndTime
(
dto
.
getEndTime
()
+
1
);
Long
count
=
0L
;
try
{
count
=
esClientDao
.
count
(
indexes
,
yuqingAnalyzeQuery
(
searchDTO
),
null
);
}
catch
(
IOException
ignore
)
{
}
line
.
add
(
new
LineVO
(
count
,
dto
.
getEndTime
()));
}
res
.
put
(
GlobalPojo
.
getPlatformNameById
(
platformId
),
line
);
res
.
put
(
GlobalPojo
.
getPlatformNameById
(
platformId
),
line
);
});
});
return
res
;
return
res
;
...
@@ -4473,15 +4500,21 @@ public class MarkDataServiceImpl implements MarkDataService {
...
@@ -4473,15 +4500,21 @@ public class MarkDataServiceImpl implements MarkDataService {
private
Pair
<
String
,
List
<
LineVO
>>
getEmotionSpreadTendency
(
MarkSearchDTO
dto
,
String
emotion
)
throws
IOException
{
private
Pair
<
String
,
List
<
LineVO
>>
getEmotionSpreadTendency
(
MarkSearchDTO
dto
,
String
emotion
)
throws
IOException
{
List
<
LineVO
>
res
=
new
ArrayList
<>();
List
<
LineVO
>
res
=
new
ArrayList
<>();
String
[]
indexes
=
esClientDao
.
getIndexes
();
String
[]
indexes
=
esClientDao
.
getIndexes
();
DateHistogramAggregationBuilder
daysAggregationBuilder
;
DateHistogramAggregationBuilder
daysAggregationBuilder
=
null
;
// 天级以小时为颗粒度,其他以天作为颗粒度
long
timeRange
=
dto
.
getEndTime
()
-
dto
.
getStartTime
();
if
(
dto
.
getEndTime
()
-
dto
.
getStartTime
()
<=
Constant
.
ONE_DAY
){
// 时间间隔≤7天,数据颗粒度为“小时级”
daysAggregationBuilder
=
AggregationBuilders
.
dateHistogram
(
"timeAgg"
).
field
(
"time"
).
calendarInterval
(
DateHistogramInterval
.
HOUR
);
if
(
timeRange
<=
Constant
.
ONE_WEEK
){
}
else
{
daysAggregationBuilder
=
AggregationBuilders
.
dateHistogram
(
"timeAgg"
).
field
(
"time"
).
calendarInterval
(
DateHistogramInterval
.
HOUR
).
offset
(
"16h"
);
daysAggregationBuilder
=
AggregationBuilders
.
dateHistogram
(
"timeAgg"
).
field
(
"time"
).
calendarInterval
(
DateHistogramInterval
.
DAY
);
}
// 7天<时间间隔≤180天,数据颗粒度为“天级”
if
(
timeRange
>
Constant
.
ONE_WEEK
&&
timeRange
<=
6
*
Constant
.
ONE_MONTH
){
daysAggregationBuilder
=
AggregationBuilders
.
dateHistogram
(
"timeAgg"
).
field
(
"time"
).
calendarInterval
(
DateHistogramInterval
.
DAY
).
offset
(
"16h"
);
}
// 180天<时间间隔,数据颗粒度为“月级”
if
(
timeRange
>
6
*
Constant
.
ONE_MONTH
){
daysAggregationBuilder
=
AggregationBuilders
.
dateHistogram
(
"timeAgg"
).
field
(
"time"
).
calendarInterval
(
DateHistogramInterval
.
MONTH
).
offset
(
"-8h"
);
}
}
TermsAggregationBuilder
titleAggregationBuilder
=
AggregationBuilders
.
terms
(
"titleAgg"
).
field
(
"agg_title.keyword"
).
order
(
BucketOrder
.
count
(
false
));
TermsAggregationBuilder
titleAggregationBuilder
=
AggregationBuilders
.
terms
(
"titleAgg"
).
field
(
"agg_title.keyword"
).
order
(
BucketOrder
.
count
(
false
));
// dto.setPlatforms(null);
// query
// query
BoolQueryBuilder
query
=
yuqingAnalyzeQuery
(
dto
,
emotion
,
null
);
BoolQueryBuilder
query
=
yuqingAnalyzeQuery
(
dto
,
emotion
,
null
);
// response
// response
...
@@ -4496,6 +4529,15 @@ public class MarkDataServiceImpl implements MarkDataService {
...
@@ -4496,6 +4529,15 @@ public class MarkDataServiceImpl implements MarkDataService {
long
count
=
bucket
.
getDocCount
();
long
count
=
bucket
.
getDocCount
();
res
.
add
(
new
LineVO
(
count
,
time
));
res
.
add
(
new
LineVO
(
count
,
time
));
});
});
// 由于结束点为开区间,将结束点数据补完
if
(
CollectionUtils
.
isNotEmpty
(
res
)){
res
.
get
(
0
).
setDate
(
dto
.
getStartTime
());
MarkSearchDTO
secondDTO
=
Tools
.
convertMap
(
dto
,
MarkSearchDTO
.
class
);
secondDTO
.
setStartTime
(
dto
.
getEndTime
());
secondDTO
.
setEndTime
(
dto
.
getEndTime
()
+
1
);
Long
count
=
esClientDao
.
count
(
indexes
,
yuqingAnalyzeQuery
(
secondDTO
,
emotion
,
null
),
null
);
res
.
add
(
new
LineVO
(
count
,
dto
.
getEndTime
()));
}
// 走势图最高点的聚合标题
// 走势图最高点的聚合标题
String
maxAggTitle
=
null
;
String
maxAggTitle
=
null
;
Optional
<?
extends
Histogram
.
Bucket
>
maxBucket
=
buckets
.
stream
().
max
(
Comparator
.
comparingLong
(
MultiBucketsAggregation
.
Bucket
::
getDocCount
));
Optional
<?
extends
Histogram
.
Bucket
>
maxBucket
=
buckets
.
stream
().
max
(
Comparator
.
comparingLong
(
MultiBucketsAggregation
.
Bucket
::
getDocCount
));
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/ProjectServiceImpl.java
View file @
859db12c
...
@@ -790,6 +790,7 @@ public class ProjectServiceImpl implements ProjectService {
...
@@ -790,6 +790,7 @@ public class ProjectServiceImpl implements ProjectService {
List
<
Project
>
lists
;
List
<
Project
>
lists
;
Map
<
String
,
Date
>
roleExpired
=
new
HashMap
<>();
Map
<
String
,
Date
>
roleExpired
=
new
HashMap
<>();
Map
<
String
,
Pair
<
Integer
,
Integer
>>
searchWholeInfo
=
new
HashMap
<>();
Map
<
String
,
Pair
<
Integer
,
Integer
>>
searchWholeInfo
=
new
HashMap
<>();
Map
<
String
,
Integer
>
planConfigurationInfo
=
new
HashMap
<>();
if
(
user
.
isSuperAdmin
())
{
if
(
user
.
isSuperAdmin
())
{
lists
=
projectDao
.
findListByKeywordFuzz
(
null
,
null
);
lists
=
projectDao
.
findListByKeywordFuzz
(
null
,
null
);
}
else
{
}
else
{
...
@@ -801,6 +802,7 @@ public class ProjectServiceImpl implements ProjectService {
...
@@ -801,6 +802,7 @@ public class ProjectServiceImpl implements ProjectService {
lists
.
add
(
projectDao
.
findOneById
(
userRole
.
getProjectId
()));
lists
.
add
(
projectDao
.
findOneById
(
userRole
.
getProjectId
()));
roleExpired
.
put
(
userRole
.
getProjectId
(),
null
==
userRole
.
getExpiredTime
()
?
null
:
new
Date
(
userRole
.
getExpiredTime
()));
roleExpired
.
put
(
userRole
.
getProjectId
(),
null
==
userRole
.
getExpiredTime
()
?
null
:
new
Date
(
userRole
.
getExpiredTime
()));
searchWholeInfo
.
put
(
userRole
.
getProjectId
(),
Pair
.
of
(
userRole
.
getSearchWholeRights
(),
userRole
.
getSearchWholeRange
()));
searchWholeInfo
.
put
(
userRole
.
getProjectId
(),
Pair
.
of
(
userRole
.
getSearchWholeRights
(),
userRole
.
getSearchWholeRange
()));
planConfigurationInfo
.
put
(
userRole
.
getProjectId
(),
userRole
.
getPlanConfiguration
());
}
}
});
});
}
}
...
@@ -812,7 +814,7 @@ public class ProjectServiceImpl implements ProjectService {
...
@@ -812,7 +814,7 @@ public class ProjectServiceImpl implements ProjectService {
json
.
put
(
"extraProjectName"
,
project
.
getExtraProjectName
());
json
.
put
(
"extraProjectName"
,
project
.
getExtraProjectName
());
json
.
put
(
"group"
,
project
.
getBrandLinkedGroup
());
json
.
put
(
"group"
,
project
.
getBrandLinkedGroup
());
json
.
put
(
"avatarUrl"
,
project
.
getAvatarUrl
());
json
.
put
(
"avatarUrl"
,
project
.
getAvatarUrl
());
json
.
put
(
"permission"
,
getPermissionList
(
project
));
json
.
put
(
"permission"
,
getPermissionList
(
project
,
planConfigurationInfo
,
user
.
isSuperAdmin
()
));
json
.
put
(
"isManual"
,
project
.
isManual
());
json
.
put
(
"isManual"
,
project
.
isManual
());
if
(!
project
.
isManual
())
{
if
(!
project
.
isManual
())
{
json
.
put
(
"markModel"
,
project
.
getMarkModel
());
json
.
put
(
"markModel"
,
project
.
getMarkModel
());
...
@@ -859,7 +861,7 @@ public class ProjectServiceImpl implements ProjectService {
...
@@ -859,7 +861,7 @@ public class ProjectServiceImpl implements ProjectService {
* @param project
* @param project
* @return
* @return
*/
*/
private
List
<
Map
<
String
,
Object
>>
getPermissionList
(
Project
project
)
{
private
List
<
Map
<
String
,
Object
>>
getPermissionList
(
Project
project
,
Map
<
String
,
Integer
>
planConfigurationInfo
,
boolean
isSuperAdmin
)
{
List
<
Map
<
String
,
Object
>>
permissionList
=
new
ArrayList
<>();
List
<
Map
<
String
,
Object
>>
permissionList
=
new
ArrayList
<>();
// 定制化模块权限
// 定制化模块权限
List
<
String
>
moduleShowList
=
project
.
getModuleShowList
();
List
<
String
>
moduleShowList
=
project
.
getModuleShowList
();
...
@@ -872,6 +874,20 @@ public class ProjectServiceImpl implements ProjectService {
...
@@ -872,6 +874,20 @@ public class ProjectServiceImpl implements ProjectService {
channelPermission
.
put
(
"positiveChannel"
,
Objects
.
nonNull
(
jsonObject
)
&&
Objects
.
nonNull
(
jsonObject
.
getLong
(
EmotionEnum
.
POSITIVE
.
getName
()))
&&
0
!=
jsonObject
.
getLong
(
EmotionEnum
.
POSITIVE
.
getName
()));
channelPermission
.
put
(
"positiveChannel"
,
Objects
.
nonNull
(
jsonObject
)
&&
Objects
.
nonNull
(
jsonObject
.
getLong
(
EmotionEnum
.
POSITIVE
.
getName
()))
&&
0
!=
jsonObject
.
getLong
(
EmotionEnum
.
POSITIVE
.
getName
()));
channelPermission
.
put
(
"negativeChannel"
,
Objects
.
nonNull
(
jsonObject
)
&&
Objects
.
nonNull
(
jsonObject
.
getLong
(
EmotionEnum
.
NEGATIVE
.
getName
()))
&&
0
!=
jsonObject
.
getLong
(
EmotionEnum
.
NEGATIVE
.
getName
()));
channelPermission
.
put
(
"negativeChannel"
,
Objects
.
nonNull
(
jsonObject
)
&&
Objects
.
nonNull
(
jsonObject
.
getLong
(
EmotionEnum
.
NEGATIVE
.
getName
()))
&&
0
!=
jsonObject
.
getLong
(
EmotionEnum
.
NEGATIVE
.
getName
()));
permissionList
.
add
(
channelPermission
);
permissionList
.
add
(
channelPermission
);
// 非人工项目方案编辑权限
if
(!
project
.
isManual
())
{
if
(
isSuperAdmin
)
{
Map
<
String
,
Object
>
planConfigurationPermission
=
new
HashMap
<>();
planConfigurationPermission
.
put
(
"planConfiguration"
,
1
);
permissionList
.
add
(
planConfigurationPermission
);
}
else
{
if
(
Objects
.
nonNull
(
planConfigurationInfo
.
get
(
project
.
getId
())))
{
Map
<
String
,
Object
>
planConfigurationPermission
=
new
HashMap
<>();
planConfigurationPermission
.
put
(
"planConfiguration"
,
planConfigurationInfo
.
get
(
project
.
getId
()));
permissionList
.
add
(
planConfigurationPermission
);
}
}
}
return
permissionList
;
return
permissionList
;
}
}
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/SearchWholeServiceImpl.java
View file @
859db12c
...
@@ -611,6 +611,9 @@ public class SearchWholeServiceImpl implements SearchWholeService {
...
@@ -611,6 +611,9 @@ public class SearchWholeServiceImpl implements SearchWholeService {
public
JSONObject
getSearchWholeSpreadTendency
(
SearchFilterDTO
dto
)
{
public
JSONObject
getSearchWholeSpreadTendency
(
SearchFilterDTO
dto
)
{
JSONObject
res
=
new
JSONObject
();
JSONObject
res
=
new
JSONObject
();
try
{
try
{
Long
[]
times
=
Tools
.
formatSpreadTendencyTime
(
dto
.
getStartTime
(),
dto
.
getEndTime
());
dto
.
setStartTime
(
times
[
0
]);
dto
.
setEndTime
(
times
[
1
]);
List
<
LineVO
>
totalSpreadTendency
=
getTotalSpreadTendency
(
dto
);
List
<
LineVO
>
totalSpreadTendency
=
getTotalSpreadTendency
(
dto
);
Map
<
String
,
List
<
LineVO
>>
platformSpreadTendency
=
getPlatformSpreadTendency
(
dto
);
Map
<
String
,
List
<
LineVO
>>
platformSpreadTendency
=
getPlatformSpreadTendency
(
dto
);
BaseMap
firstArticle
=
getFirstArticle
(
dto
,
totalSpreadTendency
);
BaseMap
firstArticle
=
getFirstArticle
(
dto
,
totalSpreadTendency
);
...
@@ -858,12 +861,19 @@ public class SearchWholeServiceImpl implements SearchWholeService {
...
@@ -858,12 +861,19 @@ public class SearchWholeServiceImpl implements SearchWholeService {
private
List
<
LineVO
>
getTotalSpreadTendency
(
SearchFilterDTO
dto
)
throws
IOException
{
private
List
<
LineVO
>
getTotalSpreadTendency
(
SearchFilterDTO
dto
)
throws
IOException
{
List
<
LineVO
>
res
=
new
ArrayList
<>();
List
<
LineVO
>
res
=
new
ArrayList
<>();
String
[]
indexes
=
esClientDao
.
getAllIndexes
(
dto
.
getStartTime
(),
dto
.
getEndTime
());
String
[]
indexes
=
esClientDao
.
getAllIndexes
(
dto
.
getStartTime
(),
dto
.
getEndTime
());
DateHistogramAggregationBuilder
daysAggregationBuilder
;
DateHistogramAggregationBuilder
daysAggregationBuilder
=
null
;
// 天级以小时为颗粒度,其他以天作为颗粒度
long
timeRange
=
dto
.
getEndTime
()
-
dto
.
getStartTime
();
if
(
dto
.
getEndTime
()
-
dto
.
getStartTime
()
<=
Constant
.
ONE_DAY
){
// 时间间隔≤7天,数据颗粒度为“小时级”
daysAggregationBuilder
=
AggregationBuilders
.
dateHistogram
(
"timeAgg"
).
field
(
"time"
).
calendarInterval
(
DateHistogramInterval
.
HOUR
);
if
(
timeRange
<=
Constant
.
ONE_WEEK
){
}
else
{
daysAggregationBuilder
=
AggregationBuilders
.
dateHistogram
(
"timeAgg"
).
field
(
"time"
).
calendarInterval
(
DateHistogramInterval
.
HOUR
).
offset
(
"16h"
);
daysAggregationBuilder
=
AggregationBuilders
.
dateHistogram
(
"timeAgg"
).
field
(
"time"
).
calendarInterval
(
DateHistogramInterval
.
DAY
);
}
// 7天<时间间隔≤180天,数据颗粒度为“天级”
if
(
timeRange
>
Constant
.
ONE_WEEK
&&
timeRange
<=
6
*
Constant
.
ONE_MONTH
){
daysAggregationBuilder
=
AggregationBuilders
.
dateHistogram
(
"timeAgg"
).
field
(
"time"
).
calendarInterval
(
DateHistogramInterval
.
DAY
).
offset
(
"16h"
);
}
// 180天<时间间隔,数据颗粒度为“月级”
if
(
timeRange
>
6
*
Constant
.
ONE_MONTH
){
daysAggregationBuilder
=
AggregationBuilders
.
dateHistogram
(
"timeAgg"
).
field
(
"time"
).
calendarInterval
(
DateHistogramInterval
.
MONTH
).
offset
(
"-8h"
);
}
}
// query
// query
BoolQueryBuilder
query
=
searchWholeAnalyzeQuery
(
dto
);
BoolQueryBuilder
query
=
searchWholeAnalyzeQuery
(
dto
);
...
@@ -879,6 +889,15 @@ public class SearchWholeServiceImpl implements SearchWholeService {
...
@@ -879,6 +889,15 @@ public class SearchWholeServiceImpl implements SearchWholeService {
long
count
=
bucket
.
getDocCount
();
long
count
=
bucket
.
getDocCount
();
res
.
add
(
new
LineVO
(
count
,
time
));
res
.
add
(
new
LineVO
(
count
,
time
));
});
});
// 由于结束点为开区间,将结束点数据补完
if
(
CollectionUtils
.
isNotEmpty
(
res
)){
res
.
get
(
0
).
setDate
(
dto
.
getStartTime
());
SearchFilterDTO
searchFilterDTO
=
Tools
.
convertMap
(
dto
,
SearchFilterDTO
.
class
);
searchFilterDTO
.
setStartTime
(
dto
.
getEndTime
());
searchFilterDTO
.
setEndTime
(
dto
.
getEndTime
()
+
1
);
Long
count
=
esClientDao
.
count
(
indexes
,
searchWholeAnalyzeQuery
(
searchFilterDTO
),
null
);
res
.
add
(
new
LineVO
(
count
,
dto
.
getEndTime
()));
}
return
res
;
return
res
;
}
}
...
@@ -897,12 +916,19 @@ public class SearchWholeServiceImpl implements SearchWholeService {
...
@@ -897,12 +916,19 @@ public class SearchWholeServiceImpl implements SearchWholeService {
// 平台聚合
// 平台聚合
Script
script
=
new
Script
(
"doc['c5'].value +'_' +doc['foreign'].value"
);
Script
script
=
new
Script
(
"doc['c5'].value +'_' +doc['foreign'].value"
);
TermsAggregationBuilder
platformAggregationBuilder
=
AggregationBuilders
.
terms
(
"platformAgg"
).
script
(
script
).
order
(
BucketOrder
.
count
(
false
));
TermsAggregationBuilder
platformAggregationBuilder
=
AggregationBuilders
.
terms
(
"platformAgg"
).
script
(
script
).
order
(
BucketOrder
.
count
(
false
));
DateHistogramAggregationBuilder
daysAggregationBuilder
;
DateHistogramAggregationBuilder
daysAggregationBuilder
=
null
;
// 天级以小时为颗粒度,其他以天作为颗粒度
long
timeRange
=
dto
.
getEndTime
()
-
dto
.
getStartTime
();
if
(
dto
.
getEndTime
()
-
dto
.
getStartTime
()
<=
Constant
.
ONE_DAY
){
// 时间间隔≤7天,数据颗粒度为“小时级”
daysAggregationBuilder
=
AggregationBuilders
.
dateHistogram
(
"timeAgg"
).
field
(
"time"
).
calendarInterval
(
DateHistogramInterval
.
HOUR
);
if
(
timeRange
<=
Constant
.
ONE_WEEK
){
}
else
{
daysAggregationBuilder
=
AggregationBuilders
.
dateHistogram
(
"timeAgg"
).
field
(
"time"
).
calendarInterval
(
DateHistogramInterval
.
HOUR
).
offset
(
"16h"
);
daysAggregationBuilder
=
AggregationBuilders
.
dateHistogram
(
"timeAgg"
).
field
(
"time"
).
calendarInterval
(
DateHistogramInterval
.
DAY
);
}
// 7天<时间间隔≤180天,数据颗粒度为“天级”
if
(
timeRange
>
Constant
.
ONE_WEEK
&&
timeRange
<=
6
*
Constant
.
ONE_MONTH
){
daysAggregationBuilder
=
AggregationBuilders
.
dateHistogram
(
"timeAgg"
).
field
(
"time"
).
calendarInterval
(
DateHistogramInterval
.
DAY
).
offset
(
"16h"
);
}
// 180天<时间间隔,数据颗粒度为“月级”
if
(
timeRange
>
6
*
Constant
.
ONE_MONTH
){
daysAggregationBuilder
=
AggregationBuilders
.
dateHistogram
(
"timeAgg"
).
field
(
"time"
).
calendarInterval
(
DateHistogramInterval
.
MONTH
).
offset
(
"-8h"
);
}
}
// query
// query
BoolQueryBuilder
query
=
searchWholeAnalyzeQuery
(
dto
);
BoolQueryBuilder
query
=
searchWholeAnalyzeQuery
(
dto
);
...
@@ -936,9 +962,24 @@ public class SearchWholeServiceImpl implements SearchWholeService {
...
@@ -936,9 +962,24 @@ public class SearchWholeServiceImpl implements SearchWholeService {
});
});
}
}
});
});
// 合并数据
platformLines
.
forEach
((
k1
,
v1
)
->
{
platformLines
.
forEach
((
k1
,
v1
)
->
{
List
<
LineVO
>
line
=
new
ArrayList
<>();
List
<
LineVO
>
line
=
new
ArrayList
<>();
v1
.
forEach
((
k2
,
v2
)
->
line
.
add
(
new
LineVO
(
v2
,
Long
.
valueOf
(
k2
))));
v1
.
forEach
((
k2
,
v2
)
->
line
.
add
(
new
LineVO
(
v2
,
Long
.
valueOf
(
k2
))));
// 结束点数据补充完全
if
(
CollectionUtils
.
isNotEmpty
(
line
)){
line
.
get
(
0
).
setDate
(
dto
.
getStartTime
());
SearchFilterDTO
searchFilterDTO
=
Tools
.
convertMap
(
dto
,
SearchFilterDTO
.
class
);
searchFilterDTO
.
setPlatforms
(
Collections
.
singletonList
(
GlobalPojo
.
getPlatformIdByName
(
k1
)));
searchFilterDTO
.
setStartTime
(
dto
.
getEndTime
());
searchFilterDTO
.
setEndTime
(
dto
.
getEndTime
()
+
1
);
Long
count
=
0L
;
try
{
count
=
esClientDao
.
count
(
indexes
,
searchWholeAnalyzeQuery
(
searchFilterDTO
),
null
);
}
catch
(
IOException
ignore
)
{
}
line
.
add
(
new
LineVO
(
count
,
dto
.
getEndTime
()));
}
res
.
put
(
k1
,
line
);
res
.
put
(
k1
,
line
);
});
});
return
res
;
return
res
;
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/UserServiceImpl.java
View file @
859db12c
...
@@ -239,6 +239,10 @@ public class UserServiceImpl implements UserService {
...
@@ -239,6 +239,10 @@ public class UserServiceImpl implements UserService {
OptionalInt
.
of
(
userDTO
.
getSearchWholeRights
()).
ifPresent
(
userRole:
:
setSearchWholeRights
);
OptionalInt
.
of
(
userDTO
.
getSearchWholeRights
()).
ifPresent
(
userRole:
:
setSearchWholeRights
);
OptionalInt
.
of
(
userDTO
.
getSearchWholeRange
()).
ifPresent
(
userRole:
:
setSearchWholeRange
);
OptionalInt
.
of
(
userDTO
.
getSearchWholeRange
()).
ifPresent
(
userRole:
:
setSearchWholeRange
);
}
}
// 方案编辑权限
if
(!
GlobalPojo
.
PROJECT_MAP
.
get
(
userRole
.
getProjectId
()).
isManual
()){
userRole
.
setPlanConfiguration
(
userDTO
.
getPlanConfiguration
());
}
userDao
.
updateOneByIdWithField
(
userDTO
.
getId
(),
new
Update
().
set
(
"roles"
,
roles
));
userDao
.
updateOneByIdWithField
(
userDTO
.
getId
(),
new
Update
().
set
(
"roles"
,
roles
));
});
});
Optional
.
of
(
userDTO
.
getNickname
()).
ifPresent
(
nickName
->
userDao
.
updateOneByIdWithField
(
userDTO
.
getId
(),
new
Update
().
set
(
"nickname"
,
nickName
)));
Optional
.
of
(
userDTO
.
getNickname
()).
ifPresent
(
nickName
->
userDao
.
updateOneByIdWithField
(
userDTO
.
getId
(),
new
Update
().
set
(
"nickname"
,
nickName
)));
...
@@ -332,8 +336,13 @@ public class UserServiceImpl implements UserService {
...
@@ -332,8 +336,13 @@ public class UserServiceImpl implements UserService {
if
(
RoleEnum
.
CUSTOMER
.
getState
()
==
userProject
.
getRoleId
())
{
if
(
RoleEnum
.
CUSTOMER
.
getState
()
==
userProject
.
getRoleId
())
{
expiredTime
=
userProject
.
getExpiredTime
();
expiredTime
=
userProject
.
getExpiredTime
();
}
}
// 方案编辑权限默认
Integer
planConfiguration
=
null
;
if
(!
project
.
isManual
()){
planConfiguration
=
1
;
}
// 给默认全网搜权益
// 给默认全网搜权益
userRoles
.
add
(
new
UserRole
(
project
.
getId
(),
userProject
.
getRoleId
(),
expiredTime
,
userProject
.
getExportAmount
(),
1
,
1
));
userRoles
.
add
(
new
UserRole
(
project
.
getId
(),
userProject
.
getRoleId
(),
expiredTime
,
userProject
.
getExportAmount
(),
1
,
1
,
planConfiguration
));
hit
.
set
(
true
);
hit
.
set
(
true
);
}
}
});
});
...
@@ -462,6 +471,7 @@ public class UserServiceImpl implements UserService {
...
@@ -462,6 +471,7 @@ public class UserServiceImpl implements UserService {
jsonObject
.
put
(
"key"
,
role
.
getKey
());
jsonObject
.
put
(
"key"
,
role
.
getKey
());
jsonObject
.
put
(
"searchWholeRights"
,
role
.
getSearchWholeRights
());
jsonObject
.
put
(
"searchWholeRights"
,
role
.
getSearchWholeRights
());
jsonObject
.
put
(
"searchWholeRange"
,
role
.
getSearchWholeRange
());
jsonObject
.
put
(
"searchWholeRange"
,
role
.
getSearchWholeRange
());
jsonObject
.
put
(
"planConfiguration"
,
role
.
getPlanConfiguration
());
resList
.
add
(
jsonObject
);
resList
.
add
(
jsonObject
);
}
}
}
}
...
@@ -549,6 +559,7 @@ public class UserServiceImpl implements UserService {
...
@@ -549,6 +559,7 @@ public class UserServiceImpl implements UserService {
json
.
put
(
"expiredTime"
,
role
.
getExpiredTime
());
json
.
put
(
"expiredTime"
,
role
.
getExpiredTime
());
json
.
put
(
"searchWholeRights"
,
role
.
getSearchWholeRights
());
json
.
put
(
"searchWholeRights"
,
role
.
getSearchWholeRights
());
json
.
put
(
"searchWholeRange"
,
role
.
getSearchWholeRange
());
json
.
put
(
"searchWholeRange"
,
role
.
getSearchWholeRange
());
json
.
put
(
"planConfiguration"
,
role
.
getPlanConfiguration
());
return
json
;
return
json
;
}).
filter
(
Objects:
:
nonNull
).
collect
(
Collectors
.
toList
());
}).
filter
(
Objects:
:
nonNull
).
collect
(
Collectors
.
toList
());
jsonObject
.
put
(
"roles"
,
roles
);
jsonObject
.
put
(
"roles"
,
roles
);
...
@@ -626,6 +637,7 @@ public class UserServiceImpl implements UserService {
...
@@ -626,6 +637,7 @@ public class UserServiceImpl implements UserService {
result
.
put
(
"exportAmount"
,
userRole
.
getExportAmount
());
result
.
put
(
"exportAmount"
,
userRole
.
getExportAmount
());
result
.
put
(
"searchWholeRights"
,
userRole
.
getSearchWholeRights
());
result
.
put
(
"searchWholeRights"
,
userRole
.
getSearchWholeRights
());
result
.
put
(
"searchWholeRange"
,
userRole
.
getSearchWholeRange
());
result
.
put
(
"searchWholeRange"
,
userRole
.
getSearchWholeRange
());
result
.
put
(
"planConfiguration"
,
userRole
.
getPlanConfiguration
());
});
});
return
result
;
return
result
;
}).
collect
(
Collectors
.
toList
());
}).
collect
(
Collectors
.
toList
());
...
...
src/main/java/com/zhiwei/brandkbs2/util/Tools.java
View file @
859db12c
...
@@ -1397,4 +1397,29 @@ public class Tools {
...
@@ -1397,4 +1397,29 @@ public class Tools {
long
ss
=
BigDecimal
.
valueOf
(
temp
).
divideAndRemainder
(
BigDecimal
.
valueOf
(
60
))[
1
].
setScale
(
0
,
RoundingMode
.
HALF_UP
).
longValue
();
long
ss
=
BigDecimal
.
valueOf
(
temp
).
divideAndRemainder
(
BigDecimal
.
valueOf
(
60
))[
1
].
setScale
(
0
,
RoundingMode
.
HALF_UP
).
longValue
();
return
((
mm
<
10
?
(
"0"
+
mm
)
:
mm
)
+
":"
+
(
ss
<
10
?
(
"0"
+
ss
)
:
ss
));
return
((
mm
<
10
?
(
"0"
+
mm
)
:
mm
)
+
":"
+
(
ss
<
10
?
(
"0"
+
ss
)
:
ss
));
}
}
public
static
Long
[]
formatSpreadTendencyTime
(
long
sTime
,
long
eTime
){
long
timeRange
=
eTime
-
sTime
;
Calendar
calendar1
=
Calendar
.
getInstance
();
calendar1
.
setTime
(
new
Date
(
sTime
));
Calendar
calendar2
=
Calendar
.
getInstance
();
calendar2
.
setTime
(
new
Date
(
eTime
));
calendar1
.
set
(
Calendar
.
MINUTE
,
0
);
calendar1
.
set
(
Calendar
.
SECOND
,
0
);
calendar1
.
set
(
Calendar
.
MILLISECOND
,
0
);
calendar2
.
set
(
Calendar
.
MINUTE
,
0
);
calendar2
.
set
(
Calendar
.
SECOND
,
0
);
calendar2
.
set
(
Calendar
.
MILLISECOND
,
0
);
if
(
timeRange
>
Constant
.
ONE_WEEK
&&
timeRange
<=
6
*
Constant
.
ONE_MONTH
){
calendar1
.
set
(
Calendar
.
HOUR_OF_DAY
,
0
);
calendar2
.
set
(
Calendar
.
HOUR_OF_DAY
,
0
);
}
if
(
timeRange
>
6
*
Constant
.
ONE_MONTH
){
calendar1
.
set
(
Calendar
.
HOUR_OF_DAY
,
0
);
calendar2
.
set
(
Calendar
.
HOUR_OF_DAY
,
0
);
calendar1
.
set
(
Calendar
.
DAY_OF_MONTH
,
1
);
calendar2
.
set
(
Calendar
.
DAY_OF_MONTH
,
1
);
}
return
new
Long
[]{
calendar1
.
getTime
().
getTime
(),
calendar2
.
getTime
().
getTime
()};
}
}
}
\ No newline at end of file
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