Browse Source

Merge branch 'V2.0.1' into test

# Conflicts:
#	jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java
zhaoxian 3 years ago
parent
commit
93c97b6265
13 changed files with 1492 additions and 2 deletions
  1. 2 0
      jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java
  2. 5 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/mapper/TagInfoMapper.java
  3. 15 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/mapper/xml/TagInfoMapper.xml
  4. 3 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/ITagInfoService.java
  5. 9 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/impl/TagInfoServiceImpl.java
  6. 56 2
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/utils/ExportExcelUtils.java
  7. 191 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/utils/ExternalMaterialCollection.java
  8. 49 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/utils/LoadFileUtil.java
  9. 406 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/fileupload/controller/ExternalMaterialCollectionController.java
  10. 35 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/fileupload/mapper/ExternalMaterialCollectionMapper.java
  11. 209 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/fileupload/mapper/xml/ExternalMaterialCollectionMapper.xml
  12. 41 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/fileupload/service/IExternalMaterialCollectionService.java
  13. 471 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/fileupload/service/impl/ExternalMaterialCollectionServiceImpl.java

+ 2 - 0
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java

@@ -244,6 +244,8 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/audienceReport/**", "anon");
         filterChainDefinitionMap.put("/stare/**", "anon");
         filterChainDefinitionMap.put("/boss/**", "anon");
+        filterChainDefinitionMap.put("/external/materialCollection/*", "anon");
+
         // 添加自己的过滤器并且取名为jwt
         Map<String, Filter> filterMap = new HashMap<>(1);
         filterMap.put("jwt", new JwtFilter());

+ 5 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/mapper/TagInfoMapper.java

@@ -1,7 +1,11 @@
 package cn.com.ctop.common.module.mapper;
 
 import cn.com.ctop.common.module.entity.TagInfo;
+import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * 标签信息
@@ -11,4 +15,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface TagInfoMapper extends BaseMapper<TagInfo> {
 
+    List<TagInfo> getListByCode(@Param("array")  JSONArray array);
 }

+ 15 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/mapper/xml/TagInfoMapper.xml

@@ -2,4 +2,19 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.ctop.common.module.mapper.TagInfoMapper">
 
+    <select id="getListByCode" resultType="cn.com.ctop.common.module.entity.TagInfo">
+        SELECT
+        id,
+        tag_name,
+        parent_id,
+        tag_code,
+        description
+        FROM  ctop_tag_info
+        WHERE tag_code IN
+        <foreach collection="array" item="item" separator=","
+                 open="(" close=")">
+            #{item}
+        </foreach>
+    </select>
+
 </mapper>

+ 3 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/ITagInfoService.java

@@ -2,6 +2,7 @@ package cn.com.ctop.common.module.service;
 
 import cn.com.ctop.common.module.entity.TagInfo;
 import cn.com.ctop.common.module.model.TagInfoTreeModel;
+import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 import java.util.List;
@@ -19,4 +20,6 @@ public interface ITagInfoService extends IService<TagInfo> {
     TagInfo getByTagCode(String tagCode);
 
     List<TagInfo> getByParentId(Long id);
+
+    List<TagInfo> getListByCode(JSONArray array);
 }

+ 9 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/impl/TagInfoServiceImpl.java

@@ -5,8 +5,10 @@ import cn.com.ctop.common.module.mapper.TagInfoMapper;
 import cn.com.ctop.common.module.model.TagInfoTreeModel;
 import cn.com.ctop.common.module.service.ITagInfoService;
 import cn.com.ctop.common.module.utils.FindstagInfosChildrenUtil;
+import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
@@ -20,6 +22,8 @@ import java.util.List;
 @Service
 public class TagInfoServiceImpl extends ServiceImpl<TagInfoMapper, TagInfo> implements ITagInfoService {
 
+    @Autowired
+    private TagInfoMapper mapper;
     /**
      * queryTreeList 对应 queryTreeList 查询所有的部门数据,以树结构形式响应给前端
      */
@@ -54,4 +58,9 @@ public class TagInfoServiceImpl extends ServiceImpl<TagInfoMapper, TagInfo> impl
         queryWrapper.orderByAsc("tag_order");
         return this.list(queryWrapper);
     }
+
+    @Override
+    public List<TagInfo> getListByCode(JSONArray array) {
+        return mapper.getListByCode(array);
+    }
 }

+ 56 - 2
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/utils/ExportExcelUtils.java

@@ -3,8 +3,19 @@ package cn.com.ctop.common.module.utils;
 
 import org.apache.poi.hssf.usermodel.HSSFCell;
 import org.apache.poi.hssf.usermodel.HSSFDateUtil;
-import org.apache.poi.ss.usermodel.*;
-import org.apache.poi.xssf.usermodel.*;
+import org.apache.poi.ss.usermodel.BorderStyle;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.FillPatternType;
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
+import org.apache.poi.ss.usermodel.IndexedColors;
+import org.apache.poi.ss.usermodel.VerticalAlignment;
+import org.apache.poi.xssf.usermodel.XSSFCell;
+import org.apache.poi.xssf.usermodel.XSSFCellStyle;
+import org.apache.poi.xssf.usermodel.XSSFFont;
+import org.apache.poi.xssf.usermodel.XSSFRichTextString;
+import org.apache.poi.xssf.usermodel.XSSFRow;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.UnsupportedEncodingException;
@@ -328,4 +339,47 @@ public class ExportExcelUtils {
         }
         return value.trim();
     }
+
+    public void putHeaders(XSSFWorkbook workbook, int sheetNum, String sheetTitle, String[] headers) {
+        // 生成一个表格
+        XSSFSheet sheet = workbook.createSheet();
+        workbook.setSheetName(sheetNum, sheetTitle);
+        // 设置表格默认列宽度为20个字节
+        sheet.setDefaultColumnWidth((short) 30);
+        // 生成一个样式
+        XSSFCellStyle style = workbook.createCellStyle();
+        // 设置这些样式
+        style.setFillForegroundColor(IndexedColors.PALE_BLUE.index);
+        style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+        style.setBorderBottom(BorderStyle.THIN);
+        style.setBorderLeft(BorderStyle.THIN);
+        style.setBorderRight(BorderStyle.THIN);
+        style.setBorderTop(BorderStyle.THIN);
+        // style.setAlignment(HorizontalAlignment.CENTER);
+        style.setAlignment(HorizontalAlignment.CENTER);
+        style.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中
+        // 生成一个字体
+        XSSFFont font = workbook.createFont();
+        font.setColor(IndexedColors.BLACK.index);
+        font.setFontHeightInPoints((short) 12);
+        //加粗
+        font.setBold(true);
+        // 把字体应用到当前的样式
+        style.setFont(font);
+
+        // 指定当单元格内容显示不下时自动换行
+        style.setWrapText(true);
+        //记录样式(标黄)
+//        style.setFillForegroundColor(IndexedColors.LIGHT_YELLOW.index);
+
+        // 产生表格标题行
+        XSSFRow row = sheet.createRow(0);
+        for (int i = 0; i < headers.length; i++) {
+            XSSFCell cell = row.createCell((short) i);
+            cell.setCellStyle(style);
+            XSSFRichTextString text = new XSSFRichTextString(headers[i]);
+            cell.setCellValue(text.toString());
+        }
+    }
+
 }

