|
@@ -92,6 +92,9 @@ public class CourseSectionServiceImpl extends ServiceImpl<CourseSectionMapper, C
|
|
|
@Autowired
|
|
|
private ICourseModuleChapterService iCourseModuleChapterService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ICourseChapterService iCourseChapterService;
|
|
|
+
|
|
|
@Override
|
|
|
public CourseSectionVo queryById(Long sectionId){
|
|
|
CourseSection db = this.baseMapper.selectById(sectionId);
|
|
@@ -372,6 +375,142 @@ public class CourseSectionServiceImpl extends ServiceImpl<CourseSectionMapper, C
|
|
|
return rs;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> importChapterSection(List<CourseChapterSectionImport> sectionList,List<CourseSectionBusinessAddBo> businessList, String operName) throws ParseException {
|
|
|
+ if (Validator.isNull(sectionList) || sectionList.size() == 0) {
|
|
|
+ throw new CustomException("导入数据不能为空!");
|
|
|
+ }
|
|
|
+ String errorLog = "";
|
|
|
+ String importNo = ServletUtils.getEncoded("IMPORT");
|
|
|
+ int i=10;
|
|
|
+ int Index = 0;
|
|
|
+ int total = 0; //节的总数
|
|
|
+ Map<String,List<CourseChapterSectionImport>> map = new HashMap();
|
|
|
+ for (CourseChapterSectionImport sectionImport : sectionList) {
|
|
|
+ if(Validator.isEmpty(sectionImport.getChapterName())){
|
|
|
+ // errorLog+="第"+ (Index)+"条:"+"节标题空白。\r\n";
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(sectionImport.getChapterName().startsWith("说明:")){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(map.containsKey(sectionImport.getChapterName())){
|
|
|
+ Collections.reverse(sectionImport.getSectionList());
|
|
|
+ List<CourseChapterSectionImport> list = map.get(sectionImport.getChapterName());
|
|
|
+ list.add(sectionImport);
|
|
|
+ total+=sectionImport.getSectionList().size();
|
|
|
+ }else{
|
|
|
+ Collections.reverse(sectionImport.getSectionList());
|
|
|
+ List<CourseChapterSectionImport> list = new ArrayList<>();
|
|
|
+ list.add(sectionImport);
|
|
|
+ map.put(sectionImport.getChapterName(),list);
|
|
|
+ total+=sectionImport.getSectionList().size();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ i=10;
|
|
|
+ Index = 0;
|
|
|
+ int size = total+1;
|
|
|
+ Iterator<Map.Entry<String, List<CourseChapterSectionImport>>> it = map.entrySet().iterator();
|
|
|
+ List<CourseChapterBusinessAddBo> chapterBusinessList = new ArrayList<>();//章绑定的业务层次列表
|
|
|
+ //模块业务层次同步到章节
|
|
|
+ for(CourseSectionBusinessAddBo businessAddBo :businessList){
|
|
|
+ CourseChapterBusinessAddBo addBo = BeanUtil.toBean(businessAddBo, CourseChapterBusinessAddBo.class);
|
|
|
+ chapterBusinessList.add(addBo);
|
|
|
+ }
|
|
|
+ while (it.hasNext()) {
|
|
|
+ Map.Entry e = it.next();
|
|
|
+ System.out.println("testHashMap===>Key: " + e.getKey() + "; Value: " + e.getValue());
|
|
|
+ List<CourseChapterSectionImport> list = (List<CourseChapterSectionImport>)e.getValue();
|
|
|
+ for(CourseChapterSectionImport item : list){
|
|
|
+ List<CourseChapterSectionListAddBo> sectionIdList = new ArrayList<>();//章绑定的节列表
|
|
|
+ String chapterName = item.getChapterName();//章标题
|
|
|
+ String chapterPrefixName = item.getChapterPrefixName();//章前缀
|
|
|
+ int sortIndex = item.getSectionList().size();
|
|
|
+ for(CourseSectionEasyImport sectionImport : item.getSectionList()){
|
|
|
+ Index++;
|
|
|
+ CourseSectionAddBo bo = new CourseSectionAddBo();
|
|
|
+ if(!Validator.isNotEmpty(sectionImport.getName())){
|
|
|
+ errorLog+="第"+ (size - Index)+"条:"+"节标题空白。\r\n";
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!Validator.isNotEmpty(sectionImport.getPublishStatus())){
|
|
|
+ errorLog+="第"+(size - Index)+"条:"+"发布状态空白。\r\n";
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(!sectionImport.getPublishStatus().equals("发布")&&!sectionImport.getPublishStatus().equals("未发布")){
|
|
|
+ errorLog+="第"+(size - Index)+"条:"+"发布状态错误。\r\n";
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ Integer sectionType = findType(sectionImport.getSectionType());
|
|
|
+ if(!Validator.isNotEmpty(sectionType)&&Validator.isNotEmpty(sectionImport.getSectionType())){
|
|
|
+ errorLog+="第"+(size - Index)+"条:"+sectionImport.getSectionType()+"-该节类型不存在。\r\n";
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ bo.setPrefixName(sectionImport.getPrefixName());
|
|
|
+ bo.setName(sectionImport.getName());
|
|
|
+ bo.setName(sectionImport.getName());
|
|
|
+ bo.setBusinessList(businessList);
|
|
|
+ bo.setImportBy(operName);
|
|
|
+ bo.setImportNo(importNo);
|
|
|
+ bo.setSectionType(sectionType);
|
|
|
+ // bo.setDurationTime(sectionImport.getDurationTime());
|
|
|
+ bo.setRecordingUrl(sectionImport.getRecordingUrl());
|
|
|
+ bo.setLiveUrl(sectionImport.getLiveUrl());
|
|
|
+ bo.setPublishStatus(sectionImport.getPublishStatus().equals("发布")?1:0);
|
|
|
+ bo.setStatus(1);
|
|
|
+ bo.setCoverUrl("oss/images/avatar/20211013/1634097664410_1397766697");
|
|
|
+
|
|
|
+ if(Validator.isNotEmpty(sectionImport.getLiveStartTime())){
|
|
|
+ bo.setLiveStartTime(Convert.toLong(sectionImport.getLiveStartTime().getTime())/1000);
|
|
|
+ }
|
|
|
+ if(Validator.isNotEmpty(sectionImport.getLiveEndTime())){
|
|
|
+ bo.setLiveEndTime(Convert.toLong(sectionImport.getLiveEndTime().getTime())/1000);
|
|
|
+ }
|
|
|
+ if(bo.getSectionType()==1){
|
|
|
+ try{
|
|
|
+ PolyvVideoQuerVo poly = iPolyvVideoService.queryById(bo.getRecordingUrl());
|
|
|
+ if(Validator.isNotEmpty(poly)){
|
|
|
+ bo.setDurationTime(new Long(DateUtils.durationFormat(poly.getDuration())));
|
|
|
+ }
|
|
|
+ }catch (Exception e2){
|
|
|
+ errorLog+="第"+(size - Index)+"条:读取保利威时长错误。\r\n";
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(bo.getSectionType()==2){
|
|
|
+ bo.setDurationTime(bo.getLiveEndTime().longValue() - bo.getLiveStartTime().longValue());
|
|
|
+ }
|
|
|
+ Long sectionId = insertByAddBo(bo); //导入节ID
|
|
|
+ if(sectionId.longValue()>0){
|
|
|
+ CourseChapterSectionListAddBo addBo = new CourseChapterSectionListAddBo();
|
|
|
+ addBo.setSectionId(sectionId);
|
|
|
+ addBo.setSort(new Long(sortIndex));
|
|
|
+ sectionIdList.add(addBo);
|
|
|
+ }
|
|
|
+ i++;
|
|
|
+ sortIndex--;
|
|
|
+ }
|
|
|
+ CourseChapterAddBo courseChapterAddBo = new CourseChapterAddBo();
|
|
|
+ courseChapterAddBo.setPrefixName(chapterPrefixName);
|
|
|
+ courseChapterAddBo.setName(chapterName);
|
|
|
+ courseChapterAddBo.setImportNo(importNo);
|
|
|
+ courseChapterAddBo.setPublishStatus(1L);
|
|
|
+ courseChapterAddBo.setStatus(1);
|
|
|
+ courseChapterAddBo.setCoverUrl("oss/images/avatar/20211013/1634097664410_1397766697");
|
|
|
+ courseChapterAddBo.setSectionIdList(sectionIdList);
|
|
|
+ courseChapterAddBo.setBusinessList(chapterBusinessList);
|
|
|
+ iCourseChapterService.insertByAddBo(courseChapterAddBo);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ Map<String,Object> rs = new HashMap();
|
|
|
+ rs.put("errorLog",errorLog);
|
|
|
+ rs.put("importNo",importNo);
|
|
|
+ return rs;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<CourseSectionVo> overSectionList(Long startTime, Long endTime) {
|
|
|
return this.baseMapper.overSectionList(startTime,endTime);
|