完善数据库结构调用
This commit is contained in:
@@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.genersoft.iot.vmp.common.InviteInfo;
|
||||
import com.genersoft.iot.vmp.common.InviteSessionType;
|
||||
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.Device;
|
||||
@@ -84,7 +85,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
|
||||
List<DeviceChannel> channelList = channelMapper.queryChannelsByDeviceDbId(device.getId());
|
||||
if (channelList.isEmpty()) {
|
||||
for (DeviceChannel channel : channels) {
|
||||
channel.setDeviceDbId(device.getId());
|
||||
channel.setDataDeviceId(device.getId());
|
||||
InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, channel.getId());
|
||||
if (inviteInfo != null && inviteInfo.getStreamInfo() != null) {
|
||||
channel.setStreamId(inviteInfo.getStreamInfo().getStream());
|
||||
@@ -96,7 +97,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
|
||||
}
|
||||
}else {
|
||||
for (DeviceChannel deviceChannel : channelList) {
|
||||
channelsInStore.put(deviceChannel.getDeviceDbId() + deviceChannel.getDeviceId(), deviceChannel);
|
||||
channelsInStore.put(deviceChannel.getDataDeviceId() + deviceChannel.getDeviceId(), deviceChannel);
|
||||
}
|
||||
for (DeviceChannel channel : channels) {
|
||||
InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, channel.getId());
|
||||
@@ -105,7 +106,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
|
||||
}
|
||||
String now = DateUtil.getNow();
|
||||
channel.setUpdateTime(now);
|
||||
DeviceChannel deviceChannelInDb = channelsInStore.get(channel.getDeviceDbId() + channel.getDeviceId());
|
||||
DeviceChannel deviceChannelInDb = channelsInStore.get(channel.getDataDeviceId() + channel.getDeviceId());
|
||||
if ( deviceChannelInDb != null) {
|
||||
channel.setId(deviceChannelInDb.getId());
|
||||
channel.setUpdateTime(now);
|
||||
@@ -324,7 +325,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
|
||||
}
|
||||
for (DeviceChannel channel : channels) {
|
||||
if (channel.getParentId() != null) {
|
||||
channelMapper.updateChannelSubCount(channel.getDeviceDbId(), channel.getParentId());
|
||||
channelMapper.updateChannelSubCount(channel.getDataDeviceId(), channel.getParentId());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -487,7 +488,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
|
||||
Map<String,DeviceChannel> allChannelMap = new HashMap<>();
|
||||
if (!allChannels.isEmpty()) {
|
||||
for (DeviceChannel deviceChannel : allChannels) {
|
||||
allChannelMap.put(deviceChannel.getDeviceDbId() + deviceChannel.getDeviceId(), deviceChannel);
|
||||
allChannelMap.put(deviceChannel.getDataDeviceId() + deviceChannel.getDeviceId(), deviceChannel);
|
||||
}
|
||||
}
|
||||
// 数据去重
|
||||
@@ -500,7 +501,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
|
||||
Map<String, Integer> subContMap = new HashMap<>();
|
||||
|
||||
for (DeviceChannel deviceChannel : deviceChannelList) {
|
||||
DeviceChannel channelInDb = allChannelMap.get(deviceChannel.getDeviceDbId() + deviceChannel.getDeviceId());
|
||||
DeviceChannel channelInDb = allChannelMap.get(deviceChannel.getDataDeviceId() + deviceChannel.getDeviceId());
|
||||
if (channelInDb != null) {
|
||||
deviceChannel.setStreamId(channelInDb.getStreamId());
|
||||
deviceChannel.setHasAudio(channelInDb.isHasAudio());
|
||||
@@ -520,7 +521,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
|
||||
deviceChannel.setUpdateTime(DateUtil.getNow());
|
||||
addChannels.add(deviceChannel);
|
||||
}
|
||||
allChannelMap.remove(deviceChannel.getDeviceDbId() + deviceChannel.getDeviceId());
|
||||
allChannelMap.remove(deviceChannel.getDataDeviceId() + deviceChannel.getDeviceId());
|
||||
channels.add(deviceChannel);
|
||||
if (!ObjectUtils.isEmpty(deviceChannel.getParentId())) {
|
||||
if (subContMap.get(deviceChannel.getParentId()) == null) {
|
||||
@@ -700,6 +701,8 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
|
||||
|
||||
@Override
|
||||
public void addChannel(DeviceChannel channel) {
|
||||
channel.setDataType(ChannelDataType.GB28181.value);
|
||||
channel.setDataDeviceId(channel.getDataDeviceId());
|
||||
channelMapper.add(channel);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.genersoft.iot.vmp.common.CommonCallback;
|
||||
import com.genersoft.iot.vmp.common.VideoManagerConstants;
|
||||
import com.genersoft.iot.vmp.common.enums.ChannelDataType;
|
||||
import com.genersoft.iot.vmp.conf.DynamicTask;
|
||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
||||
@@ -71,9 +72,6 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
@Autowired
|
||||
private PlatformChannelMapper platformChannelMapper;
|
||||
|
||||
@Autowired
|
||||
private IDeviceChannelService deviceChannelService;
|
||||
|
||||
@Autowired
|
||||
private DeviceChannelMapper deviceChannelMapper;
|
||||
|
||||
@@ -95,11 +93,15 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
@Autowired
|
||||
private AudioBroadcastManager audioBroadcastManager;
|
||||
|
||||
private Device getDeviceByDeviceIdFromDb(String deviceId) {
|
||||
return deviceMapper.getDeviceByDeviceId(deviceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void online(Device device, SipTransactionInfo sipTransactionInfo) {
|
||||
log.info("[设备上线] deviceId:{}->{}:{}", device.getDeviceId(), device.getIp(), device.getPort());
|
||||
Device deviceInRedis = redisCatchStorage.getDevice(device.getDeviceId());
|
||||
Device deviceInDb = deviceMapper.getDeviceByDeviceId(device.getDeviceId());
|
||||
Device deviceInDb = getDeviceByDeviceIdFromDb(device.getDeviceId());
|
||||
|
||||
String now = DateUtil.getNow();
|
||||
if (deviceInRedis != null && deviceInDb == null) {
|
||||
@@ -194,7 +196,7 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
@Override
|
||||
public void offline(String deviceId, String reason) {
|
||||
log.warn("[设备离线],{}, device:{}", reason, deviceId);
|
||||
Device device = deviceMapper.getDeviceByDeviceId(deviceId);
|
||||
Device device = getDeviceByDeviceIdFromDb(deviceId);
|
||||
if (device == null) {
|
||||
return;
|
||||
}
|
||||
@@ -346,7 +348,7 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
public Device getDeviceByDeviceId(String deviceId) {
|
||||
Device device = redisCatchStorage.getDevice(deviceId);
|
||||
if (device == null) {
|
||||
device = deviceMapper.getDeviceByDeviceId(deviceId);
|
||||
device = getDeviceByDeviceIdFromDb(deviceId);
|
||||
if (device != null) {
|
||||
redisCatchStorage.updateDevice(device);
|
||||
}
|
||||
@@ -361,7 +363,7 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
|
||||
@Override
|
||||
public List<Device> getAllByStatus(Boolean status) {
|
||||
return deviceMapper.getDevices(status);
|
||||
return deviceMapper.getDevices(ChannelDataType.GB28181.value, status);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -403,7 +405,7 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
|
||||
@Override
|
||||
public boolean isExist(String deviceId) {
|
||||
return deviceMapper.getDeviceByDeviceId(deviceId) != null;
|
||||
return getDeviceByDeviceIdFromDb(deviceId) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -496,7 +498,7 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean delete(String deviceId) {
|
||||
Device device = deviceMapper.getDeviceByDeviceId(deviceId);
|
||||
Device device = getDeviceByDeviceIdFromDb(deviceId);
|
||||
if (device == null) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到设备:" + deviceId);
|
||||
}
|
||||
@@ -527,7 +529,7 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
.replaceAll("%", "/%")
|
||||
.replaceAll("_", "/_");
|
||||
}
|
||||
List<Device> all = deviceMapper.getDeviceList(query, status);
|
||||
List<Device> all = deviceMapper.getDeviceList(ChannelDataType.GB28181.value, query, status);
|
||||
return new PageInfo<>(all);
|
||||
}
|
||||
|
||||
@@ -538,11 +540,11 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
|
||||
@Override
|
||||
public Device getDeviceByChannelId(Integer channelId) {
|
||||
return deviceMapper.queryByChannelId(channelId);
|
||||
return deviceMapper.queryByChannelId(ChannelDataType.GB28181.value,channelId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Device getDeviceBySourceChannelDeviceId(String channelId) {
|
||||
return deviceMapper.getDeviceBySourceChannelDeviceId(channelId);
|
||||
return deviceMapper.getDeviceBySourceChannelDeviceId(ChannelDataType.GB28181.value,channelId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -372,7 +372,7 @@ public class GbChannelServiceImpl implements IGbChannelService {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "非国标下级通道无法重置");
|
||||
}
|
||||
// 这个多加一个参数,为了防止将非国标的通道通过此方法清空内容,导致意外发生
|
||||
commonGBChannelMapper.reset(id, channel.getDataDeviceId(), DateUtil.getNow());
|
||||
commonGBChannelMapper.reset(id, ChannelDataType.GB28181.value, channel.getDataDeviceId(), DateUtil.getNow());
|
||||
CommonGBChannel channelNew = getOne(id);
|
||||
// 发送通过更新通知
|
||||
try {
|
||||
@@ -495,7 +495,7 @@ public class GbChannelServiceImpl implements IGbChannelService {
|
||||
|
||||
@Override
|
||||
public void addChannelToRegionByGbDevice(String civilCode, List<Integer> deviceIds) {
|
||||
List<CommonGBChannel> channelList = commonGBChannelMapper.queryByGbDeviceIds(deviceIds);
|
||||
List<CommonGBChannel> channelList = commonGBChannelMapper.queryByGbDeviceIds(ChannelDataType.GB28181.value, deviceIds);
|
||||
if (channelList.isEmpty()) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "所有通道Id不存在");
|
||||
}
|
||||
@@ -516,7 +516,7 @@ public class GbChannelServiceImpl implements IGbChannelService {
|
||||
|
||||
@Override
|
||||
public void deleteChannelToRegionByGbDevice(List<Integer> deviceIds) {
|
||||
List<CommonGBChannel> channelList = commonGBChannelMapper.queryByGbDeviceIds(deviceIds);
|
||||
List<CommonGBChannel> channelList = commonGBChannelMapper.queryByGbDeviceIds(ChannelDataType.GB28181.value, deviceIds);
|
||||
if (channelList.isEmpty()) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "所有通道Id不存在");
|
||||
}
|
||||
@@ -633,7 +633,7 @@ public class GbChannelServiceImpl implements IGbChannelService {
|
||||
@Override
|
||||
@Transactional
|
||||
public void addChannelToGroupByGbDevice(String parentId, String businessGroup, List<Integer> deviceIds) {
|
||||
List<CommonGBChannel> channelList = commonGBChannelMapper.queryByGbDeviceIds(deviceIds);
|
||||
List<CommonGBChannel> channelList = commonGBChannelMapper.queryByGbDeviceIds(ChannelDataType.GB28181.value, deviceIds);
|
||||
if (channelList.isEmpty()) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "所有通道Id不存在");
|
||||
}
|
||||
@@ -661,7 +661,7 @@ public class GbChannelServiceImpl implements IGbChannelService {
|
||||
|
||||
@Override
|
||||
public void deleteChannelToGroupByGbDevice(List<Integer> deviceIds) {
|
||||
List<CommonGBChannel> channelList = commonGBChannelMapper.queryByGbDeviceIds(deviceIds);
|
||||
List<CommonGBChannel> channelList = commonGBChannelMapper.queryByGbDeviceIds(ChannelDataType.GB28181.value, deviceIds);
|
||||
if (channelList.isEmpty()) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "所有通道Id不存在");
|
||||
}
|
||||
@@ -703,12 +703,12 @@ public class GbChannelServiceImpl implements IGbChannelService {
|
||||
|
||||
@Override
|
||||
public List<CommonGBChannel> queryListByStreamPushList(List<StreamPush> streamPushList) {
|
||||
return commonGBChannelMapper.queryListByStreamPushList(streamPushList);
|
||||
return commonGBChannelMapper.queryListByStreamPushList(ChannelDataType.STREAM_PUSH.value, streamPushList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateGpsByDeviceIdForStreamPush(List<CommonGBChannel> channels) {
|
||||
commonGBChannelMapper.updateGpsByDeviceIdForStreamPush(channels);
|
||||
commonGBChannelMapper.updateGpsByDeviceIdForStreamPush(ChannelDataType.STREAM_PUSH.value, channels);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.genersoft.iot.vmp.gb28181.service.impl;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.genersoft.iot.vmp.common.enums.ChannelDataType;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||
import com.genersoft.iot.vmp.gb28181.dao.*;
|
||||
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
|
||||
@@ -288,14 +289,14 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
||||
@Override
|
||||
@Transactional
|
||||
public void addChannelByDevice(Integer platformId, List<Integer> deviceIds) {
|
||||
List<Integer> channelList = commonGBChannelMapper.queryByGbDeviceIdsForIds(deviceIds);
|
||||
List<Integer> channelList = commonGBChannelMapper.queryByGbDeviceIdsForIds(ChannelDataType.GB28181.value, deviceIds);
|
||||
addChannels(platformId, channelList);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void removeChannelByDevice(Integer platformId, List<Integer> deviceIds) {
|
||||
List<Integer> channelList = commonGBChannelMapper.queryByGbDeviceIdsForIds(deviceIds);
|
||||
List<Integer> channelList = commonGBChannelMapper.queryByGbDeviceIdsForIds(ChannelDataType.GB28181.value, deviceIds);
|
||||
removeChannels(platformId, channelList);
|
||||
}
|
||||
|
||||
|
||||
@@ -1623,7 +1623,7 @@ public class PlayServiceImpl implements IPlayService {
|
||||
log.warn("[停止点播] 发现通道不存在");
|
||||
return;
|
||||
}
|
||||
Device device = deviceService.getDevice(channel.getDeviceDbId());
|
||||
Device device = deviceService.getDevice(channel.getDataDeviceId());
|
||||
if (device == null) {
|
||||
log.warn("[停止点播] 发现设备不存在");
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user