فهرست منبع

fix 导入模块章节

he2802 3 سال پیش
والد
کامیت
9fe6e9843f

+ 34 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/controller/course/CourseModuleController.java

@@ -1,16 +1,28 @@
 package com.zhongzheng.controller.course;
 
+import java.util.Collections;
 import java.util.List;
 import java.util.Arrays;
+import java.util.Map;
 
+import com.alibaba.fastjson.JSON;
+import com.zhongzheng.common.core.domain.model.LoginUser;
+import com.zhongzheng.common.utils.ServletUtils;
+import com.zhongzheng.common.utils.poi.EasyPoiUtil;
+import com.zhongzheng.framework.web.service.TokenService;
+import com.zhongzheng.modules.bank.vo.QuestionImportV2;
 import com.zhongzheng.modules.course.bo.CourseModuleAddBo;
 import com.zhongzheng.modules.course.bo.CourseModuleEditBo;
 import com.zhongzheng.modules.course.bo.CourseModuleQueryBo;
+import com.zhongzheng.modules.course.bo.CourseSectionBusinessAddBo;
 import com.zhongzheng.modules.course.domain.CourseChapterBusiness;
 import com.zhongzheng.modules.course.domain.CourseModuleBusiness;
 import com.zhongzheng.modules.course.service.ICourseModuleBusinessService;
 import com.zhongzheng.modules.course.service.ICourseModuleService;
+import com.zhongzheng.modules.course.service.ICourseSectionService;
+import com.zhongzheng.modules.course.vo.CourseChapterSectionImport;
 import com.zhongzheng.modules.course.vo.CourseModuleVo;
+import com.zhongzheng.modules.course.vo.CourseSectionImport;
 import lombok.RequiredArgsConstructor;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -30,6 +42,7 @@ import com.zhongzheng.common.utils.poi.ExcelUtil;
 import com.zhongzheng.common.core.page.TableDataInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.springframework.web.multipart.MultipartFile;
 
 /**
  * 课程模块Controller
@@ -47,6 +60,11 @@ public class CourseModuleController extends BaseController {
 
     private final ICourseModuleBusinessService iCourseModuleBusinessService;
 
+    private final TokenService tokenService;
+
+    private final ICourseSectionService iCourseSectionService;
+
+
     /**
      * 查询课程模块列表
      */
@@ -125,4 +143,20 @@ public class CourseModuleController extends BaseController {
         List<CourseModuleBusiness> list = iCourseModuleBusinessService.getListById(moduleId);
         return AjaxResult.success(list);
     }
+
+    @ApiOperation("导入章节模板")
+    @Log(title = "导入节模板", businessType = BusinessType.IMPORT)
+    @PreAuthorize("@ss.hasPermi('system:section:import')")
+    @PostMapping("/importData")
+    public AjaxResult<Map<String,Object>> importData(MultipartFile file,String businessJson) throws Exception
+    {
+        List<CourseSectionBusinessAddBo> businessList = JSON.parseArray(businessJson, CourseSectionBusinessAddBo.class);
+        List<CourseChapterSectionImport> sectionList = EasyPoiUtil.importExcel(file,0,2,CourseChapterSectionImport.class);
+        Collections.reverse(sectionList);
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        String operName = loginUser.getUsername();
+        Map<String,Object> message = iCourseSectionService.importChapterSection(sectionList, businessList, operName);
+
+        return AjaxResult.success(message);
+    }
 }

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CourseChapterAddBo.java

@@ -50,4 +50,7 @@ public class CourseChapterAddBo {
     private List<CourseChapterBusinessAddBo> businessList;
     @ApiModelProperty("节id列表")
     private List<CourseChapterSectionListAddBo> sectionIdList;
+    /** 导入编号 */
+    @ApiModelProperty("导入编号")
+    private String importNo;
 }

+ 3 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CourseChapterEditBo.java

@@ -61,5 +61,7 @@ public class CourseChapterEditBo {
     private List<CourseChapterBusinessAddBo> businessList;
     @ApiModelProperty("节id列表")
     private List<CourseChapterSectionListAddBo> sectionIdList;
-
+    /** 导入编号 */
+    @ApiModelProperty("导入编号")
+    private String importNo;
 }

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CourseChapterQueryBo.java

