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
4f1a595f
Commit
4f1a595f
authored
Aug 10, 2022
by
shenjunjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2022/8/10 9:44
parent
9277c5d1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
115 additions
and
20 deletions
+115
-20
src/main/java/com/zhiwei/brandkbs2/dao/impl/EventDaoImpl.java
+1
-0
src/main/java/com/zhiwei/brandkbs2/pojo/Channel.java
+1
-0
src/main/java/com/zhiwei/brandkbs2/service/ChannelService.java
+6
-0
src/main/java/com/zhiwei/brandkbs2/service/impl/ChannelServiceImpl.java
+76
-14
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkDataServiceImpl.java
+6
-6
src/main/java/com/zhiwei/brandkbs2/util/Tools.java
+25
-0
No files found.
src/main/java/com/zhiwei/brandkbs2/dao/impl/EventDaoImpl.java
View file @
4f1a595f
...
@@ -77,6 +77,7 @@ public class EventDaoImpl extends BaseMongoDaoImpl<Event> implements EventDao {
...
@@ -77,6 +77,7 @@ public class EventDaoImpl extends BaseMongoDaoImpl<Event> implements EventDao {
Aggregation
.
group
(
"patternDate"
).
count
().
as
(
"eventCount"
));
Aggregation
.
group
(
"patternDate"
).
count
().
as
(
"eventCount"
));
AggregationResults
<
JSONObject
>
aggregate
=
mongoTemplate
.
aggregate
(
agg
,
getAggreeCollection
(),
JSONObject
.
class
);
AggregationResults
<
JSONObject
>
aggregate
=
mongoTemplate
.
aggregate
(
agg
,
getAggreeCollection
(),
JSONObject
.
class
);
List
<
JSONObject
>
mappedResults
=
aggregate
.
getMappedResults
();
List
<
JSONObject
>
mappedResults
=
aggregate
.
getMappedResults
();
// TODO
return
new
HashMap
<>();
return
new
HashMap
<>();
}
}
...
...
src/main/java/com/zhiwei/brandkbs2/pojo/Channel.java
View file @
4f1a595f
...
@@ -92,6 +92,7 @@ public class Channel extends ChannelIndex {
...
@@ -92,6 +92,7 @@ public class Channel extends ChannelIndex {
channel
.
setCTime
(
new
Date
().
getTime
());
channel
.
setCTime
(
new
Date
().
getTime
());
channel
.
setProjectId
(
channelIndex
.
getProjectId
());
channel
.
setProjectId
(
channelIndex
.
getProjectId
());
channel
.
setLinkedGroupId
(
channelIndex
.
getLinkedGroupId
());
channel
.
setLinkedGroupId
(
channelIndex
.
getLinkedGroupId
());
channel
.
setContendId
(
channelIndex
.
getContendId
());
channel
.
setPlatform
(
channelIndex
.
getPlatform
());
channel
.
setPlatform
(
channelIndex
.
getPlatform
());
channel
.
setRealSource
(
channelIndex
.
getRealSource
());
channel
.
setRealSource
(
channelIndex
.
getRealSource
());
channel
.
setSource
(
channelIndex
.
getSource
());
channel
.
setSource
(
channelIndex
.
getSource
());
...
...
src/main/java/com/zhiwei/brandkbs2/service/ChannelService.java
View file @
4f1a595f
...
@@ -219,4 +219,10 @@ public interface ChannelService {
...
@@ -219,4 +219,10 @@ public interface ChannelService {
* @return 稿件信息
* @return 稿件信息
*/
*/
List
<
ExportAppChannelArticleDTO
>
downloadArticlesByTime
(
Long
startTime
,
Long
endTime
,
String
channelId
,
String
contendId
);
List
<
ExportAppChannelArticleDTO
>
downloadArticlesByTime
(
Long
startTime
,
Long
endTime
,
String
channelId
,
String
contendId
);
/**
* 计算渠道倾向及指数
* @param channelId 渠道ID
*/
void
calculateChannelEmotionIndex
(
String
channelId
);
}
}
src/main/java/com/zhiwei/brandkbs2/service/impl/ChannelServiceImpl.java
View file @
4f1a595f
...
@@ -668,6 +668,37 @@ public class ChannelServiceImpl implements ChannelService {
...
@@ -668,6 +668,37 @@ public class ChannelServiceImpl implements ChannelService {
return
futureList
.
stream
().
map
(
CompletableFuture:
:
join
).
collect
(
Collectors
.
toList
());
return
futureList
.
stream
().
map
(
CompletableFuture:
:
join
).
collect
(
Collectors
.
toList
());
}
}
@Override
public
void
calculateChannelEmotionIndex
(
String
channelId
)
{
try
{
Channel
channel
=
channelDao
.
findOneById
(
channelId
);
// 数据格式变化未含有contendId部分
if
(
null
==
channel
.
getContendId
())
{
channel
.
setContendId
(
"0"
);
}
if
(
hasEmotion
(
channel
))
{
//该渠道发布正面稿件
Long
positiveCount
=
markCountByEmotion
(
channel
,
EmotionEnum
.
POSITIVE
.
getName
());
//该渠道发布中性稿件
Long
neutralCount
=
markCountByEmotion
(
channel
,
EmotionEnum
.
NEUTRAL
.
getName
());
//该渠道发布负面稿件
Long
negativeCount
=
markCountByEmotion
(
channel
,
EmotionEnum
.
NEGATIVE
.
getName
());
//是否友好渠道
boolean
isPositive
=
false
;
}
}
catch
(
Exception
e
)
{
log
.
error
(
"calculateChannelEmotionIndex-"
,
e
);
}
}
private
Long
markCountByEmotion
(
Channel
channel
,
String
emotion
)
throws
IOException
{
BoolQueryBuilder
postFilter
=
MarkDataServiceImpl
.
projectLinkedGroupContendIdQuery
(
channel
.
getProjectId
(),
channel
.
getLinkedGroupId
(),
channel
.
getContendId
());
postFilter
.
must
(
QueryBuilders
.
termQuery
(
"brandkbs_mark_cache_maps.name.keyword"
,
emotion
));
return
esClientDao
.
count
(
postFilter
);
}
private
Map
<
String
,
List
<
ChannelIndex
.
Article
>>
getSourceContendMap
(
String
channelId
,
Collection
<
String
>
contendIds
,
String
platform
,
String
keyword
,
Long
startTime
,
Long
endTime
)
{
private
Map
<
String
,
List
<
ChannelIndex
.
Article
>>
getSourceContendMap
(
String
channelId
,
Collection
<
String
>
contendIds
,
String
platform
,
String
keyword
,
Long
startTime
,
Long
endTime
)
{
try
{
try
{
String
projectId
=
UserThreadLocal
.
getProjectId
();
String
projectId
=
UserThreadLocal
.
getProjectId
();
...
@@ -704,9 +735,8 @@ public class ChannelServiceImpl implements ChannelService {
...
@@ -704,9 +735,8 @@ public class ChannelServiceImpl implements ChannelService {
res
.
put
(
"negativeCount"
,
negativeCount
);
res
.
put
(
"negativeCount"
,
negativeCount
);
res
.
put
(
"articleTotal"
,
total
);
res
.
put
(
"articleTotal"
,
total
);
// 做分母时不能为0
// 做分母时不能为0
total
=
0
==
total
?
1
:
total
;
res
.
put
(
"positivePercent"
,
BigDecimal
.
valueOf
((
double
)
positiveCount
*
100
/
(
0
==
total
?
1
:
total
)).
setScale
(
1
,
RoundingMode
.
UP
));
res
.
put
(
"positivePercent"
,
new
BigDecimal
((
double
)
positiveCount
*
100
/
total
).
setScale
(
1
,
RoundingMode
.
UP
));
res
.
put
(
"negativePercent"
,
BigDecimal
.
valueOf
((
double
)
negativeCount
*
100
/
(
0
==
total
?
1
:
total
)).
setScale
(
1
,
RoundingMode
.
UP
));
res
.
put
(
"negativePercent"
,
new
BigDecimal
((
double
)
negativeCount
*
100
/
total
).
setScale
(
1
,
RoundingMode
.
UP
));
return
Pair
.
of
(
total
,
res
);
return
Pair
.
of
(
total
,
res
);
}
}
...
@@ -743,23 +773,21 @@ public class ChannelServiceImpl implements ChannelService {
...
@@ -743,23 +773,21 @@ public class ChannelServiceImpl implements ChannelService {
private
List
<
JSONObject
>
spreadingTendData
(
Long
startTime
,
Long
endTime
,
List
<
ChannelIndex
.
Article
>
articleList
,
String
timePattern
)
{
private
List
<
JSONObject
>
spreadingTendData
(
Long
startTime
,
Long
endTime
,
List
<
ChannelIndex
.
Article
>
articleList
,
String
timePattern
)
{
// 按日分组并根据id去重保留最近标注时间
// 按日分组并根据id去重保留最近标注时间
Map
<
Long
,
List
<
ChannelIndex
.
Article
>>
dateListMap
=
partition
(
startTime
,
endTime
,
timePattern
,
articleList
);
Map
<
Long
,
List
<
ChannelIndex
.
Article
>>
dateListMap
=
partition
(
startTime
,
endTime
,
timePattern
,
articleList
);
List
<
JSONObject
>
collect
=
dateListMap
.
entrySet
().
stream
().
sorted
(
Comparator
.
comparingLong
(
Map
.
Entry
::
getKey
)).
map
(
e
->
{
return
dateListMap
.
entrySet
().
stream
().
sorted
(
Comparator
.
comparingLong
(
Map
.
Entry
::
getKey
)).
map
(
e
->
{
JSONObject
spreadJson
=
new
JSONObject
();
JSONObject
spreadJson
=
new
JSONObject
();
spreadJson
.
put
(
"time"
,
e
.
getKey
());
spreadJson
.
put
(
"time"
,
e
.
getKey
());
spreadJson
.
put
(
"sum"
,
e
.
getValue
().
size
());
spreadJson
.
put
(
"sum"
,
e
.
getValue
().
size
());
return
spreadJson
;
return
spreadJson
;
}).
collect
(
Collectors
.
toList
());
}).
collect
(
Collectors
.
toList
());
Collections
.
reverse
(
collect
);
return
collect
;
}
}
private
List
<
JSONObject
>
spreadingTendEvent
(
Long
startTime
,
Long
endTime
,
Channel
channel
,
String
projectId
,
String
contendId
,
String
timePattern
)
{
private
List
<
JSONObject
>
spreadingTendEvent
(
Long
startTime
,
Long
endTime
,
Channel
channel
,
String
projectId
,
String
contendId
,
String
timePattern
)
{
String
linkedGroupId
=
projectService
.
getProjectByContendId
(
contendId
).
getBrandLinkedGroupId
();
String
linkedGroupId
=
projectService
.
getProjectByContendId
(
contendId
).
getBrandLinkedGroupId
();
Map
<
Long
,
List
<
Event
>>
eventCount
;
Map
<
Long
,
List
<
Event
>>
eventCount
=
completeTimes
(
startTime
,
endTime
,
timePattern
)
;
if
(
Constant
.
MONTH_PATTERN
.
equals
(
timePattern
))
{
if
(
Constant
.
MONTH_PATTERN
.
equals
(
timePattern
))
{
eventCount
=
eventDao
.
getEventMonth
(
new
ChannelIndex
(
projectId
,
linkedGroupId
,
channel
),
startTime
,
endTime
);
eventCount
.
putAll
(
eventDao
.
getEventMonth
(
new
ChannelIndex
(
projectId
,
linkedGroupId
,
channel
),
startTime
,
endTime
)
);
}
else
{
}
else
{
eventCount
=
eventDao
.
getEventDay
(
new
ChannelIndex
(
projectId
,
linkedGroupId
,
channel
),
startTime
,
endTime
);
eventCount
.
putAll
(
eventDao
.
getEventDay
(
new
ChannelIndex
(
projectId
,
linkedGroupId
,
channel
),
startTime
,
endTime
)
);
}
}
return
eventCount
.
entrySet
().
stream
().
sorted
(
Comparator
.
comparingLong
(
Map
.
Entry
::
getKey
)).
map
(
e
->
{
return
eventCount
.
entrySet
().
stream
().
sorted
(
Comparator
.
comparingLong
(
Map
.
Entry
::
getKey
)).
map
(
e
->
{
JSONObject
spreadJson
=
new
JSONObject
();
JSONObject
spreadJson
=
new
JSONObject
();
...
@@ -804,11 +832,7 @@ public class ChannelServiceImpl implements ChannelService {
...
@@ -804,11 +832,7 @@ public class ChannelServiceImpl implements ChannelService {
* @return
* @return
*/
*/
private
Map
<
Long
,
List
<
ChannelIndex
.
Article
>>
partition
(
Long
startTime
,
Long
endTime
,
String
timePattern
,
List
<
ChannelIndex
.
Article
>
articles
)
{
private
Map
<
Long
,
List
<
ChannelIndex
.
Article
>>
partition
(
Long
startTime
,
Long
endTime
,
String
timePattern
,
List
<
ChannelIndex
.
Article
>
articles
)
{
Map
<
Long
,
List
<
ChannelIndex
.
Article
>>
res
=
new
LinkedHashMap
<>();
Map
<
Long
,
List
<
ChannelIndex
.
Article
>>
res
=
completeTimes
(
startTime
,
endTime
,
timePattern
);
// 自动补全时间段
for
(
Long
timeKey
:
Tools
.
parseToDayList
(
startTime
,
endTime
))
{
res
.
put
(
timeKey
,
Lists
.
newArrayList
());
}
for
(
ChannelIndex
.
Article
article
:
articles
)
{
for
(
ChannelIndex
.
Article
article
:
articles
)
{
// 按日分组
// 按日分组
long
key
=
Tools
.
truncDate
(
new
Date
(
article
.
getTime
()),
timePattern
).
getTime
();
long
key
=
Tools
.
truncDate
(
new
Date
(
article
.
getTime
()),
timePattern
).
getTime
();
...
@@ -899,4 +923,42 @@ public class ChannelServiceImpl implements ChannelService {
...
@@ -899,4 +923,42 @@ public class ChannelServiceImpl implements ChannelService {
return
new
String
[]{
null
,
null
};
return
new
String
[]{
null
,
null
};
}
}
private
boolean
hasEmotion
(
Channel
channel
)
{
if
(
"0"
.
equals
(
channel
.
getContendId
()))
{
return
true
;
}
AbstractProject
project
=
projectService
.
getProjectByContendId
(
channel
.
getContendId
());
if
(
project
instanceof
Contend
)
{
//有情感倾向更新渠道指数
return
((
Contend
)
project
).
isHasEmotion
();
}
return
project
instanceof
Project
;
}
/**
* 自动补全时间段
*
* @param startTime
* @param endTime
* @param timePattern
* @return
*/
private
<
T
>
Map
<
Long
,
List
<
T
>>
completeTimes
(
Long
startTime
,
Long
endTime
,
String
timePattern
)
{
Map
<
Long
,
List
<
T
>>
res
=
new
LinkedHashMap
<>();
if
(
Constant
.
DAY_PATTERN
.
equals
(
timePattern
))
{
for
(
Long
timeKey
:
Tools
.
parseToDayList
(
startTime
,
endTime
))
{
res
.
put
(
timeKey
,
Lists
.
newArrayList
());
}
}
else
if
(
Constant
.
MONTH_PATTERN
.
equals
(
timePattern
))
{
for
(
Long
timeKey
:
Tools
.
parseToMonthList
(
startTime
,
endTime
))
{
res
.
put
(
timeKey
,
Lists
.
newArrayList
());
}
}
return
res
;
}
private
long
judgeSpecEventCount
(
String
channelId
,
List
<
Integer
>
eventEmotions
,
int
articleEmotion
)
{
return
0
;
}
}
}
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkDataServiceImpl.java
View file @
4f1a595f
...
@@ -64,7 +64,6 @@ import org.springframework.stereotype.Service;
...
@@ -64,7 +64,6 @@ import org.springframework.stereotype.Service;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -358,7 +357,7 @@ public class MarkDataServiceImpl implements MarkDataService {
...
@@ -358,7 +357,7 @@ public class MarkDataServiceImpl implements MarkDataService {
result
.
put
(
"negTopTitle"
,
topTitle
);
result
.
put
(
"negTopTitle"
,
topTitle
);
List
<
JSONObject
>
articlePlatformProportion
=
getMarkPlatformProportion
(
startTime
,
endTime
,
projectId
,
linkedGroupId
,
true
);
List
<
JSONObject
>
articlePlatformProportion
=
getMarkPlatformProportion
(
startTime
,
endTime
,
projectId
,
linkedGroupId
,
true
);
result
.
put
(
"platformRank"
,
articlePlatformProportion
.
stream
().
filter
(
articlePlatform
->
articlePlatform
.
getLongValue
(
"count"
)
>
0
).
sorted
((
o1
,
o2
)
->
o2
.
getLong
(
"count"
).
compareTo
(
o1
.
getLong
(
"count"
))).
collect
(
Collectors
.
toList
()));
result
.
put
(
"platformRank"
,
articlePlatformProportion
.
stream
().
filter
(
articlePlatform
->
articlePlatform
.
getLongValue
(
"count"
)
>
0
).
sorted
((
o1
,
o2
)
->
o2
.
getLong
(
"count"
).
compareTo
(
o1
.
getLong
(
"count"
))).
collect
(
Collectors
.
toList
()));
redisUtil
.
setExpire
(
redisKey
,
JSON
.
toJSONString
(
result
)
,
1
,
TimeUnit
.
HOURS
);
redisUtil
.
setExpire
(
redisKey
,
JSON
.
toJSONString
(
result
));
return
result
;
return
result
;
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"es查询异常"
),
e
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"es查询异常"
),
e
);
...
@@ -404,7 +403,7 @@ public class MarkDataServiceImpl implements MarkDataService {
...
@@ -404,7 +403,7 @@ public class MarkDataServiceImpl implements MarkDataService {
result
.
put
(
"lastPosCount"
,
oldEmotions
.
get
(
0
).
getLongValue
(
"count"
));
result
.
put
(
"lastPosCount"
,
oldEmotions
.
get
(
0
).
getLongValue
(
"count"
));
result
.
put
(
"lastNeuCount"
,
oldEmotions
.
get
(
1
).
getLongValue
(
"count"
));
result
.
put
(
"lastNeuCount"
,
oldEmotions
.
get
(
1
).
getLongValue
(
"count"
));
result
.
put
(
"lastNegCount"
,
oldEmotions
.
get
(
2
).
getLongValue
(
"count"
));
result
.
put
(
"lastNegCount"
,
oldEmotions
.
get
(
2
).
getLongValue
(
"count"
));
redisUtil
.
setExpire
(
redisKey
,
JSON
.
toJSONString
(
result
)
,
1
,
TimeUnit
.
HOURS
);
redisUtil
.
setExpire
(
redisKey
,
JSON
.
toJSONString
(
result
));
return
result
;
return
result
;
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"es查询异常"
),
e
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"es查询异常"
),
e
);
...
@@ -433,6 +432,7 @@ public class MarkDataServiceImpl implements MarkDataService {
...
@@ -433,6 +432,7 @@ public class MarkDataServiceImpl implements MarkDataService {
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"es查询异常"
));
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
.
message
(
"es查询异常"
));
}
}
redisUtil
.
setExpire
(
redisKey
,
JSON
.
toJSONString
(
result
));
return
result
;
return
result
;
}
}
...
@@ -753,7 +753,7 @@ public class MarkDataServiceImpl implements MarkDataService {
...
@@ -753,7 +753,7 @@ public class MarkDataServiceImpl implements MarkDataService {
line
.
put
(
"time"
,
day
.
getLongValue
(
"date"
));
line
.
put
(
"time"
,
day
.
getLongValue
(
"date"
));
lineList
.
add
(
line
);
lineList
.
add
(
line
);
});
});
redisUtil
.
setExpire
(
redisKey
,
JSON
.
toJSONString
(
lineList
),
1
,
TimeUnit
.
HOURS
);
redisUtil
.
setExpire
(
redisKey
,
JSON
.
toJSONString
(
result
)
);
return
lineList
;
return
lineList
;
}
}
...
@@ -946,7 +946,7 @@ public class MarkDataServiceImpl implements MarkDataService {
...
@@ -946,7 +946,7 @@ public class MarkDataServiceImpl implements MarkDataService {
List
<
JSONObject
>
platformsCount
=
getPlatformsCount
(
startTime
,
endTime
,
null
,
null
,
projectId
,
linkedGroupId
,
platformList
);
List
<
JSONObject
>
platformsCount
=
getPlatformsCount
(
startTime
,
endTime
,
null
,
null
,
projectId
,
linkedGroupId
,
platformList
);
long
articlesCount
=
platformsCount
.
stream
().
mapToLong
(
platform
->
platform
.
getLongValue
(
"count"
)).
sum
();
long
articlesCount
=
platformsCount
.
stream
().
mapToLong
(
platform
->
platform
.
getLongValue
(
"count"
)).
sum
();
List
<
JSONObject
>
resultList
=
platformsCount
.
stream
().
peek
(
platform
->
platform
.
put
(
"proportion"
,
0
==
articlesCount
?
0
:
platform
.
getLongValue
(
"count"
)
*
1.0
/
articlesCount
)).
collect
(
Collectors
.
toList
());
List
<
JSONObject
>
resultList
=
platformsCount
.
stream
().
peek
(
platform
->
platform
.
put
(
"proportion"
,
0
==
articlesCount
?
0
:
platform
.
getLongValue
(
"count"
)
*
1.0
/
articlesCount
)).
collect
(
Collectors
.
toList
());
redisUtil
.
setExpire
(
redisKey
,
JSON
.
toJSONString
(
resultList
)
,
1
,
TimeUnit
.
HOURS
);
redisUtil
.
setExpire
(
redisKey
,
JSON
.
toJSONString
(
resultList
));
return
resultList
;
return
resultList
;
}
}
...
@@ -1076,7 +1076,7 @@ public class MarkDataServiceImpl implements MarkDataService {
...
@@ -1076,7 +1076,7 @@ public class MarkDataServiceImpl implements MarkDataService {
return
QueryBuilders
.
boolQuery
().
must
(
QueryBuilders
.
termQuery
(
"brandkbs_cache_maps.project_id.keyword"
,
projectId
)).
must
(
QueryBuilders
.
termQuery
(
"brandkbs_cache_maps.linked_group_id.keyword"
,
linkedGroupId
));
return
QueryBuilders
.
boolQuery
().
must
(
QueryBuilders
.
termQuery
(
"brandkbs_cache_maps.project_id.keyword"
,
projectId
)).
must
(
QueryBuilders
.
termQuery
(
"brandkbs_cache_maps.linked_group_id.keyword"
,
linkedGroupId
));
}
}
pr
ivate
static
BoolQueryBuilder
projectLinkedGroupContendIdQuery
(
String
projectId
,
String
linkedGroupId
,
String
contendId
)
{
pr
otected
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
QueryBuilders
.
boolQuery
().
must
(
QueryBuilders
.
termQuery
(
"brandkbs_cache_maps.key.keyword"
,
Tools
.
concat
(
projectId
,
linkedGroupId
,
contendId
)));
}
}
...
...
src/main/java/com/zhiwei/brandkbs2/util/Tools.java
View file @
4f1a595f
...
@@ -674,6 +674,31 @@ public class Tools {
...
@@ -674,6 +674,31 @@ public class Tools {
* @param endTime 结束时间
* @param endTime 结束时间
* @return 按日分割的map集合
* @return 按日分割的map集合
*/
*/
public
static
List
<
Long
>
parseToMonthList
(
Long
startTime
,
Long
endTime
)
{
Date
start
=
new
Date
(
startTime
);
Date
end
=
new
Date
(
endTime
);
start
=
Tools
.
truncDate
(
start
,
MONTH_PATTERN
);
end
=
Tools
.
truncDate
(
end
,
MONTH_PATTERN
);
Period
periodDays
=
new
Period
(
start
.
getTime
(),
end
.
getTime
(),
PeriodType
.
months
());
int
months
=
periodDays
.
getMonths
();
if
(
months
<
0
)
{
return
Collections
.
emptyList
();
}
List
<
Long
>
resList
=
new
ArrayList
<>(
months
);
for
(
int
i
=
0
;
i
<=
months
;
i
++)
{
resList
.
add
(
DateUtils
.
addMonths
(
start
,
i
).
getTime
());
}
Collections
.
reverse
(
resList
);
return
resList
;
}
/**
* 解析时间转换成按日的集合
*
* @param startTime 开始时间
* @param endTime 结束时间
* @return 按日分割的map集合
*/
public
static
List
<
Map
<
String
,
String
>>
parseToDays
(
Long
startTime
,
Long
endTime
)
{
public
static
List
<
Map
<
String
,
String
>>
parseToDays
(
Long
startTime
,
Long
endTime
)
{
FastDateFormat
df
=
DAY_FORMAT
;
FastDateFormat
df
=
DAY_FORMAT
;
Date
start
=
Tools
.
truncDate
(
new
Date
(
startTime
),
Constant
.
DAY_PATTERN
);
Date
start
=
Tools
.
truncDate
(
new
Date
(
startTime
),
Constant
.
DAY_PATTERN
);
...
...
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