|
@ -0,0 +1,254 @@
|
|
|
package com.yihu.jw.care.endpoint;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.yihu.jw.care.common.BaseController;
|
|
|
import com.yihu.jw.care.service.YsDeviceService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.io.BufferedReader;
|
|
|
import java.io.InputStream;
|
|
|
import java.io.InputStreamReader;
|
|
|
|
|
|
/**
|
|
|
* Created by Bing on 2021/6/1.
|
|
|
*/
|
|
|
@RestController
|
|
|
@RequestMapping("ys/device")
|
|
|
@Api(value = "萤石设备设备相关服务", description = "设备相关服务")
|
|
|
public class YsDeviceController extends BaseController {
|
|
|
|
|
|
private static org.slf4j.Logger logger = LoggerFactory.getLogger(YsDeviceController.class);
|
|
|
|
|
|
@Autowired
|
|
|
private YsDeviceService ysDeviceService;
|
|
|
|
|
|
|
|
|
@ApiOperation("萤石摄像机消息通知数据接收")
|
|
|
@RequestMapping(value = "pushdata", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
|
|
|
public String pushdata(
|
|
|
HttpServletRequest request) {
|
|
|
try {
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
BufferedReader in=new BufferedReader(new InputStreamReader(request.getInputStream(),"UTF-8"));
|
|
|
String line = null;
|
|
|
while ((line = in.readLine()) != null) {
|
|
|
sb.append(line);
|
|
|
}
|
|
|
|
|
|
return write(200,"查询成功","data",ysDeviceService.pushdata(sb.toString(),request));
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return error(-1,"error");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
@ApiOperation("摄像机通道详情")
|
|
|
@RequestMapping(value = "surveillanceWay", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
|
|
|
public String surveillanceWay(
|
|
|
@ApiParam(name="deviceSerial",required = true,value="设备序列号")
|
|
|
@RequestParam(value = "deviceSerial",required = true) String deviceSerial,
|
|
|
@ApiParam(name="channelNo",required = false,value="设备通道号,默认为1")
|
|
|
@RequestParam(value = "channelNo",required = false,defaultValue = "1") Integer channelNo,
|
|
|
@ApiParam(name="isTrust",required = false,value="是否托管设备:0-非托管,1-托管,默认0")
|
|
|
@RequestParam(value = "isTrust",required = false,defaultValue = "0") Integer isTrust,
|
|
|
HttpServletRequest request) {
|
|
|
try {
|
|
|
String paraString = JSON.toJSONString(request.getParameterMap());
|
|
|
logger.info("萤石摄像机获取通道详情,请求参数:\n"+paraString);
|
|
|
|
|
|
return write(200,"查询成功","data",ysDeviceService.surveillanceWay(deviceSerial,channelNo,isTrust,request));
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return error(-1,"error");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@ApiOperation("获取摄像头直播加密Id")
|
|
|
@RequestMapping(value = "surveillanceWayAddress", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
|
|
|
public String surveillanceWayAddress(
|
|
|
@ApiParam(name="deviceSerial",required = true,value="设备序列号")
|
|
|
@RequestParam(value = "deviceSerial",required = true) String[] deviceSerial,
|
|
|
@ApiParam(name="channelNo",required = false,value="设备通道号,默认为1")
|
|
|
@RequestParam(value = "channelNo",required = false,defaultValue = "1") Integer channelNo,
|
|
|
HttpServletRequest request){
|
|
|
try {
|
|
|
String paraString = JSON.toJSONString(request.getParameterMap());
|
|
|
logger.info("萤石摄像机获取直播加密Id,请求参数:\n"+paraString);
|
|
|
|
|
|
return write(200,"查询成功","data",ysDeviceService.surveillanceWayAddress(deviceSerial,channelNo,request));
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
return error(-1,"error");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@ApiOperation("跌倒检测")
|
|
|
@RequestMapping(value = "deviceFailConfig", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
|
|
|
public String surveillanceWayAddress(
|
|
|
@ApiParam(name="deviceSerial",required = true,value="设备序列号")
|
|
|
@RequestParam(value = "deviceSerial",required = true) String deviceSerial,
|
|
|
@ApiParam(name="type",required = false,value="0-人或车检测,1-人形检测,2-车检测,3-画面变化检测,4-人脸检测,5-智能人体检测,6-宠物检测,7-跌倒检测")
|
|
|
@RequestParam(value = "type",required = false) Integer type,
|
|
|
HttpServletRequest request){
|
|
|
try {
|
|
|
String paraString = JSON.toJSONString(request.getParameterMap());
|
|
|
logger.info("跌倒检测,请求参数:\n"+paraString);
|
|
|
|
|
|
return write(200,"查询成功","data",ysDeviceService.deviceFailConfig(deviceSerial,type,request));
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
return error(-1,"error");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@ApiOperation("视频加解密")
|
|
|
@RequestMapping(value = "deviceEncrypt", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
|
|
|
public String deviceEncrypt(
|
|
|
@ApiParam(name="deviceSerial",required = true,value="设备序列号")
|
|
|
@RequestParam(value = "deviceSerial",required = true) String deviceSerial,
|
|
|
@ApiParam(name="isEncrypt",required = true,value="0-关闭,1-开启")
|
|
|
@RequestParam(value = "isEncrypt",required = true) Integer isEncrypt,
|
|
|
@ApiParam(name="validateCode",required = false,value="设备验证码,当isEncrypt=0时,需要传递此参数")
|
|
|
@RequestParam(value = "validateCode",required = false) String validateCode,
|
|
|
HttpServletRequest request){
|
|
|
try {
|
|
|
|
|
|
if (0==isEncrypt&& StringUtils.isBlank(validateCode)){
|
|
|
return error(-1,"参数错误");
|
|
|
}
|
|
|
String paraString = JSON.toJSONString(request.getParameterMap());
|
|
|
logger.info("视频加解密开关,请求参数:\n"+paraString);
|
|
|
|
|
|
return write(200,"查询成功","data",ysDeviceService.deviceEncrypt(deviceSerial,isEncrypt,validateCode,request));
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
return error(-1,"error");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@ApiOperation("设备有效直播地址")
|
|
|
@RequestMapping(value = "getDeviceLiveAddress", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
|
|
|
public String getDeviceLiveAddress(
|
|
|
@ApiParam(name="deviceSerial",required = true,value="设备序列号")
|
|
|
@RequestParam(value = "deviceSerial",required = true) String deviceSerial,
|
|
|
@ApiParam(name="channelNo",required = true,value="通道号,IPC设备填1")
|
|
|
@RequestParam(value = "channelNo",required = true) Integer channelNo,
|
|
|
HttpServletRequest request){
|
|
|
try {
|
|
|
|
|
|
String paraString = JSON.toJSONString(request.getParameterMap());
|
|
|
logger.info("获取设备有效直播地址,请求参数:\n"+paraString);
|
|
|
|
|
|
return write(200,"查询成功","data",ysDeviceService.getDeviceLiveAddress(deviceSerial,channelNo,request));
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
return error(-1,"error");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@ApiOperation("设备云台控制开始")//操作后都需要调用停止接口 才会停止转动
|
|
|
@RequestMapping(value = "ptzStart", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
|
|
|
public String ptzStart(
|
|
|
@ApiParam(name="deviceSerial",required = true,value="设备序列号")
|
|
|
@RequestParam(value = "deviceSerial",required = true) String deviceSerial,
|
|
|
@ApiParam(name="channelNo",required = true,value="通道号,IPC设备填1")
|
|
|
@RequestParam(value = "channelNo",required = true) Integer channelNo,
|
|
|
@ApiParam(name="direction",required = true,value="0-上,1-下,2-左,3-右,4-左上,5-左下,6-右上,7-右下,8-放大,9-缩小,10-近焦距,11-远焦距")
|
|
|
@RequestParam(value = "direction",required = true) Integer direction,
|
|
|
@ApiParam(name="speed",required = true,value="云台速度:0-慢,1-适中,2-快,海康设备参数不可为0")
|
|
|
@RequestParam(value = "speed",required = true) Integer speed,
|
|
|
HttpServletRequest request){
|
|
|
try {
|
|
|
|
|
|
String paraString = JSON.toJSONString(request.getParameterMap());
|
|
|
logger.info("设备云台控制开始,请求参数:\n"+paraString);
|
|
|
|
|
|
return write(200,"查询成功","data",ysDeviceService.ptzStart(deviceSerial,channelNo,direction,speed,request));
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
return error(-1,"error");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@ApiOperation("设备云台控制结束")
|
|
|
@RequestMapping(value = "ptzStop", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
|
|
|
public String ptzStop(
|
|
|
@ApiParam(name="deviceSerial",required = true,value="设备序列号")
|
|
|
@RequestParam(value = "deviceSerial",required = true) String deviceSerial,
|
|
|
@ApiParam(name="channelNo",required = true,value="通道号,IPC设备填1")
|
|
|
@RequestParam(value = "channelNo",required = true) Integer channelNo,
|
|
|
@ApiParam(name="direction",required = true,value="0-上,1-下,2-左,3-右,4-左上,5-左下,6-右上,7-右下,8-放大,9-缩小,10-近焦距,11-远焦距")
|
|
|
@RequestParam(value = "direction",required = true) Integer direction,
|
|
|
HttpServletRequest request){
|
|
|
try {
|
|
|
|
|
|
String paraString = JSON.toJSONString(request.getParameterMap());
|
|
|
logger.info("设备云台控制结束,请求参数:\n"+paraString);
|
|
|
|
|
|
return write(200,"查询成功","data",ysDeviceService.ptzStop(deviceSerial,channelNo,direction,request));
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
return error(-1,"error");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@ApiOperation("获取录像accessToken")
|
|
|
@RequestMapping(value = "getVideoKey", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
|
|
|
public String getVideoKey(
|
|
|
HttpServletRequest request){
|
|
|
try {
|
|
|
|
|
|
String paraString = JSON.toJSONString(request.getParameterMap());
|
|
|
logger.info("获取录像accessToken,请求参数:\n"+paraString);
|
|
|
|
|
|
return write(200,"查询成功","data",ysDeviceService.getVideoKey(request));
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
return error(-1,"error");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@ApiOperation("上传录像")
|
|
|
@RequestMapping(value = "videoUpload", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
|
|
|
public String videoUpload(
|
|
|
HttpServletRequest request,
|
|
|
@ApiParam(value = "文件", required = true)
|
|
|
@RequestParam(value = "file", required = true) MultipartFile file){
|
|
|
try {
|
|
|
|
|
|
String originalFilename = file.getOriginalFilename();
|
|
|
InputStream inputStream = file.getInputStream();
|
|
|
|
|
|
return write(200,"查询成功","data",ysDeviceService.videoUpload(request));
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
return error(-1,"error");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@ApiOperation("查询录像列表")
|
|
|
@RequestMapping(value = "videoList", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
|
|
|
public String videoList(
|
|
|
HttpServletRequest request){
|
|
|
try {
|
|
|
|
|
|
String paraString = JSON.toJSONString(request.getParameterMap());
|
|
|
logger.info("查询录像列表,请求参数:\n"+paraString);
|
|
|
|
|
|
return write(200,"查询成功","data",ysDeviceService.videoList());
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
return error(-1,"error");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|