视频点带在线状态列表

master
wany 2024-07-29 13:23:23 +08:00
parent c29ce51617
commit 4a5027ab99
8 changed files with 202 additions and 3 deletions

View File

@ -90,7 +90,11 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>com.hikvision.ga</groupId>
<artifactId>artemis-http-client</artifactId>
<version>1.1.3</version>
</dependency>
<!-- <dependency>--> <!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>--> <!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-data-elasticsearch</artifactId>--> <!-- <artifactId>spring-boot-starter-data-elasticsearch</artifactId>-->

View File

@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.gunshi.core.result.R; import com.gunshi.core.result.R;
import com.gunshi.project.xyt.entity.so.AttCctvBasePage; import com.gunshi.project.xyt.entity.so.AttCctvBasePage;
import com.gunshi.project.xyt.entity.vo.CctvControlVo;
import com.gunshi.project.xyt.model.AttCctvBase; import com.gunshi.project.xyt.model.AttCctvBase;
import com.gunshi.project.xyt.service.AttCctvBaseService; import com.gunshi.project.xyt.service.AttCctvBaseService;
import com.gunshi.project.xyt.util.OkHttpUtil; import com.gunshi.project.xyt.util.OkHttpUtil;
@ -103,4 +104,32 @@ public class AttCctvBaseController {
return R.ok(ret); return R.ok(ret);
} }
@Operation(summary = "云台控制")
@PostMapping("/control")
public R<String> control(@RequestBody CctvControlVo vo) {
String indexCode = vo.getIndexCode();
Integer action = vo.getAction();
Integer speed = vo.getSpeed();
String command = vo.getCommand();
String api = "http://223.75.53.141:81/isc/controlling?cameraIndexCode="+indexCode+"&action="+action+"&speed="+speed+"&command="+command+"&token=111";
OkHttpClient client = OkHttpUtil.build();
String ret = null;
try {
Response resp = client.newCall(new Request.Builder().url(api).build()).execute();
String respStr = resp.body().string();
ObjectMapper om = new ObjectMapper();
Map map = om.readValue(respStr, Map.class);
ret = map.get("data").toString();
} catch (IOException e) {
throw new RuntimeException(e);
}
return R.ok(ret);
}
@Operation(summary = "视频点列表(带在线状态)")
@GetMapping("/listWithStatus")
public R<List<AttCctvBase>> listWithStatus() {
return R.ok(service.listWithStatus());
}
} }

View File

@ -0,0 +1,22 @@
package com.gunshi.project.xyt.entity.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* Description:
* Created by wanyan on 2024/7/26
*
* @author wanyan
* @version 1.0
*/
@Data
public class CameraOnlineVo {
@Schema(description="摄像头code")
private String indexCode;
@Schema(description="在线状态0离线1在线")
private Integer online;
}

View File

@ -0,0 +1,45 @@
package com.gunshi.project.xyt.entity.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* Description:
* Created by wanyan on 2024/7/26
*
* @author wanyan
* @version 1.0
*/
@Data
public class CctvControlVo {
@Schema(description="摄像头code")
private String indexCode;
@Schema(description="动作0开始 1停止")
private Integer action;
@Schema(description="云台速度")
private Integer speed;
@Schema(description="命令(LEFT 左转\n" +
"RIGHT右转\n" +
"UP 上转\n" +
"DOWN 下转\n" +
"ZOOM_IN 焦距变大\n" +
"ZOOM_OUT 焦距变小\n" +
"LEFT_UP 左上\n" +
"LEFT_DOWN 左下\n" +
"RIGHT_UP 右上\n" +
"RIGHT_DOWN 右下\n" +
"FOCUS_NEAR 焦点前移\n" +
"FOCUS_FAR 焦点后移\n" +
"IRIS_ENLARGE 光圈扩大\n" +
"IRIS_REDUCE 光圈缩小\n" +
"WIPER_SWITCH 接通雨刷开关\n" +
"START_RECORD_TRACK 开始记录运行轨迹\n" +
"STOP_RECORD_TRACK 停止记录运行轨迹\n" +
"START_TRACK 开始运行轨迹\n" +
"STOP_TRACK 停止运行轨迹;)")
private String command;
}

