diff --git a/src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java b/src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java index 102e4913..37d5c4bc 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java @@ -2,10 +2,9 @@ package com.genersoft.iot.vmp.conf; import com.genersoft.iot.vmp.gb28181.bean.Platform; import com.genersoft.iot.vmp.gb28181.bean.PlatformCatch; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; import com.genersoft.iot.vmp.gb28181.service.IPlatformService; +import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; @@ -23,9 +22,6 @@ import java.util.List; @Order(value=13) public class SipPlatformRunner implements CommandLineRunner { - @Autowired - private IVideoManagerStorage storager; - @Autowired private IRedisCatchStorage redisCatchStorage; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/DeviceConfig.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/DeviceConfig.java index d485be4a..f6e7ddcb 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/DeviceConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/DeviceConfig.java @@ -11,11 +11,10 @@ import com.alibaba.fastjson2.JSONObject; import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.conf.security.JwtUtils; import com.genersoft.iot.vmp.gb28181.bean.Device; +import com.genersoft.iot.vmp.gb28181.service.IDeviceService; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; -import com.genersoft.iot.vmp.gb28181.service.IDeviceService; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -38,9 +37,6 @@ import java.util.UUID; @RequestMapping("/api/device/config") public class DeviceConfig { - @Autowired - private IVideoManagerStorage storager; - @Autowired private IDeviceService deviceService; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/DeviceQuery.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/DeviceQuery.java index bc084c2c..c3ba87a4 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/DeviceQuery.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/DeviceQuery.java @@ -7,17 +7,15 @@ import com.genersoft.iot.vmp.conf.security.JwtUtils; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.SyncStatus; +import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService; +import com.genersoft.iot.vmp.gb28181.service.IDeviceService; +import com.genersoft.iot.vmp.gb28181.service.IInviteStreamService; import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask; import com.genersoft.iot.vmp.gb28181.task.impl.CatalogSubscribeTask; import com.genersoft.iot.vmp.gb28181.task.impl.MobilePositionSubscribeTask; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; -import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService; -import com.genersoft.iot.vmp.gb28181.service.IDeviceService; -import com.genersoft.iot.vmp.gb28181.service.IInviteStreamService; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import com.github.pagehelper.PageInfo; @@ -57,16 +55,10 @@ import java.util.UUID; @RestController @RequestMapping("/api/device/query") public class DeviceQuery { - - @Autowired - private IVideoManagerStorage storager; @Autowired private IDeviceChannelService deviceChannelService; - @Autowired - private IRedisCatchStorage redisCatchStorage; - @Autowired private IInviteStreamService inviteStreamService; 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 ba16222f..e48ae616 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 @@ -9,13 +9,12 @@ import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.RecordInfo; import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService; +import com.genersoft.iot.vmp.gb28181.service.IDeviceService; +import com.genersoft.iot.vmp.gb28181.service.IPlayService; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; -import com.genersoft.iot.vmp.gb28181.service.IDeviceService; -import com.genersoft.iot.vmp.gb28181.service.IPlayService; import com.genersoft.iot.vmp.service.bean.InviteErrorCode; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import com.genersoft.iot.vmp.vmanager.bean.StreamContent; @@ -47,9 +46,6 @@ public class GBRecordController { @Autowired private SIPCommander cmder; - @Autowired - private IVideoManagerStorage storager; - @Autowired private DeferredResultHolder resultHolder; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/MobilePositionController.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/MobilePositionController.java index 5c10b119..1c3406f8 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/MobilePositionController.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/MobilePositionController.java @@ -4,12 +4,11 @@ import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.conf.security.JwtUtils; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.MobilePosition; +import com.genersoft.iot.vmp.gb28181.service.IDeviceService; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; -import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService; -import com.genersoft.iot.vmp.gb28181.service.IDeviceService; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; +import com.genersoft.iot.vmp.service.IMobilePositionService; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import com.github.pagehelper.util.StringUtil; import io.swagger.v3.oas.annotations.Operation; @@ -37,7 +36,7 @@ import java.util.UUID; public class MobilePositionController { @Autowired - private IVideoManagerStorage storager; + private IMobilePositionService mobilePositionService; @Autowired private SIPCommander cmder; @@ -48,8 +47,6 @@ public class MobilePositionController { @Autowired private IDeviceService deviceService; - @Autowired - private IDeviceChannelService deviceChannelService; /** * 查询历史轨迹 @@ -75,7 +72,7 @@ public class MobilePositionController { if (StringUtil.isEmpty(end)) { end = null; } - return storager.queryMobilePositions(deviceId, channelId, start, end); + return mobilePositionService.queryMobilePositions(deviceId, channelId, start, end); } /** @@ -87,7 +84,7 @@ public class MobilePositionController { @Parameter(name = "deviceId", description = "设备国标编号", required = true) @GetMapping("/latest/{deviceId}") public MobilePosition latestPosition(@PathVariable String deviceId) { - return storager.queryLatestPosition(deviceId); + return mobilePositionService.queryLatestPosition(deviceId); } /** diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlaybackController.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlaybackController.java index d6e2b044..210b022f 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlaybackController.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlaybackController.java @@ -17,7 +17,6 @@ import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; import com.genersoft.iot.vmp.service.bean.InviteErrorCode; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import com.genersoft.iot.vmp.vmanager.bean.StreamContent; import com.genersoft.iot.vmp.vmanager.bean.WVPResult; @@ -54,9 +53,6 @@ public class PlaybackController { @Autowired private SIPCommander cmder; - @Autowired - private IVideoManagerStorage storager; - @Autowired private IInviteStreamService inviteStreamService; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PtzController.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PtzController.java index e83eae33..d2773918 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PtzController.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PtzController.java @@ -4,11 +4,10 @@ package com.genersoft.iot.vmp.gb28181.controller; import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.conf.security.JwtUtils; import com.genersoft.iot.vmp.gb28181.bean.Device; +import com.genersoft.iot.vmp.gb28181.service.IDeviceService; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; -import com.genersoft.iot.vmp.gb28181.service.IDeviceService; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -34,9 +33,6 @@ public class PtzController { @Autowired private SIPCommander cmder; - @Autowired - private IVideoManagerStorage storager; - @Autowired private IDeviceService deviceService; 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 c7cd9b66..d623d79d 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 @@ -353,4 +353,8 @@ public interface DeviceMapper { @Select("select wd.* from wvp_device wd left join wvp_device_channel wdc on wd.id = wdc.device_db_id where wdc.id = #{channelId}") Device queryByChannelId(@Param("channelId") Integer channelId); + + @Select("select wd.* from wvp_device wd left join wvp_device_channel wdc on wd.id = wdc.device_db_id where wdc.device_id = #{channelDeviceId}") + Device getDeviceBySourceChannelDeviceId(@Param("channelDeviceId") String channelDeviceId); + } 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 9aa46a7e..3fbc459a 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 @@ -168,4 +168,6 @@ public interface IDeviceService { Device getDevice(Integer gbDeviceDbId); Device getDeviceByChannelId(Integer channelId); + + Device getDeviceBySourceChannelDeviceId(String requesterId); } 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 6336a6d6..29498692 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 @@ -575,4 +575,9 @@ public class DeviceServiceImpl implements IDeviceService { public Device getDeviceByChannelId(Integer channelId) { return deviceMapper.queryByChannelId(channelId); } + + @Override + public Device getDeviceBySourceChannelDeviceId(String channelId) { + return deviceMapper.getDeviceBySourceChannelDeviceId(channelId); + } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java b/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java index 7aa40026..baa9e2f2 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java @@ -2,7 +2,6 @@ package com.genersoft.iot.vmp.gb28181.session; import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @@ -17,9 +16,6 @@ public class CatalogDataCatch { public static Map data = new ConcurrentHashMap<>(); - @Autowired - private IVideoManagerStorage storager; - @Autowired private IDeviceChannelService deviceChannelService; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java index ba087faa..4bbe4a69 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java @@ -24,7 +24,6 @@ import com.genersoft.iot.vmp.service.ISendRtpServerService; import com.genersoft.iot.vmp.service.bean.InviteErrorCode; import com.genersoft.iot.vmp.service.redisMsg.RedisPushStreamResponseListener; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import gov.nist.javax.sdp.TimeDescriptionImpl; import gov.nist.javax.sdp.fields.TimeField; import gov.nist.javax.sdp.fields.URIField; @@ -63,10 +62,10 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements private ISIPCommanderForPlatform cmderFroPlatform; @Autowired - private IVideoManagerStorage storager; + private IDeviceChannelService deviceChannelService; @Autowired - private IDeviceChannelService deviceChannelService; + private IDeviceService deviceService; @Autowired private IGbChannelService channelService; @@ -423,11 +422,11 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements Device device = redisCatchStorage.getDevice(inviteInfo.getRequesterId()); // 判断requesterId是设备还是通道 if (device == null) { - device = storager.queryVideoDeviceByChannelId(inviteInfo.getRequesterId()); + device = deviceService.getDeviceBySourceChannelDeviceId(inviteInfo.getRequesterId()); } if (device == null) { // 检查channelID是否可用 - device = storager.queryVideoDeviceByChannelId(inviteInfo.getSourceChannelId()); + device = deviceService.getDeviceBySourceChannelDeviceId(inviteInfo.getSourceChannelId()); } if (device == null) { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java index ca05fe30..730e8c0f 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java @@ -4,14 +4,13 @@ import com.genersoft.iot.vmp.gb28181.bean.CmdType; import com.genersoft.iot.vmp.gb28181.bean.Platform; import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder; import com.genersoft.iot.vmp.gb28181.bean.SubscribeInfo; +import com.genersoft.iot.vmp.gb28181.service.IPlatformService; import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; import com.genersoft.iot.vmp.gb28181.transmit.SIPSender; import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor; import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; import com.genersoft.iot.vmp.gb28181.utils.SipUtils; import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; -import com.genersoft.iot.vmp.gb28181.service.IPlatformService; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import gov.nist.javax.sip.message.SIPRequest; import gov.nist.javax.sip.message.SIPResponse; import lombok.extern.slf4j.Slf4j; @@ -41,9 +40,6 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme @Autowired private SIPProcessorObserver sipProcessorObserver; - @Autowired - private IVideoManagerStorage storager; - @Autowired private SubscribeHolder subscribeHolder; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MobilePositionNotifyMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MobilePositionNotifyMessageHandler.java index f71fc353..f8bb5570 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MobilePositionNotifyMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MobilePositionNotifyMessageHandler.java @@ -1,16 +1,12 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.cmd; -import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.bean.*; -import com.genersoft.iot.vmp.gb28181.event.EventPublisher; +import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService; import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.NotifyMessageHandler; import com.genersoft.iot.vmp.gb28181.utils.NumericUtil; import com.genersoft.iot.vmp.gb28181.utils.SipUtils; -import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.utils.DateUtil; import gov.nist.javax.sip.message.SIPRequest; import lombok.extern.slf4j.Slf4j; @@ -44,21 +40,9 @@ public class MobilePositionNotifyMessageHandler extends SIPRequestProcessorParen @Autowired private NotifyMessageHandler notifyMessageHandler; - @Autowired - private UserSetting userSetting; - - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private IRedisCatchStorage redisCatchStorage; - @Autowired private IDeviceChannelService deviceChannelService; - @Autowired - private EventPublisher eventPublisher; - private ConcurrentLinkedQueue taskQueue = new ConcurrentLinkedQueue<>(); @Qualifier("taskExecutor") diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceInfoQueryMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceInfoQueryMessageHandler.java index d1007989..e04bc8e8 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceInfoQueryMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceInfoQueryMessageHandler.java @@ -10,7 +10,6 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderForPlatform; import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.QueryMessageHandler; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import gov.nist.javax.sip.message.SIPRequest; import lombok.extern.slf4j.Slf4j; import org.dom4j.Element; @@ -39,9 +38,6 @@ public class DeviceInfoQueryMessageHandler extends SIPRequestProcessorParent imp @Autowired private SIPCommanderForPlatform cmderFroPlatform; - @Autowired - private IVideoManagerStorage storager; - @Autowired private IDeviceService deviceService; diff --git a/src/main/java/com/genersoft/iot/vmp/service/IMobilePositionService.java b/src/main/java/com/genersoft/iot/vmp/service/IMobilePositionService.java index 9af64150..28ab1d1f 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IMobilePositionService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IMobilePositionService.java @@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.service; import com.genersoft.iot.vmp.gb28181.bean.MobilePosition; +import com.genersoft.iot.vmp.gb28181.bean.Platform; import java.util.List; @@ -10,4 +11,10 @@ public interface IMobilePositionService { void add(List mobilePositionList); void add(MobilePosition mobilePosition); + + List queryMobilePositions(String deviceId, String channelId, String startTime, String endTime); + + List queryEnablePlatformListWithAsMessageChannel(); + + MobilePosition queryLatestPosition(String deviceId); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/MobilePositionServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/MobilePositionServiceImpl.java index 52042739..20cf8f8f 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/MobilePositionServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/MobilePositionServiceImpl.java @@ -3,6 +3,8 @@ package com.genersoft.iot.vmp.service.impl; import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.MobilePosition; +import com.genersoft.iot.vmp.gb28181.bean.Platform; +import com.genersoft.iot.vmp.gb28181.dao.PlatformMapper; import com.genersoft.iot.vmp.service.IMobilePositionService; import com.genersoft.iot.vmp.gb28181.dao.DeviceChannelMapper; import com.genersoft.iot.vmp.gb28181.dao.DeviceMobilePositionMapper; @@ -31,6 +33,10 @@ public class MobilePositionServiceImpl implements IMobilePositionService { @Autowired private UserSetting userSetting; + + @Autowired + private PlatformMapper platformMapper; + @Autowired private RedisTemplate redisTemplate; @@ -64,6 +70,30 @@ public class MobilePositionServiceImpl implements IMobilePositionService { + /** + * 查询移动位置轨迹 + */ + @Override + public synchronized List queryMobilePositions(String deviceId, String channelId, String startTime, String endTime) { + return mobilePositionMapper.queryPositionByDeviceIdAndTime(deviceId, channelId, startTime, endTime); + } + + @Override + public List queryEnablePlatformListWithAsMessageChannel() { + return platformMapper.queryEnablePlatformListWithAsMessageChannel(); + } + + /** + * 查询最新移动位置 + * @param deviceId + */ + @Override + public MobilePosition queryLatestPosition(String deviceId) { + return mobilePositionMapper.queryLatestPositionByDevice(deviceId); + } + + + @Scheduled(fixedRate = 1000) @Transactional public void executeTaskQueue() { diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java index 315ade75..e31c65cb 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java @@ -6,12 +6,12 @@ import com.genersoft.iot.vmp.gb28181.bean.AlarmChannelMessage; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm; import com.genersoft.iot.vmp.gb28181.bean.Platform; +import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService; +import com.genersoft.iot.vmp.gb28181.service.IDeviceService; import com.genersoft.iot.vmp.gb28181.service.IPlatformService; import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; -import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService; -import com.genersoft.iot.vmp.gb28181.service.IDeviceService; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; +import com.genersoft.iot.vmp.service.IMobilePositionService; import com.genersoft.iot.vmp.utils.DateUtil; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -50,7 +50,7 @@ public class RedisAlarmMsgListener implements MessageListener { private IDeviceChannelService channelService; @Autowired - private IVideoManagerStorage storage; + private IMobilePositionService mobilePositionService; @Autowired private IPlatformService platformService; @@ -109,7 +109,7 @@ public class RedisAlarmMsgListener implements MessageListener { } }else { // 获取开启了消息推送的设备和平台 - List parentPlatforms = storage.queryEnablePlatformListWithAsMessageChannel(); + List parentPlatforms = mobilePositionService.queryEnablePlatformListWithAsMessageChannel(); if (parentPlatforms.size() > 0) { for (Platform parentPlatform : parentPlatforms) { try { diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisGpsMsgListener.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisGpsMsgListener.java index 7569fb8e..86a9d537 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisGpsMsgListener.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisGpsMsgListener.java @@ -3,7 +3,6 @@ package com.genersoft.iot.vmp.service.redisMsg; import com.alibaba.fastjson2.JSON; import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import lombok.extern.slf4j.Slf4j; import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Autowired; @@ -30,9 +29,6 @@ public class RedisGpsMsgListener implements MessageListener { @Autowired private IRedisCatchStorage redisCatchStorage; - @Autowired - private IVideoManagerStorage storager; - private ConcurrentLinkedQueue taskQueue = new ConcurrentLinkedQueue<>(); @Qualifier("taskExecutor") diff --git a/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java b/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java deleted file mode 100755 index 66e1af42..00000000 --- a/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.genersoft.iot.vmp.storager; - -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.MobilePosition; -import com.genersoft.iot.vmp.gb28181.bean.Platform; - -import java.util.List; - -/** - * @description:视频设备数据存储接口 - * @author: swwheihei - * @date: 2020年5月6日 下午2:14:31 - */ -@SuppressWarnings("rawtypes") -public interface IVideoManagerStorage { - - - - Device queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId); - - /** - * 针对deviceinfo指令的查询接口 - * @param platformId 平台id - * @param channelId 通道id - * @return 设备信息 - */ - Device queryDeviceInfoByPlatformIdAndChannelId(String platformId, String channelId); - - /** - * 查询移动位置轨迹 - * @param deviceId - * @param startTime - * @param endTime - */ - public List queryMobilePositions(String deviceId, String channelId, String startTime, String endTime); - - /** - * 查询最新移动位置 - * @param deviceId - */ - public MobilePosition queryLatestPosition(String deviceId); - - - /** - * 根据通道ID获取其所在设备 - * @param channelId 通道ID - * @return - */ - Device queryVideoDeviceByChannelId(String channelId); - - List queryEnablePlatformListWithAsMessageChannel(); - -} diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java deleted file mode 100755 index 5818611a..00000000 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java +++ /dev/null @@ -1,112 +0,0 @@ -package com.genersoft.iot.vmp.storager.impl; - -import com.baomidou.dynamic.datasource.annotation.DS; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; -import com.genersoft.iot.vmp.gb28181.bean.MobilePosition; -import com.genersoft.iot.vmp.gb28181.bean.Platform; -import com.genersoft.iot.vmp.gb28181.dao.*; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.util.List; - -/** - * 视频设备数据存储-jdbc实现 - * swwheihei - * 2020年5月6日 下午2:31:42 - */ -@SuppressWarnings("rawtypes") -@Slf4j -@Component -@DS("master") -public class VideoManagerStorageImpl implements IVideoManagerStorage { - - - @Autowired - private DeviceMapper deviceMapper; - - @Autowired - private DeviceChannelMapper deviceChannelMapper; - - @Autowired - private DeviceMobilePositionMapper deviceMobilePositionMapper; - - @Autowired - private PlatformMapper platformMapper; - - @Autowired - private PlatformChannelMapper platformChannelMapper; - - - /** - * 查询移动位置轨迹 - * @param deviceId - * @param startTime - * @param endTime - */ - @Override - public synchronized List queryMobilePositions(String deviceId, String channelId, String startTime, String endTime) { - return deviceMobilePositionMapper.queryPositionByDeviceIdAndTime(deviceId, channelId, startTime, endTime); - } - - @Override - public List queryEnablePlatformListWithAsMessageChannel() { - return platformMapper.queryEnablePlatformListWithAsMessageChannel(); - } - - @Override - public Device queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId) { - List devices = platformChannelMapper.queryDeviceByPlatformIdAndChannelId(platformId, channelId); - if (devices.size() > 1) { - // 出现长度大于0的时候肯定是国标通道的ID重复了 - log.warn("国标ID存在重复:{}", channelId); - } - if (devices.size() == 0) { - return null; - }else { - return devices.get(0); - } - - - } - - @Override - public Device queryDeviceInfoByPlatformIdAndChannelId(String platformId, String channelId) { - List devices = platformChannelMapper.queryDeviceInfoByPlatformIdAndChannelId(platformId, channelId); - if (devices.size() > 1) { - // 出现长度大于0的时候肯定是国标通道的ID重复了 - log.warn("国标ID存在重复:{}", channelId); - } - if (devices.size() == 0) { - return null; - }else { - return devices.get(0); - } - } - - /** - * 查询最新移动位置 - * @param deviceId - */ - @Override - public MobilePosition queryLatestPosition(String deviceId) { - return deviceMobilePositionMapper.queryLatestPositionByDevice(deviceId); - } - - - @Override - public Device queryVideoDeviceByChannelId( String channelId) { - Device result = null; - List channelList = deviceChannelMapper.queryChannelByChannelId(channelId); - if (channelList.size() == 1) { - result = deviceMapper.getDeviceByDeviceId(channelList.get(0).getDeviceId()); - } - return result; - } - - - -} diff --git a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java index a2f82be8..359d3814 100644 --- a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java +++ b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java @@ -5,12 +5,11 @@ import com.alibaba.fastjson2.JSONObject; import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.PresetQuerySipReq; +import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService; +import com.genersoft.iot.vmp.gb28181.service.IDeviceService; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; -import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService; -import com.genersoft.iot.vmp.gb28181.service.IDeviceService; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.vmanager.bean.DeferredResultEx; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import com.genersoft.iot.vmp.web.gb28181.dto.DeviceChannelExtend; @@ -38,9 +37,6 @@ import java.util.*; @RequestMapping(value = "/api/v1/device") public class ApiDeviceController { - @Autowired - private IVideoManagerStorage storager; - @Autowired private SIPCommander cmder; @Autowired