Browse Source

数据修改

yumeng 1 year ago
parent
commit
06c4b33ed4

+ 1 - 0
ruixuan-framework/src/main/java/com/ruixuan/framework/config/SecurityConfig.java

@@ -128,6 +128,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
                 .antMatchers("/report/**").permitAll()
                 .antMatchers("/settlement/**").permitAll()
                 .antMatchers("/bytedance/**").permitAll()
+                .antMatchers("/jy/material/**").permitAll()
 
                 // 除上面外的所有请求全部需要鉴权认证
                 .anyRequest().authenticated()

+ 14 - 1
ruixuan-live/pom.xml

@@ -27,7 +27,11 @@
             <artifactId>sdk</artifactId>
             <version>1.0.11</version>
         </dependency>
-
+        <dependency>
+            <groupId>com.tencentcloudapi</groupId>
+            <artifactId>tencentcloud-sdk-java</artifactId>
+            <version>3.1.62</version><!-- 注:这里只是示例版本号,请获取并替换为 最新的版本号 -->
+        </dependency>
         <dependency>
             <groupId>thirtpart</groupId>
             <artifactId>sdk</artifactId>
@@ -43,6 +47,15 @@
             <scope>system</scope>
             <systemPath>${project.basedir}/src/main/resources/lib/sdk-java-1.0-SNAPSHOT.jar</systemPath>
         </dependency>
+
+        <dependency>
+            <groupId>jave</groupId>
+            <artifactId>bytedance</artifactId>
+            <version>1.0</version>
+            <scope>system</scope>
+            <systemPath>${project.basedir}/src/main/resources/lib/jave-1.0.jar</systemPath>
+        </dependency>
+
         <!-- 通用工具-->
         <dependency>
             <groupId>com.ruixuan</groupId>

+ 1 - 0
ruixuan-live/src/main/java/com/ruixuan/data/service/impl/VideoTextServiceImpl.java

@@ -67,6 +67,7 @@ public class VideoTextServiceImpl implements VideoTextService {
             }
         };
         thread.start();
+        log.info("转文字成功:{}", videoText);
         return ResultResponse.success(videoText);
     }
 

+ 11 - 6
ruixuan-live/src/main/java/com/ruixuan/data/utils/VideoToPCMTool.java

@@ -7,6 +7,8 @@ import com.tencent.asr.model.FlashRecognitionRequest;
 import com.tencent.asr.model.FlashRecognitionResponse;
 import com.tencent.asr.service.FlashRecognizer;
 import com.tencent.core.utils.ByteUtils;
+import it.sauronsoftware.jave.Encoder;
+import it.sauronsoftware.jave.EncoderException;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.codec.digest.DigestUtils;
 import org.bytedeco.javacpp.Loader;
