yangdamao 1 ماه پیش
والد
کامیت
33cb4505ab

+ 8 - 0
zhichen-admin/src/main/java/com/zhichen/controller/course/CourseController.java

@@ -283,5 +283,13 @@ public class CourseController extends BaseController {
         return AjaxResult.success(result);
     }
 
+    @ApiOperation("七大员视频导入")
+    @PostMapping("/importQDY")
+    public AjaxResult<Map<String,Object>> importQDY(MultipartFile file,String param) throws Exception
+    {
+        List<CourseEJVo> questionList2 = EasyPoiUtil.importExcel(file,0,1,CourseEJVo.class);
+        Map<String,Object> result = iCourseService.importQDY(questionList2,param);
+        return AjaxResult.success(result);
+    }
 
 }

+ 1 - 1
zhichen-system/src/main/java/com/zhichen/modules/course/bo/CourseEJVo.java

@@ -26,7 +26,7 @@ public class CourseEJVo implements Serializable {
     @Excel(name = "视频Key")
     private String sectionKey;
 
-    @Excel(name = "视频时长")
+    @Excel(name = "时长")
     private String sectionTime;
 
     @Excel(name = "类型")

+ 2 - 0
zhichen-system/src/main/java/com/zhichen/modules/course/mapper/CourseSubjectMapper.java

@@ -43,4 +43,6 @@ public interface CourseSubjectMapper extends BaseMapper<CourseSubject> {
     List<CourseSubject> getListByIDs(@Param("ids") List<Long> ids);
 
     CourseSubject getOneByName(@Param("subjectName") String subjectName,@Param("proId") Long proId);
+
+    List<CourseSubject> listByProId(@Param("proId") Long proId);
 }

+ 1 - 0
zhichen-system/src/main/java/com/zhichen/modules/course/service/ICourseService.java

@@ -117,4 +117,5 @@ public interface ICourseService extends IService<Course> {
 
     Map<String, Object> importEJ(List<CourseEJVo> questionList2,String param);
 
+	Map<String, Object> importQDY(List<CourseEJVo> questionList2, String param);
 }

+ 2 - 0
zhichen-system/src/main/java/com/zhichen/modules/course/service/ICourseSubjectService.java

@@ -64,4 +64,6 @@ public interface ICourseSubjectService extends IService<CourseSubject> {
     List<CourseSubject> getListByIDs(List<Long> ids);
 
     CourseSubject getOneByName(String subjectName, Long id);
+
+	List<CourseSubject> listByProId(Long proId);
 }

+ 181 - 0
zhichen-system/src/main/java/com/zhichen/modules/course/service/impl/CourseServiceImpl.java

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

+ 6 - 0
zhichen-system/src/main/java/com/zhichen/modules/course/service/impl/CourseSubjectServiceImpl.java

@@ -23,6 +23,7 @@ import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -198,4 +199,9 @@ public class CourseSubjectServiceImpl extends ServiceImpl<CourseSubjectMapper, C
     public CourseSubject getOneByName(String subjectName, Long proId) {
         return baseMapper.getOneByName(subjectName,proId);
     }
+
+    @Override
+    public List<CourseSubject> listByProId(Long proId) {
+        return baseMapper.listByProId(proId);
+    }
 }

+ 5 - 1
zhichen-system/src/main/java/com/zhichen/modules/tencentcloud/service/impl/FaceOcrServiceImpl.java

@@ -61,6 +61,9 @@ public class FaceOcrServiceImpl implements IFaceOcrService {
     @Value("${aliyun.oss.endpoint}")
     private String ossHost;
 
+    @Value("${tengxun.cos.endpoint}")
+    private String cosHost;
+
     @Autowired
     private OssService ossService;
 
@@ -246,7 +249,8 @@ public class FaceOcrServiceImpl implements IFaceOcrService {
             IaiClient iaiClient = new IaiClient(cred,"ap-guangzhou");
             DetectFaceRequest faceRequest = new DetectFaceRequest();
             if(Validator.isNotEmpty(bo.getUrlA())){
-                faceRequest.setUrl(ossHost+"/"+bo.getUrlA());
+//                faceRequest.setUrl(ossHost+"/"+bo.getUrlA());
+                faceRequest.setUrl(cosHost+"/"+bo.getUrlA());
             }else{
                 faceRequest.setImage(bo.getImageA()); //学习拍照
             }

+ 11 - 0
zhichen-system/src/main/resources/mapper/modules/course/CourseSubjectMapper.xml

@@ -177,4 +177,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
           AND cs.`status` = 1
             LIMIT 1
     </select>
+
+    <select id="listByProId"  resultType="com.zhichen.modules.course.domain.CourseSubject">
+        SELECT
+            cs.*
+        FROM
+            course_subject cs
+                LEFT JOIN course_subject_project csp ON cs.id = csp.subject_id
+        WHERE
+            csp.project_id = #{proId}
+          AND cs.`status` = 1
+    </select>
 </mapper>