mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-11 20:06:51 +08:00
es数据同步
This commit is contained in:
@@ -101,6 +101,9 @@ public class PhpOnlineStudyRecordScheduledTasks {
|
|||||||
// 获取ES中的数据
|
// 获取ES中的数据
|
||||||
List<CourseStudyDto> esDataList = getEsData(batch);
|
List<CourseStudyDto> esDataList = getEsData(batch);
|
||||||
|
|
||||||
|
if (CollUtil.isEmpty(esDataList)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// 更新ES数据
|
// 更新ES数据
|
||||||
List<CourseStudyDto> toBeUpdatedEs = esDataList.stream()
|
List<CourseStudyDto> toBeUpdatedEs = esDataList.stream()
|
||||||
@@ -136,6 +139,7 @@ public class PhpOnlineStudyRecordScheduledTasks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<CourseStudyDto> getEsData(List<PhpOnlineDto> finishedCourseList) throws IOException {
|
private List<CourseStudyDto> getEsData(List<PhpOnlineDto> finishedCourseList) throws IOException {
|
||||||
|
log.info("待处理的数据:{}", finishedCourseList);
|
||||||
SearchRequest searchRequest = new SearchRequest("new_study_resource");
|
SearchRequest searchRequest = new SearchRequest("new_study_resource");
|
||||||
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
|
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
|
||||||
|
|
||||||
@@ -151,11 +155,13 @@ public class PhpOnlineStudyRecordScheduledTasks {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder().query(boolQuery).timeout(new TimeValue(60, TimeUnit.SECONDS));
|
|
||||||
searchRequest.source(sourceBuilder);
|
|
||||||
if (boolQuery.hasClauses()) {
|
if (boolQuery.hasClauses()) {
|
||||||
sourceBuilder.query(boolQuery);
|
return null;
|
||||||
}
|
}
|
||||||
|
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder()
|
||||||
|
.query(boolQuery)
|
||||||
|
.timeout(new TimeValue(60, TimeUnit.SECONDS))
|
||||||
|
.size(finishedCourseList.size() + 10);
|
||||||
searchRequest.source(sourceBuilder);
|
searchRequest.source(sourceBuilder);
|
||||||
|
|
||||||
SearchResponse response = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
|
SearchResponse response = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
|
||||||
|
|||||||
@@ -95,20 +95,20 @@ public class PhpOnlineCourseDao extends BaseDao<PhpOnlineDto> {
|
|||||||
userBasicDataBase = "userbasic";
|
userBasicDataBase = "userbasic";
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> userIds = objectList1.stream().map(objects -> String.valueOf(objects[1])).distinct().collect(Collectors.toList());
|
List<String> userIdOfPhpList = objectList1.stream().map(objects -> String.valueOf(objects[1])).distinct().collect(Collectors.toList());
|
||||||
List<Object[]> objectList2 = this.sqlFindList("select kid,user_id from " + userBasicDataBase + ".user_account where kid in (?1) and deleted=0 and account_status = 0", userIds);
|
List<Object[]> objectList2 = this.sqlFindList("select kid,user_id from " + userBasicDataBase + ".user_account where kid in (?1) and deleted=0 and account_status = 0", userIdOfPhpList);
|
||||||
|
|
||||||
if (CollUtil.isEmpty(objectList1)) {
|
if (CollUtil.isEmpty(objectList1)) {
|
||||||
log.info("新系统用户数据不存在");
|
log.info("新系统用户数据不存在");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<Object, Object> userIdToKidMap = objectList2.stream().collect(Collectors.toMap(object -> object[0], object -> object[1]));
|
Map<Object, Object> kidAndUserIdMap = objectList2.stream().collect(Collectors.toMap(object -> object[0], object -> object[1]));
|
||||||
|
|
||||||
// 设置新系统用户ID
|
// 设置新系统用户ID
|
||||||
recentLearnRecordList = recentLearnRecordList.stream()
|
recentLearnRecordList = recentLearnRecordList.stream()
|
||||||
.map(phpOnlineDto -> {
|
.map(phpOnlineDto -> {
|
||||||
Object userIdOfJavaObj = userIdToKidMap.get(phpOnlineDto.getUserIdOfPhp());
|
Object userIdOfJavaObj = kidAndUserIdMap.get(phpOnlineDto.getUserIdOfPhp());
|
||||||
if (userIdOfJavaObj != null) {
|
if (userIdOfJavaObj != null) {
|
||||||
phpOnlineDto.setUserIdOfJava(userIdOfJavaObj.toString());
|
phpOnlineDto.setUserIdOfJava(userIdOfJavaObj.toString());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user