@@ -71,4 +71,8 @@ public class CourseChapterQueryBo extends BaseEntity {
 	private Long subjectId;
 
 	private List<Long> chapterIds;
+
+	/** 导入编号 */
+	@ApiModelProperty("导入编号")
+	private String importNo;
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/domain/CourseChapter.java

@@ -46,4 +46,6 @@ private static final long serialVersionUID=1L;
     private Long publishStatus;
     /** 编码 */
     private String code;
+    /** 导入编号 */
+    private String importNo;
 }

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/ICourseSectionService.java

@@ -4,9 +4,11 @@ package com.zhongzheng.modules.course.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.zhongzheng.modules.bank.vo.QuestionImport;
 import com.zhongzheng.modules.course.bo.CourseSectionAddBo;
+import com.zhongzheng.modules.course.bo.CourseSectionBusinessAddBo;
 import com.zhongzheng.modules.course.bo.CourseSectionEditBo;
 import com.zhongzheng.modules.course.bo.CourseSectionQueryBo;
 import com.zhongzheng.modules.course.domain.CourseSection;
+import com.zhongzheng.modules.course.vo.CourseChapterSectionImport;
 import com.zhongzheng.modules.course.vo.CourseSectionImport;
 import com.zhongzheng.modules.course.vo.CourseSectionVo;
 import net.polyv.live.v1.entity.chat.LiveGetMessageListResponse;
@@ -65,6 +67,8 @@ public interface ICourseSectionService extends IService<CourseSection> {
 
 	Map<String,Object> importSection(List<CourseSectionImport> sectionList, Boolean isUpdateSupport, String operName) throws ParseException;
 
+	Map<String,Object> importChapterSection(List<CourseChapterSectionImport> sectionList, List<CourseSectionBusinessAddBo> businessList, String operName) throws ParseException;
+
 	List<CourseSectionVo> overSectionList(Long startTime,Long endTime);
 
 	List<CourseSectionVo> livingSectionList(Long userId);

+ 0 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseChapterServiceImpl.java

@@ -94,7 +94,6 @@ public class CourseChapterServiceImpl extends ServiceImpl<CourseChapterMapper, C
     }
 
     @Override
