移除旧的数据库操作类

pull/1642/head
648540858 2024-09-24 15:59:47 +08:00
parent 632b1f3e53
commit 3b2a28fd00
22 changed files with 74 additions and 259 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;
@ -58,15 +56,9 @@ import java.util.UUID;
@RequestMapping("/api/device/query")
public class DeviceQuery {
@Autowired
private IVideoManagerStorage storager;
@Autowired
private IDeviceChannelService deviceChannelService;
@Autowired
private IRedisCatchStorage redisCatchStorage;
@Autowired
private IInviteStreamService inviteStreamService;

View File

@ -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;

View File

@ -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);
}
/**

View File

@ -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;

View File

@ -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;

View File

@ -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);
}

View File

@ -168,4 +168,6 @@ public interface IDeviceService {
Device getDevice(Integer gbDeviceDbId);
Device getDeviceByChannelId(Integer channelId);
Device getDeviceBySourceChannelDeviceId(String requesterId);
}

View File

@ -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);
}
}

View File

@ -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<String, CatalogData> data = new ConcurrentHashMap<>();
@Autowired
private IVideoManagerStorage storager;
@Autowired
private IDeviceChannelService deviceChannelService;

View File

@ -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) {

View File

@ -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;

View File

@ -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<SipMsgInfo> taskQueue = new ConcurrentLinkedQueue<>();
@Qualifier("taskExecutor")

View File

@ -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;

View File

@ -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<MobilePosition> mobilePositionList);
void add(MobilePosition mobilePosition);
List<MobilePosition> queryMobilePositions(String deviceId, String channelId, String startTime, String endTime);
List<Platform> queryEnablePlatformListWithAsMessageChannel();
MobilePosition queryLatestPosition(String deviceId);
}

View File

@ -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<String, MobilePosition> redisTemplate;
@ -64,6 +70,30 @@ public class MobilePositionServiceImpl implements IMobilePositionService {
/**
*
*/
@Override
public synchronized List<MobilePosition> queryMobilePositions(String deviceId, String channelId, String startTime, String endTime) {
return mobilePositionMapper.queryPositionByDeviceIdAndTime(deviceId, channelId, startTime, endTime);
}
@Override
public List<Platform> queryEnablePlatformListWithAsMessageChannel() {
return platformMapper.queryEnablePlatformListWithAsMessageChannel();
}
/**
*
* @param deviceId
*/
@Override
public MobilePosition queryLatestPosition(String deviceId) {
return mobilePositionMapper.queryLatestPositionByDevice(deviceId);
}
@Scheduled(fixedRate = 1000)
@Transactional
public void executeTaskQueue() {

View File

@ -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<Platform> parentPlatforms = storage.queryEnablePlatformListWithAsMessageChannel();
List<Platform> parentPlatforms = mobilePositionService.queryEnablePlatformListWithAsMessageChannel();
if (parentPlatforms.size() > 0) {
for (Platform parentPlatform : parentPlatforms) {
try {

View File

@ -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<Message> taskQueue = new ConcurrentLinkedQueue<>();
@Qualifier("taskExecutor")

View File

@ -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: 202056 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<MobilePosition> 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<Platform> queryEnablePlatformListWithAsMessageChannel();
}

View File

@ -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
* 202056 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<MobilePosition> queryMobilePositions(String deviceId, String channelId, String startTime, String endTime) {
return deviceMobilePositionMapper.queryPositionByDeviceIdAndTime(deviceId, channelId, startTime, endTime);
}
@Override
public List<Platform> queryEnablePlatformListWithAsMessageChannel() {
return platformMapper.queryEnablePlatformListWithAsMessageChannel();
}
@Override
public Device queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId) {
List<Device> 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<Device> 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<DeviceChannel> channelList = deviceChannelMapper.queryChannelByChannelId(channelId);
if (channelList.size() == 1) {
result = deviceMapper.getDeviceByDeviceId(channelList.get(0).getDeviceId());
}
return result;
}
}

View File

@ -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