支持手动添加,为设备设置单独的密码
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user