-    @Transactional(rollbackFor = Exception.class)
     public Long insertByAddBo(CourseChapterAddBo bo) {
         CourseChapter add = BeanUtil.toBean(bo, CourseChapter.class);
         add.setCode(ServletUtils.getEncoded("Z"));

+ 139 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseSectionServiceImpl.java

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

+ 36 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/vo/CourseChapterSectionImport.java

@@ -0,0 +1,36 @@
+package com.zhongzheng.modules.course.vo;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import cn.afterturn.easypoi.excel.annotation.ExcelCollection;
+import com.zhongzheng.modules.course.bo.CourseSectionBusinessAddBo;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+import java.util.List;
+
+
+/**
+ * 课程小节添加对象 course_section
+ *
+ * @author hjl
+ * @date 2021-10-11
+ */
+@Data
+@NoArgsConstructor
+@Accessors(chain = true)
+public class CourseChapterSectionImport {
+
+    private static final long serialVersionUID = 1L;
+
+    @Excel(name = "*章标题")
+    @ApiModelProperty("章标题")
+    private String chapterName;
+    /** 前缀名称 */
+    @Excel(name = "章标题前缀")
+    @ApiModelProperty("章标题前缀")
+    private String chapterPrefixName;
+    @ExcelCollection(name = "节数据")
+   private List<CourseSectionEasyImport> sectionList;
+}

+ 4 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/vo/CourseChapterVo.java

@@ -77,5 +77,8 @@ public class CourseChapterVo {
 	@ApiModelProperty("修改时间")
 	@Excel(name = "修改时间")
 	private Long updateTime;
-
+	/** 导入编号 */
+	@Excel(name = "导入编号")
+	@ApiModelProperty("导入编号")
+	private String importNo;
 }

+ 85 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/vo/CourseSectionEasyImport.java

@@ -0,0 +1,85 @@
+package com.zhongzheng.modules.course.vo;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import com.zhongzheng.modules.course.bo.CourseSectionBusinessAddBo;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+import java.util.Date;
+import java.util.List;
+
+
+/**
+ * 课程小节添加对象 course_section
+ *
+ * @author hjl
+ * @date 2021-10-11
+ */
+@Data
+@NoArgsConstructor
+@Accessors(chain = true)
+public class CourseSectionEasyImport {
+
+    private static final long serialVersionUID = 1L;
+
+    /** 名称 */
+    @Excel(name = "*节标题")
+    @ApiModelProperty("名称")
+    private String name;
+    /** 前缀名称 */
+    @Excel(name = "节标题前缀")
+    @ApiModelProperty("前缀名称")
+    private String prefixName;
+    /** 教育类型ID */
+    @Excel(name = "教育类型")
+    private String educationType;
+    /** 项目ID */
+    @Excel(name = "项目类型")
+    private String project;
+    /** 业务层次id */
+    @Excel(name = "业务层次")
+    private String business;
+    /** 科目id */
+    @Excel(name = "科目")
+    private String subject;
+    /** 节类型 1录播 2直播 3回放 */
+    @Excel(name = "节类型")
+    @ApiModelProperty("节类型 1录播 2直播 3回放")
+    private String sectionType;
+    /** 发布状态 1发布 0未发布 */
+    @Excel(name = "*节发布状态")
+    private String publishStatus;
+    /** 直播流地址 */
+    @Excel(name = "直播地址")
+    @ApiModelProperty("直播流地址")
+    private String liveUrl;
+    /** 直播开始时间 */
+    @Excel(name = "直播开始时间",databaseFormat="yyyy/MM/dd HH:mm:ss")
+    @ApiModelProperty("直播开始时间")
+    private Date liveStartTime;
+    /** 直播结束时间 */
+    @Excel(name = "直播结束时间",databaseFormat="yyyy/MM/dd HH:mm:ss")
+    @ApiModelProperty("直播结束时间")
+    private Date liveEndTime;
+    /** 录播和回放的url地址 */
+    @Excel(name = "URL地址")
+    @ApiModelProperty("录播和回放的url地址")
+    private String recordingUrl;
+    /** 节时长(分钟) */
+    @Excel(name = "节时长")
+    @ApiModelProperty("节时长(分钟)")
+    private Long durationTime;
+
+
+    private Long educationTypeId;
+
+    private Long businessId;
+
+    private Long subjectId;
+
+    private Long projectId;
+
+    private List<CourseSectionBusinessAddBo> businessList;
+}

+ 5 - 0
zhongzheng-system/src/main/resources/mapper/modules/course/CourseChapterMapper.xml

@@ -15,6 +15,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="coverUrl" column="cover_url"/>
         <result property="publishStatus" column="publish_status"/>
         <result property="code" column="code"/>
+        <result property="importNo" column="import_no"/>
     </resultMap>
 
     <resultMap type="com.zhongzheng.modules.course.vo.CourseChapterVo" id="CourseChapterResultVo">
@@ -30,6 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="durationTime" column="duration_time"/>
         <result property="createTime" column="create_time"/>
         <result property="updateTime" column="update_time"/>
+        <result property="importNo" column="import_no"/>
         <collection property="businessList" column="chapter_id" select="findBusinessList"/>
         <collection property="moduleList" column="chapter_id" select="findModuleList"/>
         <collection property="courseList" column="chapter_id" select="findCourseList"/>
@@ -143,6 +145,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="businessId != null and businessId != ''">
             AND ccb.business_id = #{businessId}
         </if>
+        <if test="importNo != null and importNo != ''">
+            AND c.import_no = #{importNo}
+        </if>
         <if test="name != null and name != ''">
             AND c.name like concat('%', #{name}, '%')
         </if>

+ 1 - 1
zhongzheng-system/src/main/resources/mapper/modules/order/OrderBusinessConfigGoodsMapper.xml

@@ -48,7 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
              goods g
                  LEFT JOIN major m ON g.major_id = m.id and m.`status` = 1
         WHERE
-            FIND_IN_SET( g.goods_id,#{goods_ids} ) GROUP BY g.goods_id
+            FIND_IN_SET( g.goods_id,#{goods_ids} ) and g.`status` =1 and g.goods_status=1 GROUP BY g.goods_id
     </select>