Commit 8bb3a55c429472a574cc39d6daa747252655b389

Authored by 徐近程
2 parents 112bb003 3fe60a43

Merge branch 'dev'

# Conflicts:
#	src/main/java/com/cnlive/shenhe/api/YiDunControllerApi.java
#	src/main/java/com/cnlive/shenhe/entity/ShyYidun.java
#	src/main/java/com/cnlive/shenhe/job/VideosJob.java
#	src/main/java/com/cnlive/shenhe/mapper/ShyYidunMapper.java
#	src/main/java/com/cnlive/shenhe/serviceImpl/YiDunServiceImpl.java
src/main/java/com/cnlive/shenhe/api/YiDunControllerApi.java 0 → 100644
  1 +package com.cnlive.shenhe.api;
  2 +
  3 +import com.alibaba.fastjson.JSONObject;
  4 +import com.cnlive.shenhe.entity.ShyYidun;
  5 +import com.cnlive.shenhe.serviceImpl.YiDunServiceImpl;
  6 +import com.cnlive.shenhe.utils.HttpClientUtils;
  7 +import com.cnlive.shenhe.utils.YiDunAntiFraudUtil;
  8 +import org.slf4j.Logger;
  9 +import org.slf4j.LoggerFactory;
  10 +import org.springframework.beans.factory.annotation.Autowired;
  11 +import org.springframework.stereotype.Controller;
  12 +import org.springframework.web.bind.annotation.PostMapping;
  13 +import org.springframework.web.bind.annotation.RequestMapping;
  14 +import org.springframework.web.bind.annotation.ResponseBody;
  15 +
  16 +import java.util.*;
  17 +
  18 +/**
  19 + * @Author: xujincheng
  20 + * @Date: 2020/3/26 13:43
  21 + */
  22 +@Controller
  23 +@RequestMapping("/api/yiDun")
  24 +public class YiDunControllerApi {
  25 +
  26 + private static Logger logger = LoggerFactory.getLogger(YiDunControllerApi.class);
  27 +
  28 + @Autowired
  29 + YiDunServiceImpl yiDunServiceImpl;
  30 +
  31 + /**
  32 + * 网站地址URL产品密钥ID,产品标识
  33 + */
  34 + private final static String SECRETID = "c7f33c191020bcc9cbacb7d70417fd2f";
  35 + /**
  36 + * 网站地址URL产品私有密钥,服务端生成签名信息使用,请严格保管,避免泄露
  37 + */
  38 + private final static String SECRETKEY = "833222b4951a67a9bc63b5ed0c24d07d";
  39 + /**
  40 + * 网站地址URL提交接口地址
  41 + */
  42 + private final static String URL_SUBMIT = "https://as.dun.163yun.com/v1/crawler/submit";
  43 +
  44 + /**
  45 + * 向易盾提交网站检测地址(用于测试)
  46 + *
  47 + * @param url 网站地址
  48 + */
  49 + @PostMapping("/submitYiDunUrl")
  50 + @ResponseBody
  51 + public void submitYiDunUrl(String url) {
  52 + Map<String, String> params = new HashMap<String, String>();
  53 +
  54 + // 1.设置公共参数
  55 + params.put("secretId", SECRETID);
  56 + params.put("version", "v1.0");
  57 + params.put("timestamp", String.valueOf(System.currentTimeMillis()));
  58 + params.put("nonce", String.valueOf(new Random().nextInt()));
  59 +
  60 + // 2.设置私有参数
  61 + //数据唯一标识,能够根据该值定位到该条数据(查询作用)
  62 + params.put("dataId", UUID.randomUUID().toString());
  63 + //网页URL, 支持contentType类型: html、txt、doc、docx、ppt、pptx、xls、xlsx、pdf
  64 + params.put("url", url);
  65 + //1:检测文本,2:检测图片,同时检测文本+图片则以逗号分隔,例:1,2。
  66 + params.put("checkFlags", "1,2");
  67 + //不是必传参数
  68 + params.put("callback", UUID.randomUUID().toString());
  69 +
  70 + // 3.生成签名信息
  71 + String signature = YiDunAntiFraudUtil.genSignature(SECRETKEY, params);
  72 + params.put("signature", signature);
  73 +
  74 + // 4.发送HTTP请求
  75 + //String response = HttpClient4Utils.sendPost(httpClient, API_URL, params, Consts.UTF_8);
  76 + String s = HttpClientUtils.post_str(URL_SUBMIT, params);
  77 + logger.info("向易盾提交网站检测地址返回的结果:{}", s);
  78 + JSONObject jsonObject = JSONObject.parseObject(s);
  79 + int code = jsonObject.getIntValue("code");
  80 + String msg = jsonObject.getString("msg");
  81 + if (code == 200 && "ok".equals(msg)) {
  82 + JSONObject result = jsonObject.getJSONObject("result");
  83 + String dataId = result.getString("dataId");
  84 + ShyYidun shyYidun = new ShyYidun();
  85 + shyYidun.setId(dataId);
  86 + shyYidun.setCreate_time(new Date());
  87 + yiDunServiceImpl.addYiDunMsg(shyYidun);
  88 +
  89 + }
  90 +
  91 + }
  92 +}