@@ -88,17 +90,20 @@ public class VideoToPCMTool {
     }
 
     public static long readDuration(Path mp4Path) {
+
         if (Files.notExists(mp4Path) || !Files.isReadable(mp4Path)) {
             log.warn("文件路径不存在或不可读 {}", mp4Path);
             return 0;
         }
         try {
-            File file = mp4Path.toFile();
-            IsoFile isoFile = new IsoFile(mp4Path.toFile());
-            long duration = isoFile.getMovieBox().getMovieHeaderBox().getDuration();
-            long timescale = isoFile.getMovieBox().getMovieHeaderBox().getTimescale();
-            return duration / timescale;
-        } catch (IOException e) {
+            it.sauronsoftware.jave.MultimediaInfo m = null;
+            File file = new File(mp4Path.toString());
+            it.sauronsoftware.jave.Encoder encoder = new Encoder();
+            m = encoder.getInfo(file);
+            long duration = m.getDuration();
+            long secondDuration = duration / 1000;
+            return secondDuration;
+        } catch (Exception e) {
             log.error("读取MP4文件时长出错", e);
             return 0;
         }

+ 174 - 0
ruixuan-live/src/main/java/com/ruixuan/jiaoyang/controller/JyMaterialListController.java

@@ -0,0 +1,174 @@
+package com.ruixuan.jiaoyang.controller;
+
+
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import javax.servlet.http.HttpServletResponse;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.github.pagehelper.PageInfo;
+import com.ruixuan.common.annotation.Log;
+import com.ruixuan.common.core.controller.BaseController;
+import com.ruixuan.common.core.domain.AjaxResult;
+import com.ruixuan.common.core.page.TableDataInfo;
+import com.ruixuan.common.enums.BusinessType;
+import com.ruixuan.common.utils.Check;
+import com.ruixuan.common.utils.poi.ExcelUtil;
+import com.ruixuan.jiaoyang.entity.JyMaterialList;
+import com.ruixuan.jiaoyang.service.IJyMaterialListService;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+
+/**
+ * 素材信息Controller
+ *
+ * @author ruoyi
+ * @date 2023-11-16
+ */
+@RestController
+@RequestMapping("/jy/material")
+public class JyMaterialListController extends BaseController {
+    private static ExecutorService uploadExecutorService = Executors.newFixedThreadPool(20);
+    @Autowired
+    private IJyMaterialListService jyMaterialListService;
+
+    @GetMapping("/getKeyWordList")
+    public TableDataInfo getKeyWordList() {
+        startPage();
+        List<JSONObject> list = jyMaterialListService.getKeyWordList();
+        return getDataTable(list);
+    }
+
+    @GetMapping("/insertKeyWord")
+    public JSONObject insertKeyWord(String type, String keyWord) {
+        JSONObject json = new JSONObject();
+        jyMaterialListService.insertKeyWord(type, keyWord);
+        json.put("code", 0);
+        json.put("message", "success");
+        return json;
+    }
+
+    @GetMapping("/checkMaterial")
+    public JSONObject checkMaterial(String signature) {
+        JSONObject returnJson = new JSONObject();
+        try {
+            if (Check.isNull(signature)) {
+                throw new Exception("入参不能为空");
+            }
+            Integer count = jyMaterialListService.checkMaterial(signature);
+            if (count > 0) {
+                returnJson.put("data", false);
+            } else {
+                returnJson.put("data", true);
+            }
+            returnJson.put("code", 0);
+        } catch (Exception e) {
+            returnJson.put("code", 500);
+            returnJson.put("message", e.getMessage());
+
+        }
+        return returnJson;
+    }
+
+
+    @PostMapping("/addMaterials")
+    public JSONObject addMaterials(@RequestBody JSONObject requestJson) {
+        JSONObject returnJson = new JSONObject();
+        try {
+            if (Check.isNull(requestJson)) {
+                throw new Exception("入参不能为空");
+            }
+            Long userId = requestJson.getLong("userId");
+            if (Check.isNull(userId)) {
+                throw new Exception("上传人不能为空");
+            }
+            String userName = requestJson.getString("userName");
+            if (Check.isNull(userName)) {
+                throw new Exception("上传人不能为空");
+            }
+            JSONArray materialList = requestJson.getJSONArray("materialList");
+            if (Check.isNull(materialList)) {
+                throw new Exception("上传人不能为空");
+            }
+
+            uploadExecutorService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    jyMaterialListService.addMaterials(userId, userName, materialList);
+                }
+            });
+            returnJson.put("code", 0);
+            returnJson.put("message", "提交成功");
+
+
+        } catch (Exception e) {
+            returnJson.put("code", 500);
+            returnJson.put("message", e.getMessage());
+        }
+        return returnJson;
+    }
+
+
+    /**
+     * 查询素材信息列表
+     */
+    @GetMapping("/list")
+    public PageInfo<JyMaterialList> list(JyMaterialList jyMaterialList) {
+
+        return jyMaterialListService.selectJyMaterialListList(jyMaterialList);
+    }
+
+
+    /**
+     * 修改素材信息
+     */
+
+    @Log(title = "素材信息", businessType = BusinessType.UPDATE)
+    @PutMapping("/edit")
+    public AjaxResult edit(@RequestBody JyMaterialList jyMaterialList) {
+        return toAjax(jyMaterialListService.updateJyMaterialList(jyMaterialList));
+    }
+
+
+    /**
+     * 获取素材信息详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('system:list:query')")
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id) {
+        return AjaxResult.success(jyMaterialListService.selectJyMaterialListById(id));
+    }
+
+    /**
+     * 新增素材信息
+     */
+    @PreAuthorize("@ss.hasPermi('system:list:add')")
+    @Log(title = "素材信息", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody JyMaterialList jyMaterialList) {
+        return toAjax(jyMaterialListService.insertJyMaterialList(jyMaterialList));
+    }
+
+
+    /**
+     * 删除素材信息
+     */
+    @PreAuthorize("@ss.hasPermi('system:list:remove')")
+    @Log(title = "素材信息", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids) {
+        return toAjax(jyMaterialListService.deleteJyMaterialListByIds(ids));
+    }
+}
+

+ 224 - 0
ruixuan-live/src/main/java/com/ruixuan/jiaoyang/entity/JyMaterialList.java

