yangdamao 1 týždeň pred
rodič
commit
fc1aa4f401

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

@@ -12,7 +12,9 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.zhichen.common.exception.CustomException;
 import com.zhichen.common.type.EncryptHandler;
 import com.zhichen.common.utils.ServletUtils;
+import com.zhichen.common.utils.poi.EasyPoiUtil;
 import com.zhichen.framework.web.service.WxTokenService;
+import com.zhichen.modules.bank.vo.QuestionImageVo;
 import com.zhichen.modules.course.bo.*;
 import com.zhichen.modules.course.service.ICourseService;
 import com.zhichen.modules.course.vo.CourseVo;
@@ -45,6 +47,7 @@ import com.zhichen.common.utils.poi.ExcelUtil;
 import com.zhichen.common.core.page.TableDataInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.springframework.web.multipart.MultipartFile;
 
 /**
  * 课程Controller
@@ -270,4 +273,15 @@ public class CourseController extends BaseController {
         return AjaxResult.success(listVos);
     }
 
+
+    @ApiOperation("二建视频导入")
+    @PostMapping("/importEJ")
+    public AjaxResult<Map<String,Object>> importEJ(MultipartFile file,String param) throws Exception
+    {
+        List<CourseEJVo> questionList2 = EasyPoiUtil.importExcel(file,0,1,CourseEJVo.class);
+        Map<String,Object> result = iCourseService.importEJ(questionList2,param);
+        return AjaxResult.success(result);
+    }
+
+
 }

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

@@ -0,0 +1,38 @@
+package com.zhichen.modules.course.bo;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+
+/**
+ * 题库题目添加对象 question
+ *
+ * @author hjl
+ * @date 2021-10-22
+ */
+@Data
+public class CourseEJVo implements Serializable {
+
+    @Excel(name = "章节名称")
+    private String chapterName;
+
+    @Excel(name = "视频名称")
+    private String sectionName;
+
+    @Excel(name = "视频Key")
+    private String sectionKey;
+
+    @Excel(name = "视频时长")
+    private String sectionTime;
+
+    @Excel(name = "类型")
+    private String type;
+
+    @Excel(name = "级别")
+    private String level;
+
+}

+ 27 - 0
zhichen-system/src/main/java/com/zhichen/modules/course/bo/CourseJsonEJVo.java

@@ -0,0 +1,27 @@
+package com.zhichen.modules.course.bo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+
+/**
+ * 题库题目添加对象 question
+ *
+ * @author hjl
+ * @date 2021-10-22
+ */
+@Data
+public class CourseJsonEJVo implements Serializable {
+
+    private String eduName;
+
+    private String proName;
+
+    private String businessName;
+
+    private String subName;
+
+    private String modelName;
+
+}

+ 1 - 1
zhichen-system/src/main/java/com/zhichen/modules/course/domain/CourseChapter.java

@@ -53,7 +53,7 @@ private static final long serialVersionUID=1L;
     @TableField(exist = false)
     private Long oId;
     /** 公共标识:1公共章 0非公共章 */
-    private String commonSign;
+    private Integer commonSign;
 
     /** 视频标签:1保利威 2腾讯*/
     private Integer viewSign;

+ 1 - 1
zhichen-system/src/main/java/com/zhichen/modules/course/domain/CourseModule.java

@@ -62,7 +62,7 @@ private static final long serialVersionUID=1L;
     @TableField(updateStrategy=FieldStrategy.IGNORED)
     private Long certificateTpId;
     /** 公共标识:1公共章 0非公共章 */
-    private String commonSign;
+    private Integer commonSign;
     /** 视频标签:1保利威 2腾讯*/
     private Integer viewSign;
 }

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

@@ -114,4 +114,7 @@ public interface ICourseService extends IService<Course> {
     Map<String, String> getUserSkipPort(Long userId);
 
 	UserNewGoodsVo getOldGoodsRedirect(Long userId);
+
+    Map<String, Object> importEJ(List<CourseEJVo> questionList2,String param);
+
 }

+ 164 - 7
zhichen-system/src/main/java/com/zhichen/modules/course/service/impl/CourseServiceImpl.java

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