... ...
src/main/java/com/cnlive/shenhe/entity/ShyYidun.java 0 → 100644
  1 +package com.cnlive.shenhe.entity;
  2 +
  3 +import java.util.Date;
  4 +import javax.persistence.*;
  5 +
  6 +@Table(name = "shy_yidun")
  7 +public class ShyYidun {
  8 + /**
  9 + * 网站审核-dataId 图文审核文本审核-taskId
  10 + */
  11 + @Id
  12 + private String id;
  13 +
  14 +
  15 + /**
  16 + * 视频内容id 网站内容id
  17 + */
  18 + private String content_id;
  19 +
  20 + /**
  21 + * 网站审核url
  22 + */
  23 + private String url;
  24 +
  25 + /**
  26 + * 审核结果 2:建议删除,1:建议审核,0:建议通过
  27 + */
  28 + private String result_type;
  29 +
  30 + /**
  31 + * 检测描述信息
  32 + */
  33 + private String desc_msg;
  34 +
  35 + /**
  36 + * 视频时长,单位s
  37 + */
  38 + private Integer duration;
  39 +
  40 + /**
  41 + * 创建时间
  42 + */
  43 + private Date create_time;
  44 +
  45 + /**
  46 + * 修改时间
  47 + */
  48 + private Date update_time;
  49 +
  50 + /**
  51 + * 获取网站审核-dataId 图文审核文本审核-taskId
  52 + *
  53 + * @return id - 网站审核-dataId 图文审核文本审核-taskId
  54 + */
  55 + public String getId() {
  56 + return id;
  57 + }
  58 +
  59 + /**
  60 + * 设置网站审核-dataId 图文审核文本审核-taskId
  61 + *
  62 + * @param id 网站审核-dataId 图文审核文本审核-taskId
  63 + */
  64 + public void setId(String id) {
  65 + this.id = id;
  66 + }
  67 +
  68 + /**
  69 + * 获取视频内容id 网站内容id
  70 + *
  71 + * @return content_id - 视频内容id 网站内容id
  72 + */
  73 + public String getContent_id() {
  74 + return content_id;
  75 + }
  76 +
  77 + /**
  78 + * 设置视频内容id 网站内容id
  79 + *
  80 + * @param content_id 视频内容id 网站内容id
  81 + */
  82 + public void setContent_id(String content_id) {
  83 + this.content_id = content_id;
  84 + }
  85 +
  86 + /**
  87 + * 获取网站审核url
  88 + *
  89 + * @return url - 网站审核url
  90 + */
  91 + public String getUrl() {
  92 + return url;
  93 + }
  94 +
  95 + /**
  96 + * 设置网站审核url
  97 + *
  98 + * @param url 网站审核url
  99 + */
  100 + public void setUrl(String url) {
  101 + this.url = url;
  102 + }
  103 +
  104 + /**
  105 + * 获取审核结果 2:建议删除,1:建议审核,0:建议通过
  106 + *
  107 + * @return result_type - 审核结果 2:建议删除,1:建议审核,0:建议通过
  108 + */
  109 + public String getResult_type() {
  110 + return result_type;
  111 + }
  112 +
  113 + /**
  114 + * 设置审核结果 2:建议删除,1:建议审核,0:建议通过
  115 + *
  116 + * @param result_type 审核结果 2:建议删除,1:建议审核,0:建议通过
  117 + */
  118 + public void setResult_type(String result_type) {
  119 + this.result_type = result_type;
  120 + }
  121 +
  122 + /**
  123 + * 获取检测描述信息
  124 + *
  125 + * @return desc_msg - 检测描述信息
  126 + */
  127 + public String getDesc_msg() {
  128 + return desc_msg;
  129 + }
  130 +
  131 + /**
  132 + * 设置检测描述信息
  133 + *
  134 + * @param desc_msg 检测描述信息
  135 + */
  136 + public void setDesc_msg(String desc_msg) {
  137 + this.desc_msg = desc_msg;
  138 + }
  139 +
  140 + /**
  141 + * 获取视频时长,单位s
  142 + *
  143 + * @return duration - 视频时长,单位s
  144 + */
  145 + public Integer getDuration() {
  146 + return duration;
  147 + }
  148 +
  149 + /**
  150 + * 设置视频时长,单位s
  151 + *
  152 + * @param duration 视频时长,单位s
  153 + */
  154 + public void setDuration(Integer duration) {
  155 + this.duration = duration;
  156 + }
  157 +
  158 + /**
  159 + * 获取创建时间
  160 + *
  161 + * @return create_time - 创建时间
  162 + */
  163 + public Date getCreate_time() {
  164 + return create_time;
  165 + }
  166 +
  167 + /**
  168 + * 设置创建时间
  169 + *
  170 + * @param create_time 创建时间
  171 + */
  172 + public void setCreate_time(Date create_time) {
  173 + this.create_time = create_time;
  174 + }
  175 +
  176 + /**
  177 + * 获取修改时间
  178 + *
  179 + * @return update_time - 修改时间
  180 + */
  181 + public Date getUpdate_time() {
  182 + return update_time;
  183 + }
  184 +
  185 + /**
  186 + * 设置修改时间
  187 + *
  188 + * @param update_time 修改时间
  189 + */
  190 + public void setUpdate_time(Date update_time) {
  191 + this.update_time = update_time;
  192 + }
  193 +
  194 + public ShyYidun() {
  195 + }
  196 +
  197 + public ShyYidun(String id, String content_id, String url, String result_type, String desc_msg, Integer duration, Date create_time, Date update_time) {
  198 + this.id = id;
  199 + this.content_id = content_id;
  200 + this.url = url;
  201 + this.result_type = result_type;
  202 + this.desc_msg = desc_msg;
  203 + this.duration = duration;
  204 + this.create_time = create_time;
  205 + this.update_time = update_time;
  206 + }
  207 +}
