| | |
| | | package com.genersoft.iot.vmp.vmanager.platform; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; |
| | |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import com.genersoft.iot.vmp.conf.SipConfig; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | |
| | | @CrossOrigin |
| | | @RestController |
| | |
| | | public ResponseEntity<String> savePlatform(@RequestBody ParentPlatform parentPlatform){ |
| | | |
| | | if (logger.isDebugEnabled()) { |
| | | logger.debug("查询所有上级设备API调用"); |
| | | logger.debug("保存上级平台信息API调用"); |
| | | } |
| | | if (StringUtils.isEmpty(parentPlatform.getName()) |
| | | ||StringUtils.isEmpty(parentPlatform.getServerGBId()) |
| | |
| | | if (parentPlatform.isEnable()) { |
| | | // 只要保存就发送注册 |
| | | commanderForPlatform.register(parentPlatform); |
| | | }else if (parentPlatformOld != null && parentPlatformOld.isEnable() && !parentPlatform.isEnable()){ // 关闭启用时注销 |
| | | } else if (parentPlatformOld != null && parentPlatformOld.isEnable() && !parentPlatform.isEnable()){ // 关闭启用时注销 |
| | | commanderForPlatform.unregister(parentPlatform, null, null); |
| | | } |
| | | |
| | | |
| | | |
| | | return new ResponseEntity<>("success", HttpStatus.OK); |
| | | }else { |
| | | } else { |
| | | return new ResponseEntity<>("fail", HttpStatus.OK); |
| | | } |
| | | } |
| | |
| | | public ResponseEntity<String> deletePlatform(@RequestBody ParentPlatform parentPlatform){ |
| | | |
| | | if (logger.isDebugEnabled()) { |
| | | logger.debug("查询所有上级设备API调用"); |
| | | logger.debug("删除上级平台API调用"); |
| | | } |
| | | if (StringUtils.isEmpty(parentPlatform.getDeviceGBId()) |
| | | if (StringUtils.isEmpty(parentPlatform.getServerGBId()) |
| | | ){ |
| | | return new ResponseEntity<>("missing parameters", HttpStatus.BAD_REQUEST); |
| | | } |
| | |
| | | // 发送离线消息,无论是否成功都删除缓存 |
| | | commanderForPlatform.unregister(parentPlatform, (event -> { |
| | | // 清空redis缓存 |
| | | redisCatchStorage.delPlatformCatchInfo(parentPlatform.getDeviceGBId()); |
| | | redisCatchStorage.delPlatformKeepalive(parentPlatform.getDeviceGBId()); |
| | | redisCatchStorage.delPlatformRegister(parentPlatform.getDeviceGBId()); |
| | | redisCatchStorage.delPlatformCatchInfo(parentPlatform.getServerGBId()); |
| | | redisCatchStorage.delPlatformKeepalive(parentPlatform.getServerGBId()); |
| | | redisCatchStorage.delPlatformRegister(parentPlatform.getServerGBId()); |
| | | }), (event -> { |
| | | // 清空redis缓存 |
| | | redisCatchStorage.delPlatformCatchInfo(parentPlatform.getDeviceGBId()); |
| | | redisCatchStorage.delPlatformKeepalive(parentPlatform.getDeviceGBId()); |
| | | redisCatchStorage.delPlatformRegister(parentPlatform.getDeviceGBId()); |
| | | redisCatchStorage.delPlatformCatchInfo(parentPlatform.getServerGBId()); |
| | | redisCatchStorage.delPlatformKeepalive(parentPlatform.getServerGBId()); |
| | | redisCatchStorage.delPlatformRegister(parentPlatform.getServerGBId()); |
| | | })); |
| | | |
| | | boolean deleteResult = storager.deleteParentPlatform(parentPlatform); |
| | |
| | | public ResponseEntity<String> exitPlatform(@PathVariable String deviceGbId){ |
| | | |
| | | if (logger.isDebugEnabled()) { |
| | | logger.debug("查询所有上级设备API调用"); |
| | | logger.debug("查询上级平台是否存在API调用:" + deviceGbId); |
| | | } |
| | | ParentPlatform parentPlatform = storager.queryParentPlatById(deviceGbId); |
| | | return new ResponseEntity<>(String.valueOf(parentPlatform != null), HttpStatus.OK); |
| | |
| | | public ResponseEntity<String> delChannelForGB(@RequestBody UpdateChannelParam param){ |
| | | |
| | | if (logger.isDebugEnabled()) { |
| | | logger.debug("给上级平台添加国标通道API调用"); |
| | | logger.debug("给上级平台删除国标通道API调用"); |
| | | } |
| | | int result = storager.delChannelForGB(param.getPlatformId(), param.getChannelReduces()); |
| | | |