支持手动添加,为设备设置单独的密码
parent
882e6a027e
commit
3c52a16e5f
File diff suppressed because one or more lines are too long
|
@ -6,5 +6,24 @@ alter table stream_proxy
|
|||
|
||||
alter table device
|
||||
add mediaServerId varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'auto';
|
||||
|
||||
alter table device
|
||||
add custom_name varchar(255) default null;
|
||||
|
||||
alter table device
|
||||
add password varchar(255) default null;
|
||||
|
||||
alter table device
|
||||
modify ip varchar(50) null;
|
||||
|
||||
alter table device
|
||||
modify port int null;
|
||||
|
||||
alter table device
|
||||
modify expires int null;
|
||||
|
||||
alter table device
|
||||
modify subscribeCycleForCatalog int null;
|
||||
|
||||
alter table device
|
||||
modify hostAddress varchar(50) null;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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头
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 = "数据流传输模式, 取值:" +
|
||||
"UDP(udp传输),TCP-ACTIVE(tcp主动模式,暂不支持),TCP-PASSIVE(tcp被动模式)", 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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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 + "未找到");
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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","未找到设备");
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
<div class="page-header">
|
||||
<div class="page-title">设备列表</div>
|
||||
<div class="page-header-btn">
|
||||
<el-button icon="el-icon-plus" size="mini" style="margin-right: 1rem;" type="primary" @click="add">添加设备
|
||||
</el-button>
|
||||
<el-button icon="el-icon-refresh-right" circle size="mini" :loading="getDeviceListLoading"
|
||||
@click="getDeviceList()"></el-button>
|
||||
</div>
|
||||
|
@ -16,7 +18,8 @@
|
|||
<el-table-column label="地址" min-width="160" >
|
||||
<template slot-scope="scope">
|
||||
<div slot="reference" class="name-wrapper">
|
||||
<el-tag size="medium">{{ scope.row.hostAddress }}</el-tag>
|
||||
<el-tag v-if="scope.row.hostAddress" size="medium">{{ scope.row.hostAddress }}</el-tag>
|
||||
<el-tag v-if="!scope.row.hostAddress" size="medium">未知</el-tag>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
@ -164,7 +167,6 @@ export default {
|
|||
console.error(error);
|
||||
this.getDeviceListLoading = false;
|
||||
});
|
||||
|
||||
},
|
||||
deleteDevice: function (row) {
|
||||
let msg = "确定删除此设备?"
|
||||
|
@ -254,21 +256,6 @@ export default {
|
|||
})
|
||||
return result;
|
||||
},
|
||||
//通知设备上传媒体流
|
||||
sendDevicePush: function (itemData) {
|
||||
// let deviceId = this.currentDevice.deviceId;
|
||||
// let channelId = itemData.channelId;
|
||||
// console.log("通知设备推流1:" + deviceId + " : " + channelId);
|
||||
// let that = this;
|
||||
// this.$axios({
|
||||
// method: 'get',
|
||||
// url: '/api/play/' + deviceId + '/' + channelId
|
||||
// }).then(function(res) {
|
||||
// let ssrc = res.data.ssrc;
|
||||
// that.$refs.devicePlayer.play(ssrc,deviceId,channelId);
|
||||
// }).catch(function(e) {
|
||||
// });
|
||||
},
|
||||
transportChange: function (row) {
|
||||
console.log(`修改传输方式为 ${row.streamMode}:${row.deviceId} `);
|
||||
let that = this;
|
||||
|
@ -290,9 +277,22 @@ export default {
|
|||
});
|
||||
setTimeout(this.getDeviceList, 200)
|
||||
|
||||
})
|
||||
},
|
||||
add: function () {
|
||||
this.$refs.deviceEdit.openDialog(null, () => {
|
||||
this.$refs.deviceEdit.close();
|
||||
this.$message({
|
||||
showClose: true,
|
||||
message: "添加成功",
|
||||
type: "success",
|
||||
});
|
||||
setTimeout(this.getDeviceList, 200)
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -11,13 +11,17 @@
|
|||
>
|
||||
<div id="shared" style="margin-top: 1rem;margin-right: 100px;">
|
||||
<el-form ref="form" :rules="rules" :model="form" label-width="200px" >
|
||||
<el-form-item label="设备编号" >
|
||||
<el-input v-model="form.deviceId" disabled></el-input>
|
||||
<el-form-item label="设备编号" prop="deviceId">
|
||||
<el-input v-if="isEdit" v-model="form.deviceId" disabled></el-input>
|
||||
<el-input v-if="!isEdit" v-model="form.deviceId" clearable></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="设备名称" prop="name">
|
||||
<el-input v-model="form.name" clearable></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="密码" prop="password">
|
||||
<el-input type="password" v-model="form.password" clearable></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="流媒体ID" prop="mediaServerId">
|
||||
<el-select v-model="form.mediaServerId" style="float: left; width: 100%" >
|
||||
<el-option key="auto" label="自动负载最小" value="auto"></el-option>
|
||||
|
@ -48,10 +52,10 @@
|
|||
<el-option key="GCJ02" label="业务分组" value="BusinessGroup"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="目录订阅" title="0为取消订阅" prop="subscribeCycleForCatalog" >
|
||||
<el-form-item v-if="this.isEdit" label="目录订阅" title="0为取消订阅" prop="subscribeCycleForCatalog" >
|
||||
<el-input v-model="form.subscribeCycleForCatalog" clearable ></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="移动位置订阅" title="0为取消订阅" prop="subscribeCycleForCatalog" >
|
||||
<el-form-item v-if="this.isEdit" label="移动位置订阅" title="0为取消订阅" prop="subscribeCycleForCatalog" >
|
||||
<el-input v-model="form.subscribeCycleForMobilePosition" clearable ></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.subscribeCycleForMobilePosition > 0" label="移动位置报送间隔" prop="subscribeCycleForCatalog" >
|
||||
|
@ -89,8 +93,9 @@ export default {
|
|||
mediaServerList: [], // 滅体节点列表
|
||||
mediaServerObj : new MediaServer(),
|
||||
form: {},
|
||||
isEdit: false,
|
||||
rules: {
|
||||
name: [{ required: true, message: "请输入名称", trigger: "blur" }]
|
||||
deviceId: [{ required: true, message: "请输入设备编号", trigger: "blur" }]
|
||||
},
|
||||
};
|
||||
},
|
||||
|
@ -98,6 +103,11 @@ export default {
|
|||
openDialog: function (row, callback) {
|
||||
console.log(row)
|
||||
this.showDialog = true;
|
||||
this.isEdit = false;
|
||||
if (row) {
|
||||
this.isEdit = true;
|
||||
}
|
||||
this.form = {};
|
||||
this.listChangeCallback = callback;
|
||||
if (row != null) {
|
||||
this.form = row;
|
||||
|
@ -118,7 +128,7 @@ export default {
|
|||
this.form.mobilePositionSubmissionInterval = this.form.mobilePositionSubmissionInterval||0
|
||||
this.$axios({
|
||||
method: 'post',
|
||||
url:`/api/device/query/device/update/`,
|
||||
url:`/api/device/query/device/${this.isEdit?'update':'add'}/`,
|
||||
params: this.form
|
||||
}).then((res) => {
|
||||
console.log(res.data)
|
||||
|
|
Loading…
Reference in New Issue