@@ -0,0 +1,224 @@
+package com.ruixuan.jiaoyang.entity;
+
+
+import com.ruixuan.common.annotation.Excel;
+import com.ruixuan.common.core.domain.BaseEntity;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import org.springframework.data.annotation.Transient;
+
+
+/**
+ * 素材信息对象 jy_material_list
+ *
+ * @author ruoyi
+ * @date 2023-11-16
+ */
+public class JyMaterialList extends BaseEntity {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * $column.columnComment
+     */
+    private Long id;
+
+    /**
+     * 素材唯一标识
+     */
+    @Excel(name = "素材唯一标识")
+    private String signature;
+
+    /**
+     * 素材名称
+     */
+    @Excel(name = "素材名称")
+    private String materialName;
+
+    /**
+     * $column.columnComment
+     */
+    @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
+    private String coverUrl;
+
+    /**
+     * $column.columnComment
+     */
+    @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
+    private String materialUrl;
+
+    /**
+     * 创建人id
+     */
+    @Excel(name = "创建人id")
+    private Long userId;
+
+    /**
+     * $column.columnComment
+     */
+    @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
+    private String userName;
+
+    /**
+     * 1-待处理 2-检测完成 3-检测失败
+     */
+    @Excel(name = "1-待处理 2-检测完成 3-检测失败")
+    private Integer materialStatus;
+
+    /**
+     * 视频文本
+     */
+    @Excel(name = "视频文本")
+    private String materialText;
+
+    /**
+     * 违规词
+     */
+    @Excel(name = "违规词")
+    private String violatingText;
+
+    @Transient
+    private String startDate;
+    @Transient
+    private String endDate;
+    @Transient
+    private Integer pageNum;
+    @Transient
+    private Integer pageSize;
+
+    public static long getSerialVersionUID() {
+        return serialVersionUID;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getSignature() {
+        return signature;
+    }
+
+    public void setSignature(String signature) {
+        this.signature = signature;
+    }
+
+    public String getMaterialName() {
+        return materialName;
+    }
+
+    public void setMaterialName(String materialName) {
+        this.materialName = materialName;
+    }
+
+    public String getCoverUrl() {
+        return coverUrl;
+    }
+
+    public void setCoverUrl(String coverUrl) {
+        this.coverUrl = coverUrl;
+    }
+
+    public String getMaterialUrl() {
+        return materialUrl;
+    }
+
+    public void setMaterialUrl(String materialUrl) {
+        this.materialUrl = materialUrl;
+    }
+
+    public Long getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Long userId) {
+        this.userId = userId;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public Integer getMaterialStatus() {
+        return materialStatus;
+    }
+
+    public void setMaterialStatus(Integer materialStatus) {
+        this.materialStatus = materialStatus;
+    }
+
+    public String getMaterialText() {
+        return materialText;
+    }
+
+    public void setMaterialText(String materialText) {
+        this.materialText = materialText;
+    }
+
+    public String getViolatingText() {
+        return violatingText;
+    }
+
+    public void setViolatingText(String violatingText) {
+        this.violatingText = violatingText;
+    }
+
+    public String getStartDate() {
+        return startDate;
+    }
+
+    public void setStartDate(String startDate) {
+        this.startDate = startDate;
+    }
+
+    public String getEndDate() {
+        return endDate;
+    }
+
+    public void setEndDate(String endDate) {
+        this.endDate = endDate;
+    }
+
+    public Integer getPageNum() {
+        return pageNum;
+    }
+
+    public void setPageNum(Integer pageNum) {
+        this.pageNum = pageNum;
+    }
+
+    public Integer getPageSize() {
+        return pageSize;
+    }
+
+    public void setPageSize(Integer pageSize) {
+        this.pageSize = pageSize;
+    }
+
+    @Override
+    public String toString() {
+        return "JyMaterialList{" +
+                "id=" + id +
+                ", signature='" + signature + '\'' +
+                ", materialName='" + materialName + '\'' +
+                ", coverUrl='" + coverUrl + '\'' +
+                ", materialUrl='" + materialUrl + '\'' +
+                ", userId=" + userId +
+                ", userName='" + userName + '\'' +
+                ", materialStatus=" + materialStatus +
+                ", materialText='" + materialText + '\'' +
+                ", violatingText='" + violatingText + '\'' +
+                ", startDate='" + startDate + '\'' +
+                ", endDate='" + endDate + '\'' +
+                ", pageNum=" + pageNum +
+                ", pageSize=" + pageSize +
+                '}';
+    }
+}
+

+ 74 - 0
ruixuan-live/src/main/java/com/ruixuan/jiaoyang/mapper/JyMaterialListMapper.java

@@ -0,0 +1,74 @@
+package com.ruixuan.jiaoyang.mapper;
+
+
+import com.alibaba.fastjson.JSONObject;
+import com.ruixuan.jiaoyang.entity.JyMaterialList;
+
+import java.util.List;
+
+/**
+ * 素材信息Mapper接口
+ *
+ * @author ruoyi
+ * @date 2023-11-16
+ */
+public interface JyMaterialListMapper
+{
+    /**
+     * 查询素材信息
+     *
+     * @param id 素材信息主键
+     * @return 素材信息
+     */
+    public JyMaterialList selectJyMaterialListById(Long id);
+
+    /**
+     * 查询素材信息列表
+     *
+     * @param jyMaterialList 素材信息
+     * @return 素材信息集合
+     */
+    public List<JyMaterialList> selectJyMaterialListList(JyMaterialList jyMaterialList);
+
+    /**
+     * 新增素材信息
+     *
+     * @param jyMaterialList 素材信息
+     * @return 结果
+     */
+    public int insertJyMaterialList(JyMaterialList jyMaterialList);
+
+    /**
+     * 修改素材信息
+     *
+     * @param jyMaterialList 素材信息
+     * @return 结果
+     */
+    public int updateJyMaterialList(JyMaterialList jyMaterialList);
+
+    /**
+     * 删除素材信息
+     *
+     * @param id 素材信息主键
+     * @return 结果
+     */
+    public int deleteJyMaterialListById(Long id);
+
+    /**
+     * 批量删除素材信息
+     *
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteJyMaterialListByIds(Long[] ids);
+
+    Integer checkMaterial(String signature);
+
+    List<JSONObject> jyMaterialListMapper();
+
+    void updateJyMaterialListBySignature(JyMaterialList updateMaterial);
+
+    List<JSONObject> getKeyWordList();
+
+    void insertKeyWord(String type, String keyWord);
+}

+ 5 - 0
ruixuan-live/src/main/java/com/ruixuan/jiaoyang/service/ICloudVideoProcessService.java

@@ -0,0 +1,5 @@
+package com.ruixuan.jiaoyang.service;
+
+public interface ICloudVideoProcessService {
+    String videoCutPictureHandle(String videoPath, String outputPath);
+}

+ 74 - 0
ruixuan-live/src/main/java/com/ruixuan/jiaoyang/service/IJyMaterialListService.java

@@ -0,0 +1,74 @@
+package com.ruixuan.jiaoyang.service;
+
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.github.pagehelper.PageInfo;
+import com.ruixuan.jiaoyang.entity.JyMaterialList;
+
+import java.util.List;
+
+/**
+ * 素材信息Service接口
+ *
+ * @author ruoyi
+ * @date 2023-11-16
+ */
+public interface IJyMaterialListService
+{
+    /**
+     * 查询素材信息
+     *
+     * @param id 素材信息主键
+     * @return 素材信息
+     */
+    public JyMaterialList selectJyMaterialListById(Long id);
+
+    /**
+     * 查询素材信息列表
+     *
+     * @param jyMaterialList 素材信息
+     * @return 素材信息集合
+     */
+    public PageInfo<JyMaterialList> selectJyMaterialListList(JyMaterialList jyMaterialList);
+
+    /**
+     * 新增素材信息
+     *
+     * @param jyMaterialList 素材信息
+     * @return 结果
+     */
+    public int insertJyMaterialList(JyMaterialList jyMaterialList);
+
+    /**
+     * 修改素材信息
+     *
+     * @param jyMaterialList 素材信息
+     * @return 结果
+     */
+    public int updateJyMaterialList(JyMaterialList jyMaterialList);
+
+    /**
+     * 批量删除素材信息
+     *
+     * @param ids 需要删除的素材信息主键集合
+     * @return 结果
+     */
+    public int deleteJyMaterialListByIds(Long[] ids);
+
+    /**
+     * 删除素材信息信息
+     *
+     * @param id 素材信息主键
+     * @return 结果
+     */
+    public int deleteJyMaterialListById(Long id);
+
+    Integer checkMaterial(String signature);
+
+    void addMaterials(Long userId, String userName, JSONArray materialList);
+
+    List<JSONObject> getKeyWordList();
+
+    void insertKeyWord(String type, String keyWord);
+}

+ 81 - 0
ruixuan-live/src/main/java/com/ruixuan/jiaoyang/service/impl/CloudVideoProcessServiceImpl.java

@@ -0,0 +1,81 @@
+package com.ruixuan.jiaoyang.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.qcloud.cos.auth.BasicCOSCredentials;
+import com.qcloud.cos.auth.COSCredentials;
+import com.qcloud.cos.auth.COSSigner;
+import com.qcloud.cos.http.HttpMethodName;
+import com.ruixuan.jiaoyang.service.ICloudVideoProcessService;
+import com.ruixuan.jiaoyang.utils.CosConstant;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.MediaType;
+import org.springframework.stereotype.Service;
+import org.springframework.web.client.RestClientException;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.Date;
+@Slf4j
+@Service
+public class CloudVideoProcessServiceImpl implements ICloudVideoProcessService {
+
+    private static RestTemplate restTemplate = new RestTemplate();
+
+    private static final String SECRET_ID = "AKIDE6IpMi8fJQRCg1iuWzFajjRs43kbbets";
+    private static final String SECRET_KEY = "tXzuwMfplTTK3c9GFUyETilasvQfePu9";
+    private static final String COS_LOCATION = "ap-chongqing";
+    private static final String COS_BUCKET_MEDIA = "live-1301855440";
+
+    @Override
+    public String videoCutPictureHandle(String videoPath, String outputPath) {
+        String auth = generateAuth(SECRET_ID, SECRET_KEY, "/snapshot", HttpMethodName.POST);
+        if (auth.isEmpty()) {
+            log.error("腾讯云Authorization获取失败");
+        }
+        //拼接请求数据万象jobs接口的参数
+        JSONObject input = new JSONObject();
+        input.put("Object", videoPath);
+        JSONObject output = new JSONObject();
+        output.put("Region", COS_LOCATION);
+        output.put("Bucket", COS_BUCKET_MEDIA);
+        output.put("Object", outputPath);
+        JSONObject request = new JSONObject();
+        request.put("Input", input);
+        request.put("Output", output);
+        request.put("Time", 0);
+
+        //请求media-1301855440.ci.ap-chongqing.myqcloud.com/snapshot 接口
+        HttpHeaders headers = new HttpHeaders();
+        headers.set("Authorization", auth);
+        headers.setContentType(MediaType.APPLICATION_JSON);
+        HttpEntity<String> requestEntity = new HttpEntity<>(request.toJSONString(), headers);
+        String response = null;
+        try {
+            response = restTemplate.exchange(CosConstant.URL_SNAPSHOT, HttpMethod.POST, requestEntity, String.class).getBody();
+        } catch (RestClientException e) {
+            e.printStackTrace();
+            log.error(e.getMessage());
+        }
+        if (response.isEmpty()) {
+            return CosConstant.URL_COS_ADDRESS + "error.jpg";
+        } else {
+            return CosConstant.URL_COS_ADDRESS + outputPath;
+        }
+    }
+
+    public static String generateAuth(String secretId, String secretKey, String path, HttpMethodName httpMethodName) {
+        COSCredentials cred = new BasicCOSCredentials(secretId, secretKey);
+        COSSigner signer = new COSSigner();
+        //设置过期时间为1个小时
+        Date expiredTime = new Date(System.currentTimeMillis() + 3600L * 1000L);
+        //授权的签名
+        return signer.buildAuthorizationStr(
+                httpMethodName,
+                path,
+                cred,
+                expiredTime
+        );
+    }
+}

+ 220 - 0
ruixuan-live/src/main/java/com/ruixuan/jiaoyang/service/impl/JyMaterialListServiceImpl.java

@@ -0,0 +1,220 @@
+package com.ruixuan.jiaoyang.service.impl;
+
+import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.ruixuan.common.core.domain.ResultResponse;
+import com.ruixuan.common.utils.Check;
+import com.ruixuan.common.utils.DateUtils;
+import com.ruixuan.data.service.VideoTextService;
+import com.ruixuan.jiaoyang.entity.JyMaterialList;
+import com.ruixuan.jiaoyang.mapper.JyMaterialListMapper;
+
+import com.ruixuan.jiaoyang.service.ICloudVideoProcessService;
+import com.ruixuan.jiaoyang.service.IJyMaterialListService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+
+/**
+ * 素材信息Service业务层处理
+ *
+ * @author ruoyi
+ * @date 2023-11-16
+ */
+@Slf4j
+@Service
+public class JyMaterialListServiceImpl implements IJyMaterialListService {
+    @Autowired
+    private JyMaterialListMapper jyMaterialListMapper;
+    @Autowired
+    private ICloudVideoProcessService cloudVideoProcessService;
+    @Autowired
+    private VideoTextService videoTextService;
+    private static ExecutorService uploadExecutorService = Executors.newFixedThreadPool(5);
+    private static List<JSONObject> keyList = new ArrayList<>();
+
+    /**
+     * 查询素材信息
+     *
+     * @param id 素材信息主键
+     * @return 素材信息
+     */
+    @Override
+    public JyMaterialList selectJyMaterialListById(Long id) {
+        return jyMaterialListMapper.selectJyMaterialListById(id);
+    }
+
+    /**
+     * 查询素材信息列表
+     *
+     * @param jyMaterialList 素材信息
+     * @return 素材信息
+     */
+    @Override
+    public PageInfo<JyMaterialList> selectJyMaterialListList(JyMaterialList jyMaterialList) {
+        PageHelper.startPage(jyMaterialList.getPageNum(), jyMaterialList.getPageSize());
+        List<JyMaterialList> jyMaterialLists = jyMaterialListMapper.selectJyMaterialListList(jyMaterialList);
+        PageInfo<JyMaterialList> pageInfo = new PageInfo<>(jyMaterialLists);
+        return pageInfo;
+    }
+
+    /**
+     * 新增素材信息
+     *
+     * @param jyMaterialList 素材信息
+     * @return 结果
+     */
+    @Override
+    public int insertJyMaterialList(JyMaterialList jyMaterialList) {
+        jyMaterialList.setCreateTime(DateUtils.getNowDate());
+        return jyMaterialListMapper.insertJyMaterialList(jyMaterialList);
+    }
+
+    /**
+     * 修改素材信息
+     *
+     * @param jyMaterialList 素材信息
+     * @return 结果
+     */
+    @Override
+    public int updateJyMaterialList(JyMaterialList jyMaterialList) {
+        jyMaterialList.setUpdateTime(DateUtils.getNowDate());
+        return jyMaterialListMapper.updateJyMaterialList(jyMaterialList);
+    }
+
+    /**
+     * 批量删除素材信息
+     *
+     * @param ids 需要删除的素材信息主键
+     * @return 结果
+     */
+    @Override
+    public int deleteJyMaterialListByIds(Long[] ids) {
+        return jyMaterialListMapper.deleteJyMaterialListByIds(ids);
+    }
+
+    /**
+     * 删除素材信息信息
+     *
+     * @param id 素材信息主键
+     * @return 结果
+     */
+    @Override
+    public int deleteJyMaterialListById(Long id) {
+        return jyMaterialListMapper.deleteJyMaterialListById(id);
+    }
+
+    @Override
+    public Integer checkMaterial(String signature) {
+        return jyMaterialListMapper.checkMaterial(signature);
+    }
+
+    @Override
+    public void addMaterials(Long userId, String userName, JSONArray materialList) {
+        for (int i = 0; i < materialList.size(); i++) {
+            JSONObject jsonObject = materialList.getJSONObject(i);
+            String signature = jsonObject.getString("signature");
+            Integer count = jyMaterialListMapper.checkMaterial(signature);
+            if (count > 0) {
+                continue;
+            }
+            String materialUrl = jsonObject.getString("materialUrl");
+            String url = "";
+            if (!Check.isNull(materialUrl) && !materialUrl.contains("https:")) {
+                url = "https:" + materialUrl;
+            } else {
+                url = materialUrl;
+            }
+            String materialName = jsonObject.getString("materialName");
+            String videoUrl = URLDecoder.decode(url.replace("https://live-1301855440.cos.ap-chongqing.myqcloud.com/", ""));//  System.err.println(videoUrl);
+            String loadImage = "screenshot/" + signature + "/zero.jpg";
+            String coverUrl = cloudVideoProcessService.videoCutPictureHandle(videoUrl, loadImage);
+            JyMaterialList material = new JyMaterialList();
+            material.setSignature(signature);
+            material.setMaterialName(getFileNameNoEx(materialName));
+            material.setMaterialUrl(url);
+            material.setCoverUrl(coverUrl);
+            material.setMaterialStatus(1);
+            material.setUserId(userId);
+            material.setUserName(userName);
+            jyMaterialListMapper.insertJyMaterialList(material);
+            this.checkText(signature, url);
+        }
+    }
+
+    @Override
+    public List<JSONObject> getKeyWordList() {
+        return jyMaterialListMapper.getKeyWordList();
+    }
+
+    @Override
+    public void insertKeyWord(String type, String keyWord) {
+        jyMaterialListMapper.insertKeyWord(type,keyWord);
+        keyList = new ArrayList<>();
+    }
+
+    private void checkText(String signature, String videoUrl) {
+        uploadExecutorService.submit(new Runnable() {
+            @Override
+            public void run() {
+                JSONArray keyArray = new JSONArray();
+                Integer isKey = 2; // 2 未命中 3 命中
+                JyMaterialList updateMaterial = new JyMaterialList();
+                ResultResponse videoText = videoTextService.getVideoText(videoUrl);
+                if (!Check.isNull(videoText)) {
+                    String data = videoText.getData().toString();
+                    if (!Check.isNull(data)) {
+                        if (Check.isNull(keyList)) {
+                            getKeyList();
+                        }
+                        for (JSONObject keyJson : keyList) {
+                            String keyWord = keyJson.getString("keyWord");
+                            if (data.contains(keyWord)) {
+                                isKey = 3;
+                                keyArray.add(keyJson);
+                            }
+                        }
+                    }
+                    updateMaterial.setMaterialStatus(isKey);
+                    updateMaterial.setMaterialText(data);
+                    updateMaterial.setViolatingText(keyArray.toJSONString());
+                    updateMaterial.setSignature(signature);
+                } else {
+                    updateMaterial.setMaterialStatus(isKey);
+                    updateMaterial.setMaterialText(null);
+                    updateMaterial.setViolatingText(keyArray.toJSONString());
+                    updateMaterial.setSignature(signature);
+                }
+                jyMaterialListMapper.updateJyMaterialListBySignature(updateMaterial);
+                log.info("违规词判定成功,code:{}", signature);
+
+            }
+        });
+    }
+
+
+    private void getKeyList() {
+        keyList = jyMaterialListMapper.jyMaterialListMapper();
+        getKeyList();
+    }
+
+    private String getFileNameNoEx(String filename) {
+        if ((filename != null) && (filename.length() > 0)) {
+            int dot = filename.lastIndexOf('.');
+            if ((dot > -1) && (dot < (filename.length()))) {
+                return filename.substring(0, dot);
+            }
+        }
+        return filename;
+    }
+}
+

+ 14 - 0
ruixuan-live/src/main/java/com/ruixuan/jiaoyang/utils/CosConstant.java

@@ -0,0 +1,14 @@
+package com.ruixuan.jiaoyang.utils;
+
+public class CosConstant {
+
+    //数据万象URL
+    public static final String URL="https://live-1301855440.ci.ap-chongqing.myqcloud.com/";
+
+    //snapshot接口URL
+    public static final String URL_SNAPSHOT=URL+"snapshot";
+
+    //COS首帧地址
+    public static final String URL_COS_ADDRESS="https://live-1301855440.cos.ap-chongqing.myqcloud.com/";
+
+}

BIN
ruixuan-live/src/main/resources/lib/jave-1.0.jar


+ 144 - 0
ruixuan-live/src/main/resources/mapper/jiaoyang/JyMaterialListMapper.xml

@@ -0,0 +1,144 @@
+<?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="com.ruixuan.jiaoyang.mapper.JyMaterialListMapper">
+
+    <resultMap type="com.ruixuan.jiaoyang.entity.JyMaterialList" id="JyMaterialListResult">
+        <result property="id" column="id"/>
+        <result property="signature" column="signature"/>
+        <result property="materialName" column="material_name"/>
+        <result property="coverUrl" column="cover_url"/>
+        <result property="materialUrl" column="material_url"/>
+        <result property="userId" column="user_id"/>
+        <result property="userName" column="user_name"/>
+        <result property="materialStatus" column="material_status"/>
+        <result property="materialText" column="material_text"/>
+        <result property="violatingText" column="violating_text"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateTime" column="update_time"/>
+    </resultMap>
+
+    <sql id="selectJyMaterialListVo">
+        select id, signature, material_name, cover_url, material_url, user_id, user_name, material_status, material_text, violating_text, create_time, update_time from jy_material_list
+    </sql>
+
+    <select id="selectJyMaterialListList" parameterType="com.ruixuan.jiaoyang.entity.JyMaterialList"
+            resultMap="JyMaterialListResult">
+        <include refid="selectJyMaterialListVo"/>
+        where 1 = 1
+        <if test="signature != null  and signature != ''">and signature = #{signature}</if>
+        <if test="materialName != null  and materialName != ''">and material_name like concat('%', #{materialName},
+            '%')
+        </if>
+
+        <if test="userId != null  and userId != ''">and user_id = #{userId}</if>
+        <if test="userName != null  and userName != ''">and user_name like concat('%', #{userName}, '%')</if>
+        <if test="materialStatus != null ">and material_status = #{materialStatus}</if>
+        <if test="startDate != null ">and create_time &gt;= str_to_date(concat(#{startDate},' 00:00:01'),'%Y-%m-%d
+            %H:%i:%s')
+        </if>
+        <if test="endDate != null ">and create_time &lt;= str_to_date(concat(#{startDate},' 23:59:59'),'%Y-%m-%d
+            %H:%i:%s')
+        </if>
+        order by create_time desc
+    </select>
+
+    <select id="selectJyMaterialListById" parameterType="Long" resultMap="JyMaterialListResult">
+        <include refid="selectJyMaterialListVo"/>
+        where id = #{id}
+    </select>
+    <select id="checkMaterial" resultType="java.lang.Integer" parameterType="java.lang.String">
+        select  count(1)  from jy_material_list where signature = #{signature}
+
+    </select>
+    <select id="jyMaterialListMapper" resultType="com.alibaba.fastjson.JSONObject">
+        select  type as 'type',key_word as 'keyWord'  from sensitive_key_word
+    </select>
+    <select id="getKeyWordList" resultType="com.alibaba.fastjson.JSONObject">
+        select  *  from  sensitive_key_word  group by key_word  order by `type`
+    </select>
+
+    <insert id="insertJyMaterialList" parameterType="com.ruixuan.jiaoyang.entity.JyMaterialList" useGeneratedKeys="true"
+            keyProperty="id">
+        insert into jy_material_list
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="signature != null">signature,</if>
+            <if test="materialName != null">material_name,</if>
+            <if test="coverUrl != null">cover_url,</if>
+            <if test="materialUrl != null">material_url,</if>
+            <if test="userId != null">user_id,</if>
+            <if test="userName != null">user_name,</if>
+            <if test="materialStatus != null">material_status,</if>
+            <if test="materialText != null">material_text,</if>
+            <if test="violatingText != null">violating_text,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateTime != null">update_time,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="signature != null">#{signature},</if>
+            <if test="materialName != null">#{materialName},</if>
+            <if test="coverUrl != null">#{coverUrl},</if>
+            <if test="materialUrl != null">#{materialUrl},</if>
+            <if test="userId != null">#{userId},</if>
+            <if test="userName != null">#{userName},</if>
+            <if test="materialStatus != null">#{materialStatus},</if>
+            <if test="materialText != null">#{materialText},</if>
+            <if test="violatingText != null">#{violatingText},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+        </trim>
+    </insert>
+    <insert id="insertKeyWord">
+        insert into  sensitive_key_word(`type`,key_word) values (
+        #{type},
+        #{keyWord}
+        )
+    </insert>
+
+    <update id="updateJyMaterialList" parameterType="com.ruixuan.jiaoyang.entity.JyMaterialList">
+        update jy_material_list
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="signature != null">signature = #{signature},</if>
+            <if test="materialName != null">material_name = #{materialName},</if>
+            <if test="coverUrl != null">cover_url = #{coverUrl},</if>
+            <if test="materialUrl != null">material_url = #{materialUrl},</if>
+            <if test="userId != null">user_id = #{userId},</if>
+            <if test="userName != null">user_name = #{userName},</if>
+            <if test="materialStatus != null">material_status = #{materialStatus},</if>
+            <if test="materialText != null">material_text = #{materialText},</if>
+            <if test="violatingText != null">violating_text = #{violatingText},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+        </trim>
+        where id = #{id}
+    </update>
+    <update id="updateJyMaterialListBySignature" parameterType="com.ruixuan.jiaoyang.entity.JyMaterialList">
+        update jy_material_list
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="materialName != null">material_name = #{materialName},</if>
+            <if test="coverUrl != null">cover_url = #{coverUrl},</if>
+            <if test="materialUrl != null">material_url = #{materialUrl},</if>
+            <if test="userId != null">user_id = #{userId},</if>
+            <if test="userName != null">user_name = #{userName},</if>
+            <if test="materialStatus != null">material_status = #{materialStatus},</if>
+            <if test="materialText != null">material_text = #{materialText},</if>
+            <if test="violatingText != null">violating_text = #{violatingText},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+        </trim>
+        where signature = #{signature}
+
+    </update>
+
+    <delete id="deleteJyMaterialListById" parameterType="Long">
+        delete from jy_material_list where id = #{id}
+    </delete>
+
+    <delete id="deleteJyMaterialListByIds" parameterType="String">
+        delete from jy_material_list where id in
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+</mapper>