|
|
@@ -19,10 +19,7 @@ import org.springframework.stereotype.Service;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
@@ -152,9 +149,16 @@ public class FsUserWatchCourseStatisticsServiceImpl extends ServiceImpl<FsUserWa
|
|
|
|
|
|
// 处理数据
|
|
|
List<FsUserWatchCourseStatistics> list = new ArrayList<>();
|
|
|
+
|
|
|
+ //查询数据表中已经存在的会员看课统计表
|
|
|
+ FsUserWatchCourseStatistics fsUserWatchCourseStatisticsOld = new FsUserWatchCourseStatistics();
|
|
|
+ List<FsUserWatchCourseStatistics> watchCourseStatisticsListOld = baseMapper.selectFsUserWatchCourseStatisticsListTotal(fsUserWatchCourseStatisticsOld);
|
|
|
+
|
|
|
+ Map<String, FsUserWatchCourseStatistics> newDataMap = new HashMap<>();
|
|
|
for (FsUserWatchCourseStatistics data : fsUserWatchCourseStatistics) {
|
|
|
FsUserWatchCourseStatistics vo = new FsUserWatchCourseStatistics();
|
|
|
String key = String.format("%s-%s-%s", data.getPeriodId(), data.getVideoId(), data.getCompanyUserId());
|
|
|
+ newDataMap.put(key, data);
|
|
|
FsUserWatchCourseStatistics watchLogData = watchLogMap.get(key);
|
|
|
FsUserWatchCourseStatistics redPacketLogData = redPacketLogMap.get(key);
|
|
|
FsUserWatchCourseStatistics answerLogData = answerLogMap.get(key);
|
|
|
@@ -237,7 +241,21 @@ public class FsUserWatchCourseStatisticsServiceImpl extends ServiceImpl<FsUserWa
|
|
|
list.add(vo);
|
|
|
}
|
|
|
|
|
|
- //2、分批次插入数据
|
|
|
+ // 过滤掉被删除的,然后执行删除
|
|
|
+ List<Long> listToDelete = new ArrayList<>();
|
|
|
+ for (FsUserWatchCourseStatistics oldData : watchCourseStatisticsListOld) {
|
|
|
+ String oldKey = String.format("%s-%s-%s", oldData.getPeriodId(), oldData.getVideoId(), oldData.getCompanyUserId());
|
|
|
+ if (!newDataMap.containsKey(oldKey)) {
|
|
|
+ listToDelete.add(oldData.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2、执行删除
|
|
|
+ if (!listToDelete.isEmpty()) {
|
|
|
+ baseMapper.deleteFsUserWatchCourseStatisticsByIds(listToDelete.toArray(new Long[0]));
|
|
|
+ }
|
|
|
+
|
|
|
+ //3、分批次插入数据
|
|
|
this.batchInsert(list);
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|