+ 191 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/utils/ExternalMaterialCollection.java

@@ -0,0 +1,191 @@
+package cn.com.ctop.common.module.utils;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+ * 外部素材集信息表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2022-01-12
+ */
+@Data
+@TableName("ctop_external_material_collection")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_external_material_collection对象", description = "外部素材集信息表")
+public class ExternalMaterialCollection {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 创建人id
+     */
+    @Excel(name = "创建人id", width = 15)
+    @ApiModelProperty(value = "创建人id")
+    private String userId;
+    /**
+     * 媒体类型 1头条,2快手
+     */
+    @Excel(name = "媒体类型 1头条,2快手", width = 15)
+    @ApiModelProperty(value = "媒体类型 1头条,2快手")
+    private Integer mediaType;
+    /**
+     * 创建形式:1视频、2链接
+     */
+    @Excel(name = "创建形式:1视频、2链接,3导入,4同步内部", width = 15)
+    @ApiModelProperty(value = "创建形式:1视频、2链接,3导入,4同步内部")
+    private Integer createType;
+    /**
+     * 素材唯一标识
+     */
+    @Excel(name = "素材唯一标识", width = 15)
+    @ApiModelProperty(value = "素材唯一标识")
+    private String md5;
+    /**
+     * url
+     */
+    @Excel(name = "url", width = 15)
+    @ApiModelProperty(value = "url")
+    private String url;
+
+    /**
+     * 外部 url
+     */
+    @Excel(name = "externalUrl", width = 15)
+    @ApiModelProperty(value = "externalUrl")
+    private String externalUrl;
+    /**
+     * coverUrl
+     */
+    @Excel(name = "coverUrl", width = 15)
+    @ApiModelProperty(value = "coverUrl")
+    private String coverUrl;
+    /**
+     * 创建时间
+     */
+    private String statDate;
+    /**
+     * 素材来源
+     */
+    @Excel(name = "素材来源", width = 15)
+    @ApiModelProperty(value = "素材来源")
+    private String materialSource;
+    /**
+     * 行业标签
+     */
+    @Excel(name = "行业", width = 15)
+    @ApiModelProperty(value = "行业")
+    private String industry;
+
+    /**
+     * 产品
+     */
+    @Excel(name = "产品", width = 15)
+    @ApiModelProperty(value = "产品")
+    private String product;
+    /**
+     * 形式标签 modalityTagList::1
+     */
+    @Excel(name = "形式标签", width = 15)
+    @ApiModelProperty(value = "形式标签")
+    private String modalityTag;
+    /**
+     * 场景标签 senceTagList 4
+     */
+    @Excel(name = "场景标签", width = 15)
+    @ApiModelProperty(value = "场景标签")
+    private String sceneTag;
+    /**
+     * 基调标签 daTagList:2
+     */
+    @Excel(name = "基调标签", width = 15)
+    @ApiModelProperty(value = "基调标签")
+    private String daTag;
+    /**
+     * 版位
+     */
+    @Excel(name = "版位", width = 15)
+    @ApiModelProperty(value = "版位")
+    private String platePosition;
+    /**
+     * 素材描述
+     */
+    @Excel(name = "素材描述", width = 15)
+    @ApiModelProperty(value = "素材描述")
+    private String materialDescribe;
+    /**
+     * 素材名称
+     */
+    @Excel(name = "素材名称", width = 15)
+    @ApiModelProperty(value = "素材名称")
+    private String materialName;
+    /**
+     * 视频秒数
+     */
+    @Excel(name = "视频秒数", width = 15)
+    @ApiModelProperty(value = "视频秒数")
+    private Long second;
+    /**
+     * 格式
+     */
+    @Excel(name = "格式", width = 15)
+    @ApiModelProperty(value = "格式")
+    private String format;
+    /**
+     * 宽度
+     */
+    @Excel(name = "宽度", width = 15)
+    @ApiModelProperty(value = "宽度")
+    private String width;
+    /**
+     * 高度
+     */
+    @Excel(name = "高度", width = 15)
+    @ApiModelProperty(value = "高度")
+    private String height;
+    /**
+     * 大小
+     */
+    @Excel(name = "大小", width = 15)
+    @ApiModelProperty(value = "大小")
+    private String size;
+    /**
+     * createTime
+     */
+    @Excel(name = "createTime", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "createTime")
+    private Date createTime;
+    /**
+     * updateTime
+     */
+    @Excel(name = "updateTime", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "updateTime")
+    private Date updateTime;
+
+    @TableField(exist = false)
+    private String startTime;
+    @TableField(exist = false)
+    private String endTime;
+}

+ 49 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/utils/LoadFileUtil.java

@@ -60,6 +60,55 @@ public class LoadFileUtil {
 
     }
 
