|
@@ -1,5 +1,6 @@
|
|
package com.sky.ioc.service.security.impl;
|
|
package com.sky.ioc.service.security.impl;
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.sky.ioc.entity.domain.security.SecurityDevice;
|
|
import com.sky.ioc.entity.domain.security.SecurityDevice;
|
|
import com.sky.ioc.mapper.job.TokenMapper;
|
|
import com.sky.ioc.mapper.job.TokenMapper;
|
|
import com.sky.ioc.mapper.security.SecurityDeviceMapper;
|
|
import com.sky.ioc.mapper.security.SecurityDeviceMapper;
|
|
@@ -30,6 +31,7 @@ public class SecurityDeviceServiceImpl implements SecurityDeviceService {
|
|
private SecurityDeviceMapper securityDeviceMapper;
|
|
private SecurityDeviceMapper securityDeviceMapper;
|
|
|
|
|
|
final static String SECURITY_CAMERA_URL = "http://192.168.1.45:9001/api/safety/Hikvision/camera/list?pageNum=1&pageSize=1000";
|
|
final static String SECURITY_CAMERA_URL = "http://192.168.1.45:9001/api/safety/Hikvision/camera/list?pageNum=1&pageSize=1000";
|
|
|
|
+ final static String SECURITY_CAMERA_API_INFO_URL = "http://192.168.1.45:9001/api/safety/Hikvision/api/apiInfo";
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public ReturnMsg syncAllCameras() {
|
|
public ReturnMsg syncAllCameras() {
|
|
@@ -84,8 +86,41 @@ public class SecurityDeviceServiceImpl implements SecurityDeviceService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public ReturnMsg getAllCameras() {
|
|
public ReturnMsg getAllCameras() {
|
|
- List<SecurityDevice> securityDevices = securityDeviceMapper.selectList(null);
|
|
|
|
|
|
+ LambdaQueryWrapper<SecurityDevice> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ queryWrapper.eq(SecurityDevice::getDeviceType, "1");
|
|
|
|
+ List<SecurityDevice> securityDevices = securityDeviceMapper.selectList(queryWrapper);
|
|
return ReturnMsg.ok(securityDevices);
|
|
return ReturnMsg.ok(securityDevices);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public ReturnMsg getCameraApiInfo() {
|
|
|
|
+ Map<String,String> tokenMap = tokenMapper.getNewToken();
|
|
|
|
+ String token ="Bearer eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX2tleSI6IjUwZTU1NTRkLWJjYzYtNGRhMS1iZDUxLWFhNTc3YzU4YTFiNCIsInVzZXJuYW1lIjoiYWRtaW4ifQ.X10VPYJfeeRTka7OtqNPOGMpL4QkW3fR_TfCKXCmO-yXbIIrr_40fcwiVnpXfYVENo_BvXWEACRd-Y6nXsbkog";
|
|
|
|
+ if(tokenMap!=null){
|
|
|
|
+ token = "Bearer "+tokenMap.get("token");
|
|
|
|
+ }
|
|
|
|
+ // 创建一个请求头对象
|
|
|
|
+ HttpHeaders httpHeaders = new HttpHeaders();
|
|
|
|
+ // 设置参数
|
|
|
|
+ httpHeaders.set("authorization", token);
|
|
|
|
+ // 创建一个响应体对象
|
|
|
|
+ HttpEntity<String> httpEntity = new HttpEntity(httpHeaders);
|
|
|
|
+ // 3.创建RestTemplate
|
|
|
|
+ RestTemplate restTemplate = new RestTemplate();
|
|
|
|
+ // 发送GET请求
|
|
|
|
+ ResponseEntity<Map> responseEntity = restTemplate.exchange(SECURITY_CAMERA_API_INFO_URL, HttpMethod.GET, httpEntity, Map.class);
|
|
|
|
+ // 获取响应对象里的 body 对象
|
|
|
|
+ Map<String, Object> body = responseEntity.getBody();
|
|
|
|
+ // 获取状态码
|
|
|
|
+ Integer code = (Integer)body.get("code");
|
|
|
|
+ // 获取响应信息
|
|
|
|
+ String message = (String)body.get("msg");
|
|
|
|
+ if(code==200){
|
|
|
|
+ return ReturnMsg.ok(body.get("data"));
|
|
|
|
+ }else{
|
|
|
|
+ log.info("获取摄像头api信息:"+message);
|
|
|
|
+ return ReturnMsg.fail(message);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|