萤石云+博瓦摄像头第三方接口

package com.keda.iot.ecrentiot.monitoring.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.;
import org.springframework.web.bind.annotation.
;
import org.springframework.web.client.RestTemplate;

/**

  • @version: java version 1.8

  • @Author: Ygp Work

  • @description:

  • @date: 2023-07-14 17:18
    */
    @RestController
    @RequestMapping(“/api/v1/camer”)
    @Api(tags = “摄像头接口”)
    public class GBChannelController {

    @Value(“ a u t h . a p p K e y " ) p r i v a t e S t r i n g a p p K e y ; @ V a l u e ( " {auth.appKey}") private String appKey; @Value(" auth.appKey")privateStringappKey;@Value("{auth.appSecret}”)
    private String appSecret;

    @Value(“ l o g i n . u s e r n a m e " ) p r i v a t e S t r i n g u s e r n a m e ; @ V a l u e ( " {login.username}") private String username; @Value(" login.username")privateStringusername;@Value("{login.password}”)
    private String password;

    private final String API_URL = “http://api.uddgps.com”;
    private final String BOVA_URL = “http://bova.createiot.com:8001”;

    @GetMapping(“/liveAddress”)
    @ApiOperation(value = “萤石云根据token等获取到摄像头”)
    public ResponseEntity getLiveAddress(@RequestParam String accessToken, @RequestParam String deviceSerial, @RequestParam(required = false) Integer channelNo) {
    String url = “https://open.ys7.com/api/lapp/v2/live/address/get”;
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
    String requestBody = “accessToken=” + accessToken + “&deviceSerial=” + deviceSerial;
    if (channelNo != null) {
    requestBody += “&channelNo=” + channelNo;
    }
    HttpEntity entity = new HttpEntity<>(requestBody, headers);
    RestTemplate restTemplate = new RestTemplate();
    ResponseEntity response = restTemplate.exchange(url, HttpMethod.POST, entity, String.class);
    return response;
    }

    @GetMapping(“/accessToken”)
    @ApiOperation(value = “萤石云访问数据获取token”)
    public ResponseEntity getAccessToken() {
    String url = “https://open.ys7.com/api/lapp/token/get”;
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
    String requestBody = “appKey=” + appKey + “&appSecret=” + appSecret;
    HttpEntity entity = new HttpEntity<>(requestBody, headers);
    RestTemplate restTemplate = new RestTemplate();
    ResponseEntity response = restTemplate.exchange(url, HttpMethod.POST, entity, String.class);
    return response;
    }

    @GetMapping(“/login”)
    @ApiOperation(value = “博瓦通过账号密码进行登录”)
    public ResponseEntity login() {
    String url = API_URL + “/UserLogin?username=” + username + “&password=” + password;
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_JSON);
    HttpEntity entity = new HttpEntity<>(headers);
    RestTemplate restTemplate = new RestTemplate();
    ResponseEntity response = restTemplate.exchange(url, HttpMethod.GET, entity, String.class);
    return response;
    }

    @GetMapping(“/streamUrl”)
    @ApiOperation(value = “博瓦通过获取的sessionId获取信息,url: 'http: //api.uddaps .com/GetPushstreamUrl’的”)
    public ResponseEntity getStreamUrl(@RequestParam String deviceNo, @RequestParam String sessionId) {
    String url = API_URL + “/GetPushStreamUrl?DeviceNo=” + deviceNo + “&SessionId=” + sessionId;
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_JSON);
    HttpEntity entity = new HttpEntity<>(headers);
    RestTemplate restTemplate = new RestTemplate();
    ResponseEntity response = restTemplate.exchange(url, HttpMethod.GET, entity, String.class);
    return response;
    }

    @GetMapping(“/channelData”)
    @ApiOperation(value = “博瓦通过获取的sessionId获取信息,url: 'http://bova.createiot.com:8001/getchanneData’的”)
    public ResponseEntity getChannelData(@RequestParam String deviceNo, @RequestParam String sessionId) {
    String url = BOVA_URL + “/getChannelData?DeviceNo=” + deviceNo + “&SessionId=” + sessionId + “&checkTime=false&Channelname=IPCameraState_Response”;
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_JSON);
    HttpEntity entity = new HttpEntity<>(headers);
    RestTemplate restTemplate = new RestTemplate();
    ResponseEntity response = restTemplate.exchange(url, HttpMethod.GET, entity, String.class);
    return response;
    }
    }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值