|
@@ -1,14 +1,21 @@
|
|
|
package com.welampiot.controller;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.welampiot.common.BaseResult;
|
|
|
+import com.welampiot.common.Constant;
|
|
|
import com.welampiot.common.InterfaceResultEnum;
|
|
|
import com.welampiot.common.ResultEnum;
|
|
|
import com.welampiot.dto.UserDTO;
|
|
|
import com.welampiot.dto.VideoMonitorDTO;
|
|
|
import com.welampiot.dto.WaterImmersionDevInfoDTO;
|
|
|
+import com.welampiot.service.SystemConfigService;
|
|
|
import com.welampiot.service.VideoMonitorService;
|
|
|
import com.welampiot.utils.MD5Utils;
|
|
|
import com.welampiot.utils.ToolUtils;
|
|
|
+import com.welampiot.utils.VideoUtil;
|
|
|
+import com.welampiot.utils.WebUtils;
|
|
|
import com.welampiot.vo.LoginVO;
|
|
|
import com.welampiot.vo.VideoMonitorVO;
|
|
|
import org.slf4j.Logger;
|
|
@@ -34,6 +41,9 @@ public class VideoController {
|
|
|
|
|
|
@Autowired
|
|
|
private VideoMonitorService videoMonitorService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SystemConfigService systemConfigService;
|
|
|
/**
|
|
|
* 设置AI开关状态
|
|
|
* @param request
|
|
@@ -58,7 +68,6 @@ public class VideoController {
|
|
|
@RequestMapping(value = "/getRecordList", method = RequestMethod.POST)
|
|
|
public BaseResult getRecordList(VideoMonitorDTO videoMonitorDTO){
|
|
|
int version = videoMonitorDTO.getVersion();
|
|
|
-// Integer id = videoMonitorDTO.getId();
|
|
|
long startTime = System.currentTimeMillis() - 24 * 3600 * 1000;
|
|
|
ArrayList<VideoMonitorDTO> videoMonitorDTOS = new ArrayList<>();
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
@@ -76,14 +85,71 @@ public class VideoController {
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * 获取摄像头回放列表
|
|
|
+ * 获取回放播放地址
|
|
|
* @param videoMonitorDTO
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/getRecordPlay", method = RequestMethod.POST)
|
|
|
public BaseResult getRecordPlay(VideoMonitorDTO videoMonitorDTO){
|
|
|
int version = videoMonitorDTO.getVersion();
|
|
|
-// Integer id = videoMonitorDTO.getId();
|
|
|
+ Integer id = videoMonitorDTO.getId();
|
|
|
+ String startTime = videoMonitorDTO.getStartTime();
|
|
|
+ String endTime = videoMonitorDTO.getEndTime();
|
|
|
+ if (startTime == null || endTime == null) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
+ VideoMonitorDTO oneById = videoMonitorService.getOneById(id);
|
|
|
+ String gbAddress = oneById.getGbAddress();
|
|
|
+ String gbPlayBackAddress = VideoUtil.getGbPlayBackAddress(videoMonitorService, systemConfigService, gbAddress, startTime, endTime);
|
|
|
+ VideoMonitorDTO videoMonitorDTO1 = new VideoMonitorDTO();
|
|
|
+ videoMonitorDTO1.setAddress(gbPlayBackAddress);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,videoMonitorDTO1);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取NVR通道值信息
|
|
|
+ * @param videoMonitorDTO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/getChannelValue", method = RequestMethod.POST)
|
|
|
+ public BaseResult getChannelValue(VideoMonitorDTO videoMonitorDTO){
|
|
|
+ int version = videoMonitorDTO.getVersion();
|
|
|
+ Integer id = videoMonitorDTO.getId();
|
|
|
+ if (id == null || id == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
+ VideoMonitorDTO oneById = videoMonitorService.getOneById(id);
|
|
|
+
|
|
|
+ String url = Constant.GB_HOST_ADDRESS+"/api/devices";
|
|
|
+ String s = WebUtils.requestGet(url);
|
|
|
+ JSONArray jsonArray = JSON.parseArray(s);
|
|
|
+ JSONObject data = null;
|
|
|
+ if (jsonArray != null){
|
|
|
+ for (Object j: jsonArray) {
|
|
|
+ JSONObject j1 = (JSONObject) j;
|
|
|
+ String deviceId = (String) j1.get("deviceId");
|
|
|
+ if (deviceId.equalsIgnoreCase(oneById.getGbAddress())){
|
|
|
+ data = j1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ArrayList<Object> objects = new ArrayList<>();
|
|
|
+ if (data != null){
|
|
|
+ for (Object channelMap : (JSONArray) data.get("channelMap")) {
|
|
|
+ JSONObject channelMap1 = (JSONObject) channelMap;
|
|
|
+ VideoMonitorDTO videoMonitorDTO1 = new VideoMonitorDTO();
|
|
|
+ videoMonitorDTO1.setName((String) channelMap1.get("name"));
|
|
|
+ videoMonitorDTO1.setChannelId((String) channelMap1.get("channelId"));
|
|
|
+ objects.add(videoMonitorDTO1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,objects);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * NVR获取回放列表
|
|
|
+ * @param videoMonitorDTO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/getNvrRecordList", method = RequestMethod.POST)
|
|
|
+ public BaseResult getNvrRecordList(VideoMonitorDTO videoMonitorDTO){
|
|
|
+ int version = videoMonitorDTO.getVersion();
|
|
|
long startTime = System.currentTimeMillis() - 24 * 3600 * 1000;
|
|
|
ArrayList<VideoMonitorDTO> videoMonitorDTOS = new ArrayList<>();
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
@@ -98,4 +164,70 @@ public class VideoController {
|
|
|
videoMonitorVO.setList(videoMonitorDTOS);
|
|
|
return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,videoMonitorVO);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * NVR获取回放地址
|
|
|
+ * @param videoMonitorDTO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/getPlayBackAddressByChannel", method = RequestMethod.POST)
|
|
|
+ public BaseResult getPlayBackAddressByChannel(VideoMonitorDTO videoMonitorDTO){
|
|
|
+ int version = videoMonitorDTO.getVersion();
|
|
|
+ if (videoMonitorDTO.getId() == null || videoMonitorDTO.getChannel() == null || videoMonitorDTO.getStartTime() == null || videoMonitorDTO.getEndTime() == null) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
+ VideoMonitorDTO oneById = videoMonitorService.getOneById(videoMonitorDTO.getId());
|
|
|
+ String nvrGbPlayBackAddress = VideoUtil.getNvrGbPlayBackAddress(videoMonitorService, systemConfigService, oneById.getGbAddress(), videoMonitorDTO.getStartTime(), videoMonitorDTO.getEndTime(), videoMonitorDTO.getChannel());
|
|
|
+ VideoMonitorDTO videoMonitorDTO1 = new VideoMonitorDTO();
|
|
|
+ videoMonitorDTO1.setAddress(nvrGbPlayBackAddress);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,videoMonitorDTO1);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * NVR获取通道播放地址
|
|
|
+ * @param videoMonitorDTO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/getPlayAddressByChannel", method = RequestMethod.POST)
|
|
|
+ public BaseResult getPlayAddressByChannel(VideoMonitorDTO videoMonitorDTO){
|
|
|
+ int version = videoMonitorDTO.getVersion();
|
|
|
+ if (videoMonitorDTO.getId() == null || videoMonitorDTO.getChannel() == null || videoMonitorDTO.getStartTime() == null || videoMonitorDTO.getEndTime() == null) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
+ VideoMonitorDTO oneById = videoMonitorService.getOneById(videoMonitorDTO.getId());
|
|
|
+ String nvrGbPlayBackAddress = VideoUtil.getNvrGbPlayAddress(videoMonitorService, systemConfigService, oneById.getGbAddress(), videoMonitorDTO.getChannel());
|
|
|
+ VideoMonitorDTO videoMonitorDTO1 = new VideoMonitorDTO();
|
|
|
+ videoMonitorDTO1.setAddress(nvrGbPlayBackAddress);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,videoMonitorDTO1);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置报警位
|
|
|
+ * @param videoMonitorDTO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/setEmergencyLocation", method = RequestMethod.POST)
|
|
|
+ public BaseResult setEmergencyLocation(VideoMonitorDTO videoMonitorDTO){
|
|
|
+ int version = videoMonitorDTO.getVersion();
|
|
|
+ if (videoMonitorDTO.getId() == null) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
+ VideoMonitorDTO oneById = videoMonitorService.getOneById(videoMonitorDTO.getId());
|
|
|
+
|
|
|
+ String url = Constant.GB_HOST_ADDRESS+"/api/postion/"+oneById.getGbAddress()+"/34020000001320000001";
|
|
|
+ String param = "{\"code\":1,\"postion\":1}";
|
|
|
+ WebUtils.requestPost(url, param);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查看报警位
|
|
|
+ * @param videoMonitorDTO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/getEmergencyLocation", method = RequestMethod.POST)
|
|
|
+ public BaseResult getEmergencyLocation(VideoMonitorDTO videoMonitorDTO){
|
|
|
+ int version = videoMonitorDTO.getVersion();
|
|
|
+ if (videoMonitorDTO.getId() == null) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
+ VideoMonitorDTO oneById = videoMonitorService.getOneById(videoMonitorDTO.getId());
|
|
|
+
|
|
|
+ String url = Constant.GB_HOST_ADDRESS+"/api/postion/"+oneById.getGbAddress()+"/34020000001320000001";
|
|
|
+ String param = "{\"code\":2,\"postion\":1}";
|
|
|
+ WebUtils.requestPost(url, param);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
|
|
|
+ }
|
|
|
}
|