Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
S
screen-setting
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
耿迪迪
screen-setting
Commits
d10753ef
Commit
d10753ef
authored
May 30, 2023
by
耿迪迪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
海康视频接口
parent
f42fc284
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
300 additions
and
2 deletions
+300
-2
pom.xml
pom.xml
+14
-0
ScreenSettingController.java
...ensetting/controller/setting/ScreenSettingController.java
+1
-2
ArtemisController.java
...hkj/screensetting/controller/video/ArtemisController.java
+196
-0
EventSubscriptionVo.java
...va/com/zhkj/screensetting/entity/EventSubscriptionVo.java
+67
-0
EventUnSubscriptionVo.java
.../com/zhkj/screensetting/entity/EventUnSubscriptionVo.java
+22
-0
No files found.
pom.xml
View file @
d10753ef
...
...
@@ -33,6 +33,20 @@
<artifactId>
hutool-all
</artifactId>
<version>
5.5.2
</version>
</dependency>
<!--海康-->
<dependency>
<groupId>
com.hikvision.ga
</groupId>
<artifactId>
artemis-http-client
</artifactId>
<version>
1.1.3
</version>
</dependency>
<!-- 阿里JSON解析器 -->
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
<version>
1.2.76
</version>
</dependency>
</dependencies>
<build>
...
...
src/main/java/com/zhkj/screensetting/controller/ScreenSettingController.java
→
src/main/java/com/zhkj/screensetting/controller/
setting/
ScreenSettingController.java
View file @
d10753ef
package
com
.
zhkj
.
screensetting
.
controller
;
package
com
.
zhkj
.
screensetting
.
controller
.
setting
;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.util.StrUtil
;
...
...
@@ -10,7 +10,6 @@ import org.springframework.web.bind.annotation.RequestBody;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
src/main/java/com/zhkj/screensetting/controller/video/ArtemisController.java
0 → 100644
View file @
d10753ef
package
com
.
zhkj
.
screensetting
.
controller
.
video
;
import
com.alibaba.fastjson.JSONObject
;
import
com.hikvision.artemis.sdk.ArtemisHttpUtil
;
import
com.hikvision.artemis.sdk.config.ArtemisConfig
;
import
com.zhkj.screensetting.entity.EventSubscriptionVo
;
import
com.zhkj.screensetting.entity.EventUnSubscriptionVo
;
import
com.zhkj.screensetting.entity.Result
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* 海康视频接口
*/
@RestController
@RequestMapping
(
"artemis"
)
public
class
ArtemisController
{
/**
* 请根据自己的appKey和appSecret更换static静态块中的三个参数. [1 host]
* 如果你选择的是和现场环境对接,host要修改为现场环境的ip,https端口默认为443,http端口默认为80.例如10.33.25.22:443 或者10.33.25.22:80
* appKey和appSecret请按照或得到的appKey和appSecret更改.
*/
static
{
// 代理API网关nginx服务器ip端口
ArtemisConfig
.
host
=
"27.128.189.137:1443"
;
// 秘钥appkey
ArtemisConfig
.
appKey
=
"28616162"
;
// 秘钥appSecret
ArtemisConfig
.
appSecret
=
"5ueTWDOJ21jRbpHACAzF"
;
}
/**
* 能力开放平台的网站路径
*/
private
static
final
String
ARTEMIS_PATH
=
"/artemis"
;
/**
* 获取监控点预览取流URL
*/
private
static
final
String
GET_PREVIEWURLS
=
ARTEMIS_PATH
+
"/api/video/v1/cameras/previewURLs"
;
/**
* 分页获取监控点资源
*/
private
static
final
String
GET_CAMERAS
=
ARTEMIS_PATH
+
"/api/resource/v1/cameras"
;
private
static
final
String
VEDIO_CONTROLLING
=
ARTEMIS_PATH
+
"/api/video/v1/ptzs/controlling"
;
/**
* 按事件类型订阅事件
*/
private
static
final
String
EVENT_SUBSCIRPTION_BY_ENVENTTYPES
=
ARTEMIS_PATH
+
"/api/eventService/v1/eventSubscriptionByEventTypes"
;
/**
* 按事件类型取消订阅事件
*/
private
static
final
String
EVENT_UNSUBSCRIPTION_BY_EVENTTYPES
=
ARTEMIS_PATH
+
"/api/eventService/v1/eventUnSubscriptionByEventTypes"
;
/**
* 获取监控点预览取流URL
* @return
*/
@GetMapping
(
"/getPreviewURLs"
)
public
Result
getPreviewURLs
(
@RequestParam
(
value
=
"cameraIndexCode"
)
String
cameraIndexCode
){
/**
* 根据API文档可以看出来,这是一个POST请求的Rest接口,而且传入的参数值为一个json
* ArtemisHttpUtil工具类提供了doPostStringArtemis这个函数,一共六个参数在文档里写明其中的意思,因为接口是https,
* 所以第一个参数path是一个hashmap类型,请put一个key-value,query为传入的参数,body为传入的json数据
* 传入的contentType为application/json,accept不指定为null
* header没有额外参数可不传,指定为null
*
*/
Map
<
String
,
String
>
path
=
new
HashMap
<
String
,
String
>(
2
)
{
{
//根据现场环境部署确认是http还是https
put
(
"https://"
,
GET_PREVIEWURLS
);
}
};
JSONObject
jsonBody
=
new
JSONObject
();
//jsonBody.put("cameraIndexCode", "2a9891a194c24747b277f3ea4836d433");
jsonBody
.
put
(
"cameraIndexCode"
,
cameraIndexCode
);
jsonBody
.
put
(
"streamType"
,
0
);
//0主码流,1子码流
jsonBody
.
put
(
"protocol"
,
"ws"
);
jsonBody
.
put
(
"transmode"
,
1
);
String
body
=
jsonBody
.
toJSONString
();
// post请求application/json类型参数
String
result
=
ArtemisHttpUtil
.
doPostStringArtemis
(
path
,
body
,
null
,
null
,
"application/json"
,
null
);
return
new
Result
(
200
,
"视频流获取成功"
).
setData
(
JSONObject
.
parseObject
(
result
));
}
/**
* 分页获取监控点资源
* @param pageNo 页码
* @param pageSize 每页条数
* @return
*/
@GetMapping
(
"/getCameras"
)
public
Result
getCameras
(
@RequestParam
(
"pageNo"
)
int
pageNo
,
@RequestParam
(
"pageSize"
)
int
pageSize
){
Map
<
String
,
String
>
path
=
new
HashMap
<
String
,
String
>(
2
)
{
{
//根据现场环境部署确认是http还是https
put
(
"https://"
,
GET_CAMERAS
);
}
};
JSONObject
jsonBody
=
new
JSONObject
();
jsonBody
.
put
(
"pageNo"
,
pageNo
);
jsonBody
.
put
(
"pageSize"
,
pageSize
);
jsonBody
.
put
(
"treeCode"
,
0
);
String
body
=
jsonBody
.
toJSONString
();
// post请求application/json类型参数
String
result
=
ArtemisHttpUtil
.
doPostStringArtemis
(
path
,
body
,
null
,
null
,
"application/json"
,
null
);
return
new
Result
(
200
,
"视频列表获取成功"
).
setData
(
JSONObject
.
parseObject
(
result
));
}
/**
* 云控操作
* @param cameraIndexCode
* @param command
* @param action
* @return
*/
@RequestMapping
(
"/videoControlling"
)
public
Result
videoControlling
(
@RequestParam
(
"cameraIndexCode"
)
String
cameraIndexCode
,
@RequestParam
(
"command"
)
String
command
,
@RequestParam
(
"action"
)
String
action
,
@RequestParam
(
"speed"
)
String
speed
){
Map
<
String
,
String
>
path
=
new
HashMap
<
String
,
String
>(
2
)
{
{
//根据现场环境部署确认是http还是https
put
(
"https://"
,
VEDIO_CONTROLLING
);
}
};
JSONObject
jsonBody
=
new
JSONObject
();
jsonBody
.
put
(
"cameraIndexCode"
,
cameraIndexCode
);
jsonBody
.
put
(
"action"
,
action
);
jsonBody
.
put
(
"command"
,
command
);
jsonBody
.
put
(
"speed"
,
speed
);
String
body
=
jsonBody
.
toJSONString
();
// post请求application/json类型参数
String
result
=
ArtemisHttpUtil
.
doPostStringArtemis
(
path
,
body
,
null
,
null
,
"application/json"
,
null
);
return
new
Result
(
200
,
"操作成功"
).
setData
(
JSONObject
.
parseObject
(
result
));
}
/**
* 按事件类型订阅事件
* @param eventSubscriptionVo 事件订阅实体
* @return
*/
@PostMapping
(
"/eventSubscriptionByEventTypes"
)
public
Result
eventSubscriptionByEventTypes
(
@RequestBody
EventSubscriptionVo
eventSubscriptionVo
){
Map
<
String
,
String
>
path
=
new
HashMap
<
String
,
String
>(
2
)
{
{
//根据现场环境部署确认是http还是https
put
(
"https://"
,
EVENT_SUBSCIRPTION_BY_ENVENTTYPES
);
}
};
JSONObject
jsonBody
=
new
JSONObject
();
jsonBody
.
put
(
"eventTypes"
,
eventSubscriptionVo
.
getEventTypes
());
jsonBody
.
put
(
"eventDest"
,
eventSubscriptionVo
.
getEventDest
());
if
(
eventSubscriptionVo
.
getSubType
()
!=
0
){
jsonBody
.
put
(
"subType"
,
eventSubscriptionVo
.
getSubType
());
}
if
(
null
!=
eventSubscriptionVo
.
getEventLvl
()
&&
eventSubscriptionVo
.
getEventLvl
().
size
()
!=
0
){
jsonBody
.
put
(
"eventLvl"
,
eventSubscriptionVo
.
getEventLvl
());
}
String
body
=
jsonBody
.
toJSONString
();
String
result
=
ArtemisHttpUtil
.
doPostStringArtemis
(
path
,
body
,
null
,
null
,
"application/json"
,
null
);
return
new
Result
(
200
,
"事件订阅成功"
).
setData
(
JSONObject
.
parseObject
(
result
));
}
/**
* 按事件类型取消订阅
* @param eventUnSubscriptionVo 事件类型
* @return
*/
@PostMapping
(
"/eventUnSubscriptionByEventTypes"
)
public
Result
eventUnSubscriptionByEventTypes
(
@RequestBody
EventUnSubscriptionVo
eventUnSubscriptionVo
){
Map
<
String
,
String
>
path
=
new
HashMap
<
String
,
String
>(
2
)
{
{
//根据现场环境部署确认是http还是https
put
(
"https://"
,
EVENT_UNSUBSCRIPTION_BY_EVENTTYPES
);
}
};
JSONObject
jsonBody
=
new
JSONObject
();
jsonBody
.
put
(
"eventTypes"
,
eventUnSubscriptionVo
.
getEventTypes
());
String
body
=
jsonBody
.
toJSONString
();
String
result
=
ArtemisHttpUtil
.
doPostStringArtemis
(
path
,
body
,
null
,
null
,
"application/json"
,
null
);
return
new
Result
(
200
,
"事件取消订阅成功"
).
setData
(
JSONObject
.
parseObject
(
result
));
}
}
src/main/java/com/zhkj/screensetting/entity/EventSubscriptionVo.java
0 → 100644
View file @
d10753ef
package
com
.
zhkj
.
screensetting
.
entity
;
import
java.util.List
;
public
class
EventSubscriptionVo
{
/**
* 必填 - 事件类型
*/
private
List
<
Integer
>
eventTypes
;
/**
* 必填 - 指定事件接收的地址,采用restful回调模式,支持http和https,样式如下:http://ip:port/eventRcv或者
* https://ip:port/eventRcv
* 不超过1024个字符
* 事件接收地址由应用方负责按指定的规范提供,事件接收接口不需要认证
* 三方客户收到消息,请注意立即返回HTTP/1.1 200 OK, 否则因为接收太慢,导致事件积压
*/
private
String
eventDest
;
/**
* 非必填 - 订阅类型,0-订阅原始事件,1-联动事件,2-原始事件和联动事件,不填使用默认值0
*/
private
int
subType
;
/**
* 非必填 - 事件等级,0-未配置,1-低,2-中,3-高
* 此处事件等级是指在事件联动中配置的等级
* 订阅类型为0时,此参数无效,使用默认值0
* 在订阅类型为1时,不填使用默认值[1,2,3]
* 在订阅类型为2时,不填使用默认值[0,1,2,3]
* 数组大小不超过32,事件等级大小不超过31
*/
private
List
<
Integer
>
eventLvl
;
public
List
<
Integer
>
getEventTypes
()
{
return
eventTypes
;
}
public
void
setEventTypes
(
List
<
Integer
>
eventTypes
)
{
this
.
eventTypes
=
eventTypes
;
}
public
String
getEventDest
()
{
return
eventDest
;
}
public
void
setEventDest
(
String
eventDest
)
{
this
.
eventDest
=
eventDest
;
}
public
int
getSubType
()
{
return
subType
;
}
public
void
setSubType
(
int
subType
)
{
this
.
subType
=
subType
;
}
public
List
<
Integer
>
getEventLvl
()
{
return
eventLvl
;
}
public
void
setEventLvl
(
List
<
Integer
>
eventLvl
)
{
this
.
eventLvl
=
eventLvl
;
}
}
src/main/java/com/zhkj/screensetting/entity/EventUnSubscriptionVo.java
0 → 100644
View file @
d10753ef
package
com
.
zhkj
.
screensetting
.
entity
;
import
java.util.List
;
public
class
EventUnSubscriptionVo
{
private
List
<
Integer
>
eventTypes
;
public
List
<
Integer
>
getEventTypes
()
{
return
eventTypes
;
}
public
void
setEventTypes
(
List
<
Integer
>
eventTypes
)
{
this
.
eventTypes
=
eventTypes
;
}
@Override
public
String
toString
()
{
return
"EventUnSubscriptionVo{"
+
"eventTypes="
+
eventTypes
+
'}'
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment