调整代码对通道类型的调用

pull/1733/head
648540858 2024-12-23 18:37:24 +08:00
parent 19453f7ca9
commit 59e3175f00
6 changed files with 24 additions and 20 deletions

View File

@ -550,4 +550,6 @@ public interface CommonGBChannelMapper {
@Param("channelType") Integer channelType, @Param("online") Boolean online,
@Param("hasLink") Boolean hasLink);
@SelectProvider(type = ChannelProvider.class, method = "queryByDataId")
CommonGBChannel queryByDataId(@Param("dataType") Integer dataType, @Param("dataDeviceId") Integer dataDeviceId);
}

View File

@ -113,6 +113,10 @@ public class ChannelProvider {
return BASE_SQL + " where channel_type = 0 and stream_push_id = #{streamPushId}";
}
public String queryByDataId(Map<String, Object> params ){
return BASE_SQL + " where data_type = #{dataType} and data_device_id = #{dataDeviceId}";
}
public String queryByStreamProxyId(Map<String, Object> params ){
return BASE_SQL + " where channel_type = 0 and stream_proxy_id = #{streamProxyId}";
}

View File

@ -1,5 +1,6 @@
package com.genersoft.iot.vmp.gb28181.service.impl;
import com.genersoft.iot.vmp.common.enums.ChannelDataType;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.dao.CommonGBChannelMapper;
@ -53,18 +54,13 @@ public class GbChannelServiceImpl implements IGbChannelService {
@Override
public int add(CommonGBChannel commonGBChannel) {
if (commonGBChannel.getDataType() != null && commonGBChannel.getDataDeviceId() > 0) {
CommonGBChannel commonGBChannelInDb = commonGBChannelMapper.queryByStreamPushId(commonGBChannel.getStreamPushId());
if (commonGBChannel.getDataType() == null || commonGBChannel.getDataDeviceId() == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "缺少通道数据类型或通道数据关联设备ID");
}
CommonGBChannel commonGBChannelInDb = commonGBChannelMapper.queryByDataId(commonGBChannel.getDataType(), commonGBChannel.getDataDeviceId());
if (commonGBChannelInDb != null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "此推流已经关联通道");
}
}
if (commonGBChannel.getStreamProxyId() != null && commonGBChannel.getStreamProxyId() > 0) {
CommonGBChannel commonGBChannelInDb = commonGBChannelMapper.queryByStreamProxyId(commonGBChannel.getStreamProxyId());
if (commonGBChannelInDb != null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "此代理已经关联通道");
}
}
commonGBChannel.setCreateTime(DateUtil.getNow());
commonGBChannel.setUpdateTime(DateUtil.getNow());
return commonGBChannelMapper.insert(commonGBChannel);
@ -113,7 +109,7 @@ public class GbChannelServiceImpl implements IGbChannelService {
public int update(CommonGBChannel commonGBChannel) {
log.info("[更新通道] 通道ID: {}, ", commonGBChannel.getGbId());
if (commonGBChannel.getGbId() <= 0) {
log.warn("[更新通道] 未找到数据库ID更新失败 {}", commonGBChannel.getGbDeviceDbId());
log.warn("[更新通道] 未找到数据库ID更新失败 {}({})", commonGBChannel.getGbName(), commonGBChannel.getGbDeviceId());
return 0;
}
commonGBChannel.setUpdateTime(DateUtil.getNow());
@ -132,7 +128,7 @@ public class GbChannelServiceImpl implements IGbChannelService {
@Override
public int offline(CommonGBChannel commonGBChannel) {
if (commonGBChannel.getGbId() <= 0) {
log.warn("[通道离线] 未找到数据库ID更新失败 {}", commonGBChannel.getGbDeviceDbId());
log.warn("[通道离线] 未找到数据库ID更新失败 {}({})", commonGBChannel.getGbName(), commonGBChannel.getGbDeviceId());
return 0;
}
int result = commonGBChannelMapper.updateStatusById(commonGBChannel.getGbId(), 0);
@ -186,7 +182,7 @@ public class GbChannelServiceImpl implements IGbChannelService {
@Override
public int online(CommonGBChannel commonGBChannel) {
if (commonGBChannel.getGbId() <= 0) {
log.warn("[通道上线] 未找到数据库ID更新失败 {}", commonGBChannel.getGbDeviceDbId());
log.warn("[通道上线] 未找到数据库ID更新失败 {}({})", commonGBChannel.getGbName(), commonGBChannel.getGbDeviceId());
return 0;
}
int result = commonGBChannelMapper.updateStatusById(commonGBChannel.getGbId(), 1);
@ -371,12 +367,12 @@ public class GbChannelServiceImpl implements IGbChannelService {
log.warn("[重置国标通道] 未找到对应Id的通道: id: {}", id);
throw new ControllerException(ErrorCode.ERROR400);
}
if (channel.getGbDeviceDbId() <= 0) {
if (channel.getDataType() == ChannelDataType.GB28181.value) {
log.warn("[重置国标通道] 非国标下级通道无法重置: id: {}", id);
throw new ControllerException(ErrorCode.ERROR100.getCode(), "非国标下级通道无法重置");
}
// 这个多加一个参数,为了防止将非国标的通道通过此方法清空内容,导致意外发生
commonGBChannelMapper.reset(id, channel.getGbDeviceDbId(), DateUtil.getNow());
commonGBChannelMapper.reset(id, channel.getDataDeviceId(), DateUtil.getNow());
CommonGBChannel channelNew = getOne(id);
// 发送通过更新通知
try {

View File

@ -7,7 +7,6 @@ import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
import com.genersoft.iot.vmp.gb28181.service.IPlatformChannelService;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
import com.genersoft.iot.vmp.jt1078.proc.request.Re;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
@ -432,7 +431,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
eventPublisher.catalogEventPublish(channel.getPlatformId(), commonGBChannel, CatalogEvent.UPDATE);
} catch (Exception e) {
log.warn("[自定义通道信息] 发送失败, 平台ID {} 通道: {}{}", channel.getPlatformId(),
channel.getGbName(), channel.getGbDeviceDbId(), e);
channel.getGbName(), channel.getId(), e);
}
}

View File

@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.streamProxy.service.impl;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.common.enums.ChannelDataType;
import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
@ -179,7 +180,8 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
streamProxy.setCreateTime(DateUtil.getNow());
streamProxy.setUpdateTime(DateUtil.getNow());
streamProxyMapper.add(streamProxy);
streamProxy.setStreamProxyId(streamProxy.getId());
streamProxy.setDataType(ChannelDataType.STREAM_PROXY.value);
streamProxy.setDataDeviceId(streamProxy.getId());
}
@Override

View File

@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.streamPush.controller;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelReader;
import com.alibaba.excel.read.metadata.ReadSheet;
import com.genersoft.iot.vmp.common.enums.ChannelDataType;
import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.conf.security.JwtUtils;
@ -28,7 +29,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
@ -215,7 +215,8 @@ public class StreamPushController {
if (!streamPushService.add(stream)) {
throw new ControllerException(ErrorCode.ERROR100);
}
stream.setStreamPushId(stream.getId());
stream.setDataType(ChannelDataType.STREAM_PUSH.value);
stream.setDataDeviceId(stream.getId());
return stream;
}