Merge branch 'master' into dev/数据库统合
# Conflicts: # src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java # web_src/src/components/DeviceList.vue
This commit is contained in:
@@ -489,4 +489,21 @@ public class DeviceQuery {
|
||||
public DeviceChannel getRawChannel(int id) {
|
||||
return deviceChannelService.getRawChannel(id);
|
||||
}
|
||||
|
||||
@GetMapping("/subscribe/catalog")
|
||||
@Operation(summary = "开启/关闭目录订阅")
|
||||
@Parameter(name = "id", description = "通道的Id", required = true)
|
||||
@Parameter(name = "cycle", description = "订阅周期", required = true)
|
||||
public void subscribeCatalog(int id, int cycle) {
|
||||
deviceService.subscribeCatalog(id, cycle);
|
||||
}
|
||||
|
||||
@GetMapping("/subscribe/mobile-position")
|
||||
@Operation(summary = "开启/关闭移动位置订阅")
|
||||
@Parameter(name = "id", description = "通道的Id", required = true)
|
||||
@Parameter(name = "cycle", description = "订阅周期", required = true)
|
||||
@Parameter(name = "interval", description = "报送间隔", required = true)
|
||||
public void subscribeMobilePosition(int id, int cycle, int interval) {
|
||||
deviceService.subscribeMobilePosition(id, cycle, interval);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -284,9 +284,8 @@ public interface DeviceMapper {
|
||||
@Update(value = {" <script>" +
|
||||
"UPDATE wvp_device " +
|
||||
"SET update_time=#{updateTime}, custom_name=#{name} , password=#{password}, stream_mode=#{streamMode}" +
|
||||
", ip=#{ip}, sdp_ip=#{sdpIp}, port=#{port}, charset=#{charset}, subscribe_cycle_for_catalog=#{subscribeCycleForCatalog}" +
|
||||
", subscribe_cycle_for_mobile_position=#{subscribeCycleForMobilePosition}, mobile_position_submission_interval=#{mobilePositionSubmissionInterval}" +
|
||||
", subscribe_cycle_for_alarm=#{subscribeCycleForAlarm}, ssrc_check=#{ssrcCheck}, as_message_channel=#{asMessageChannel}" +
|
||||
", ip=#{ip}, sdp_ip=#{sdpIp}, port=#{port}, charset=#{charset}" +
|
||||
", ssrc_check=#{ssrcCheck}, as_message_channel=#{asMessageChannel}" +
|
||||
", broadcast_push_after_ack=#{broadcastPushAfterAck}, geo_coord_sys=#{geoCoordSys}, media_server_id=#{mediaServerId}" +
|
||||
" WHERE id=#{id}"+
|
||||
" </script>"})
|
||||
@@ -391,4 +390,17 @@ public interface DeviceMapper {
|
||||
@Select("select wd.* from wvp_device wd left join wvp_device_channel wdc on wdc.data_type = #{dataType} and wd.id = wdc.data_device_id where wdc.device_id = #{channelDeviceId}")
|
||||
Device getDeviceBySourceChannelDeviceId(@Param("dataType") Integer dataType, @Param("channelDeviceId") String channelDeviceId);
|
||||
|
||||
@Update(value = {" <script>" +
|
||||
" UPDATE wvp_device " +
|
||||
" SET subscribe_cycle_for_catalog=#{subscribeCycleForCatalog}" +
|
||||
" WHERE id=#{id}"+
|
||||
" </script>"})
|
||||
void updateSubscribeCatalog(Device device);
|
||||
|
||||
@Update(value = {" <script>" +
|
||||
"UPDATE wvp_device " +
|
||||
"SET subscribe_cycle_for_mobile_position=#{subscribeCycleForMobilePosition}, mobile_position_submission_interval=#{mobilePositionSubmissionInterval}" +
|
||||
" WHERE id=#{id}"+
|
||||
" </script>"})
|
||||
void updateSubscribeMobilePosition(Device device);
|
||||
}
|
||||
|
||||
@@ -128,4 +128,5 @@ public interface IDeviceChannelService {
|
||||
void queryRecordInfo(Device device, DeviceChannel channel, String startTime, String endTime, ErrorCallback<RecordInfo> object);
|
||||
|
||||
void queryRecordInfo(CommonGBChannel channel, String startTime, String endTime, ErrorCallback<RecordInfo> object);
|
||||
|
||||
}
|
||||
|
||||
@@ -160,4 +160,9 @@ public interface IDeviceService {
|
||||
Device getDeviceByChannelId(Integer channelId);
|
||||
|
||||
Device getDeviceBySourceChannelDeviceId(String requesterId);
|
||||
|
||||
void subscribeCatalog(int id, int cycle);
|
||||
|
||||
void subscribeMobilePosition(int id, int cycle, int interval);
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||
import com.genersoft.iot.vmp.gb28181.dao.DeviceChannelMapper;
|
||||
import com.genersoft.iot.vmp.gb28181.dao.DeviceMapper;
|
||||
import com.genersoft.iot.vmp.gb28181.dao.PlatformChannelMapper;
|
||||
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.session.AudioBroadcastManager;
|
||||
@@ -38,6 +37,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import javax.sip.InvalidArgumentException;
|
||||
import javax.sip.SipException;
|
||||
@@ -269,6 +269,9 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
@Override
|
||||
public boolean removeCatalogSubscribe(Device device, CommonCallback<Boolean> callback) {
|
||||
if (device == null || device.getSubscribeCycleForCatalog() < 0) {
|
||||
if (callback != null) {
|
||||
callback.run(false);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
log.info("[移除目录订阅]: {}", device.getDeviceId());
|
||||
@@ -278,6 +281,16 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
if (runnable instanceof ISubscribeTask) {
|
||||
ISubscribeTask subscribeTask = (ISubscribeTask) runnable;
|
||||
subscribeTask.stop(callback);
|
||||
}else {
|
||||
log.info("[移除目录订阅]失败,未找到订阅任务 : {}", device.getDeviceId());
|
||||
if (callback != null) {
|
||||
callback.run(false);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
log.info("[移除移动位置订阅]失败,设备已经离线 : {}", device.getDeviceId());
|
||||
if (callback != null) {
|
||||
callback.run(false);
|
||||
}
|
||||
}
|
||||
dynamicTask.stop(taskKey);
|
||||
@@ -303,6 +316,9 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
@Override
|
||||
public boolean removeMobilePositionSubscribe(Device device, CommonCallback<Boolean> callback) {
|
||||
if (device == null || device.getSubscribeCycleForCatalog() < 0) {
|
||||
if (callback != null) {
|
||||
callback.run(false);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
log.info("[移除移动位置订阅]: {}", device.getDeviceId());
|
||||
@@ -312,6 +328,16 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
if (runnable instanceof ISubscribeTask) {
|
||||
ISubscribeTask subscribeTask = (ISubscribeTask) runnable;
|
||||
subscribeTask.stop(callback);
|
||||
}else {
|
||||
log.info("[移除移动位置订阅]失败,未找到订阅任务 : {}", device.getDeviceId());
|
||||
if (callback != null) {
|
||||
callback.run(false);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
log.info("[移除移动位置订阅]失败,设备已经离线 : {}", device.getDeviceId());
|
||||
if (callback != null) {
|
||||
callback.run(false);
|
||||
}
|
||||
}
|
||||
dynamicTask.stop(taskKey);
|
||||
@@ -427,64 +453,12 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
|
||||
@Override
|
||||
public void updateCustomDevice(Device device) {
|
||||
// 订阅状态的修改使用一个单独方法控制,此处不再进行状态修改
|
||||
Device deviceInStore = deviceMapper.query(device.getId());
|
||||
if (deviceInStore == null) {
|
||||
log.warn("更新设备时未找到设备信息");
|
||||
return;
|
||||
}
|
||||
// 目录订阅相关的信息
|
||||
if (deviceInStore.getSubscribeCycleForCatalog() != device.getSubscribeCycleForCatalog()) {
|
||||
if (device.getSubscribeCycleForCatalog() > 0) {
|
||||
// 若已开启订阅,但订阅周期不同,则先取消
|
||||
if (deviceInStore.getSubscribeCycleForCatalog() != 0) {
|
||||
removeCatalogSubscribe(deviceInStore, result->{
|
||||
// 开启订阅
|
||||
deviceInStore.setSubscribeCycleForCatalog(device.getSubscribeCycleForCatalog());
|
||||
addCatalogSubscribe(deviceInStore);
|
||||
// 因为是异步执行,需要在这里更新下数据
|
||||
deviceMapper.updateCustom(deviceInStore);
|
||||
redisCatchStorage.updateDevice(deviceInStore);
|
||||
});
|
||||
}else {
|
||||
// 开启订阅
|
||||
deviceInStore.setSubscribeCycleForCatalog(device.getSubscribeCycleForCatalog());
|
||||
addCatalogSubscribe(deviceInStore);
|
||||
}
|
||||
|
||||
}else if (device.getSubscribeCycleForCatalog() == 0) {
|
||||
// 取消订阅
|
||||
deviceInStore.setSubscribeCycleForCatalog(0);
|
||||
removeCatalogSubscribe(deviceInStore, null);
|
||||
}
|
||||
}
|
||||
// 移动位置订阅相关的信息
|
||||
if (deviceInStore.getSubscribeCycleForMobilePosition() != device.getSubscribeCycleForMobilePosition()) {
|
||||
if (device.getSubscribeCycleForMobilePosition() > 0) {
|
||||
// 若已开启订阅,但订阅周期不同,则先取消
|
||||
if (deviceInStore.getSubscribeCycleForMobilePosition() != 0) {
|
||||
removeMobilePositionSubscribe(deviceInStore, result->{
|
||||
// 开启订阅
|
||||
deviceInStore.setSubscribeCycleForMobilePosition(device.getSubscribeCycleForMobilePosition());
|
||||
deviceInStore.setMobilePositionSubmissionInterval(device.getMobilePositionSubmissionInterval());
|
||||
addMobilePositionSubscribe(deviceInStore);
|
||||
// 因为是异步执行,需要在这里更新下数据
|
||||
deviceMapper.updateCustom(deviceInStore);
|
||||
redisCatchStorage.updateDevice(deviceInStore);
|
||||
});
|
||||
}else {
|
||||
// 开启订阅
|
||||
deviceInStore.setSubscribeCycleForMobilePosition(device.getSubscribeCycleForMobilePosition());
|
||||
deviceInStore.setMobilePositionSubmissionInterval(device.getMobilePositionSubmissionInterval());
|
||||
addMobilePositionSubscribe(deviceInStore);
|
||||
}
|
||||
|
||||
}else if (device.getSubscribeCycleForMobilePosition() == 0) {
|
||||
// 取消订阅
|
||||
deviceInStore.setSubscribeCycleForMobilePosition(0);
|
||||
deviceInStore.setMobilePositionSubmissionInterval(0);
|
||||
removeMobilePositionSubscribe(deviceInStore, null);
|
||||
}
|
||||
}
|
||||
if (deviceInStore.getGeoCoordSys() != null) {
|
||||
// 坐标系变化,需要重新计算GCJ02坐标和WGS84坐标
|
||||
if (!deviceInStore.getGeoCoordSys().equals(device.getGeoCoordSys())) {
|
||||
@@ -553,4 +527,68 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
public Device getDeviceBySourceChannelDeviceId(String channelId) {
|
||||
return deviceMapper.getDeviceBySourceChannelDeviceId(ChannelDataType.GB28181.value,channelId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subscribeCatalog(int id, int cycle) {
|
||||
Device device = deviceMapper.query(id);
|
||||
Assert.notNull(device, "未找到设备");
|
||||
if (device.getSubscribeCycleForCatalog() == cycle) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 目录订阅相关的信息
|
||||
if (device.getSubscribeCycleForCatalog() > 0) {
|
||||
// 订阅周期不同,则先取消
|
||||
removeCatalogSubscribe(device, result->{
|
||||
device.setSubscribeCycleForCatalog(cycle);
|
||||
if (cycle > 0) {
|
||||
// 开启订阅
|
||||
addCatalogSubscribe(device);
|
||||
}
|
||||
// 因为是异步执行,需要在这里更新下数据
|
||||
deviceMapper.updateSubscribeCatalog(device);
|
||||
redisCatchStorage.updateDevice(device);
|
||||
});
|
||||
}else {
|
||||
// 开启订阅
|
||||
device.setSubscribeCycleForCatalog(cycle);
|
||||
addCatalogSubscribe(device);
|
||||
deviceMapper.updateSubscribeCatalog(device);
|
||||
redisCatchStorage.updateDevice(device);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subscribeMobilePosition(int id, int cycle, int interval) {
|
||||
Device device = deviceMapper.query(id);
|
||||
Assert.notNull(device, "未找到设备");
|
||||
if (device.getSubscribeCycleForMobilePosition() == cycle) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 目录订阅相关的信息
|
||||
if (device.getSubscribeCycleForMobilePosition() > 0) {
|
||||
// 订阅周期已经开启,则先取消
|
||||
removeMobilePositionSubscribe(device, result->{
|
||||
// 开启订阅
|
||||
device.setSubscribeCycleForMobilePosition(cycle);
|
||||
device.setMobilePositionSubmissionInterval(interval);
|
||||
if (cycle > 0) {
|
||||
addMobilePositionSubscribe(device);
|
||||
}
|
||||
// 因为是异步执行,需要在这里更新下数据
|
||||
deviceMapper.updateSubscribeMobilePosition(device);
|
||||
redisCatchStorage.updateDevice(device);
|
||||
});
|
||||
}else {
|
||||
// 订阅未开启
|
||||
device.setSubscribeCycleForMobilePosition(cycle);
|
||||
device.setMobilePositionSubmissionInterval(interval);
|
||||
// 开启订阅
|
||||
addMobilePositionSubscribe(device);
|
||||
// 因为是异步执行,需要在这里更新下数据
|
||||
deviceMapper.updateSubscribeMobilePosition(device);
|
||||
redisCatchStorage.updateDevice(device);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user