+    /**
+     * 上传文件
+     *
+     * @param urlStr
+     * @param savePath
+     * @return
+     * @throws IOException
+     */
+    public static String downLoadFromUrlAndName(String urlStr, String savePath,String fileName) {
+        try {
+            URL url = new URL(urlStr);
+
+            System.setProperty("https.protocols", "TLSv1,TLSv1.1,TLSv1.2,SSLv3");
+            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+            //设置超时间为3秒
+            conn.setConnectTimeout(60 * 1000);
+            //防止屏蔽程序抓取而返回403错误
+            conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
+            //得到输入流
+            InputStream inputStream = conn.getInputStream();
+            //获取自己数组
+            byte[] getData = readInputStream(inputStream);
+
+            //文件保存位置
+            File saveDir = new File(savePath);
+            if (!saveDir.exists()) {
+                saveDir.mkdirs();
+            }
+            String localPath = saveDir + File.separator + fileName;
+            File file = new File(localPath);
+            if (!file.exists()) {
+                file.getParentFile().mkdirs();
+            }
+            FileOutputStream fos = new FileOutputStream(file);
+            fos.write(getData);
+            if (fos != null) {
+                fos.close();
+            }
+            if (inputStream != null) {
+                inputStream.close();
+            }
+            return localPath;
+        } catch (Exception e) {
+            return null;
+        }
+
+
+    }
+
     public static byte[] readInputStream(InputStream inputStream) throws IOException {
         byte[] buffer = new byte[1024];
         int len = 0;

+ 406 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/fileupload/controller/ExternalMaterialCollectionController.java

@@ -0,0 +1,406 @@
+package org.jeecg.modules.fileupload.controller;
+
+import cn.com.ctop.common.module.entity.MaterialTagInfo;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.ExportExcelUtils;
+import cn.com.ctop.common.module.utils.ExternalMaterialCollection;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.modules.fileupload.service.IExternalMaterialCollectionService;
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 外部素材集信息表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2022-01-12
+ */
+@Slf4j
+@Api(tags = "外部素材集信息表")
+@RestController
+@RequestMapping("/external/materialCollection")
+public class ExternalMaterialCollectionController {
+    @Autowired
+    private IExternalMaterialCollectionService externalMaterialCollectionService;
+
+    /**
+     * 分页列表查询
+     */
+    @GetMapping(value = "/list")
+    public Result<Object> queryPageList(ExternalMaterialCollection externalMaterialCollection,
+                                        @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                        @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                        HttpServletRequest req) {
+        try {
+            return externalMaterialCollectionService.queryPageList(externalMaterialCollection, pageNo, pageSize);
+        } catch (Exception e) {
+            log.error("查询异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+
+    /**
+     * 上传单素材——视频
+     */
+    @PostMapping(value = "/addByVideo")
+    public Result<ExternalMaterialCollection> addByVideo(@RequestBody JSONObject json) {
+        Result<ExternalMaterialCollection> result = new Result<>();
+        try {
+            ExternalMaterialCollection materialCollection = JSONObject.parseObject(json.toJSONString(), ExternalMaterialCollection.class);
+            if (Check.isNull(materialCollection)) {
+                throw new Exception("数据格式异常");
+            }
+            externalMaterialCollectionService.addByVideo(materialCollection);
+            result.success("素材异步上传中");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 上传单素材——链接
+     */
+    @PostMapping(value = "/addByUrl")
+    public Result<ExternalMaterialCollection> addByUrl(@RequestBody JSONObject json) {
+        Result<ExternalMaterialCollection> result = new Result<>();
+        try {
+            ExternalMaterialCollection materialCollection = JSONObject.parseObject(json.toJSONString(), ExternalMaterialCollection.class);
+            if (Check.isNull(materialCollection)) {
+                throw new Exception("数据格式异常");
+            }
+            externalMaterialCollectionService.addByUrl(materialCollection);
+            result.success("素材异步上传中!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 上传批量素材——视频
+     */
+    @PostMapping(value = "/addMoreVideos")
+    public Result<ExternalMaterialCollection> addMoreVideos(@RequestBody JSONArray array) {
+        Result<ExternalMaterialCollection> result = new Result<>();
+        try {
+            if (array.size() < 1) {
+                return result.error500("缺少参数");
+            }
+            externalMaterialCollectionService.addMoreVideos(array);
+            result.success("素材异步上传中!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+
+    /**
+     * 上传批量素材——链接
+     */
+    @PostMapping(value = "/addMoreVideosByUrl")
+    public Result<ExternalMaterialCollection> addMoreVideosByUrl(@RequestBody JSONArray array) {
+        Result<ExternalMaterialCollection> result = new Result<>();
+        try {
+            if (array.size() < 1) {
+                return result.error500("缺少参数");
+            }
+            externalMaterialCollectionService.addMoreVideosByUrl(array);
+            result.success("素材异步上传中!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 上传批量素材——excel
+     */
+    @PostMapping(value = "/addMoreVideosByExcel")
+    @ResponseBody
+    public Result<Object> addMoreVideosByExcel(HttpServletResponse response, @RequestParam("file") MultipartFile file, @RequestParam("materialSource") String materialSource, @RequestParam("userId") String userId, @RequestParam("mediaType") Integer mediaType) {
+        response.setHeader("Access-Control-Allow-Origin", "*");
+        try {
+            if (Check.isNull(file) || Check.isNull(materialSource) || Check.isNull(userId) || Check.isNull(mediaType)) {
+                return Result.error("缺少参数");
+            }
+            return externalMaterialCollectionService.addMoreVideosByExcel(file, materialSource, userId, mediaType);
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("excel批量导入链接异常", e);
+            return Result.error("excel批量导入链接失败," + e.getMessage());
+        }
+    }
+
+    /**
+     * 校验素材是否已存在
+     */
+    @GetMapping(value = "/checkMaterialByMd5")
+    public Result<ExternalMaterialCollection> checkMaterialByMd5(String md5) {
+        Result<ExternalMaterialCollection> result = new Result<>();
+        try {
+            if (Check.isNull(md5)) {
+                return result.error500("缺少参数");
+            }
+            boolean f = externalMaterialCollectionService.checkMaterialByMd5(md5);
+            if (f) {
+                result.success("success");
+            } else {
+                result.error500("fail");
+            }
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 行业标签
+     */
+    @GetMapping(value = "/getIndustry")
+    public Result<Object> getIndustry() {
+        try {
+            return externalMaterialCollectionService.getIndustryLabel();
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            return Result.error("操作失败");
+        }
+    }
+
+    /**
+     * 标签回显
+     */
+    @GetMapping(value = "/getTagDetail")
+    public Result<Object> getTagDetail(String md5) {
+        return externalMaterialCollectionService.getTagDetail(md5);
+    }
+
+
+    /**
+     * 同步内部素材
+     */
+    @GetMapping(value = "/createInternalMaterial")
+    public Result<Object> createInternalMaterial() {
+        try {
+            return externalMaterialCollectionService.createInternalMaterial();
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            return Result.error("操作失败");
+        }
+    }
+
+    /**
+     * 编辑
+     */
+    @PostMapping(value = "/edit")
+    public Result<ExternalMaterialCollection> edit(@RequestBody ExternalMaterialCollection externalMaterialCollection) {
+        Result<ExternalMaterialCollection> result = new Result<ExternalMaterialCollection>();
+        ExternalMaterialCollection externalMaterialCollectionEntity = externalMaterialCollectionService.getById(externalMaterialCollection.getId());
+        if (externalMaterialCollectionEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = externalMaterialCollectionService.updateById(externalMaterialCollection);
+            if (ok) {
+                result.success("修改成功!");
+            }
+        }
+
+        return result;
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @ApiOperation(value = "外部素材集信息表-通过id删除", notes = "外部素材集信息表-通过id删除")
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id") String id) {
+        try {
+            externalMaterialCollectionService.removeById(id);
+        } catch (Exception e) {
+            log.error("删除失败", e.getMessage());
+            return Result.error("删除失败!");
+        }
+        return Result.ok("删除成功!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @ApiOperation(value = "外部素材集信息表-批量删除", notes = "外部素材集信息表-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<ExternalMaterialCollection> deleteBatch(@RequestParam(name = "ids") String ids) {
+        Result<ExternalMaterialCollection> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.externalMaterialCollectionService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @ApiOperation(value = "外部素材集信息表-通过id查询", notes = "外部素材集信息表-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<ExternalMaterialCollection> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<ExternalMaterialCollection> result = new Result<>();
+        ExternalMaterialCollection externalMaterialCollection = externalMaterialCollectionService.getById(id);
+        if (externalMaterialCollection == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(externalMaterialCollection);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<ExternalMaterialCollection> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                ExternalMaterialCollection externalMaterialCollection = JSON.parseObject(deString, ExternalMaterialCollection.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(externalMaterialCollection, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<ExternalMaterialCollection> pageList = externalMaterialCollectionService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "外部素材集信息表列表");
+        mv.addObject(NormalExcelConstants.CLASS, ExternalMaterialCollection.class);
+        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("外部素材集信息表列表数据", "导出人:Jeecg", "导出信息"));
+        mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
+        return mv;
+    }
+
+    /**
+     * 通过excel导入数据
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
+            MultipartFile file = entity.getValue();
+            ImportParams params = new ImportParams();
+            params.setTitleRows(2);
+            params.setHeadRows(1);
+            params.setNeedSave(true);
+            try {
+                List<ExternalMaterialCollection> listExternalMaterialCollections = ExcelImportUtil.importExcel(file.getInputStream(), ExternalMaterialCollection.class, params);
+                externalMaterialCollectionService.saveBatch(listExternalMaterialCollections);
+                return Result.ok("文件导入成功!数据行数:" + listExternalMaterialCollections.size());
+            } catch (Exception e) {
+                log.error(e.getMessage(), e);
+                return Result.error("文件导入失败:" + e.getMessage());
+            } finally {
+                try {
+                    file.getInputStream().close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return Result.ok("文件导入失败!");
+    }
+    /**
+     * 导出excel模板
+     */
+    @GetMapping("/exportTemplate")
+    public Result<Object> exportTemplate(HttpServletResponse response ) {
+        try {
+
+            OutputStream os = response.getOutputStream();
+            ExportExcelUtils eeu = new ExportExcelUtils();
+            XSSFWorkbook workbook = new XSSFWorkbook();
+            String[] titles = {
+                    "行业(如:综合游戏、休闲益智、动作射击、棋牌桌游、综合服务、小额贷款、第三方支付、金融综合线上平台、综合电商、电商商家、跨境、其他电商零售类、服饰、美妆日化、快消、工具、影音娱乐、婚恋/交友、生活/健康)请严格按照以上的行业填写,否则无法识别",
+                    "产品",
+                    "素材链接",
+                    "板位",
+                    "素材描述"
+            };
+            eeu.putHeaders(workbook, 0, "Sheet1", titles);
+            eeu.putResponseHeader(response, "exportTemplate.xlsx");
+            workbook.write(os);
+            os.flush();
+            os.close();
+        } catch (IOException e) {
+            log.error(e.getMessage());
+        }
+        return Result.ok("success");
+    }
+}

+ 35 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/fileupload/mapper/ExternalMaterialCollectionMapper.java

@@ -0,0 +1,35 @@
+package org.jeecg.modules.fileupload.mapper;
+
+import java.util.List;
+import java.util.Map;
+
+import cn.com.ctop.common.module.utils.ExternalMaterialCollection;
+import cn.com.ctop.crawler.modules.kuaishoucce.entity.KuaishouHotPhotoInfo;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * 外部素材集信息表
+ * @author jeecg-boot
+ * 2022-01-12
+ * @version V1.0
+ */
+public interface ExternalMaterialCollectionMapper extends BaseMapper<ExternalMaterialCollection> {
+
+    void replaceBatch(List<ExternalMaterialCollection> list);
+
+    Long getListTotal(ExternalMaterialCollection externalMaterialCollection);
+
+    List<ExternalMaterialCollection> queryPageList(ExternalMaterialCollection externalMaterialCollection);
+
+    List<Map<String,String>> getIndustryLabel();
+
+    List<JSONObject> getParentIndustryLabel();
+
+    List<JSONObject> getMd5ByMediaType(@Param("mediaType") Integer mediaType);
+
+    List<ExternalMaterialCollection> getKuaiShouInternalMaterial(@Param("md5List")  List<JSONObject> md5List);
+
+    List<ExternalMaterialCollection> getBytedanceInternalMaterial(@Param("md5List")  List<JSONObject> md5List);
+}

+ 209 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/fileupload/mapper/xml/ExternalMaterialCollectionMapper.xml

@@ -0,0 +1,209 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.jeecg.modules.fileupload.mapper.ExternalMaterialCollectionMapper">
+
+
+    <insert id="replaceBatch">
+        replace into ctop_external_material_collection (
+        user_id,
+        media_type,
+        create_type,
+        stat_date,
+        md5,
+        url,
+        external_url,
+        cover_url,
+        material_source,
+        industry,
+        product,
+        modality_tag,
+        scene_tag,
+        da_tag,
+        plate_position,
+        material_describe,
+        material_name,
+        `second`,
+        format,
+        width,
+        height,
+        `size`
+        )
+        values
+        <foreach collection="list" item="item" separator=",">
+            (
+            #{item.userId},
+            #{item.mediaType},
+            #{item.createType},
+            #{item.statDate},
+            #{item.md5},
+            #{item.url},
+            #{item.externalUrl},
+            #{item.coverUrl},
+            #{item.materialSource},
+            #{item.industry},
+            #{item.product},
+            #{item.modalityTag},
+            #{item.sceneTag},
+            #{item.daTag},
+            #{item.platePosition},
+            #{item.materialDescribe},
+            #{item.materialName},
+            #{item.second},
+            #{item.format},
+            #{item.width},
+            #{item.height},
+            #{item.size}
+            )
+        </foreach>
+    </insert>
+
+    <select id="getListTotal" resultType="java.lang.Long">
+        SELECT
+        IFNULL( SUM( 1 ), 0 )
+        FROM
+        ctop_external_material_collection
+        <where>
+            <if test="materialName != null">
+                AND material_name = #{materialName}
+            </if>
+            <if test="mediaType != null">
+                AND media_type =#{mediaType}
+            </if>
+            <if test="startTime != null">
+                AND stat_date &gt;= #{startTime}
+            </if>
+            <if test="endTime != null">
+                AND stat_date &lt;=#{endTime}
+            </if>
+            <if test="daTag != null">
+                AND da_tag = #{daTag}
+            </if>
+            <if test="sceneTag != null">
+                AND scene_tag = #{sceneTag}
+            </if>
+            <if test="modalityTag != null">
+                AND modality_tag = #{modalityTag}
+            </if>
+            <if test="industry != null">
+                AND industry = #{industry}
+            </if>
+            <if test="materialSource != null">
+                AND material_source = #{materialSource}
+            </if>
+        </where>
+    </select>
+
+    <select id="queryPageList" resultType="cn.com.ctop.common.module.utils.ExternalMaterialCollection">
+        SELECT
+        *
+        FROM
+        ctop_external_material_collection
+        <where>
+            <if test="materialName != null">
+                AND material_name = #{materialName}
+            </if>
+            <if test="mediaType != null">
+                AND media_type =#{mediaType}
+            </if>
+            <if test="startTime != null">
+                AND stat_date &gt;= #{startTime}
+            </if>
+            <if test="endTime != null">
+                AND stat_date &lt;=#{endTime}
+            </if>
+            <if test="daTag != null">
+                AND da_tag = #{daTag}
+            </if>
+            <if test="sceneTag != null">
+                AND scene_tag = #{sceneTag}
+            </if>
+            <if test="modalityTag != null">
+                AND modality_tag = #{modalityTag}
+            </if>
+            <if test="industry != null">
+                AND industry = #{industry}
+            </if>
+            <if test="materialSource != null">
+                AND material_source = #{materialSource}
+            </if>
+        </where>
+            ORDER BY create_time DESC
+    </select>
+
+
+    <select id="getIndustryLabel" resultType="Map">
+        select parent_id as 'parentId',name
+        from ctop_external_material_industry
+        where parent_id != 0
+    </select>
+
+    <select id="getParentIndustryLabel" resultType="com.alibaba.fastjson.JSONObject">
+        select id, name
+        from ctop_external_material_industry
+        where parent_id = 0
+    </select>
+
+
+    <select id="getMd5ByMediaType" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT user_id as 'userId',
+               signature as 'md5',
+               form_tag_list as 'formTagList',
+               mood_tag_list as 'moodTagList',
+               scene_tag_list as 'sceneTagList',
+               industry_id as 'industry',
+               DATE_FORMAT(hot_date,'%Y-%m-%d') as 'statDate' FROM application.hot_material_tag_info
+        where media_id = #{mediaType};
+    </select>
+
+
+    <select id="getKuaiShouInternalMaterial" resultType="cn.com.ctop.common.module.utils.ExternalMaterialCollection">
+        SELECT
+            t2.signature as 'md5',
+            t2.photo_name as 'materialName',
+            t2.url,
+            t2.cover_url,
+            6 as 'materialSource',
+            t3.second,
+            t3.format,
+            IFNULL(t3.width,t2.width) as 'width',
+            IFNULL(t3.height,t2.height) as 'height',
+            t3.size,
+            4 as 'createType',
+            2 as 'mediaType'
+        FROM  ctop_kuaishou_video_get t2
+        LEFT JOIN ctop_material_parameter t3 ON t2.signature= t3.material_id
+        WHERE t2.signature IN
+        <foreach collection="md5List" item="item" separator=","
+                 open="(" close=")">
+            #{item.md5}
+        </foreach>
+        group by t2.signature
+    </select>
+
+    <select id="getBytedanceInternalMaterial" resultType="cn.com.ctop.common.module.utils.ExternalMaterialCollection">
+        SELECT
+        t1.signature AS 'md5',
+        t1.filename AS 'materialName',
+        t1.video_url as 'url',
+        if(t1.poster_url='素材所属主体与开发者主体不一致无法获取URL',t2.cover_url,t1.poster_url) as 'coverUrl',
+        5 AS 'materialSource',
+        ROUND(t1.duration) as 'second',
+        t1.format,
+        t1.width AS 'width',
+        t1.height,
+        t1.size,
+        4 AS 'createType',
+        1 AS 'mediaType'
+        FROM
+        ctop_bytedance_video_info t1
+        LEFT JOIN ctop_material_info t2 ON t1.signature = t2.code
+        WHERE
+        signature IN
+        <foreach collection="md5List" item="item" separator=","
+                 open="(" close=")">
+            #{item.md5}
+        </foreach>
+        group by signature
+    </select>
+
+</mapper>

+ 41 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/fileupload/service/IExternalMaterialCollectionService.java

@@ -0,0 +1,41 @@
+package org.jeecg.modules.fileupload.service;
+
+import cn.com.ctop.common.module.entity.MaterialTagInfo;
+import cn.com.ctop.common.module.utils.ExternalMaterialCollection;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.api.vo.Result;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * 外部素材集信息表
+ * @author jeecg-boot
+ * 2022-01-12
+ * @version V1.0
+ */
+public interface IExternalMaterialCollectionService extends IService<ExternalMaterialCollection> {
+
+    Result<Object> queryPageList(ExternalMaterialCollection externalMaterialCollection, Integer pageNo, Integer pageSize);
+
+    void addByVideo(ExternalMaterialCollection materialCollection) throws Exception;
+
+    void addByUrl(ExternalMaterialCollection materialCollection) throws Exception;
+
+    void addMoreVideos(JSONArray array) throws Exception;
+
+    void addMoreVideosByUrl(JSONArray array) throws Exception;
+
+    boolean checkMaterialByMd5(String md5) throws Exception;
+
+    Result<Object> addMoreVideosByExcel(MultipartFile file, String materialSource,String userId,Integer mediaType) throws Exception;
+
+    Result<Object> getIndustryLabel();
+
+    Result<Object> createInternalMaterial();
+
+    Result<Object> getTagDetail(String md5);
+}

+ 471 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/fileupload/service/impl/ExternalMaterialCollectionServiceImpl.java

@@ -0,0 +1,471 @@
+package org.jeecg.modules.fileupload.service.impl;
+
+import cn.com.ctop.common.module.entity.MaterialCutFrame;
+import cn.com.ctop.common.module.entity.TagInfo;
+import cn.com.ctop.common.module.service.IMaterialCutFrameService;
+import cn.com.ctop.common.module.service.ITagInfoService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.CloudVideoProcessUtil;
+import cn.com.ctop.common.module.utils.CosUtils;
+import cn.com.ctop.common.module.utils.ExportExcelUtils;
+import cn.com.ctop.common.module.utils.ExternalMaterialCollection;
+import cn.com.ctop.common.module.utils.LoadFileUtil;
+import cn.com.ctop.common.module.vo.ResFileDTO;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import it.sauronsoftware.jave.Encoder;
+import it.sauronsoftware.jave.MultimediaInfo;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.util.DateUtils;
+import org.jeecg.modules.fileupload.mapper.ExternalMaterialCollectionMapper;
+import org.jeecg.modules.fileupload.service.IExternalMaterialCollectionService;
+import org.jeecg.modules.system.entity.SysCategory;
+import org.jeecg.modules.system.service.ISysCategoryService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.net.URLDecoder;
+import java.nio.channels.FileChannel;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * 外部素材集信息表
+ *
+ * @author jeecg-boot
+ * 2022-01-12
+ * @version V1.0
+ */
+@Service
+public class ExternalMaterialCollectionServiceImpl extends ServiceImpl<ExternalMaterialCollectionMapper, ExternalMaterialCollection> implements IExternalMaterialCollectionService {
+
+    @Autowired
+    private ExternalMaterialCollectionMapper mapper;
+
+    @Resource
+    private IMaterialCutFrameService materialCutFrameService;
+
+    @Autowired
+    private ITagInfoService tagInfoService;
+
+    @Autowired
+    private ISysCategoryService sysCategoryService;
+
+    @Value("${oss.replace.download}")
+    private String downloadUrl;
+
+    private static ExecutorService uploadExecutorService = Executors.newFixedThreadPool(5);
+
+    @Override
+    public Result<Object> queryPageList(ExternalMaterialCollection externalMaterialCollection, Integer pageNo, Integer pageSize) {
+        Long total = mapper.getListTotal(externalMaterialCollection);
+        PageHelper.startPage(pageNo, pageSize, false);
+        PageInfo pageInfo = new PageInfo(mapper.queryPageList(externalMaterialCollection));
+        pageInfo.setTotal(total);
+        return Result.ok(pageInfo);
+    }
+
+    @Override
+    public void addByVideo(ExternalMaterialCollection materialCollection) throws Exception {
+        uploadExecutorService.submit(new Runnable() {
+            @Override
+            public void run() {
+                materialCollection.setCreateType(1);// 1视频、2链接
+                String url = materialCollection.getUrl();
+                if (!Check.isNull(url)) {
+                    url = "https:" + url;
+                }
+                materialCollection.setUrl(url);
+                String localUrl = null;
+                FileInputStream fis = null;
+                try {
+                    String videoName = null;
+                    String industryName = materialCollection.getIndustry();
+                    SysCategory category = sysCategoryService.getById(materialCollection.getIndustry());
+                    if(!Check.isNull(category)){
+                        industryName = category.getName();
+                    }
+                    if (Check.isNull(materialCollection.getProduct())) {
+                        videoName = industryName + "-" + UUID.randomUUID().toString().replace("-", "").substring(0, 8) + ".mp4";
+                    } else {
+                        videoName = industryName + "-" + materialCollection.getProduct() + "-" + UUID.randomUUID().toString().replace("-", "").substring(0, 8) + ".mp4";
+                    }
+                    localUrl = LoadFileUtil.downLoadFromUrlAndName(url, downloadUrl, videoName);
+                    String md5 = LoadFileUtil.getMD5(localUrl);
+                    materialCollection.setMd5(md5);
+                    MaterialCutFrame cutFrame = materialCutFrameService.getCutFrameByCode(materialCollection.getMd5());
+                    if (Check.isNull(cutFrame)) {
+                        String videoUrl = URLDecoder.decode(url).replace("https://media-1301855440.cos.ap-chongqing.myqcloud.com/", "");
+                        String loadImage = "cutFrame/" + md5 + "/zero.jpg";
+                        String coverUrl = CloudVideoProcessUtil.videoCutPictureHandle(videoUrl, loadImage);
+                        materialCollection.setCoverUrl(coverUrl);
+                    } else {
+                        materialCollection.setCoverUrl(cutFrame.getUrl());
+                    }
+                    File file = new File(localUrl);
+                    it.sauronsoftware.jave.Encoder encoder = new Encoder();
+                    MultimediaInfo m = encoder.getInfo(file);
+                    long duration = m.getDuration();
+                    long secondDuration = duration / 1000;
+                    // 视频秒数
+                    materialCollection.setSecond(secondDuration);
+                    // 视频格式
+                    materialCollection.setFormat(m.getFormat());
+                    // 视频宽
+                    String width = String.valueOf(m.getVideo().getSize().getWidth());
+                    materialCollection.setWidth(width);
+                    // 视频高
+                    String height = String.valueOf(m.getVideo().getSize().getHeight());
+                    materialCollection.setHeight(height);
+                    fis = new FileInputStream(file);
+                    FileChannel fc = fis.getChannel();
+                    BigDecimal fileSize = new BigDecimal(fc.size());
+                    String size = fileSize.divide(new BigDecimal(1048576), 2, RoundingMode.HALF_UP) + "MB";
+                    materialCollection.setSize(size);
+                    materialCollection.setStatDate(DateUtils.formatDate(new Date()));
+                    materialCollection.setMaterialName(videoName);
+                    List<ExternalMaterialCollection> list = new ArrayList<>();
+                    list.add(materialCollection);
+                    mapper.replaceBatch(list);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                } finally {
+                    try {
+                        if (fis != null) {
+                            fis.close();
+                        }
+                    } catch (IOException e) {
+                        e.printStackTrace();
+                    }
+                    LoadFileUtil.delFile(localUrl);
+                }
+            }
+        });
+    }
+
+    @Override
+    public void addByUrl(ExternalMaterialCollection materialCollection) throws Exception {
+        uploadExecutorService.submit(new Runnable() {
+            @Override
+            public void run() {
+                materialCollection.setCreateType(2);// 1视频、2链接
+                String externalUrl = materialCollection.getExternalUrl();
+                String localUrl = null;
+                FileInputStream fis = null;
+                try {
+                    String videoName = null;
+                    String industryName = materialCollection.getIndustry();
+                    SysCategory category = sysCategoryService.getById(materialCollection.getIndustry());
+                    if(!Check.isNull(category)){
+                        industryName = category.getName();
+                    }
+                    if (Check.isNull(materialCollection.getProduct())) {
+                        videoName = industryName + "-" + UUID.randomUUID().toString().replace("-", "").substring(0, 8) + ".mp4";
+                    } else {
+                        videoName = industryName + "-" + materialCollection.getProduct() + "-" + UUID.randomUUID().toString().replace("-", "").substring(0, 8) + ".mp4";
+                    }
+                    localUrl = LoadFileUtil.downLoadFromUrlAndName(externalUrl, downloadUrl, videoName);
+                    File file = new File(localUrl);
+                    it.sauronsoftware.jave.Encoder encoder = new Encoder();
+                    MultimediaInfo m = encoder.getInfo(file);
+                    long duration = m.getDuration();
+                    long secondDuration = duration / 1000;
+                    // 视频秒数
+                    materialCollection.setSecond(secondDuration);
+                    // 视频格式
+                    materialCollection.setFormat(m.getFormat());
+                    // 视频宽
+                    String width = String.valueOf(m.getVideo().getSize().getWidth());
+                    materialCollection.setWidth(width);
+                    // 视频高
+                    String height = String.valueOf(m.getVideo().getSize().getHeight());
+                    materialCollection.setHeight(height);
+                    fis = new FileInputStream(file);
+                    FileChannel fc = fis.getChannel();
+                    BigDecimal fileSize = new BigDecimal(fc.size());
+                    String size = fileSize.divide(new BigDecimal(1048576), 2, RoundingMode.HALF_UP) + "MB";
+                    //大小
+                    materialCollection.setSize(size);
+                    String url = null;
+                    try {
+                        String path = "external-videos/" + DateUtils.formatDate(new Date(), DateUtils.SHORT_FORMAT) + "/";
+                        materialCollection.setMaterialName(videoName);
+                        ResFileDTO resultFile = CosUtils.uploadDetailInputStreamV2(fis, videoName, "mp4", fc.size(), path);
+                        url = resultFile.getFileUrl();
+                        materialCollection.setUrl(url);
+                    } catch (IOException e) {
+                        log.error("上传COS异常", e);
+                        throw new Exception("上传COS失败");
+                    }
+                    String md5 = LoadFileUtil.getMD5(localUrl);
+                    materialCollection.setMd5(md5);
+                    MaterialCutFrame cutFrame = materialCutFrameService.getCutFrameByCode(materialCollection.getMd5());
+                    if (Check.isNull(cutFrame)) {
+                        String videoUrl = URLDecoder.decode(url).replace("https://media-1301855440.cos.ap-chongqing.myqcloud.com/", "");
+                        String loadImage = "cutFrame/" + md5 + "/zero.jpg";
+                        String coverUrl = CloudVideoProcessUtil.videoCutPictureHandle(videoUrl, loadImage);
+                        materialCollection.setCoverUrl(coverUrl);
+                    } else {
+                        materialCollection.setCoverUrl(cutFrame.getUrl());
+                    }
+                    materialCollection.setStatDate(DateUtils.formatDate(new Date()));
+                    List<ExternalMaterialCollection> list = new ArrayList<>();
+                    list.add(materialCollection);
+                    mapper.replaceBatch(list);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                } finally {
+                    try {
+                        if (fis != null) {
+                            fis.close();
+                        }
+                    } catch (IOException e) {
+                        e.printStackTrace();
+                    }
+                    LoadFileUtil.delFile(localUrl);
+                }
+            }
+        });
+    }
+
+    @Override
+    public void addMoreVideos(JSONArray array) throws Exception {
+        for (int i = 0; i < array.size(); i++) {
+            ExternalMaterialCollection materialCollection = JSONObject.parseObject(array.getJSONObject(i).toJSONString(), ExternalMaterialCollection.class);
+            if (materialCollection == null) {
+                continue;
+            }
+            this.addByVideo(materialCollection);
+        }
+    }
+
+    @Override
+    public void addMoreVideosByUrl(JSONArray array) throws Exception {
+        for (int i = 0; i < array.size(); i++) {
+            ExternalMaterialCollection materialCollection = JSONObject.parseObject(array.getJSONObject(i).toJSONString(), ExternalMaterialCollection.class);
+            if (materialCollection == null) {
+                continue;
+            }
+            this.addByUrl(materialCollection);
+        }
+    }
+
+    @Override
+    public Result<Object> addMoreVideosByExcel(MultipartFile file, String materialSource, String userId, Integer mediaType) throws Exception {
+        JSONObject returnJson = new JSONObject();
+        Workbook workbook = null;
+        String fileName = file.getOriginalFilename();
+        String substring = fileName.substring(fileName.lastIndexOf(".") + 1).toUpperCase();
+        if ("XLS".equals(substring)) {
+            workbook = new HSSFWorkbook(file.getInputStream());
+        } else if ("XLSX".equals(substring)) {
+            workbook = new XSSFWorkbook(file.getInputStream());
+        } else {
+            throw new Exception("文件不是Excel文件");
+        }
+        Sheet sheet = workbook.getSheet("Sheet1");
+        if (Check.isNull(sheet)) {
+            throw new Exception("Sheet标题不是默认的Sheet1");
+        }
+        int rows = sheet.getLastRowNum();// 指的行数,一共有多少行+
+        if (rows == 0) {
+            throw new Exception("请填写数据");
+        }
+        List<ExternalMaterialCollection> list = new ArrayList<>();
+        ExportExcelUtils eeu = new ExportExcelUtils();
+        for (int i = 1; i <= rows + 1; i++) {
+            Row row = sheet.getRow(i);
+            if (row != null) {
+                //行业
+                String industryLabel = eeu.getCellValue(row.getCell(0));
+                if (Check.isNull(industryLabel)) {
+                    return Result.error("解析数据失败,文档中第" + (i + 1) + "行,行业列缺失数据");
+                }
+                //产品
+                String product = eeu.getCellValue(row.getCell(1));
+                //链接
+                String externalUrl = eeu.getCellValue(row.getCell(2));
+                if (Check.isNull(externalUrl)) {
+                    return Result.error("解析数据失败,文档中第" + (i + 1) + "行,素材链接列缺失数据");
+                }
+                if (!externalUrl.contains("http")) {
+                    externalUrl = "https:" + externalUrl;
+                }
+                //板位
+                String platePosition = eeu.getCellValue(row.getCell(3));
+                //描述
+                String materialDescribe = eeu.getCellValue(row.getCell(4));
+                ExternalMaterialCollection materialCollection = new ExternalMaterialCollection();
+                materialCollection.setIndustry(industryLabel);
+                materialCollection.setProduct(product);
+                materialCollection.setExternalUrl(externalUrl);
+                materialCollection.setPlatePosition(platePosition);
+                materialCollection.setMaterialDescribe(materialDescribe);
+                materialCollection.setMaterialSource(materialSource);
+                materialCollection.setStatDate(DateUtils.formatDate(new Date()));
+                materialCollection.setUserId(userId);
+                materialCollection.setCreateType(3);
+                materialCollection.setMediaType(mediaType);
+                list.add(materialCollection);
+            }
+        }
+        if (!list.isEmpty()) {
+            for (ExternalMaterialCollection materialCollection : list) {
+                this.addByUrl(materialCollection);
+            }
+        }
+        return Result.ok("素材异步上传中");
+    }
+
+    @Override
+    public boolean checkMaterialByMd5(String md5) throws Exception {
+        QueryWrapper<ExternalMaterialCollection> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("md5", md5).last("limit 1");
+        ExternalMaterialCollection one = this.getOne(queryWrapper);
+        if (Check.isNull(one)) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+
+    @Override
+    public Result<Object> getIndustryLabel() {
+        List<JSONObject> json = mapper.getParentIndustryLabel();
+        List<Map<String, String>> industryLabels = mapper.getIndustryLabel();
+        for (JSONObject obj : json) {
+            JSONArray children = new JSONArray();
+            String id = obj.getString("id");
+            for (Map map : industryLabels) {
+                if (id.equals(map.get("parentId"))) {
+                    children.add(map.get("name"));
+                }
+            }
+            obj.put("child", children);
+        }
+        return Result.ok(json);
+    }
+
+    @Override
+    public Result<Object> createInternalMaterial() {
+        List<JSONObject> md5List = mapper.getMd5ByMediaType(2);// 1头条,2快手
+        Map<String, JSONObject> map = new HashMap<>();
+        for (JSONObject object : md5List) {
+            map.put(object.getString("md5"), object);
+        }
+        List<ExternalMaterialCollection> list = new ArrayList<>();
+        if (!Check.isNull(md5List) && !md5List.isEmpty()) {
+            list = mapper.getKuaiShouInternalMaterial(md5List);
+            for (ExternalMaterialCollection materialCollection : list) {
+                JSONObject entity2 = map.get(materialCollection.getMd5());
+                if (!Check.isNull(entity2)) {
+                    materialCollection.setUserId(entity2.getString("userId"));
+                    materialCollection.setModalityTag(getList(entity2.getString("formTagList")));
+                    materialCollection.setDaTag(getList(entity2.getString("moodTagList")));
+                    materialCollection.setSceneTag(getList(entity2.getString("sceneTagList")));
+                    materialCollection.setIndustry(entity2.getString("industry"));
+                    materialCollection.setStatDate(entity2.getString("statDate"));
+                }
+            }
+        }
+        if (!Check.isNull(list)) {
+            mapper.replaceBatch(list);
+        }
+
+        md5List = mapper.getMd5ByMediaType(1);// 1头条,2快手
+        Map<String, JSONObject> map1 = new HashMap<>();
+        for (JSONObject object : md5List) {
+            map1.put(object.getString("md5"), object);
+        }
+        if (!Check.isNull(md5List) && !md5List.isEmpty()) {
+            list = mapper.getBytedanceInternalMaterial(md5List);
+            for (ExternalMaterialCollection materialCollection : list) {
+                JSONObject entity1 = map1.get(materialCollection.getMd5());
+                if (!Check.isNull(entity1)) {
+                    materialCollection.setUserId(entity1.getString("userId"));
+                    materialCollection.setModalityTag(getList(entity1.getString("formTagList")));
+                    materialCollection.setDaTag(getList(entity1.getString("moodTagList")));
+                    materialCollection.setSceneTag(getList(entity1.getString("sceneTagList")));
+                    materialCollection.setIndustry(entity1.getString("industry"));
+                    materialCollection.setStatDate(entity1.getString("statDate"));
+                }
+            }
+        }
+        if (!Check.isNull(list)) {
+            mapper.replaceBatch(list);
+        }
+        return Result.ok("success");
+    }
+
+    private String getList(String str) {
+        try {
+            if (Check.isNull(str)) {
+                return null;
+            }
+            String[] split = str.split(",");
+            List<String> list = Arrays.asList(split);
+            return JSONObject.toJSONString(list);
+        } catch (Exception e) {
+            return null;
+        }
+    }
+
+    @Override
+    public Result<Object> getTagDetail(String md5) {
+        QueryWrapper<ExternalMaterialCollection> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("md5", md5).last("limit 1");
+        ExternalMaterialCollection one = this.getOne(queryWrapper);
+        if (Check.isNull(one)) {
+            return Result.error("未查询到素材");
+        }
+        List<TagInfo> modTagList = new ArrayList<>();
+        List<TagInfo> modalityTagList = new ArrayList<>();
+        List<TagInfo> sceneTagList = new ArrayList<>();
+        JSONArray modTagArr = JSONArray.parseArray(one.getDaTag());
+        if (!Check.isNull(modTagArr) && !modTagArr.isEmpty()) {
+            modTagList = tagInfoService.getListByCode(modTagArr);
+        }
+
+        JSONArray ModalityTagArr = JSONArray.parseArray(one.getModalityTag());
+        if (!Check.isNull(ModalityTagArr) && !ModalityTagArr.isEmpty()) {
+            modalityTagList = tagInfoService.getListByCode(ModalityTagArr);
+        }
+        JSONArray sceneTagArr = JSONArray.parseArray(one.getSceneTag());
+        if (!Check.isNull(sceneTagArr) && !sceneTagArr.isEmpty()) {
+            sceneTagList = tagInfoService.getListByCode(sceneTagArr);
+        }
+
+        JSONObject result = new JSONObject();
+        result.put("modTagList", modTagList);
+        result.put("modalityTagList", modalityTagList);
+        result.put("sceneTagList", sceneTagList);
+        return Result.ok(result);
+    }
+}
+
+