0 208 \ No newline at end of file
... ...
src/main/java/com/cnlive/shenhe/job/ContentJob.java
... ... @@ -74,6 +74,7 @@ public class ContentJob {
74 74 if (shyYidun1 == null) {
75 75 logger.info("定时发送易盾检测的content_id:" + content.getId());
76 76 contentService.contentFilter(content);
  77 +
77 78 }
78 79 }
79 80 }
... ...
src/main/java/com/cnlive/shenhe/job/VideosJob.java
... ... @@ -19,20 +19,20 @@ import java.util.List;
19 19  
20 20 @Component
21 21 public class VideosJob {
22   - private static Logger logger = LoggerFactory.getLogger(VideosJob.class);
23   - @Autowired
24   - SitesServiceImpl sitesService;
25   - @Autowired
26   - AuditPass Pass;
27   - @Autowired
28   - CommentsServiceImpl commentsService;
29   - @Autowired
30   - UsersServiceImpl usersService;
31   - @Autowired
32   - VideosServiceImpl videosService;
  22 + private static Logger logger = LoggerFactory.getLogger(VideosJob.class);
  23 + @Autowired
  24 + SitesServiceImpl sitesService;
  25 + @Autowired
  26 + AuditPass Pass;
  27 + @Autowired
  28 + CommentsServiceImpl commentsService;
  29 + @Autowired
  30 + UsersServiceImpl usersService;
  31 + @Autowired
  32 + VideosServiceImpl videosService;
33 33  
34 34  
35   - /**
  35 + /**
36 36 * 白名单sp视频通过
37 37 */
38 38 @Scheduled(fixedRate = 60 * 1000)
... ... @@ -43,52 +43,53 @@ public class VideosJob {
43 43 List<ShyVideos> shyVideosList = videosService.findshyVideo(shyVideos);
44 44 if (shyVideosList.size() > 0) {
45 45 for (ShyVideos video : shyVideosList) {
46   - logger.info("当前白名单通过的videos_id:"+video.getId());
  46 + logger.info("当前白名单通过的videos_id:"+video.getId());
47 47 video.setUpdater("白名单");
48 48 // 更新点播和审核的视频状态
49 49 videosService.updateDianboAndShenhe(video, 3);
50 50 }
51 51 }
52   - }
  52 + }
