|
@@ -21,6 +21,9 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.CompletableFuture;
|
|
|
+import java.util.concurrent.ExecutorService;
|
|
|
+import java.util.concurrent.Executors;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
@@ -39,7 +42,6 @@ public class StudentStatisticsServiceImpl extends BaseServiceImpl<Integer, Stude
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
public void updateStudentStatistics() {
|
|
|
//获取声部班老师
|
|
|
studentBasicInfoDao.updateSubjectTeacher();
|
|
@@ -61,11 +63,18 @@ public class StudentStatisticsServiceImpl extends BaseServiceImpl<Integer, Stude
|
|
|
statisticsList.addAll(studentStatisticsDao.queryStatisticsNormalGroupNum());
|
|
|
statisticsList.removeAll(Collections.singleton(null));
|
|
|
if(CollectionUtils.isNotEmpty(statisticsList)){
|
|
|
- studentStatisticsDao.clean();
|
|
|
- List<List<StudentStatistics>> partition = Lists.partition(statisticsList, 1000);
|
|
|
- for (List<StudentStatistics> studentStatistics : partition) {
|
|
|
- studentStatisticsDao.batchUpdate(studentStatistics);
|
|
|
- }
|
|
|
+ ExecutorService executor = Executors.newCachedThreadPool();
|
|
|
+ CompletableFuture.runAsync(()->{
|
|
|
+ try {
|
|
|
+ studentStatisticsDao.clean();
|
|
|
+ List<List<StudentStatistics>> partition = Lists.partition(statisticsList, 1000);
|
|
|
+ for (List<StudentStatistics> studentStatistics : partition) {
|
|
|
+ studentStatisticsDao.batchUpdate(studentStatistics);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ },executor);
|
|
|
}
|
|
|
}
|
|
|
|