lawrencehj
2021-03-10 2c1dbe63de3d370d0b0f20fea474326e88b9ca23
src/main/java/com/genersoft/iot/vmp/vmanager/platform/PlatformController.java
@@ -1,6 +1,5 @@
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;
@@ -17,10 +16,6 @@
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
@@ -82,7 +77,8 @@
        }
        // TODO 检查是否已经存在,且注册成功, 如果注册成功,需要先注销之前再,修改并注册
        ParentPlatform parentPlatformOld = storager.queryParentPlatById(parentPlatform.getDeviceGBId());
        // ParentPlatform parentPlatformOld = storager.queryParentPlatById(parentPlatform.getDeviceGBId());
        ParentPlatform parentPlatformOld = storager.queryParentPlatById(parentPlatform.getServerGBId());
        boolean updateResult = storager.updateParentPlatform(parentPlatform);
@@ -109,7 +105,7 @@
        if (logger.isDebugEnabled()) {
            logger.debug("查询所有上级设备API调用");
        }
        if (StringUtils.isEmpty(parentPlatform.getDeviceGBId())
        if (StringUtils.isEmpty(parentPlatform.getServerGBId())
        ){
            return new ResponseEntity<>("missing parameters", HttpStatus.BAD_REQUEST);
        }
@@ -117,14 +113,14 @@
        // 发送离线消息,无论是否成功都删除缓存
        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);
@@ -151,15 +147,21 @@
    @RequestMapping("/platforms/channelList")
    @ResponseBody
    public PageInfo<ChannelReduce> channelList(int page, int count,
                                              @RequestParam(required = false) String platformId,
                                              @RequestParam(required = false) String query,
                                              @RequestParam(required = false) Boolean online,
                                              @RequestParam(required = false) Boolean choosed,
                                              @RequestParam(required = false) Boolean channelType){
        if (logger.isDebugEnabled()) {
            logger.debug("查询所有所有通道API调用");
        }
        PageInfo<ChannelReduce> channelReduces = storager.queryChannelListInAll(page, count, query, online, channelType, null);
        PageInfo<ChannelReduce> channelReduces = null;
        if (platformId != null ) {
            channelReduces = storager.queryAllChannelList(page, count, query, online, channelType, platformId, choosed);
        }else {
            channelReduces = storager.queryAllChannelList(page, count, query, online, channelType, null, false);
        }
        return channelReduces;
    }
@@ -177,5 +179,17 @@
        return new ResponseEntity<>(String.valueOf(result > 0), HttpStatus.OK);
    }
    @RequestMapping("/platforms/delChannelForGB")
    @ResponseBody
    public ResponseEntity<String> delChannelForGB(@RequestBody UpdateChannelParam param){
        if (logger.isDebugEnabled()) {
            logger.debug("给上级平台添加国标通道API调用");
        }
        int result = storager.delChannelForGB(param.getPlatformId(), param.getChannelReduces());
        return new ResponseEntity<>(String.valueOf(result > 0), HttpStatus.OK);
    }
}