VAServerController.java
4.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
package com.viontech.fanxing.task.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.viontech.fanxing.commons.config.VionConfig;
import com.viontech.fanxing.task.model.vaserver.VaServerInfo;
import com.viontech.fanxing.task.model.vaserver.VaServerOverViewModel;
import com.viontech.fanxing.task.service.VAServerService;
import com.viontech.keliu.util.JsonMessageUtil;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RMap;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Collection;
import java.util.HashMap;
/**
* .
*
* @author 谢明辉
* @date 2021/7/13
*/
@RestController
@Slf4j
public class VAServerController {
@Resource
private VAServerService vaServerService;
@Resource
private VionConfig vionConfig;
/**
* 注册
*/
@PostMapping("/register")
public Object register(@RequestBody VaServerInfo vaServerInfo) {
log.info("收到注册消息:{}", JSON.toJSONString(vaServerInfo));
vaServerService.registerVAServer(vaServerInfo);
HashMap<String, Object> result = new HashMap<>();
result.put("code", 200);
result.put("msg", "success");
result.put("resultRecvUrl", vionConfig.getReceiveResultPrefixPath() + "/fanxing-forward/result");
result.put("videoUploadUrl", vionConfig.getReceiveResultPrefixPath() + "/fanxing-forward/result/video");
return result;
}
/**
* 心跳
*/
@GetMapping("/keepalive/{devId}")
public Object keepalive(@PathVariable String devId) {
log.info("收到心跳消息:{}", devId);
vaServerService.keepalive(devId);
return JsonMessageUtil.getSuccessJsonMsg("success");
}
@GetMapping("/vaServerInfo")
public Object getVaServerInfo() {
RMap<String, VaServerInfo> vaServerInfoMap = vaServerService.getVaServerRedisRepository().getVaServerInfoMap();
return JsonMessageUtil.getSuccessJsonMsg(vaServerInfoMap.values());
}
/**
* 获取分析视频点播地址
*/
@GetMapping("/getAnalyzeStream")
public Object getAnalyzeStream(@RequestParam String taskUnid) {
return vaServerService.getAnalyzeStream(taskUnid);
}
/**
* 输出分析流,每30秒调一次,不调用就不再输出视频流
*/
@PostMapping("/startAnalyzeStream")
public Object startAnalyzeStream(@RequestBody JSONObject object) {
String taskUnid = object.getString("taskUnid");
String s = vaServerService.startAnalyzeStream(taskUnid);
return JsonMessageUtil.getSuccessJsonMsg("success", s);
}
/**
* 获取vaServer运行状态,配置等信息
*/
@GetMapping("/status")
public Object status(@RequestParam String devId) {
return vaServerService.getStatus(devId);
}
/**
* 切换场景/预置位
*/
@GetMapping("/switchScene")
public Object switchScene(@RequestParam String taskUnid, String sceneId) {
return vaServerService.switchScene(taskUnid, sceneId);
}
/**
* 截图
*/
@GetMapping("/snapshot")
public Object snapshot(@RequestParam String taskUnid) {
return vaServerService.snapshot(taskUnid);
}
@GetMapping("/updateRotationStatus")
public Object updateRotationStatus(@RequestParam String taskUnid, @RequestParam Integer status) {
return vaServerService.updateRotationStatus(taskUnid, status);
}
@GetMapping("/getRotationStatus")
public Object getRotationStatus(@RequestParam String taskUnid) {
return vaServerService.getRotationStatus(taskUnid);
}
@GetMapping("/getCurrentScene")
public Object getCurrentScene(@RequestParam String taskUnid) {
return vaServerService.getCurrentScene(taskUnid);
}
/**
* @param type 任务的类型 0 交通, 1 客流, 2 安防, 3 违停, 4 人脸
*/
@GetMapping("/getDefaultAlgorithmConfig")
public Object getDefaultAlgorithmConfig(@RequestParam String type) {
return vaServerService.getDefaultAlgorithmConfig(type);
}
@GetMapping("/vaServer/overview")
public Object vaServerOverview() {
Collection<VaServerOverViewModel> result = vaServerService.vaServerOverview();
return JsonMessageUtil.getSuccessJsonMsg(result);
}
}