|
@@ -3,6 +3,7 @@ package com.zhichen.modules.course.service.impl;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.lang.Validator;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
@@ -18,6 +19,7 @@ import com.google.zxing.BarcodeFormat;
|
|
|
import com.google.zxing.client.j2se.MatrixToImageWriter;
|
|
|
import com.google.zxing.common.BitMatrix;
|
|
|
import com.google.zxing.qrcode.QRCodeWriter;
|
|
|
+import com.tencentcloudapi.ecm.v20190719.models.ModuleCounter;
|
|
|
import com.zhichen.common.core.page.TableDataInfo;
|
|
|
import com.zhichen.common.core.redis.RedisCache;
|
|
|
import com.zhichen.common.exception.CustomException;
|
|
@@ -26,16 +28,13 @@ import com.zhichen.common.utils.DateUtils;
|
|
|
import com.zhichen.common.utils.ServletUtils;
|
|
|
import com.zhichen.common.utils.ToolsUtils;
|
|
|
import com.zhichen.common.utils.http.HttpUtils;
|
|
|
+import com.zhichen.modules.bank.vo.QuestionBusinessImportVo;
|
|
|
import com.zhichen.modules.base.domain.UserProfile;
|
|
|
import com.zhichen.modules.base.service.IUserProfileService;
|
|
|
-import com.zhichen.modules.course.bo.CourseAddBo;
|
|
|
-import com.zhichen.modules.course.bo.CourseEditBo;
|
|
|
-import com.zhichen.modules.course.bo.CourseQueryBo;
|
|
|
-import com.zhichen.modules.course.domain.Course;
|
|
|
-import com.zhichen.modules.course.domain.CoursePhotoLog;
|
|
|
+import com.zhichen.modules.course.bo.*;
|
|
|
+import com.zhichen.modules.course.domain.*;
|
|
|
import com.zhichen.modules.course.mapper.CourseMapper;
|
|
|
-import com.zhichen.modules.course.service.ICoursePhotoLogService;
|
|
|
-import com.zhichen.modules.course.service.ICourseService;
|
|
|
+import com.zhichen.modules.course.service.*;
|
|
|
import com.zhichen.modules.course.vo.CourseUserVo;
|
|
|
import com.zhichen.modules.course.vo.CourseVo;
|
|
|
import com.zhichen.modules.exam.bo.ExamApplySiteTimeTwoAddBo;
|
|
@@ -89,6 +88,7 @@ import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -172,7 +172,32 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
|
|
|
private ClassGradeUserMapper classGradeUserMapper;
|
|
|
@Autowired
|
|
|
private IUserStudyVideoService iUserStudyVideoService;
|
|
|
+ @Autowired
|
|
|
+ private ICourseEducationTypeService iCourseEducationTypeService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ICourseProjectTypeService iCourseProjectTypeService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ICourseBusinessService iCourseBusinessService;
|
|
|
+ @Autowired
|
|
|
+ private ICourseSubjectService iCourseSubjectService;
|
|
|
+ @Autowired
|
|
|
+ private ICourseModuleService iCourseModuleService;
|
|
|
+ @Autowired
|
|
|
+ private ICourseModuleBusinessService iCourseModuleBusinessService;
|
|
|
+ @Autowired
|
|
|
+ private ICourseModuleChapterService iCourseModuleChapterService;
|
|
|
+ @Autowired
|
|
|
+ private ICourseChapterService iCourseChapterService;
|
|
|
+ @Autowired
|
|
|
+ private ICourseChapterBusinessService iCourseChapterBusinessService;
|
|
|
+ @Autowired
|
|
|
+ private ICourseChapterSectionService iCourseChapterSectionService;
|
|
|
+ @Autowired
|
|
|
+ private ICourseSectionService iCourseSectionService;
|
|
|
+ @Autowired
|
|
|
+ private ICourseSectionBusinessService iCourseSectionBusinessService;
|
|
|
|
|
|
@Override
|
|
|
public CourseVo queryById(Long courseId){
|
|
@@ -1302,6 +1327,138 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
|
|
|
return vo;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> importEJ(List<CourseEJVo> ejVoList,String param) {
|
|
|
+ if (CollectionUtils.isEmpty(ejVoList)){
|
|
|
+ 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"));
|
|
|
+ CourseSubject courseSubject = iCourseSubjectService.getOneByName(importVo.getSubName(),projectType.getId());
|
|
|
+
|
|
|
+ //默认图片地址
|
|
|
+ String imagePath = "cos/images/tupain/1634097664410_1397766697";
|
|
|
+
|
|
|
+ //新增课程模块
|
|
|
+ CourseModule module = new CourseModule();
|
|
|
+ module.setPrefixName("2025");
|
|
|
+ module.setModuleName(importVo.getModelName());
|
|
|
+ module.setPublishStatus(1L);
|
|
|
+ module.setCreateTime(DateUtils.getNowTime());
|
|
|
+ module.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ module.setStatus(1);
|
|
|
+ module.setCode(ServletUtils.getEncoded("MK"));
|
|
|
+ module.setCommonSign(0);
|
|
|
+ module.setViewSign(2);
|
|
|
+ module.setCoverUrl(imagePath);
|
|
|
+ iCourseModuleService.save(module);
|
|
|
+
|
|
|
+ //模块业务层次
|
|
|
+ CourseModuleBusiness moduleBusiness = new CourseModuleBusiness();
|
|
|
+ moduleBusiness.setModuleId(module.getModuleId());
|
|
|
+ moduleBusiness.setEducationTypeId(educationType.getId());
|
|
|
+ moduleBusiness.setProjectId(projectType.getId());
|
|
|
+ moduleBusiness.setBusinessId(business.getId());
|
|
|
+ moduleBusiness.setSubjectId(courseSubject.getId());
|
|
|
+ iCourseModuleBusinessService.save(moduleBusiness);
|
|
|
+
|
|
|
+ //根据章节名称分组
|
|
|
+ Map<String, List<CourseEJVo>> map = ejVoList.stream().collect(Collectors.groupingBy(CourseEJVo::getChapterName));
|
|
|
+
|
|
|
+ // 使用 AtomicInteger 实现自增
|
|
|
+ AtomicInteger counter = new AtomicInteger(1);
|
|
|
+ map.forEach((k,v) -> {
|
|
|
+ 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(0);
|
|
|
+ chapter.setViewSign(2);
|
|
|
+ chapter.setCoverUrl(imagePath);
|
|
|
+ iCourseChapterService.save(chapter);
|
|
|
+
|
|
|
+ //章业务层
|
|
|
+ CourseChapterBusiness chapterBusiness = new CourseChapterBusiness();
|
|
|
+ chapterBusiness.setChapterId(chapter.getChapterId());
|
|
|
+ chapterBusiness.setEducationTypeId(educationType.getId());
|
|
|
+ chapterBusiness.setProjectId(projectType.getId());
|
|
|
+ chapterBusiness.setBusinessId(business.getId());
|
|
|
+ chapterBusiness.setSubjectId(courseSubject.getId());
|
|
|
+ iCourseChapterBusinessService.save(chapterBusiness);
|
|
|
+
|
|
|
+ //处理视频节
|
|
|
+ for (int i = 0; i < v.size(); i++) {
|
|
|
+ CourseEJVo vo = v.get(i);
|
|
|
+ if (vo.getType().equals("2")){
|
|
|
+ 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);
|
|
|
+
|
|
|
+ //节业务层
|
|
|
+ CourseSectionBusiness sectionBusiness = new CourseSectionBusiness();
|
|
|
+ sectionBusiness.setSectionId(section.getSectionId());
|
|
|
+ sectionBusiness.setEducationTypeId(educationType.getId());
|
|
|
+ sectionBusiness.setProjectId(projectType.getId());
|
|
|
+ sectionBusiness.setBusinessId(business.getId());
|
|
|
+ sectionBusiness.setSubjectId(courseSubject.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);
|