Browse Source

视频监控信息、广播信息可配置

develop
lau572 7 months ago
parent
commit
c8e2b7e5f2
  1. 67
      zc-business/src/main/java/com/zc/business/controller/VideoController.java

67
zc-business/src/main/java/com/zc/business/controller/VideoController.java

@ -23,6 +23,7 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import okhttp3.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
@ -50,21 +51,26 @@ import static java.util.Comparator.comparing;
@RequestMapping("/video")
public class VideoController extends BaseController {
private static final String ID = "admin";
private static final String SECRET = "21232f297a57a5a743894a0e4a801fc3";
private static final String CALLBACKURL = "http://10.0.81.209/broadcast/logIn";
private final static String TOKENKEY = "tokenRoadTestBroadcastPlatform";
private static final String USERNAME = "jhgskj";
private static final String PASSWORD = "jhgskj@2023";
// private static final String ID = "admin";
// private static final String SECRET = "21232f297a57a5a743894a0e4a801fc3";
// private static final String CALLBACKURL = "http://10.0.81.209/broadcast/logIn";
// private final static String TOKENKEY = "tokenRoadTestBroadcastPlatform";
// private static final String USERNAME = "jhgskj";
// private static final String PASSWORD = "jhgskj@2023";
private static String TOKEN;
private final static String URL = HTTP + "10.166.147.60:9021";
// private final static String URL = HTTP + "10.166.147.60:9021";
public static final Integer UNAUTHORIZED = 401;
public static final Integer ERROR = 500;
@Value("${iot.address}")
private String iotAddress;
@Resource
private RedisCache redisCache;
@Resource
@ -158,6 +164,9 @@ public class VideoController extends BaseController {
public JSONObject nearCamListDistance(@ApiParam(value = "纬度", name = "devLat", required = true) String devLat,
@ApiParam(value = "经度", name = "devLon", required = true) String devLon) throws HttpException, IOException {
JSONObject cameraInfo = JSONObject.parseObject(configService.selectConfigByKey("dc.cameraInfo"));
JSONObject jsonResult = null;
// 1000 米
@ -181,7 +190,7 @@ public class VideoController extends BaseController {
Response response // 请求响应
= okHttp
.headers(header)
.url(URL + "/videoInfo/api/nearCamListDistance") // 请求地址
.url(cameraInfo.getString("URL") + "/videoInfo/api/nearCamListDistance") // 请求地址
.data(requestParams) // 请求参数
.get(); // 请求方法
@ -280,7 +289,9 @@ public class VideoController extends BaseController {
private AjaxResult synchronizingBroadcastDeviceStatus() throws HttpException, IOException {
OkHttp okHttp = new OkHttp();
RequestParams requestParams = new RequestParams();
String tokenRoadTestBroadcastPlatform = redisCache.getCacheObject(TOKENKEY);
JSONObject broadcast = JSONObject.parseObject(configService.selectConfigByKey("broadcast"));
String tokenRoadTestBroadcastPlatform = redisCache.getCacheObject(broadcast.getString("TOKENKEY"));
if (tokenRoadTestBroadcastPlatform == null) {
tokenRoadTestBroadcastPlatform = getBroadcastToken();
}
@ -290,26 +301,29 @@ public class VideoController extends BaseController {
= okHttp
.headers(new HashMap<>())
.data(requestParams) // 请求参数
.url("http://10.0.81.106/api/REST-API/queryTerm.do?accessToken=" + tokenRoadTestBroadcastPlatform) // 请求地址
.url(broadcast.getString("URL") + "queryTerm.do?accessToken=" + tokenRoadTestBroadcastPlatform) // 请求地址
.post(); // 请求方法
return JSON.parseObject(response.body().string(), AjaxResult.class);
}
public String getBroadcastToken() throws HttpException, IOException {
JSONObject broadcast = JSONObject.parseObject(configService.selectConfigByKey("broadcast"));
OkHttp okHttp = new OkHttp();
RequestParams requestParams = new RequestParams();
requestParams.put("id", ID);
requestParams.put("secret", SECRET);
requestParams.put("callbackUrl", CALLBACKURL);
requestParams.put("id", broadcast.getString("ID"));
requestParams.put("secret", broadcast.getString("SECRET"));
requestParams.put("callbackUrl", broadcast.getString("CALLBACKURL"));
Response response // 请求响应
= okHttp
.headers(new HashMap<>())
.url("http://10.0.81.106/api/REST-API/login.do") // 请求地址
.url(broadcast.getString("URL") + "login.do") // 请求地址
.data(requestParams) // 请求参数
.post(); // 请求方法
if (response.body() != null) {
String accessToken = JSONObject.parseObject(response.body().string()).getString("accessToken");
redisCache.setCacheObject(TOKENKEY, accessToken, 5, TimeUnit.MINUTES);
redisCache.setCacheObject(broadcast.getString("TOKENKEY"), accessToken, 5, TimeUnit.MINUTES);
return accessToken;
}
return null;
@ -322,7 +336,7 @@ public class VideoController extends BaseController {
Response response // 请求响应
= okHttp
.url(HTTP + "10.0.111.11:8081" + "/api/iot/device/query") // 请求地址
.url(iotAddress + "/api/iot/device/query") // 请求地址
.get(); // 请求方法
return JSON.parseObject(response.body().string(), AjaxResult.class);
}
@ -332,6 +346,7 @@ public class VideoController extends BaseController {
* 查询同步相机数据
*/
public JSONObject synchronizeCameraData() throws HttpException, IOException {
JSONObject cameraInfo = JSONObject.parseObject(configService.selectConfigByKey("dc.cameraInfo"));
JSONObject jsonResult = null;
@ -351,7 +366,7 @@ public class VideoController extends BaseController {
Response response // 请求响应
= okHttp
.headers(header)
.url(URL + "/system/dept/camTreeselect") // 请求地址
.url(cameraInfo.getString("URL") + "/system/dept/camTreeselect") // 请求地址
.data(requestParams) // 请求参数
.get(); // 请求方法
@ -462,6 +477,7 @@ public class VideoController extends BaseController {
@ApiOperation("获取视频流信息")
@GetMapping(value = "/externalVideoStreaming")
public JSONObject externalVideoStreaming(@ApiParam(value = "摄像头标识", name = "camId", required = true) String camId) throws HttpException, IOException {
JSONObject cameraInfo = JSONObject.parseObject(configService.selectConfigByKey("dc.cameraInfo"));
JSONObject jsonResult = null;
@ -482,7 +498,7 @@ public class VideoController extends BaseController {
Response response // 请求响应
= okHttp
.headers(header)
.url(URL + "/videoInfo/api/externalVideoStreaming") // 请求地址
.url(cameraInfo.getString("URL") + "/videoInfo/api/externalVideoStreaming") // 请求地址
.data(requestParams) // 请求参数
.post(); // 请求方法
@ -525,6 +541,7 @@ public class VideoController extends BaseController {
public JSONObject PTZControl(@ApiParam(value = "相机id", name = "camId", required = true) String camId,
@ApiParam(value = "指令类型", name = "cmdType", required = true) String cmdType,
@ApiParam(value = "速度", name = "speed", required = true) String speed) throws HttpException, IOException {
JSONObject cameraInfo = JSONObject.parseObject(configService.selectConfigByKey("dc.cameraInfo"));
JSONObject jsonResult = null;
@ -547,7 +564,7 @@ public class VideoController extends BaseController {
Response response // 请求响应
= okHttp
.headers(header)
.url(URL + "/videoInfo/api/PTZControl") // 请求地址
.url(cameraInfo.getString("URL") + "/videoInfo/api/PTZControl") // 请求地址
.data(requestParams) // 请求参数
.get(); // 请求方法
@ -569,15 +586,17 @@ public class VideoController extends BaseController {
public void getToken() throws HttpException, IOException {
JSONObject cameraInfo = JSONObject.parseObject(configService.selectConfigByKey("dc.cameraInfo"));
OkHttp okHttp = new OkHttp();
RequestParams requestParams = new RequestParams();
requestParams.put("username", USERNAME);
requestParams.put("password", PASSWORD);
requestParams.put("username", cameraInfo.getString("USERNAME"));
requestParams.put("password", cameraInfo.getString("PASSWORD"));
Response response // 请求响应
= okHttp
.url(URL + "/apiLogin") // 请求地址
.url(cameraInfo.getString("URL") + "/apiLogin") // 请求地址
.data(requestParams) // 请求参数
.post(); // 请求方法
@ -597,6 +616,8 @@ public class VideoController extends BaseController {
* @return
*/
public JSONObject getCamByDept(String deptId) throws HttpException, IOException {
JSONObject cameraInfo = JSONObject.parseObject(configService.selectConfigByKey("dc.cameraInfo"));
JSONObject jsonResult = null;
OkHttp okHttp = new OkHttp();
@ -615,7 +636,7 @@ public class VideoController extends BaseController {
Response response // 请求响应
= okHttp
.headers(header)
.url(URL + "/system/camera/camList") // 请求地址
.url(cameraInfo.getString("URL") + "/system/camera/camList") // 请求地址
.data(requestParams) // 请求参数
.get(); // 请求方法
if (response.body() != null) {

Loading…
Cancel
Save