VideoController.java 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  1. package com.welampiot.controller;
  2. import com.alibaba.fastjson.JSON;
  3. import com.alibaba.fastjson.JSONArray;
  4. import com.alibaba.fastjson.JSONObject;
  5. import com.welampiot.common.BaseResult;
  6. import com.welampiot.common.Constant;
  7. import com.welampiot.common.InterfaceResultEnum;
  8. import com.welampiot.dto.VideoMonitorDTO;
  9. import com.welampiot.dto.VideoPointInfoDTO;
  10. import com.welampiot.service.SystemConfigService;
  11. import com.welampiot.service.VideoMonitorService;
  12. import com.welampiot.service.VideoPointInfoService;
  13. import com.welampiot.utils.ToolUtils;
  14. import com.welampiot.utils.VideoUtil;
  15. import com.welampiot.utils.WebUtils;
  16. import com.welampiot.vo.VideoMonitorDetailVO;
  17. import com.welampiot.vo.VideoMonitorVO;
  18. import com.welampiot.vo.VideoPointInfoVO;
  19. import org.slf4j.Logger;
  20. import org.slf4j.LoggerFactory;
  21. import org.springframework.beans.BeanUtils;
  22. import org.springframework.beans.factory.annotation.Autowired;
  23. import org.springframework.web.bind.annotation.CrossOrigin;
  24. import org.springframework.web.bind.annotation.RequestMapping;
  25. import org.springframework.web.bind.annotation.RequestMethod;
  26. import org.springframework.web.bind.annotation.RestController;
  27. import javax.servlet.http.HttpServletRequest;
  28. import java.text.SimpleDateFormat;
  29. import java.util.ArrayList;
  30. import java.util.Date;
  31. import java.util.List;
  32. @RestController
  33. @CrossOrigin
  34. @RequestMapping("/video")
  35. public class VideoController {
  36. private final static Logger log = LoggerFactory.getLogger(VideoController.class);
  37. @Autowired
  38. private ToolUtils toolUtils;
  39. @Autowired
  40. private VideoMonitorService videoMonitorService;
  41. @Autowired
  42. private SystemConfigService systemConfigService;
  43. @Autowired
  44. private VideoPointInfoService videoPointInfoService;
  45. /**
  46. * 设置AI开关状态
  47. * @param request
  48. * @return
  49. */
  50. @RequestMapping(value = "/setAiStatus", method = RequestMethod.POST)
  51. public BaseResult setAiStatus(HttpServletRequest request){
  52. int version = request.getParameter("version") == null ? 0 : Integer.parseInt(request.getParameter("version"));
  53. int lampPoleId = request.getParameter("lampPoleId") == null ? 0 : Integer.parseInt(request.getParameter("lampPoleId"));
  54. int status = request.getParameter("status") == null ? 0 : Integer.parseInt(request.getParameter("status"));
  55. VideoMonitorDTO videoMonitorDTO = new VideoMonitorDTO();
  56. videoMonitorDTO.setLampPoleId(lampPoleId);
  57. videoMonitorDTO.setIsInspect(status);
  58. return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
  59. }
  60. /**
  61. * 获取摄像头回放列表
  62. * @param videoMonitorDTO
  63. * @return
  64. */
  65. @RequestMapping(value = "/getRecordList", method = RequestMethod.POST)
  66. public BaseResult getRecordList(VideoMonitorDTO videoMonitorDTO){
  67. int version = videoMonitorDTO.getVersion();
  68. long startTime = System.currentTimeMillis() - 24 * 3600 * 1000;
  69. ArrayList<VideoMonitorDTO> videoMonitorDTOS = new ArrayList<>();
  70. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  71. while (System.currentTimeMillis() > startTime + 20 * 60 * 1000) {
  72. VideoMonitorDTO videoMonitorDTO1 = new VideoMonitorDTO();
  73. videoMonitorDTO1.setStartTime(simpleDateFormat.format(new Date(startTime)));
  74. videoMonitorDTO1.setEndTime(simpleDateFormat.format(new Date(startTime + 20 * 60 * 1000)));
  75. videoMonitorDTOS.add(videoMonitorDTO1);
  76. }
  77. VideoMonitorVO videoMonitorVO = new VideoMonitorVO();
  78. videoMonitorVO.setList(videoMonitorDTOS);
  79. return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,videoMonitorVO);
  80. }
  81. /**
  82. * 获取回放播放地址
  83. * @param videoMonitorDTO
  84. * @return
  85. */
  86. @RequestMapping(value = "/getRecordPlay", method = RequestMethod.POST)
  87. public BaseResult getRecordPlay(VideoMonitorDTO videoMonitorDTO){
  88. int version = videoMonitorDTO.getVersion();
  89. Integer id = videoMonitorDTO.getId();
  90. String startTime = videoMonitorDTO.getStartTime();
  91. String endTime = videoMonitorDTO.getEndTime();
  92. if (startTime == null || endTime == null) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
  93. VideoMonitorDTO oneById = videoMonitorService.getOneById(id);
  94. String gbAddress = oneById.getGbAddress();
  95. String gbPlayBackAddress = VideoUtil.getGbPlayBackAddress(videoMonitorService, systemConfigService, gbAddress, startTime, endTime);
  96. VideoMonitorDTO videoMonitorDTO1 = new VideoMonitorDTO();
  97. videoMonitorDTO1.setAddress(gbPlayBackAddress);
  98. return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,videoMonitorDTO1);
  99. }
  100. /**
  101. * 获取NVR通道值信息
  102. * @param videoMonitorDTO
  103. * @return
  104. */
  105. @RequestMapping(value = "/getChannelValue", method = RequestMethod.POST)
  106. public BaseResult getChannelValue(VideoMonitorDTO videoMonitorDTO){
  107. int version = videoMonitorDTO.getVersion();
  108. Integer id = videoMonitorDTO.getId();
  109. if (id == null || id == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
  110. VideoMonitorDTO oneById = videoMonitorService.getOneById(id);
  111. String url = Constant.GB_HOST_ADDRESS+"/api/devices";
  112. String s = WebUtils.requestGet(url);
  113. JSONArray jsonArray = JSON.parseArray(s);
  114. JSONObject data = null;
  115. if (jsonArray != null){
  116. for (Object j: jsonArray) {
  117. JSONObject j1 = (JSONObject) j;
  118. String deviceId = (String) j1.get("deviceId");
  119. if (deviceId.equalsIgnoreCase(oneById.getGbAddress())){
  120. data = j1;
  121. }
  122. }
  123. }
  124. ArrayList<Object> objects = new ArrayList<>();
  125. if (data != null){
  126. for (Object channelMap : (JSONArray) data.get("channelMap")) {
  127. JSONObject channelMap1 = (JSONObject) channelMap;
  128. VideoMonitorDTO videoMonitorDTO1 = new VideoMonitorDTO();
  129. videoMonitorDTO1.setName((String) channelMap1.get("name"));
  130. videoMonitorDTO1.setChannelId((String) channelMap1.get("channelId"));
  131. objects.add(videoMonitorDTO1);
  132. }
  133. }
  134. return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,objects);
  135. }
  136. /**
  137. * NVR获取回放列表
  138. * @param videoMonitorDTO
  139. * @return
  140. */
  141. @RequestMapping(value = "/getNvrRecordList", method = RequestMethod.POST)
  142. public BaseResult getNvrRecordList(VideoMonitorDTO videoMonitorDTO){
  143. int version = videoMonitorDTO.getVersion();
  144. long startTime = System.currentTimeMillis() - 24 * 3600 * 1000;
  145. ArrayList<VideoMonitorDTO> videoMonitorDTOS = new ArrayList<>();
  146. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  147. while (System.currentTimeMillis() > startTime + 20 * 60 * 1000) {
  148. VideoMonitorDTO videoMonitorDTO1 = new VideoMonitorDTO();
  149. videoMonitorDTO1.setStartTime(simpleDateFormat.format(new Date(startTime)));
  150. videoMonitorDTO1.setEndTime(simpleDateFormat.format(new Date(startTime + 20 * 60 * 1000)));
  151. videoMonitorDTOS.add(videoMonitorDTO1);
  152. }
  153. VideoMonitorVO videoMonitorVO = new VideoMonitorVO();
  154. videoMonitorVO.setList(videoMonitorDTOS);
  155. return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,videoMonitorVO);
  156. }
  157. /**
  158. * NVR获取回放地址
  159. * @param videoMonitorDTO
  160. * @return
  161. */
  162. @RequestMapping(value = "/getPlayBackAddressByChannel", method = RequestMethod.POST)
  163. public BaseResult getPlayBackAddressByChannel(VideoMonitorDTO videoMonitorDTO){
  164. int version = videoMonitorDTO.getVersion();
  165. if (videoMonitorDTO.getId() == null || videoMonitorDTO.getChannel() == null || videoMonitorDTO.getStartTime() == null || videoMonitorDTO.getEndTime() == null) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
  166. VideoMonitorDTO oneById = videoMonitorService.getOneById(videoMonitorDTO.getId());
  167. String nvrGbPlayBackAddress = VideoUtil.getNvrGbPlayBackAddress(videoMonitorService, systemConfigService, oneById.getGbAddress(), videoMonitorDTO.getStartTime(), videoMonitorDTO.getEndTime(), videoMonitorDTO.getChannel());
  168. VideoMonitorDTO videoMonitorDTO1 = new VideoMonitorDTO();
  169. videoMonitorDTO1.setAddress(nvrGbPlayBackAddress);
  170. return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,videoMonitorDTO1);
  171. }
  172. /**
  173. * NVR获取通道播放地址
  174. * @param videoMonitorDTO
  175. * @return
  176. */
  177. @RequestMapping(value = "/getPlayAddressByChannel", method = RequestMethod.POST)
  178. public BaseResult getPlayAddressByChannel(VideoMonitorDTO videoMonitorDTO){
  179. int version = videoMonitorDTO.getVersion();
  180. if (videoMonitorDTO.getId() == null || videoMonitorDTO.getChannel() == null || videoMonitorDTO.getStartTime() == null || videoMonitorDTO.getEndTime() == null) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
  181. VideoMonitorDTO oneById = videoMonitorService.getOneById(videoMonitorDTO.getId());
  182. String nvrGbPlayBackAddress = VideoUtil.getNvrGbPlayAddress(videoMonitorService, systemConfigService, oneById.getGbAddress(), videoMonitorDTO.getChannel());
  183. VideoMonitorDTO videoMonitorDTO1 = new VideoMonitorDTO();
  184. videoMonitorDTO1.setAddress(nvrGbPlayBackAddress);
  185. return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,videoMonitorDTO1);
  186. }
  187. /**
  188. * 设置报警位
  189. * @param videoMonitorDTO
  190. * @return
  191. */
  192. @RequestMapping(value = "/setEmergencyLocation", method = RequestMethod.POST)
  193. public BaseResult setEmergencyLocation(VideoMonitorDTO videoMonitorDTO){
  194. int version = videoMonitorDTO.getVersion();
  195. if (videoMonitorDTO.getId() == null) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
  196. VideoMonitorDTO oneById = videoMonitorService.getOneById(videoMonitorDTO.getId());
  197. String url = Constant.GB_HOST_ADDRESS+"/api/postion/"+oneById.getGbAddress()+"/34020000001320000001";
  198. String param = "{\"code\":1,\"postion\":1}";
  199. WebUtils.requestPost(url, param);
  200. return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
  201. }
  202. /**
  203. * 查看报警位
  204. * @param videoMonitorDTO
  205. * @return
  206. */
  207. @RequestMapping(value = "/getEmergencyLocation", method = RequestMethod.POST)
  208. public BaseResult getEmergencyLocation(VideoMonitorDTO videoMonitorDTO){
  209. int version = videoMonitorDTO.getVersion();
  210. if (videoMonitorDTO.getId() == null) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
  211. VideoMonitorDTO oneById = videoMonitorService.getOneById(videoMonitorDTO.getId());
  212. String url = Constant.GB_HOST_ADDRESS+"/api/postion/"+oneById.getGbAddress()+"/34020000001320000001";
  213. String param = "{\"code\":2,\"postion\":1}";
  214. WebUtils.requestPost(url, param);
  215. return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
  216. }
  217. /**
  218. * 视屏监控列表
  219. * @param request 路段,关键字搜索,分页
  220. * @return 视屏监控列表
  221. */
  222. @RequestMapping(value = "/getList", method = RequestMethod.POST)
  223. public BaseResult<?> getList(HttpServletRequest request) {
  224. Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
  225. Integer page = (Integer) toolUtils.getRequestContent(request,"page",1);
  226. Integer count = (Integer) toolUtils.getRequestContent(request,"count",1);
  227. Integer areaId = (Integer) toolUtils.getRequestContent(request,"areaId",1);
  228. Integer sectionId = (Integer) toolUtils.getRequestContent(request,"sectionId",1);
  229. String keyword = (String) toolUtils.getRequestContent(request,"keyword",2);
  230. if (page == 0) page = 1;
  231. if (count == 0) count = 16;
  232. VideoMonitorVO vo = new VideoMonitorVO();
  233. vo.setLimit(count * (page - 1));
  234. vo.setOffset(count);
  235. vo.setAreaId(areaId);
  236. vo.setSectionId(sectionId);
  237. vo.setKeyword(keyword);
  238. vo.setSectionList(toolUtils.getSectionList(request));
  239. List<VideoMonitorDTO> videoList = videoMonitorService.getVideoListByVO(vo);
  240. Integer total = videoMonitorService.getVideoTotal(vo);
  241. VideoMonitorVO videoMonitorVO = new VideoMonitorVO();
  242. videoMonitorVO.setList(videoList);
  243. videoMonitorVO.setTotal((int) Math.ceil(total / (double) count));
  244. return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,videoMonitorVO);
  245. }
  246. /**
  247. * 视屏监控详情
  248. * @param vo id
  249. * @return 视屏监控详情
  250. */
  251. @RequestMapping(value = "/info", method = RequestMethod.POST)
  252. public BaseResult<?> info(VideoMonitorVO vo) {
  253. if (vo.getVersion() == null) vo.setVersion(0);
  254. Integer version = vo.getVersion();
  255. Integer id = vo.getId();
  256. if (id == null || id == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
  257. VideoMonitorDTO videoMonitorDTO = videoMonitorService.getVideoMonitorDetailsById(vo);
  258. if (videoMonitorDTO == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL,version);
  259. VideoMonitorDetailVO videoMonitorDetailVO = new VideoMonitorDetailVO();
  260. BeanUtils.copyProperties(videoMonitorDTO,videoMonitorDetailVO);
  261. if (videoMonitorDetailVO.getType() != null && videoMonitorDetailVO.getType() == 1) {
  262. videoMonitorDetailVO.setTypeStr("NVR");
  263. } else {
  264. videoMonitorDetailVO.setTypeStr("IPC");
  265. }
  266. return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,videoMonitorDetailVO);
  267. }
  268. /**
  269. * 添加/编辑视屏监控
  270. * @param vo 视屏监控字段
  271. * @return 添加/编辑视屏监控
  272. */
  273. @RequestMapping(value = "/save", method = RequestMethod.POST)
  274. public BaseResult<?> save(VideoMonitorDetailVO vo) {
  275. if (vo.getVersion() == null) vo.setVersion(0);
  276. Integer version = vo.getVersion();
  277. Integer id = vo.getId();
  278. if (vo.getName() == null || vo.getName().trim().isEmpty())
  279. return toolUtils.response(InterfaceResultEnum.LACK_NAME_ERROR,version);
  280. if (vo.getSectionId() == null || vo.getSectionId() == 0)
  281. return toolUtils.response(InterfaceResultEnum.LACK_SECTION_ERROR,version);
  282. if (vo.getAreaId() == null || vo.getAreaId() == 0)
  283. return toolUtils.response(InterfaceResultEnum.LACK_AREA_ERROR,version);
  284. if (vo.getDevId() == null || vo.getDevId().isEmpty())
  285. return toolUtils.response(InterfaceResultEnum.LACK_DEV_SN_ERROR,version);
  286. if (vo.getPassword() == null || vo.getPassword().isEmpty())
  287. return toolUtils.response(InterfaceResultEnum.LACK_DEV_CODE_ERROR,version);
  288. if (vo.getDeviceType() == null)
  289. return toolUtils.response(InterfaceResultEnum.LACK_DEV_TYPE_ERROR,version);
  290. if (vo.getType() == null)
  291. return toolUtils.response(InterfaceResultEnum.LACK_VIDEO_TYPE_ERROR,version);
  292. VideoMonitorDTO videoMonitorDTO = new VideoMonitorDTO();
  293. BeanUtils.copyProperties(vo,videoMonitorDTO);
  294. VideoMonitorDTO dto = new VideoMonitorDTO();
  295. if (id == null || id == 0) { // 添加
  296. dto.setDevId(vo.getDevId());
  297. if (videoMonitorService.checkVideoDevId(dto) > 0)
  298. return toolUtils.response(InterfaceResultEnum.DEV_SN_UNIQUE_ERROR,version);
  299. videoMonitorService.addVideoMonitorData(videoMonitorDTO);
  300. } else { // 编辑
  301. dto.setId(id);
  302. dto.setDevId(vo.getDevId());
  303. if (videoMonitorService.checkVideoDevId(dto) > 0)
  304. return toolUtils.response(InterfaceResultEnum.DEV_SN_UNIQUE_ERROR,version);
  305. videoMonitorService.updateVideoMonitorData(videoMonitorDTO);
  306. }
  307. return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
  308. }
  309. /**
  310. * 删除视屏监控
  311. * @param vo id
  312. * @return 删除视屏监控
  313. */
  314. @RequestMapping(value = "/del", method = RequestMethod.POST)
  315. public BaseResult<?> del(VideoMonitorVO vo) {
  316. if (vo.getVersion() == null) vo.setVersion(0);
  317. Integer version = vo.getVersion();
  318. String videoId = vo.getVideoId();
  319. if (videoId == null || videoId.trim().isEmpty())
  320. return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
  321. String[] split = videoId.split(",");
  322. for (String s : split) {
  323. Integer id = Integer.valueOf(s);
  324. videoMonitorService.deleteVideoMonitorById(id);
  325. }
  326. return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
  327. }
  328. /**
  329. * 获取视屏监控点位信息
  330. * @param vo id
  331. * @return 获取视屏监控点位信息
  332. */
  333. @RequestMapping(value = "/getPointInfo", method = RequestMethod.POST)
  334. public BaseResult<?> getPointInfo(VideoPointInfoVO vo) {
  335. if (vo.getVersion() == null) vo.setVersion(0);
  336. Integer version = vo.getVersion();
  337. Integer id = vo.getId();
  338. if (id == null || id == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
  339. List<VideoPointInfoDTO> videoPointList = videoPointInfoService.getVideoPointListByVideoId(id);
  340. VideoPointInfoVO videoPointInfoVO = new VideoPointInfoVO();
  341. videoPointInfoVO.setList(videoPointList);
  342. return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,videoPointInfoVO);
  343. }
  344. /**
  345. * 设置点位信息
  346. * @param vo 点位属性
  347. * @return 设置点位信息
  348. */
  349. @RequestMapping(value = "/setPointInfo", method = RequestMethod.POST)
  350. public BaseResult<?> setPointInfo(VideoPointInfoVO vo) {
  351. if (vo.getVersion() == null) vo.setVersion(0);
  352. Integer version = vo.getVersion();
  353. Integer point = vo.getPoint();
  354. Integer time = vo.getTime();
  355. Integer videoId = vo.getVideoId();
  356. if (point == null || time == null || videoId == null)
  357. return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
  358. VideoPointInfoDTO videoPointInfoDTO = new VideoPointInfoDTO();
  359. BeanUtils.copyProperties(vo,videoPointInfoDTO);
  360. videoPointInfoService.addVideoPointData(videoPointInfoDTO);
  361. return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
  362. }
  363. /**
  364. * 设置点位状态
  365. * @param vo 点位属性
  366. * @return 设置点位状态
  367. */
  368. @RequestMapping(value = "/setPointStatus", method = RequestMethod.POST)
  369. public BaseResult<?> setPointStatus(VideoPointInfoVO vo) {
  370. if (vo.getVersion() == null) vo.setVersion(0);
  371. Integer version = vo.getVersion();
  372. Integer point = vo.getPoint();
  373. Integer status = vo.getStatus();
  374. Integer videoId = vo.getVideoId();
  375. if (point == null || status == null || videoId == null)
  376. return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
  377. VideoPointInfoDTO videoPointInfoDTO = new VideoPointInfoDTO();
  378. BeanUtils.copyProperties(vo,videoPointInfoDTO);
  379. videoPointInfoService.updateVideoPointStatus(videoPointInfoDTO);
  380. return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
  381. }
  382. /**
  383. * 云台控制
  384. * @param request
  385. * @return
  386. */
  387. @RequestMapping(value = "/yunStart", method = RequestMethod.POST)
  388. public BaseResult yunStart(HttpServletRequest request){
  389. Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
  390. Integer direction = (Integer) toolUtils.getRequestContent(request,"direction",1);
  391. String deviceSerial = (String) toolUtils.getRequestContent(request,"deviceSerial",2);
  392. if (deviceSerial.length() == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
  393. String requestData = "{\"moveSpeed\":130,\"zoomSpeed\":130";
  394. switch (direction){
  395. case 0:
  396. requestData += ",\"upDown\":1,\"leftRight\":0,\"inOut\":0";
  397. case 1:
  398. requestData += ",\"upDown\":2,\"leftRight\":0,\"inOut\":0";
  399. case 2:
  400. requestData += ",\"upDown\":0,\"leftRight\":1,\"inOut\":0";
  401. case 3:
  402. requestData += ",\"upDown\":0,\"leftRight\":2,\"inOut\":0";
  403. case 4:
  404. requestData += ",\"upDown\":1,\"leftRight\":1,\"inOut\":0";
  405. case 5:
  406. requestData += ",\"upDown\":2,\"leftRight\":1,\"inOut\":0";
  407. case 6:
  408. requestData += ",\"upDown\":1,\"leftRight\":2,\"inOut\":0";
  409. case 7:
  410. requestData += ",\"upDown\":2,\"leftRight\":2,\"inOut\":0";
  411. case 8:
  412. requestData += ",\"upDown\":0,\"leftRight\":0,\"inOut\":2";
  413. case 9:
  414. requestData += ",\"upDown\":0,\"leftRight\":0,\"inOut\":1";
  415. }
  416. requestData += "}";
  417. VideoMonitorDTO oneByDevId = videoMonitorService.getOneByDevId(deviceSerial);
  418. String url1 = Constant.GB_HOST_ADDRESS+"/api/ptz/"+oneByDevId.getGbAddress()+"/34020000001320000001";
  419. WebUtils.requestPost(url1, requestData);
  420. try {
  421. Thread.sleep(500);
  422. } catch (InterruptedException e) {
  423. // throw new RuntimeException(e);
  424. }
  425. requestData = "{\"upDown\":0,\"leftRight\":0,\"inOut\":0,\"moveSpeed\":0,\"zoomSpeed\":0}";
  426. WebUtils.requestPost(url1, requestData);
  427. return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
  428. }
  429. /**
  430. * 播放视屏监控
  431. * @param request
  432. * @return
  433. */
  434. @RequestMapping(value = "/videoPlay", method = RequestMethod.POST)
  435. public BaseResult videoPlay(HttpServletRequest request){
  436. Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
  437. Integer id = (Integer) toolUtils.getRequestContent(request,"id",1);
  438. if (id == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
  439. VideoMonitorDTO oneById = videoMonitorService.getOneById(id);
  440. String gbPlayAddress = VideoUtil.getGbPlayAddress(oneById.getGbAddress());
  441. oneById.setHlsHd(gbPlayAddress);
  442. oneById.setRtmp(gbPlayAddress);
  443. oneById.setRtmp2(gbPlayAddress);
  444. oneById.setRtmpHD2(gbPlayAddress);
  445. return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,oneById);
  446. }
  447. /**
  448. * 播放视屏监控
  449. * @param request
  450. * @return
  451. */
  452. @RequestMapping(value = "/videoPlayAsy", method = RequestMethod.POST)
  453. public BaseResult videoPlayAsy(HttpServletRequest request){
  454. Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
  455. Integer id = (Integer) toolUtils.getRequestContent(request,"id",1);
  456. if (id == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
  457. VideoMonitorDTO oneById = videoMonitorService.getOneById(id);
  458. String gbPlayAddress = VideoUtil.getGbPlayAddress(oneById.getGbAddress());
  459. oneById.setHlsHd(gbPlayAddress);
  460. oneById.setRtmp(gbPlayAddress);
  461. oneById.setRtmp2(gbPlayAddress);
  462. oneById.setRtmpHD2(gbPlayAddress);
  463. return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,oneById);
  464. }
  465. /**
  466. * 查看点位
  467. * @param request
  468. * @return
  469. */
  470. @RequestMapping(value = "/viewPoint", method = RequestMethod.POST)
  471. public BaseResult viewPoint(HttpServletRequest request){
  472. Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
  473. Integer id = (Integer) toolUtils.getRequestContent(request,"videoId",1);
  474. Integer point = (Integer) toolUtils.getRequestContent(request,"point",1);
  475. if (id == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
  476. VideoMonitorDTO oneById = videoMonitorService.getOneById(id);
  477. point = point + 1;
  478. String url = Constant.GB_HOST_ADDRESS+"/api/postion/"+oneById.getGbAddress()+"/34020000001320000001";
  479. String param = "{\"code\":2,\"postion\":"+point+"}";
  480. WebUtils.requestPost(url, param);
  481. return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
  482. }
  483. }