View File

@ -122,4 +122,9 @@ public class AttCctvBase implements Serializable {
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8") @JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8")
private Date createTime; private Date createTime;
@TableField(exist = false)
@Schema(description="在线状态0离线1在线")
private Integer online;
} }

View File

@ -1,13 +1,19 @@
package com.gunshi.project.xyt.service; package com.gunshi.project.xyt.service;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gunshi.project.xyt.entity.vo.CameraOnlineVo;
import com.gunshi.project.xyt.mapper.AttCctvBaseMapper; import com.gunshi.project.xyt.mapper.AttCctvBaseMapper;
import com.gunshi.project.xyt.model.AttCctvBase; import com.gunshi.project.xyt.model.AttCctvBase;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.Date; import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/** /**
* : * :
@ -20,6 +26,22 @@ import java.util.Date;
public class AttCctvBaseService extends ServiceImpl<AttCctvBaseMapper, AttCctvBase> public class AttCctvBaseService extends ServiceImpl<AttCctvBaseMapper, AttCctvBase>
{ {
@Resource
private IscService iscService;
public List<AttCctvBase> listWithStatus() {
List<AttCctvBase> list = this.list();
if(CollectionUtils.isEmpty(list)){
return new ArrayList<>();
}
List<String> indexCodes = list.stream().map(AttCctvBase::getIndexCode).collect(Collectors.toList());
List<CameraOnlineVo> cameraOnlineVos = iscService.getCameraOnlineStatus(indexCodes);
Map<String, Integer> map = cameraOnlineVos.stream().collect(Collectors.toMap(CameraOnlineVo::getIndexCode, CameraOnlineVo::getOnline));
for (AttCctvBase base : list){
base.setOnline(map.get(base.getIndexCode()));
}
return list;
}
} }

View File

@ -117,7 +117,7 @@ public class GateValveRealService extends ServiceImpl<GateValveRealMapper, GateV
/** /**
* = - * = -
* = ( + )*3600 * = ( + )*3600
* = / * = * 10000/
* = * =
*/ */
List<AttResBaseVo> list = reservoirWaterService.list(); List<AttResBaseVo> list = reservoirWaterService.list();

View File

@ -0,0 +1,72 @@
package com.gunshi.project.xyt.service;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.gunshi.project.xyt.entity.vo.CameraOnlineVo;
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
import com.hikvision.artemis.sdk.config.ArtemisConfig;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Description:
* Created by wanyan on 2024/7/26
*
* @author wanyan
* @version 1.0
*/
@Service
public class IscService {
public List<CameraOnlineVo> getCameraOnlineStatus(List<String> indexCodes) {
/**
* STEP1,host appkey appsecret .
*/
ArtemisConfig.host="223.76.234.232:1443";
ArtemisConfig.appKey="22410244";
ArtemisConfig.appSecret="6WYT5OVPyCHJJmaaAZr9";
/**
* STEP2OpenAPI
*/
final String ARTEMIS_PATH = "/artemis";
/**
* STEP3URI
*/
final String previewURLsApi = ARTEMIS_PATH + "/api/nms/v1/online/camera/get";
Map<String, String> path = new HashMap<String, String>(2) {
{
put("https://", previewURLsApi);//根据现场环境部署确认是http还是https
}
};
/**
* STEP4
*/
String contentType = "application/json";
/**
* STEP5
*/
JSONObject jsonBody = new JSONObject();
jsonBody.put("indexCodes", indexCodes);
jsonBody.put("pageNo", 1);
jsonBody.put("pageSize", 1000);
String body = jsonBody.toString();
/**
* STEP6
*/
String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , null);// post请求application/json类型参数
JSONObject obj = JSONUtil.parseObj(result);
JSONObject jsonObject = obj.getJSONObject("data");
JSONArray list = jsonObject.getJSONArray("list");
return list.toList(CameraOnlineVo.class);
}
}