|
|
@@ -59,6 +59,9 @@ public class StudentTotalServiceImpl extends ServiceImpl<StudentTotalDao, Studen
|
|
|
public List<StudentTotal> queryStudentTotal() {
|
|
|
List<Student> students = studentDao.selectList(Wrappers.<Student>emptyWrapper()
|
|
|
.select("userId"));
|
|
|
+
|
|
|
+ log.info("总学生人数:" + students.size());
|
|
|
+
|
|
|
//查询关注老师数
|
|
|
List<StudentTotalVo> studentStarTotal = studentStarDao.queryStudentTotal();
|
|
|
Map<Long, StudentTotalVo> studentStarMap = new HashMap<>();
|
|
|
@@ -79,6 +82,8 @@ public class StudentTotalServiceImpl extends ServiceImpl<StudentTotalDao, Studen
|
|
|
if (!CollectionUtils.isEmpty(studentMusicTotal)) {
|
|
|
studentMusicMap = studentMusicTotal.stream().collect(Collectors.toMap(StudentTotalVo::getUserId, o -> o));
|
|
|
}
|
|
|
+
|
|
|
+ log.info("开始更新redis数据");
|
|
|
|
|
|
List<StudentTotal> resultList = new ArrayList<>();
|
|
|
for (Student student : students) {
|
|
|
@@ -104,6 +109,7 @@ public class StudentTotalServiceImpl extends ServiceImpl<StudentTotalDao, Studen
|
|
|
redissonClient.getBucket(CacheNameEnum.STUDENT_TOTAL.getRedisKey(studentTotal.getUserId()))
|
|
|
.set(studentTotal);
|
|
|
}
|
|
|
+ log.info("开始更新数据库数据");
|
|
|
saveOrUpdateBatch(resultList);
|
|
|
return resultList;
|
|
|
}
|
|
|
@@ -190,11 +196,14 @@ public class StudentTotalServiceImpl extends ServiceImpl<StudentTotalDao, Studen
|
|
|
List<StudentTotal> saveList = resultList.stream()
|
|
|
.filter(o -> null == studentTotalMap.get(o.getUserId())).collect(Collectors.toList());
|
|
|
batchOpera(saveList, this::saveBatch);
|
|
|
+
|
|
|
+ log.info("批量插入完成:" + saveList.size() + "条");
|
|
|
|
|
|
//批量更新
|
|
|
List<StudentTotal> updateList = resultList.stream()
|
|
|
.filter(o -> null != studentTotalMap.get(o.getUserId())).collect(Collectors.toList());
|
|
|
batchOpera(updateList, this::updateBatch);
|
|
|
+ log.info("批量更新完成:" + updateList.size() + "条");
|
|
|
}
|
|
|
|
|
|
private void batchOpera(List<StudentTotal> resultList, Consumer<List<StudentTotal>> action) {
|