package com.ruoyi.web.controller.manage; import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.fuzhou.domain.CameraPTZ; import com.ruoyi.fuzhou.domain.DpEquipment; import com.ruoyi.fuzhou.domain.HikEvent; import com.ruoyi.fuzhou.domain.HikEventObj; import com.ruoyi.fuzhou.service.EquipmentService; import com.ruoyi.fuzhou.service.HikService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.time.OffsetDateTime; import java.util.Date; @RestController @RequestMapping("/dp/hik") @Tag(name = "大屏--海康视频") public class HikController extends BaseController { @Autowired private HikService hikService; @Autowired private EquipmentService dpEquipmentService; @GetMapping("/getCameraPreviewURL/{cameraName}") @Operation(summary = "根据name查询视频播放URL") public AjaxResult getCameraPreviewURL(@PathVariable("cameraName") String cameraName) throws Exception { return AjaxResult.success(hikService.getCameraPreviewURL(cameraName)); } @GetMapping("/getCameraURL/{cameraIndexCode}") @Operation(summary = "根据indexcode查询视频播放URL") public AjaxResult getCameraURL(@PathVariable("cameraIndexCode") String cameraIndexCode) throws Exception { return AjaxResult.success(hikService.getCameraURL(cameraIndexCode)); } @GetMapping("/getCameraOnline/{indexCodes}") @Operation(summary = "根据indexCodes数组查询监控状态") public AjaxResult getCameraOnline(@PathVariable("indexCodes") String[] indexCodes) throws Exception { return AjaxResult.success(hikService.getCameraOnline(indexCodes)); } @Operation(summary = "云台操作") @PostMapping("/cameraCommand") public AjaxResult cameraCommand(@RequestBody CameraPTZ cameraPTZ) throws Exception{ return AjaxResult.success(hikService.cameraCommand(cameraPTZ)); } @Operation(summary = "根据事件类型订阅事件") @PostMapping("/subByEventTypes") public JSONObject subByEventTypes(@RequestBody HikEventObj hikEventObj) throws Exception{ return hikService.subByEventTypes(hikEventObj); } @Operation(summary = "根据事件类型取消订阅事件") @PostMapping("/unSubByEventTypes") public JSONObject unSubByEventTypes(@RequestBody HikEventObj hikEventObj) throws Exception{ return hikService.unSubByEventTypes(hikEventObj); } @Operation(summary = "查询订阅事件信息") @PostMapping("/eventView") public JSONObject eventView() throws Exception{ return hikService.eventView(); } @Operation(summary = "接收海康事件信息") @PostMapping("/eventRcv") public JSONObject eventRcv(@RequestBody JSONObject jsonObject) throws Exception{ String method = null; JSONObject params = new JSONObject(); JSONArray events = new JSONArray(); JSONObject res = new JSONObject(); String sendTime = null; if(jsonObject.containsKey("method")){ method = jsonObject.getString("method"); } if (jsonObject.containsKey("params")) { params = jsonObject.getJSONObject("params"); if(params.containsKey("sendTime")){ sendTime = params.getString("sendTime"); } if (params.containsKey("events")) { events = params.getJSONArray("events"); if(events.size()>0){ for (int i=0;i0){ for (int k=0;k