From 0517ab3be9ef119196f0c38ff31ecb3d00f6c394 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Fri, 13 Dec 2024 14:35:44 +0800 Subject: [PATCH 01/38] =?UTF-8?q?=E5=A2=9E=E5=8A=A0RPC=E5=BD=95=E5=83=8F?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../genersoft/iot/vmp/conf/UserSetting.java | 5 + .../iot/vmp/conf/redis/RedisRpcConfig.java | 5 +- .../controller/GBRecordController.java | 40 ++-- .../iot/vmp/gb28181/event/EventPublisher.java | 8 +- ...dEndEvent.java => RecordInfoEndEvent.java} | 17 +- .../gb28181/event/record/RecordInfoEvent.java | 27 +++ ...ener.java => RecordInfoEventListener.java} | 11 +- .../service/IDeviceChannelService.java | 9 +- .../vmp/gb28181/service/IDeviceService.java | 5 +- .../service/IGbChannelPlayService.java | 2 +- .../gb28181/service/IGbChannelService.java | 2 + .../impl/DeviceChannelServiceImpl.java | 86 +++++++- .../service/impl/DeviceServiceImpl.java | 11 +- .../impl/GbChannelPlayServiceImpl.java | 7 +- .../service/impl/GbChannelServiceImpl.java | 28 +++ .../vmp/gb28181/session/RecordDataCatch.java | 6 +- .../cmd/RecordInfoQueryMessageHandler.java | 6 +- .../cmd/RecordInfoResponseMessageHandler.java | 204 +++++++++--------- .../redisMsg/IRedisRpcPlayService.java | 6 +- .../RedisRpcChannelPlayController.java | 70 ++++-- .../control/RedisRpcSendRtpController.java | 12 +- .../control/RedisRpcStreamPushController.java | 13 +- .../service/RedisRpcPlayServiceImpl.java | 30 ++- .../iot/vmp/vmanager/bean/ErrorCode.java | 1 + src/main/resources/配置详情.yml | 2 + 25 files changed, 409 insertions(+), 204 deletions(-) rename src/main/java/com/genersoft/iot/vmp/gb28181/event/record/{RecordEndEvent.java => RecordInfoEndEvent.java} (54%) create mode 100755 src/main/java/com/genersoft/iot/vmp/gb28181/event/record/RecordInfoEvent.java rename src/main/java/com/genersoft/iot/vmp/gb28181/event/record/{RecordEndEventListener.java => RecordInfoEventListener.java} (85%) diff --git a/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java b/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java index 604c8c56..b9356592 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java @@ -37,6 +37,11 @@ public class UserSetting { */ private Integer playTimeout = 10000; + /** + * 获取设备录像数据超时时间,单位:毫秒 + */ + private Integer recordInfoTimeout = 15000; + /** * 上级点播等待超时时间,单位:毫秒 */ diff --git a/src/main/java/com/genersoft/iot/vmp/conf/redis/RedisRpcConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/redis/RedisRpcConfig.java index 02293685..29e090ad 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/redis/RedisRpcConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/redis/RedisRpcConfig.java @@ -8,6 +8,7 @@ import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcMessage; import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcRequest; import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcResponse; import com.genersoft.iot.vmp.service.redisMsg.dto.RpcController; +import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; @@ -129,7 +130,7 @@ public class RedisRpcConfig implements MessageListener { if (method == null) { // 回复404结果 RedisRpcResponse response = request.getResponse(); - response.setStatusCode(Response.NOT_FOUND); + response.setStatusCode(ErrorCode.ERROR404.getCode()); sendResponse(response); return; } @@ -185,7 +186,7 @@ public class RedisRpcConfig implements MessageListener { } catch (InterruptedException e) { log.warn("[redis rpc timeout] uri: {}, sn: {}", request.getUri(), request.getSn(), e); RedisRpcResponse redisRpcResponse = new RedisRpcResponse(); - redisRpcResponse.setStatusCode(Response.BUSY_HERE); + redisRpcResponse.setStatusCode(ErrorCode.ERROR486.getCode()); return redisRpcResponse; } finally { this.unsubscribe(request.getSn()); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/GBRecordController.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/GBRecordController.java index e48ae616..87357d27 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/GBRecordController.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/GBRecordController.java @@ -36,6 +36,7 @@ import javax.sip.InvalidArgumentException; import javax.sip.SipException; import java.text.ParseException; import java.util.UUID; +import java.util.concurrent.TimeUnit; @Tag(name = "国标录像") @Slf4j @@ -72,7 +73,7 @@ public class GBRecordController { if (log.isDebugEnabled()) { log.debug(String.format("录像信息查询 API调用,deviceId:%s ,startTime:%s, endTime:%s",deviceId, startTime, endTime)); } - DeferredResult> result = new DeferredResult<>(); + DeferredResult> result = new DeferredResult<>(Long.valueOf(userSetting.getRecordInfoTimeout()), TimeUnit.MILLISECONDS); if (!DateUtil.verification(startTime, DateUtil.formatter)){ throw new ControllerException(ErrorCode.ERROR100.getCode(), "startTime格式为" + DateUtil.PATTERN); } @@ -81,35 +82,24 @@ public class GBRecordController { } Device device = deviceService.getDeviceByDeviceId(deviceId); - // 指定超时时间 1分钟30秒 - String uuid = UUID.randomUUID().toString(); - int sn = (int)((Math.random()*9+1)*100000); - String key = DeferredResultHolder.CALLBACK_CMD_RECORDINFO + deviceId + sn; - RequestMessage msg = new RequestMessage(); - msg.setId(uuid); - msg.setKey(key); - try { - cmder.recordInfoQuery(device, channelId, startTime, endTime, sn, null, null, null, (eventResult -> { - WVPResult wvpResult = new WVPResult<>(); - wvpResult.setCode(ErrorCode.ERROR100.getCode()); - wvpResult.setMsg("查询录像失败, status: " + eventResult.statusCode + ", message: " + eventResult.msg); - msg.setData(wvpResult); - resultHolder.invokeResult(msg); - })); - } catch (InvalidArgumentException | SipException | ParseException e) { - log.error("[命令发送失败] 查询录像: {}", e.getMessage()); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage()); + if (device == null) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), deviceId + " 不存在"); } - - // 录像查询以channelId作为deviceId查询 - resultHolder.put(key, uuid, result); + DeviceChannel channel = channelService.getOneForSource(device.getId(), channelId); + if (channel == null) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), channelId + " 不存在"); + } + channelService.queryRecordInfo(device, channel, startTime, endTime, (code, msg, data)->{ + WVPResult wvpResult = new WVPResult<>(); + wvpResult.setCode(code); + wvpResult.setMsg(msg); + result.setResult(wvpResult); + }); result.onTimeout(()->{ - msg.setData("timeout"); WVPResult wvpResult = new WVPResult<>(); wvpResult.setCode(ErrorCode.ERROR100.getCode()); wvpResult.setMsg("timeout"); - msg.setData(wvpResult); - resultHolder.invokeResult(msg); + result.setResult(wvpResult); }); return result; } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/EventPublisher.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/EventPublisher.java index 7d4c876a..a19a1009 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/EventPublisher.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/EventPublisher.java @@ -3,7 +3,7 @@ package com.genersoft.iot.vmp.gb28181.event; import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.event.alarm.AlarmEvent; import com.genersoft.iot.vmp.gb28181.event.device.RequestTimeoutEvent; -import com.genersoft.iot.vmp.gb28181.event.record.RecordEndEvent; +import com.genersoft.iot.vmp.gb28181.event.record.RecordInfoEvent; import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; import com.genersoft.iot.vmp.gb28181.event.subscribe.mobilePosition.MobilePositionEvent; import com.genersoft.iot.vmp.media.bean.MediaServer; @@ -101,9 +101,5 @@ public class EventPublisher { applicationEventPublisher.publishEvent(event); } - public void recordEndEventPush(RecordInfo recordInfo) { - RecordEndEvent outEvent = new RecordEndEvent(this); - outEvent.setRecordInfo(recordInfo); - applicationEventPublisher.publishEvent(outEvent); - } + } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/record/RecordEndEvent.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/record/RecordInfoEndEvent.java similarity index 54% rename from src/main/java/com/genersoft/iot/vmp/gb28181/event/record/RecordEndEvent.java rename to src/main/java/com/genersoft/iot/vmp/gb28181/event/record/RecordInfoEndEvent.java index cfd2985c..4788eb62 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/record/RecordEndEvent.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/record/RecordInfoEndEvent.java @@ -1,7 +1,8 @@ package com.genersoft.iot.vmp.gb28181.event.record; -import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm; import com.genersoft.iot.vmp.gb28181.bean.RecordInfo; +import lombok.Getter; +import lombok.Setter; import org.springframework.context.ApplicationEvent; /** @@ -9,24 +10,18 @@ import org.springframework.context.ApplicationEvent; * @author: pan * @data: 2022-02-23 */ - -public class RecordEndEvent extends ApplicationEvent { +@Setter +@Getter +public class RecordInfoEndEvent extends ApplicationEvent { /** * */ private static final long serialVersionUID = 1L; - public RecordEndEvent(Object source) { + public RecordInfoEndEvent(Object source) { super(source); } private RecordInfo recordInfo; - public RecordInfo getRecordInfo() { - return recordInfo; - } - - public void setRecordInfo(RecordInfo recordInfo) { - this.recordInfo = recordInfo; - } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/record/RecordInfoEvent.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/record/RecordInfoEvent.java new file mode 100755 index 00000000..d78a22b2 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/record/RecordInfoEvent.java @@ -0,0 +1,27 @@ +package com.genersoft.iot.vmp.gb28181.event.record; + +import com.genersoft.iot.vmp.gb28181.bean.RecordInfo; +import lombok.Getter; +import lombok.Setter; +import org.springframework.context.ApplicationEvent; + +/** + * @description: 录像查询结束时间 + * @author: pan + * @data: 2022-02-23 + */ + +@Setter +@Getter +public class RecordInfoEvent extends ApplicationEvent { + /** + * + */ + private static final long serialVersionUID = 1L; + + public RecordInfoEvent(Object source) { + super(source); + } + + private RecordInfo recordInfo; +} diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/record/RecordEndEventListener.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/record/RecordInfoEventListener.java similarity index 85% rename from src/main/java/com/genersoft/iot/vmp/gb28181/event/record/RecordEndEventListener.java rename to src/main/java/com/genersoft/iot/vmp/gb28181/event/record/RecordInfoEventListener.java index 411b54d5..f2a0986d 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/record/RecordEndEventListener.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/record/RecordInfoEventListener.java @@ -15,15 +15,15 @@ import java.util.concurrent.ConcurrentHashMap; */ @Slf4j @Component -public class RecordEndEventListener implements ApplicationListener { +public class RecordInfoEventListener implements ApplicationListener { - private Map handlerMap = new ConcurrentHashMap<>(); + private final Map handlerMap = new ConcurrentHashMap<>(); public interface RecordEndEventHandler{ void handler(RecordInfo recordInfo); } @Override - public void onApplicationEvent(RecordEndEvent event) { + public void onApplicationEvent(RecordInfoEvent event) { String deviceId = event.getRecordInfo().getDeviceId(); String channelId = event.getRecordInfo().getChannelId(); int count = event.getRecordInfo().getCount(); @@ -45,9 +45,6 @@ public class RecordEndEventListener implements ApplicationListener queryChaneListByDeviceDbId(Integer deviceDbId); List queryChaneIdListByDeviceDbIds(List deviceDbId); + + void queryRecordInfo(Device device, DeviceChannel channel, String startTime, String endTime, ErrorCallback object); + + void queryRecordInfo(CommonGBChannel channel, String startTime, String endTime, ErrorCallback object); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceService.java index a8f48a47..43a965f4 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceService.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceService.java @@ -1,9 +1,8 @@ package com.genersoft.iot.vmp.gb28181.service; import com.genersoft.iot.vmp.common.CommonCallback; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo; -import com.genersoft.iot.vmp.gb28181.bean.SyncStatus; +import com.genersoft.iot.vmp.gb28181.bean.*; +import com.genersoft.iot.vmp.service.bean.ErrorCallback; import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo; import com.github.pagehelper.PageInfo; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelPlayService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelPlayService.java index 967661a8..61c0b8cb 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelPlayService.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelPlayService.java @@ -5,6 +5,7 @@ import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; import com.genersoft.iot.vmp.gb28181.bean.InviteMessageInfo; import com.genersoft.iot.vmp.gb28181.bean.Platform; +import com.genersoft.iot.vmp.gb28181.bean.RecordInfo; import com.genersoft.iot.vmp.service.bean.ErrorCallback; public interface IGbChannelPlayService { @@ -25,6 +26,5 @@ public interface IGbChannelPlayService { void playPush(CommonGBChannel channel, String platformDeviceId, String platformName, ErrorCallback callback); - void stopPlayPush(CommonGBChannel channel); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelService.java index 8dc67df2..441b524f 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelService.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelService.java @@ -1,6 +1,7 @@ package com.genersoft.iot.vmp.gb28181.service; import com.genersoft.iot.vmp.gb28181.bean.*; +import com.genersoft.iot.vmp.service.bean.ErrorCallback; import com.genersoft.iot.vmp.streamPush.bean.StreamPush; import com.github.pagehelper.PageInfo; @@ -87,4 +88,5 @@ public interface IGbChannelService { PageInfo queryList(int page, int count, String query, Boolean online, Boolean hasRecordPlan, Integer channelType); + void queryRecordInfo(CommonGBChannel channel, String startTime, String endTime, ErrorCallback callback); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java index b397f4d4..062fd1d5 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java @@ -5,37 +5,48 @@ import com.genersoft.iot.vmp.common.InviteInfo; import com.genersoft.iot.vmp.common.InviteSessionType; import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.conf.exception.ControllerException; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; -import com.genersoft.iot.vmp.gb28181.bean.GbCode; -import com.genersoft.iot.vmp.gb28181.bean.MobilePosition; +import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.controller.bean.ChannelReduce; import com.genersoft.iot.vmp.gb28181.dao.DeviceChannelMapper; import com.genersoft.iot.vmp.gb28181.dao.DeviceMapper; import com.genersoft.iot.vmp.gb28181.dao.DeviceMobilePositionMapper; import com.genersoft.iot.vmp.gb28181.dao.PlatformChannelMapper; import com.genersoft.iot.vmp.gb28181.event.EventPublisher; +import com.genersoft.iot.vmp.gb28181.event.record.RecordInfoEndEvent; import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService; import com.genersoft.iot.vmp.gb28181.service.IInviteStreamService; import com.genersoft.iot.vmp.gb28181.service.IPlatformChannelService; +import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; import com.genersoft.iot.vmp.gb28181.utils.SipUtils; +import com.genersoft.iot.vmp.media.event.media.MediaArrivalEvent; +import com.genersoft.iot.vmp.service.bean.ErrorCallback; +import com.genersoft.iot.vmp.service.redisMsg.IRedisRpcPlayService; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; 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.bean.WVPResult; 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.scheduling.annotation.Async; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.Assert; import org.springframework.util.CollectionUtils; import org.springframework.util.ObjectUtils; +import javax.sip.InvalidArgumentException; +import javax.sip.SipException; +import javax.sip.message.Response; +import java.text.ParseException; import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.SynchronousQueue; +import java.util.concurrent.TimeUnit; /** * @author lin @@ -71,6 +82,26 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { @Autowired private IPlatformChannelService platformChannelService; + @Autowired + private IRedisRpcPlayService redisRpcPlayService; + + @Autowired + private ISIPCommander commander; + + // 记录录像查询的结果等待 + private final Map> topicSubscribers = new ConcurrentHashMap<>(); + + /** + * 监听录像查询结束事件 + */ + @Async("taskExecutor") + @org.springframework.context.event.EventListener + public void onApplicationEvent(RecordInfoEndEvent event) { + SynchronousQueue queue = topicSubscribers.get("record" + event.getRecordInfo().getSn()); + if (queue != null) { + queue.offer(event.getRecordInfo()); + } + } @Override public int updateChannels(Device device, List channels) { @@ -164,10 +195,8 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { @Override public ResourceBaseInfo getOverview() { - int online = channelMapper.getOnlineCount(); int total = channelMapper.getAllChannelCount(); - return new ResourceBaseInfo(total, online); } @@ -705,4 +734,49 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { public void updateChannelForNotify(DeviceChannel channel) { channelMapper.updateChannelForNotify(channel); } + + @Override + public void queryRecordInfo(Device device, DeviceChannel channel, String startTime, String endTime, ErrorCallback callback) { + if (!userSetting.getServerId().equals(device.getServerId())){ + redisRpcPlayService.queryRecordInfo(device.getServerId(), channel.getId(), startTime, endTime, callback); + return; + } + try { + int sn = (int)((Math.random()*9+1)*100000); + commander.recordInfoQuery(device, channel.getDeviceId(), startTime, endTime, sn, null, null, eventResult -> { + try { + // 消息发送成功, 监听等待数据到来 + SynchronousQueue queue = new SynchronousQueue<>(); + topicSubscribers.put("record" + sn, queue); + RecordInfo recordInfo = queue.poll(userSetting.getRecordInfoTimeout(), TimeUnit.MILLISECONDS); + if (recordInfo == null) { + callback.run(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), recordInfo); + } + } catch (InterruptedException e) { + callback.run(ErrorCode.ERROR100.getCode(), e.getMessage(), null); + } finally { + this.topicSubscribers.remove("record" + sn); + } + + }, (eventResult -> { + callback.run(ErrorCode.ERROR100.getCode(), "查询录像失败, status: " + eventResult.statusCode + ", message: " + eventResult.msg, null); + })); + } catch (InvalidArgumentException | SipException | ParseException e) { + log.error("[命令发送失败] 查询录像: {}", e.getMessage()); + throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage()); + } + } + + @Override + public void queryRecordInfo(CommonGBChannel channel, String startTime, String endTime, ErrorCallback callback) { + Device device = deviceMapper.query(channel.getGbDeviceDbId()); + if (device == null) { + log.warn("[点播] 未找到通道{}的设备信息", channel); + callback.run(ErrorCode.ERROR100.getCode(), "设备不存在", null); + return; + } + DeviceChannel deviceChannel = getOneForSourceById(channel.getGbId()); + queryRecordInfo(device, deviceChannel, startTime, endTime, callback); + + } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceServiceImpl.java index 4773b9fd..3c69da75 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceServiceImpl.java @@ -6,6 +6,7 @@ import com.genersoft.iot.vmp.common.VideoManagerConstants; 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.conf.redis.bean.RedisRpcResponse; import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.dao.DeviceChannelMapper; import com.genersoft.iot.vmp.gb28181.dao.DeviceMapper; @@ -23,10 +24,13 @@ import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.respons import com.genersoft.iot.vmp.media.bean.MediaServer; import com.genersoft.iot.vmp.media.service.IMediaServerService; import com.genersoft.iot.vmp.service.ISendRtpServerService; +import com.genersoft.iot.vmp.service.bean.ErrorCallback; +import com.genersoft.iot.vmp.service.redisMsg.IRedisRpcPlayService; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; 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.bean.WVPResult; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import lombok.extern.slf4j.Slf4j; @@ -36,9 +40,13 @@ import org.springframework.transaction.annotation.Transactional; import javax.sip.InvalidArgumentException; import javax.sip.SipException; +import javax.sip.message.Response; import java.text.ParseException; import java.time.Instant; import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.SynchronousQueue; import java.util.concurrent.TimeUnit; /** @@ -69,9 +77,6 @@ public class DeviceServiceImpl implements IDeviceService { @Autowired private PlatformChannelMapper platformChannelMapper; - @Autowired - private IDeviceChannelService deviceChannelService; - @Autowired private DeviceChannelMapper deviceChannelMapper; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelPlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelPlayServiceImpl.java index c1c009d3..cd3bf212 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelPlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelPlayServiceImpl.java @@ -2,10 +2,7 @@ package com.genersoft.iot.vmp.gb28181.service.impl; import com.genersoft.iot.vmp.common.InviteSessionType; import com.genersoft.iot.vmp.common.StreamInfo; -import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; -import com.genersoft.iot.vmp.gb28181.bean.InviteMessageInfo; -import com.genersoft.iot.vmp.gb28181.bean.Platform; -import com.genersoft.iot.vmp.gb28181.bean.PlayException; +import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.service.IGbChannelPlayService; import com.genersoft.iot.vmp.gb28181.service.IPlayService; import com.genersoft.iot.vmp.service.bean.ErrorCallback; @@ -223,4 +220,6 @@ public class GbChannelPlayServiceImpl implements IGbChannelPlayService { callback.run(Response.BUSY_HERE, "busy here", null); } } + + } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java index 792fd88b..5fb01d4b 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java @@ -8,11 +8,15 @@ import com.genersoft.iot.vmp.gb28181.dao.PlatformChannelMapper; import com.genersoft.iot.vmp.gb28181.dao.RegionMapper; 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.IDeviceChannelService; +import com.genersoft.iot.vmp.gb28181.service.IDeviceService; import com.genersoft.iot.vmp.gb28181.service.IGbChannelService; import com.genersoft.iot.vmp.gb28181.service.IPlatformChannelService; +import com.genersoft.iot.vmp.service.bean.ErrorCallback; import com.genersoft.iot.vmp.streamPush.bean.StreamPush; import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; +import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import lombok.extern.slf4j.Slf4j; @@ -22,6 +26,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.Assert; import org.springframework.util.ObjectUtils; +import javax.sip.message.Response; import java.util.*; @Slf4j @@ -46,6 +51,9 @@ public class GbChannelServiceImpl implements IGbChannelService { @Autowired private GroupMapper groupMapper; + @Autowired + private IDeviceChannelService deviceChannelService; + @Override public CommonGBChannel queryByDeviceId(String gbDeviceId) { return commonGBChannelMapper.queryByDeviceId(gbDeviceId); @@ -726,4 +734,24 @@ public class GbChannelServiceImpl implements IGbChannelService { List all = commonGBChannelMapper.queryList(query, online, hasRecordPlan, channelType); return new PageInfo<>(all); } + + @Override + public void queryRecordInfo(CommonGBChannel channel, String startTime, String endTime, ErrorCallback callback) { + if (channel.getGbDeviceDbId() != null) { + + deviceChannelService.queryRecordInfo(channel, startTime, endTime, callback); + } else if (channel.getStreamProxyId() != null) { + // 拉流代理 + log.warn("[下载通用通道录像] 不支持下载拉流代理的录像: {}({})", channel.getGbName(), channel.getGbDeviceId()); + throw new PlayException(Response.FORBIDDEN, "forbidden"); + } else if (channel.getStreamPushId() != null) { + // 推流 + log.warn("[下载通用通道录像] 不支持下载推流的录像: {}({})", channel.getGbName(), channel.getGbDeviceId()); + throw new PlayException(Response.FORBIDDEN, "forbidden"); + } else { + // 通道数据异常 + log.error("[回放通用通道] 通道数据异常,无法识别通道来源: {}({})", channel.getGbName(), channel.getGbDeviceId()); + throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error"); + } + } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/session/RecordDataCatch.java b/src/main/java/com/genersoft/iot/vmp/gb28181/session/RecordDataCatch.java index 3f24dbee..e89cedf2 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/session/RecordDataCatch.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/session/RecordDataCatch.java @@ -1,10 +1,9 @@ package com.genersoft.iot.vmp.gb28181.session; import com.genersoft.iot.vmp.gb28181.bean.*; -import com.genersoft.iot.vmp.gb28181.event.record.RecordEndEventListener; +import com.genersoft.iot.vmp.gb28181.event.record.RecordInfoEventListener; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; -import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @@ -24,8 +23,9 @@ public class RecordDataCatch { @Autowired private DeferredResultHolder deferredResultHolder; + @Autowired - private RecordEndEventListener recordEndEventListener; + private RecordInfoEventListener recordEndEventListener; public int put(String deviceId,String channelId, String sn, int sumNum, List recordItems) { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/RecordInfoQueryMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/RecordInfoQueryMessageHandler.java index 79deb042..ccb1b2c9 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/RecordInfoQueryMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/RecordInfoQueryMessageHandler.java @@ -4,7 +4,7 @@ import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.Platform; -import com.genersoft.iot.vmp.gb28181.event.record.RecordEndEventListener; +import com.genersoft.iot.vmp.gb28181.event.record.RecordInfoEventListener; import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService; import com.genersoft.iot.vmp.gb28181.service.IDeviceService; import com.genersoft.iot.vmp.gb28181.service.IGbChannelService; @@ -52,7 +52,7 @@ public class RecordInfoQueryMessageHandler extends SIPRequestProcessorParent imp private SIPCommander commander; @Autowired - private RecordEndEventListener recordEndEventListener; + private RecordInfoEventListener recordInfoEventListener; @Override public void afterPropertiesSet() throws Exception { @@ -126,7 +126,7 @@ public class RecordInfoQueryMessageHandler extends SIPRequestProcessorParent imp // 获取通道的原始信息 DeviceChannel deviceChannel = deviceChannelService.getOneForSourceById(channel.getGbId()); // 接收录像数据 - recordEndEventListener.addEndEventHandler(device.getDeviceId(), deviceChannel.getDeviceId(), (recordInfo)->{ + recordInfoEventListener.addEndEventHandler(device.getDeviceId(), deviceChannel.getDeviceId(), (recordInfo)->{ try { log.info("[国标级联] 录像查询收到数据, 通道: {},准备转发===", channelId); cmderFroPlatform.recordInfo(channel, platform, request.getFromTag(), recordInfo); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/RecordInfoResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/RecordInfoResponseMessageHandler.java index 655c0551..0ab97e87 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/RecordInfoResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/RecordInfoResponseMessageHandler.java @@ -6,6 +6,8 @@ import com.genersoft.iot.vmp.gb28181.bean.Platform; import com.genersoft.iot.vmp.gb28181.bean.RecordInfo; import com.genersoft.iot.vmp.gb28181.bean.RecordItem; import com.genersoft.iot.vmp.gb28181.event.EventPublisher; +import com.genersoft.iot.vmp.gb28181.event.record.RecordInfoEndEvent; +import com.genersoft.iot.vmp.gb28181.event.record.RecordInfoEvent; 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.event.request.SIPRequestProcessorParent; @@ -19,6 +21,7 @@ import org.dom4j.Element; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.context.ApplicationEventPublisher; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.stereotype.Component; @@ -48,14 +51,7 @@ public class RecordInfoResponseMessageHandler extends SIPRequestProcessorParent private ResponseMessageHandler responseMessageHandler; @Autowired - private DeferredResultHolder deferredResultHolder; - - @Autowired - private EventPublisher eventPublisher; - - @Qualifier("taskExecutor") - @Autowired - private ThreadPoolTaskExecutor taskExecutor; + private ApplicationEventPublisher applicationEventPublisher; @Autowired private RedisTemplate redisTemplate; @@ -75,88 +71,89 @@ public class RecordInfoResponseMessageHandler extends SIPRequestProcessorParent }catch (SipException | InvalidArgumentException | ParseException e) { log.error("[命令发送失败] 国标级联 国标录像: {}", e.getMessage()); } - taskExecutor.execute(()->{ - try { - String sn = getText(rootElement, "SN"); - String channelId = getText(rootElement, "DeviceID"); - RecordInfo recordInfo = new RecordInfo(); - recordInfo.setChannelId(channelId); - recordInfo.setDeviceId(device.getDeviceId()); - recordInfo.setSn(sn); - recordInfo.setName(getText(rootElement, "Name")); - String sumNumStr = getText(rootElement, "SumNum"); - int sumNum = 0; - if (!ObjectUtils.isEmpty(sumNumStr)) { - sumNum = Integer.parseInt(sumNumStr); - } - recordInfo.setSumNum(sumNum); - Element recordListElement = rootElement.element("RecordList"); - if (recordListElement == null || sumNum == 0) { - log.info("无录像数据"); - recordInfo.setCount(sumNum); - eventPublisher.recordEndEventPush(recordInfo); - releaseRequest(device.getDeviceId(), sn,recordInfo); - } else { - Iterator recordListIterator = recordListElement.elementIterator(); - if (recordListIterator != null) { - List recordList = new ArrayList<>(); - // 遍历DeviceList - while (recordListIterator.hasNext()) { - Element itemRecord = recordListIterator.next(); - Element recordElement = itemRecord.element("DeviceID"); - if (recordElement == null) { - log.info("记录为空,下一个..."); - continue; - } - RecordItem record = new RecordItem(); - record.setDeviceId(getText(itemRecord, "DeviceID")); - record.setName(getText(itemRecord, "Name")); - record.setFilePath(getText(itemRecord, "FilePath")); - record.setFileSize(getText(itemRecord, "FileSize")); - record.setAddress(getText(itemRecord, "Address")); - - String startTimeStr = getText(itemRecord, "StartTime"); - record.setStartTime(DateUtil.ISO8601Toyyyy_MM_dd_HH_mm_ss(startTimeStr)); - - String endTimeStr = getText(itemRecord, "EndTime"); - record.setEndTime(DateUtil.ISO8601Toyyyy_MM_dd_HH_mm_ss(endTimeStr)); - - record.setSecrecy(itemRecord.element("Secrecy") == null ? 0 - : Integer.parseInt(getText(itemRecord, "Secrecy"))); - record.setType(getText(itemRecord, "Type")); - record.setRecorderId(getText(itemRecord, "RecorderID")); - recordList.add(record); - } - Map map = recordList.stream() - .filter(record -> record.getDeviceId() != null) - .collect(Collectors.toMap(record -> record.getStartTime()+ record.getEndTime(), UJson::writeJson)); - // 获取任务结果数据 - String resKey = VideoManagerConstants.REDIS_RECORD_INFO_RES_PRE + channelId + sn; - redisTemplate.opsForHash().putAll(resKey, map); - redisTemplate.expire(resKey, recordInfoTtl, TimeUnit.SECONDS); - String resCountKey = VideoManagerConstants.REDIS_RECORD_INFO_RES_COUNT_PRE + channelId + sn; - long incr = redisTemplate.opsForValue().increment(resCountKey, map.size()); - redisTemplate.expire(resCountKey, recordInfoTtl, TimeUnit.SECONDS); - recordInfo.setRecordList(recordList); - recordInfo.setCount(Math.toIntExact(incr)); - eventPublisher.recordEndEventPush(recordInfo); - if (incr < sumNum) { - return; - } - // 已接收完成 - List resList = redisTemplate.opsForHash().entries(resKey).values().stream().map(e -> UJson.readJson(e.toString(), RecordItem.class)).collect(Collectors.toList()); - if (resList.size() < sumNum) { - return; - } - recordInfo.setRecordList(resList); - releaseRequest(device.getDeviceId(), sn,recordInfo); - } - } - } catch (Exception e) { - log.error("[国标录像] 发现未处理的异常, \r\n{}", evt.getRequest()); - log.error("[国标录像] 异常内容: ", e); + try { + String sn = getText(rootElement, "SN"); + String channelId = getText(rootElement, "DeviceID"); + RecordInfo recordInfo = new RecordInfo(); + recordInfo.setChannelId(channelId); + recordInfo.setDeviceId(device.getDeviceId()); + recordInfo.setSn(sn); + recordInfo.setName(getText(rootElement, "Name")); + String sumNumStr = getText(rootElement, "SumNum"); + int sumNum = 0; + if (!ObjectUtils.isEmpty(sumNumStr)) { + sumNum = Integer.parseInt(sumNumStr); } - }); + recordInfo.setSumNum(sumNum); + Element recordListElement = rootElement.element("RecordList"); + if (recordListElement == null || sumNum == 0) { + log.info("无录像数据"); + recordInfo.setCount(sumNum); + recordInfoEventPush(recordInfo); + recordInfoEndEventPush(recordInfo); + } else { + Iterator recordListIterator = recordListElement.elementIterator(); + if (recordListIterator != null) { + List recordList = new ArrayList<>(); + // 遍历DeviceList + while (recordListIterator.hasNext()) { + Element itemRecord = recordListIterator.next(); + Element recordElement = itemRecord.element("DeviceID"); + if (recordElement == null) { + log.info("记录为空,下一个..."); + continue; + } + RecordItem record = new RecordItem(); + record.setDeviceId(getText(itemRecord, "DeviceID")); + record.setName(getText(itemRecord, "Name")); + record.setFilePath(getText(itemRecord, "FilePath")); + record.setFileSize(getText(itemRecord, "FileSize")); + record.setAddress(getText(itemRecord, "Address")); + + String startTimeStr = getText(itemRecord, "StartTime"); + record.setStartTime(DateUtil.ISO8601Toyyyy_MM_dd_HH_mm_ss(startTimeStr)); + + String endTimeStr = getText(itemRecord, "EndTime"); + record.setEndTime(DateUtil.ISO8601Toyyyy_MM_dd_HH_mm_ss(endTimeStr)); + + record.setSecrecy(itemRecord.element("Secrecy") == null ? 0 + : Integer.parseInt(getText(itemRecord, "Secrecy"))); + record.setType(getText(itemRecord, "Type")); + record.setRecorderId(getText(itemRecord, "RecorderID")); + recordList.add(record); + } + Map map = recordList.stream() + .filter(record -> record.getDeviceId() != null) + .collect(Collectors.toMap(record -> record.getStartTime()+ record.getEndTime(), UJson::writeJson)); + // 获取任务结果数据 + String resKey = VideoManagerConstants.REDIS_RECORD_INFO_RES_PRE + channelId + sn; + redisTemplate.opsForHash().putAll(resKey, map); + redisTemplate.expire(resKey, recordInfoTtl, TimeUnit.SECONDS); + String resCountKey = VideoManagerConstants.REDIS_RECORD_INFO_RES_COUNT_PRE + channelId + sn; + Long incr = redisTemplate.opsForValue().increment(resCountKey, map.size()); + if (incr == null) { + incr = 0L; + } + redisTemplate.expire(resCountKey, recordInfoTtl, TimeUnit.SECONDS); + recordInfo.setRecordList(recordList); + recordInfo.setCount(Math.toIntExact(incr)); + recordInfoEventPush(recordInfo); + if (incr < sumNum) { + return; + } + // 已接收完成 + List resList = redisTemplate.opsForHash().entries(resKey).values().stream().map(e -> UJson.readJson(e.toString(), RecordItem.class)).collect(Collectors.toList()); + if (resList.size() < sumNum) { + return; + } + recordInfo.setRecordList(resList); + recordInfoEndEventPush(recordInfo); + } + } + } catch (Exception e) { + log.error("[国标录像] 发现未处理的异常, \r\n{}", evt.getRequest()); + log.error("[国标录像] 异常内容: ", e); + } } @Override @@ -164,18 +161,31 @@ public class RecordInfoResponseMessageHandler extends SIPRequestProcessorParent } - public void releaseRequest(String deviceId, String sn,RecordInfo recordInfo){ - String key = DeferredResultHolder.CALLBACK_CMD_RECORDINFO + deviceId + sn; - // 对数据进行排序 - if(recordInfo!=null && recordInfo.getRecordList()!=null) { + private void recordInfoEventPush(RecordInfo recordInfo) { + if (recordInfo == null) { + return; + } + if(recordInfo.getRecordList() != null) { Collections.sort(recordInfo.getRecordList()); }else{ recordInfo.setRecordList(new ArrayList<>()); } + RecordInfoEvent outEvent = new RecordInfoEvent(this); + outEvent.setRecordInfo(recordInfo); + applicationEventPublisher.publishEvent(outEvent); + } - RequestMessage msg = new RequestMessage(); - msg.setKey(key); - msg.setData(recordInfo); - deferredResultHolder.invokeAllResult(msg); + private void recordInfoEndEventPush(RecordInfo recordInfo) { + if (recordInfo == null) { + return; + } + if(recordInfo.getRecordList() != null) { + Collections.sort(recordInfo.getRecordList()); + }else{ + recordInfo.setRecordList(new ArrayList<>()); + } + RecordInfoEndEvent outEvent = new RecordInfoEndEvent(this); + outEvent.setRecordInfo(recordInfo); + applicationEventPublisher.publishEvent(outEvent); } } diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/IRedisRpcPlayService.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/IRedisRpcPlayService.java index 4c1bc066..11f80ee8 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/IRedisRpcPlayService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/IRedisRpcPlayService.java @@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.service.redisMsg; import com.genersoft.iot.vmp.common.InviteSessionType; import com.genersoft.iot.vmp.common.StreamInfo; +import com.genersoft.iot.vmp.gb28181.bean.RecordInfo; import com.genersoft.iot.vmp.service.bean.ErrorCallback; public interface IRedisRpcPlayService { @@ -13,5 +14,8 @@ public interface IRedisRpcPlayService { void playback(String serverId, Integer channelId, String startTime, String endTime, ErrorCallback callback); - void download(String serverId, Integer id, String startTime, String endTime, int downloadSpeed, ErrorCallback callback); + void download(String serverId, Integer channelId, String startTime, String endTime, int downloadSpeed, ErrorCallback callback); + + void queryRecordInfo(String serverId, Integer channelId, String startTime, String endTime, ErrorCallback callback); + } diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcChannelPlayController.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcChannelPlayController.java index f28aa6f1..3eb9c1e3 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcChannelPlayController.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcChannelPlayController.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSONObject; import com.genersoft.iot.vmp.common.InviteInfo; import com.genersoft.iot.vmp.common.InviteSessionType; import com.genersoft.iot.vmp.conf.UserSetting; +import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.conf.redis.RedisRpcConfig; import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcMessage; import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcRequest; @@ -17,6 +18,7 @@ import com.genersoft.iot.vmp.service.redisMsg.dto.RedisRpcController; import com.genersoft.iot.vmp.service.redisMsg.dto.RedisRpcMapping; import com.genersoft.iot.vmp.service.redisMsg.dto.RpcController; import com.genersoft.iot.vmp.utils.DateUtil; +import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import lombok.Data; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -60,14 +62,14 @@ public class RedisRpcChannelPlayController extends RpcController { RedisRpcResponse response = request.getResponse(); if (channelId <= 0) { - response.setStatusCode(Response.BAD_REQUEST); + response.setStatusCode(ErrorCode.ERROR400.getCode()); response.setBody("param error"); return response; } // 获取对应的设备和通道信息 CommonGBChannel channel = channelService.getOne(channelId); if (channel == null) { - response.setStatusCode(Response.BAD_REQUEST); + response.setStatusCode(ErrorCode.ERROR400.getCode()); response.setBody("param error"); return response; } @@ -76,7 +78,7 @@ public class RedisRpcChannelPlayController extends RpcController { inviteInfo.setSessionName("Play"); channelPlayService.start(channel, inviteInfo, null, (code, msg, data) ->{ if (code == InviteErrorCode.SUCCESS.getCode()) { - response.setStatusCode(Response.OK); + response.setStatusCode(ErrorCode.SUCCESS.getCode()); response.setBody(data); }else { response.setStatusCode(code); @@ -88,6 +90,50 @@ public class RedisRpcChannelPlayController extends RpcController { } + /** + * 点播国标设备 + */ + @RedisRpcMapping("queryRecordInfo") + public RedisRpcResponse queryRecordInfo(RedisRpcRequest request) { + JSONObject paramJson = JSONObject.parseObject(request.getParam().toString()); + int channelId = paramJson.getIntValue("channelId"); + String startTime = paramJson.getString("startTime"); + String endTime = paramJson.getString("endTime"); + RedisRpcResponse response = request.getResponse(); + + if (channelId <= 0) { + response.setStatusCode(ErrorCode.ERROR400.getCode()); + response.setBody("param error"); + return response; + } + // 获取对应的设备和通道信息 + CommonGBChannel channel = channelService.getOne(channelId); + if (channel == null) { + response.setStatusCode(ErrorCode.ERROR400.getCode()); + response.setBody("param error"); + return response; + } + + try { + channelService.queryRecordInfo(channel, startTime, endTime, (code, msg, data) ->{ + if (code == InviteErrorCode.SUCCESS.getCode()) { + response.setStatusCode(ErrorCode.SUCCESS.getCode()); + response.setBody(data); + }else { + response.setStatusCode(code); + } + // 手动发送结果 + sendResponse(response); + }); + }catch (ControllerException e) { + response.setStatusCode(ErrorCode.ERROR100.getCode()); + response.setBody(e.getMessage()); + } + + return null; + } + + /** * 停止点播国标设备 */ @@ -99,7 +145,7 @@ public class RedisRpcChannelPlayController extends RpcController { Integer channelId = jsonObject.getIntValue("channelId"); if (channelId == null || channelId <= 0) { - response.setStatusCode(Response.BAD_REQUEST); + response.setStatusCode(ErrorCode.ERROR400.getCode()); response.setBody("param error"); return response; } @@ -110,13 +156,13 @@ public class RedisRpcChannelPlayController extends RpcController { // 获取对应的设备和通道信息 CommonGBChannel channel = channelService.getOne(channelId); if (channel == null) { - response.setStatusCode(Response.BAD_REQUEST); + response.setStatusCode(ErrorCode.ERROR400.getCode()); response.setBody("param error"); return response; } try { channelPlayService.stopPlay(type, channel, stream); - response.setStatusCode(Response.OK); + response.setStatusCode(ErrorCode.SUCCESS.getCode()); }catch (Exception e){ response.setStatusCode(Response.SERVER_INTERNAL_ERROR); response.setBody(e.getMessage()); @@ -136,14 +182,14 @@ public class RedisRpcChannelPlayController extends RpcController { RedisRpcResponse response = request.getResponse(); if (channelId <= 0) { - response.setStatusCode(Response.BAD_REQUEST); + response.setStatusCode(ErrorCode.ERROR400.getCode()); response.setBody("param error"); return response; } // 获取对应的设备和通道信息 CommonGBChannel channel = channelService.getOne(channelId); if (channel == null) { - response.setStatusCode(Response.BAD_REQUEST); + response.setStatusCode(ErrorCode.ERROR400.getCode()); response.setBody("param error"); return response; } @@ -154,7 +200,7 @@ public class RedisRpcChannelPlayController extends RpcController { inviteInfo.setStopTime(DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(endTime)); channelPlayService.start(channel, inviteInfo, null, (code, msg, data) ->{ if (code == InviteErrorCode.SUCCESS.getCode()) { - response.setStatusCode(Response.OK); + response.setStatusCode(ErrorCode.SUCCESS.getCode()); response.setBody(data); }else { response.setStatusCode(code); @@ -178,14 +224,14 @@ public class RedisRpcChannelPlayController extends RpcController { RedisRpcResponse response = request.getResponse(); if (channelId <= 0) { - response.setStatusCode(Response.BAD_REQUEST); + response.setStatusCode(ErrorCode.ERROR400.getCode()); response.setBody("param error"); return response; } // 获取对应的设备和通道信息 CommonGBChannel channel = channelService.getOne(channelId); if (channel == null) { - response.setStatusCode(Response.BAD_REQUEST); + response.setStatusCode(ErrorCode.ERROR400.getCode()); response.setBody("param error"); return response; } @@ -197,7 +243,7 @@ public class RedisRpcChannelPlayController extends RpcController { inviteInfo.setDownloadSpeed(downloadSpeed + ""); channelPlayService.start(channel, inviteInfo, null, (code, msg, data) ->{ if (code == InviteErrorCode.SUCCESS.getCode()) { - response.setStatusCode(Response.OK); + response.setStatusCode(ErrorCode.SUCCESS.getCode()); response.setBody(data); }else { response.setStatusCode(code); diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcSendRtpController.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcSendRtpController.java index ee5d1e18..fa818025 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcSendRtpController.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcSendRtpController.java @@ -49,7 +49,7 @@ public class RedisRpcSendRtpController extends RpcController { if (sendRtpItem == null) { log.info("[redis-rpc] 获取发流的信息, 未找到redis中的发流信息, callId:{}", callId); RedisRpcResponse response = request.getResponse(); - response.setStatusCode(200); + response.setStatusCode(ErrorCode.SUCCESS.getCode()); return response; } log.info("[redis-rpc] 获取发流的信息: {}/{}, 目标地址: {}:{}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort()); @@ -57,14 +57,14 @@ public class RedisRpcSendRtpController extends RpcController { MediaServer mediaServerItem = mediaServerService.getMediaServerByAppAndStream(sendRtpItem.getApp(), sendRtpItem.getStream()); if (mediaServerItem == null) { RedisRpcResponse response = request.getResponse(); - response.setStatusCode(200); + response.setStatusCode(ErrorCode.SUCCESS.getCode()); } // 自平台内容 int localPort = sendRtpServerService.getNextPort(mediaServerItem); if (localPort == 0) { log.info("[redis-rpc] getSendRtpItem->服务器端口资源不足" ); RedisRpcResponse response = request.getResponse(); - response.setStatusCode(200); + response.setStatusCode(ErrorCode.SUCCESS.getCode()); } // 写入redis, 超时时回复 sendRtpItem.setStatus(1); @@ -77,7 +77,7 @@ public class RedisRpcSendRtpController extends RpcController { } sendRtpServerService.update(sendRtpItem); RedisRpcResponse response = request.getResponse(); - response.setStatusCode(200); + response.setStatusCode(ErrorCode.SUCCESS.getCode()); response.setBody(callId); return response; } @@ -90,7 +90,7 @@ public class RedisRpcSendRtpController extends RpcController { String callId = request.getParam().toString(); SendRtpInfo sendRtpItem = sendRtpServerService.queryByCallId(callId); RedisRpcResponse response = request.getResponse(); - response.setStatusCode(200); + response.setStatusCode(ErrorCode.SUCCESS.getCode()); if (sendRtpItem == null) { log.info("[redis-rpc] 开始发流, 未找到redis中的发流信息, callId:{}", callId); WVPResult wvpResult = WVPResult.fail(ErrorCode.ERROR100.getCode(), "未找到redis中的发流信息"); @@ -134,7 +134,7 @@ public class RedisRpcSendRtpController extends RpcController { String callId = request.getParam().toString(); SendRtpInfo sendRtpItem = sendRtpServerService.queryByCallId(callId); RedisRpcResponse response = request.getResponse(); - response.setStatusCode(Response.OK); + response.setStatusCode(ErrorCode.SUCCESS.getCode()); if (sendRtpItem == null) { log.info("[redis-rpc] 停止推流, 未找到redis中的发流信息, key:{}", callId); WVPResult wvpResult = WVPResult.fail(ErrorCode.ERROR100.getCode(), "未找到redis中的发流信息"); diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcStreamPushController.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcStreamPushController.java index e1ef57b5..1cf46890 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcStreamPushController.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcStreamPushController.java @@ -18,6 +18,7 @@ import com.genersoft.iot.vmp.service.ISendRtpServerService; import com.genersoft.iot.vmp.service.redisMsg.dto.RedisRpcController; import com.genersoft.iot.vmp.service.redisMsg.dto.RedisRpcMapping; import com.genersoft.iot.vmp.service.redisMsg.dto.RpcController; +import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; @@ -79,7 +80,7 @@ public class RedisRpcStreamPushController extends RpcController { sendRtpServerService.update(sendRtpItem); RedisRpcResponse response = request.getResponse(); response.setBody(sendRtpItem.getChannelId()); - response.setStatusCode(200); + response.setStatusCode(ErrorCode.SUCCESS.getCode()); } // 监听流上线。 流上线直接发送sendRtpItem消息给实际的信令处理者 Hook hook = Hook.getInstance(HookType.on_media_arrival, sendRtpItem.getApp(), sendRtpItem.getStream(), null); @@ -98,7 +99,7 @@ public class RedisRpcStreamPushController extends RpcController { redisTemplate.opsForValue().set(sendRtpItem.getChannelId(), sendRtpItem); RedisRpcResponse response = request.getResponse(); response.setBody(sendRtpItem.getChannelId()); - response.setStatusCode(200); + response.setStatusCode(ErrorCode.SUCCESS.getCode()); // 手动发送结果 sendResponse(response); hookSubscribe.removeSubscribe(hook); @@ -120,7 +121,7 @@ public class RedisRpcStreamPushController extends RpcController { log.info("[redis-rpc] 监听流上线时发现流已存在直接返回: {}/{}", streamInfo.getApp(), streamInfo.getStream()); RedisRpcResponse response = request.getResponse(); response.setBody(JSONObject.toJSONString(streamInfoInServer)); - response.setStatusCode(200); + response.setStatusCode(ErrorCode.SUCCESS.getCode()); return response; } // 监听流上线。 流上线直接发送sendRtpItem消息给实际的信令处理者 @@ -133,7 +134,7 @@ public class RedisRpcStreamPushController extends RpcController { streamInfo.getApp(), streamInfo.getStream(), hookData.getMediaInfo(), hookData.getMediaInfo() != null ? hookData.getMediaInfo().getCallId() : null); response.setBody(JSONObject.toJSONString(streamInfoByAppAndStream)); - response.setStatusCode(200); + response.setStatusCode(ErrorCode.SUCCESS.getCode()); // 手动发送结果 sendResponse(response); hookSubscribe.removeSubscribe(hook); @@ -152,7 +153,7 @@ public class RedisRpcStreamPushController extends RpcController { Hook hook = Hook.getInstance(HookType.on_media_arrival, sendRtpItem.getApp(), sendRtpItem.getStream(), null); hookSubscribe.removeSubscribe(hook); RedisRpcResponse response = request.getResponse(); - response.setStatusCode(200); + response.setStatusCode(ErrorCode.SUCCESS.getCode()); return response; } @@ -167,7 +168,7 @@ public class RedisRpcStreamPushController extends RpcController { Hook hook = Hook.getInstance(HookType.on_media_arrival, streamInfo.getApp(), streamInfo.getStream(), null); hookSubscribe.removeSubscribe(hook); RedisRpcResponse response = request.getResponse(); - response.setStatusCode(200); + response.setStatusCode(ErrorCode.SUCCESS.getCode()); return response; } diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/service/RedisRpcPlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/service/RedisRpcPlayServiceImpl.java index 623aae13..a22e9dad 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/service/RedisRpcPlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/service/RedisRpcPlayServiceImpl.java @@ -9,6 +9,7 @@ import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.conf.redis.RedisRpcConfig; import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcRequest; import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcResponse; +import com.genersoft.iot.vmp.gb28181.bean.RecordInfo; import com.genersoft.iot.vmp.service.bean.ErrorCallback; import com.genersoft.iot.vmp.service.bean.InviteErrorCode; import com.genersoft.iot.vmp.service.redisMsg.IRedisRpcPlayService; @@ -48,7 +49,7 @@ public class RedisRpcPlayServiceImpl implements IRedisRpcPlayService { if (response == null) { callback.run(ErrorCode.ERROR100.getCode(), ErrorCode.ERROR100.getMsg(), null); }else { - if (response.getStatusCode() == Response.OK) { + if (response.getStatusCode() == ErrorCode.SUCCESS.getCode()) { StreamInfo streamInfo = JSON.parseObject(response.getBody().toString(), StreamInfo.class); callback.run(InviteErrorCode.SUCCESS.getCode(), InviteErrorCode.SUCCESS.getMsg(), streamInfo); }else { @@ -69,12 +70,33 @@ public class RedisRpcPlayServiceImpl implements IRedisRpcPlayService { if (response == null) { throw new ControllerException(ErrorCode.ERROR100.getCode(), ErrorCode.ERROR100.getMsg()); }else { - if (response.getStatusCode() != Response.OK) { + if (response.getStatusCode() != ErrorCode.SUCCESS.getCode()) { throw new ControllerException(ErrorCode.ERROR100.getCode(), ErrorCode.ERROR100.getMsg()); } } } + @Override + public void queryRecordInfo(String serverId, Integer channelId, String startTime, String endTime, ErrorCallback callback) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("channelId", channelId); + jsonObject.put("startTime", startTime); + jsonObject.put("endTime", endTime); + RedisRpcRequest request = buildRequest("channel/queryRecordInfo", jsonObject); + request.setToId(serverId); + RedisRpcResponse response = redisRpcConfig.request(request, userSetting.getRecordInfoTimeout(), TimeUnit.MILLISECONDS); + if (response == null) { + callback.run(ErrorCode.ERROR100.getCode(), ErrorCode.ERROR100.getMsg(), null); + }else { + if (response.getStatusCode() == ErrorCode.SUCCESS.getCode()) { + RecordInfo recordInfo = JSON.parseObject(response.getBody().toString(), RecordInfo.class); + callback.run(InviteErrorCode.SUCCESS.getCode(), InviteErrorCode.SUCCESS.getMsg(), recordInfo); + }else { + callback.run(response.getStatusCode(), response.getBody().toString(), null); + } + } + } + @Override public void playback(String serverId, Integer channelId, String startTime, String endTime, ErrorCallback callback) { @@ -88,7 +110,7 @@ public class RedisRpcPlayServiceImpl implements IRedisRpcPlayService { if (response == null) { callback.run(ErrorCode.ERROR100.getCode(), ErrorCode.ERROR100.getMsg(), null); }else { - if (response.getStatusCode() == Response.OK) { + if (response.getStatusCode() == ErrorCode.SUCCESS.getCode()) { StreamInfo streamInfo = JSON.parseObject(response.getBody().toString(), StreamInfo.class); callback.run(InviteErrorCode.SUCCESS.getCode(), InviteErrorCode.SUCCESS.getMsg(), streamInfo); }else { @@ -111,7 +133,7 @@ public class RedisRpcPlayServiceImpl implements IRedisRpcPlayService { if (response == null) { callback.run(ErrorCode.ERROR100.getCode(), ErrorCode.ERROR100.getMsg(), null); }else { - if (response.getStatusCode() == Response.OK) { + if (response.getStatusCode() == ErrorCode.SUCCESS.getCode()) { StreamInfo streamInfo = JSON.parseObject(response.getBody().toString(), StreamInfo.class); callback.run(InviteErrorCode.SUCCESS.getCode(), InviteErrorCode.SUCCESS.getMsg(), streamInfo); }else { diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/bean/ErrorCode.java b/src/main/java/com/genersoft/iot/vmp/vmanager/bean/ErrorCode.java index e2e3879b..53b8be60 100755 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/bean/ErrorCode.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/bean/ErrorCode.java @@ -9,6 +9,7 @@ public enum ErrorCode { ERROR400(400, "参数或方法错误"), ERROR404(404, "资源未找到"), ERROR403(403, "无权限操作"), + ERROR486(486, "超时或无响应"), ERROR401(401, "请登录后重新请求"), ERROR500(500, "系统异常"); diff --git a/src/main/resources/配置详情.yml b/src/main/resources/配置详情.yml index cef72151..167dd834 100644 --- a/src/main/resources/配置详情.yml +++ b/src/main/resources/配置详情.yml @@ -198,6 +198,8 @@ user-settings: save-position-history: false # 点播/录像回放 等待超时时间,单位:毫秒 play-timeout: 18000 + # 获取设备录像数据超时时间,单位:毫秒 + record-info-timeout: 10000 # 上级点播等待超时时间,单位:毫秒 platform-play-timeout: 60000 # 是否开启接口鉴权 From af7344225413729e2ccf8f3b83b68dc097fa5bcd Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Mon, 9 Dec 2024 14:27:54 +0800 Subject: [PATCH 02/38] =?UTF-8?q?=E6=8C=87=E5=AE=9A=E8=AF=BB=E5=8F=96?= =?UTF-8?q?=E8=A1=8C=E6=94=BF=E5=8C=BA=E5=88=92=E6=96=87=E4=BB=B6=E7=BC=96?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/genersoft/iot/vmp/conf/CivilCodeFileConf.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/genersoft/iot/vmp/conf/CivilCodeFileConf.java b/src/main/java/com/genersoft/iot/vmp/conf/CivilCodeFileConf.java index 878e01c5..28e68fb3 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/CivilCodeFileConf.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/CivilCodeFileConf.java @@ -15,6 +15,7 @@ import java.io.BufferedReader; import java.io.File; import java.io.InputStream; import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; /** @@ -54,7 +55,7 @@ public class CivilCodeFileConf implements CommandLineRunner { inputStream = Files.newInputStream(civilCodeFile.toPath()); } - BufferedReader inputStreamReader = new BufferedReader(new InputStreamReader(inputStream)); + BufferedReader inputStreamReader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8)); int index = -1; String line; while ((line = inputStreamReader.readLine()) != null) { From 4354a532bbe430fd776c890232fe31dec70d8469 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Mon, 18 Nov 2024 18:00:21 +0800 Subject: [PATCH 03/38] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BD=95=E5=88=B6?= =?UTF-8?q?=E8=AE=A1=E5=88=92=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/service/bean/RecordPlan.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlan.java diff --git a/src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlan.java b/src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlan.java new file mode 100644 index 00000000..0ed21513 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlan.java @@ -0,0 +1,27 @@ +package com.genersoft.iot.vmp.service.bean; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +@Schema(description = "录制计划") +public class RecordPlan { + + @Schema(description = "计划数据库ID") + private int id; + + @Schema(description = "计划关联的通道ID") + private Integer channelId; + + @Schema(description = "计划开始时间") + private Long startTime; + + @Schema(description = "计划结束时间") + private Long stopTime; + + @Schema(description = "计划周几执行") + private Integer weekDay; + + @Schema(description = "是否开启定时截图") + private Boolean snap; +} From b6bce3b02998455f9402e744905b96e7a7f74756 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Tue, 19 Nov 2024 16:42:11 +0800 Subject: [PATCH 04/38] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BD=95=E5=88=B6?= =?UTF-8?q?=E8=AE=A1=E5=88=92=E7=9A=84=E9=A1=B5=E9=9D=A2=E4=B8=8E=E9=80=9A?= =?UTF-8?q?=E9=81=93=E6=9F=A5=E8=AF=A2=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/gb28181/bean/CommonGBChannel.java | 3 + .../controller/CommonChannelController.java | 21 ++ .../gb28181/dao/CommonGBChannelMapper.java | 2 + .../gb28181/dao/provider/ChannelProvider.java | 32 +++ .../gb28181/service/IGbChannelService.java | 3 + .../service/impl/GbChannelServiceImpl.java | 12 + .../recordPlan/RecordPlanController.java | 15 ++ web_src/src/components/RecordPLan.vue | 241 ++++++++++++++++++ web_src/src/layout/UiHeader.vue | 1 + web_src/src/router/index.js | 5 + 数据库/2.7.3/初始化-mysql-2.7.3.sql | 1 + .../2.7.3/初始化-postgresql-kingbase-2.7.3.sql | 1 + 12 files changed, 337 insertions(+) create mode 100644 src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/RecordPlanController.java create mode 100755 web_src/src/components/RecordPLan.vue diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CommonGBChannel.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CommonGBChannel.java index 6327688b..ea606692 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CommonGBChannel.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CommonGBChannel.java @@ -126,6 +126,9 @@ public class CommonGBChannel { @Schema(description = "关联的国标设备数据库ID") private Integer gbDeviceDbId; + @Schema(description = "二进制保存的录制计划, 每一位表示每个小时的前半个小时") + private Long recordPLan; + @Schema(description = "关联的推流Id(流来源是推流时有效)") private Integer streamPushId; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/CommonChannelController.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/CommonChannelController.java index 44d11b0b..3db52a43 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/CommonChannelController.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/CommonChannelController.java @@ -101,11 +101,31 @@ public class CommonChannelController { return channel; } + @Operation(summary = "获取通道列表", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Parameter(name = "page", description = "当前页", required = true) + @Parameter(name = "count", description = "每页查询数量", required = true) + @Parameter(name = "query", description = "查询内容") + @Parameter(name = "online", description = "是否在线") + @Parameter(name = "hasRecordPlan", description = "是否已设置录制计划") + @Parameter(name = "channelType", description = "通道类型, 0:国标设备,1:推流设备,2:拉流代理") + @GetMapping("/list") + public PageInfo queryList(int page, int count, + @RequestParam(required = false) String query, + @RequestParam(required = false) Boolean online, + @RequestParam(required = false) Boolean hasRecordPlan, + @RequestParam(required = false) Integer channelType){ + if (ObjectUtils.isEmpty(query)){ + query = null; + } + return channelService.queryList(page, count, query, online, hasRecordPlan, channelType); + } + @Operation(summary = "获取关联行政区划通道列表", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Parameter(name = "page", description = "当前页", required = true) @Parameter(name = "count", description = "每页查询数量", required = true) @Parameter(name = "query", description = "查询内容") @Parameter(name = "online", description = "是否在线") + @Parameter(name = "channelType", description = "通道类型, 0:国标设备,1:推流设备,2:拉流代理") @Parameter(name = "civilCode", description = "行政区划") @GetMapping("/civilcode/list") public PageInfo queryListByCivilCode(int page, int count, @@ -124,6 +144,7 @@ public class CommonChannelController { @Parameter(name = "count", description = "每页查询数量", required = true) @Parameter(name = "query", description = "查询内容") @Parameter(name = "online", description = "是否在线") + @Parameter(name = "channelType", description = "通道类型, 0:国标设备,1:推流设备,2:拉流代理") @Parameter(name = "groupDeviceId", description = "业务分组下的父节点ID") @GetMapping("/parent/list") public PageInfo queryListByParentId(int page, int count, diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java index 664329e4..99aff973 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java @@ -457,4 +457,6 @@ public interface CommonGBChannelMapper { " "}) void updateGpsByDeviceIdForStreamPush(List channels); + @SelectProvider(type = ChannelProvider.class, method = "queryList") + List queryList(@Param("query") String query, @Param("online") Boolean online, @Param("hasRecordPlan") Boolean hasRecordPlan, @Param("channelType") Integer channelType); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/ChannelProvider.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/ChannelProvider.java index 092c90dc..3c481cdc 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/ChannelProvider.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/ChannelProvider.java @@ -17,6 +17,7 @@ public class ChannelProvider { " stream_proxy_id,\n" + " create_time,\n" + " update_time,\n" + + " record_plan,\n" + " coalesce(gb_device_id, device_id) as gb_device_id,\n" + " coalesce(gb_name, name) as gb_name,\n" + " coalesce(gb_manufacturer, manufacturer) as gb_manufacturer,\n" + @@ -182,6 +183,37 @@ public class ChannelProvider { return sqlBuild.toString(); } + public String queryList(Map params ){ + StringBuilder sqlBuild = new StringBuilder(); + sqlBuild.append(BASE_SQL); + sqlBuild.append(" where channel_type = 0 "); + if (params.get("query") != null) { + sqlBuild.append(" AND (coalesce(gb_device_id, device_id) LIKE concat('%',#{query},'%') escape '/'" + + " OR coalesce(gb_name, name) LIKE concat('%',#{query},'%') escape '/' )") + ; + } + if (params.get("online") != null && (Boolean)params.get("online")) { + sqlBuild.append(" AND coalesce(gb_status, status) = 'ON'"); + } + if (params.get("online") != null && !(Boolean)params.get("online")) { + sqlBuild.append(" AND coalesce(gb_status, status) = 'OFF'"); + } + if (params.get("hasRecordPlan") != null && !(Boolean)params.get("hasRecordPlan")) { + sqlBuild.append(" AND record_plan == 0"); + } + + if (params.get("channelType") != null) { + if ((Integer)params.get("channelType") == 0) { + sqlBuild.append(" AND device_db_id is not null"); + }else if ((Integer)params.get("channelType") == 1) { + sqlBuild.append(" AND stream_push_id is not null"); + }else if ((Integer)params.get("channelType") == 2) { + sqlBuild.append(" AND stream_proxy_id is not null"); + } + } + return sqlBuild.toString(); + } + public String queryInListByStatus(Map params ){ StringBuilder sqlBuild = new StringBuilder(); sqlBuild.append(BASE_SQL); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelService.java index 2d8f9531..8dc67df2 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelService.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelService.java @@ -84,4 +84,7 @@ public interface IGbChannelService { List queryListByStreamPushList(List streamPushList); void updateGpsByDeviceIdForStreamPush(List channels); + + PageInfo queryList(int page, int count, String query, Boolean online, Boolean hasRecordPlan, Integer channelType); + } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java index f19f4f9c..792fd88b 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java @@ -714,4 +714,16 @@ public class GbChannelServiceImpl implements IGbChannelService { public void updateGpsByDeviceIdForStreamPush(List channels) { commonGBChannelMapper.updateGpsByDeviceIdForStreamPush(channels); } + + @Override + public PageInfo queryList(int page, int count, String query, Boolean online, Boolean hasRecordPlan, Integer channelType) { + PageHelper.startPage(page, count); + if (query != null) { + query = query.replaceAll("/", "//") + .replaceAll("%", "/%") + .replaceAll("_", "/_"); + } + List all = commonGBChannelMapper.queryList(query, online, hasRecordPlan, channelType); + return new PageInfo<>(all); + } } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/RecordPlanController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/RecordPlanController.java new file mode 100644 index 00000000..9c8b4687 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/RecordPlanController.java @@ -0,0 +1,15 @@ +package com.genersoft.iot.vmp.vmanager.recordPlan; + +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@Tag(name = "录制计划") +@Slf4j +@RestController +@RequestMapping("/api/record/plan") +public class RecordPlanController { + + +} diff --git a/web_src/src/components/RecordPLan.vue b/web_src/src/components/RecordPLan.vue new file mode 100755 index 00000000..ed4215fd --- /dev/null +++ b/web_src/src/components/RecordPLan.vue @@ -0,0 +1,241 @@ + + + + + diff --git a/web_src/src/layout/UiHeader.vue b/web_src/src/layout/UiHeader.vue index 0561bea7..dda1a8ea 100755 --- a/web_src/src/layout/UiHeader.vue +++ b/web_src/src/layout/UiHeader.vue @@ -15,6 +15,7 @@ 行政区划 业务分组 + 录制计划 云端录像 节点管理 国标级联 diff --git a/web_src/src/router/index.js b/web_src/src/router/index.js index f85c5a5a..5d609c4e 100755 --- a/web_src/src/router/index.js +++ b/web_src/src/router/index.js @@ -26,6 +26,7 @@ import rtcPlayer from '../components/dialog/rtcPlayer.vue' import region from '../components/region.vue' import group from '../components/group.vue' import operations from '../components/operations.vue' +import recordPLan from '../components/RecordPLan.vue' const originalPush = VueRouter.prototype.push VueRouter.prototype.push = function push(location) { @@ -148,6 +149,10 @@ export default new VueRouter({ path: '/operations', component: operations, }, + { + path: '/recordPLan', + component: recordPLan, + }, ] }, { diff --git a/数据库/2.7.3/初始化-mysql-2.7.3.sql b/数据库/2.7.3/初始化-mysql-2.7.3.sql index d572843d..0d9322a5 100644 --- a/数据库/2.7.3/初始化-mysql-2.7.3.sql +++ b/数据库/2.7.3/初始化-mysql-2.7.3.sql @@ -147,6 +147,7 @@ create table wvp_device_channel gb_download_speed character varying(255), gb_svc_space_support_mod integer, gb_svc_time_support_mode integer, + record_plan integer, stream_push_id integer, stream_proxy_id integer, constraint uk_wvp_device_channel_unique_device_channel unique (device_db_id, device_id), diff --git a/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql b/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql index cb06d2ee..223d80ab 100644 --- a/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql +++ b/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql @@ -163,6 +163,7 @@ create table wvp_device_channel gb_download_speed character varying(255), gb_svc_space_support_mod integer, gb_svc_time_support_mode integer, + record_plan integer, stream_push_id integer, stream_proxy_id integer, constraint uk_wvp_device_channel_unique_device_channel unique (device_db_id, device_id), From 3da263493f1eeda2803e985c3fb7cd4ab2c74973 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Tue, 19 Nov 2024 18:03:43 +0800 Subject: [PATCH 05/38] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BD=95=E5=88=B6?= =?UTF-8?q?=E8=AE=A1=E5=88=92=E8=AE=BE=E7=BD=AE=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web_src/package.json | 1 + web_src/src/components/RecordPLan.vue | 14 +++ .../src/components/dialog/editRecordPlan.vue | 98 +++++++++++++++++++ 3 files changed, 113 insertions(+) create mode 100644 web_src/src/components/dialog/editRecordPlan.vue diff --git a/web_src/package.json b/web_src/package.json index c314b9ba..78582b87 100644 --- a/web_src/package.json +++ b/web_src/package.json @@ -15,6 +15,7 @@ "@liveqing/liveplayer": "^2.7.10", "@wchbrad/vue-easy-tree": "^1.0.12", "axios": "^0.24.0", + "byte-weektime-picker": "^1.1.1", "core-js": "^2.6.5", "echarts": "^4.9.0", "element-ui": "^2.15.14", diff --git a/web_src/src/components/RecordPLan.vue b/web_src/src/components/RecordPLan.vue index ed4215fd..a31917ce 100755 --- a/web_src/src/components/RecordPLan.vue +++ b/web_src/src/components/RecordPLan.vue @@ -81,6 +81,12 @@ + + + + diff --git a/web_src/src/components/dialog/editRecordPlan.vue b/web_src/src/components/dialog/editRecordPlan.vue new file mode 100644 index 00000000..3b54b1b6 --- /dev/null +++ b/web_src/src/components/dialog/editRecordPlan.vue @@ -0,0 +1,98 @@ + + + From c7e33f655efea9d7f564c87b67f6b5b226307217 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 20 Nov 2024 18:37:39 +0800 Subject: [PATCH 06/38] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=BD=95=E5=88=B6=E8=AE=A1=E5=88=92=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gb28181/dao/provider/ChannelProvider.java | 6 +- .../recordPlan/RecordPlanController.java | 27 ++++++- web_src/src/components/RecordPLan.vue | 2 +- .../src/components/dialog/editRecordPlan.vue | 79 ++++++++++++++++--- 数据库/2.7.3/初始化-mysql-2.7.3.sql | 2 +- .../2.7.3/初始化-postgresql-kingbase-2.7.3.sql | 2 +- 6 files changed, 99 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/ChannelProvider.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/ChannelProvider.java index 3c481cdc..8a941d3c 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/ChannelProvider.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/ChannelProvider.java @@ -17,7 +17,7 @@ public class ChannelProvider { " stream_proxy_id,\n" + " create_time,\n" + " update_time,\n" + - " record_plan,\n" + + " record_plan_id,\n" + " coalesce(gb_device_id, device_id) as gb_device_id,\n" + " coalesce(gb_name, name) as gb_name,\n" + " coalesce(gb_manufacturer, manufacturer) as gb_manufacturer,\n" + @@ -198,8 +198,8 @@ public class ChannelProvider { if (params.get("online") != null && !(Boolean)params.get("online")) { sqlBuild.append(" AND coalesce(gb_status, status) = 'OFF'"); } - if (params.get("hasRecordPlan") != null && !(Boolean)params.get("hasRecordPlan")) { - sqlBuild.append(" AND record_plan == 0"); + if (params.get("hasRecordPlan") != null && (Boolean)params.get("hasRecordPlan")) { + sqlBuild.append(" AND record_plan_id > 0"); } if (params.get("channelType") != null) { diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/RecordPlanController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/RecordPlanController.java index 9c8b4687..2a269836 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/RecordPlanController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/RecordPlanController.java @@ -1,9 +1,17 @@ package com.genersoft.iot.vmp.vmanager.recordPlan; +import com.genersoft.iot.vmp.conf.exception.ControllerException; +import com.genersoft.iot.vmp.conf.security.JwtUtils; +import com.genersoft.iot.vmp.service.bean.RecordPlan; +import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.extern.slf4j.Slf4j; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; + +import java.util.List; @Tag(name = "录制计划") @Slf4j @@ -11,5 +19,20 @@ import org.springframework.web.bind.annotation.RestController; @RequestMapping("/api/record/plan") public class RecordPlanController { + @ResponseBody + @PostMapping("/add") + @Operation(summary = "添加录制计划", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Parameter(name = "channelId", description = "通道ID", required = true) + @Parameter(name = "deviceDbId", description = "国标设备ID", required = true) + @Parameter(name = "planList", description = "录制计划, 为空则清空计划", required = false) + public void openRtpServer(@RequestParam(required = false) Integer channelId, @RequestParam(required = false) Integer deviceDbId, @RequestParam(required = false) List planList + ) { + if (channelId == null && deviceDbId == null) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "通道ID和国标设备ID不可都为NULL"); + } + + + + } } diff --git a/web_src/src/components/RecordPLan.vue b/web_src/src/components/RecordPLan.vue index a31917ce..bba30ea4 100755 --- a/web_src/src/components/RecordPLan.vue +++ b/web_src/src/components/RecordPLan.vue @@ -76,7 +76,7 @@ diff --git a/web_src/src/components/dialog/editRecordPlan.vue b/web_src/src/components/dialog/editRecordPlan.vue index 3b54b1b6..7f12794f 100644 --- a/web_src/src/components/dialog/editRecordPlan.vue +++ b/web_src/src/components/dialog/editRecordPlan.vue @@ -11,9 +11,9 @@ >
- + -
+
保存 取消
@@ -36,7 +36,6 @@ export default { }, data() { return { - value:"", options: [], loading: false, showDialog: false, @@ -44,6 +43,7 @@ export default { deviceDbId: "", endCallback: "", byteTime: "", + planList: [], }; }, methods: { @@ -52,15 +52,22 @@ export default { this.deviceDbId = deviceDbId; this.endCallback = endCallback; this.showDialog = true; + this.byteTime= ""; + if (channel.recordPlanId) { + // 请求plan信息 + + } }, onSubmit: function () { + let planList = this.byteTime2PlanList(); + console.log(planList) this.$axios({ method: 'post', - url: "/api/user/add", + url: "/api/record/plan/add", params: { - username: this.username, - password: this.password, - roleId: this.roleId + channelId: this.channel?this.channel.id:null, + deviceDbId: this.deviceDbId, + planList: planList } }).then((res) => { if (res.data.code === 0) { @@ -68,11 +75,9 @@ export default { showClose: true, message: '添加成功', type: 'success', - }); this.showDialog = false; - this.listChangeCallback() - + this.endCallback() } else { this.$message({ showClose: true, @@ -85,7 +90,6 @@ export default { }); }, close: function () { - console.log(this.byteTime) this.channel = ""; this.deviceDbId = ""; this.showDialog = false; @@ -93,6 +97,59 @@ export default { this.endCallback(); } }, + byteTime2PlanList() { + this.planList = [] + if (this.byteTime.length === 0) { + return; + } + const DayTimes = 24 * 2; + let planList = [] + let week = 1; + // 把 336长度的 list 分成 7 组,每组 48 个 + for (let i = 0; i < this.byteTime.length; i += DayTimes) { + let planArray = this.byteTime2Plan(this.byteTime.slice(i, i + DayTimes)); + console.log(planArray) + if(!planArray || planArray.length === 0) { + week ++; + continue + } + for (let j = 0; j < planArray.length; j++) { + console.log(planArray[j]) + planList.push({ + startTime: planArray[j].startTime, + stopTime: planArray[j].stopTime, + weekDay: week + }) + } + week ++; + } + return planList + }, + byteTime2Plan(weekItem){ + let startTime = 0; + let endTime = 0; + let result = [] + + for (let i = 0; i < weekItem.length; i++) { + let item = weekItem[i] + if (item === '1') { + endTime = 30*i + if (startTime === 0 ) { + startTime = 30*i + } + } else { + if (endTime !== 0){ + result.push({ + startTime: startTime * 60 * 1000, + stopTime: endTime * 60 * 1000, + }) + startTime = 0 + endTime = 0 + } + } + } + return result; + } }, }; diff --git a/数据库/2.7.3/初始化-mysql-2.7.3.sql b/数据库/2.7.3/初始化-mysql-2.7.3.sql index 0d9322a5..705eb301 100644 --- a/数据库/2.7.3/初始化-mysql-2.7.3.sql +++ b/数据库/2.7.3/初始化-mysql-2.7.3.sql @@ -147,7 +147,7 @@ create table wvp_device_channel gb_download_speed character varying(255), gb_svc_space_support_mod integer, gb_svc_time_support_mode integer, - record_plan integer, + record_plan_id integer, stream_push_id integer, stream_proxy_id integer, constraint uk_wvp_device_channel_unique_device_channel unique (device_db_id, device_id), diff --git a/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql b/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql index 223d80ab..f589329e 100644 --- a/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql +++ b/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql @@ -163,7 +163,7 @@ create table wvp_device_channel gb_download_speed character varying(255), gb_svc_space_support_mod integer, gb_svc_time_support_mode integer, - record_plan integer, + record_plan_id integer, stream_push_id integer, stream_proxy_id integer, constraint uk_wvp_device_channel_unique_device_channel unique (device_db_id, device_id), From 988845f246cfc90ff9cfdcda50b018a125dd42ef Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 20 Nov 2024 22:33:21 +0800 Subject: [PATCH 07/38] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E7=BB=93=E6=9E=84=E4=BB=A5=E5=8F=8A=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vmp/gb28181/dao/DeviceChannelMapper.java | 3 + .../service/IDeviceChannelService.java | 3 + .../impl/DeviceChannelServiceImpl.java | 10 ++ .../cmd/BroadcastResponseMessageHandler.java | 2 + .../iot/vmp/service/IRecordPlanService.java | 23 +++++ .../iot/vmp/service/bean/RecordPlan.java | 25 +++-- .../iot/vmp/service/bean/RecordPlanItem.java | 25 +++++ .../service/impl/RecordPlanServiceImpl.java | 79 ++++++++++++++++ .../vmp/storager/dao/RecordPlanMapper.java | 40 ++++++++ .../recordPlan/RecordPlanController.java | 93 +++++++++++++++++-- .../recordPlan/bean/RecordPlanParam.java | 22 +++++ src/main/resources/index.html | 10 ++ 数据库/2.7.3/初始化-mysql-2.7.3.sql | 20 ++++ .../2.7.3/初始化-postgresql-kingbase-2.7.3.sql | 20 ++++ 14 files changed, 356 insertions(+), 19 deletions(-) create mode 100644 src/main/java/com/genersoft/iot/vmp/service/IRecordPlanService.java create mode 100644 src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlanItem.java create mode 100644 src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java create mode 100644 src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java create mode 100644 src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/bean/RecordPlanParam.java create mode 100644 src/main/resources/index.html 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 a5263235..75131ca6 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 @@ -93,6 +93,9 @@ public interface DeviceChannelMapper { @SelectProvider(type = DeviceChannelProvider.class, method = "queryChannelsByDeviceDbId") List queryChannelsByDeviceDbId(@Param("deviceDbId") int deviceDbId); + @Select("select id from wvp_device_channel where device_db_id = #{deviceDbId}") + List queryChaneIdListByDeviceDbId(@Param("deviceDbId") int deviceDbId); + @Delete("DELETE FROM wvp_device_channel WHERE device_db_id=#{deviceId}") int cleanChannelsByDeviceId(@Param("deviceId") int deviceId); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java index 81d9f9af..4f0ee8e1 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java @@ -122,4 +122,7 @@ public interface IDeviceChannelService { DeviceChannel getOneBySourceId(int deviceDbId, String channelId); + List queryChaneListByDeviceDbId(Integer deviceDbId); + + List queryChaneIdListByDeviceDbId(Integer deviceDbId); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java index 4536c1ec..8fecc7f4 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java @@ -348,6 +348,16 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { return channelMapper.queryChannelsByDeviceDbId(device.getId()); } + @Override + public List queryChaneListByDeviceDbId(Integer deviceDbId) { + return channelMapper.queryChannelsByDeviceDbId(deviceDbId); + } + + @Override + public List queryChaneIdListByDeviceDbId(Integer deviceDbId) { + return channelMapper.queryChaneIdListByDeviceDbId(deviceDbId); + } + @Override public void updateChannelGPS(Device device, DeviceChannel deviceChannel, MobilePosition mobilePosition) { if (userSetting.getSavePositionHistory()) { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/BroadcastResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/BroadcastResponseMessageHandler.java index 97748222..2567b762 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/BroadcastResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/BroadcastResponseMessageHandler.java @@ -94,4 +94,6 @@ public class BroadcastResponseMessageHandler extends SIPRequestProcessorParent i public void handForPlatform(RequestEvent evt, Platform parentPlatform, Element element) { } + + } diff --git a/src/main/java/com/genersoft/iot/vmp/service/IRecordPlanService.java b/src/main/java/com/genersoft/iot/vmp/service/IRecordPlanService.java new file mode 100644 index 00000000..641ddb18 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/service/IRecordPlanService.java @@ -0,0 +1,23 @@ +package com.genersoft.iot.vmp.service; + +import com.genersoft.iot.vmp.service.bean.RecordPlan; +import com.genersoft.iot.vmp.service.bean.RecordPlanItem; +import com.github.pagehelper.PageInfo; + +import java.util.List; + +public interface IRecordPlanService { + + + RecordPlan get(Integer planId); + + void update(RecordPlan plan); + + void delete(Integer planId); + + PageInfo query(Integer page, Integer count, String query); + + void add(RecordPlan plan); + + void linke(List channelIds, Integer planId); +} diff --git a/src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlan.java b/src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlan.java index 0ed21513..5333b2c3 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlan.java +++ b/src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlan.java @@ -3,6 +3,8 @@ package com.genersoft.iot.vmp.service.bean; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import java.util.List; + @Data @Schema(description = "录制计划") public class RecordPlan { @@ -10,18 +12,21 @@ public class RecordPlan { @Schema(description = "计划数据库ID") private int id; - @Schema(description = "计划关联的通道ID") - private Integer channelId; + @Schema(description = "计划名称") + private String name; - @Schema(description = "计划开始时间") - private Long startTime; - - @Schema(description = "计划结束时间") - private Long stopTime; - - @Schema(description = "计划周几执行") - private Integer weekDay; + @Schema(description = "计划关联通道数量") + private int channelCount; @Schema(description = "是否开启定时截图") private Boolean snap; + + @Schema(description = "创建时间") + private String createTime; + + @Schema(description = "更新时间") + private String updateTime; + + @Schema(description = "计划内容") + private List planItemList; } diff --git a/src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlanItem.java b/src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlanItem.java new file mode 100644 index 00000000..14383cb1 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlanItem.java @@ -0,0 +1,25 @@ +package com.genersoft.iot.vmp.service.bean; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +@Schema(description = "录制计划项") +public class RecordPlanItem { + + @Schema(description = "计划项数据库ID") + private int id; + + @Schema(description = "计划开始时间") + private Long startTime; + + @Schema(description = "计划结束时间") + private Long stopTime; + + @Schema(description = "计划周几执行") + private Integer weekDay; + + @Schema(description = "所属计划ID") + private Integer planId; + +} diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java new file mode 100644 index 00000000..661bea1b --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java @@ -0,0 +1,79 @@ +package com.genersoft.iot.vmp.service.impl; + +import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; +import com.genersoft.iot.vmp.gb28181.dao.CommonGBChannelMapper; +import com.genersoft.iot.vmp.service.IRecordPlanService; +import com.genersoft.iot.vmp.service.bean.CloudRecordItem; +import com.genersoft.iot.vmp.service.bean.RecordPlan; +import com.genersoft.iot.vmp.service.bean.RecordPlanItem; +import com.genersoft.iot.vmp.storager.dao.RecordPlanMapper; +import com.genersoft.iot.vmp.utils.DateUtil; +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; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +@Service +@Slf4j +public class RecordPlanServiceImpl implements IRecordPlanService { + + @Autowired + private RecordPlanMapper recordPlanMapper; + + @Autowired + private CommonGBChannelMapper channelMapper; + + @Override + @Transactional + public void add(RecordPlan plan) { + plan.setCreateTime(DateUtil.getNow()); + plan.setUpdateTime(DateUtil.getNow()); + recordPlanMapper.add(plan); + if (plan.getId() > 0) { + recordPlanMapper.batchAddItem(plan.getId(), plan.getPlanItemList()); + } + } + + @Override + public RecordPlan get(Integer planId) { + return recordPlanMapper.get(planId); + } + + @Override + public void update(RecordPlan plan) { + plan.setUpdateTime(DateUtil.getNow()); + recordPlanMapper.update(plan); + } + + @Override + public void delete(Integer planId) { + recordPlanMapper.delete(planId); + } + + @Override + public PageInfo query(Integer page, Integer count, String query) { + PageHelper.startPage(page, count); + if (query != null) { + query = query.replaceAll("/", "//") + .replaceAll("%", "/%") + .replaceAll("_", "/_"); + } + List all = recordPlanMapper.query(query); + return new PageInfo<>(all); + } + + @Override + public void linke(List channelIds, Integer planId) { + if (planId == null) { + log.info("[录制计划] 移除通道关联的计划"); + channelMapper.removeRecordPlan(channelIds); + }else { + channelMapper.addRecordPlan(channelIds, planId); + } + + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java new file mode 100644 index 00000000..cd4f3173 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java @@ -0,0 +1,40 @@ +package com.genersoft.iot.vmp.storager.dao; + +import com.genersoft.iot.vmp.service.bean.RecordPlan; +import com.genersoft.iot.vmp.service.bean.RecordPlanItem; +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Options; + +import java.util.List; + +@Mapper +public interface RecordPlanMapper { + + @Insert(" ") + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + void add(RecordPlan plan); + + RecordPlan get(Integer planId); + + List query(String query); + + void update(RecordPlan plan); + + void delete(Integer planId); + + + void batchAddItem(int planId, List planItemList); + +} diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/RecordPlanController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/RecordPlanController.java index 2a269836..6f3fdfa3 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/RecordPlanController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/RecordPlanController.java @@ -2,15 +2,22 @@ package com.genersoft.iot.vmp.vmanager.recordPlan; import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.conf.security.JwtUtils; +import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService; +import com.genersoft.iot.vmp.service.IRecordPlanService; import com.genersoft.iot.vmp.service.bean.RecordPlan; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; +import com.genersoft.iot.vmp.vmanager.recordPlan.bean.RecordPlanParam; +import com.github.pagehelper.PageInfo; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.ObjectUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.util.ArrayList; import java.util.List; @Tag(name = "录制计划") @@ -19,20 +26,88 @@ import java.util.List; @RequestMapping("/api/record/plan") public class RecordPlanController { + @Autowired + private IRecordPlanService recordPlanService; + + @Autowired + private IDeviceChannelService deviceChannelService; + + @ResponseBody @PostMapping("/add") @Operation(summary = "添加录制计划", security = @SecurityRequirement(name = JwtUtils.HEADER)) - @Parameter(name = "channelId", description = "通道ID", required = true) - @Parameter(name = "deviceDbId", description = "国标设备ID", required = true) - @Parameter(name = "planList", description = "录制计划, 为空则清空计划", required = false) - public void openRtpServer(@RequestParam(required = false) Integer channelId, @RequestParam(required = false) Integer deviceDbId, @RequestParam(required = false) List planList + @Parameter(name = "plan", description = "计划", required = true) + public void add(@RequestBody RecordPlan plan) { + if (plan.getPlanItemList() == null || plan.getPlanItemList().isEmpty()) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "添加录制计划时,录制计划不可为空"); + } + recordPlanService.add(plan); + } - ) { - if (channelId == null && deviceDbId == null) { + @ResponseBody + @PostMapping("/linke") + @Operation(summary = "通道关联录制计划", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Parameter(name = "param", description = "通道关联录制计划", required = false) + public void linke(@RequestBody RecordPlanParam param) { + if (param.getChannelId() == null && param.getDeviceDbId() == null) { throw new ControllerException(ErrorCode.ERROR100.getCode(), "通道ID和国标设备ID不可都为NULL"); } - - - + List channelIds = new ArrayList<>(); + if (param.getChannelId() != null) { + channelIds.add(param.getChannelId()); + }else { + List chanelIdList = deviceChannelService.queryChaneIdListByDeviceDbId(param.getDeviceDbId()); + if (chanelIdList == null || chanelIdList.isEmpty()) { + channelIds = chanelIdList; + } + } + recordPlanService.linke(channelIds, param.getPlanId()); } + + @ResponseBody + @GetMapping("/get") + @Operation(summary = "查询录制计划", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Parameter(name = "planId", description = "计划ID", required = true) + public RecordPlan get(Integer planId) { + if (planId == null) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "计划ID不可为NULL"); + } + return recordPlanService.get(planId); + } + + @ResponseBody + @GetMapping("/query") + @Operation(summary = "查询录制计划列表", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Parameter(name = "query", description = "检索内容", required = false) + @Parameter(name = "page", description = "当前页", required = true) + @Parameter(name = "count", description = "每页查询数量", required = true) + public PageInfo query(@RequestParam(required = false) String query, @RequestParam Integer page, @RequestParam Integer count) { + if (query != null && ObjectUtils.isEmpty(query.trim())) { + query = null; + } + return recordPlanService.query(page, count, query); + } + + @ResponseBody + @PostMapping("/edit") + @Operation(summary = "编辑录制计划", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Parameter(name = "plan", description = "计划", required = true) + public void edit(@RequestBody RecordPlan plan) { + if (plan == null || plan.getId() == 0) { + throw new ControllerException(ErrorCode.ERROR400); + } + recordPlanService.update(plan); + } + + @ResponseBody + @DeleteMapping("/delete") + @Operation(summary = "删除录制计划", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Parameter(name = "planId", description = "计划ID", required = true) + public void delete(Integer planId) { + if (planId == null) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "计划IDID不可为NULL"); + } + recordPlanService.delete(planId); + } + } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/bean/RecordPlanParam.java b/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/bean/RecordPlanParam.java new file mode 100644 index 00000000..11cc1a0a --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/bean/RecordPlanParam.java @@ -0,0 +1,22 @@ +package com.genersoft.iot.vmp.vmanager.recordPlan.bean; + +import com.genersoft.iot.vmp.service.bean.RecordPlan; +import com.genersoft.iot.vmp.service.bean.RecordPlanItem; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.List; + +@Data +@Schema(description = "录制计划-添加/编辑参数") +public class RecordPlanParam { + + @Schema(description = "关联的通道ID") + private Integer channelId; + + @Schema(description = "关联的设备ID,会为设备下的所有通道关联此录制计划,channelId存在是此项不生效,") + private Integer deviceDbId; + + @Schema(description = "录制计划ID, ID为空是删除关联的计划") + private Integer planId; +} diff --git a/src/main/resources/index.html b/src/main/resources/index.html new file mode 100644 index 00000000..9d2fdca2 --- /dev/null +++ b/src/main/resources/index.html @@ -0,0 +1,10 @@ + + + + + Title + + +111 + + \ No newline at end of file diff --git a/数据库/2.7.3/初始化-mysql-2.7.3.sql b/数据库/2.7.3/初始化-mysql-2.7.3.sql index 705eb301..faada9cd 100644 --- a/数据库/2.7.3/初始化-mysql-2.7.3.sql +++ b/数据库/2.7.3/初始化-mysql-2.7.3.sql @@ -428,3 +428,23 @@ CREATE TABLE wvp_common_region constraint uk_common_region_device_id unique (device_id) ); +create table wvp_record_plan +( + id serial primary key, + snap bool default false, + name varchar(255) NOT NULL, + create_time character varying(50), + update_time character varying(50) +); + +create table wvp_record_plan_item +( + id serial primary key, + start_time bigint, + stop_time bigint, + week_day int, + plan_id int, + create_time character varying(50), + update_time character varying(50) +); + diff --git a/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql b/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql index f589329e..9ef3e926 100644 --- a/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql +++ b/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql @@ -445,3 +445,23 @@ CREATE TABLE wvp_common_region constraint uk_common_region_device_id unique (device_id) ); +create table wvp_record_plan +( + id serial primary key, + snap bool default false, + name varchar(255) NOT NULL, + create_time character varying(50), + update_time character varying(50) +); + +create table wvp_record_plan_item +( + id serial primary key, + start_time int8, + stop_time int8, + week_day int, + plan_id int, + create_time character varying(50), + update_time character varying(50) +); + From 0ad1aceeb58f7bdd95439e48748c54788c76577e Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 21 Nov 2024 20:50:22 +0800 Subject: [PATCH 08/38] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/RecordPlanServiceImpl.java | 10 +++++- .../vmp/storager/dao/RecordPlanMapper.java | 34 ++++++++++++++----- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java index 661bea1b..aa6d922d 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java @@ -40,7 +40,15 @@ public class RecordPlanServiceImpl implements IRecordPlanService { @Override public RecordPlan get(Integer planId) { - return recordPlanMapper.get(planId); + RecordPlan recordPlan = recordPlanMapper.get(planId); + if (recordPlan == null) { + return null; + } + List recordPlanItemList = recordPlanMapper.getItemList(planId); + if (!recordPlanItemList.isEmpty()) { + recordPlan.setPlanItemList(recordPlanItemList); + } + return recordPlan; } @Override diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java index cd4f3173..9fb4d588 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java @@ -2,9 +2,7 @@ package com.genersoft.iot.vmp.storager.dao; import com.genersoft.iot.vmp.service.bean.RecordPlan; import com.genersoft.iot.vmp.service.bean.RecordPlanItem; -import org.apache.ibatis.annotations.Insert; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Options; +import org.apache.ibatis.annotations.*; import java.util.List; @@ -26,15 +24,35 @@ public interface RecordPlanMapper { @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") void add(RecordPlan plan); - RecordPlan get(Integer planId); + @Insert(" ") + void batchAddItem(@Param("planId") int planId, List planItemList); - List query(String query); + @Select("select * from wvp_record_plan where id = #{planId}") + RecordPlan get(@Param("planId") Integer planId); + @Select(" ") + List query(@Param("query") String query); + + @Update("UPDATE wvp_record_plan SET update_time=#{updateTime}, name=#{name}, snap=#{snap} WHERE id=#{id}") void update(RecordPlan plan); - void delete(Integer planId); + @Delete("DELETE FROM wvp_record_plan WHERE id=#{id}") + void delete(@Param("planId") Integer planId); - void batchAddItem(int planId, List planItemList); - + List getItemList(Integer planId); } From a35c1193f2bffe845585f05a4dcbac40063c0e40 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 21 Nov 2024 23:20:56 +0800 Subject: [PATCH 09/38] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=80=9A=E9=81=93?= =?UTF-8?q?=E5=85=B3=E8=81=94=E4=BB=A5=E5=8F=8A=E5=BD=95=E5=88=B6=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E6=8E=A5=E5=8F=A3=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gb28181/dao/CommonGBChannelMapper.java | 89 ++++ .../vmp/gb28181/dao/DeviceChannelMapper.java | 5 +- .../service/IDeviceChannelService.java | 2 +- .../impl/DeviceChannelServiceImpl.java | 4 +- .../impl/PlatformChannelServiceImpl.java | 5 + .../iot/vmp/service/IRecordPlanService.java | 11 +- .../service/impl/RecordPlanServiceImpl.java | 49 +- .../vmp/storager/dao/RecordPlanMapper.java | 21 +- .../recordPlan/RecordPlanController.java | 56 +- .../recordPlan/bean/RecordPlanParam.java | 7 +- web_src/src/components/RecordPLan.vue | 157 +++--- .../src/components/dialog/editRecordPlan.vue | 152 ++++-- .../components/dialog/linkChannelRecord.vue | 500 ++++++++++++++++++ 13 files changed, 899 insertions(+), 159 deletions(-) create mode 100755 web_src/src/components/dialog/linkChannelRecord.vue diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java index 99aff973..2f636a4d 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java @@ -459,4 +459,93 @@ public interface CommonGBChannelMapper { @SelectProvider(type = ChannelProvider.class, method = "queryList") List queryList(@Param("query") String query, @Param("online") Boolean online, @Param("hasRecordPlan") Boolean hasRecordPlan, @Param("channelType") Integer channelType); + + @Update(value = {" "}) + void removeRecordPlan(List channelIds); + + @Update(value = {" "}) + void addRecordPlan(List channelIds, @Param("planId") Integer planId); + + @Update(value = {" "}) + void addRecordPlanForAll(@Param("planId") Integer planId); + + @Update(value = {" "}) + void removeRecordPlanByPlanId( @Param("planId") Integer planId); + + + @Select("") + List queryForRecordPlanForWebList(@Param("planId") Integer planId, @Param("query") String query, + @Param("channelType") Integer channelType, @Param("online") Boolean online, + @Param("hasLink") Boolean hasLink); } 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 75131ca6..13f1976a 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 @@ -93,8 +93,9 @@ public interface DeviceChannelMapper { @SelectProvider(type = DeviceChannelProvider.class, method = "queryChannelsByDeviceDbId") List queryChannelsByDeviceDbId(@Param("deviceDbId") int deviceDbId); - @Select("select id from wvp_device_channel where device_db_id = #{deviceDbId}") - List queryChaneIdListByDeviceDbId(@Param("deviceDbId") int deviceDbId); + @Select("select id from wvp_device_channel where device_db_id in " + + " #{item} ") + List queryChaneIdListByDeviceDbIds(List deviceDbIds); @Delete("DELETE FROM wvp_device_channel WHERE device_db_id=#{deviceId}") int cleanChannelsByDeviceId(@Param("deviceId") int deviceId); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java index 4f0ee8e1..bb21e321 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java @@ -124,5 +124,5 @@ public interface IDeviceChannelService { List queryChaneListByDeviceDbId(Integer deviceDbId); - List queryChaneIdListByDeviceDbId(Integer deviceDbId); + List queryChaneIdListByDeviceDbIds(List deviceDbId); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java index 8fecc7f4..c18510c3 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java @@ -354,8 +354,8 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { } @Override - public List queryChaneIdListByDeviceDbId(Integer deviceDbId) { - return channelMapper.queryChaneIdListByDeviceDbId(deviceDbId); + public List queryChaneIdListByDeviceDbIds(List deviceDbIds) { + return channelMapper.queryChaneIdListByDeviceDbIds(deviceDbIds); } @Override diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java index 62125e7c..6b51054b 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java @@ -52,6 +52,11 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService { @Override public PageInfo queryChannelList(int page, int count, String query, Integer channelType, Boolean online, Integer platformId, Boolean hasShare) { PageHelper.startPage(page, count); + if (query != null) { + query = query.replaceAll("/", "//") + .replaceAll("%", "/%") + .replaceAll("_", "/_"); + } List all = platformChannelMapper.queryForPlatformForWebList(platformId, query, channelType, online, hasShare); return new PageInfo<>(all); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/IRecordPlanService.java b/src/main/java/com/genersoft/iot/vmp/service/IRecordPlanService.java index 641ddb18..359e0072 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IRecordPlanService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IRecordPlanService.java @@ -1,7 +1,8 @@ package com.genersoft.iot.vmp.service; +import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; +import com.genersoft.iot.vmp.gb28181.bean.PlatformChannel; import com.genersoft.iot.vmp.service.bean.RecordPlan; -import com.genersoft.iot.vmp.service.bean.RecordPlanItem; import com.github.pagehelper.PageInfo; import java.util.List; @@ -19,5 +20,11 @@ public interface IRecordPlanService { void add(RecordPlan plan); - void linke(List channelIds, Integer planId); + void link(List channelIds, Integer planId); + + PageInfo queryChannelList(int page, int count, String query, Integer channelType, Boolean online, Integer planId, Boolean hasLink); + + void linkAll(Integer planId); + + void cleanAll(Integer planId); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java index aa6d922d..f8f7e9c3 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java @@ -1,6 +1,8 @@ package com.genersoft.iot.vmp.service.impl; +import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; +import com.genersoft.iot.vmp.gb28181.bean.PlatformChannel; import com.genersoft.iot.vmp.gb28181.dao.CommonGBChannelMapper; import com.genersoft.iot.vmp.service.IRecordPlanService; import com.genersoft.iot.vmp.service.bean.CloudRecordItem; @@ -8,6 +10,7 @@ import com.genersoft.iot.vmp.service.bean.RecordPlan; import com.genersoft.iot.vmp.service.bean.RecordPlanItem; import com.genersoft.iot.vmp.storager.dao.RecordPlanMapper; import com.genersoft.iot.vmp.utils.DateUtil; +import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import lombok.extern.slf4j.Slf4j; @@ -33,9 +36,13 @@ public class RecordPlanServiceImpl implements IRecordPlanService { plan.setCreateTime(DateUtil.getNow()); plan.setUpdateTime(DateUtil.getNow()); recordPlanMapper.add(plan); - if (plan.getId() > 0) { + if (plan.getId() > 0 && !plan.getPlanItemList().isEmpty()) { + for (RecordPlanItem recordPlanItem : plan.getPlanItemList()) { + recordPlanItem.setPlanId(plan.getId()); + } recordPlanMapper.batchAddItem(plan.getId(), plan.getPlanItemList()); } + // TODO 更新录像队列 } @Override @@ -52,14 +59,30 @@ public class RecordPlanServiceImpl implements IRecordPlanService { } @Override + @Transactional public void update(RecordPlan plan) { plan.setUpdateTime(DateUtil.getNow()); recordPlanMapper.update(plan); + recordPlanMapper.cleanItems(plan.getId()); + if (plan.getPlanItemList() != null){ + recordPlanMapper.batchAddItem(plan.getId(), plan.getPlanItemList()); + } + // TODO 更新录像队列 + } @Override + @Transactional public void delete(Integer planId) { + RecordPlan recordPlan = recordPlanMapper.get(planId); + if (recordPlan == null) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "录制计划不存在"); + } + // 清理关联的通道 + channelMapper.removeRecordPlanByPlanId(recordPlan.getId()); + recordPlanMapper.cleanItems(planId); recordPlanMapper.delete(planId); + // TODO 更新录像队列 } @Override @@ -75,13 +98,35 @@ public class RecordPlanServiceImpl implements IRecordPlanService { } @Override - public void linke(List channelIds, Integer planId) { + public void link(List channelIds, Integer planId) { if (planId == null) { log.info("[录制计划] 移除通道关联的计划"); channelMapper.removeRecordPlan(channelIds); }else { channelMapper.addRecordPlan(channelIds, planId); } + // TODO 更新录像队列 + } + @Override + public PageInfo queryChannelList(int page, int count, String query, Integer channelType, Boolean online, Integer planId, Boolean hasLink) { + PageHelper.startPage(page, count); + if (query != null) { + query = query.replaceAll("/", "//") + .replaceAll("%", "/%") + .replaceAll("_", "/_"); + } + List all = channelMapper.queryForRecordPlanForWebList(planId, query, channelType, online, hasLink); + return new PageInfo<>(all); + } + + @Override + public void linkAll(Integer planId) { + channelMapper.addRecordPlanForAll(planId); + } + + @Override + public void cleanAll(Integer planId) { + channelMapper.removeRecordPlanByPlanId(planId); } } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java index 9fb4d588..705e59aa 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java @@ -10,7 +10,7 @@ import java.util.List; public interface RecordPlanMapper { @Insert(" ") void batchAddItem(@Param("planId") int planId, List planItemList); @@ -42,7 +41,8 @@ public interface RecordPlanMapper { RecordPlan get(@Param("planId") Integer planId); @Select(" ") List query(@Param("query") String query); @@ -50,9 +50,12 @@ public interface RecordPlanMapper { @Update("UPDATE wvp_record_plan SET update_time=#{updateTime}, name=#{name}, snap=#{snap} WHERE id=#{id}") void update(RecordPlan plan); - @Delete("DELETE FROM wvp_record_plan WHERE id=#{id}") + @Delete("DELETE FROM wvp_record_plan WHERE id=#{planId}") void delete(@Param("planId") Integer planId); + @Select("select * from wvp_record_plan_item where plan_id = #{planId}") + List getItemList(@Param("planId") Integer planId); - List getItemList(Integer planId); + @Delete("DELETE FROM wvp_record_plan_item WHERE plan_id = #{planId}") + void cleanItems(@Param("planId") Integer planId); } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/RecordPlanController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/RecordPlanController.java index 6f3fdfa3..3675acbb 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/RecordPlanController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/RecordPlanController.java @@ -2,6 +2,8 @@ package com.genersoft.iot.vmp.vmanager.recordPlan; import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.conf.security.JwtUtils; +import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; +import com.genersoft.iot.vmp.gb28181.bean.PlatformChannel; import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService; import com.genersoft.iot.vmp.service.IRecordPlanService; import com.genersoft.iot.vmp.service.bean.RecordPlan; @@ -15,6 +17,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ObjectUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.Assert; import org.springframework.web.bind.annotation.*; import java.util.ArrayList; @@ -45,23 +48,31 @@ public class RecordPlanController { } @ResponseBody - @PostMapping("/linke") + @PostMapping("/link") @Operation(summary = "通道关联录制计划", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Parameter(name = "param", description = "通道关联录制计划", required = false) - public void linke(@RequestBody RecordPlanParam param) { - if (param.getChannelId() == null && param.getDeviceDbId() == null) { + public void link(@RequestBody RecordPlanParam param) { + if (param.getChannelIds() == null && param.getDeviceDbIds() == null) { throw new ControllerException(ErrorCode.ERROR100.getCode(), "通道ID和国标设备ID不可都为NULL"); } + if (param.getAll() != null) { + if (param.getAll()) { + recordPlanService.linkAll(param.getPlanId()); + }else { + recordPlanService.cleanAll(param.getPlanId()); + } + return; + } List channelIds = new ArrayList<>(); - if (param.getChannelId() != null) { - channelIds.add(param.getChannelId()); + if (param.getChannelIds() != null) { + channelIds.addAll(param.getChannelIds()); }else { - List chanelIdList = deviceChannelService.queryChaneIdListByDeviceDbId(param.getDeviceDbId()); + List chanelIdList = deviceChannelService.queryChaneIdListByDeviceDbIds(param.getDeviceDbIds()); if (chanelIdList == null || chanelIdList.isEmpty()) { channelIds = chanelIdList; } } - recordPlanService.linke(channelIds, param.getPlanId()); + recordPlanService.link(channelIds, param.getPlanId()); } @ResponseBody @@ -88,11 +99,36 @@ public class RecordPlanController { return recordPlanService.query(page, count, query); } + @Operation(summary = "分页查询级联平台的所有所有通道", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Parameter(name = "page", description = "当前页", required = true) + @Parameter(name = "count", description = "每页条数", required = true) + @Parameter(name = "planId", description = "录制计划ID") + @Parameter(name = "channelType", description = "通道类型, 0:国标设备,1:推流设备,2:拉流代理") + @Parameter(name = "query", description = "查询内容") + @Parameter(name = "online", description = "是否在线") + @Parameter(name = "hasLink", description = "是否已经关联") + @GetMapping("/channel/list") @ResponseBody - @PostMapping("/edit") - @Operation(summary = "编辑录制计划", security = @SecurityRequirement(name = JwtUtils.HEADER)) + public PageInfo queryChannelList(int page, int count, + @RequestParam(required = false) Integer planId, + @RequestParam(required = false) String query, + @RequestParam(required = false) Integer channelType, + @RequestParam(required = false) Boolean online, + @RequestParam(required = false) Boolean hasLink) { + + Assert.notNull(planId, "录制计划ID不可为NULL"); + if (org.springframework.util.ObjectUtils.isEmpty(query)) { + query = null; + } + + return recordPlanService.queryChannelList(page, count, query, channelType, online, planId, hasLink); + } + + @ResponseBody + @PostMapping("/update") + @Operation(summary = "更新录制计划", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Parameter(name = "plan", description = "计划", required = true) - public void edit(@RequestBody RecordPlan plan) { + public void update(@RequestBody RecordPlan plan) { if (plan == null || plan.getId() == 0) { throw new ControllerException(ErrorCode.ERROR400); } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/bean/RecordPlanParam.java b/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/bean/RecordPlanParam.java index 11cc1a0a..e7431409 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/bean/RecordPlanParam.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/bean/RecordPlanParam.java @@ -12,10 +12,13 @@ import java.util.List; public class RecordPlanParam { @Schema(description = "关联的通道ID") - private Integer channelId; + private List channelIds; @Schema(description = "关联的设备ID,会为设备下的所有通道关联此录制计划,channelId存在是此项不生效,") - private Integer deviceDbId; + private List deviceDbIds; + + @Schema(description = "全部关联/全部取消关联") + private Boolean all; @Schema(description = "录制计划ID, ID为空是删除关联的计划") private Integer planId; diff --git a/web_src/src/components/RecordPLan.vue b/web_src/src/components/RecordPLan.vue index bba30ea4..4e649fa5 100755 --- a/web_src/src/components/RecordPLan.vue +++ b/web_src/src/components/RecordPLan.vue @@ -9,82 +9,30 @@ 搜索: - - 在线状态: - - - - - - 录制计划: - - - - - - 类型: - - - - - - - 按国标设备添加 + 添加 - - 按国标设备移除 - - +
- - + - + - + - - + + + - - - - - - - - - @@ -99,37 +47,31 @@ :total="total"> + diff --git a/web_src/src/components/dialog/editRecordPlan.vue b/web_src/src/components/dialog/editRecordPlan.vue index 7f12794f..3772c490 100644 --- a/web_src/src/components/dialog/editRecordPlan.vue +++ b/web_src/src/components/dialog/editRecordPlan.vue @@ -10,8 +10,13 @@ @close="close()" >
- + + + + + +
保存 @@ -38,67 +43,111 @@ export default { return { options: [], loading: false, + edit: false, + planName: null, + id: null, showDialog: false, - channel: "", - deviceDbId: "", endCallback: "", byteTime: "", - planList: [], }; }, methods: { - openDialog: function (channel, deviceDbId, endCallback) { - this.channel = channel; - this.deviceDbId = deviceDbId; + openDialog: function (recordPlan, endCallback) { + console.log(recordPlan); this.endCallback = endCallback; this.showDialog = true; this.byteTime= ""; - if (channel.recordPlanId) { - // 请求plan信息 + if (recordPlan) { + this.edit = true + this.planName = recordPlan.name + this.id = recordPlan.id + this.$axios({ + method: 'get', + url: "/api/record/plan/get", + params: { + planId: recordPlan.id, + } + }).then((res) => { + if (res.data.code === 0) { + this.byteTime = this.plan2Byte(res.data.data.planItemList) + } + }).catch((error) => { + console.error(error) + }); } }, onSubmit: function () { let planList = this.byteTime2PlanList(); - console.log(planList) - this.$axios({ - method: 'post', - url: "/api/record/plan/add", - params: { - channelId: this.channel?this.channel.id:null, - deviceDbId: this.deviceDbId, - planList: planList - } - }).then((res) => { - if (res.data.code === 0) { - this.$message({ - showClose: true, - message: '添加成功', - type: 'success', - }); - this.showDialog = false; - this.endCallback() - } else { - this.$message({ - showClose: true, - message: res.data.msg, - type: 'error' - }); - } - }).catch((error) => { - console.error(error) - }); + if (!this.edit) { + this.$axios({ + method: 'post', + url: "/api/record/plan/add", + data: { + name: this.planName, + planItemList: planList + } + }).then((res) => { + if (res.data.code === 0) { + this.$message({ + showClose: true, + message: '添加成功', + type: 'success', + }); + this.showDialog = false; + this.endCallback() + } else { + this.$message({ + showClose: true, + message: res.data.msg, + type: 'error' + }); + } + }).catch((error) => { + console.error(error) + }); + }else { + this.$axios({ + method: 'post', + url: "/api/record/plan/update", + data: { + id: this.id, + name: this.planName, + planItemList: planList + } + }).then((res) => { + if (res.data.code === 0) { + this.$message({ + showClose: true, + message: '更新成功', + type: 'success', + }); + this.showDialog = false; + this.endCallback() + } else { + this.$message({ + showClose: true, + message: res.data.msg, + type: 'error' + }); + } + }).catch((error) => { + console.error(error) + }); + } + }, close: function () { - this.channel = ""; - this.deviceDbId = ""; this.showDialog = false; + this.id = null + this.planName = null + this.byteTime = "" + this.endCallback = "" if(this.endCallback) { this.endCallback(); } }, byteTime2PlanList() { - this.planList = [] if (this.byteTime.length === 0) { return; } @@ -114,8 +163,8 @@ export default { continue } for (let j = 0; j < planArray.length; j++) { - console.log(planArray[j]) planList.push({ + id: this.id, startTime: planArray[j].startTime, stopTime: planArray[j].stopTime, weekDay: week @@ -149,6 +198,27 @@ export default { } } return result; + }, + plan2Byte(planList) { + console.log(planList); + let byte = "" + let indexArray = {} + for (let i = 0; i < planList.length; i++) { + let index = planList[i].startTime/1000/60/30 + let endIndex = planList[i].stopTime/1000/60/30 + for (let j = index; j <= endIndex; j++) { + indexArray[j + (planList[i].weekDay - 1 )*48] = j + i*48 + } + } + console.log(indexArray) + for (let i = 0; i < 336; i++) { + if (indexArray[i]){ + byte += "1" + }else { + byte += "0" + } + } + return byte } }, }; diff --git a/web_src/src/components/dialog/linkChannelRecord.vue b/web_src/src/components/dialog/linkChannelRecord.vue new file mode 100755 index 00000000..173b5008 --- /dev/null +++ b/web_src/src/components/dialog/linkChannelRecord.vue @@ -0,0 +1,500 @@ + + + + + From c2ad767d89505695912af352657d5c88e480459f Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Sat, 23 Nov 2024 14:51:13 +0800 Subject: [PATCH 10/38] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/dialog/linkChannelRecord.vue | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/web_src/src/components/dialog/linkChannelRecord.vue b/web_src/src/components/dialog/linkChannelRecord.vue index 173b5008..6f2a299a 100755 --- a/web_src/src/components/dialog/linkChannelRecord.vue +++ b/web_src/src/components/dialog/linkChannelRecord.vue @@ -1,6 +1,6 @@ - - +
+
+ 未找到通道,可在国标设备/通道中选择编辑按钮, 选择{{dataType === 'civilCode'?'行政区划':'父节点编码'}} +
+ + +
+
diff --git a/web_src/src/components/dialog/groupEdit.vue b/web_src/src/components/dialog/groupEdit.vue index 72795cb4..1c77bc84 100755 --- a/web_src/src/components/dialog/groupEdit.vue +++ b/web_src/src/components/dialog/groupEdit.vue @@ -22,7 +22,7 @@
- 生成 + 选择 @@ -37,17 +37,17 @@
- + "}) int update(Device device); @@ -207,9 +210,43 @@ public interface DeviceMapper { "as_message_channel,"+ "broadcast_push_after_ack,"+ "geo_coord_sys,"+ + "server_id,"+ "on_line"+ " FROM wvp_device WHERE on_line = true") List getOnlineDevices(); + @Select("SELECT " + + "id, " + + "device_id, " + + "coalesce(custom_name, name) as name, " + + "password, " + + "manufacturer, " + + "model, " + + "firmware, " + + "transport," + + "stream_mode," + + "ip," + + "sdp_ip,"+ + "local_ip,"+ + "port,"+ + "host_address,"+ + "expires,"+ + "register_time,"+ + "keepalive_time,"+ + "create_time,"+ + "update_time,"+ + "charset,"+ + "subscribe_cycle_for_catalog,"+ + "subscribe_cycle_for_mobile_position,"+ + "mobile_position_submission_interval,"+ + "subscribe_cycle_for_alarm,"+ + "ssrc_check,"+ + "as_message_channel,"+ + "broadcast_push_after_ack,"+ + "geo_coord_sys,"+ + "server_id,"+ + "on_line"+ + " FROM wvp_device WHERE on_line = true and server_id = #{serverId}") + List getOnlineDevicesByServerId(@Param("serverId") String serverId); @Select("SELECT " + "id,"+ @@ -269,6 +306,7 @@ public interface DeviceMapper { "geo_coord_sys,"+ "on_line,"+ "stream_mode," + + "server_id," + "media_server_id"+ ") VALUES (" + "#{deviceId}," + @@ -284,6 +322,7 @@ public interface DeviceMapper { "#{geoCoordSys}," + "#{onLine}," + "#{streamMode}," + + "#{serverId}," + "#{mediaServerId}" + ")") void addCustomDevice(Device device); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceService.java index 0812f8cf..a8f48a47 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceService.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceService.java @@ -86,7 +86,7 @@ public interface IDeviceService { * 获取所有在线设备 * @return 设备列表 */ - List getAllOnlineDevice(); + List getAllOnlineDevice(String serverId); List getAllByStatus(Boolean status); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceServiceImpl.java index c3ede305..4773b9fd 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceServiceImpl.java @@ -353,8 +353,8 @@ public class DeviceServiceImpl implements IDeviceService { } @Override - public List getAllOnlineDevice() { - return deviceMapper.getOnlineDevices(); + public List getAllOnlineDevice(String serverId) { + return deviceMapper.getOnlineDevicesByServerId(serverId); } @Override diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/task/SipRunner.java b/src/main/java/com/genersoft/iot/vmp/gb28181/task/SipRunner.java index 102f9d0c..56a649bc 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/task/SipRunner.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/task/SipRunner.java @@ -1,5 +1,6 @@ package com.genersoft.iot.vmp.gb28181.task; +import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.Platform; @@ -60,9 +61,12 @@ public class SipRunner implements CommandLineRunner { @Autowired private ISendRtpServerService sendRtpServerService; + @Autowired + private UserSetting userSetting; + @Override public void run(String... args) throws Exception { - List deviceList = deviceService.getAllOnlineDevice(); + List deviceList = deviceService.getAllOnlineDevice(userSetting.getServerId()); for (Device device : deviceList) { if (deviceService.expire(device)){ @@ -86,7 +90,8 @@ public class SipRunner implements CommandLineRunner { deviceMapInDb.put(device.getDeviceId(), device); }); devicesInRedis.parallelStream().forEach(device -> { - if (deviceMapInDb.get(device.getDeviceId()) == null) { + if (deviceMapInDb.get(device.getDeviceId()) == null + && userSetting.getServerId().equals(device.getServerId())) { redisCatchStorage.removeDevice(device.getDeviceId()); } }); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java index 44a3eb1e..8ad37f1e 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java @@ -183,7 +183,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen device.setGeoCoordSys("WGS84"); } } - + device.setServerId(userSetting.getServerId()); device.setIp(remoteAddressInfo.getIp()); device.setPort(remoteAddressInfo.getPort()); device.setHostAddress(remoteAddressInfo.getIp().concat(":").concat(String.valueOf(remoteAddressInfo.getPort()))); From 6258bf69692407fa484160cff5826bdcd4546900 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 11 Dec 2024 11:43:41 +0800 Subject: [PATCH 23/38] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=AD=90=E7=A0=81=E6=B5=81=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java | 4 ++++ .../vmp/gb28181/service/impl/DeviceChannelServiceImpl.java | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) 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 99bb6e36..068eb4b7 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 @@ -413,6 +413,10 @@ public interface DeviceChannelMapper { "") void updateChannelStreamIdentification(DeviceChannel channel); + @Update("") + void updateAllChannelStreamIdentification(@Param("streamIdentification") String streamIdentification); @Update({""}) @@ -138,32 +141,27 @@ public interface MediaServerMapper { ", type=#{type}" + ", transcode_suffix=#{transcodeSuffix}" + ", hook_alive_interval=#{hookAliveInterval}" + + ", server_id=#{serverId}" + "WHERE ip=#{ip} and http_port=#{httpPort}"+ " "}) int updateByHostAndPort(MediaServer mediaServerItem); - @Select("SELECT * FROM wvp_media_server WHERE id=#{id}") - MediaServer queryOne(String id); + @Select("SELECT * FROM wvp_media_server WHERE id=#{id} and server_id = #{serverId}") + MediaServer queryOne(@Param("id") String id, @Param("serverId") String serverId); - @Select("SELECT * FROM wvp_media_server") - List queryAll(); + @Select("SELECT * FROM wvp_media_server where server_id = #{serverId}") + List queryAll(@Param("serverId") String serverId); - @Delete("DELETE FROM wvp_media_server WHERE id=#{id}") - void delOne(String id); + @Delete("DELETE FROM wvp_media_server WHERE id=#{id} and server_id = #{serverId}") + void delOne(String id, @Param("serverId") String serverId); - @Select("DELETE FROM wvp_media_server WHERE ip=#{host} and http_port=#{port}") - void delOneByIPAndPort(@Param("host") String host, @Param("port") int port); + @Select("SELECT * FROM wvp_media_server WHERE ip=#{host} and http_port=#{port} and server_id = #{serverId}") + MediaServer queryOneByHostAndPort(@Param("host") String host, @Param("port") int port, @Param("serverId") String serverId); - @Delete("DELETE FROM wvp_media_server WHERE default_server=true") - int delDefault(); + @Select("SELECT * FROM wvp_media_server WHERE default_server=true and server_id = #{serverId}") + MediaServer queryDefault(@Param("serverId") String serverId); - @Select("SELECT * FROM wvp_media_server WHERE ip=#{host} and http_port=#{port}") - MediaServer queryOneByHostAndPort(@Param("host") String host, @Param("port") int port); - - @Select("SELECT * FROM wvp_media_server WHERE default_server=true") - MediaServer queryDefault(); - - @Select("SELECT * FROM wvp_media_server WHERE record_assist_port > 0") - List queryAllWithAssistPort(); + @Select("SELECT * FROM wvp_media_server WHERE record_assist_port > 0 and server_id = #{serverId}") + List queryAllWithAssistPort(@Param("serverId") String serverId); } diff --git a/数据库/2.7.3/初始化-mysql-2.7.3.sql b/数据库/2.7.3/初始化-mysql-2.7.3.sql index e12677da..5ffb722c 100644 --- a/数据库/2.7.3/初始化-mysql-2.7.3.sql +++ b/数据库/2.7.3/初始化-mysql-2.7.3.sql @@ -29,6 +29,7 @@ create table wvp_device custom_name character varying(255), sdp_ip character varying(50), local_ip character varying(50), + server_id character varying(50), password character varying(255), as_message_channel bool default false, keepalive_interval_time integer, @@ -190,6 +191,7 @@ create table wvp_media_server record_path character varying(255), record_day integer default 7, transcode_suffix character varying(255), + server_id character varying(50), constraint uk_media_server_unique_ip_http_port unique (ip, http_port) ); diff --git a/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql b/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql index c632f9a8..9789b463 100644 --- a/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql +++ b/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql @@ -29,6 +29,7 @@ create table wvp_device custom_name character varying(255), sdp_ip character varying(50), local_ip character varying(50), + server_id character varying(50), password character varying(255), as_message_channel bool default false, keepalive_interval_time integer, @@ -207,6 +208,7 @@ create table wvp_media_server record_path character varying(255), record_day integer default 7, transcode_suffix character varying(255), + server_id character varying(50), constraint uk_media_server_unique_ip_http_port unique (ip, http_port) ); From 8372bfec6884b4078721b8239d7d67e381d28f69 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 12 Dec 2024 09:29:49 +0800 Subject: [PATCH 28/38] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AA=92=E4=BD=93?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E8=A1=A8=E6=95=B0=E6=8D=AE=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 数据库/2.7.3/初始化-mysql-2.7.3.sql | 2 +- 数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/数据库/2.7.3/初始化-mysql-2.7.3.sql b/数据库/2.7.3/初始化-mysql-2.7.3.sql index 5ffb722c..f294e62e 100644 --- a/数据库/2.7.3/初始化-mysql-2.7.3.sql +++ b/数据库/2.7.3/初始化-mysql-2.7.3.sql @@ -192,7 +192,7 @@ create table wvp_media_server record_day integer default 7, transcode_suffix character varying(255), server_id character varying(50), - constraint uk_media_server_unique_ip_http_port unique (ip, http_port) + constraint uk_media_server_unique_ip_http_port unique (ip, http_port, server_id) ); create table wvp_platform diff --git a/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql b/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql index 9789b463..67fb1445 100644 --- a/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql +++ b/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql @@ -209,7 +209,7 @@ create table wvp_media_server record_day integer default 7, transcode_suffix character varying(255), server_id character varying(50), - constraint uk_media_server_unique_ip_http_port unique (ip, http_port) + constraint uk_media_server_unique_ip_http_port unique (ip, http_port, server_id) ); create table wvp_platform From c4025d7a073bf0a47ec8680ef0916159011345ce Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 12 Dec 2024 09:37:12 +0800 Subject: [PATCH 29/38] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=80=9A=E7=94=A8?= =?UTF-8?q?=E7=82=B9=E6=92=ADRPC=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RedisRpcChannelPlayController.java | 101 ++++++++++++++++++ .../service/RedisRpcPlayServiceImpl.java | 2 +- 数据库/2.7.3/初始化-mysql-2.7.3.sql | 1 + .../2.7.3/初始化-postgresql-kingbase-2.7.3.sql | 1 + 4 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcChannelPlayController.java diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcChannelPlayController.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcChannelPlayController.java new file mode 100644 index 00000000..adeda445 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcChannelPlayController.java @@ -0,0 +1,101 @@ +package com.genersoft.iot.vmp.service.redisMsg.control; + +import com.alibaba.fastjson2.JSONObject; +import com.genersoft.iot.vmp.common.StreamInfo; +import com.genersoft.iot.vmp.conf.UserSetting; +import com.genersoft.iot.vmp.conf.redis.RedisRpcConfig; +import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcMessage; +import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcRequest; +import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcResponse; +import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; +import com.genersoft.iot.vmp.gb28181.bean.SendRtpInfo; +import com.genersoft.iot.vmp.gb28181.service.IGbChannelPlayService; +import com.genersoft.iot.vmp.gb28181.service.IGbChannelService; +import com.genersoft.iot.vmp.gb28181.session.SSRCFactory; +import com.genersoft.iot.vmp.media.bean.MediaServer; +import com.genersoft.iot.vmp.media.event.hook.Hook; +import com.genersoft.iot.vmp.media.event.hook.HookSubscribe; +import com.genersoft.iot.vmp.media.event.hook.HookType; +import com.genersoft.iot.vmp.media.service.IMediaServerService; +import com.genersoft.iot.vmp.service.ISendRtpServerService; +import com.genersoft.iot.vmp.service.bean.InviteErrorCode; +import com.genersoft.iot.vmp.service.redisMsg.dto.RedisRpcController; +import com.genersoft.iot.vmp.service.redisMsg.dto.RedisRpcMapping; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; + +import javax.sip.message.Response; + +@Slf4j +@RedisRpcController("chanel") +public class RedisRpcChannelPlayController { + + @Autowired + private SSRCFactory ssrcFactory; + + @Autowired + private IMediaServerService mediaServerService; + + @Autowired + private ISendRtpServerService sendRtpServerService; + + @Autowired + private UserSetting userSetting; + + @Autowired + private HookSubscribe hookSubscribe; + + @Autowired + private RedisTemplate redisTemplate; + + @Autowired + private IGbChannelService channelService; + + @Autowired + private IGbChannelPlayService channelPlayService; + + private void sendResponse(RedisRpcResponse response){ + log.info("[redis-rpc] >> {}", response); + response.setToId(userSetting.getServerId()); + RedisRpcMessage message = new RedisRpcMessage(); + message.setResponse(response); + redisTemplate.convertAndSend(RedisRpcConfig.REDIS_REQUEST_CHANNEL_KEY, message); + } + + + /** + * 点播国标设备 + */ + @RedisRpcMapping("play") + public RedisRpcResponse playChannel(RedisRpcRequest request) { + int channelId = Integer.parseInt(request.getParam().toString()); + RedisRpcResponse response = request.getResponse(); + + if (channelId <= 0) { + response.setStatusCode(Response.BAD_REQUEST); + response.setBody("param error"); + return response; + } + // 获取对应的设备和通道信息 + CommonGBChannel channel = channelService.getOne(channelId); + if (channel == null) { + response.setStatusCode(Response.BAD_REQUEST); + response.setBody("param error"); + return response; + } + + channelPlayService.play(channel, null, (code, msg, data) ->{ + if (code == InviteErrorCode.SUCCESS.getCode()) { + response.setStatusCode(Response.OK); + response.setBody(data); + }else { + response.setStatusCode(code); + } + // 手动发送结果 + sendResponse(response); + }); + return null; + } + +} diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/service/RedisRpcPlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/service/RedisRpcPlayServiceImpl.java index 93f218a6..0e1c0b1e 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/service/RedisRpcPlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/service/RedisRpcPlayServiceImpl.java @@ -37,7 +37,7 @@ public class RedisRpcPlayServiceImpl implements IRedisRpcPlayService { @Override public void play(String serverId, Integer channelId, ErrorCallback callback) { - RedisRpcRequest request = buildRequest("playChannel", channelId); + RedisRpcRequest request = buildRequest("channel/play", channelId); request.setToId(serverId); RedisRpcResponse response = redisRpcConfig.request(request, userSetting.getPlayTimeout()); if (response == null) { diff --git a/数据库/2.7.3/初始化-mysql-2.7.3.sql b/数据库/2.7.3/初始化-mysql-2.7.3.sql index f294e62e..81658c3d 100644 --- a/数据库/2.7.3/初始化-mysql-2.7.3.sql +++ b/数据库/2.7.3/初始化-mysql-2.7.3.sql @@ -34,6 +34,7 @@ create table wvp_device as_message_channel bool default false, keepalive_interval_time integer, broadcast_push_after_ack bool default false, + server_id character varying(50), constraint uk_device_device unique (device_id) ); diff --git a/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql b/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql index 67fb1445..d7c4c1f0 100644 --- a/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql +++ b/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql @@ -34,6 +34,7 @@ create table wvp_device as_message_channel bool default false, keepalive_interval_time integer, broadcast_push_after_ack bool default false, + server_id character varying(50), constraint uk_device_device unique (device_id) ); From 1c2709163d97833276c56e2403c0168ef3df2a05 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 12 Dec 2024 09:43:24 +0800 Subject: [PATCH 30/38] =?UTF-8?q?=E4=BF=AE=E6=94=B9RedisRpcChannelPlayCont?= =?UTF-8?q?roller=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../control/RedisRpcChannelPlayController.java | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcChannelPlayController.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcChannelPlayController.java index adeda445..d6f3a5af 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcChannelPlayController.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcChannelPlayController.java @@ -28,24 +28,12 @@ import org.springframework.data.redis.core.RedisTemplate; import javax.sip.message.Response; @Slf4j -@RedisRpcController("chanel") +@RedisRpcController("channel") public class RedisRpcChannelPlayController { - @Autowired - private SSRCFactory ssrcFactory; - - @Autowired - private IMediaServerService mediaServerService; - - @Autowired - private ISendRtpServerService sendRtpServerService; - @Autowired private UserSetting userSetting; - @Autowired - private HookSubscribe hookSubscribe; - @Autowired private RedisTemplate redisTemplate; From fe341036a8f38f58563b3d6bbc8b2d39827e9acf Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 12 Dec 2024 10:15:04 +0800 Subject: [PATCH 31/38] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=9B=BD=E6=A0=87?= =?UTF-8?q?=E7=BA=A7=E8=81=94=E7=82=B9=E6=92=AD=E5=85=B6=E4=BB=96wvp?= =?UTF-8?q?=E7=9A=84=E5=9B=BD=E6=A0=87=E8=AE=BE=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gb28181/controller/PlayController.java | 11 +------- .../iot/vmp/gb28181/dao/DeviceMapper.java | 1 + .../gb28181/service/impl/PlayServiceImpl.java | 27 ++++++++++-------- web_src/src/components/DeviceList.vue | 28 +++++++++---------- 4 files changed, 32 insertions(+), 35 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlayController.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlayController.java index e5087cba..b99a00bf 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlayController.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlayController.java @@ -21,7 +21,6 @@ import com.genersoft.iot.vmp.media.bean.MediaServer; import com.genersoft.iot.vmp.media.service.IMediaServerService; import com.genersoft.iot.vmp.service.bean.ErrorCallback; import com.genersoft.iot.vmp.service.bean.InviteErrorCode; -import com.genersoft.iot.vmp.service.redisMsg.IRedisRpcPlayService; import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.vmanager.bean.AudioBroadcastResult; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; @@ -66,9 +65,6 @@ public class PlayController { @Autowired private IPlayService playService; - @Autowired - private IRedisRpcPlayService redisRpcPlayService; - @Autowired private IMediaServerService mediaServerService; @@ -153,12 +149,7 @@ public class PlayController { // 此处必须释放所有请求 resultHolder.invokeAllResult(requestMessage); }; - // 判断设备是否属于当前平台, 如果不属于则发起自动调用 - if (userSetting.getServerId().equals(device.getServerId())) { - redisRpcPlayService.play(device.getServerId(), channel.getId(), callback); - }else { - playService.play(device, channel, callback); - } + playService.play(device, channel, callback); return result; } 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 07b18676..b33f906b 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 @@ -365,6 +365,7 @@ public interface DeviceMapper { "geo_coord_sys,"+ "on_line,"+ "media_server_id,"+ + "server_id,"+ "(SELECT count(0) FROM wvp_device_channel dc WHERE dc.device_db_id= de.id) as channel_count " + " FROM wvp_device de" + " where 1 = 1 "+ diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java index 8b3d9f06..e631a6cd 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java @@ -31,6 +31,7 @@ import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo; import com.genersoft.iot.vmp.service.IReceiveRtpServerService; import com.genersoft.iot.vmp.service.ISendRtpServerService; import com.genersoft.iot.vmp.service.bean.*; +import com.genersoft.iot.vmp.service.redisMsg.IRedisRpcPlayService; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.utils.CloudRecordUtils; import com.genersoft.iot.vmp.utils.DateUtil; @@ -123,6 +124,9 @@ public class PlayServiceImpl implements IPlayService { @Autowired private ICloudRecordService cloudRecordService; + @Autowired + private IRedisRpcPlayService redisRpcPlayService; + /** * 流到来的处理 */ @@ -287,12 +291,18 @@ public class PlayServiceImpl implements IPlayService { @Override public void play(Device device, DeviceChannel channel, ErrorCallback callback) { - MediaServer mediaServerItem = getNewMediaServerItem(device); - if (mediaServerItem == null) { - log.warn("[点播] 未找到可用的zlm deviceId: {},channelId:{}", device.getDeviceId(), channel.getDeviceId()); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到可用的zlm"); + + // 判断设备是否属于当前平台, 如果不属于则发起自动调用 + if (userSetting.getServerId().equals(device.getServerId())) { + redisRpcPlayService.play(device.getServerId(), channel.getId(), callback); + }else { + MediaServer mediaServerItem = getNewMediaServerItem(device); + if (mediaServerItem == null) { + log.warn("[点播] 未找到可用的zlm deviceId: {},channelId:{}", device.getDeviceId(), channel.getDeviceId()); + throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到可用的zlm"); + } + play(mediaServerItem, device, channel, null, callback); } - play(mediaServerItem, device, channel, null, callback); } @Override @@ -1660,13 +1670,8 @@ public class PlayServiceImpl implements IPlayService { log.warn("[点播] 未找到通道{}的设备信息", channel); throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error"); } - MediaServer mediaServer = getNewMediaServerItem(device); - if (mediaServer == null) { - log.warn("[点播] 未找到可用媒体节点"); - throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error"); - } DeviceChannel deviceChannel = deviceChannelService.getOneForSourceById(channel.getGbId()); - play(mediaServer, device, deviceChannel, null, callback); + play(device, deviceChannel, callback); } @Override diff --git a/web_src/src/components/DeviceList.vue b/web_src/src/components/DeviceList.vue index 7525def5..f9240f64 100755 --- a/web_src/src/components/DeviceList.vue +++ b/web_src/src/components/DeviceList.vue @@ -15,7 +15,7 @@ 添加设备 - 平台信息 + 平台信息 @@ -53,7 +53,8 @@ @@ -62,11 +63,6 @@ - - - - -