记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
Project
Project
Details
Activity
Releases
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
董敬伟
liquidnet-bus-v1
Commits
ecde213f
Commit
ecde213f
authored
Sep 19, 2021
by
anjiabin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交chime社交相关
parent
7b99f97b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
7 deletions
+16
-7
DataUtils.java
...ain/java/com/liquidnet/service/chime/utils/DataUtils.java
+16
-7
No files found.
liquidnet-bus-service/liquidnet-service-chime/liquidnet-service-chime-impl/src/main/java/com/liquidnet/service/chime/utils/DataUtils.java
View file @
ecde213f
package
com
.
liquidnet
.
service
.
chime
.
utils
;
package
com
.
liquidnet
.
service
.
chime
.
utils
;
import
com.liquidnet.common.cache.redis.util.RedisUtil
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
com.liquidnet.commons.lang.util.StringUtil
;
import
com.liquidnet.service.adam.dto.rsc.AdamChimeUinfoDto
;
import
com.liquidnet.service.chime.biz.ChimeUserBiz
;
import
com.liquidnet.service.chime.constant.ChimeConstant
;
import
com.liquidnet.service.chime.constant.ChimeConstant
;
import
com.liquidnet.service.chime.dto.ChimeJoinUserCountDto
;
import
com.liquidnet.service.chime.dto.ChimeJoinUserCountDto
;
import
com.liquidnet.service.chime.dto.ChimeUserTagDto
;
import
com.liquidnet.service.chime.dto.ChimeUserTagDto
;
...
@@ -22,6 +24,7 @@ import org.springframework.stereotype.Component;
...
@@ -22,6 +24,7 @@ import org.springframework.stereotype.Component;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@Slf4j
@Slf4j
@Component
@Component
...
@@ -30,7 +33,9 @@ public class DataUtils {
...
@@ -30,7 +33,9 @@ public class DataUtils {
@Autowired
@Autowired
private
MongoTemplate
mongoTemplate
;
private
MongoTemplate
mongoTemplate
;
@Autowired
@Autowired
private
RedisUtil
redisUtil
;
private
ChimeUserBiz
chimeUserBiz
;
/**
/**
* 注册社交用户
* 注册社交用户
...
@@ -116,18 +121,18 @@ public class DataUtils {
...
@@ -116,18 +121,18 @@ public class DataUtils {
public
List
<
ChimeJoinUserCountDto
>
getJoinUserCountList
(
List
<
String
>
performanceIdList
){
public
List
<
ChimeJoinUserCountDto
>
getJoinUserCountList
(
List
<
String
>
performanceIdList
){
Aggregation
agg
=
Aggregation
.
newAggregation
(
Aggregation
agg
=
Aggregation
.
newAggregation
(
// 挑选所需的字段,类似select *,*所代表的字段内容
// 挑选所需的字段,类似select *,*所代表的字段内容
Aggregation
.
project
(
"joinPerformanceId"
,
"
avatar
"
),
Aggregation
.
project
(
"joinPerformanceId"
,
"
userId
"
),
// sql where 语句筛选符合条件的记录
// sql where 语句筛选符合条件的记录
Aggregation
.
match
(
Criteria
.
where
(
"joinPerformanceId"
).
in
(
performanceIdList
)),
Aggregation
.
match
(
Criteria
.
where
(
"joinPerformanceId"
).
in
(
performanceIdList
)),
// 分组条件,设置分组字段
// 分组条件,设置分组字段
Aggregation
.
group
(
"joinPerformanceId"
)
Aggregation
.
group
(
"joinPerformanceId"
)
.
first
(
"joinPerformanceId"
).
as
(
"joinPerformanceId"
)
.
first
(
"joinPerformanceId"
).
as
(
"joinPerformanceId"
)
.
addToSet
(
"
avatar"
).
as
(
"avatar
Array"
)
.
addToSet
(
"
userId"
).
as
(
"userId
Array"
)
.
count
().
as
(
"totalCount"
),
.
count
().
as
(
"totalCount"
),
// 排序(根据某字段排序 倒序)
// 排序(根据某字段排序 倒序)
// Aggregation.sort(Sort.Direction.DESC,"startDate"),
// Aggregation.sort(Sort.Direction.DESC,"startDate"),
// 重新挑选字段
// 重新挑选字段
Aggregation
.
project
(
"joinPerformanceId"
,
"totalCount"
,
"
avatar
Array"
)
Aggregation
.
project
(
"joinPerformanceId"
,
"totalCount"
,
"
userId
Array"
)
);
);
AggregationResults
<
Document
>
results
=
mongoTemplate
.
aggregate
(
agg
,
ChimeUserInfoVo
.
class
.
getSimpleName
(),
Document
.
class
);
AggregationResults
<
Document
>
results
=
mongoTemplate
.
aggregate
(
agg
,
ChimeUserInfoVo
.
class
.
getSimpleName
(),
Document
.
class
);
...
@@ -139,8 +144,12 @@ public class DataUtils {
...
@@ -139,8 +144,12 @@ public class DataUtils {
ChimeJoinUserCountDto
dto
=
ChimeJoinUserCountDto
.
getNew
();
ChimeJoinUserCountDto
dto
=
ChimeJoinUserCountDto
.
getNew
();
dto
.
setPerformancesId
(
document
.
getString
(
"joinPerformanceId"
));
dto
.
setPerformancesId
(
document
.
getString
(
"joinPerformanceId"
));
dto
.
setCount
(
document
.
getInteger
(
"totalCount"
));
dto
.
setCount
(
document
.
getInteger
(
"totalCount"
));
List
<
String
>
ppl2
=
document
.
getList
(
"avatarArray"
,
String
.
class
);
List
<
String
>
ppl2
=
document
.
getList
(
"userIdArray"
,
String
.
class
);
dto
.
setAvatarImgList
(
ppl2
);
//根据userId获取用户头像
List
<
AdamChimeUinfoDto
>
adamChimeUinfoDtoList
=
chimeUserBiz
.
getAdamUserInfoDtoList
(
ppl2
);
if
(
StringUtil
.
isNotNull
(
adamChimeUinfoDtoList
)){
dto
.
setAvatarImgList
(
adamChimeUinfoDtoList
.
stream
().
map
(
AdamChimeUinfoDto:
:
getAvatar
).
collect
(
Collectors
.
toList
()));
}
joinUserCountDtoList
.
add
(
dto
);
joinUserCountDtoList
.
add
(
dto
);
});
});
log
.
debug
(
"排序后的code列表2:[{}]"
,
results
);
log
.
debug
(
"排序后的code列表2:[{}]"
,
results
);
...
...
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