package com.cloud.retrieve.controller;
|
|
import com.alibaba.fastjson.JSONObject;
|
import com.cloud.model.common.Result;
|
import com.cloud.retrieve.service.AnalyDevService;
|
import com.cloud.retrieve.utils.EnumStr;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import lombok.extern.slf4j.Slf4j;
|
import org.apache.commons.lang3.StringUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.http.MediaType;
|
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import javax.servlet.http.HttpServletRequest;
|
import java.text.ParseException;
|
import java.util.Map;
|
|
/**
|
* 查看大图 查看视频
|
*/
|
@Slf4j
|
@Api(value = "EsDataBaseController",description = " 查看大图 查看视频")
|
@RestController
|
@RequestMapping("/data/api-r/dev")
|
public class DevInfoController {
|
|
@Autowired
|
private AnalyDevService analyDevService;
|
@Autowired
|
private EnumStr enumStr;
|
|
@ApiOperation(value = "getBigPic",notes =
|
"查看大图 {\"videoNum\":\"DS-2CD2T46WDA2-I20180622AACHC30488278\",\"picDate\":\"2019-02-12 06:59:52:505\"," +
|
"\"videoIp\":\"192.168.1.182\",\"indeviceid\":\"DSVAD010120181115\",\"imgKey\":\"DS-2CD2T46WDA2-I20180622AACHC30488278$2019-02-12-06-59-52_22803272\"}",
|
httpMethod = "POST",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
@RequestMapping("/getBigPic")
|
public Result getBigPic(@RequestBody Map reqMap, HttpServletRequest req) throws ParseException {
|
String videoNum = (String) reqMap.get("videoNum");
|
String picDate = (String) reqMap.get("picDate");
|
String videoIp = (String) reqMap.get("videoIp");
|
String imgKey = (String) reqMap.get("imgKey");
|
Object indeviceid = reqMap.get("indeviceid");
|
if (videoNum == null ||videoNum.isEmpty()|| picDate == null|| picDate.isEmpty()||
|
((videoIp == null|| videoIp.isEmpty() ))){
|
throw new RuntimeException("查看大图参数 videoNum:"+videoNum+",picDate:"+picDate+
|
",videoIp:"+videoIp+"为空。");
|
}
|
log.info("查看大图参数videoNum:"+videoNum+",picDate:"+picDate+
|
",videoIp:"+videoIp+"indeviceid:"+indeviceid+"imgKey:"+imgKey);
|
JSONObject respView = analyDevService.getBigPic(videoNum,picDate,videoIp,indeviceid != null?indeviceid.toString():null,imgKey);
|
if ( respView.getString("img_url")!= null){
|
String file_path = respView.getString("img_url");
|
file_path = enumStr.getHttpImgUrl() +":"+enumStr.getHttpImgPort()+"/"+file_path; // 80 44280
|
log.info("查看大图;file_path:"+file_path);
|
respView.put("imgurl",file_path);
|
return Result.ok("查看大图成功。",respView);
|
}else {
|
return Result.error(new RuntimeException(respView.getString("error")));
|
}
|
}
|
|
@ApiOperation(value = "getVideoByCServer",notes =
|
"查看视频{\"videoNum\":\"DS-2CD2T46WDA2-I20180622AACHC30488278\",\"picDate\":\"2019-02-12 06:59:52:505\"," +
|
"\"videoIp\":\"192.168.1.182\",\"indeviceid\":\"DSVAD010120181115\",\"imgKey\":\"DS-2CD2T46WDA2-I20180622AACHC30488278$2019-02-12-06-59-52_22803272\"}",
|
httpMethod = "POST",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
@RequestMapping("/getVideoByCServer")
|
public Result getUploadRtnVideo(@RequestBody Map reqMap, HttpServletRequest req) throws ParseException {
|
String videoNum = (String) reqMap.get("videoNum");
|
String picDate = (String) reqMap.get("picDate");
|
String videoIp = (String) reqMap.get("videoIp");
|
String imgKey = (String) reqMap.get("imgKey");
|
String indeviceid = (String) reqMap.get("indeviceid");
|
if (videoNum == null ||videoNum.isEmpty()|| picDate == null|| picDate.isEmpty()||
|
((videoIp == null|| videoIp.isEmpty() )&&( indeviceid == null||indeviceid.isEmpty() ))){
|
throw new RuntimeException("查看视频参数 videoNum:"+videoNum+",picDate:"+picDate+
|
",videoIp:"+videoIp+"indeviceid:"+indeviceid+"为空。");
|
}
|
log.info("查看视频参数videoNum:"+videoNum+",picDate:"+picDate+
|
",videoIp:"+videoIp+"indeviceid:"+indeviceid);
|
JSONObject respView = analyDevService.getVideo(videoNum,picDate,videoIp,indeviceid,imgKey);
|
if ( respView.getString("file_path")!= null && respView.getString("file_path").contains("/cut")){
|
String file_path = respView.getString("file_path");
|
log.info("c返回数据:"+file_path);
|
// String netPath = req.getScheme()+"://"+req.getServerName() /*"http://"+PropUtils.getProperty("cserver_web_host")*/ // req.getServerName()
|
// + respView.getString("filepath");; // nginxHttpPort
|
// respView.put("filepath",netPath);
|
// log.info("返回页面数据:"+netPath);
|
// log.info("视频地址:"+file_path);
|
return Result.ok("查看视频成功。",respView);
|
}else {
|
return Result.error(new RuntimeException(respView.getString("error")));
|
}
|
}
|
|
|
@ApiOperation(value = "getDevSnapshot",notes =
|
"获取实时流截图{\"devId\":\"DS-2CD2T46WDA2-I20180622AACHC30488278\"}",
|
httpMethod = "POST",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
@RequestMapping("/getDevSnapshot")
|
public Result getDevSnapshot(@RequestBody Map reqMap, HttpServletRequest req) throws ParseException {
|
String devId = (String) reqMap.get("devId");
|
if (StringUtils.isBlank(devId)){
|
throw new RuntimeException("获取实时流截图 devId:"+devId+"为空。");
|
}
|
log.info("获取实时流截图 devId:"+devId);
|
Result respView = analyDevService.getDevSnapshot(devId);
|
return respView;
|
}
|
}
|