支持手动添加,为设备设置单独的密码

This commit is contained in:
648540858
2022-10-18 17:02:05 +08:00
parent 882e6a027e
commit 3c52a16e5f
19 changed files with 277 additions and 265 deletions

View File

@@ -172,6 +172,9 @@ public class Device {
@Schema(description = "树类型 国标规定了两种树的展现方式 行政区划CivilCode 和业务分组:BusinessGroup")
private String treeType;
@Schema(description = "密码")
private String password;
public String getDeviceId() {
return deviceId;
@@ -381,4 +384,11 @@ public class Device {
this.treeType = treeType;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}

View File

@@ -107,7 +107,7 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In
if (totalReaderCount <= 0) {
logger.info("[收到bye] {} 无其它观看者,通知设备停止推流", streamId);
if (sendRtpItem.getPlayType().equals(InviteStreamType.PLAY)) {
Device device = deviceService.queryDevice(sendRtpItem.getDeviceId());
Device device = deviceService.getDevice(sendRtpItem.getDeviceId());
if (device == null) {
logger.info("[收到bye] {} 通知设备停止推流时未找到设备信息", streamId);
}

View File

@@ -21,7 +21,6 @@ import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import javax.sip.RequestEvent;
import javax.sip.SipException;
@@ -82,9 +81,10 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
AddressImpl address = (AddressImpl) fromHeader.getAddress();
SipUri uri = (SipUri) address.getURI();
String deviceId = uri.getUser();
Device device = deviceService.getDevice(deviceId);
String password = (device != null && !ObjectUtils.isEmpty(device.getPassword()))? device.getPassword() : sipConfig.getPassword();
AuthorizationHeader authHead = (AuthorizationHeader) request.getHeader(AuthorizationHeader.NAME);
if (authHead == null && !ObjectUtils.isEmpty(sipConfig.getPassword())) {
if (authHead == null && !ObjectUtils.isEmpty(password)) {
logger.info("[注册请求] 未携带授权头 回复401: {}", requestAddress);
response = getMessageFactory().createResponse(Response.UNAUTHORIZED, request);
new DigestServerAuthenticationHelper().generateChallenge(getHeaderFactory(), response, sipConfig.getDomain());
@@ -93,8 +93,8 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
}
// 校验密码是否正确
passwordCorrect = ObjectUtils.isEmpty(sipConfig.getPassword()) ||
new DigestServerAuthenticationHelper().doAuthenticatePlainTextPassword(request, sipConfig.getPassword());
passwordCorrect = ObjectUtils.isEmpty(password) ||
new DigestServerAuthenticationHelper().doAuthenticatePlainTextPassword(request, password);
if (!passwordCorrect) {
// 注册失败
@@ -105,8 +105,6 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
return;
}
Device device = deviceService.queryDevice(deviceId);
// 携带授权头并且密码正确
response = getMessageFactory().createResponse(Response.OK, request);
// 添加date头

View File

@@ -43,20 +43,9 @@ public class DeviceInfoResponseMessageHandler extends SIPRequestProcessorParent
@Autowired
private ResponseMessageHandler responseMessageHandler;
@Autowired
private IVideoManagerStorage storager;
@Autowired
private IRedisCatchStorage redisCatchStorage;
@Autowired
private DeferredResultHolder deferredResultHolder;
@Autowired
private SipConfig config;
@Autowired
private EventPublisher publisher;
@Autowired
private IDeviceService deviceService;

View File

@@ -521,7 +521,7 @@ public class ZLMHttpHookListener {
if (sendRtpItem.getApp().equals(app)) {
String platformId = sendRtpItem.getPlatformId();
ParentPlatform platform = storager.queryParentPlatByServerGBId(platformId);
Device device = deviceService.queryDevice(platformId);
Device device = deviceService.getDevice(platformId);
try {
if (platform != null) {
@@ -581,7 +581,7 @@ public class ZLMHttpHookListener {
}
}
}
Device device = deviceService.queryDevice(streamInfoForPlayCatch.getDeviceID());
Device device = deviceService.getDevice(streamInfoForPlayCatch.getDeviceID());
if (device != null) {
try {
cmder.streamByeCmd(device, streamInfoForPlayCatch.getChannelId(),
@@ -601,7 +601,7 @@ public class ZLMHttpHookListener {
if (streamInfoForPlayBackCatch.isPause()) {
ret.put("close", false);
}else {
Device device = deviceService.queryDevice(streamInfoForPlayBackCatch.getDeviceID());
Device device = deviceService.getDevice(streamInfoForPlayBackCatch.getDeviceID());
if (device != null) {
try {
cmder.streamByeCmd(device,streamInfoForPlayBackCatch.getChannelId(),

View File

@@ -78,7 +78,7 @@ public interface IDeviceService {
* @param deviceId 设备编号
* @return 设备信息
*/
Device queryDevice(String deviceId);
Device getDevice(String deviceId);
/**
* 获取所有在线设备
@@ -129,4 +129,30 @@ public interface IDeviceService {
* @return
*/
List<DeviceChannel> queryVideoDeviceInTreeNode(String deviceId, String parentId);
/**
* 检查设备编号是否已经存在
* @param deviceId 设备编号
* @return
*/
boolean isExist(String deviceId);
/**
* 添加设备
* @param device
*/
void addDevice(Device device);
/**
* 页面表单更新设备信息
* @param device
*/
void updateCustomDevice(Device device);
/**
* 删除设备
* @param deviceId
* @return
*/
boolean delete(String deviceId);
}

View File

@@ -16,13 +16,17 @@ import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper;
import com.genersoft.iot.vmp.storager.dao.DeviceMapper;
import com.genersoft.iot.vmp.storager.dao.PlatformChannelMapper;
import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.vmanager.bean.BaseTree;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.jdbc.support.incrementer.AbstractIdentityColumnMaxValueIncrementer;
import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
@@ -60,12 +64,21 @@ public class DeviceServiceImpl implements IDeviceService {
@Autowired
private DeviceMapper deviceMapper;
@Autowired
private PlatformChannelMapper platformChannelMapper;
@Autowired
private IDeviceChannelService deviceChannelService;
@Autowired
private DeviceChannelMapper deviceChannelMapper;
@Autowired
DataSourceTransactionManager dataSourceTransactionManager;
@Autowired
TransactionDefinition transactionDefinition;
@Autowired
private IVideoManagerStorage storage;
@@ -263,7 +276,7 @@ public class DeviceServiceImpl implements IDeviceService {
}
@Override
public Device queryDevice(String deviceId) {
public Device getDevice(String deviceId) {
Device device = redisCatchStorage.getDevice(deviceId);
if (device == null) {
device = deviceMapper.getDeviceByDeviceId(deviceId);
@@ -307,60 +320,11 @@ public class DeviceServiceImpl implements IDeviceService {
@Override
public void updateDevice(Device device) {
Device deviceInStore = deviceMapper.getDeviceByDeviceId(device.getDeviceId());
if (deviceInStore == null) {
logger.warn("更新设备时未找到设备信息");
return;
}
if (!ObjectUtils.isEmpty(device.getName())) {
deviceInStore.setName(device.getName());
}
if (!ObjectUtils.isEmpty(device.getCharset())) {
deviceInStore.setCharset(device.getCharset());
}
if (!ObjectUtils.isEmpty(device.getMediaServerId())) {
deviceInStore.setMediaServerId(device.getMediaServerId());
}
// 目录订阅相关的信息
if (device.getSubscribeCycleForCatalog() > 0) {
if (deviceInStore.getSubscribeCycleForCatalog() == 0 || deviceInStore.getSubscribeCycleForCatalog() != device.getSubscribeCycleForCatalog()) {
deviceInStore.setSubscribeCycleForCatalog(device.getSubscribeCycleForCatalog());
// 开启订阅
addCatalogSubscribe(deviceInStore);
}
}else if (device.getSubscribeCycleForCatalog() == 0) {
if (deviceInStore.getSubscribeCycleForCatalog() != 0) {
deviceInStore.setSubscribeCycleForCatalog(device.getSubscribeCycleForCatalog());
// 取消订阅
removeCatalogSubscribe(deviceInStore);
}
}
// 移动位置订阅相关的信息
if (device.getSubscribeCycleForMobilePosition() > 0) {
if (deviceInStore.getSubscribeCycleForMobilePosition() == 0 || deviceInStore.getSubscribeCycleForMobilePosition() != device.getSubscribeCycleForMobilePosition()) {
deviceInStore.setMobilePositionSubmissionInterval(device.getMobilePositionSubmissionInterval());
deviceInStore.setSubscribeCycleForMobilePosition(device.getSubscribeCycleForMobilePosition());
// 开启订阅
addMobilePositionSubscribe(deviceInStore);
}
}else if (device.getSubscribeCycleForMobilePosition() == 0) {
if (deviceInStore.getSubscribeCycleForMobilePosition() != 0) {
// 取消订阅
removeMobilePositionSubscribe(deviceInStore);
}
}
// 坐标系变化需要重新计算GCJ02坐标和WGS84坐标
if (!deviceInStore.getGeoCoordSys().equals(device.getGeoCoordSys())) {
updateDeviceChannelGeoCoordSys(device);
}
String now = DateUtil.getNow();
device.setUpdateTime(now);
device.setCharset(device.getCharset().toUpperCase());
device.setUpdateTime(DateUtil.getNow());
if (deviceMapper.updateCustom(device) > 0) {
if (deviceMapper.update(device) > 0) {
redisCatchStorage.updateDevice(device);
}
@@ -555,4 +519,88 @@ public class DeviceServiceImpl implements IDeviceService {
return result;
}
@Override
public boolean isExist(String deviceId) {
return deviceMapper.getDeviceByDeviceId(deviceId) != null;
}
@Override
public void addDevice(Device device) {
device.setOnline(0);
device.setCreateTime(DateUtil.getNow());
device.setUpdateTime(DateUtil.getNow());
deviceMapper.addCustomDevice(device);
}
@Override
public void updateCustomDevice(Device device) {
Device deviceInStore = deviceMapper.getDeviceByDeviceId(device.getDeviceId());
if (deviceInStore == null) {
logger.warn("更新设备时未找到设备信息");
return;
}
if (!ObjectUtils.isEmpty(device.getName())) {
deviceInStore.setName(device.getName());
}
if (!ObjectUtils.isEmpty(device.getCharset())) {
deviceInStore.setCharset(device.getCharset());
}
if (!ObjectUtils.isEmpty(device.getMediaServerId())) {
deviceInStore.setMediaServerId(device.getMediaServerId());
}
// 目录订阅相关的信息
if (device.getSubscribeCycleForCatalog() > 0) {
if (deviceInStore.getSubscribeCycleForCatalog() == 0 || deviceInStore.getSubscribeCycleForCatalog() != device.getSubscribeCycleForCatalog()) {
deviceInStore.setSubscribeCycleForCatalog(device.getSubscribeCycleForCatalog());
// 开启订阅
addCatalogSubscribe(deviceInStore);
}
}else if (device.getSubscribeCycleForCatalog() == 0) {
if (deviceInStore.getSubscribeCycleForCatalog() != 0) {
deviceInStore.setSubscribeCycleForCatalog(device.getSubscribeCycleForCatalog());
// 取消订阅
removeCatalogSubscribe(deviceInStore);
}
}
// 移动位置订阅相关的信息
if (device.getSubscribeCycleForMobilePosition() > 0) {
if (deviceInStore.getSubscribeCycleForMobilePosition() == 0 || deviceInStore.getSubscribeCycleForMobilePosition() != device.getSubscribeCycleForMobilePosition()) {
deviceInStore.setMobilePositionSubmissionInterval(device.getMobilePositionSubmissionInterval());
deviceInStore.setSubscribeCycleForMobilePosition(device.getSubscribeCycleForMobilePosition());
// 开启订阅
addMobilePositionSubscribe(deviceInStore);
}
}else if (device.getSubscribeCycleForMobilePosition() == 0) {
if (deviceInStore.getSubscribeCycleForMobilePosition() != 0) {
// 取消订阅
removeMobilePositionSubscribe(deviceInStore);
}
}
// 坐标系变化需要重新计算GCJ02坐标和WGS84坐标
if (!deviceInStore.getGeoCoordSys().equals(device.getGeoCoordSys())) {
updateDeviceChannelGeoCoordSys(device);
}
deviceMapper.updateCustom(device);
}
@Override
public boolean delete(String deviceId) {
TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
boolean result = false;
try {
platformChannelMapper.delChannelForDeviceId(deviceId);
deviceChannelMapper.cleanChannelsByDeviceId(deviceId);
if ( deviceMapper.del(deviceId) < 0 ) {
//事务回滚
dataSourceTransactionManager.rollback(transactionStatus);
}
result = true;
dataSourceTransactionManager.commit(transactionStatus); //手动提交
}catch (Exception e) {
dataSourceTransactionManager.rollback(transactionStatus);
}
return result;
}
}

View File

@@ -9,7 +9,6 @@ import javax.sip.InvalidArgumentException;
import javax.sip.ResponseEvent;
import javax.sip.SipException;
import com.genersoft.iot.vmp.common.VideoManagerConstants;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.conf.exception.ServiceException;
import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
@@ -21,11 +20,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.context.request.async.DeferredResult;
import com.alibaba.fastjson.JSON;
@@ -59,8 +56,6 @@ import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.PlayResult;
import gov.nist.javax.sip.stack.SIPDialog;
@SuppressWarnings(value = {"rawtypes", "unchecked"})
@Service
public class PlayServiceImpl implements IPlayService {
@@ -758,7 +753,7 @@ public class PlayServiceImpl implements IPlayService {
if (allSsrc.size() > 0) {
for (SsrcTransaction ssrcTransaction : allSsrc) {
if (ssrcTransaction.getMediaServerId().equals(mediaServerId)) {
Device device = deviceService.queryDevice(ssrcTransaction.getDeviceId());
Device device = deviceService.getDevice(ssrcTransaction.getDeviceId());
if (device == null) {
continue;
}

View File

@@ -100,36 +100,6 @@ public interface IVideoManagerStorage {
*/
public List<Device> queryVideoDeviceList();
/**
* 删除设备
*
* @param deviceId 设备ID
* @return true删除成功 false删除失败
*/
public boolean delete(String deviceId);
/**
* 更新设备在线
*
* @param deviceId 设备ID
* @return true更新成功 false更新失败
*/
public boolean online(String deviceId);
/**
* 更新设备离线
*
* @param deviceId 设备ID
* @return true更新成功 false更新失败
*/
public boolean outline(String deviceId);
/**
* 更新所有设备离线
*
* @return true更新成功 false更新失败
*/
public boolean outlineForAll();
/**

View File

@@ -16,6 +16,7 @@ public interface DeviceMapper {
@Select("SELECT " +
"deviceId, " +
"coalesce(custom_name, name) as name, " +
"password, " +
"manufacturer, " +
"model, " +
"firmware, " +
@@ -102,7 +103,6 @@ public interface DeviceMapper {
"<if test=\"model != null\">, model='${model}'</if>" +
"<if test=\"firmware != null\">, firmware='${firmware}'</if>" +
"<if test=\"transport != null\">, transport='${transport}'</if>" +
"<if test=\"streamMode != null\">, streamMode='${streamMode}'</if>" +
"<if test=\"ip != null\">, ip='${ip}'</if>" +
"<if test=\"port != null\">, port=${port}</if>" +
"<if test=\"hostAddress != null\">, hostAddress='${hostAddress}'</if>" +
@@ -110,15 +110,6 @@ public interface DeviceMapper {
"<if test=\"registerTime != null\">, registerTime='${registerTime}'</if>" +
"<if test=\"keepaliveTime != null\">, keepaliveTime='${keepaliveTime}'</if>" +
"<if test=\"expires != null\">, expires=${expires}</if>" +
"<if test=\"charset != null\">, charset='${charset}'</if>" +
"<if test=\"subscribeCycleForCatalog != null\">, subscribeCycleForCatalog=${subscribeCycleForCatalog}</if>" +
"<if test=\"subscribeCycleForMobilePosition != null\">, subscribeCycleForMobilePosition=${subscribeCycleForMobilePosition}</if>" +
"<if test=\"mobilePositionSubmissionInterval != null\">, mobilePositionSubmissionInterval=${mobilePositionSubmissionInterval}</if>" +
"<if test=\"subscribeCycleForAlarm != null\">, subscribeCycleForAlarm=${subscribeCycleForAlarm}</if>" +
"<if test=\"ssrcCheck != null\">, ssrcCheck=${ssrcCheck}</if>" +
"<if test=\"geoCoordSys != null\">, geoCoordSys=#{geoCoordSys}</if>" +
"<if test=\"treeType != null\">, treeType=#{treeType}</if>" +
"<if test=\"mediaServerId != null\">, mediaServerId=#{mediaServerId}</if>" +
"WHERE deviceId='${deviceId}'"+
" </script>"})
int update(Device device);
@@ -126,6 +117,7 @@ public interface DeviceMapper {
@Select("SELECT " +
"deviceId, " +
"coalesce(custom_name, name) as name, " +
"password, " +
"manufacturer, " +
"model, " +
"firmware, " +
@@ -160,6 +152,7 @@ public interface DeviceMapper {
@Select("SELECT " +
"deviceId, " +
"coalesce(custom_name, name) as name, " +
"password, " +
"manufacturer, " +
"model, " +
"firmware, " +
@@ -181,12 +174,13 @@ public interface DeviceMapper {
"ssrcCheck," +
"geoCoordSys," +
"treeType," +
"online" +
"online " +
" FROM device WHERE online = 1")
List<Device> getOnlineDevices();
@Select("SELECT " +
"deviceId, " +
"coalesce(custom_name, name) as name, " +
"password, " +
"manufacturer, " +
"model, " +
"firmware, " +
@@ -216,11 +210,10 @@ public interface DeviceMapper {
"UPDATE device " +
"SET updateTime='${updateTime}'" +
"<if test=\"name != null\">, custom_name='${name}'</if>" +
"<if test=\"password != null\">, password='${password}'</if>" +
"<if test=\"streamMode != null\">, streamMode='${streamMode}'</if>" +
"<if test=\"ip != null\">, ip='${ip}'</if>" +
"<if test=\"port != null\">, port=${port}</if>" +
"<if test=\"hostAddress != null\">, hostAddress='${hostAddress}'</if>" +
"<if test=\"online != null\">, online=${online}</if>" +
"<if test=\"charset != null\">, charset='${charset}'</if>" +
"<if test=\"subscribeCycleForCatalog != null\">, subscribeCycleForCatalog=${subscribeCycleForCatalog}</if>" +
"<if test=\"subscribeCycleForMobilePosition != null\">, subscribeCycleForMobilePosition=${subscribeCycleForMobilePosition}</if>" +
@@ -233,4 +226,29 @@ public interface DeviceMapper {
"WHERE deviceId='${deviceId}'"+
" </script>"})
int updateCustom(Device device);
@Insert("INSERT INTO device (" +
"deviceId, " +
"custom_name, " +
"password, " +
"createTime," +
"updateTime," +
"charset," +
"ssrcCheck," +
"geoCoordSys," +
"treeType," +
"online" +
") VALUES (" +
"#{deviceId}," +
"#{name}," +
"#{password}," +
"#{createTime}," +
"#{updateTime}," +
"#{charset}," +
"#{ssrcCheck}," +
"#{geoCoordSys}," +
"#{treeType}," +
"#{online}" +
")")
void addCustomDevice(Device device);
}

View File

@@ -299,79 +299,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
return deviceList;
}
/**
* 删除设备
*
* @param deviceId 设备ID
* @return true删除成功 false删除失败
*/
@Override
public boolean delete(String deviceId) {
TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
boolean result = false;
try {
platformChannelMapper.delChannelForDeviceId(deviceId);
deviceChannelMapper.cleanChannelsByDeviceId(deviceId);
if ( deviceMapper.del(deviceId) < 0 ) {
//事务回滚
dataSourceTransactionManager.rollback(transactionStatus);
}
result = true;
dataSourceTransactionManager.commit(transactionStatus); //手动提交
}catch (Exception e) {
dataSourceTransactionManager.rollback(transactionStatus);
}
return result;
}
/**
* 更新设备在线
*
* @param deviceId 设备ID
* @return true更新成功 false更新失败
*/
@Override
public synchronized boolean online(String deviceId) {
Device device = deviceMapper.getDeviceByDeviceId(deviceId);
if (device == null) {
return false;
}
device.setOnline(1);
logger.info("更新设备在线: " + deviceId);
redisCatchStorage.updateDevice(device);
return deviceMapper.update(device) > 0;
}
/**
* 更新设备离线
*
* @param deviceId 设备ID
* @return true更新成功 false更新失败
*/
@Override
public synchronized boolean outline(String deviceId) {
logger.info("更新设备离线: " + deviceId);
Device device = deviceMapper.getDeviceByDeviceId(deviceId);
if (device == null) {
return false;
}
device.setOnline(0);
redisCatchStorage.updateDevice(device);
return deviceMapper.update(device) > 0;
}
/**
* 更新所有设备离线
*
* @return true更新成功 false更新失败
*/
@Override
public synchronized boolean outlineForAll() {
logger.info("更新所有设备离线");
int result = deviceMapper.outlineForAll();
return result > 0;
}
/**
* 清空通道
* @param deviceId

View File

@@ -76,9 +76,6 @@ public class DeviceQuery {
@Autowired
private DynamicTask dynamicTask;
@Autowired
private SubscribeHolder subscribeHolder;
/**
* 使用ID查询国标设备
* @param deviceId 国标ID
@@ -184,7 +181,7 @@ public class DeviceQuery {
}
// 清除redis记录
boolean isSuccess = storager.delete(deviceId);
boolean isSuccess = deviceService.delete(deviceId);
if (isSuccess) {
redisCatchStorage.clearCatchByDeviceId(deviceId);
// 停止此设备的订阅更新
@@ -228,7 +225,7 @@ public class DeviceQuery {
@Parameter(name = "online", description = "是否在线")
@Parameter(name = "channelType", description = "设备/子目录-> false/true")
@GetMapping("/sub_channels/{deviceId}/{channelId}/channels")
public ResponseEntity<PageInfo> subChannels(@PathVariable String deviceId,
public PageInfo subChannels(@PathVariable String deviceId,
@PathVariable String channelId,
int page,
int count,
@@ -239,11 +236,11 @@ public class DeviceQuery {
DeviceChannel deviceChannel = storager.queryChannel(deviceId,channelId);
if (deviceChannel == null) {
PageInfo<DeviceChannel> deviceChannelPageResult = new PageInfo<>();
return new ResponseEntity<>(deviceChannelPageResult,HttpStatus.OK);
return deviceChannelPageResult;
}
PageInfo pageResult = storager.querySubChannels(deviceId, channelId, query, channelType, online, page, count);
return new ResponseEntity<>(pageResult,HttpStatus.OK);
return pageResult;
}
/**
@@ -256,9 +253,8 @@ public class DeviceQuery {
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
@Parameter(name = "channel", description = "通道信息", required = true)
@PostMapping("/channel/update/{deviceId}")
public ResponseEntity updateChannel(@PathVariable String deviceId,DeviceChannel channel){
public void updateChannel(@PathVariable String deviceId,DeviceChannel channel){
deviceChannelService.updateChannel(deviceId, channel);
return new ResponseEntity<>(null,HttpStatus.OK);
}
/**
@@ -272,11 +268,32 @@ public class DeviceQuery {
@Parameter(name = "streamMode", description = "数据流传输模式, 取值:" +
"UDPudp传输TCP-ACTIVEtcp主动模式,暂不支持TCP-PASSIVEtcp被动模式", required = true)
@PostMapping("/transport/{deviceId}/{streamMode}")
public ResponseEntity updateTransport(@PathVariable String deviceId, @PathVariable String streamMode){
Device device = storager.queryVideoDevice(deviceId);
public void updateTransport(@PathVariable String deviceId, @PathVariable String streamMode){
Device device = deviceService.getDevice(deviceId);
device.setStreamMode(streamMode);
deviceService.updateDevice(device);
return new ResponseEntity<>(null,HttpStatus.OK);
deviceService.updateCustomDevice(device);
}
/**
* 添加设备信息
* @param device 设备信息
* @return
*/
@Operation(summary = "添加设备信息")
@Parameter(name = "device", description = "设备", required = true)
@PostMapping("/device/add/")
public void addDevice(Device device){
if (device == null || device.getDeviceId() == null) {
throw new ControllerException(ErrorCode.ERROR400);
}
// 查看deviceId是否存在
boolean exist = deviceService.isExist(device.getDeviceId());
if (exist) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "设备编号已存在");
}
deviceService.addDevice(device);
}
/**
@@ -287,15 +304,11 @@ public class DeviceQuery {
@Operation(summary = "更新设备信息")
@Parameter(name = "device", description = "设备", required = true)
@PostMapping("/device/update/")
public ResponseEntity<WVPResult<String>> updateDevice(Device device){
public void updateDevice(Device device){
if (device != null && device.getDeviceId() != null) {
deviceService.updateDevice(device);
deviceService.updateCustomDevice(device);
}
WVPResult<String> result = new WVPResult<>();
result.setCode(0);
result.setMsg("success");
return new ResponseEntity<>(result,HttpStatus.OK);
}
/**

View File

@@ -1,12 +1,10 @@
package com.genersoft.iot.vmp.vmanager.gb28181.record;
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
import com.genersoft.iot.vmp.service.IDeviceService;
import com.genersoft.iot.vmp.service.IMediaServerService;
import com.genersoft.iot.vmp.service.IPlayService;
import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
@@ -18,8 +16,6 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@@ -36,7 +32,6 @@ import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import javax.sip.InvalidArgumentException;
import javax.sip.SipException;
import java.text.ParseException;
import java.time.LocalDate;
import java.util.UUID;
@Tag(name = "国标录像")
@@ -155,7 +150,7 @@ public class GBRecordController {
throw new ControllerException(ErrorCode.ERROR400);
}
Device device = deviceService.queryDevice(deviceId);
Device device = deviceService.getDevice(deviceId);
if (device == null) {
throw new ControllerException(ErrorCode.ERROR400.getCode(), "设备:" + deviceId + "未找到");
}

View File

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.service.IDeviceService;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
@@ -26,6 +27,8 @@ public class ApiDeviceController {
@Autowired
private IVideoManagerStorage storager;
@Autowired
private IDeviceService deviceService;
// @Autowired
// private SIPCommander cmder;

View File

@@ -178,7 +178,7 @@ public class ApiStreamController {
result.put("error","未找到流信息");
return result;
}
Device device = deviceService.queryDevice(serial);
Device device = deviceService.getDevice(serial);
if (device == null) {
JSONObject result = new JSONObject();
result.put("error","未找到设备");