|
|
|
@ -1,6 +1,9 @@
|
|
|
|
|
package com.ibeetl.jlw.service;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import cn.hutool.core.bean.copier.CopyOptions;
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
import cn.hutool.core.map.MapUtil;
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
import cn.jlw.util.ToolUtils;
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
@ -397,8 +400,8 @@ public class TeacherOpenCourseMergeCourseInfoService extends CoreBaseService<Tea
|
|
|
|
|
* 教师端-导入课程章节操作,逻辑拆分
|
|
|
|
|
*
|
|
|
|
|
* 从系统章节库拉取章节到教师开课的课程章节中。
|
|
|
|
|
* @param courseInfoIds 超管端的章节ID
|
|
|
|
|
* @param teacherOpenCourseId 开课iD
|
|
|
|
|
* @param courseInfoIds 超管端的课程章节ID
|
|
|
|
|
* @param teacherOpenCourseId 开课ID
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public void copyFromCourseInfo(@NotEmpty(message = "系统课程ID不能为空!") Set<Long> courseInfoIds,
|
|
|
|
@ -406,14 +409,23 @@ public class TeacherOpenCourseMergeCourseInfoService extends CoreBaseService<Tea
|
|
|
|
|
|
|
|
|
|
// 开启并行处理
|
|
|
|
|
courseInfoIds.stream().parallel().forEach(courseInfoId -> {
|
|
|
|
|
List<CourseInfo> chapterList = courseInfoService.getChapterList(courseInfoId);
|
|
|
|
|
// 当前的课程信息
|
|
|
|
|
CourseInfo currentCourseInfo = courseInfoService.getById(courseInfoId);
|
|
|
|
|
// 查询当前课程信息下的,章节或者小节信息,返回一维集合
|
|
|
|
|
List<CourseInfo> chapterList = courseInfoService.getCourseResources(courseInfoId);
|
|
|
|
|
|
|
|
|
|
// 将课程本身添加进集合
|
|
|
|
|
chapterList.add(currentCourseInfo);
|
|
|
|
|
// 拷贝
|
|
|
|
|
CopyOptions copyOptions = CopyOptions.create().setFieldMapping(MapUtil.of("courseInfoId", "teacherOpenCourseMergeCourseInfoId"));
|
|
|
|
|
List<TeacherOpenCourseMergeCourseInfo> copyToList =
|
|
|
|
|
BeanUtil.copyToList(chapterList, TeacherOpenCourseMergeCourseInfo.class);
|
|
|
|
|
BeanUtil.copyToList(chapterList, TeacherOpenCourseMergeCourseInfo.class, copyOptions);
|
|
|
|
|
if (ObjectUtil.isEmpty(copyToList)) { return; }
|
|
|
|
|
// 设置开课ID
|
|
|
|
|
copyToList.forEach(item -> item.setTeacherOpenCourseId(teacherOpenCourseId));
|
|
|
|
|
copyToList.forEach(item -> {
|
|
|
|
|
item.setTeacherOpenCourseId(teacherOpenCourseId);
|
|
|
|
|
item.setCourseInfoName(item.getCourseInfoName().replaceAll(" ", ""));
|
|
|
|
|
});
|
|
|
|
|
// 批量插入
|
|
|
|
|
teacherOpenCourseMergeCourseInfoDao.insertBatch(copyToList);
|
|
|
|
|
});
|
|
|
|
@ -438,12 +450,13 @@ public class TeacherOpenCourseMergeCourseInfoService extends CoreBaseService<Tea
|
|
|
|
|
courseInfoIds.stream().parallel().forEach(courseInfoId -> {
|
|
|
|
|
// 获取这个课程章节下的所有的子章节信息
|
|
|
|
|
List<CourseInfo> chapterList = courseInfoService.getChapterList(Long.valueOf(courseInfoId));
|
|
|
|
|
HashSet<CourseInfo> courseInfos = CollectionUtil.newHashSet(chapterList);
|
|
|
|
|
|
|
|
|
|
// 如果课程章节没查到记录,则下面的资源也没必要执行,资源依赖课程章节
|
|
|
|
|
if (ObjectUtil.isEmpty(chapterList)) { return; }
|
|
|
|
|
if (ObjectUtil.isEmpty(courseInfos)) { return; }
|
|
|
|
|
|
|
|
|
|
// 取出来所有的课程章节ID
|
|
|
|
|
String allCourseInfoIdsJoin = chapterList.stream().map(item -> item.getCourseInfoId().toString()).collect(joining(","));
|
|
|
|
|
String allCourseInfoIdsJoin = courseInfos.stream().map(item -> item.getCourseInfoId().toString()).collect(joining(","));
|
|
|
|
|
|
|
|
|
|
ResourcesQuestionQuery resourcesQuestionQuery = new ResourcesQuestionQuery();
|
|
|
|
|
resourcesQuestionQuery.setCourseInfoIds(allCourseInfoIdsJoin);
|
|
|
|
|