Commit 30aff1b1dc8454fa63625f59d752d0b913db6968

Authored by 周伟鹏
2 parents 6dcf9db4 543bc3d2

Merge branch 'dev'

src/main/java/com/cnlive/shenhe/api/VideosControllerApi.java
@@ -72,6 +72,8 @@ public class VideosControllerApi { @@ -72,6 +72,8 @@ public class VideosControllerApi {
72 //g得到视频id去查询是否已有 72 //g得到视频id去查询是否已有
73 String videoId = json.getString("videoId"); 73 String videoId = json.getString("videoId");
74 shyVideos1.setVideo_id(videoId); 74 shyVideos1.setVideo_id(videoId);
  75 + Integer duration = json.getInteger("duration");
  76 + if (CommonUtils.isNotNull(duration)) duration = duration / 1000;
75 //查询一下 存在,更新 没有,插入 77 //查询一下 存在,更新 没有,插入
76 List<ShyVideos> listshyVideos = videosService.findshyVideo(shyVideos1); 78 List<ShyVideos> listshyVideos = videosService.findshyVideo(shyVideos1);
77 if (listshyVideos.size() > 0) { 79 if (listshyVideos.size() > 0) {
@@ -96,6 +98,7 @@ public class VideosControllerApi { @@ -96,6 +98,7 @@ public class VideosControllerApi {
96 shyVideos.setState(CommonConst.AUDIT_INTT); 98 shyVideos.setState(CommonConst.AUDIT_INTT);
97 shyVideos.setBucket(json.getString("bucketName")); 99 shyVideos.setBucket(json.getString("bucketName"));
98 shyVideos.setPlat(json.getInteger("bucketType")); 100 shyVideos.setPlat(json.getInteger("bucketType"));
  101 + shyVideos.setDuration(duration);
99 boolean YorN = videosService.updateshyVideos(shyVideos); 102 boolean YorN = videosService.updateshyVideos(shyVideos);
100 if (YorN == true) { 103 if (YorN == true) {
101 return new ResponseBean(ErrorEnum.SUCCESS); 104 return new ResponseBean(ErrorEnum.SUCCESS);
@@ -110,6 +113,10 @@ public class VideosControllerApi { @@ -110,6 +113,10 @@ public class VideosControllerApi {
110 shyVideos1.setVideo_imgs(videoCoverUrl); 113 shyVideos1.setVideo_imgs(videoCoverUrl);
111 if (CommonUtils.isNotEmpty(videoCoverUrl)) { 114 if (CommonUtils.isNotEmpty(videoCoverUrl)) {
112 String poster = json.getJSONObject("videoCoverUrl").getString("224*126"); 115 String poster = json.getJSONObject("videoCoverUrl").getString("224*126");
  116 + if (CommonUtils.isEmpty(poster)) {
  117 + //ugc短视频只有一张图片
  118 + poster = json.getJSONObject("videoCoverUrl").getString("key");
  119 + }
113 shyVideos1.setVideo_poster(poster); 120 shyVideos1.setVideo_poster(poster);
114 } 121 }
115 shyVideos1.setVideo_desc(json.getString("videoIntro")); 122 shyVideos1.setVideo_desc(json.getString("videoIntro"));
@@ -122,7 +129,10 @@ public class VideosControllerApi { @@ -122,7 +129,10 @@ public class VideosControllerApi {
122 shyVideos1.setState(CommonConst.AUDIT_INTT); 129 shyVideos1.setState(CommonConst.AUDIT_INTT);
123 shyVideos1.setBucket(json.getString("bucketName")); 130 shyVideos1.setBucket(json.getString("bucketName"));
124 shyVideos1.setPlat(json.getInteger("bucketType")); 131 shyVideos1.setPlat(json.getInteger("bucketType"));
125 - shyVideos1 = avsample(shyVideos1);//请求抽帧 132 + shyVideos1.setDuration(duration);
  133 + if (CommonUtils.isNotNull(duration) && duration > 80) {
  134 + shyVideos1 = avsample(shyVideos1);//视频至少可以抽8张,请求抽帧
  135 + }
126 boolean result = videosService.impotVideo(shyVideos1); 136 boolean result = videosService.impotVideo(shyVideos1);
127 if (result == true) { 137 if (result == true) {
128 return new ResponseBean(ErrorEnum.SUCCESS); 138 return new ResponseBean(ErrorEnum.SUCCESS);
@@ -147,13 +157,14 @@ public class VideosControllerApi { @@ -147,13 +157,14 @@ public class VideosControllerApi {
147 157
148 String path = video_url.replace("//", ""); 158 String path = video_url.replace("//", "");
149 path = path.substring(path.indexOf("/"), path.length()); 159 path = path.substring(path.indexOf("/"), path.length());
150 - String domian = video_url.replace(path,""); 160 + String domian = video_url.replace(path, "");
151 path = "/" + bucket + path; 161 path = "/" + bucket + path;
152 162
153 JSONObject attach = new JSONObject(); 163 JSONObject attach = new JSONObject();
154 JSONObject extParam = new JSONObject(); 164 JSONObject extParam = new JSONObject();
155 - attach.put("num", 24);  
156 - extParam.put("domain",domian); 165 + attach.put("interval", 10);
  166 + attach.put("strategy", 1);
  167 + extParam.put("domain", domian);
157 if (CommonConst.KS_PLAT == plat) { 168 if (CommonConst.KS_PLAT == plat) {
158 //金山 169 //金山
159 params.put("plat", 0); 170 params.put("plat", 0);
@@ -185,7 +196,7 @@ public class VideosControllerApi { @@ -185,7 +196,7 @@ public class VideosControllerApi {
185 httpUtil.setParamMap(dataMap); 196 httpUtil.setParamMap(dataMap);
186 Map<String, String> resultMap = httpUtil.post(url); 197 Map<String, String> resultMap = httpUtil.post(url);
187 JSONObject result = JSON.parseObject(resultMap.get("result")); 198 JSONObject result = JSON.parseObject(resultMap.get("result"));
188 - logger.info("请求抽帧结果:result:{}",result); 199 + logger.info("请求抽帧结果:result:{}", result);
189 Integer code = result.getInteger("code"); 200 Integer code = result.getInteger("code");
190 if (code == 0) { 201 if (code == 0) {
191 video.setAvsample(CommonConst.AVSAMPLE_ING); 202 video.setAvsample(CommonConst.AVSAMPLE_ING);
src/main/java/com/cnlive/shenhe/entity/ShyVideos.java
1 package com.cnlive.shenhe.entity; 1 package com.cnlive.shenhe.entity;
2 2
3 -import javax.persistence.Id;  
4 -import javax.persistence.Table;  
5 -import javax.persistence.Transient;  
6 import java.util.Date; 3 import java.util.Date;
  4 +import javax.persistence.*;
7 5
8 @Table(name = "shy_videos") 6 @Table(name = "shy_videos")
9 public class ShyVideos { 7 public class ShyVideos {
@@ -126,8 +124,10 @@ public class ShyVideos { @@ -126,8 +124,10 @@ public class ShyVideos {
126 private Integer plat; 124 private Integer plat;
127 125
128 /** 126 /**
129 - * 审核员 127 + * 视频时长,单位s
130 */ 128 */
  129 + private Integer duration;
  130 +
131 @Transient 131 @Transient
132 private String auditor; 132 private String auditor;
133 133
@@ -600,4 +600,22 @@ public class ShyVideos { @@ -600,4 +600,22 @@ public class ShyVideos {
600 public void setPlat(Integer plat) { 600 public void setPlat(Integer plat) {
601 this.plat = plat; 601 this.plat = plat;
602 } 602 }
  603 +
  604 + /**
  605 + * 获取视频时长,单位s
  606 + *
  607 + * @return duration - 视频时长,单位s
  608 + */
  609 + public Integer getDuration() {
  610 + return duration;
  611 + }
  612 +
  613 + /**
  614 + * 设置视频时长,单位s
  615 + *
  616 + * @param duration 视频时长,单位s
  617 + */
  618 + public void setDuration(Integer duration) {
  619 + this.duration = duration;
  620 + }
603 } 621 }
604 \ No newline at end of file 622 \ No newline at end of file
src/main/java/com/cnlive/shenhe/job/UsersSiteJob.java
@@ -71,7 +71,7 @@ public class UsersSiteJob { @@ -71,7 +71,7 @@ public class UsersSiteJob {
71 //用户信息入库 71 //用户信息入库
72 JSONObject user = data.getJSONObject(i); 72 JSONObject user = data.getJSONObject(i);
73 Integer id = user.getInteger("sid"); 73 Integer id = user.getInteger("sid");
74 - String user_id = CommonUtils.md5(id+""); 74 + String user_id = CommonUtils.md5(id + "");
75 String email = user.getString("email"); 75 String email = user.getString("email");
76 Integer spid = user.getInteger("new_sp_id"); 76 Integer spid = user.getInteger("new_sp_id");
77 String userLogo = user.getString("userLogo"); 77 String userLogo = user.getString("userLogo");
@@ -108,10 +108,15 @@ public class UsersSiteJob { @@ -108,10 +108,15 @@ public class UsersSiteJob {
108 ShySites shySites = new ShySites(); 108 ShySites shySites = new ShySites();
109 shySites.setSpid(spid); 109 shySites.setSpid(spid);
110 List<ShySites> shySitesList = shySitesMapper.select(shySites); 110 List<ShySites> shySitesList = shySitesMapper.select(shySites);
111 - if(shySitesList.isEmpty()){ 111 + if (shySitesList.isEmpty()) {
112 shySites.setCompany(company); 112 shySites.setCompany(company);
113 shySites.setName(company_brief); 113 shySites.setName(company_brief);
114 shySitesMapper.insertSelective(shySites); 114 shySitesMapper.insertSelective(shySites);
  115 + }else if(CommonUtils.isEmpty(shySitesList.get(0).getCompany()) || CommonUtils.isEmpty(shySitesList.get(0).getName())){
  116 + shySites = shySitesList.get(0);
  117 + shySites.setCompany(company);
  118 + shySites.setName(company_brief);
  119 + shySitesMapper.updateByPrimaryKeySelective(shySites);
115 } 120 }
116 121
117 } 122 }
src/main/resources/mapper/ShyVideosMapper.xml
@@ -32,5 +32,6 @@ @@ -32,5 +32,6 @@
32 <result column="task_id" jdbcType="VARCHAR" property="task_id" /> 32 <result column="task_id" jdbcType="VARCHAR" property="task_id" />
33 <result column="bucket" jdbcType="VARCHAR" property="bucket" /> 33 <result column="bucket" jdbcType="VARCHAR" property="bucket" />
34 <result column="plat" jdbcType="INTEGER" property="plat" /> 34 <result column="plat" jdbcType="INTEGER" property="plat" />
  35 + <result column="duration" jdbcType="INTEGER" property="duration" />
35 </resultMap> 36 </resultMap>
36 </mapper> 37 </mapper>
37 \ No newline at end of file 38 \ No newline at end of file