|
|
@@ -804,7 +804,28 @@ public class QwSopTempServiceImpl implements IQwSopTempService {
|
|
|
if (CollectionUtils.isEmpty(rulesList)) {
|
|
|
return;
|
|
|
}
|
|
|
+ syncTemplateCommon(rulesList,courseId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void syncTemplateByCompanyId(Long courseId,Long companyId) {
|
|
|
+
|
|
|
+ // 通过销售id 查询所属的 销售公司的正常 使用的 课程模板
|
|
|
+ QwSopTemp qwSopTemp=new QwSopTemp();
|
|
|
+ qwSopTemp.setCompanyId(companyId);
|
|
|
+ qwSopTemp.setSendType(11);
|
|
|
+ qwSopTemp.setStatus("1");
|
|
|
+ List<QwSopTemp> qwSopTemps = qwSopTempMapper.selectQwSopTempList(qwSopTemp);
|
|
|
+
|
|
|
+ List<String> tempIds = qwSopTemps.stream().map(QwSopTemp::getId).collect(Collectors.toList());
|
|
|
+ List<QwSopTempRules> rulesList = qwSopTempRulesService.listByCourseIdAndTempIds(courseId, tempIds);
|
|
|
|
|
|
+ syncTemplateCommon(rulesList,courseId);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public void syncTemplateCommon(List<QwSopTempRules> rulesList,Long courseId) {
|
|
|
// 获取这些规则关联的模板ID集合
|
|
|
Set<String> tempIds = rulesList.stream()
|
|
|
.map(QwSopTempRules::getTempId)
|
|
|
@@ -824,7 +845,6 @@ public class QwSopTempServiceImpl implements IQwSopTempService {
|
|
|
qwSopTempContentService.removeByWrapper(new LambdaQueryWrapper<QwSopTempContent>().in(QwSopTempContent::getDayId, dayIdList));
|
|
|
}
|
|
|
|
|
|
-
|
|
|
tempIds.forEach(teId->{
|
|
|
QwSopTemp sopTemp = qwSopTempMapper.selectQwSopTempById(teId);
|
|
|
List<QwSopTempContent> contentList = qwSopTempContentService.listByTempId(teId);
|
|
|
@@ -880,74 +900,9 @@ public class QwSopTempServiceImpl implements IQwSopTempService {
|
|
|
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
-// 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)
|
|
|
-// );
|
|
|
-// }
|
|
|
-// }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* sop模板update一键开关官方群发
|
|
|
* @param param
|