diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java index 308f7eab..1a4ed985 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java @@ -184,7 +184,7 @@ public class DeviceChannel extends CommonGBChannel { private String streamId; @Schema(description = "是否含有音频") - private Boolean hasAudio; + private boolean hasAudio; @Schema(description = "GPS的更新时间") private String gpsTime; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java index 325ec32a..89aa951e 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java @@ -162,13 +162,11 @@ public interface DeviceChannelMapper { " coalesce(dc.gb_svc_time_support_mode,dc.svc_time_support_mode) as svc_time_support_mode\n" + " from " + " wvp_device_channel dc " + - " left join wvp_device d on d.id=dc.device_db_id" + " WHERE " + - " d.device_id = #{deviceId} " + + " dc.device_db_id = #{deviceDbId} " + " AND (" + - "dc.device_id LIKE concat('%',#{query},'%') " + - "OR dc.name LIKE concat('%',#{query},'%') " + - "OR dc.custom_name LIKE concat('%',#{query},'%')" + + "coalesce(dc.gb_device_id, dc.device_id) LIKE concat('%',#{query},'%') " + + "OR coalesce(dc.gb_name, dc.name) LIKE concat('%',#{query},'%') " + ") " + " AND (dc.parent_id=#{parentChannelId} OR dc.civil_code = #{parentChannelId}) " + " AND dc.status= true" + @@ -180,7 +178,7 @@ public interface DeviceChannelMapper { " " + "ORDER BY dc.device_id " + " "}) - List queryChannels(@Param("deviceId") String deviceId, @Param("parentChannelId") String parentChannelId, @Param("query") String query, @Param("hasSubChannel") Boolean hasSubChannel, @Param("online") Boolean online, @Param("channelIds") List channelIds); + List queryChannels(@Param("deviceDbId") int deviceDbId, @Param("parentChannelId") String parentChannelId, @Param("query") String query, @Param("hasSubChannel") Boolean hasSubChannel, @Param("online") Boolean online, @Param("channelIds") List channelIds); @Select("select\n" + @@ -607,7 +605,7 @@ public interface DeviceChannelMapper { " coalesce(gb_business_group_id, business_group_id) as business_group_id,\n" + " coalesce(gb_download_speed, download_speed) as download_speed,\n" + " coalesce(gb_svc_space_support_mod, svc_space_support_mod) as svc_space_support_mod,\n" + - " coalesce(gb_svc_time_support_mode svc_time_support_mode) as svc_time_support_mode\n" + + " coalesce(gb_svc_time_support_mode, svc_time_support_mode) as svc_time_support_mode\n" + "from wvp_device_channel " + "where device_db_id=#{deviceDbId}" + " and parent_id = #{parentId} " + @@ -636,4 +634,103 @@ public interface DeviceChannelMapper { ""}) void batchUpdatePosition(List channelList); + @Select(value = {" "}) + DeviceChannel getOne(@Param("id") int id); + + @Select(value = {" "}) + DeviceChannel getOneByDeviceId(@Param("deviceDbId") int deviceDbId, @Param("channelId") String channelId); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceMapper.java index c4d653b2..a99aa9dd 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceMapper.java @@ -1,6 +1,7 @@ package com.genersoft.iot.vmp.gb28181.dao; import com.genersoft.iot.vmp.gb28181.bean.Device; +import com.github.pagehelper.PageInfo; import org.apache.ibatis.annotations.*; import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Repository; @@ -300,4 +301,45 @@ public interface DeviceMapper { @Select("select * FROM wvp_device where as_message_channel = true") List queryDeviceWithAsMessageChannel(); + + @Select(" ") + List getDeviceList(@Param("query") String query, @Param("status") Boolean status); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java index 2ad16046..fb1bf9df 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java @@ -491,7 +491,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements String stream = device.getDeviceId() + "_" + channelId + "_" + startTimeStr + "_" + endTimeStr; int tcpMode = device.getStreamMode().equals("TCP-ACTIVE")? 2: (device.getStreamMode().equals("TCP-PASSIVE")? 1:0); SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, stream, null, - device.isSsrcCheck(), true, 0,false,!channel.getHasAudio(), false, tcpMode); + device.isSsrcCheck(), true, 0,false,!channel.isHasAudio(), false, tcpMode); sendRtpItem.setStream(stream); // 写入redis, 超时时回复 redisCatchStorage.updateSendRTPSever(sendRtpItem); @@ -522,7 +522,8 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements sendRtpItem.setPlayType(InviteStreamType.DOWNLOAD); int tcpMode = device.getStreamMode().equals("TCP-ACTIVE")? 2: (device.getStreamMode().equals("TCP-PASSIVE")? 1:0); - SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, null, null, device.isSsrcCheck(), true, 0, false,!channel.getHasAudio(), false, tcpMode); + SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, null, null, + device.isSsrcCheck(), true, 0, false,!channel.isHasAudio(), false, tcpMode); sendRtpItem.setStream(ssrcInfo.getStream()); // 写入redis, 超时时回复 redisCatchStorage.updateSendRTPSever(sendRtpItem); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java index ce90b8df..30ad811b 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java @@ -182,7 +182,7 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent log.info("[增加通道] 已存在,不发送通知只更新,设备: {}, 通道 {}", device.getDeviceId(), catalogChannelEvent.getChannel().getDeviceId()); DeviceChannel channel = catalogChannelEvent.getChannel(); channel.setId(deviceChannel.getId()); - channel.setHasAudio(deviceChannel.getHasAudio()); + channel.setHasAudio(deviceChannel.isHasAudio()); channel.setUpdateTime(DateUtil.getNow()); updateChannelMap.put(catalogChannelEvent.getChannel().getDeviceId(), channel); } else { @@ -211,7 +211,7 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent if (deviceChannelForUpdate != null) { DeviceChannel channel = catalogChannelEvent.getChannel(); channel.setId(deviceChannelForUpdate.getId()); - channel.setHasAudio(deviceChannelForUpdate.getHasAudio()); + channel.setHasAudio(deviceChannelForUpdate.isHasAudio()); channel.setUpdateTime(DateUtil.getNow()); updateChannelMap.put(catalogChannelEvent.getChannel().getDeviceId(), channel); } else { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/info/InfoRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/info/InfoRequestProcessor.java index 9b85e718..6245301b 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/info/InfoRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/info/InfoRequestProcessor.java @@ -10,6 +10,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor; import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; import com.genersoft.iot.vmp.gb28181.utils.SipUtils; +import com.genersoft.iot.vmp.service.IDeviceService; import com.genersoft.iot.vmp.service.IInviteStreamService; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; @@ -49,7 +50,7 @@ public class InfoRequestProcessor extends SIPRequestProcessorParent implements I private IInviteStreamService inviteStreamService; @Autowired - private IVideoManagerStorage storager; + private IDeviceService deviceService; @Autowired private SIPCommander cmder; @@ -113,7 +114,7 @@ public class InfoRequestProcessor extends SIPRequestProcessorParent implements I responseAck(request, Response.NOT_FOUND, "stream " + streamId + " not found"); return; } - Device device1 = storager.queryVideoDevice(inviteInfo.getDeviceId()); + Device device1 = deviceService.getDevice(inviteInfo.getDeviceId()); if (inviteInfo.getStreamInfo() != null) { cmder.playbackControlCmd(device1,inviteInfo.getStreamInfo(),new String(evt.getRequest().getRawContent()),eventResult -> { // 失败的回复 diff --git a/src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java b/src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java index 60a75526..b6fcfb15 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java @@ -5,6 +5,8 @@ import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.MobilePosition; import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo; import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; +import com.genersoft.iot.vmp.web.gb28181.dto.DeviceChannelExtend; +import com.github.pagehelper.PageInfo; import java.util.List; @@ -40,6 +42,8 @@ public interface IDeviceChannelService { */ List queryAllChannelList(String platformId); + PageInfo queryAllChannelList(int page, int count, String query, Boolean online, Boolean channelType, String platformId, String catalogId); + /** * 查询通道所属的设备 */ @@ -103,5 +107,12 @@ public interface IDeviceChannelService { boolean resetChannels(String deviceId, List deviceChannels); + PageInfo getSubChannels(int deviceDbId, String channelId, String query, Boolean channelType, Boolean online, int page, int count); + List queryChannelExtendsByDeviceId(String deviceId, List channelIds, Boolean online); + + PageInfo queryChannelsByDeviceId(String deviceId, String query, Boolean channelType, Boolean online, int page, int count); + + + List queryDeviceWithAsMessageChannel(); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java b/src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java index e9af54e6..2383ba29 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java @@ -6,6 +6,7 @@ import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo; import com.genersoft.iot.vmp.gb28181.bean.SyncStatus; import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo; +import com.github.pagehelper.PageInfo; import java.util.List; @@ -88,6 +89,8 @@ public interface IDeviceService { */ List getAllOnlineDevice(); + List getAllByStatus(boolean status); + /** * 判断是否注册已经失效 * @param device 设备信息 @@ -159,4 +162,6 @@ public interface IDeviceService { * 获取所有设备 */ List getAll(); + + PageInfo getAll(int page, int count, String query, Boolean status); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java index 46ef5e78..9852e230 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java @@ -22,6 +22,9 @@ import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo; import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; +import com.genersoft.iot.vmp.web.gb28181.dto.DeviceChannelExtend; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -74,7 +77,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { } String now = DateUtil.getNow(); channel.setUpdateTime(now); - DeviceChannel deviceChannel = channelMapper.queryChannel(deviceId, channelId); + DeviceChannel deviceChannel = getOne(deviceId, channelId); if (deviceChannel == null) { channel.setCreateTime(now); channelMapper.add(channel); @@ -170,6 +173,13 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { return channelMapper.queryChannelListInAll(null, null, null, platformId, null); } + @Override + public PageInfo queryAllChannelList(int page, int count, String query, Boolean online, Boolean channelType, String platformId, String catalogId) { + PageHelper.startPage(page, count); + List all = channelMapper.queryChannelListInAll(query, online, channelType, platformId, catalogId); + return new PageInfo<>(all); + } + @Override public List getDeviceByChannelId(String channelId) { @@ -209,7 +219,11 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { @Override public DeviceChannel getOne(String deviceId, String channelId){ - return channelMapper.queryChannel(deviceId, channelId); + Device device = deviceMapper.getDeviceByDeviceId(deviceId); + if (device == null) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到设备:" + deviceId); + } + return channelMapper.getOneByDeviceId(device.getId(), channelId); } @Override @@ -424,7 +438,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { DeviceChannel channelInDb = allChannelMap.get(deviceChannel.getDeviceDbId() + deviceChannel.getDeviceId()); if (channelInDb != null) { deviceChannel.setStreamId(channelInDb.getStreamId()); - deviceChannel.setHasAudio(channelInDb.getHasAudio()); + deviceChannel.setHasAudio(channelInDb.isHasAudio()); deviceChannel.setId(channelInDb.getId()); if (channelInDb.getStatus().equalsIgnoreCase(deviceChannel.getStatus())){ List strings = platformChannelMapper.queryParentPlatformByChannelId(deviceChannel.getDeviceId()); @@ -518,4 +532,33 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { return true; } + + @Override + public PageInfo getSubChannels(int deviceDbId, String channelId, String query, Boolean channelType, Boolean online, int page, int count) { + PageHelper.startPage(page, count); + List all = channelMapper.queryChannels(deviceDbId, channelId, query, channelType, online,null); + return new PageInfo<>(all); + } + + @Override + public List queryChannelExtendsByDeviceId(String deviceId, List channelIds, Boolean online) { + return channelMapper.queryChannelsWithDeviceInfo(deviceId, null,null, null, online,channelIds); + } + + @Override + public PageInfo queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, int page, int count) { + Device device = deviceMapper.getDeviceByDeviceId(deviceId); + if (device == null) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到设备:" + deviceId); + } + // 获取到所有正在播放的流 + PageHelper.startPage(page, count); + List all = channelMapper.queryChannels(device.getId(), null, query, hasSubChannel, online,null); + return new PageInfo<>(all); + } + + @Override + public List queryDeviceWithAsMessageChannel() { + return deviceMapper.queryDeviceWithAsMessageChannel(); + } } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java index be7ccc7b..dace1da4 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java @@ -7,6 +7,9 @@ import com.genersoft.iot.vmp.conf.DynamicTask; import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.gb28181.bean.*; +import com.genersoft.iot.vmp.gb28181.dao.DeviceChannelMapper; +import com.genersoft.iot.vmp.gb28181.dao.DeviceMapper; +import com.genersoft.iot.vmp.gb28181.dao.PlatformChannelMapper; import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager; import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask; @@ -21,12 +24,11 @@ import com.genersoft.iot.vmp.service.IDeviceChannelService; import com.genersoft.iot.vmp.service.IDeviceService; import com.genersoft.iot.vmp.service.IInviteStreamService; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.gb28181.dao.DeviceChannelMapper; -import com.genersoft.iot.vmp.gb28181.dao.DeviceMapper; -import com.genersoft.iot.vmp.gb28181.dao.PlatformChannelMapper; import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.datasource.DataSourceTransactionManager; @@ -39,7 +41,6 @@ import javax.sip.InvalidArgumentException; import javax.sip.SipException; import java.text.ParseException; import java.time.Instant; -import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; @@ -366,6 +367,11 @@ public class DeviceServiceImpl implements IDeviceService { return deviceMapper.getOnlineDevices(); } + @Override + public List getAllByStatus(boolean status) { + return deviceMapper.getDevices(status); + } + @Override public boolean expire(Device device) { Instant registerTimeDate = Instant.from(DateUtil.formatter.parse(device.getRegisterTime())); @@ -568,5 +574,10 @@ public class DeviceServiceImpl implements IDeviceService { return deviceMapper.getAll(); } - + @Override + public PageInfo getAll(int page, int count, String query, Boolean status) { + PageHelper.startPage(page, count); + List all = deviceMapper.getDeviceList(query, status); + return new PageInfo<>(all); + } } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java index 14af6503..3bd6617d 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java @@ -170,9 +170,9 @@ public class MediaServiceImpl implements IMediaService { String deviceId = ssrcTransactionForAll.get(0).getDeviceId(); String channelId = ssrcTransactionForAll.get(0).getChannelId(); - DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId); + DeviceChannel deviceChannel = deviceChannelService.getOne(deviceId, channelId); if (deviceChannel != null) { - result.setEnable_audio(deviceChannel.getHasAudio()); + result.setEnable_audio(deviceChannel.isHasAudio()); } // 如果是录像下载就设置视频间隔十秒 if (ssrcTransactionForAll.get(0).getType() == InviteSessionType.DOWNLOAD) { diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java index 0a5c72a6..ebe6b17e 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java @@ -124,11 +124,11 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService { private List getDeviceChannelListByChannelReduceList(List channelReduces, String catalogId, ParentPlatform platform) { List deviceChannelList = new ArrayList<>(); - if (channelReduces.size() > 0){ + if (!channelReduces.isEmpty()){ PlatformCatalog catalog = catalogManager.selectByPlatFormAndCatalogId(platform.getServerGBId(),catalogId); if (catalog == null && catalogId.equals(platform.getDeviceGBId())) { for (ChannelReduce channelReduce : channelReduces) { - DeviceChannel deviceChannel = deviceChannelMapper.queryChannel(channelReduce.getDeviceId(), channelReduce.getChannelId()); + DeviceChannel deviceChannel = deviceChannelMapper.getOne(channelReduce.getId()); deviceChannel.setParental(0); deviceChannel.setCivilCode(platform.getServerGBDomain()); deviceChannelList.add(deviceChannel); @@ -139,7 +139,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService { return null; } for (ChannelReduce channelReduce : channelReduces) { - DeviceChannel deviceChannel = deviceChannelMapper.queryChannel(channelReduce.getDeviceId(), channelReduce.getChannelId()); + DeviceChannel deviceChannel = deviceChannelMapper.getOne(channelReduce.getId()); deviceChannel.setParental(0); deviceChannel.setCivilCode(catalog.getCivilCode()); deviceChannel.setParentId(catalog.getParentId()); diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java index 9f018889..c353d0f2 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java @@ -234,7 +234,7 @@ public class PlayServiceImpl implements IPlayService { if (device == null || !device.isOnLine()) { return; } - DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId); + DeviceChannel deviceChannel = channelService.getOne(deviceId, channelId); if (deviceChannel == null) { return; } @@ -258,7 +258,7 @@ public class PlayServiceImpl implements IPlayService { int tcpMode = device.getStreamMode().equals("TCP-ACTIVE")? 2: (device.getStreamMode().equals("TCP-PASSIVE")? 1:0); SSRCInfo ssrcInfo = mediaServerService.openRTPServer(event.getMediaServer(), event.getStream(), null, - device.isSsrcCheck(), true, 0, false, !deviceChannel.getHasAudio(), false, tcpMode); + device.isSsrcCheck(), true, 0, false, !deviceChannel.isHasAudio(), false, tcpMode); playBack(event.getMediaServer(), ssrcInfo, deviceId, channelId, startTime, endTime, null); } } @@ -321,7 +321,7 @@ public class PlayServiceImpl implements IPlayService { } String streamId = String.format("%s_%s", device.getDeviceId(), channelId); int tcpMode = device.getStreamMode().equals("TCP-ACTIVE")? 2: (device.getStreamMode().equals("TCP-PASSIVE")? 1:0); - SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, streamId, ssrc, device.isSsrcCheck(), false, 0, false, !channel.getHasAudio(), false, tcpMode); + SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, streamId, ssrc, device.isSsrcCheck(), false, 0, false, !channel.isHasAudio(), false, tcpMode); if (ssrcInfo == null) { callback.run(InviteErrorCode.ERROR_FOR_RESOURCE_EXHAUSTION.getCode(), InviteErrorCode.ERROR_FOR_RESOURCE_EXHAUSTION.getMsg(), null); inviteStreamService.call(InviteSessionType.PLAY, device.getDeviceId(), channelId, null, @@ -695,7 +695,7 @@ public class PlayServiceImpl implements IPlayService { Device device = redisCatchStorage.getDevice(deviceId); streamInfo = onPublishHandler(mediaServerItem, mediaInfo, deviceId, channelId); if (streamInfo != null) { - DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId); + DeviceChannel deviceChannel = channelService.getOne(deviceId, channelId); if (deviceChannel != null) { deviceChannel.setStreamId(streamInfo.getStream()); channelService.startPlay(deviceId, channelId, streamInfo.getStream()); @@ -716,7 +716,7 @@ public class PlayServiceImpl implements IPlayService { if (streamInfo != null) { streamInfo.setStartTime(startTime); streamInfo.setEndTime(endTime); - DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId); + DeviceChannel deviceChannel = channelService.getOne(deviceId, channelId); if (deviceChannel != null) { deviceChannel.setStreamId(streamInfo.getStream()); channelService.startPlay(deviceId, channelId, streamInfo.getStream()); @@ -753,7 +753,7 @@ public class PlayServiceImpl implements IPlayService { @Override public void playBack(String deviceId, String channelId, String startTime, String endTime, ErrorCallback callback) { - Device device = storager.queryVideoDevice(deviceId); + Device device = deviceService.getDevice(deviceId); if (device == null) { log.warn("[录像回放] 未找到设备 deviceId: {},channelId:{}", deviceId, channelId); throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到设备:" + deviceId); @@ -778,7 +778,7 @@ public class PlayServiceImpl implements IPlayService { .replace(" ", ""); String stream = deviceId + "_" + channelId + "_" + startTimeStr + "_" + endTimeTimeStr; int tcpMode = device.getStreamMode().equals("TCP-ACTIVE")? 2: (device.getStreamMode().equals("TCP-PASSIVE")? 1:0); - SSRCInfo ssrcInfo = mediaServerService.openRTPServer(newMediaServerItem, stream, null, device.isSsrcCheck(), true, 0, false, !channel.getHasAudio(), false, tcpMode); + SSRCInfo ssrcInfo = mediaServerService.openRTPServer(newMediaServerItem, stream, null, device.isSsrcCheck(), true, 0, false, !channel.isHasAudio(), false, tcpMode); playBack(newMediaServerItem, ssrcInfo, deviceId, channelId, startTime, endTime, callback); } @@ -793,7 +793,7 @@ public class PlayServiceImpl implements IPlayService { return; } - Device device = storager.queryVideoDevice(deviceId); + Device device = deviceService.getDevice(deviceId); if (device == null) { throw new ControllerException(ErrorCode.ERROR100.getCode(), "设备: " + deviceId + "不存在"); } @@ -959,7 +959,7 @@ public class PlayServiceImpl implements IPlayService { @Override public void download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, ErrorCallback callback) { - Device device = storager.queryVideoDevice(deviceId); + Device device = deviceService.getDevice(deviceId); if (device == null) { return; } @@ -976,7 +976,7 @@ public class PlayServiceImpl implements IPlayService { } int tcpMode = device.getStreamMode().equals("TCP-ACTIVE")? 2: (device.getStreamMode().equals("TCP-PASSIVE")? 1:0); // 录像下载不使用固定流地址,固定流地址会导致如果开始时间与结束时间一致时文件错误的叠加在一起 - SSRCInfo ssrcInfo = mediaServerService.openRTPServer(newMediaServerItem, null, null, device.isSsrcCheck(), true, 0, false,!channel.getHasAudio(), false, tcpMode); + SSRCInfo ssrcInfo = mediaServerService.openRTPServer(newMediaServerItem, null, null, device.isSsrcCheck(), true, 0, false,!channel.isHasAudio(), false, tcpMode); download(newMediaServerItem, ssrcInfo, deviceId, channelId, startTime, endTime, downloadSpeed, callback); } @@ -989,7 +989,7 @@ public class PlayServiceImpl implements IPlayService { null); return; } - Device device = storager.queryVideoDevice(deviceId); + Device device = deviceService.getDevice(deviceId); if (device == null) { callback.run(InviteErrorCode.ERROR_FOR_PARAMETER_ERROR.getCode(), "设备:" + deviceId + "不存在", @@ -1198,7 +1198,7 @@ public class PlayServiceImpl implements IPlayService { return null; } log.info("[语音喊话] device: {}, channel: {}", device.getDeviceId(), channelId); - DeviceChannel deviceChannel = storager.queryChannel(device.getDeviceId(), channelId); + DeviceChannel deviceChannel = channelService.getOne(device.getDeviceId(), channelId); if (deviceChannel == null) { log.warn("开启语音广播的时候未找到通道: {}", channelId); return null; @@ -1223,7 +1223,7 @@ public class PlayServiceImpl implements IPlayService { return false; } log.info("[语音喊话] device: {}, channel: {}", device.getDeviceId(), channelId); - DeviceChannel deviceChannel = storager.queryChannel(device.getDeviceId(), channelId); + DeviceChannel deviceChannel = channelService.getOne(device.getDeviceId(), channelId); if (deviceChannel == null) { log.warn("开启语音广播的时候未找到通道: {}", channelId); event.call("开启语音广播的时候未找到通道"); @@ -1396,7 +1396,7 @@ public class PlayServiceImpl implements IPlayService { if (!result) { throw new ServiceException("暂停RTP接收失败"); } - Device device = storager.queryVideoDevice(inviteInfo.getDeviceId()); + Device device = deviceService.getDevice(inviteInfo.getDeviceId()); cmder.playPauseCmd(device, inviteInfo.getStreamInfo()); } @@ -1424,7 +1424,7 @@ public class PlayServiceImpl implements IPlayService { if (!result) { throw new ServiceException("继续RTP接收失败"); } - Device device = storager.queryVideoDevice(inviteInfo.getDeviceId()); + Device device = deviceService.getDevice(inviteInfo.getDeviceId()); cmder.playResumeCmd(device, inviteInfo.getStreamInfo()); } @@ -1486,7 +1486,7 @@ public class PlayServiceImpl implements IPlayService { } // TODO 必须多端口模式才支持语音喊话鹤语音对讲 log.info("[语音对讲] device: {}, channel: {}", device.getDeviceId(), channelId); - DeviceChannel deviceChannel = storager.queryChannel(device.getDeviceId(), channelId); + DeviceChannel deviceChannel = channelService.getOne(device.getDeviceId(), channelId); if (deviceChannel == null) { log.warn("开启语音对讲的时候未找到通道: {}", channelId); event.call("开启语音对讲的时候未找到通道"); diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java index e1a67f34..04af9224 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java @@ -8,6 +8,8 @@ import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm; import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; +import com.genersoft.iot.vmp.service.IDeviceChannelService; +import com.genersoft.iot.vmp.service.IDeviceService; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.utils.DateUtil; import lombok.extern.slf4j.Slf4j; @@ -36,6 +38,12 @@ public class RedisAlarmMsgListener implements MessageListener { @Autowired private ISIPCommanderForPlatform commanderForPlatform; + @Autowired + private IDeviceService deviceService; + + @Autowired + private IDeviceChannelService channelService; + @Autowired private IVideoManagerStorage storage; @@ -108,7 +116,7 @@ public class RedisAlarmMsgListener implements MessageListener { } // 获取开启了消息推送的设备和平台 - List devices = storage.queryDeviceWithAsMessageChannel(); + List devices = channelService.queryDeviceWithAsMessageChannel(); if (devices.size() > 0) { for (Device device : devices) { try { @@ -121,7 +129,7 @@ public class RedisAlarmMsgListener implements MessageListener { } }else { - Device device = storage.queryVideoDevice(gbId); + Device device = deviceService.getDevice(gbId); ParentPlatform platform = storage.queryParentPlatByServerGBId(gbId); if (device != null && platform == null) { try { diff --git a/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java b/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java index 274f8371..a5f3e4b7 100755 --- a/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java @@ -4,8 +4,6 @@ import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; import com.genersoft.iot.vmp.storager.dao.dto.ChannelSourceInfo; import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; -import com.genersoft.iot.vmp.web.gb28181.dto.DeviceChannelExtend; -import com.github.pagehelper.PageInfo; import java.util.List; @@ -17,66 +15,6 @@ import java.util.List; @SuppressWarnings("rawtypes") public interface IVideoManagerStorage { - /** - * 根据设备ID判断设备是否存在 - * - * @param deviceId 设备ID - * @return true:存在 false:不存在 - */ - public boolean exists(String deviceId); - - /** - * 获取设备 - * - * @param deviceId 设备ID - * @return DShadow 设备对象 - */ - public Device queryVideoDevice(String deviceId); - - /** - * 获取某个设备的通道列表 - * - * @param deviceId 设备ID - * @param page 分页 当前页 - * @param count 每页数量 - * @return - */ - public PageInfo queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, Boolean catalogUnderDevice, int page, int count); - - /** - * 获取某个设备的通道 - * @param deviceId 设备ID - * @param channelId 通道ID - */ - public DeviceChannel queryChannel(String deviceId, String channelId); - - /** - * 获取多个设备 - * @param page 当前页数 - * @param count 每页数量 - * @return List 设备对象数组 - */ - public PageInfo queryVideoDeviceList(int page, int count,Boolean online); - - /** - * 获取多个设备 - * - * @return List 设备对象数组 - */ - public List queryVideoDeviceList(Boolean online); - - - - /** - * 查询子设备 - * - * @param deviceId - * @param channelId - * @param page - * @param count - * @return - */ - PageInfo querySubChannels(String deviceId, String channelId, String query, Boolean hasSubChannel, Boolean online, int page, int count); /** * 更新上级平台 @@ -103,12 +41,6 @@ public interface IVideoManagerStorage { */ ParentPlatform queryParentPlatByServerGBId(String platformGbId); - /** - * 查询通道信息,不区分设备(已关联平台或全部) - */ - PageInfo queryAllChannelList(int page, int count, String query, Boolean online, Boolean channelType, String platformId, String catalogId); - - /** * 移除上级平台的通道信息 * @param platformId @@ -191,9 +123,6 @@ public interface IVideoManagerStorage { List getChannelSource(String platformId, String gbId); - List queryChannelsByDeviceId(String serial, List channelIds, Boolean online); - List queryEnablePlatformListWithAsMessageChannel(); - List queryDeviceWithAsMessageChannel(); } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java index 52f7ccbf..3ea3c68f 100755 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java @@ -2,7 +2,6 @@ package com.genersoft.iot.vmp.storager.impl; import com.baomidou.dynamic.datasource.annotation.DS; import com.genersoft.iot.vmp.conf.SipConfig; -import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.dao.*; import com.genersoft.iot.vmp.gb28181.event.EventPublisher; @@ -10,15 +9,10 @@ import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import com.genersoft.iot.vmp.storager.dao.*; +import com.genersoft.iot.vmp.storager.dao.GbStreamMapper; import com.genersoft.iot.vmp.storager.dao.dto.ChannelSourceInfo; -import com.genersoft.iot.vmp.streamProxy.dao.StreamProxyMapper; -import com.genersoft.iot.vmp.streamPush.dao.StreamPushMapper; import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; -import com.genersoft.iot.vmp.web.gb28181.dto.DeviceChannelExtend; -import com.github.pagehelper.PageHelper; -import com.github.pagehelper.PageInfo; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.datasource.DataSourceTransactionManager; @@ -74,107 +68,17 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { @Autowired private PlatformCatalogMapper platformCatalogMapper; - @Autowired - private StreamProxyMapper streamProxyMapper; - - @Autowired - private StreamPushMapper streamPushMapper; - @Autowired private GbStreamMapper gbStreamMapper; - @Autowired - private UserSetting userSetting; - @Autowired private PlatformCatalogMapper catalogMapper; @Autowired private PlatformGbStreamMapper platformGbStreamMapper; - /** - * 根据设备ID判断设备是否存在 - * - * @param deviceId 设备ID - * @return true:存在 false:不存在 - */ - @Override - public boolean exists(String deviceId) { - return deviceMapper.getDeviceByDeviceId(deviceId) != null; - } - /** - * 获取设备 - * - * @param deviceId 设备ID - * @return Device 设备对象 - */ - @Override - public Device queryVideoDevice(String deviceId) { - return deviceMapper.getDeviceByDeviceId(deviceId); - } - - @Override - public PageInfo queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, Boolean catalogUnderDevice, int page, int count) { - // 获取到所有正在播放的流 - PageHelper.startPage(page, count); - List all; - if (catalogUnderDevice != null && catalogUnderDevice) { - all = deviceChannelMapper.queryChannels(deviceId, deviceId, query, hasSubChannel, online,null); - // 海康设备的parentId是SIP id - List deviceChannels = deviceChannelMapper.queryChannels(deviceId, sipConfig.getId(), query, hasSubChannel, online,null); - all.addAll(deviceChannels); - }else { - all = deviceChannelMapper.queryChannels(deviceId, null, query, hasSubChannel, online,null); - } - return new PageInfo<>(all); - } - - @Override - public List queryChannelsByDeviceId(String deviceId, List channelIds, Boolean online) { - return deviceChannelMapper.queryChannelsWithDeviceInfo(deviceId, null,null, null, online,channelIds); - } - - @Override - public PageInfo querySubChannels(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, Boolean online, int page, int count) { - PageHelper.startPage(page, count); - List all = deviceChannelMapper.queryChannels(deviceId, parentChannelId, query, hasSubChannel, online,null); - return new PageInfo<>(all); - } - - @Override - public DeviceChannel queryChannel(String deviceId, String channelId) { - return deviceChannelMapper.queryChannel(deviceId, channelId); - } - - - /** - * 获取多个设备 - * - * @param page 当前页数 - * @param count 每页数量 - * @return PageInfo 分页设备对象数组 - */ - @Override - public PageInfo queryVideoDeviceList(int page, int count,Boolean online) { - PageHelper.startPage(page, count); - List all = deviceMapper.getDevices(online); - return new PageInfo<>(all); - } - - /** - * 获取多个设备 - * - * @return List 设备对象数组 - */ - @Override - public List queryVideoDeviceList(Boolean online) { - - List deviceList = deviceMapper.getDevices(online); - return deviceList; - } - /** * 查询移动位置轨迹 @@ -246,19 +150,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { return platformMapper.queryEnablePlatformListWithAsMessageChannel(); } - @Override - public List queryDeviceWithAsMessageChannel() { - return deviceMapper.queryDeviceWithAsMessageChannel(); - } - - - @Override - public PageInfo queryAllChannelList(int page, int count, String query, Boolean online, - Boolean channelType, String platformId, String catalogId) { - PageHelper.startPage(page, count); - List all = deviceChannelMapper.queryChannelListInAll(query, online, channelType, platformId, catalogId); - return new PageInfo<>(all); - } @Override diff --git a/src/main/java/com/genersoft/iot/vmp/streamPush/service/impl/StreamPushServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/streamPush/service/impl/StreamPushServiceImpl.java index 5b60c5ba..4d617865 100755 --- a/src/main/java/com/genersoft/iot/vmp/streamPush/service/impl/StreamPushServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/streamPush/service/impl/StreamPushServiceImpl.java @@ -147,6 +147,9 @@ public class StreamPushServiceImpl implements IStreamPushService { } } StreamPush push = getPush(event.getApp(), event.getStream()); + if (push == null) { + return; + } push.setPushIng(false); if (push.getGbDeviceId() != null) { if (userSetting.isUsePushingAsStatus()) { diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/MobilePosition/MobilePositionController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/MobilePosition/MobilePositionController.java index 9459fb29..f5b0385d 100755 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/MobilePosition/MobilePositionController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/MobilePosition/MobilePositionController.java @@ -99,7 +99,7 @@ public class MobilePositionController { @Parameter(name = "deviceId", description = "设备国标编号", required = true) @GetMapping("/realtime/{deviceId}") public DeferredResult realTimePosition(@PathVariable String deviceId) { - Device device = storager.queryVideoDevice(deviceId); + Device device = deviceService.getDevice(deviceId); String uuid = UUID.randomUUID().toString(); String key = DeferredResultHolder.CALLBACK_CMD_MOBILE_POSITION + deviceId; try { @@ -147,7 +147,7 @@ public class MobilePositionController { if (StringUtil.isEmpty(interval)) { interval = "5"; } - Device device = storager.queryVideoDevice(deviceId); + Device device = deviceService.getDevice(deviceId); device.setSubscribeCycleForMobilePosition(Integer.parseInt(expires)); device.setMobilePositionSubmissionInterval(Integer.parseInt(interval)); deviceService.updateCustomDevice(device); diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/alarm/AlarmController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/alarm/AlarmController.java index 9d4f5321..ff9fd168 100755 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/alarm/AlarmController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/alarm/AlarmController.java @@ -8,6 +8,7 @@ import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; import com.genersoft.iot.vmp.service.IDeviceAlarmService; +import com.genersoft.iot.vmp.service.IDeviceService; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; @@ -45,6 +46,9 @@ public class AlarmController { @Autowired private IVideoManagerStorage storage; + @Autowired + private IDeviceService deviceService; + /** * 删除报警 @@ -95,7 +99,7 @@ public class AlarmController { @Operation(summary = "测试向上级/设备发送模拟报警通知", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Parameter(name = "deviceId", description = "设备国标编号") public void delete(@RequestParam String deviceId) { - Device device = storage.queryVideoDevice(deviceId); + Device device = deviceService.getDevice(deviceId); ParentPlatform platform = storage.queryParentPlatByServerGBId(deviceId); DeviceAlarm deviceAlarm = new DeviceAlarm(); deviceAlarm.setChannelId(deviceId); diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceConfig.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceConfig.java index bd56552a..5dc0031b 100755 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceConfig.java @@ -14,6 +14,7 @@ import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; +import com.genersoft.iot.vmp.service.IDeviceService; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import io.swagger.v3.oas.annotations.Operation; @@ -40,6 +41,9 @@ public class DeviceConfig { @Autowired private IVideoManagerStorage storager; + @Autowired + private IDeviceService deviceService; + @Autowired private SIPCommander cmder; @@ -73,7 +77,7 @@ public class DeviceConfig { if (log.isDebugEnabled()) { log.debug("报警复位API调用"); } - Device device = storager.queryVideoDevice(deviceId); + Device device = deviceService.getDevice(deviceId); String uuid = UUID.randomUUID().toString(); String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONFIG + deviceId + channelId; try { @@ -126,7 +130,7 @@ public class DeviceConfig { } String key = DeferredResultHolder.CALLBACK_CMD_CONFIGDOWNLOAD + (ObjectUtils.isEmpty(channelId) ? deviceId : channelId); String uuid = UUID.randomUUID().toString(); - Device device = storager.queryVideoDevice(deviceId); + Device device = deviceService.getDevice(deviceId); try { cmder.deviceConfigQuery(device, channelId, configType, event -> { RequestMessage msg = new RequestMessage(); diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceControl.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceControl.java index e267fee0..8dedd57c 100755 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceControl.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceControl.java @@ -14,7 +14,7 @@ import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; +import com.genersoft.iot.vmp.service.IDeviceService; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -39,7 +39,7 @@ import java.util.UUID; public class DeviceControl { @Autowired - private IVideoManagerStorage storager; + private IDeviceService deviceService; @Autowired private ISIPCommander cmder; @@ -59,7 +59,7 @@ public class DeviceControl { if (log.isDebugEnabled()) { log.debug("设备远程启动API调用"); } - Device device = storager.queryVideoDevice(deviceId); + Device device = deviceService.getDevice(deviceId); try { cmder.teleBootCmd(device); } catch (InvalidArgumentException | SipException | ParseException e) { @@ -85,7 +85,7 @@ public class DeviceControl { if (log.isDebugEnabled()) { log.debug("开始/停止录像API调用"); } - Device device = storager.queryVideoDevice(deviceId); + Device device = deviceService.getDevice(deviceId); String uuid = UUID.randomUUID().toString(); String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + deviceId + channelId; DeferredResult> result = new DeferredResult>(3 * 1000L); @@ -132,7 +132,7 @@ public class DeviceControl { if (log.isDebugEnabled()) { log.debug("布防/撤防API调用"); } - Device device = storager.queryVideoDevice(deviceId); + Device device = deviceService.getDevice(deviceId); String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + deviceId + deviceId; String uuid =UUID.randomUUID().toString(); try { @@ -181,7 +181,7 @@ public class DeviceControl { if (log.isDebugEnabled()) { log.debug("报警复位API调用"); } - Device device = storager.queryVideoDevice(deviceId); + Device device = deviceService.getDevice(deviceId); String uuid = UUID.randomUUID().toString(); String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + deviceId + channelId; try { @@ -225,7 +225,7 @@ public class DeviceControl { if (log.isDebugEnabled()) { log.debug("强制关键帧API调用"); } - Device device = storager.queryVideoDevice(deviceId); + Device device = deviceService.getDevice(deviceId); try { cmder.iFrameCmd(device, channelId); } catch (InvalidArgumentException | SipException | ParseException e) { @@ -263,7 +263,7 @@ public class DeviceControl { } String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + (ObjectUtils.isEmpty(channelId) ? deviceId : channelId); String uuid = UUID.randomUUID().toString(); - Device device = storager.queryVideoDevice(deviceId); + Device device = deviceService.getDevice(deviceId); try { cmder.homePositionCmd(device, channelId, enabled, resetTime, presetIndex, event -> { RequestMessage msg = new RequestMessage(); @@ -326,7 +326,7 @@ public class DeviceControl { if (log.isDebugEnabled()) { log.debug(String.format("设备拉框放大 API调用,deviceId:%s ,channelId:%s ,length:%d ,width:%d ,midpointx:%d ,midpointy:%d ,lengthx:%d ,lengthy:%d",deviceId, channelId, length, width, midpointx, midpointy,lengthx, lengthy)); } - Device device = storager.queryVideoDevice(deviceId); + Device device = deviceService.getDevice(deviceId); StringBuffer cmdXml = new StringBuffer(200); cmdXml.append("\r\n"); cmdXml.append("" + length+ "\r\n"); @@ -378,7 +378,7 @@ public class DeviceControl { if (log.isDebugEnabled()) { log.debug(String.format("设备拉框缩小 API调用,deviceId:%s ,channelId:%s ,length:%d ,width:%d ,midpointx:%d ,midpointy:%d ,lengthx:%d ,lengthy:%d",deviceId, channelId, length, width, midpointx, midpointy,lengthx, lengthy)); } - Device device = storager.queryVideoDevice(deviceId); + Device device = deviceService.getDevice(deviceId); StringBuffer cmdXml = new StringBuffer(200); cmdXml.append("\r\n"); cmdXml.append("" + length+ "\r\n"); diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java index c265cb7c..1b36cdc6 100755 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java @@ -91,7 +91,7 @@ public class DeviceQuery { @GetMapping("/devices/{deviceId}") public Device devices(@PathVariable String deviceId){ - return storager.queryVideoDevice(deviceId); + return deviceService.getDevice(deviceId); } /** @@ -103,12 +103,14 @@ public class DeviceQuery { @Operation(summary = "分页查询国标设备", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Parameter(name = "page", description = "当前页", required = true) @Parameter(name = "count", description = "每页查询数量", required = true) + @Parameter(name = "query", description = "搜索", required = false) + @Parameter(name = "status", description = "状态", required = false) @GetMapping("/devices") @Options() - public PageInfo devices(int page, int count){ + public PageInfo devices(int page, int count, String query, Boolean status){ // if (page == null) page = 0; // if (count == null) count = 20; - return storager.queryVideoDeviceList(page, count,null); + return deviceService.getAll(page, count,query, status); } /** @@ -131,18 +133,16 @@ public class DeviceQuery { @Parameter(name = "query", description = "查询内容") @Parameter(name = "online", description = "是否在线") @Parameter(name = "channelType", description = "设备/子目录-> false/true") - @Parameter(name = "catalogUnderDevice", description = "是否直属与设备的目录") public PageInfo channels(@PathVariable String deviceId, int page, int count, @RequestParam(required = false) String query, @RequestParam(required = false) Boolean online, - @RequestParam(required = false) Boolean channelType, - @RequestParam(required = false) Boolean catalogUnderDevice) { + @RequestParam(required = false) Boolean channelType) { if (ObjectUtils.isEmpty(query)) { query = null; } - return storager.queryChannelsByDeviceId(deviceId, query, channelType, online, catalogUnderDevice, page, count); + return deviceChannelService.queryChannelsByDeviceId(deviceId, query, channelType, online, page, count); } /** @@ -154,11 +154,11 @@ public class DeviceQuery { @Parameter(name = "deviceId", description = "设备国标编号", required = true) @GetMapping("/devices/{deviceId}/sync") public WVPResult devicesSync(@PathVariable String deviceId){ - + if (log.isDebugEnabled()) { log.debug("设备通道信息同步API调用,deviceId:" + deviceId); } - Device device = storager.queryVideoDevice(deviceId); + Device device = deviceService.getDevice(deviceId); boolean status = deviceService.isSyncRunning(deviceId); // 已存在则返回进度 if (status) { @@ -182,7 +182,7 @@ public class DeviceQuery { @Parameter(name = "deviceId", description = "设备国标编号", required = true) @DeleteMapping("/devices/{deviceId}/delete") public String delete(@PathVariable String deviceId){ - + if (log.isDebugEnabled()) { log.debug("设备信息删除API调用,deviceId:" + deviceId); } @@ -240,13 +240,13 @@ public class DeviceQuery { @RequestParam(required = false) Boolean online, @RequestParam(required = false) Boolean channelType){ - DeviceChannel deviceChannel = storager.queryChannel(deviceId,channelId); + DeviceChannel deviceChannel = deviceChannelService.getOne(deviceId,channelId); if (deviceChannel == null) { PageInfo deviceChannelPageResult = new PageInfo<>(); return deviceChannelPageResult; } - return storager.querySubChannels(deviceId, channelId, query, channelType, online, page, count); + return deviceChannelService.getSubChannels(deviceChannel.getDeviceDbId(), channelId, query, channelType, online, page, count); } /** @@ -330,7 +330,7 @@ public class DeviceQuery { /** * 设备状态查询请求API接口 - * + * * @param deviceId 设备id */ @Operation(summary = "设备状态查询", security = @SecurityRequirement(name = JwtUtils.HEADER)) @@ -340,7 +340,7 @@ public class DeviceQuery { if (log.isDebugEnabled()) { log.debug("设备状态查询API调用"); } - Device device = storager.queryVideoDevice(deviceId); + Device device = deviceService.getDevice(deviceId); String uuid = UUID.randomUUID().toString(); String key = DeferredResultHolder.CALLBACK_CMD_DEVICESTATUS + deviceId; DeferredResult> result = new DeferredResult>(2*1000L); @@ -394,8 +394,8 @@ public class DeviceQuery { @Parameter(name = "endTime", description = "报警发生终止时间") @GetMapping("/alarm/{deviceId}") public DeferredResult> alarmApi(@PathVariable String deviceId, - @RequestParam(required = false) String startPriority, - @RequestParam(required = false) String endPriority, + @RequestParam(required = false) String startPriority, + @RequestParam(required = false) String endPriority, @RequestParam(required = false) String alarmMethod, @RequestParam(required = false) String alarmType, @RequestParam(required = false) String startTime, @@ -403,7 +403,7 @@ public class DeviceQuery { if (log.isDebugEnabled()) { log.debug("设备报警查询API调用"); } - Device device = storager.queryVideoDevice(deviceId); + Device device = deviceService.getDevice(deviceId); String key = DeferredResultHolder.CALLBACK_CMD_ALARM + deviceId; String uuid = UUID.randomUUID().toString(); try { diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java index 1360a3c1..3d2c0580 100755 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java @@ -320,7 +320,7 @@ public class PlatformController { if (ObjectUtils.isEmpty(platformId) || ObjectUtils.isEmpty(catalogId)) { catalogId = null; } - PageInfo channelReduces = storager.queryAllChannelList(page, count, query, online, channelType, platformId, catalogId); + PageInfo channelReduces = deviceChannelService.queryAllChannelList(page, count, query, online, channelType, platformId, catalogId); return channelReduces; } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java index bca40927..b6c32225 100755 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java @@ -16,6 +16,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; import com.genersoft.iot.vmp.media.bean.MediaServer; import com.genersoft.iot.vmp.media.service.IMediaServerService; import com.genersoft.iot.vmp.service.IDeviceChannelService; +import com.genersoft.iot.vmp.service.IDeviceService; import com.genersoft.iot.vmp.service.IInviteStreamService; import com.genersoft.iot.vmp.service.IPlayService; import com.genersoft.iot.vmp.service.bean.InviteErrorCode; @@ -75,6 +76,8 @@ public class PlayController { @Autowired private UserSetting userSetting; + @Autowired + private IDeviceService deviceService; @Autowired private IDeviceChannelService deviceChannelService; @@ -87,8 +90,11 @@ public class PlayController { @PathVariable String channelId) { log.info("[开始点播] deviceId:{}, channelId:{}, ", deviceId, channelId); + if (ObjectUtils.isEmpty(deviceId) || ObjectUtils.isEmpty(channelId)) { + throw new ControllerException(ErrorCode.ERROR400); + } // 获取可用的zlm - Device device = storager.queryVideoDevice(deviceId); + Device device = deviceService.getDevice(deviceId); MediaServer newMediaServerItem = playService.getNewMediaServerItem(device); RequestMessage requestMessage = new RequestMessage(); @@ -163,7 +169,7 @@ public class PlayController { throw new ControllerException(ErrorCode.ERROR400); } - Device device = storager.queryVideoDevice(deviceId); + Device device = deviceService.getDevice(deviceId); if (device == null) { throw new ControllerException(ErrorCode.ERROR100.getCode(), "设备[" + deviceId + "]不存在"); } @@ -206,7 +212,7 @@ public class PlayController { if (log.isDebugEnabled()) { log.debug("语音广播API调用"); } - Device device = storager.queryVideoDevice(deviceId); + Device device = deviceService.getDevice(deviceId); if (device == null) { throw new ControllerException(ErrorCode.ERROR400.getCode(), "未找到设备: " + deviceId); } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java index f533c949..e65cf5bb 100755 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java @@ -12,6 +12,7 @@ import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; +import com.genersoft.iot.vmp.service.IDeviceService; import com.genersoft.iot.vmp.service.IInviteStreamService; import com.genersoft.iot.vmp.service.IPlayService; import com.genersoft.iot.vmp.service.bean.InviteErrorCode; @@ -67,6 +68,9 @@ public class PlaybackController { @Autowired private UserSetting userSetting; + @Autowired + private IDeviceService deviceService; + @Operation(summary = "开始视频回放", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Parameter(name = "deviceId", description = "设备国标编号", required = true) @Parameter(name = "channelId", description = "通道国标编号", required = true) @@ -136,7 +140,7 @@ public class PlaybackController { if (ObjectUtils.isEmpty(deviceId) || ObjectUtils.isEmpty(channelId) || ObjectUtils.isEmpty(stream)) { throw new ControllerException(ErrorCode.ERROR400); } - Device device = storager.queryVideoDevice(deviceId); + Device device = deviceService.getDevice(deviceId); if (device == null) { throw new ControllerException(ErrorCode.ERROR400.getCode(), "设备:" + deviceId + " 未找到"); } @@ -191,7 +195,7 @@ public class PlaybackController { log.warn("streamId不存在!"); throw new ControllerException(ErrorCode.ERROR400.getCode(), "streamId不存在"); } - Device device = storager.queryVideoDevice(inviteInfo.getDeviceId()); + Device device = deviceService.getDevice(inviteInfo.getDeviceId()); try { cmder.playSeekCmd(device, inviteInfo.getStreamInfo(), seekTime); } catch (InvalidArgumentException | ParseException | SipException e) { @@ -215,7 +219,7 @@ public class PlaybackController { log.warn("不支持的speed: " + speed); throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持的speed(0.25 0.5 1、2、4)"); } - Device device = storager.queryVideoDevice(inviteInfo.getDeviceId()); + Device device = deviceService.getDevice(inviteInfo.getDeviceId()); try { cmder.playSpeedCmd(device, inviteInfo.getStreamInfo(), speed); } catch (InvalidArgumentException | ParseException | SipException e) { diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/ptz/PtzController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/ptz/PtzController.java index 8e9818ff..b5851005 100755 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/ptz/PtzController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/ptz/PtzController.java @@ -7,6 +7,7 @@ import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; +import com.genersoft.iot.vmp.service.IDeviceService; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import io.swagger.v3.oas.annotations.Operation; @@ -36,6 +37,9 @@ public class PtzController { @Autowired private IVideoManagerStorage storager; + @Autowired + private IDeviceService deviceService; + @Autowired private DeferredResultHolder resultHolder; @@ -62,7 +66,7 @@ public class PtzController { if (log.isDebugEnabled()) { log.debug(String.format("设备云台控制 API调用,deviceId:%s ,channelId:%s ,command:%s ,horizonSpeed:%d ,verticalSpeed:%d ,zoomSpeed:%d",deviceId, channelId, command, horizonSpeed, verticalSpeed, zoomSpeed)); } - Device device = storager.queryVideoDevice(deviceId); + Device device = deviceService.getDevice(deviceId); int cmdCode = 0; switch (command){ case "left": @@ -125,7 +129,7 @@ public class PtzController { if (log.isDebugEnabled()) { log.debug(String.format("设备云台控制 API调用,deviceId:%s ,channelId:%s ,cmdCode:%d parameter1:%d parameter2:%d",deviceId, channelId, cmdCode, parameter1, parameter2)); } - Device device = storager.queryVideoDevice(deviceId); + Device device = deviceService.getDevice(deviceId); try { cmder.frontEndCmd(device, channelId, cmdCode, parameter1, parameter2, combindCode2); @@ -144,7 +148,7 @@ public class PtzController { if (log.isDebugEnabled()) { log.debug("设备预置位查询API调用"); } - Device device = storager.queryVideoDevice(deviceId); + Device device = deviceService.getDevice(deviceId); String uuid = UUID.randomUUID().toString(); String key = DeferredResultHolder.CALLBACK_CMD_PRESETQUERY + (ObjectUtils.isEmpty(channelId) ? deviceId : channelId); DeferredResult result = new DeferredResult (3 * 1000L); diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/record/GBRecordController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/record/GBRecordController.java index 5869ab99..ab8381a8 100755 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/record/GBRecordController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/record/GBRecordController.java @@ -83,7 +83,7 @@ public class GBRecordController { throw new ControllerException(ErrorCode.ERROR100.getCode(), "endTime格式为" + DateUtil.PATTERN); } - Device device = storager.queryVideoDevice(deviceId); + Device device = deviceService.getDevice(deviceId); // 指定超时时间 1分钟30秒 String uuid = UUID.randomUUID().toString(); int sn = (int)((Math.random()*9+1)*100000); diff --git a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java index ead47513..b378e01c 100644 --- a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java +++ b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java @@ -3,7 +3,7 @@ package com.genersoft.iot.vmp.web.gb28181; import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; +import com.genersoft.iot.vmp.service.IDeviceService; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -28,7 +28,7 @@ public class ApiControlController { private SIPCommander cmder; @Autowired - private IVideoManagerStorage storager; + private IDeviceService deviceService; /** * 设备控制 - 云台控制 @@ -51,7 +51,7 @@ public class ApiControlController { } if (channel == null) {channel = 0;} if (speed == null) {speed = 0;} - Device device = storager.queryVideoDevice(serial); + Device device = deviceService.getDevice(serial); if (device == null) { throw new ControllerException(ErrorCode.ERROR100.getCode(), "device[ " + serial + " ]未找到"); } @@ -125,7 +125,7 @@ public class ApiControlController { } if (channel == null) {channel = 0;} - Device device = storager.queryVideoDevice(serial); + Device device = deviceService.getDevice(serial); if (device == null) { throw new ControllerException(ErrorCode.ERROR100.getCode(), "device[ " + serial + " ]未找到"); } diff --git a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java index c329eca0..5b16dff6 100644 --- a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java +++ b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java @@ -8,6 +8,7 @@ import com.genersoft.iot.vmp.gb28181.bean.PresetQuerySipReq; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; +import com.genersoft.iot.vmp.service.IDeviceChannelService; import com.genersoft.iot.vmp.service.IDeviceService; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.vmanager.bean.DeferredResultEx; @@ -43,11 +44,14 @@ public class ApiDeviceController { @Autowired private SIPCommander cmder; @Autowired - private IDeviceService deviceService; + private IDeviceChannelService channelService; @Autowired private DeferredResultHolder resultHolder; + @Autowired + private IDeviceService deviceService; + /** * 分页获取设备列表 现在直接返回,尚未实现分页 @@ -70,10 +74,10 @@ public class ApiDeviceController { JSONObject result = new JSONObject(); List devices; if (start == null || limit ==null) { - devices = storager.queryVideoDeviceList(online); + devices = deviceService.getAllByStatus(online); result.put("DeviceCount", devices.size()); }else { - PageInfo deviceList = storager.queryVideoDeviceList(start/limit, limit,online); + PageInfo deviceList = deviceService.getAll(start/limit, limit,null, online); result.put("DeviceCount", deviceList.getTotal()); devices = deviceList.getList(); } @@ -120,7 +124,7 @@ public class ApiDeviceController { String[] split = code.trim().split(","); channelIds = Arrays.asList(split); } - List allDeviceChannelList = storager.queryChannelsByDeviceId(serial,channelIds,online); + List allDeviceChannelList = channelService.queryChannelExtendsByDeviceId(serial,channelIds,online); if (start == null || limit ==null) { deviceChannels = allDeviceChannelList; result.put("ChannelCount", deviceChannels.size()); @@ -196,7 +200,7 @@ public class ApiDeviceController { serial, channel, code, fill, timeout); } - Device device = storager.queryVideoDevice(serial); + Device device = deviceService.getDevice(serial); String uuid = UUID.randomUUID().toString(); String key = DeferredResultHolder.CALLBACK_CMD_PRESETQUERY + (ObjectUtils.isEmpty(code) ? serial : code); DeferredResult result = new DeferredResult<> (timeout * 1000L); diff --git a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java index bc497db2..2ae12b8f 100644 --- a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java +++ b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java @@ -82,7 +82,7 @@ public class ApiStreamController { ){ DeferredResult result = new DeferredResult<>(userSetting.getPlayTimeout().longValue() + 10); - Device device = storager.queryVideoDevice(serial); + Device device = deviceService.getDevice(serial); if (device == null ) { JSONObject resultJSON = new JSONObject(); resultJSON.put("error","device[ " + serial + " ]未找到"); @@ -104,7 +104,7 @@ public class ApiStreamController { // 清理RTP server }); - DeviceChannel deviceChannel = storager.queryChannel(serial, code); + DeviceChannel deviceChannel = deviceChannelService.getOne(serial, code); if (deviceChannel == null) { JSONObject resultJSON = new JSONObject(); resultJSON.put("error","channel[ " + code + " ]未找到"); diff --git a/web_src/src/components/channelList.vue b/web_src/src/components/channelList.vue index ff1d7842..b1f8469d 100755 --- a/web_src/src/components/channelList.vue +++ b/web_src/src/components/channelList.vue @@ -52,11 +52,9 @@ - + - - - +