53 53  
54 54 /**
55   - * 定时发送数美检测视频
  55 + * 定时向易盾发送视频进行检测
56 56 */
57   - @Scheduled(cron="0 0/1 10-23 * * ? ")//每天10点到23点执行,每分钟一次
  57 + @Scheduled(cron = "0 0/1 10-23 * * ? ")//每天10点到23点执行,每分钟一次
58 58 public void videofilter() {
59 59 ShyVideos shyVideos = new ShyVideos();
60 60 shyVideos.setShenhe_type(CommonConst.AUDIT_TYPE_MACHANE);//审核类型为机审
61 61 shyVideos.setState(CommonConst.AUDIT_INTT);//待审核状态
62 62 shyVideos.setAvsample(CommonConst.AVSAMPLE_SUCCESS);//抽帧完成
63 63 List<ShyVideos> shyVideosList = videosService.findshyVideo(shyVideos);
64   - if (shyVideosList.size() > 0) {
  64 + if (shyVideosList != null && shyVideosList.size() > 0) {
65 65 for (ShyVideos video : shyVideosList) {
66   - logger.info("定时发送数美检测的videos_id:"+video.getId());
67   - //数美图片过滤
68   - videosService.videoFilter(video.getId(),CommonConst.DYNAMIC_USER);
69   - }
70   - }
71   - }
  66 + logger.info("定时向易盾发送检测视频的videos_id:" + video.getId());
  67 + //易盾图片过滤
  68 + videosService.videoFilter(video.getId());
72 69  
73   -
74   - /**
75   - * 自动退领
76   - */
77   - @Scheduled(cron="0 0 0 * * ? ")//每天0点执行
78   - public void autoRetReceive() {
79   - logger.info("点播自动退领的进入.....");
80   - ShyVideos shyVideos = new ShyVideos();
81   - shyVideos.setState(CommonConst.AUDIT_INTT);//审核状态:未审核
82   - shyVideos.setReceive(CommonConst.RECEIVE_AFTER);//已领取
83   - List<ShyVideos> shyVideosList = videosService.findshyVideo(shyVideos);
84   - if(shyVideosList.size()>0){
85   - for (ShyVideos shyVideos2 : shyVideosList) {
86   - logger.info("自动退领的videos_id:"+shyVideos2.getId());
87   - shyVideos2.setReceive(CommonConst.RECEIVE_BEFORE);//未领取
88   - shyVideos2.setReceive_user_id(null);
89   - videosService.updateshyVideos(shyVideos2);
90 70 }
91 71 }
92 72 }
93   -
94   -}
95 73 \ No newline at end of file
  74 +
  75 +
  76 + /**
  77 + * 自动退领
  78 + */
  79 + @Scheduled(cron="0 0 0 * * ? ")//每天0点执行
  80 + public void autoRetReceive() {
  81 + logger.info("点播自动退领的进入.....");
  82 + ShyVideos shyVideos = new ShyVideos();
  83 + shyVideos.setState(CommonConst.AUDIT_INTT);//审核状态:未审核
  84 + shyVideos.setReceive(CommonConst.RECEIVE_AFTER);//已领取
  85 + List<ShyVideos> shyVideosList = videosService.findshyVideo(shyVideos);
  86 + if(shyVideosList.size()>0){
  87 + for (ShyVideos shyVideos2 : shyVideosList) {
  88 + logger.info("自动退领的videos_id:"+shyVideos2.getId());
  89 + shyVideos2.setReceive(CommonConst.RECEIVE_BEFORE);//未领取
  90 + shyVideos2.setReceive_user_id(null);
  91 + videosService.updateshyVideos(shyVideos2);
  92 + }
  93 + }
  94 + }
  95 +
  96 +}
