package cn.gistack.sm.hk.controller;
|
|
import cn.gistack.sm.hk.constant.HkConstant;
|
import cn.gistack.sm.hk.constant.ProtocolConstant;
|
import cn.gistack.sm.hk.service.HkService;
|
import cn.gistack.sm.hk.vo.EventVO;
|
import cn.gistack.sm.hk.vo.HkVO;
|
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import lombok.AllArgsConstructor;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springblade.core.mp.support.Query;
|
import org.springblade.core.tool.api.R;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.text.SimpleDateFormat;
|
import java.util.Date;
|
import java.util.Map;
|
|
import static cn.gistack.sm.hk.util.GetCameraUtils.*;
|
|
/**
|
* @author zhongrj
|
* @Description: 海康视频事件管理
|
* @date 2023-08-10
|
*/
|
@Slf4j
|
@Api(tags = "海康视频事件")
|
@RestController
|
@RequestMapping("/hk/hkEvent")
|
@AllArgsConstructor
|
public class HkEventController {
|
|
private final HkService hkService;
|
|
/**
|
* 海康视频事件订阅
|
* @param eventVO 订阅参数
|
* @return
|
*/
|
@GetMapping(value = "/eventSubscriptionByEventTypes")
|
public R eventSubscriptionByEventTypes(EventVO eventVO) {
|
String result = addEventSubscriptionByEventTypes(eventVO, HkConstant.eventSubscriptionByEventTypesURLs);
|
log.info("事件订阅返回信息:" + result);
|
JSONObject jsonObject1 = JSONObject.parseObject(result);
|
// 查询海康设备列表并返回
|
return R.data(jsonObject1);
|
}
|
|
/**
|
* 海康视频事件取消订阅
|
* @param eventVO 订阅参数
|
* @return
|
*/
|
@GetMapping(value = "/eventUnSubscriptionByEventTypes")
|
public R eventUnSubscriptionByEventTypes(EventVO eventVO) {
|
String result = removeEventSubscriptionByEventTypes(eventVO, HkConstant.eventUnSubscriptionByEventTypesURLs);
|
JSONObject jsonObject1 = JSONObject.parseObject(result);
|
// 查询海康设备列表并返回
|
return R.data(jsonObject1);
|
}
|
|
/**
|
* 查询事件订阅信息
|
* @param eventVO 订阅参数
|
* @return
|
*/
|
@GetMapping(value = "/eventSubscriptionView")
|
public R eventSubscriptionView(EventVO eventVO) {
|
String result = getEventSubscriptionView(eventVO, HkConstant.eventSubscriptionViewURLs);
|
JSONObject jsonObject1 = JSONObject.parseObject(result);
|
// 查询海康设备列表并返回
|
return R.data(jsonObject1);
|
}
|
|
/**
|
* 事件回调事件
|
* @param data 回调数据
|
* @return
|
*/
|
@PostMapping(value = "/eventRcv")
|
public String eventRcv(@RequestBody String data) {
|
Date date = new Date();
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
//格式化输出json
|
JSONObject jsonObject = JSON.parseObject(data);
|
String prettyData = JSON.toJSONString(jsonObject, SerializerFeature.PrettyFormat,
|
SerializerFeature.WriteMapNullValue);
|
System.out.println(simpleDateFormat.format(date) + "收到数据:" + System.lineSeparator() + prettyData);
|
log.info(simpleDateFormat.format(date) + "收到数据:" + System.lineSeparator() + prettyData);
|
|
JSONObject jsonBody = new JSONObject();
|
jsonBody.put("code", "200");
|
jsonBody.put("msg", "ok");
|
jsonBody.put("data", null);
|
return jsonBody.toJSONString();
|
}
|
|
|
}
|