AvsampleCallBackControllerApi.java
2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package com.cnlive.shenhe.api;
import com.alibaba.fastjson.JSONObject;
import com.cnlive.shenhe.entity.ShyVideos;
import com.cnlive.shenhe.service.VideosService;
import com.cnlive.shenhe.utils.CommonConst;
import com.cnlive.shenhe.utils.CommonUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
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.ResponseBody;
import java.util.List;
/**
* @author Administrator
* @Auther: 周伟鹏
* @Date: 2018/12/21 13:43
* @Description:抽帧回调接口
*/
@Controller
@RequestMapping("/api/avsample")
public class AvsampleCallBackControllerApi {
private static Logger logger = LoggerFactory.getLogger(AvsampleCallBackControllerApi.class);
@Autowired
VideosService videosService;
/**
* 接收抽帧结果
*
* @param json
*/
@PostMapping("/callback")
@ResponseBody
public JSONObject callback(@RequestBody JSONObject json) {
JSONObject result = new JSONObject();
result.put("code", 1);
try {
logger.info("抽帧回调请求。。。。json=={}", json.toJSONString());
String taskId = json.getString("taskId");
if (CommonUtils.isNotEmpty(taskId)) {
ShyVideos shyVideo = new ShyVideos();
shyVideo.setTask_id(taskId);
List<ShyVideos> shyVideosList = videosService.findShyVideo(shyVideo);
if (!shyVideosList.isEmpty()) {
ShyVideos video = shyVideosList.get(0);
Integer code = json.getInteger("code");
if (code == 3) {
video.setAvsample(CommonConst.AVSAMPLE_SUCCESS);
video.setAvsample_imgs(json.getJSONArray("images").toJSONString());
} else {
//抽帧失败
video.setAvsample(CommonConst.AVSAMPLE_FAIL);
//改为人工审核
video.setShenhe_type(CommonConst.AUDIT_TYPE_USER);
video.setMsg("抽帧失败,改为人工审核,失败消息:" + json.getString("errorMsg"));
}
video.setAvsample_msg(json.toJSONString());
boolean success = videosService.updateShyVideos(video);
if (!success) {
result.put("code", -1);
}
}
}
return result;
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
}