|
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
+import com.fs.common.BeanCopyUtils;
|
|
|
import com.fs.common.annotation.DataSource;
|
|
import com.fs.common.annotation.DataSource;
|
|
|
import com.fs.common.enums.DataSourceType;
|
|
import com.fs.common.enums.DataSourceType;
|
|
|
import com.fs.common.exception.base.BaseException;
|
|
import com.fs.common.exception.base.BaseException;
|
|
@@ -321,6 +322,7 @@ public class QwSopTempServiceImpl implements IQwSopTempService {
|
|
|
if (day == null) return;
|
|
if (day == null) return;
|
|
|
qwSopTempDayService.removeById(day.getId());
|
|
qwSopTempDayService.removeById(day.getId());
|
|
|
qwSopTempContentService.removeByDayId(day.getId());
|
|
qwSopTempContentService.removeByDayId(day.getId());
|
|
|
|
|
+ qwSopTempRulesService.removeByDayId(day.getId());
|
|
|
reorder(day.getTempId());
|
|
reorder(day.getTempId());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -633,6 +635,7 @@ public class QwSopTempServiceImpl implements IQwSopTempService {
|
|
|
if (CollectionUtils.isEmpty(rulesList)) {
|
|
if (CollectionUtils.isEmpty(rulesList)) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
// 获取这些规则关联的模板ID集合
|
|
// 获取这些规则关联的模板ID集合
|
|
|
Set<String> tempIds = rulesList.stream()
|
|
Set<String> tempIds = rulesList.stream()
|
|
|
.map(QwSopTempRules::getTempId)
|
|
.map(QwSopTempRules::getTempId)
|
|
@@ -641,11 +644,7 @@ public class QwSopTempServiceImpl implements IQwSopTempService {
|
|
|
|
|
|
|
|
FsUserCourse fsUserCourse = fsUserCourseMapper.selectFsUserCourseByCourseId(courseId);
|
|
FsUserCourse fsUserCourse = fsUserCourseMapper.selectFsUserCourseByCourseId(courseId);
|
|
|
List<FsUserCourseVideo> videoList = fsUserCourseVideoMapper.selectVideoByCourseId(fsUserCourse.getCourseId());
|
|
List<FsUserCourseVideo> videoList = fsUserCourseVideoMapper.selectVideoByCourseId(fsUserCourse.getCourseId());
|
|
|
- List<QwSopTemp> tempList = qwSopTempMapper.selectListByIds(tempIds);
|
|
|
|
|
- List<QwSopTempContent> contentList = qwSopTempContentService.listByTempIds(tempIds);
|
|
|
|
|
- List<QwSopTempDay> dayList = qwSopTempDayService.listByTempIds(new LambdaQueryWrapper<QwSopTempDay>().in(QwSopTempDay::getTempId, tempIds));
|
|
|
|
|
List<Long> videoIdList = videoList.stream().map(FsUserCourseVideo::getVideoId).collect(Collectors.toList());
|
|
List<Long> videoIdList = videoList.stream().map(FsUserCourseVideo::getVideoId).collect(Collectors.toList());
|
|
|
- // videoList转Map key 为videoId value 为 courseSort
|
|
|
|
|
Map<Long, Long> videoSortMap = videoList.stream().collect(Collectors.toMap(FsUserCourseVideo::getVideoId, FsUserCourseVideo::getCourseSort));
|
|
Map<Long, Long> videoSortMap = videoList.stream().collect(Collectors.toMap(FsUserCourseVideo::getVideoId, FsUserCourseVideo::getCourseSort));
|
|
|
|
|
|
|
|
// 将课程中已删除的视频在规则和日期中删除
|
|
// 将课程中已删除的视频在规则和日期中删除
|
|
@@ -656,54 +655,131 @@ public class QwSopTempServiceImpl implements IQwSopTempService {
|
|
|
qwSopTempContentService.removeByWrapper(new LambdaQueryWrapper<QwSopTempContent>().in(QwSopTempContent::getDayId, dayIdList));
|
|
qwSopTempContentService.removeByWrapper(new LambdaQueryWrapper<QwSopTempContent>().in(QwSopTempContent::getDayId, dayIdList));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 需要添加的课程视频
|
|
|
|
|
- List<FsUserCourseVideo> addVideoList = videoList.stream()
|
|
|
|
|
- .filter(e -> rulesList.stream().noneMatch(f -> f.getVideoId().equals(e.getVideoId()))).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
- if (CollectionUtils.isNotEmpty(addVideoList)) {
|
|
|
|
|
- for (QwSopTemp temp : tempList) {
|
|
|
|
|
|
|
+ tempIds.forEach(teId->{
|
|
|
|
|
+ QwSopTemp sopTemp = qwSopTempMapper.selectQwSopTempById(teId);
|
|
|
|
|
+ List<QwSopTempContent> contentList = qwSopTempContentService.listByTempId(teId);
|
|
|
|
|
+ List<QwSopTempDay> dayList = qwSopTempDayService.listByTempById(new LambdaQueryWrapper<QwSopTempDay>().in(QwSopTempDay::getTempId, teId));
|
|
|
|
|
+ List<QwSopTempRules> tempRulesList = qwSopTempRulesService.listByCourseIdAndTempId(courseId, teId);
|
|
|
|
|
+
|
|
|
|
|
+ List<FsUserCourseVideo> addVideoList = videoList.stream()
|
|
|
|
|
+ .filter(e -> tempRulesList.stream()
|
|
|
|
|
+ .noneMatch(f -> f.getVideoId().equals(e.getVideoId())))
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(addVideoList)) {
|
|
|
|
|
+
|
|
|
// 通过历史中的第一课的数据来构建
|
|
// 通过历史中的第一课的数据来构建
|
|
|
- Optional<QwSopTempDay> first = dayList.stream().filter(e -> e.getTempId().equals(temp.getId())).findFirst();
|
|
|
|
|
|
|
+ Optional<QwSopTempDay> first = dayList.stream().filter(e -> e.getTempId().equals(sopTemp.getId())).findFirst();
|
|
|
if (!first.isPresent()) {
|
|
if (!first.isPresent()) {
|
|
|
- break;
|
|
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
QwSopTempDay qwSopTempDay = first.get();
|
|
QwSopTempDay qwSopTempDay = first.get();
|
|
|
|
|
+
|
|
|
// 构造timeList timeDesc time
|
|
// 构造timeList timeDesc time
|
|
|
- temp.setTime(LocalTime.now());
|
|
|
|
|
|
|
+ sopTemp.setTime(LocalTime.now());
|
|
|
|
|
|
|
|
- temp.setTimeList(rulesList.stream()
|
|
|
|
|
- .filter(e -> e.getTempId().equals(temp.getId()) && Objects.equals(e.getIsOfficial(), "0")
|
|
|
|
|
|
|
+ sopTemp.setTimeList(tempRulesList.stream()
|
|
|
|
|
+ .filter(e -> e.getTempId().equals(sopTemp.getId()) && Objects.equals(e.getIsOfficial(), "0")
|
|
|
&& Objects.equals(e.getDayId(), qwSopTempDay.getId())
|
|
&& Objects.equals(e.getDayId(), qwSopTempDay.getId())
|
|
|
).map(QwSopTempRules::getTime)
|
|
).map(QwSopTempRules::getTime)
|
|
|
.collect(Collectors.toList()));
|
|
.collect(Collectors.toList()));
|
|
|
|
|
|
|
|
- temp.setTimeDesc(contentList.stream().filter(e -> e.getTempId().equals(temp.getId())
|
|
|
|
|
|
|
+ sopTemp.setTimeDesc(contentList.stream().filter(e -> e.getTempId().equals(sopTemp.getId())
|
|
|
&& Objects.isNull(e.getIsBindUrl())
|
|
&& Objects.isNull(e.getIsBindUrl())
|
|
|
&& Objects.equals(qwSopTempDay.getId(), e.getDayId())
|
|
&& Objects.equals(qwSopTempDay.getId(), e.getDayId())
|
|
|
)
|
|
)
|
|
|
.map(m -> JSONObject.parseObject(m.getContent()).getString("value")).collect(Collectors.toList()));
|
|
.map(m -> JSONObject.parseObject(m.getContent()).getString("value")).collect(Collectors.toList()));
|
|
|
- temp.setProject(fsUserCourse.getProject());
|
|
|
|
|
- temp.setCourseId(courseId);
|
|
|
|
|
- temp.setOpenOfficial("1");
|
|
|
|
|
- qwSopTempMapper.updateQwSopTemp(temp);
|
|
|
|
|
- createSopTempRules(temp, addVideoList, fsUserCourse);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ sopTemp.setProject(fsUserCourse.getProject());
|
|
|
|
|
+ sopTemp.setCourseId(courseId);
|
|
|
|
|
+ sopTemp.setOpenOfficial("1");
|
|
|
|
|
+
|
|
|
|
|
+ qwSopTempMapper.updateQwSopTemp(sopTemp);
|
|
|
|
|
+
|
|
|
|
|
+ createSopTempRules(sopTemp, addVideoList, fsUserCourse);
|
|
|
|
|
+
|
|
|
|
|
+ // 更新排序
|
|
|
|
|
+ List<QwSopTempRules> newTempRulesList = qwSopTempRulesService.listByCourseIdAndTempId(courseId, teId);
|
|
|
|
|
+ // 整理排序
|
|
|
|
|
+ Long[] dayIdArray = newTempRulesList.stream().filter(e -> e.getTempId().equals(sopTemp.getId())).sorted(Comparator.comparing(a -> videoSortMap.get(a.getVideoId())))
|
|
|
|
|
+ .map(QwSopTempRules::getDayId).distinct().toArray(Long[]::new);
|
|
|
|
|
+ for (int i = 0; i < dayIdArray.length; i++) {
|
|
|
|
|
+ qwSopTempDayService.updateByWrapper(new UpdateWrapper<QwSopTempDay>()
|
|
|
|
|
+ .eq("id", dayIdArray[i])
|
|
|
|
|
+ .set("sorts", i + 1)
|
|
|
|
|
+ .set("name", "第" + (i + 1) + "天")
|
|
|
|
|
+ .set("day_num", i + 1)
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- // 整理排序
|
|
|
|
|
- List<QwSopTempRules> afterRuleList = qwSopTempRulesService.listByCourseId(courseId);
|
|
|
|
|
- for (QwSopTemp temp : tempList) {
|
|
|
|
|
- Long[] dayIdArray = afterRuleList.stream().filter(e -> e.getTempId().equals(temp.getId())).sorted(Comparator.comparing(a -> videoSortMap.get(a.getVideoId())))
|
|
|
|
|
- .map(QwSopTempRules::getDayId).distinct().toArray(Long[]::new);
|
|
|
|
|
- for (int i = 0; i < dayIdArray.length; i++) {
|
|
|
|
|
- qwSopTempDayService.updateByWrapper(new UpdateWrapper<QwSopTempDay>()
|
|
|
|
|
- .eq("id", dayIdArray[i])
|
|
|
|
|
- .set("sorts", i + 1)
|
|
|
|
|
- .set("name", "第" + (i + 1) + "天")
|
|
|
|
|
- .set("day_num", i + 1)
|
|
|
|
|
- );
|
|
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+// FsUserCourse fsUserCourse = fsUserCourseMapper.selectFsUserCourseByCourseId(courseId);
|
|
|
|
|
+// List<FsUserCourseVideo> videoList = fsUserCourseVideoMapper.selectVideoByCourseId(fsUserCourse.getCourseId());
|
|
|
|
|
+// List<QwSopTemp> tempList = qwSopTempMapper.selectListByIds(tempIds);
|
|
|
|
|
+// List<QwSopTempContent> contentList = qwSopTempContentService.listByTempIds(tempIds);
|
|
|
|
|
+// List<QwSopTempDay> dayList = qwSopTempDayService.listByTempIds(new LambdaQueryWrapper<QwSopTempDay>().in(QwSopTempDay::getTempId, tempIds));
|
|
|
|
|
+// List<Long> videoIdList = videoList.stream().map(FsUserCourseVideo::getVideoId).collect(Collectors.toList());
|
|
|
|
|
+// // videoList转Map key 为videoId value 为 courseSort
|
|
|
|
|
+// Map<Long, Long> videoSortMap = videoList.stream().collect(Collectors.toMap(FsUserCourseVideo::getVideoId, FsUserCourseVideo::getCourseSort));
|
|
|
|
|
+
|
|
|
|
|
+ // 将课程中已删除的视频在规则和日期中删除
|
|
|
|
|
+// Set<Long> dayIdList = rulesList.stream().filter(e -> !videoIdList.contains(e.getVideoId())).map(QwSopTempRules::getDayId).collect(Collectors.toSet());
|
|
|
|
|
+// if (CollectionUtils.isNotEmpty(dayIdList)) {
|
|
|
|
|
+// qwSopTempDayService.removeByWrapper(new LambdaQueryWrapper<QwSopTempDay>().in(QwSopTempDay::getId, dayIdList));
|
|
|
|
|
+// qwSopTempRulesService.removeByWrapper(new LambdaQueryWrapper<QwSopTempRules>().in(QwSopTempRules::getDayId, dayIdList));
|
|
|
|
|
+// qwSopTempContentService.removeByWrapper(new LambdaQueryWrapper<QwSopTempContent>().in(QwSopTempContent::getDayId, dayIdList));
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+ // 需要添加的课程视频
|
|
|
|
|
+// List<FsUserCourseVideo> addVideoList = videoList.stream()
|
|
|
|
|
+// .filter(e -> rulesList.stream().noneMatch(f -> f.getVideoId().equals(e.getVideoId()))).collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
|
|
+// if (CollectionUtils.isNotEmpty(addVideoList)) {
|
|
|
|
|
+// for (QwSopTemp temp : tempList) {
|
|
|
|
|
+// // 通过历史中的第一课的数据来构建
|
|
|
|
|
+// Optional<QwSopTempDay> first = dayList.stream().filter(e -> e.getTempId().equals(temp.getId())).findFirst();
|
|
|
|
|
+// if (!first.isPresent()) {
|
|
|
|
|
+// break;
|
|
|
|
|
+// }
|
|
|
|
|
+// QwSopTempDay qwSopTempDay = first.get();
|
|
|
|
|
+// // 构造timeList timeDesc time
|
|
|
|
|
+// temp.setTime(LocalTime.now());
|
|
|
|
|
+//
|
|
|
|
|
+// temp.setTimeList(rulesList.stream()
|
|
|
|
|
+// .filter(e -> e.getTempId().equals(temp.getId()) && Objects.equals(e.getIsOfficial(), "0")
|
|
|
|
|
+// && Objects.equals(e.getDayId(), qwSopTempDay.getId())
|
|
|
|
|
+// ).map(QwSopTempRules::getTime)
|
|
|
|
|
+// .collect(Collectors.toList()));
|
|
|
|
|
+//
|
|
|
|
|
+// temp.setTimeDesc(contentList.stream().filter(e -> e.getTempId().equals(temp.getId())
|
|
|
|
|
+// && Objects.isNull(e.getIsBindUrl())
|
|
|
|
|
+// && Objects.equals(qwSopTempDay.getId(), e.getDayId())
|
|
|
|
|
+// )
|
|
|
|
|
+// .map(m -> JSONObject.parseObject(m.getContent()).getString("value")).collect(Collectors.toList()));
|
|
|
|
|
+// temp.setProject(fsUserCourse.getProject());
|
|
|
|
|
+// temp.setCourseId(courseId);
|
|
|
|
|
+// temp.setOpenOfficial("1");
|
|
|
|
|
+// qwSopTempMapper.updateQwSopTemp(temp);
|
|
|
|
|
+// createSopTempRules(temp, addVideoList, fsUserCourse);
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+// // 整理排序
|
|
|
|
|
+// List<QwSopTempRules> afterRuleList = qwSopTempRulesService.listByCourseId(courseId);
|
|
|
|
|
+// for (QwSopTemp temp : tempList) {
|
|
|
|
|
+// Long[] dayIdArray = afterRuleList.stream().filter(e -> e.getTempId().equals(temp.getId())).sorted(Comparator.comparing(a -> videoSortMap.get(a.getVideoId())))
|
|
|
|
|
+// .map(QwSopTempRules::getDayId).distinct().toArray(Long[]::new);
|
|
|
|
|
+// for (int i = 0; i < dayIdArray.length; i++) {
|
|
|
|
|
+// qwSopTempDayService.updateByWrapper(new UpdateWrapper<QwSopTempDay>()
|
|
|
|
|
+// .eq("id", dayIdArray[i])
|
|
|
|
|
+// .set("sorts", i + 1)
|
|
|
|
|
+// .set("name", "第" + (i + 1) + "天")
|
|
|
|
|
+// .set("day_num", i + 1)
|
|
|
|
|
+// );
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|