... ...
src/main/java/com/cnlive/shenhe/mapper/ShyYidunMapper.java 0 → 100644
  1 +package com.cnlive.shenhe.mapper;
  2 +
  3 +import com.cnlive.shenhe.entity.ShyYidun;
  4 +import tk.mybatis.mapper.common.Mapper;
  5 +
  6 +public interface ShyYidunMapper extends Mapper<ShyYidun> {
  7 +
  8 +}
0 9 \ No newline at end of file
... ...
src/main/java/com/cnlive/shenhe/serviceImpl/YiDunServiceImpl.java 0 → 100644
  1 +package com.cnlive.shenhe.serviceImpl;
  2 +
  3 +import com.cnlive.shenhe.entity.ShyYidun;
  4 +import com.cnlive.shenhe.mapper.ShyYidunMapper;
  5 +import com.cnlive.shenhe.utils.CommonUtils;
  6 +import org.slf4j.Logger;
  7 +import org.slf4j.LoggerFactory;
  8 +import org.springframework.beans.factory.annotation.Autowired;
  9 +import org.springframework.stereotype.Service;
  10 +
  11 +import java.util.List;
  12 +
  13 +/**
  14 + * @Author: xujincheng
  15 + * @Date: 2020/3/27 17:31
  16 + */
  17 +@Service
  18 +public class YiDunServiceImpl {
  19 +
  20 + private static Logger logger = LoggerFactory.getLogger(YiDunServiceImpl.class);
  21 +
  22 +
  23 + @Autowired
  24 + ShyYidunMapper shyYidunMapper;
  25 +
  26 + public boolean addYiDunMsg(ShyYidun shyYidun) {
  27 + int result = shyYidunMapper.insert(shyYidun);
  28 + if (result == 0) {
  29 + return false;
  30 + }
  31 + return true;
  32 + }
  33 +
  34 + public ShyYidun getidunMsgByContentId(ShyYidun shyYidun) {
  35 + List<ShyYidun> shyContentList = shyYidunMapper.select(shyYidun);
  36 + if (CommonUtils.isNotNull(shyContentList) && shyContentList.size() > 0) {
  37 + return shyContentList.get(0);
  38 + }
  39 + return null;
  40 + }
  41 +
  42 + public ShyYidun getYiDunMsg(String dataId) {
  43 + return shyYidunMapper.selectByPrimaryKey(dataId);
  44 + }
  45 +
  46 + public boolean updateYiDunMsg(ShyYidun shyYidun) {
  47 + int result = shyYidunMapper.updateByPrimaryKeySelective(shyYidun);
  48 + if (result == 0) {
  49 + return false;
  50 + }
  51 + return true;
  52 +
  53 + }
  54 +}
... ...