|
|
@@ -78,6 +78,7 @@ import com.zhongzheng.modules.system.service.ISysConfigService;
|
|
|
import com.zhongzheng.modules.system.service.ISysGoodsCopyRecordService;
|
|
|
import com.zhongzheng.modules.system.service.ISysOldOrgService;
|
|
|
import com.zhongzheng.modules.system.service.ISysTenantService;
|
|
|
+import com.zhongzheng.modules.tencentcloud.service.IVodService;
|
|
|
import com.zhongzheng.modules.user.bo.SubjectStudyRecordQueryBo;
|
|
|
import com.zhongzheng.modules.user.bo.UserPhoneBo;
|
|
|
import com.zhongzheng.modules.user.bo.UserStudyRecordAddBo;
|
|
|
@@ -135,6 +136,9 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
@Autowired
|
|
|
private CourseMapper courseMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IVodService iVodService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private ICourseService iCourseService;
|
|
|
|
|
|
@@ -5666,6 +5670,118 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
return updateById(goods);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public boolean sectionExport(List<SectionExportBo> boList,String json) {
|
|
|
+ if (CollectionUtils.isEmpty(boList)){
|
|
|
+ throw new CustomException("导入信息为空");
|
|
|
+ }
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(json);
|
|
|
+ String eduName = jsonObject.get("eduName").toString();
|
|
|
+ String businessName = jsonObject.get("businessName").toString();
|
|
|
+ String proName = jsonObject.get("proName").toString();
|
|
|
+ String subjectName = jsonObject.get("subjectName").toString();
|
|
|
+ String isPublic = jsonObject.get("isPublic").toString();
|
|
|
+
|
|
|
+ CourseEducationType educationType = iCourseEducationTypeService
|
|
|
+ .getOne(new LambdaQueryWrapper<CourseEducationType>().eq(CourseEducationType::getEducationName, eduName).eq(CourseEducationType::getStatus, 1).last("limit 1"));
|
|
|
+ Long eduId = educationType.getId();
|
|
|
+ CourseProjectType projectType = iCourseProjectTypeService
|
|
|
+ .getOne(new LambdaQueryWrapper<CourseProjectType>().eq(CourseProjectType::getProjectName, proName).eq(CourseProjectType::getEducationId, eduId).eq(CourseProjectType::getStatus, 1).last("limit 1"));
|
|
|
+ Long proId = projectType.getId();
|
|
|
+ CourseBusiness business = iCourseBusinessService
|
|
|
+ .getOne(new LambdaQueryWrapper<CourseBusiness>().eq(CourseBusiness::getBusinessName, businessName).eq(CourseBusiness::getProjectId, proId).eq(CourseBusiness::getStatus, 1).last("limit 1"));
|
|
|
+ Long businessId = business.getId();
|
|
|
+
|
|
|
+ List<Long> subjectIds = new ArrayList<>();
|
|
|
+ if (isPublic.equals("1")) {
|
|
|
+ //公共章
|
|
|
+ List<CourseSubjectProject> list = iCourseSubjectProjectService.list(new LambdaQueryWrapper<CourseSubjectProject>().eq(CourseSubjectProject::getProjectId, proId));
|
|
|
+ List<CourseSubject> courseSubjects = iCourseSubjectService.listByIds(list.stream().map(CourseSubjectProject::getSubjectId).collect(Collectors.toList()));
|
|
|
+ subjectIds.addAll(courseSubjects.stream().map(CourseSubject::getId).collect(Collectors.toList()));
|
|
|
+ }else {
|
|
|
+ List<CourseSubjectProject> list = iCourseSubjectProjectService.list(new LambdaQueryWrapper<CourseSubjectProject>().eq(CourseSubjectProject::getProjectId, proId));
|
|
|
+ List<Long> collect = list.stream().map(CourseSubjectProject::getSubjectId).collect(Collectors.toList());
|
|
|
+ CourseSubject one = iCourseSubjectService.getOne(new LambdaQueryWrapper<CourseSubject>().in(CourseSubject::getId, collect).eq(CourseSubject::getSubjectName, subjectName).last("limit 1"));
|
|
|
+ subjectIds.add(one.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //根据章名称分组
|
|
|
+ Map<String, List<SectionExportBo>> listMap = boList.stream().collect(Collectors.groupingBy(SectionExportBo::getChapterName));
|
|
|
+
|
|
|
+ listMap.forEach((k,v) -> {
|
|
|
+
|
|
|
+ //添加章信息
|
|
|
+ CourseChapter courseChapter = new CourseChapter();
|
|
|
+ courseChapter.setName(k);
|
|
|
+ courseChapter.setPrefixName("20250617");
|
|
|
+ courseChapter.setCreateTime(DateUtils.getNowTime());
|
|
|
+ courseChapter.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ courseChapter.setCode(ServletUtils.getEncoded("Z"));
|
|
|
+ courseChapter.setCoverUrl("oss/images/avatar/20211013/1634097664410_1397766697");
|
|
|
+ courseChapter.setStatus(1);
|
|
|
+ courseChapter.setPublishStatus(1L);
|
|
|
+ courseChapter.setCommonSign(isPublic);
|
|
|
+ courseChapter.setViewSign(2);
|
|
|
+ iCourseChapterService.save(courseChapter);
|
|
|
+
|
|
|
+ //添加章业务层次信息
|
|
|
+ subjectIds.forEach(subjectId -> {
|
|
|
+ CourseChapterBusiness chapterBusiness = new CourseChapterBusiness();
|
|
|
+ chapterBusiness.setBusinessId(businessId);
|
|
|
+ chapterBusiness.setProjectId(proId);
|
|
|
+ chapterBusiness.setEducationTypeId(eduId);
|
|
|
+ chapterBusiness.setSubjectId(subjectId);
|
|
|
+ chapterBusiness.setChapterId(courseChapter.getChapterId());
|
|
|
+ iCourseChapterBusinessService.save(chapterBusiness);
|
|
|
+ });
|
|
|
+
|
|
|
+ //添加章下面的节
|
|
|
+ for (int i = 0; i < v.size(); i++) {
|
|
|
+ SectionExportBo item = v.get(i);
|
|
|
+ CourseSection entity = new CourseSection();
|
|
|
+ entity.setName(item.getSectionName());
|
|
|
+ entity.setPrefixName("20250617");
|
|
|
+ entity.setSectionType(1);
|
|
|
+ entity.setPublishStatus(1);
|
|
|
+ entity.setRecordingUrl(item.getSectionUrl());
|
|
|
+ //视频时长
|
|
|
+ Map<String, Object> stringObjectMap = iVodService.describeMediaInfos(new String[]{item.getSectionUrl()});
|
|
|
+ Object duration = stringObjectMap.get("duration");
|
|
|
+ int num = (int) Double.parseDouble(duration.toString());
|
|
|
+ entity.setDurationTime(Long.valueOf(num));
|
|
|
+ entity.setCode(ServletUtils.getEncoded("J"));
|
|
|
+ entity.setCreateTime(DateUtils.getNowTime());
|
|
|
+ entity.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ entity.setCoverUrl("oss/images/avatar/20211013/1634097664410_1397766697");
|
|
|
+ entity.setViewSign(2);
|
|
|
+ entity.setStatus(1);
|
|
|
+ iCourseSectionService.save(entity);
|
|
|
+
|
|
|
+ //添加节业务层次信息
|
|
|
+ subjectIds.forEach(subjectId -> {
|
|
|
+ CourseSectionBusiness sectionBusiness = new CourseSectionBusiness();
|
|
|
+ sectionBusiness.setBusinessId(businessId);
|
|
|
+ sectionBusiness.setProjectId(proId);
|
|
|
+ sectionBusiness.setEducationTypeId(eduId);
|
|
|
+ sectionBusiness.setSubjectId(subjectId);
|
|
|
+ sectionBusiness.setSectionId(entity.getSectionId());
|
|
|
+ iCourseSectionBusinessService.save(sectionBusiness);
|
|
|
+ });
|
|
|
+
|
|
|
+ //添加章节关联
|
|
|
+ CourseChapterSection chapterSection = new CourseChapterSection();
|
|
|
+ chapterSection.setChapterId(courseChapter.getChapterId());
|
|
|
+ chapterSection.setSectionId(entity.getSectionId());
|
|
|
+ chapterSection.setSort(Long.valueOf(i+1));
|
|
|
+ iCourseChapterSectionService.save(chapterSection);
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
private void updateHandoutsId(Long goodsId, Long tenantId, Long handoutsId) {
|
|
|
baseMapper.updateHandoutsId(goodsId, tenantId, handoutsId);
|
|
|
}
|