|
|
|
@ -51,7 +51,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
import java.util.concurrent.CopyOnWriteArrayList;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import static cn.hutool.core.collection.ListUtil.toCopyOnWriteArrayList;
|
|
|
|
|
import static cn.hutool.core.util.ArrayUtil.join;
|
|
|
|
|
import static cn.hutool.core.util.ObjectUtil.defaultIfNull;
|
|
|
|
|
import static com.ibeetl.admin.core.util.ExcelUtil.getCellFormatValue;
|
|
|
|
@ -509,40 +508,33 @@ public class TeacherOpenCourseMergeCourseInfoService extends CoreBaseService<Tea
|
|
|
|
|
* 处理一维集合,更换ID和父辈ID的方法
|
|
|
|
|
*
|
|
|
|
|
* @param copyToList
|
|
|
|
|
* @param parentId
|
|
|
|
|
* @param idPair
|
|
|
|
|
*/
|
|
|
|
|
public void batchUpdateArrayListSomeMergeId(List<TeacherOpenCourseMergeCourseInfo> copyToList,
|
|
|
|
|
final Long parentId, ConcurrentHashMap<Long, Long> idPair) {
|
|
|
|
|
|
|
|
|
|
// 转换成线程安全的集合,来并行操作。
|
|
|
|
|
// TODO 未完待续。
|
|
|
|
|
CopyOnWriteArrayList<TeacherOpenCourseMergeCourseInfo> onWriteArrayList = toCopyOnWriteArrayList(copyToList);
|
|
|
|
|
Iterator<TeacherOpenCourseMergeCourseInfo> iterator = onWriteArrayList.stream().parallel().iterator();
|
|
|
|
|
|
|
|
|
|
// 过滤掉第一层,课程节点数据
|
|
|
|
|
List<TeacherOpenCourseMergeCourseInfo> reference = onWriteArrayList.stream()
|
|
|
|
|
.parallel().filter(e -> e.getCourseInfoParentId() != null)
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
public Map<Long, Long> batchUpdateArrayListSomeMergeId(CopyOnWriteArrayList<TeacherOpenCourseMergeCourseInfo> copyToList) {
|
|
|
|
|
|
|
|
|
|
iterator.forEachRemaining(item -> {
|
|
|
|
|
ConcurrentHashMap<Long, Long> idPair = new ConcurrentHashMap<>();
|
|
|
|
|
|
|
|
|
|
// 遍历所有节点
|
|
|
|
|
copyToList.stream().parallel().forEach(item -> {
|
|
|
|
|
// 先判断必要的条件不能为空!才能继续进行下面的重置ID操作
|
|
|
|
|
Assert.notNull(item.getTeacherOpenCourseMergeCourseInfoId(), "开课课程ID不能为空!");
|
|
|
|
|
Assert.notNull(item.getCourseInfoParentId(), "开课课程上级ID不能为空!");
|
|
|
|
|
|
|
|
|
|
// 查找parentId对应关系
|
|
|
|
|
List<TeacherOpenCourseMergeCourseInfo> filterMatchList = reference.stream()
|
|
|
|
|
.filter(ref -> ref.getCourseInfoParentId().equals(item.getTeacherOpenCourseMergeCourseInfoId()))
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
// 查找是否有子节点
|
|
|
|
|
CopyOnWriteArrayList<TeacherOpenCourseMergeCourseInfo> filterMatchList = copyToList.stream()
|
|
|
|
|
.filter(ref -> item.getTeacherOpenCourseMergeCourseInfoId().equals(ref.getCourseInfoParentId()))
|
|
|
|
|
.collect(Collectors.toCollection(CopyOnWriteArrayList::new));
|
|
|
|
|
|
|
|
|
|
Long newId = defaultIfNull(parentId, snowflake.nextId());
|
|
|
|
|
item.setTeacherOpenCourseMergeCourseInfoId(newId);
|
|
|
|
|
Long newId = snowflake.nextId();
|
|
|
|
|
// 存储ID对
|
|
|
|
|
idPair.put(item.getTeacherOpenCourseMergeCourseInfoId(), newId);
|
|
|
|
|
iterator.remove();
|
|
|
|
|
batchUpdateArrayListSomeMergeId(filterMatchList, newId, idPair);
|
|
|
|
|
// 重置父节点的ID
|
|
|
|
|
item.setTeacherOpenCourseMergeCourseInfoId(newId);
|
|
|
|
|
// 重置子节点的父辈ID
|
|
|
|
|
filterMatchList.forEach(e -> {
|
|
|
|
|
e.setCourseInfoParentId(newId);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return idPair;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -607,9 +599,10 @@ public class TeacherOpenCourseMergeCourseInfoService extends CoreBaseService<Tea
|
|
|
|
|
* @param teacherOpenCourseId 开课ID
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public void copyFromCourseInfo(@NotEmpty(message = "系统课程ID不能为空!") Set<Long> courseInfoIds,
|
|
|
|
|
public Map<Long, Long> copyFromCourseInfo(@NotEmpty(message = "系统课程ID不能为空!") Set<Long> courseInfoIds,
|
|
|
|
|
@NotNull(message = "开课ID不能为空!") final Long teacherOpenCourseId) {
|
|
|
|
|
|
|
|
|
|
ConcurrentHashMap<Long, Long> idPair = new ConcurrentHashMap<>();
|
|
|
|
|
// 查询是否绑定过课程
|
|
|
|
|
boolean notExists = teacherOpenCourseMergeCourseInfoDao.isNotExistsByTeacherOpenCourseId(teacherOpenCourseId);
|
|
|
|
|
|
|
|
|
@ -639,13 +632,14 @@ public class TeacherOpenCourseMergeCourseInfoService extends CoreBaseService<Tea
|
|
|
|
|
item.setCourseInfoName(item.getCourseInfoName().replaceAll(" ", ""));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
ConcurrentHashMap<Long, Long> idPair = new ConcurrentHashMap<>();
|
|
|
|
|
// batchUpdateArrayListSomeMergeId(copyToList, null, idPair);
|
|
|
|
|
System.out.println(idPair);
|
|
|
|
|
copyToList = new CopyOnWriteArrayList<>(copyToList);
|
|
|
|
|
idPair.putAll(batchUpdateArrayListSomeMergeId((CopyOnWriteArrayList)copyToList));
|
|
|
|
|
|
|
|
|
|
// 批量插入
|
|
|
|
|
teacherOpenCourseMergeCourseInfoDao.insertBatch(copyToList);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return idPair;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -661,7 +655,7 @@ public class TeacherOpenCourseMergeCourseInfoService extends CoreBaseService<Tea
|
|
|
|
|
@NotNull(message = "开课ID不能为空!") final Long teacherOpenCourseId) {
|
|
|
|
|
|
|
|
|
|
// 拷贝课程章节
|
|
|
|
|
copyFromCourseInfo(courseInfoIds, teacherOpenCourseId);
|
|
|
|
|
Map<Long, Long> idPair = copyFromCourseInfo(courseInfoIds, teacherOpenCourseId);
|
|
|
|
|
|
|
|
|
|
// 开启并行处理
|
|
|
|
|
courseInfoIds.stream().parallel().forEach(courseInfoId -> {
|
|
|
|
@ -683,7 +677,7 @@ public class TeacherOpenCourseMergeCourseInfoService extends CoreBaseService<Tea
|
|
|
|
|
// 系统题目库ID集合
|
|
|
|
|
Set<Long> resourcesQuestionIds = resourcesQuestionList.stream().map(ResourcesQuestion::getResourcesQuestionId).collect(toSet());
|
|
|
|
|
// 拷贝系统题目库到教师开课
|
|
|
|
|
teacherOpenCourseMergeResourcesQuestionService.copyFromQuestion(resourcesQuestionIds, teacherOpenCourseId);
|
|
|
|
|
teacherOpenCourseMergeResourcesQuestionService.copyFromQuestion(resourcesQuestionIds, teacherOpenCourseId, idPair);
|
|
|
|
|
|
|
|
|
|
ResourcesInfoQuery resourcesInfoQuery = new ResourcesInfoQuery();
|
|
|
|
|
resourcesInfoQuery.setCourseInfoIds(allCourseInfoIdsJoin);
|
|
|
|
@ -692,7 +686,7 @@ public class TeacherOpenCourseMergeCourseInfoService extends CoreBaseService<Tea
|
|
|
|
|
// 系统资源库ID集合
|
|
|
|
|
Set<Long> resourcesInfoIds = resourcesInfoList.stream().map(ResourcesInfo::getResourcesInfoId).collect(toSet());
|
|
|
|
|
// 拷贝系统资源库到教师开课
|
|
|
|
|
teacherOpenCourseMergeResourcesInfoService.copyFromResourcesInfo(resourcesInfoIds, teacherOpenCourseId);
|
|
|
|
|
teacherOpenCourseMergeResourcesInfoService.copyFromResourcesInfo(resourcesInfoIds, teacherOpenCourseId, idPair);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -737,7 +731,7 @@ public class TeacherOpenCourseMergeCourseInfoService extends CoreBaseService<Tea
|
|
|
|
|
public void deleteTeacherOpenCourseAllRelatedByTeacherOpenCourseId(Long teacherOpenCourseId) {
|
|
|
|
|
TeacherOpenCourseMergeCourseInfoQuery courseInfoQuery = new TeacherOpenCourseMergeCourseInfoQuery();
|
|
|
|
|
courseInfoQuery.setTeacherOpenCourseId(teacherOpenCourseId);
|
|
|
|
|
List<TeacherOpenCourseMergeCourseInfo> values = getValuesByQuery(courseInfoQuery);
|
|
|
|
|
List<TeacherOpenCourseMergeCourseInfo> values = getValuesByQueryNotWithPermission(courseInfoQuery);
|
|
|
|
|
|
|
|
|
|
// 根据ID删除数据
|
|
|
|
|
Set<Long> delIdList = values.stream().map(TeacherOpenCourseMergeCourseInfo::getTeacherOpenCourseMergeCourseInfoId).collect(toSet());
|
|
|
|
|