yangdamao 6 hónapja
szülő
commit
c48d98a5c3

+ 14 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/controller/goods/GoodsController.java

@@ -412,6 +412,20 @@ public class GoodsController extends BaseController {
         return toAjax(iGoodsService.updateRecordUrl(boList,goodsId) ? 1 : 0);
     }
 
+
+    /**
+     * 视频节导入
+     */
+    @ApiOperation("视频节导入")
+    @PostMapping("/section/export")
+    public AjaxResult<Void> sectionExport(MultipartFile file,String json) {
+        List<SectionExportBo> boList = EasyPoiUtil.importExcel(file,0,1,SectionExportBo.class);
+        if (CollectionUtils.isEmpty(boList)){
+            throw new CustomException("导入文件格式不正确或文件为空,请检查文件!");
+        }
+        return toAjax(iGoodsService.sectionExport(boList,json) ? 1 : 0);
+    }
+
     /**
      * 二建商品更换腾讯
      */

+ 24 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/bo/SectionExportBo.java

@@ -0,0 +1,24 @@
+package com.zhongzheng.modules.goods.bo;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author yangdamao
+ * @date 2024年06月04日 15:00
+ */
+@Data
+public class SectionExportBo implements Serializable {
+
+    @Excel(name = "视频名称")
+    private String sectionName;
+
+    @Excel(name = "视频Id")
+    private String sectionUrl;
+
+    @Excel(name = "章节名称")
+    private String chapterName;
+
+}

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/IGoodsService.java

@@ -177,4 +177,6 @@ public interface IGoodsService extends IService<Goods> {
     boolean updateRecordUrl(List<SectionImportBo> boList, String goodsId);
 
 	boolean updateGoodsVideo(UpdateGoodsVideoBo bo);
+
+	boolean sectionExport(List<SectionExportBo> boList,String json);
 }

+ 116 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/impl/GoodsServiceImpl.java

@@ -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);
     }