|
|
@@ -1459,6 +1459,187 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
|
|
|
return Collections.emptyMap();
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Map<String, Object> importQDY(List<CourseEJVo> questionList2, String param) {
|
|
|
+ if (CollectionUtils.isEmpty(questionList2)){
|
|
|
+ return new HashMap<>();
|
|
|
+ }
|
|
|
+ //获取业务层次ID
|
|
|
+ CourseJsonEJVo importVo = JSON.parseObject(param, CourseJsonEJVo.class);
|
|
|
+ CourseEducationType educationType = iCourseEducationTypeService
|
|
|
+ .getOne(new LambdaQueryWrapper<CourseEducationType>()
|
|
|
+ .eq(CourseEducationType::getEducationName, importVo.getEduName())
|
|
|
+ .eq(CourseEducationType::getStatus, 1)
|
|
|
+ .last("limit 1"));
|
|
|
+ CourseProjectType projectType = iCourseProjectTypeService.getOne(new LambdaUpdateWrapper<CourseProjectType>()
|
|
|
+ .eq(CourseProjectType::getEducationId, educationType.getId())
|
|
|
+ .eq(CourseProjectType::getProjectName, importVo.getProName())
|
|
|
+ .eq(CourseProjectType::getStatus, 1)
|
|
|
+ .last("limit 1"));
|
|
|
+ CourseBusiness business = iCourseBusinessService.getOne(new LambdaUpdateWrapper<CourseBusiness>()
|
|
|
+ .eq(CourseBusiness::getProjectId, projectType.getId())
|
|
|
+ .eq(CourseBusiness::getBusinessName, importVo.getBusinessName())
|
|
|
+ .eq(CourseBusiness::getStatus, 1)
|
|
|
+ .last("limit 1"));
|
|
|
+ List<CourseSubject> courseSubjects = new ArrayList<>();
|
|
|
+
|
|
|
+ //默认图片地址
|
|
|
+ String imagePath = "cos/images/tupain/1634097664410_1397766697";
|
|
|
+ CourseEJVo vo1 = questionList2.stream().filter(x -> x.getLevel().equals("1")).collect(Collectors.toList()).get(0);
|
|
|
+ if (ObjectUtils.isNull(vo1)){
|
|
|
+ throw new CustomException("模块获取失败");
|
|
|
+ }
|
|
|
+ //是否公共模块
|
|
|
+ Integer falg = vo1.getChapterName().contains("公共课")?1:0;
|
|
|
+ if (falg == 1){
|
|
|
+ //公共课包含所有科目
|
|
|
+ courseSubjects = iCourseSubjectService.listByProId(projectType.getId());
|
|
|
+ }else {
|
|
|
+ courseSubjects.add(iCourseSubjectService.getOneByName(importVo.getSubName(),projectType.getId()));
|
|
|
+ }
|
|
|
+ //新增课程模块
|
|
|
+ CourseModule module = new CourseModule();
|
|
|
+ module.setPrefixName("2025七大员继教");
|
|
|
+ module.setModuleName(vo1.getChapterName());
|
|
|
+ module.setPublishStatus(1L);
|
|
|
+ module.setCreateTime(DateUtils.getNowTime());
|
|
|
+ module.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ module.setStatus(1);
|
|
|
+ module.setCode(ServletUtils.getEncoded("MK"));
|
|
|
+ module.setCommonSign(falg);
|
|
|
+ module.setViewSign(2);
|
|
|
+ module.setCoverUrl(imagePath);
|
|
|
+ iCourseModuleService.save(module);
|
|
|
+
|
|
|
+ //模块业务层次
|
|
|
+ courseSubjects.forEach(item ->{
|
|
|
+ CourseModuleBusiness moduleBusiness = new CourseModuleBusiness();
|
|
|
+ moduleBusiness.setModuleId(module.getModuleId());
|
|
|
+ moduleBusiness.setEducationTypeId(educationType.getId());
|
|
|
+ moduleBusiness.setProjectId(projectType.getId());
|
|
|
+ moduleBusiness.setBusinessId(business.getId());
|
|
|
+ moduleBusiness.setSubjectId(item.getId());
|
|
|
+ iCourseModuleBusinessService.save(moduleBusiness);
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ //根据章节名称分组
|
|
|
+ Map<String, List<CourseEJVo>> map = questionList2.stream().collect(Collectors.groupingBy(CourseEJVo::getChapterName));
|
|
|
+
|
|
|
+ // 使用 AtomicInteger 实现自增
|
|
|
+ AtomicInteger counter = new AtomicInteger(1);
|
|
|
+ map.forEach((k,v) -> {
|
|
|
+ CourseEJVo vo2 = v.get(0);
|
|
|
+ if (vo2.getLevel().equals("1")){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ int a = counter.getAndIncrement();
|
|
|
+ //新增章
|
|
|
+ CourseChapter chapter = new CourseChapter();
|
|
|
+ chapter.setName(k);
|
|
|
+ chapter.setSort(Long.valueOf(a));
|
|
|
+ chapter.setCreateTime(DateUtils.getNowTime());
|
|
|
+ chapter.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ chapter.setStatus(1);
|
|
|
+ chapter.setPrefixName("2025七大员继教");
|
|
|
+ chapter.setPublishStatus(1L);
|
|
|
+ chapter.setCode(ServletUtils.getEncoded("Z"));
|
|
|
+ chapter.setCommonSign(falg);
|
|
|
+ chapter.setViewSign(2);
|
|
|
+ chapter.setCoverUrl(imagePath);
|
|
|
+ iCourseChapterService.save(chapter);
|
|
|
+
|
|
|
+ //章业务层
|
|
|
+ if (falg == 1){
|
|
|
+ //公共课包含所有科目
|
|
|
+ List<CourseSubject> courseSubjects1 = iCourseSubjectService.listByProId(projectType.getId());
|
|
|
+ courseSubjects1.forEach(item -> {
|
|
|
+ CourseChapterBusiness chapterBusiness = new CourseChapterBusiness();
|
|
|
+ chapterBusiness.setChapterId(chapter.getChapterId());
|
|
|
+ chapterBusiness.setEducationTypeId(educationType.getId());
|
|
|
+ chapterBusiness.setProjectId(projectType.getId());
|
|
|
+ chapterBusiness.setBusinessId(business.getId());
|
|
|
+ chapterBusiness.setSubjectId(item.getId());
|
|
|
+ iCourseChapterBusinessService.save(chapterBusiness);
|
|
|
+ });
|
|
|
+ }else {
|
|
|
+ CourseSubject oneByName = iCourseSubjectService.getOneByName(importVo.getSubName(), projectType.getId());
|
|
|
+ CourseChapterBusiness chapterBusiness = new CourseChapterBusiness();
|
|
|
+ chapterBusiness.setChapterId(chapter.getChapterId());
|
|
|
+ chapterBusiness.setEducationTypeId(educationType.getId());
|
|
|
+ chapterBusiness.setProjectId(projectType.getId());
|
|
|
+ chapterBusiness.setBusinessId(business.getId());
|
|
|
+ chapterBusiness.setSubjectId(oneByName.getId());
|
|
|
+ iCourseChapterBusinessService.save(chapterBusiness);
|
|
|
+ }
|
|
|
+
|
|
|
+ //处理视频节
|
|
|
+ for (int i = 0; i < v.size(); i++) {
|
|
|
+ CourseEJVo vo = v.get(i);
|
|
|
+ if (vo.getLevel().equals("3")){
|
|
|
+ CourseSection section = new CourseSection();
|
|
|
+ section.setName(vo.getSectionName());
|
|
|
+ section.setCreateTime(DateUtils.getNowTime());
|
|
|
+ section.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ section.setStatus(1);
|
|
|
+ section.setSort(i+1L);
|
|
|
+ section.setPrefixName("2025七大员继教");
|
|
|
+ section.setPublishStatus(1);
|
|
|
+ section.setSectionType(1);
|
|
|
+ section.setRecordingUrl(vo.getSectionKey());
|
|
|
+ section.setTencentVideoUrl(vo.getSectionKey());
|
|
|
+ section.setDurationTime(Long.valueOf(vo.getSectionTime()));
|
|
|
+ section.setTencentVideoTime(Long.valueOf(vo.getSectionTime()));
|
|
|
+ section.setCode(ServletUtils.getEncoded("J"));
|
|
|
+ section.setViewSign(2);
|
|
|
+ section.setCoverUrl(imagePath);
|
|
|
+ iCourseSectionService.save(section);
|
|
|
+
|
|
|
+ //节业务层
|
|
|
+ if (falg == 1){
|
|
|
+ //公共课包含所有科目
|
|
|
+ List<CourseSubject> courseSubjects1 = iCourseSubjectService.listByProId(projectType.getId());
|
|
|
+ courseSubjects1.forEach(item -> {
|
|
|
+ CourseSectionBusiness sectionBusiness = new CourseSectionBusiness();
|
|
|
+ sectionBusiness.setSectionId(section.getSectionId());
|
|
|
+ sectionBusiness.setEducationTypeId(educationType.getId());
|
|
|
+ sectionBusiness.setProjectId(projectType.getId());
|
|
|
+ sectionBusiness.setBusinessId(business.getId());
|
|
|
+ sectionBusiness.setSubjectId(item.getId());
|
|
|
+ iCourseSectionBusinessService.save(sectionBusiness);
|
|
|
+ });
|
|
|
+ }else {
|
|
|
+ CourseSubject oneByName = iCourseSubjectService.getOneByName(importVo.getSubName(), projectType.getId());
|
|
|
+ CourseSectionBusiness sectionBusiness = new CourseSectionBusiness();
|
|
|
+ sectionBusiness.setSectionId(section.getSectionId());
|
|
|
+ sectionBusiness.setEducationTypeId(educationType.getId());
|
|
|
+ sectionBusiness.setProjectId(projectType.getId());
|
|
|
+ sectionBusiness.setBusinessId(business.getId());
|
|
|
+ sectionBusiness.setSubjectId(oneByName.getId());
|
|
|
+ iCourseSectionBusinessService.save(sectionBusiness);
|
|
|
+ }
|
|
|
+
|
|
|
+ //章节关联关系
|
|
|
+ CourseChapterSection chapterSection = new CourseChapterSection();
|
|
|
+ chapterSection.setChapterId(chapter.getChapterId());
|
|
|
+ chapterSection.setSectionId(section.getSectionId());
|
|
|
+ chapterSection.setSort(Long.valueOf(i));
|
|
|
+ iCourseChapterSectionService.save(chapterSection);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //模块章关联
|
|
|
+ CourseModuleChapter moduleChapter = new CourseModuleChapter();
|
|
|
+ moduleChapter.setChapterId(chapter.getChapterId());
|
|
|
+ moduleChapter.setModuleId(module.getModuleId());
|
|
|
+ moduleChapter.setSort(Long.valueOf(a));
|
|
|
+ iCourseModuleChapterService.save(moduleChapter);
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ return Collections.emptyMap();
|
|
|
+ }
|
|
|
+
|
|
|
private Long liveTime(Long nowTime, Integer day) {
|
|
|
for (Integer i = 0; i < day; i++) {
|
|
|
Long dayAfter = DateUtils.getDayAfter(nowTime, 1);
|