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
295996b0
Commit
295996b0
authored
Dec 19, 2024
by
shenjunjie
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature' into 'release'
舆情分析趋势图修复 See merge request
!607
parents
450d4453
1f8c813c
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
17 deletions
+37
-17
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkDataServiceImpl.java
+8
-8
src/main/java/com/zhiwei/brandkbs2/service/impl/SearchWholeServiceImpl.java
+5
-4
src/main/java/com/zhiwei/brandkbs2/util/Tools.java
+24
-5
No files found.
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkDataServiceImpl.java
View file @
295996b0
...
@@ -4476,9 +4476,9 @@ public class MarkDataServiceImpl implements MarkDataService {
...
@@ -4476,9 +4476,9 @@ 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
));
}
}
List
<
LineVO
>
resLine
=
Tools
.
completeLine
(
line
,
dto
.
getStartTime
(),
dto
.
getEndTime
());
// 由于结束点为开区间,将结束点数据补完
// 由于结束点为开区间,将结束点数据补完
if
(
CollectionUtils
.
isNotEmpty
(
line
)){
if
(
CollectionUtils
.
isNotEmpty
(
resLine
)){
line
.
get
(
0
).
setDate
(
dto
.
getStartTime
());
MarkSearchDTO
searchDTO
=
Tools
.
convertMap
(
dto
,
MarkSearchDTO
.
class
);
MarkSearchDTO
searchDTO
=
Tools
.
convertMap
(
dto
,
MarkSearchDTO
.
class
);
searchDTO
.
setPlatforms
(
Collections
.
singletonList
(
platformId
));
searchDTO
.
setPlatforms
(
Collections
.
singletonList
(
platformId
));
searchDTO
.
setStartTime
(
dto
.
getEndTime
());
searchDTO
.
setStartTime
(
dto
.
getEndTime
());
...
@@ -4488,9 +4488,9 @@ public class MarkDataServiceImpl implements MarkDataService {
...
@@ -4488,9 +4488,9 @@ public class MarkDataServiceImpl implements MarkDataService {
count
=
esClientDao
.
count
(
indexes
,
yuqingAnalyzeQuery
(
searchDTO
),
null
);
count
=
esClientDao
.
count
(
indexes
,
yuqingAnalyzeQuery
(
searchDTO
),
null
);
}
catch
(
IOException
ignore
)
{
}
catch
(
IOException
ignore
)
{
}
}
l
ine
.
add
(
new
LineVO
(
count
,
dto
.
getEndTime
()));
resL
ine
.
add
(
new
LineVO
(
count
,
dto
.
getEndTime
()));
}
}
res
.
put
(
GlobalPojo
.
getPlatformNameById
(
platformId
),
l
ine
);
res
.
put
(
GlobalPojo
.
getPlatformNameById
(
platformId
),
resL
ine
);
});
});
return
res
;
return
res
;
}
}
...
@@ -4533,14 +4533,14 @@ public class MarkDataServiceImpl implements MarkDataService {
...
@@ -4533,14 +4533,14 @@ 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
));
});
});
List
<
LineVO
>
resLine
=
Tools
.
completeLine
(
res
,
dto
.
getStartTime
(),
dto
.
getEndTime
());
// 由于结束点为开区间,将结束点数据补完
// 由于结束点为开区间,将结束点数据补完
if
(
CollectionUtils
.
isNotEmpty
(
res
)){
if
(
CollectionUtils
.
isNotEmpty
(
resLine
)
&&
!
Objects
.
equals
(
resLine
.
get
(
resLine
.
size
()
-
1
).
getDate
(),
dto
.
getEndTime
())){
res
.
get
(
0
).
setDate
(
dto
.
getStartTime
());
MarkSearchDTO
secondDTO
=
Tools
.
convertMap
(
dto
,
MarkSearchDTO
.
class
);
MarkSearchDTO
secondDTO
=
Tools
.
convertMap
(
dto
,
MarkSearchDTO
.
class
);
secondDTO
.
setStartTime
(
dto
.
getEndTime
());
secondDTO
.
setStartTime
(
dto
.
getEndTime
());
secondDTO
.
setEndTime
(
dto
.
getEndTime
()
+
1
);
secondDTO
.
setEndTime
(
dto
.
getEndTime
()
+
1
);
Long
count
=
esClientDao
.
count
(
indexes
,
yuqingAnalyzeQuery
(
secondDTO
,
emotion
,
null
),
null
);
Long
count
=
esClientDao
.
count
(
indexes
,
yuqingAnalyzeQuery
(
secondDTO
,
emotion
,
null
),
null
);
res
.
add
(
new
LineVO
(
count
,
dto
.
getEndTime
()));
res
Line
.
add
(
new
LineVO
(
count
,
dto
.
getEndTime
()));
}
}
// 走势图最高点的聚合标题
// 走势图最高点的聚合标题
String
maxAggTitle
=
null
;
String
maxAggTitle
=
null
;
...
@@ -4552,7 +4552,7 @@ public class MarkDataServiceImpl implements MarkDataService {
...
@@ -4552,7 +4552,7 @@ public class MarkDataServiceImpl implements MarkDataService {
// 没有拿到聚合标题,说明此时发文的平台为微博
// 没有拿到聚合标题,说明此时发文的平台为微博
maxAggTitle
=
CollectionUtils
.
isEmpty
(
titleBuckets
)
?
null
:
titleBuckets
.
get
(
0
).
getKeyAsString
();
maxAggTitle
=
CollectionUtils
.
isEmpty
(
titleBuckets
)
?
null
:
titleBuckets
.
get
(
0
).
getKeyAsString
();
}
}
return
Pair
.
of
(
maxAggTitle
,
res
);
return
Pair
.
of
(
maxAggTitle
,
res
Line
);
}
}
private
Long
getYuqingAnalyzeCount
(
MarkSearchDTO
dto
,
String
emotion
)
throws
IOException
{
private
Long
getYuqingAnalyzeCount
(
MarkSearchDTO
dto
,
String
emotion
)
throws
IOException
{
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/SearchWholeServiceImpl.java
View file @
295996b0
...
@@ -840,6 +840,8 @@ public class SearchWholeServiceImpl implements SearchWholeService {
...
@@ -840,6 +840,8 @@ public class SearchWholeServiceImpl implements SearchWholeService {
endTime
=
startIndex
==
totalSpreadTendency
.
size
()
-
1
?
endTime
:
totalSpreadTendency
.
get
(
startIndex
+
1
).
getDate
();
endTime
=
startIndex
==
totalSpreadTendency
.
size
()
-
1
?
endTime
:
totalSpreadTendency
.
get
(
startIndex
+
1
).
getDate
();
dto
.
setStartTime
(
startTime
);
dto
.
setStartTime
(
startTime
);
dto
.
setEndTime
(
endTime
);
dto
.
setEndTime
(
endTime
);
dto
.
setPlatforms
(
null
);
dto
.
setVideoPlatforms
(
null
);
// indexes
// indexes
String
[]
indexes
=
esClientDao
.
getAllIndexes
(
dto
.
getStartTime
(),
dto
.
getEndTime
());
String
[]
indexes
=
esClientDao
.
getAllIndexes
(
dto
.
getStartTime
(),
dto
.
getEndTime
());
BoolQueryBuilder
query
=
searchWholeAnalyzeQuery
(
dto
);
BoolQueryBuilder
query
=
searchWholeAnalyzeQuery
(
dto
);
...
@@ -891,8 +893,7 @@ public class SearchWholeServiceImpl implements SearchWholeService {
...
@@ -891,8 +893,7 @@ public class SearchWholeServiceImpl implements SearchWholeService {
});
});
List
<
LineVO
>
resLine
=
Tools
.
completeLine
(
res
,
dto
.
getStartTime
(),
dto
.
getEndTime
());
List
<
LineVO
>
resLine
=
Tools
.
completeLine
(
res
,
dto
.
getStartTime
(),
dto
.
getEndTime
());
// 由于结束点为开区间,将结束点数据补完
// 由于结束点为开区间,将结束点数据补完
if
(
CollectionUtils
.
isNotEmpty
(
resLine
)){
if
(
CollectionUtils
.
isNotEmpty
(
resLine
)
&&
!
Objects
.
equals
(
resLine
.
get
(
resLine
.
size
()
-
1
).
getDate
(),
dto
.
getEndTime
())){
// res.get(0).setDate(dto.getStartTime());
SearchFilterDTO
searchFilterDTO
=
Tools
.
convertMap
(
dto
,
SearchFilterDTO
.
class
);
SearchFilterDTO
searchFilterDTO
=
Tools
.
convertMap
(
dto
,
SearchFilterDTO
.
class
);
searchFilterDTO
.
setStartTime
(
dto
.
getEndTime
());
searchFilterDTO
.
setStartTime
(
dto
.
getEndTime
());
searchFilterDTO
.
setEndTime
(
dto
.
getEndTime
()
+
1
);
searchFilterDTO
.
setEndTime
(
dto
.
getEndTime
()
+
1
);
...
@@ -966,11 +967,11 @@ public class SearchWholeServiceImpl implements SearchWholeService {
...
@@ -966,11 +967,11 @@ public class SearchWholeServiceImpl implements SearchWholeService {
// 合并数据
// 合并数据
platformLines
.
forEach
((
k1
,
v1
)
->
{
platformLines
.
forEach
((
k1
,
v1
)
->
{
List
<
LineVO
>
line
=
new
ArrayList
<>();
List
<
LineVO
>
line
=
new
ArrayList
<>();
v1
=
v1
.
entrySet
().
stream
().
sorted
(
Comparator
.
comparing
((
Map
.
Entry
<
String
,
Long
>
entry
)
->
Long
.
valueOf
(
entry
.
getKey
()))).
collect
(
Collectors
.
toMap
(
Map
.
Entry
::
getKey
,
Map
.
Entry
::
getValue
,
(
e1
,
e2
)
->
e2
,
LinkedHashMap:
:
new
));
v1
.
forEach
((
k2
,
v2
)
->
line
.
add
(
new
LineVO
(
v2
,
Long
.
valueOf
(
k2
))));
v1
.
forEach
((
k2
,
v2
)
->
line
.
add
(
new
LineVO
(
v2
,
Long
.
valueOf
(
k2
))));
List
<
LineVO
>
resLine
=
Tools
.
completeLine
(
line
,
dto
.
getStartTime
(),
dto
.
getEndTime
());
List
<
LineVO
>
resLine
=
Tools
.
completeLine
(
line
,
dto
.
getStartTime
(),
dto
.
getEndTime
());
// 结束点数据补充完全
// 结束点数据补充完全
if
(
CollectionUtils
.
isNotEmpty
(
resLine
)){
if
(
CollectionUtils
.
isNotEmpty
(
resLine
)
&&
!
Objects
.
equals
(
resLine
.
get
(
resLine
.
size
()
-
1
).
getDate
(),
dto
.
getEndTime
())){
// line.get(0).setDate(dto.getStartTime());
SearchFilterDTO
searchFilterDTO
=
Tools
.
convertMap
(
dto
,
SearchFilterDTO
.
class
);
SearchFilterDTO
searchFilterDTO
=
Tools
.
convertMap
(
dto
,
SearchFilterDTO
.
class
);
searchFilterDTO
.
setPlatforms
(
Collections
.
singletonList
(
GlobalPojo
.
getPlatformIdByName
(
k1
)));
searchFilterDTO
.
setPlatforms
(
Collections
.
singletonList
(
GlobalPojo
.
getPlatformIdByName
(
k1
)));
searchFilterDTO
.
setStartTime
(
dto
.
getEndTime
());
searchFilterDTO
.
setStartTime
(
dto
.
getEndTime
());
...
...
src/main/java/com/zhiwei/brandkbs2/util/Tools.java
View file @
295996b0
...
@@ -1432,14 +1432,27 @@ public class Tools {
...
@@ -1432,14 +1432,27 @@ public class Tools {
* @return
* @return
*/
*/
public
static
List
<
LineVO
>
completeLine
(
List
<
LineVO
>
lines
,
Long
startTime
,
Long
endTime
){
public
static
List
<
LineVO
>
completeLine
(
List
<
LineVO
>
lines
,
Long
startTime
,
Long
endTime
){
int
size
=
endTime
-
startTime
>
7
*
Constant
.
ONE_DAY
?
30
:
(
endTime
-
startTime
<=
Constant
.
ONE_DAY
?
24
:
7
);
int
size
=
0
;
long
timeRange
=
7
==
size
||
30
==
size
?
Constant
.
ONE_DAY
:
Constant
.
ONE_HOUR
;
long
timeGap
=
endTime
-
startTime
;
int
timeType
=
0
;
if
(
timeGap
<=
Constant
.
ONE_WEEK
){
size
=
new
Period
(
startTime
,
endTime
,
PeriodType
.
hours
()).
getHours
();
timeType
=
1
;
}
if
(
timeGap
>
Constant
.
ONE_WEEK
&&
timeGap
<=
6
*
Constant
.
ONE_MONTH
){
size
=
new
Period
(
startTime
,
endTime
,
PeriodType
.
days
()).
getDays
();
timeType
=
2
;
}
if
(
timeGap
>
6
*
Constant
.
ONE_MONTH
){
size
=
new
Period
(
startTime
,
endTime
,
PeriodType
.
months
()).
getMonths
();
timeType
=
3
;
}
if
(
lines
.
size
()
<
size
){
if
(
lines
.
size
()
<
size
){
// 无数据,按时间段全部补为0
// 无数据,按时间段全部补为0
if
(
CollectionUtils
.
isEmpty
(
lines
)){
if
(
CollectionUtils
.
isEmpty
(
lines
)){
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
lines
.
add
(
new
LineVO
(
0L
,
startTime
));
lines
.
add
(
new
LineVO
(
0L
,
startTime
));
startTime
=
startTime
+
timeRange
;
startTime
=
1
==
timeType
?
DateUtils
.
addHours
(
new
Date
(
startTime
),
1
).
getTime
()
:
2
==
timeType
?
DateUtils
.
addDays
(
new
Date
(
startTime
),
1
).
getTime
()
:
DateUtils
.
addMonths
(
new
Date
(
startTime
),
1
).
getTime
()
;
if
(
startTime
>=
endTime
||
lines
.
size
()
>=
size
){
if
(
startTime
>=
endTime
||
lines
.
size
()
>=
size
){
break
;
break
;
}
}
...
@@ -1450,8 +1463,11 @@ public class Tools {
...
@@ -1450,8 +1463,11 @@ public class Tools {
LineVO
startLine
=
lines
.
get
(
0
);
LineVO
startLine
=
lines
.
get
(
0
);
Long
startLineTime
=
startLine
.
getDate
();
Long
startLineTime
=
startLine
.
getDate
();
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
startLineTime
=
startLineTime
-
timeRange
;
startLineTime
=
1
==
timeType
?
DateUtils
.
addHours
(
new
Date
(
startLineTime
),
-
1
).
getTime
()
:
2
==
timeType
?
DateUtils
.
addDays
(
new
Date
(
startLineTime
),
-
1
).
getTime
()
:
DateUtils
.
addMonths
(
new
Date
(
startLineTime
),
-
1
).
getTime
()
;
if
(
startLineTime
<=
startTime
||
lines
.
size
()
>=
size
){
if
(
startLineTime
<=
startTime
||
lines
.
size
()
>=
size
){
if
(
startLineTime
.
equals
(
startTime
))
{
lines
.
add
(
0
,
new
LineVO
(
0L
,
startLineTime
));
}
break
;
break
;
}
}
lines
.
add
(
0
,
new
LineVO
(
0L
,
startLineTime
));
lines
.
add
(
0
,
new
LineVO
(
0L
,
startLineTime
));
...
@@ -1460,8 +1476,11 @@ public class Tools {
...
@@ -1460,8 +1476,11 @@ public class Tools {
LineVO
endLine
=
lines
.
get
(
lines
.
size
()
-
1
);
LineVO
endLine
=
lines
.
get
(
lines
.
size
()
-
1
);
Long
endLineTime
=
endLine
.
getDate
();
Long
endLineTime
=
endLine
.
getDate
();
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
endLineTime
=
endLineTime
+
timeRange
;
endLineTime
=
1
==
timeType
?
DateUtils
.
addHours
(
new
Date
(
endLineTime
),
1
).
getTime
()
:
2
==
timeType
?
DateUtils
.
addDays
(
new
Date
(
endLineTime
),
1
).
getTime
()
:
DateUtils
.
addMonths
(
new
Date
(
endLineTime
),
1
).
getTime
()
;
if
(
endLineTime
>=
endTime
||
lines
.
size
()
>=
size
){
if
(
endLineTime
>=
endTime
||
lines
.
size
()
>=
size
){
if
(
endLineTime
.
equals
(
endTime
))
{
lines
.
add
(
new
LineVO
(
0L
,
endLineTime
));
}
break
;
break
;
}
}
lines
.
add
(
new
LineVO
(
0L
,
endLineTime
));
lines
.
add
(
new
LineVO
(
0L
,
endLineTime
));
...
...
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