Pārlūkot izejas kodu

fix 合并导入

he2802 3 gadi atpakaļ
vecāks
revīzija
a841fa8aba

+ 9 - 0
zhongzheng-common/src/main/java/com/zhongzheng/common/utils/DateUtils.java

@@ -235,4 +235,13 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
         return retStr;
     }
 
+    public static Integer durationFormat(String duration) {
+        int index1=duration.indexOf(":");
+        int index2=duration.indexOf(":",index1+1);
+        int hh=Integer.parseInt(duration.substring(0,index1));
+        int mi=Integer.parseInt(duration.substring(index1+1,index2));
+        int ss=Integer.parseInt(duration.substring(index2+1));
+        return hh*60*60+mi*60+ss;
+    }
+
 }

+ 23 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseSectionServiceImpl.java

@@ -23,6 +23,8 @@ import com.zhongzheng.modules.course.mapper.CourseSectionMapper;
 import com.zhongzheng.modules.course.service.*;
 import com.zhongzheng.modules.course.vo.CourseSectionImport;
 import com.zhongzheng.modules.course.vo.CourseSectionVo;
+import com.zhongzheng.modules.polyv.service.IPolyvVideoService;
+import com.zhongzheng.modules.polyv.vo.PolyvVideoQuerVo;
 import com.zhongzheng.modules.system.domain.SysRoleMenu;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -73,6 +75,9 @@ public class CourseSectionServiceImpl extends ServiceImpl<CourseSectionMapper, C
     @Autowired
     private ICourseSubjectService iCourseSubjectService;
 
+    @Autowired
+    private IPolyvVideoService iPolyvVideoService;
+
     @Override
     public CourseSectionVo queryById(Long sectionId){
         CourseSection db = this.baseMapper.selectById(sectionId);
@@ -254,12 +259,15 @@ public class CourseSectionServiceImpl extends ServiceImpl<CourseSectionMapper, C
             bo.setImportBy(operName);
             bo.setImportNo(importNo);
             bo.setSectionType(sectionType);
-            bo.setDurationTime(sectionImport.getDurationTime());
+        //    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())){
                 if(sectionImport.getLiveStartTime().length()!=19){
                     errorLog+="第"+(size - Index)+"条:直播开始时间不对。\r\n";
@@ -284,6 +292,20 @@ public class CourseSectionServiceImpl extends ServiceImpl<CourseSectionMapper, C
                     continue;
                 }
             }
+            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 e){
+                    errorLog+="第"+(size - Index)+"条:读取保利威时长错误。\r\n";
+                    continue;
+                }
+            }
+            if(bo.getSectionType()==2){
+                bo.setDurationTime(bo.getLiveEndTime().longValue() - bo.getLiveStartTime().longValue());
+            }
             errorLog = insertByAddBoImport(bo,errorLog,(size - Index));
             i++;
 

+ 6 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/polyv/service/impl/PolyvVideoServiceImpl.java

@@ -2,6 +2,7 @@ package com.zhongzheng.modules.polyv.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.convert.Convert;
+import cn.hutool.core.lang.Validator;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.http.HttpStatus;
 import com.alibaba.fastjson.JSONArray;
@@ -401,7 +402,11 @@ public class PolyvVideoServiceImpl extends ServiceImpl<PolyvVideoMapper, PolyvVi
             polyvVideo.setUploaderRole(i.getUploader().getRole());
             polyvVideo.setCreateTime(DateUtils.getNowTime());
             polyvVideo.setUpdateTime(DateUtils.getNowTime());
-            this.save(polyvVideo);
+            if(Validator.isNotEmpty(polyvVideo.getDuration())){
+                //有时长才存入数据库
+                this.save(polyvVideo);
+            }
+
         });
     }
     @Override