临时提交

pull/1642/head
panlinlin 2024-08-11 23:20:42 +08:00
parent 76a0d248ef
commit 0177831e86
36 changed files with 334 additions and 194 deletions

View File

@ -99,7 +99,7 @@ public class AlarmController {
@Operation(summary = "测试向上级/设备发送模拟报警通知", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Operation(summary = "测试向上级/设备发送模拟报警通知", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "deviceId", description = "设备国标编号") @Parameter(name = "deviceId", description = "设备国标编号")
public void delete(@RequestParam String deviceId) { public void delete(@RequestParam String deviceId) {
Device device = deviceService.getDevice(deviceId); Device device = deviceService.getDeviceByDeviceId(deviceId);
Platform platform = storage.queryParentPlatByServerGBId(deviceId); Platform platform = storage.queryParentPlatByServerGBId(deviceId);
DeviceAlarm deviceAlarm = new DeviceAlarm(); DeviceAlarm deviceAlarm = new DeviceAlarm();
deviceAlarm.setChannelId(deviceId); deviceAlarm.setChannelId(deviceId);

View File

@ -77,7 +77,7 @@ public class DeviceConfig {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("报警复位API调用"); log.debug("报警复位API调用");
} }
Device device = deviceService.getDevice(deviceId); Device device = deviceService.getDeviceByDeviceId(deviceId);
String uuid = UUID.randomUUID().toString(); String uuid = UUID.randomUUID().toString();
String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONFIG + deviceId + channelId; String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONFIG + deviceId + channelId;
try { try {
@ -130,7 +130,7 @@ public class DeviceConfig {
} }
String key = DeferredResultHolder.CALLBACK_CMD_CONFIGDOWNLOAD + (ObjectUtils.isEmpty(channelId) ? deviceId : channelId); String key = DeferredResultHolder.CALLBACK_CMD_CONFIGDOWNLOAD + (ObjectUtils.isEmpty(channelId) ? deviceId : channelId);
String uuid = UUID.randomUUID().toString(); String uuid = UUID.randomUUID().toString();
Device device = deviceService.getDevice(deviceId); Device device = deviceService.getDeviceByDeviceId(deviceId);
try { try {
cmder.deviceConfigQuery(device, channelId, configType, event -> { cmder.deviceConfigQuery(device, channelId, configType, event -> {
RequestMessage msg = new RequestMessage(); RequestMessage msg = new RequestMessage();

View File

@ -59,7 +59,7 @@ public class DeviceControl {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("设备远程启动API调用"); log.debug("设备远程启动API调用");
} }
Device device = deviceService.getDevice(deviceId); Device device = deviceService.getDeviceByDeviceId(deviceId);
try { try {
cmder.teleBootCmd(device); cmder.teleBootCmd(device);
} catch (InvalidArgumentException | SipException | ParseException e) { } catch (InvalidArgumentException | SipException | ParseException e) {
@ -85,7 +85,7 @@ public class DeviceControl {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("开始/停止录像API调用"); log.debug("开始/停止录像API调用");
} }
Device device = deviceService.getDevice(deviceId); Device device = deviceService.getDeviceByDeviceId(deviceId);
String uuid = UUID.randomUUID().toString(); String uuid = UUID.randomUUID().toString();
String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + deviceId + channelId; String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + deviceId + channelId;
DeferredResult<ResponseEntity<String>> result = new DeferredResult<ResponseEntity<String>>(3 * 1000L); DeferredResult<ResponseEntity<String>> result = new DeferredResult<ResponseEntity<String>>(3 * 1000L);
@ -132,7 +132,7 @@ public class DeviceControl {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("布防/撤防API调用"); log.debug("布防/撤防API调用");
} }
Device device = deviceService.getDevice(deviceId); Device device = deviceService.getDeviceByDeviceId(deviceId);
String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + deviceId + deviceId; String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + deviceId + deviceId;
String uuid =UUID.randomUUID().toString(); String uuid =UUID.randomUUID().toString();
try { try {
@ -181,7 +181,7 @@ public class DeviceControl {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("报警复位API调用"); log.debug("报警复位API调用");
} }
Device device = deviceService.getDevice(deviceId); Device device = deviceService.getDeviceByDeviceId(deviceId);
String uuid = UUID.randomUUID().toString(); String uuid = UUID.randomUUID().toString();
String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + deviceId + channelId; String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + deviceId + channelId;
try { try {
@ -225,7 +225,7 @@ public class DeviceControl {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("强制关键帧API调用"); log.debug("强制关键帧API调用");
} }
Device device = deviceService.getDevice(deviceId); Device device = deviceService.getDeviceByDeviceId(deviceId);
try { try {
cmder.iFrameCmd(device, channelId); cmder.iFrameCmd(device, channelId);
} catch (InvalidArgumentException | SipException | ParseException e) { } catch (InvalidArgumentException | SipException | ParseException e) {
@ -263,7 +263,7 @@ public class DeviceControl {
} }
String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + (ObjectUtils.isEmpty(channelId) ? deviceId : channelId); String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + (ObjectUtils.isEmpty(channelId) ? deviceId : channelId);
String uuid = UUID.randomUUID().toString(); String uuid = UUID.randomUUID().toString();
Device device = deviceService.getDevice(deviceId); Device device = deviceService.getDeviceByDeviceId(deviceId);
try { try {
cmder.homePositionCmd(device, channelId, enabled, resetTime, presetIndex, event -> { cmder.homePositionCmd(device, channelId, enabled, resetTime, presetIndex, event -> {
RequestMessage msg = new RequestMessage(); RequestMessage msg = new RequestMessage();
@ -326,7 +326,7 @@ public class DeviceControl {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug(String.format("设备拉框放大 API调用deviceId%s channelId%s length%d width%d midpointx%d midpointy%d lengthx%d lengthy%d",deviceId, channelId, length, width, midpointx, midpointy,lengthx, lengthy)); log.debug(String.format("设备拉框放大 API调用deviceId%s channelId%s length%d width%d midpointx%d midpointy%d lengthx%d lengthy%d",deviceId, channelId, length, width, midpointx, midpointy,lengthx, lengthy));
} }
Device device = deviceService.getDevice(deviceId); Device device = deviceService.getDeviceByDeviceId(deviceId);
StringBuffer cmdXml = new StringBuffer(200); StringBuffer cmdXml = new StringBuffer(200);
cmdXml.append("<DragZoomIn>\r\n"); cmdXml.append("<DragZoomIn>\r\n");
cmdXml.append("<Length>" + length+ "</Length>\r\n"); cmdXml.append("<Length>" + length+ "</Length>\r\n");
@ -378,7 +378,7 @@ public class DeviceControl {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug(String.format("设备拉框缩小 API调用deviceId%s channelId%s length%d width%d midpointx%d midpointy%d lengthx%d lengthy%d",deviceId, channelId, length, width, midpointx, midpointy,lengthx, lengthy)); log.debug(String.format("设备拉框缩小 API调用deviceId%s channelId%s length%d width%d midpointx%d midpointy%d lengthx%d lengthy%d",deviceId, channelId, length, width, midpointx, midpointy,lengthx, lengthy));
} }
Device device = deviceService.getDevice(deviceId); Device device = deviceService.getDeviceByDeviceId(deviceId);
StringBuffer cmdXml = new StringBuffer(200); StringBuffer cmdXml = new StringBuffer(200);
cmdXml.append("<DragZoomOut>\r\n"); cmdXml.append("<DragZoomOut>\r\n");
cmdXml.append("<Length>" + length+ "</Length>\r\n"); cmdXml.append("<Length>" + length+ "</Length>\r\n");

View File

@ -91,7 +91,7 @@ public class DeviceQuery {
@GetMapping("/devices/{deviceId}") @GetMapping("/devices/{deviceId}")
public Device devices(@PathVariable String deviceId){ public Device devices(@PathVariable String deviceId){
return deviceService.getDevice(deviceId); return deviceService.getDeviceByDeviceId(deviceId);
} }
/** /**
@ -148,7 +148,7 @@ public class DeviceQuery {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("设备通道信息同步API调用deviceId" + deviceId); log.debug("设备通道信息同步API调用deviceId" + deviceId);
} }
Device device = deviceService.getDevice(deviceId); Device device = deviceService.getDeviceByDeviceId(deviceId);
boolean status = deviceService.isSyncRunning(deviceId); boolean status = deviceService.isSyncRunning(deviceId);
// 已存在则返回进度 // 已存在则返回进度
if (status) { if (status) {
@ -273,7 +273,7 @@ public class DeviceQuery {
"UDPudp传输TCP-ACTIVEtcp主动模式,暂不支持TCP-PASSIVEtcp被动模式", required = true) "UDPudp传输TCP-ACTIVEtcp主动模式,暂不支持TCP-PASSIVEtcp被动模式", required = true)
@PostMapping("/transport/{deviceId}/{streamMode}") @PostMapping("/transport/{deviceId}/{streamMode}")
public void updateTransport(@PathVariable String deviceId, @PathVariable String streamMode){ public void updateTransport(@PathVariable String deviceId, @PathVariable String streamMode){
Device device = deviceService.getDevice(deviceId); Device device = deviceService.getDeviceByDeviceId(deviceId);
device.setStreamMode(streamMode); device.setStreamMode(streamMode);
deviceService.updateCustomDevice(device); deviceService.updateCustomDevice(device);
} }
@ -330,7 +330,7 @@ public class DeviceQuery {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("设备状态查询API调用"); log.debug("设备状态查询API调用");
} }
Device device = deviceService.getDevice(deviceId); Device device = deviceService.getDeviceByDeviceId(deviceId);
String uuid = UUID.randomUUID().toString(); String uuid = UUID.randomUUID().toString();
String key = DeferredResultHolder.CALLBACK_CMD_DEVICESTATUS + deviceId; String key = DeferredResultHolder.CALLBACK_CMD_DEVICESTATUS + deviceId;
DeferredResult<ResponseEntity<String>> result = new DeferredResult<ResponseEntity<String>>(2*1000L); DeferredResult<ResponseEntity<String>> result = new DeferredResult<ResponseEntity<String>>(2*1000L);
@ -393,7 +393,7 @@ public class DeviceQuery {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("设备报警查询API调用"); log.debug("设备报警查询API调用");
} }
Device device = deviceService.getDevice(deviceId); Device device = deviceService.getDeviceByDeviceId(deviceId);
String key = DeferredResultHolder.CALLBACK_CMD_ALARM + deviceId; String key = DeferredResultHolder.CALLBACK_CMD_ALARM + deviceId;
String uuid = UUID.randomUUID().toString(); String uuid = UUID.randomUUID().toString();
try { try {

View File

@ -83,7 +83,7 @@ public class GBRecordController {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "endTime格式为" + DateUtil.PATTERN); throw new ControllerException(ErrorCode.ERROR100.getCode(), "endTime格式为" + DateUtil.PATTERN);
} }
Device device = deviceService.getDevice(deviceId); Device device = deviceService.getDeviceByDeviceId(deviceId);
// 指定超时时间 1分钟30秒 // 指定超时时间 1分钟30秒
String uuid = UUID.randomUUID().toString(); String uuid = UUID.randomUUID().toString();
int sn = (int)((Math.random()*9+1)*100000); int sn = (int)((Math.random()*9+1)*100000);
@ -182,7 +182,7 @@ public class GBRecordController {
throw new ControllerException(ErrorCode.ERROR400); throw new ControllerException(ErrorCode.ERROR400);
} }
Device device = deviceService.getDevice(deviceId); Device device = deviceService.getDeviceByDeviceId(deviceId);
if (device == null) { if (device == null) {
throw new ControllerException(ErrorCode.ERROR400.getCode(), "设备:" + deviceId + "未找到"); throw new ControllerException(ErrorCode.ERROR400.getCode(), "设备:" + deviceId + "未找到");
} }

View File

@ -99,7 +99,7 @@ public class MobilePositionController {
@Parameter(name = "deviceId", description = "设备国标编号", required = true) @Parameter(name = "deviceId", description = "设备国标编号", required = true)
@GetMapping("/realtime/{deviceId}") @GetMapping("/realtime/{deviceId}")
public DeferredResult<MobilePosition> realTimePosition(@PathVariable String deviceId) { public DeferredResult<MobilePosition> realTimePosition(@PathVariable String deviceId) {
Device device = deviceService.getDevice(deviceId); Device device = deviceService.getDeviceByDeviceId(deviceId);
String uuid = UUID.randomUUID().toString(); String uuid = UUID.randomUUID().toString();
String key = DeferredResultHolder.CALLBACK_CMD_MOBILE_POSITION + deviceId; String key = DeferredResultHolder.CALLBACK_CMD_MOBILE_POSITION + deviceId;
try { try {
@ -147,7 +147,7 @@ public class MobilePositionController {
if (StringUtil.isEmpty(interval)) { if (StringUtil.isEmpty(interval)) {
interval = "5"; interval = "5";
} }
Device device = deviceService.getDevice(deviceId); Device device = deviceService.getDeviceByDeviceId(deviceId);
device.setSubscribeCycleForMobilePosition(Integer.parseInt(expires)); device.setSubscribeCycleForMobilePosition(Integer.parseInt(expires));
device.setMobilePositionSubmissionInterval(Integer.parseInt(interval)); device.setMobilePositionSubmissionInterval(Integer.parseInt(interval));
deviceService.updateCustomDevice(device); deviceService.updateCustomDevice(device);

View File

@ -94,7 +94,7 @@ public class PlayController {
Assert.notNull(deviceId, "设备国标编号不可为NULL"); Assert.notNull(deviceId, "设备国标编号不可为NULL");
Assert.notNull(channelId, "通道国标编号不可为NULL"); Assert.notNull(channelId, "通道国标编号不可为NULL");
// 获取可用的zlm // 获取可用的zlm
Device device = deviceService.getDevice(deviceId); Device device = deviceService.getDeviceByDeviceId(deviceId);
MediaServer newMediaServerItem = playService.getNewMediaServerItem(device); MediaServer newMediaServerItem = playService.getNewMediaServerItem(device);
RequestMessage requestMessage = new RequestMessage(); RequestMessage requestMessage = new RequestMessage();
@ -169,7 +169,7 @@ public class PlayController {
throw new ControllerException(ErrorCode.ERROR400); throw new ControllerException(ErrorCode.ERROR400);
} }
Device device = deviceService.getDevice(deviceId); Device device = deviceService.getDeviceByDeviceId(deviceId);
if (device == null) { if (device == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "设备[" + deviceId + "]不存在"); throw new ControllerException(ErrorCode.ERROR100.getCode(), "设备[" + deviceId + "]不存在");
} }
@ -212,7 +212,7 @@ public class PlayController {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("语音广播API调用"); log.debug("语音广播API调用");
} }
Device device = deviceService.getDevice(deviceId); Device device = deviceService.getDeviceByDeviceId(deviceId);
if (device == null) { if (device == null) {
throw new ControllerException(ErrorCode.ERROR400.getCode(), "未找到设备: " + deviceId); throw new ControllerException(ErrorCode.ERROR400.getCode(), "未找到设备: " + deviceId);
} }

View File

@ -140,7 +140,7 @@ public class PlaybackController {
if (ObjectUtils.isEmpty(deviceId) || ObjectUtils.isEmpty(channelId) || ObjectUtils.isEmpty(stream)) { if (ObjectUtils.isEmpty(deviceId) || ObjectUtils.isEmpty(channelId) || ObjectUtils.isEmpty(stream)) {
throw new ControllerException(ErrorCode.ERROR400); throw new ControllerException(ErrorCode.ERROR400);
} }
Device device = deviceService.getDevice(deviceId); Device device = deviceService.getDeviceByDeviceId(deviceId);
if (device == null) { if (device == null) {
throw new ControllerException(ErrorCode.ERROR400.getCode(), "设备:" + deviceId + " 未找到"); throw new ControllerException(ErrorCode.ERROR400.getCode(), "设备:" + deviceId + " 未找到");
} }
@ -195,7 +195,7 @@ public class PlaybackController {
log.warn("streamId不存在!"); log.warn("streamId不存在!");
throw new ControllerException(ErrorCode.ERROR400.getCode(), "streamId不存在"); throw new ControllerException(ErrorCode.ERROR400.getCode(), "streamId不存在");
} }
Device device = deviceService.getDevice(inviteInfo.getDeviceId()); Device device = deviceService.getDeviceByDeviceId(inviteInfo.getDeviceId());
try { try {
cmder.playSeekCmd(device, inviteInfo.getStreamInfo(), seekTime); cmder.playSeekCmd(device, inviteInfo.getStreamInfo(), seekTime);
} catch (InvalidArgumentException | ParseException | SipException e) { } catch (InvalidArgumentException | ParseException | SipException e) {
@ -219,7 +219,7 @@ public class PlaybackController {
log.warn("不支持的speed " + speed); log.warn("不支持的speed " + speed);
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持的speed0.25 0.5 1、2、4"); throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持的speed0.25 0.5 1、2、4");
} }
Device device = deviceService.getDevice(inviteInfo.getDeviceId()); Device device = deviceService.getDeviceByDeviceId(inviteInfo.getDeviceId());
try { try {
cmder.playSpeedCmd(device, inviteInfo.getStreamInfo(), speed); cmder.playSpeedCmd(device, inviteInfo.getStreamInfo(), speed);
} catch (InvalidArgumentException | ParseException | SipException e) { } catch (InvalidArgumentException | ParseException | SipException e) {

View File

@ -66,7 +66,7 @@ public class PtzController {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug(String.format("设备云台控制 API调用deviceId%s channelId%s command%s horizonSpeed%d verticalSpeed%d zoomSpeed%d",deviceId, channelId, command, horizonSpeed, verticalSpeed, zoomSpeed)); log.debug(String.format("设备云台控制 API调用deviceId%s channelId%s command%s horizonSpeed%d verticalSpeed%d zoomSpeed%d",deviceId, channelId, command, horizonSpeed, verticalSpeed, zoomSpeed));
} }
Device device = deviceService.getDevice(deviceId); Device device = deviceService.getDeviceByDeviceId(deviceId);
int cmdCode = 0; int cmdCode = 0;
switch (command){ switch (command){
case "left": case "left":
@ -129,7 +129,7 @@ public class PtzController {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug(String.format("设备云台控制 API调用deviceId%s channelId%s cmdCode%d parameter1%d parameter2%d",deviceId, channelId, cmdCode, parameter1, parameter2)); log.debug(String.format("设备云台控制 API调用deviceId%s channelId%s cmdCode%d parameter1%d parameter2%d",deviceId, channelId, cmdCode, parameter1, parameter2));
} }
Device device = deviceService.getDevice(deviceId); Device device = deviceService.getDeviceByDeviceId(deviceId);
try { try {
cmder.frontEndCmd(device, channelId, cmdCode, parameter1, parameter2, combindCode2); cmder.frontEndCmd(device, channelId, cmdCode, parameter1, parameter2, combindCode2);
@ -148,7 +148,7 @@ public class PtzController {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("设备预置位查询API调用"); log.debug("设备预置位查询API调用");
} }
Device device = deviceService.getDevice(deviceId); Device device = deviceService.getDeviceByDeviceId(deviceId);
String uuid = UUID.randomUUID().toString(); String uuid = UUID.randomUUID().toString();
String key = DeferredResultHolder.CALLBACK_CMD_PRESETQUERY + (ObjectUtils.isEmpty(channelId) ? deviceId : channelId); String key = DeferredResultHolder.CALLBACK_CMD_PRESETQUERY + (ObjectUtils.isEmpty(channelId) ? deviceId : channelId);
DeferredResult<String> result = new DeferredResult<String> (3 * 1000L); DeferredResult<String> result = new DeferredResult<String> (3 * 1000L);

View File

@ -456,4 +456,100 @@ public interface CommonGBChannelMapper {
"</foreach>" + "</foreach>" +
"</script>"}) "</script>"})
int batchUpdate(List<CommonGBChannel> commonGBChannels); int batchUpdate(List<CommonGBChannel> commonGBChannels);
@Select("select\n" +
" wdc.id as gb_id,\n" +
" wdc.device_db_id as gb_device_db_id,\n" +
" wdc.stream_push_id,\n" +
" wdc.stream_proxy_id,\n" +
" wdc.create_time,\n" +
" wdc.update_time,\n" +
" coalesce(wpgc.device_id, wdc.gb_device_id, wdc.device_id) as gb_device_id,\n" +
" coalesce(wpgc.name, wdc.gb_name, wdc.name) as gb_name,\n" +
" coalesce(wdc.gb_manufacturer, wdc.manufacturer) as gb_manufacturer,\n" +
" coalesce(wdc.gb_model, wdc.model) as gb_model,\n" +
" coalesce(wdc.gb_owner, wdc.owner) as gb_owner,\n" +
" coalesce(wpgc.civil_code, wdc.gb_civil_code, wdc.civil_code),\n" +
" coalesce(wdc.gb_block, wdc.block) as gb_block,\n" +
" coalesce(wdc.gb_address, wdc.address) as gb_address,\n" +
" coalesce(wdc.gb_parental, wdc.parental) as gb_parental,\n" +
" coalesce(wpgc.parent_id, wdc.gb_parent_id, wdc.parent_id) as gb_parent_id,\n" +
" coalesce(wdc.gb_safety_way, wdc.safety_way) as gb_safety_way,\n" +
" coalesce(wdc.gb_register_way, wdc.register_way) as gb_register_way,\n" +
" coalesce(wdc.gb_cert_num, wdc.cert_num) as gb_cert_num,\n" +
" coalesce(wdc.gb_certifiable, wdc.certifiable) as gb_certifiable,\n" +
" coalesce(wdc.gb_err_code, wdc.err_code) as gb_err_code,\n" +
" coalesce(wdc.gb_end_time, wdc.end_time) as gb_end_time,\n" +
" coalesce(wdc.gb_secrecy, wdc.secrecy) as gb_secrecy,\n" +
" coalesce(wdc.gb_ip_address, wdc.ip_address) as gb_ip_address,\n" +
" coalesce(wdc.gb_port, wdc.port) as gb_port,\n" +
" coalesce(wdc.gb_password, wdc.password) as gb_password,\n" +
" coalesce(wdc.gb_status, wdc.status) as gb_status,\n" +
" coalesce(wdc.gb_longitude, wdc.longitude) as gb_longitude,\n" +
" coalesce(wdc.gb_latitude, wdc.latitude) as gb_latitude,\n" +
" coalesce(wdc.gb_ptz_type, wdc.ptz_type) as gb_ptz_type,\n" +
" coalesce(wdc.gb_position_type, wdc.position_type) as gb_position_type,\n" +
" coalesce(wdc.gb_room_type, wdc.room_type) as gb_room_type,\n" +
" coalesce(wdc.gb_use_type, wdc.use_type) as gb_use_type,\n" +
" coalesce(wdc.gb_supply_light_type, wdc.supply_light_type) as gb_supply_light_type,\n" +
" coalesce(wdc.gb_direction_type, wdc.direction_type) as gb_direction_type,\n" +
" coalesce(wdc.gb_resolution, wdc.resolution) as gb_resolution,\n" +
" coalesce(wpgc.business_group_id, wdc.gb_business_group_id, wdc.business_group_id) as gb_business_group_id,\n" +
" coalesce(wdc.gb_download_speed, wdc.download_speed) as gb_download_speed,\n" +
" coalesce(wdc.gb_svc_space_support_mod, wdc.svc_space_support_mod) as gb_svc_space_support_mod,\n" +
" coalesce(wdc.gb_svc_time_support_mode, wdc.svc_time_support_mode) as gb_svc_time_support_mode\n" +
" from wvp_device_channel wdc" +
" left jon wvp_platform_gb_channel wpgc on wdc.id = wpgc.device_channel_id" +
" where wpgc.platform_id = #{platformId}"
)
List<CommonGBChannel> queryWithPlatform(@Param("platformId") Integer platformId);
@Select("select\n" +
" wdc.id as gb_id,\n" +
" wdc.device_db_id as gb_device_db_id,\n" +
" wdc.stream_push_id,\n" +
" wdc.stream_proxy_id,\n" +
" wdc.create_time,\n" +
" wdc.update_time,\n" +
" coalesce(wpgc.device_id, wdc.gb_device_id, wdc.device_id) as gb_device_id,\n" +
" coalesce(wpgc.name, wdc.gb_name, wdc.name) as gb_name,\n" +
" coalesce(wdc.gb_manufacturer, wdc.manufacturer) as gb_manufacturer,\n" +
" coalesce(wdc.gb_model, wdc.model) as gb_model,\n" +
" coalesce(wdc.gb_owner, wdc.owner) as gb_owner,\n" +
" coalesce(wpgc.civil_code, wdc.gb_civil_code, wdc.civil_code),\n" +
" coalesce(wdc.gb_block, wdc.block) as gb_block,\n" +
" coalesce(wdc.gb_address, wdc.address) as gb_address,\n" +
" coalesce(wdc.gb_parental, wdc.parental) as gb_parental,\n" +
" coalesce(wpgc.parent_id, wdc.gb_parent_id, wdc.parent_id) as gb_parent_id,\n" +
" coalesce(wdc.gb_safety_way, wdc.safety_way) as gb_safety_way,\n" +
" coalesce(wdc.gb_register_way, wdc.register_way) as gb_register_way,\n" +
" coalesce(wdc.gb_cert_num, wdc.cert_num) as gb_cert_num,\n" +
" coalesce(wdc.gb_certifiable, wdc.certifiable) as gb_certifiable,\n" +
" coalesce(wdc.gb_err_code, wdc.err_code) as gb_err_code,\n" +
" coalesce(wdc.gb_end_time, wdc.end_time) as gb_end_time,\n" +
" coalesce(wdc.gb_secrecy, wdc.secrecy) as gb_secrecy,\n" +
" coalesce(wdc.gb_ip_address, wdc.ip_address) as gb_ip_address,\n" +
" coalesce(wdc.gb_port, wdc.port) as gb_port,\n" +
" coalesce(wdc.gb_password, wdc.password) as gb_password,\n" +
" coalesce(wdc.gb_status, wdc.status) as gb_status,\n" +
" coalesce(wdc.gb_longitude, wdc.longitude) as gb_longitude,\n" +
" coalesce(wdc.gb_latitude, wdc.latitude) as gb_latitude,\n" +
" coalesce(wdc.gb_ptz_type, wdc.ptz_type) as gb_ptz_type,\n" +
" coalesce(wdc.gb_position_type, wdc.position_type) as gb_position_type,\n" +
" coalesce(wdc.gb_room_type, wdc.room_type) as gb_room_type,\n" +
" coalesce(wdc.gb_use_type, wdc.use_type) as gb_use_type,\n" +
" coalesce(wdc.gb_supply_light_type, wdc.supply_light_type) as gb_supply_light_type,\n" +
" coalesce(wdc.gb_direction_type, wdc.direction_type) as gb_direction_type,\n" +
" coalesce(wdc.gb_resolution, wdc.resolution) as gb_resolution,\n" +
" coalesce(wpgc.business_group_id, wdc.gb_business_group_id, wdc.business_group_id) as gb_business_group_id,\n" +
" coalesce(wdc.gb_download_speed, wdc.download_speed) as gb_download_speed,\n" +
" coalesce(wdc.gb_svc_space_support_mod, wdc.svc_space_support_mod) as gb_svc_space_support_mod,\n" +
" coalesce(wdc.gb_svc_time_support_mode, wdc.svc_time_support_mode) as gb_svc_time_support_mode\n" +
" from wvp_device_channel wdc" +
" left jon wvp_platform_gb_channel wpgc on wdc.id = wpgc.device_channel_id" +
" where wpgc.platform_id = #{platformId} and coalesce(wpgc.device_id, wdc.gb_device_id, wdc.device_id) = #{channelDeviceId}"
)
CommonGBChannel queryOneWithPlatform(@Param("platformId") Integer platformId, @Param("channelDeviceId") String channelDeviceId);
} }

View File

@ -347,4 +347,7 @@ public interface DeviceMapper {
@Select("select * from wvp_device_channel where id = #{id}") @Select("select * from wvp_device_channel where id = #{id}")
DeviceChannel getRawChannel(@Param("id") int id); DeviceChannel getRawChannel(@Param("id") int id);
@Select("select * from wvp_device where id = #{id}")
Device query(@Param("id") Integer id);
} }

View File

@ -1,5 +1,6 @@
package com.genersoft.iot.vmp.gb28181.dao; package com.genersoft.iot.vmp.gb28181.dao;
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
import com.genersoft.iot.vmp.gb28181.bean.Group; import com.genersoft.iot.vmp.gb28181.bean.Group;
import com.genersoft.iot.vmp.gb28181.bean.GroupTree; import com.genersoft.iot.vmp.gb28181.bean.GroupTree;
import com.genersoft.iot.vmp.gb28181.bean.Region; import com.genersoft.iot.vmp.gb28181.bean.Region;
@ -160,4 +161,14 @@ public interface GroupMapper {
" <foreach collection='groupList' item='item' open='(' separator=',' close=')' > #{item.deviceId}</foreach>" + " <foreach collection='groupList' item='item' open='(' separator=',' close=')' > #{item.deviceId}</foreach>" +
" </script>") " </script>")
List<Region> queryInGroupList(List<Group> groupList); List<Region> queryInGroupList(List<Group> groupList);
@Select(" <script>" +
" SELECT " +
" device_id as gb_device_id" +
" name as gb_name" +
" from wvp_common_group " +
" where (device_id, business_group) in " +
" <foreach collection='channelList' item='item' open='(' separator=',' close=')' > (#{item.gbParentId}, #{item.gbBusinessGroupId})</foreach>" +
" </script>")
List<CommonGBChannel> queryInChannelList(List<CommonGBChannel> channelList);
} }

View File

@ -1,5 +1,6 @@
package com.genersoft.iot.vmp.gb28181.dao; package com.genersoft.iot.vmp.gb28181.dao;
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
import com.genersoft.iot.vmp.gb28181.bean.Region; import com.genersoft.iot.vmp.gb28181.bean.Region;
import com.genersoft.iot.vmp.gb28181.bean.RegionTree; import com.genersoft.iot.vmp.gb28181.bean.RegionTree;
import org.apache.ibatis.annotations.*; import org.apache.ibatis.annotations.*;
@ -96,4 +97,14 @@ public interface RegionMapper {
" <foreach collection='regionList' item='item' open='(' separator=',' close=')' > #{item.deviceId}</foreach>" + " <foreach collection='regionList' item='item' open='(' separator=',' close=')' > #{item.deviceId}</foreach>" +
" </script>") " </script>")
List<Region> queryInRegionList(List<Region> regionList); List<Region> queryInRegionList(List<Region> regionList);
@Select(" <script>" +
" SELECT " +
" device_id as gb_device_id" +
" name as gb_name" +
" from wvp_common_region " +
" where device_id in " +
" <foreach collection='channelList' item='item' open='(' separator=',' close=')' > #{item.gbCivilCode}</foreach>" +
" </script>")
List<CommonGBChannel> queryInChannelList(List<CommonGBChannel> channelList);
} }

View File

@ -81,7 +81,7 @@ public interface IDeviceService {
* @param deviceId * @param deviceId
* @return * @return
*/ */
Device getDevice(String deviceId); Device getDeviceByDeviceId(String deviceId);
/** /**
* 线 * 线
@ -164,4 +164,7 @@ public interface IDeviceService {
List<Device> getAll(); List<Device> getAll();
PageInfo<Device> getAll(int page, int count, String query, Boolean status); PageInfo<Device> getAll(int page, int count, String query, Boolean status);
Device getDevice(Integer gbDeviceDbId);
} }

View File

@ -75,4 +75,6 @@ public interface IGbChannelService {
void deleteChannelToGroupByGbDevice(List<Integer> deviceIds); void deleteChannelToGroupByGbDevice(List<Integer> deviceIds);
void batchUpdate(List<CommonGBChannel> commonGBChannels); void batchUpdate(List<CommonGBChannel> commonGBChannels);
CommonGBChannel queryOneWithPlatform(Integer platformId, String channelDeviceId);
} }

View File

@ -1,5 +1,6 @@
package com.genersoft.iot.vmp.gb28181.service; package com.genersoft.iot.vmp.gb28181.service;
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.Platform; import com.genersoft.iot.vmp.gb28181.bean.Platform;
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
@ -79,7 +80,7 @@ public interface IPlatformService {
/** /**
* BYE * BYE
*/ */
void stopBroadcast(Platform platform, DeviceChannel channel, String stream, boolean sendBye, MediaServer mediaServerItem); void stopBroadcast(Platform platform, CommonGBChannel channel, String stream, boolean sendBye, MediaServer mediaServerItem);
void addSimulatedSubscribeInfo(Platform parentPlatform); void addSimulatedSubscribeInfo(Platform parentPlatform);

View File

@ -351,7 +351,7 @@ public class DeviceServiceImpl implements IDeviceService {
} }
@Override @Override
public Device getDevice(String deviceId) { public Device getDeviceByDeviceId(String deviceId) {
Device device = redisCatchStorage.getDevice(deviceId); Device device = redisCatchStorage.getDevice(deviceId);
if (device == null) { if (device == null) {
device = deviceMapper.getDeviceByDeviceId(deviceId); device = deviceMapper.getDeviceByDeviceId(deviceId);
@ -568,4 +568,9 @@ public class DeviceServiceImpl implements IDeviceService {
List<Device> all = deviceMapper.getDeviceList(query, status); List<Device> all = deviceMapper.getDeviceList(query, status);
return new PageInfo<>(all); return new PageInfo<>(all);
} }
@Override
public Device getDevice(Integer id) {
return deviceMapper.query(id);
}
} }

View File

@ -3,6 +3,8 @@ package com.genersoft.iot.vmp.gb28181.service.impl;
import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.dao.CommonGBChannelMapper; import com.genersoft.iot.vmp.gb28181.dao.CommonGBChannelMapper;
import com.genersoft.iot.vmp.gb28181.dao.GroupMapper;
import com.genersoft.iot.vmp.gb28181.dao.RegionMapper;
import com.genersoft.iot.vmp.gb28181.event.EventPublisher; import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
import com.genersoft.iot.vmp.gb28181.service.IGbChannelService; import com.genersoft.iot.vmp.gb28181.service.IGbChannelService;
@ -32,6 +34,12 @@ public class GbChannelServiceImpl implements IGbChannelService {
@Autowired @Autowired
private CommonGBChannelMapper commonGBChannelMapper; private CommonGBChannelMapper commonGBChannelMapper;
@Autowired
private RegionMapper regionMapper;
@Autowired
private GroupMapper groupMapper;
@Override @Override
public CommonGBChannel queryByDeviceId(String gbDeviceId) { public CommonGBChannel queryByDeviceId(String gbDeviceId) {
return commonGBChannelMapper.queryByDeviceId(gbDeviceId); return commonGBChannelMapper.queryByDeviceId(gbDeviceId);
@ -316,14 +324,19 @@ public class GbChannelServiceImpl implements IGbChannelService {
// 是否包含行政区划信息 // 是否包含行政区划信息
if (platform.getCatalogWithRegion()) { if (platform.getCatalogWithRegion()) {
List<CommonGBChannel> regionChannelList = regionMapper.queryInChannelList(commonGBChannelList);
if (!regionChannelList.isEmpty()) {
channelList.addAll(regionChannelList);
}
} }
// 是否包含分组信息 // 是否包含分组信息
if (platform.getCatalogWithGroup()) { if (platform.getCatalogWithGroup()) {
List<CommonGBChannel> groupChannelList = groupMapper.queryInChannelList(commonGBChannelList);
if (!groupChannelList.isEmpty()) {
channelList.addAll(groupChannelList);
}
} }
channelList.addAll(commonGBChannelList);
return channelList; return channelList;
} }
@ -619,4 +632,9 @@ public class GbChannelServiceImpl implements IGbChannelService {
} }
commonGBChannelMapper.removeParentIdByChannels(channelList); commonGBChannelMapper.removeParentIdByChannels(channelList);
} }
@Override
public CommonGBChannel queryOneWithPlatform(Integer platformId, String channelDeviceId) {
return commonGBChannelMapper.queryOneWithPlatform(platformId, channelDeviceId);
}
} }

View File

@ -165,7 +165,6 @@ public class PlatformServiceImpl implements IPlatformService {
// 每次发送目录的数量默认为1 // 每次发送目录的数量默认为1
parentPlatform.setCatalogGroup(1); parentPlatform.setCatalogGroup(1);
} }
parentPlatform.setCatalogId(parentPlatform.getDeviceGBId());
int result = platformMapper.addParentPlatform(parentPlatform); int result = platformMapper.addParentPlatform(parentPlatform);
// 添加缓存 // 添加缓存
PlatformCatch parentPlatformCatch = new PlatformCatch(); PlatformCatch parentPlatformCatch = new PlatformCatch();
@ -776,23 +775,23 @@ public class PlatformServiceImpl implements IPlatformService {
} }
@Override @Override
public void stopBroadcast(Platform platform, DeviceChannel channel, String stream, boolean sendBye, MediaServer mediaServerItem) { public void stopBroadcast(Platform platform, CommonGBChannel channel, String stream, boolean sendBye, MediaServer mediaServerItem) {
try { try {
if (sendBye) { if (sendBye) {
commanderForPlatform.streamByeCmd(platform, channel.getDeviceId(), stream, null, null); commanderForPlatform.streamByeCmd(platform, channel.getGbDeviceId(), stream, null, null);
} }
} catch (InvalidArgumentException | SipException | ParseException | SsrcTransactionNotFoundException e) { } catch (InvalidArgumentException | SipException | ParseException | SsrcTransactionNotFoundException e) {
log.warn("[消息发送失败] 停止语音对讲, 平台:{},通道:{}", platform.getId(), channel.getDeviceId() ); log.warn("[消息发送失败] 停止语音对讲, 平台:{},通道:{}", platform.getId(), channel.getGbDeviceId() );
} finally { } finally {
mediaServerService.closeRTPServer(mediaServerItem, stream); mediaServerService.closeRTPServer(mediaServerItem, stream);
InviteInfo inviteInfo = inviteStreamService.getInviteInfo(null, platform.getServerGBId(), channel.getDeviceId(), stream); InviteInfo inviteInfo = inviteStreamService.getInviteInfo(null, platform.getServerGBId(), channel.getGbDeviceId(), stream);
if (inviteInfo != null) { if (inviteInfo != null) {
// 释放ssrc // 释放ssrc
mediaServerService.releaseSsrc(mediaServerItem.getId(), inviteInfo.getSsrcInfo().getSsrc()); mediaServerService.releaseSsrc(mediaServerItem.getId(), inviteInfo.getSsrcInfo().getSsrc());
inviteStreamService.removeInviteInfo(inviteInfo); inviteStreamService.removeInviteInfo(inviteInfo);
} }
streamSession.remove(platform.getServerGBId(), channel.getDeviceId(), stream); streamSession.remove(platform.getServerGBId(), channel.getGbDeviceId(), stream);
} }
} }

View File

@ -130,7 +130,7 @@ public class PlayServiceImpl implements IPlayService {
if (streamArray.length == 2) { if (streamArray.length == 2) {
String deviceId = streamArray[0]; String deviceId = streamArray[0];
String channelId = streamArray[1]; String channelId = streamArray[1];
Device device = deviceService.getDevice(deviceId); Device device = deviceService.getDeviceByDeviceId(deviceId);
if (device == null) { if (device == null) {
log.info("[语音对讲/喊话] 未找到设备:{}", deviceId); log.info("[语音对讲/喊话] 未找到设备:{}", deviceId);
return; return;
@ -172,7 +172,7 @@ public class PlayServiceImpl implements IPlayService {
for (SendRtpItem sendRtpItem : sendRtpItems) { for (SendRtpItem sendRtpItem : sendRtpItems) {
if (sendRtpItem != null && sendRtpItem.getApp().equals(event.getApp())) { if (sendRtpItem != null && sendRtpItem.getApp().equals(event.getApp())) {
String platformId = sendRtpItem.getPlatformId(); String platformId = sendRtpItem.getPlatformId();
Device device = deviceService.getDevice(platformId); Device device = deviceService.getDeviceByDeviceId(platformId);
try { try {
if (device != null) { if (device != null) {
cmder.streamByeCmd(device, sendRtpItem.getChannelId(), event.getStream(), sendRtpItem.getCallId()); cmder.streamByeCmd(device, sendRtpItem.getChannelId(), event.getStream(), sendRtpItem.getCallId());
@ -200,7 +200,7 @@ public class PlayServiceImpl implements IPlayService {
if (streamArray.length == 2) { if (streamArray.length == 2) {
String deviceId = streamArray[0]; String deviceId = streamArray[0];
String channelId = streamArray[1]; String channelId = streamArray[1];
Device device = deviceService.getDevice(deviceId); Device device = deviceService.getDeviceByDeviceId(deviceId);
if (device == null) { if (device == null) {
log.info("[语音对讲/喊话] 未找到设备:{}", deviceId); log.info("[语音对讲/喊话] 未找到设备:{}", deviceId);
return; return;
@ -753,7 +753,7 @@ public class PlayServiceImpl implements IPlayService {
@Override @Override
public void playBack(String deviceId, String channelId, String startTime, public void playBack(String deviceId, String channelId, String startTime,
String endTime, ErrorCallback<Object> callback) { String endTime, ErrorCallback<Object> callback) {
Device device = deviceService.getDevice(deviceId); Device device = deviceService.getDeviceByDeviceId(deviceId);
if (device == null) { if (device == null) {
log.warn("[录像回放] 未找到设备 deviceId: {},channelId:{}", deviceId, channelId); log.warn("[录像回放] 未找到设备 deviceId: {},channelId:{}", deviceId, channelId);
throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到设备:" + deviceId); throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到设备:" + deviceId);
@ -793,7 +793,7 @@ public class PlayServiceImpl implements IPlayService {
return; return;
} }
Device device = deviceService.getDevice(deviceId); Device device = deviceService.getDeviceByDeviceId(deviceId);
if (device == null) { if (device == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "设备: " + deviceId + "不存在"); throw new ControllerException(ErrorCode.ERROR100.getCode(), "设备: " + deviceId + "不存在");
} }
@ -959,7 +959,7 @@ public class PlayServiceImpl implements IPlayService {
@Override @Override
public void download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, ErrorCallback<Object> callback) { public void download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, ErrorCallback<Object> callback) {
Device device = deviceService.getDevice(deviceId); Device device = deviceService.getDeviceByDeviceId(deviceId);
if (device == null) { if (device == null) {
return; return;
} }
@ -989,7 +989,7 @@ public class PlayServiceImpl implements IPlayService {
null); null);
return; return;
} }
Device device = deviceService.getDevice(deviceId); Device device = deviceService.getDeviceByDeviceId(deviceId);
if (device == null) { if (device == null) {
callback.run(InviteErrorCode.ERROR_FOR_PARAMETER_ERROR.getCode(), callback.run(InviteErrorCode.ERROR_FOR_PARAMETER_ERROR.getCode(),
"设备:" + deviceId + "不存在", "设备:" + deviceId + "不存在",
@ -1169,7 +1169,7 @@ public class PlayServiceImpl implements IPlayService {
if (allSsrc.size() > 0) { if (allSsrc.size() > 0) {
for (SsrcTransaction ssrcTransaction : allSsrc) { for (SsrcTransaction ssrcTransaction : allSsrc) {
if (ssrcTransaction.getMediaServerId().equals(mediaServerId)) { if (ssrcTransaction.getMediaServerId().equals(mediaServerId)) {
Device device = deviceService.getDevice(ssrcTransaction.getDeviceId()); Device device = deviceService.getDeviceByDeviceId(ssrcTransaction.getDeviceId());
if (device == null) { if (device == null) {
continue; continue;
} }
@ -1291,7 +1291,7 @@ public class PlayServiceImpl implements IPlayService {
} }
if (audioBroadcastCatchList.size() > 0) { if (audioBroadcastCatchList.size() > 0) {
for (AudioBroadcastCatch audioBroadcastCatch : audioBroadcastCatchList) { for (AudioBroadcastCatch audioBroadcastCatch : audioBroadcastCatchList) {
Device device = deviceService.getDevice(deviceId); Device device = deviceService.getDeviceByDeviceId(deviceId);
if (device == null || audioBroadcastCatch == null) { if (device == null || audioBroadcastCatch == null) {
return; return;
} }
@ -1390,7 +1390,7 @@ public class PlayServiceImpl implements IPlayService {
if (!result) { if (!result) {
throw new ServiceException("暂停RTP接收失败"); throw new ServiceException("暂停RTP接收失败");
} }
Device device = deviceService.getDevice(inviteInfo.getDeviceId()); Device device = deviceService.getDeviceByDeviceId(inviteInfo.getDeviceId());
cmder.playPauseCmd(device, inviteInfo.getStreamInfo()); cmder.playPauseCmd(device, inviteInfo.getStreamInfo());
} }
@ -1418,7 +1418,7 @@ public class PlayServiceImpl implements IPlayService {
if (!result) { if (!result) {
throw new ServiceException("继续RTP接收失败"); throw new ServiceException("继续RTP接收失败");
} }
Device device = deviceService.getDevice(inviteInfo.getDeviceId()); Device device = deviceService.getDeviceByDeviceId(inviteInfo.getDeviceId());
cmder.playResumeCmd(device, inviteInfo.getStreamInfo()); cmder.playResumeCmd(device, inviteInfo.getStreamInfo());
} }
@ -1450,7 +1450,7 @@ public class PlayServiceImpl implements IPlayService {
@Override @Override
public void startSendRtpStreamFailHand(SendRtpItem sendRtpItem, Platform platform, CallIdHeader callIdHeader) { public void startSendRtpStreamFailHand(SendRtpItem sendRtpItem, Platform platform, CallIdHeader callIdHeader) {
if (sendRtpItem.isOnlyAudio()) { if (sendRtpItem.isOnlyAudio()) {
Device device = deviceService.getDevice(sendRtpItem.getDeviceId()); Device device = deviceService.getDeviceByDeviceId(sendRtpItem.getDeviceId());
AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(sendRtpItem.getDeviceId(), sendRtpItem.getChannelId()); AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(sendRtpItem.getDeviceId(), sendRtpItem.getChannelId());
if (audioBroadcastCatch != null) { if (audioBroadcastCatch != null) {
try { try {
@ -1571,7 +1571,7 @@ public class PlayServiceImpl implements IPlayService {
@Override @Override
public void getSnap(String deviceId, String channelId, String fileName, ErrorCallback errorCallback) { public void getSnap(String deviceId, String channelId, String fileName, ErrorCallback errorCallback) {
Device device = deviceService.getDevice(deviceId); Device device = deviceService.getDeviceByDeviceId(deviceId);
if (device == null) { if (device == null) {
errorCallback.run(InviteErrorCode.ERROR_FOR_PARAMETER_ERROR.getCode(), InviteErrorCode.ERROR_FOR_PARAMETER_ERROR.getMsg(), null); errorCallback.run(InviteErrorCode.ERROR_FOR_PARAMETER_ERROR.getCode(), InviteErrorCode.ERROR_FOR_PARAMETER_ERROR.getMsg(), null);
return; return;

View File

@ -122,7 +122,7 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In
} }
} }
}else { }else {
Device device = deviceService.getDevice(fromUserId); Device device = deviceService.getDeviceByDeviceId(fromUserId);
if (device == null) { if (device == null) {
log.warn("[收到ACK]:来自{},目标为({})的推流信息为找到流体服务[{}]信息",fromUserId, toUserId, sendRtpItem.getMediaServerId()); log.warn("[收到ACK]:来自{},目标为({})的推流信息为找到流体服务[{}]信息",fromUserId, toUserId, sendRtpItem.getMediaServerId());
return; return;

View File

@ -67,10 +67,10 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In
private AudioBroadcastManager audioBroadcastManager; private AudioBroadcastManager audioBroadcastManager;
@Autowired @Autowired
private IDeviceChannelService channelService; private IVideoManagerStorage storager;
@Autowired @Autowired
private IVideoManagerStorage storager; private IGbChannelService channelService;
@Autowired @Autowired
private IMediaServerService mediaServerService; private IMediaServerService mediaServerService;
@ -163,7 +163,7 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In
if (mediaInfo.getReaderCount() <= 0) { if (mediaInfo.getReaderCount() <= 0) {
log.info("[收到bye] {} 无其它观看者,通知设备停止推流", streamId); log.info("[收到bye] {} 无其它观看者,通知设备停止推流", streamId);
if (sendRtpItem.getPlayType().equals(InviteStreamType.PLAY)) { if (sendRtpItem.getPlayType().equals(InviteStreamType.PLAY)) {
Device device = deviceService.getDevice(sendRtpItem.getDeviceId()); Device device = deviceService.getDeviceByDeviceId(sendRtpItem.getDeviceId());
if (device == null) { if (device == null) {
log.info("[收到bye] {} 通知设备停止推流时未找到设备信息", streamId); log.info("[收到bye] {} 通知设备停止推流时未找到设备信息", streamId);
} }
@ -189,7 +189,7 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In
if (platform != null ) { if (platform != null ) {
if (ssrcTransaction.getType().equals(InviteSessionType.BROADCAST)) { if (ssrcTransaction.getType().equals(InviteSessionType.BROADCAST)) {
log.info("[收到bye] 上级停止语音对讲,来自:{}, 通道已停止推流: {}", ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId()); log.info("[收到bye] 上级停止语音对讲,来自:{}, 通道已停止推流: {}", ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId());
DeviceChannel channel = storager.queryChannelInParentPlatform(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId()); CommonGBChannel channel = channelService.queryOneWithPlatform(platform.getId(), ssrcTransaction.getChannelId());
if (channel == null) { if (channel == null) {
log.info("[收到bye] 未找到通道,设备:{} 通道:{}", ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId()); log.info("[收到bye] 未找到通道,设备:{} 通道:{}", ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId());
return; return;
@ -198,16 +198,16 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In
platformService.stopBroadcast(platform, channel, ssrcTransaction.getStream(), false, platformService.stopBroadcast(platform, channel, ssrcTransaction.getStream(), false,
mediaServerService.getOne(mediaServerId)); mediaServerService.getOne(mediaServerId));
playService.stopAudioBroadcast(ssrcTransaction.getDeviceId(), channel.getDeviceId()); playService.stopAudioBroadcast(ssrcTransaction.getDeviceId(), channel.getGbDeviceId());
} }
}else { }else {
Device device = deviceService.getDevice(ssrcTransaction.getDeviceId()); Device device = deviceService.getDeviceByDeviceId(ssrcTransaction.getDeviceId());
if (device == null) { if (device == null) {
log.info("[收到bye] 未找到设备:{} ", ssrcTransaction.getDeviceId()); log.info("[收到bye] 未找到设备:{} ", ssrcTransaction.getDeviceId());
return; return;
} }
DeviceChannel channel = channelService.getOne(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId()); DeviceChannel channel = deviceChannelService.getOne(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId());
if (channel == null) { if (channel == null) {
log.info("[收到bye] 未找到通道,设备:{} 通道:{}", ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId()); log.info("[收到bye] 未找到通道,设备:{} 通道:{}", ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId());
return; return;

View File

@ -10,6 +10,7 @@ import com.genersoft.iot.vmp.conf.SipConfig;
import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.service.IGbChannelService;
import com.genersoft.iot.vmp.gb28181.service.IPlayService; import com.genersoft.iot.vmp.gb28181.service.IPlayService;
import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager; import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager;
import com.genersoft.iot.vmp.gb28181.session.SSRCFactory; import com.genersoft.iot.vmp.gb28181.session.SSRCFactory;
@ -82,6 +83,9 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
@Autowired @Autowired
private IVideoManagerStorage storager; private IVideoManagerStorage storager;
@Autowired
private IGbChannelService channelService;
@Autowired @Autowired
private IStreamPushService streamPushService; private IStreamPushService streamPushService;
@ -190,15 +194,12 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
} else { } else {
// 查询平台下是否有该通道 // 查询平台下是否有该通道
DeviceChannel channel = storager.queryChannelInParentPlatform(requesterId, channelId); CommonGBChannel channel= channelService.queryOneWithPlatform(platform.getId(), channelId);
GbStream gbStream = storager.queryStreamInParentPlatform(requesterId, channelId);
// PlatformCatalog catalog = storager.getCatalog(requesterId, channelId);
MediaServer mediaServerItem = null; MediaServer mediaServerItem = null;
StreamPush streamPushItem = null; StreamPush streamPushItem = null;
StreamProxy proxyByAppAndStream = null; StreamProxy proxyByAppAndStream = null;
// 不是通道可能是直播流 // 不是通道可能是直播流
if (channel != null && gbStream == null) { if (channel != null ) {
// 通道存在发100TRYING // 通道存在发100TRYING
try { try {
responseAck(request, Response.TRYING); responseAck(request, Response.TRYING);

View File

@ -93,7 +93,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
SipUri uri = (SipUri) address.getURI(); SipUri uri = (SipUri) address.getURI();
String deviceId = uri.getUser(); String deviceId = uri.getUser();
Device device = deviceService.getDevice(deviceId); Device device = deviceService.getDeviceByDeviceId(deviceId);
RemoteAddressInfo remoteAddressInfo = SipUtils.getRemoteAddressFromRequest(request, RemoteAddressInfo remoteAddressInfo = SipUtils.getRemoteAddressFromRequest(request,
userSetting.getSipUseSourceIpAsRemoteAddress()); userSetting.getSipUseSourceIpAsRemoteAddress());

View File

@ -9,7 +9,6 @@ import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor; 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.transmit.event.request.SIPRequestProcessorParent;
import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
import com.genersoft.iot.vmp.gb28181.service.IDeviceService; import com.genersoft.iot.vmp.gb28181.service.IDeviceService;
import com.genersoft.iot.vmp.gb28181.service.IInviteStreamService; import com.genersoft.iot.vmp.gb28181.service.IInviteStreamService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
@ -28,6 +27,9 @@ import javax.sip.header.ContentTypeHeader;
import javax.sip.message.Response; import javax.sip.message.Response;
import java.text.ParseException; import java.text.ParseException;
/**
* INFO
*/
@Slf4j @Slf4j
@Component @Component
public class InfoRequestProcessor extends SIPRequestProcessorParent implements InitializingBean, ISIPRequestProcessor { public class InfoRequestProcessor extends SIPRequestProcessorParent implements InitializingBean, ISIPRequestProcessor {
@ -68,22 +70,17 @@ public class InfoRequestProcessor extends SIPRequestProcessorParent implements I
public void process(RequestEvent evt) { public void process(RequestEvent evt) {
log.debug("接收到消息:" + evt.getRequest()); log.debug("接收到消息:" + evt.getRequest());
SIPRequest request = (SIPRequest) evt.getRequest(); SIPRequest request = (SIPRequest) evt.getRequest();
String deviceId = SipUtils.getUserIdFromFromHeader(request);
CallIdHeader callIdHeader = request.getCallIdHeader(); CallIdHeader callIdHeader = request.getCallIdHeader();
// 先从会话内查找 // 先从会话内查找
SsrcTransaction ssrcTransaction = sessionManager.getSsrcTransaction(null, null, callIdHeader.getCallId(), null); SsrcTransaction ssrcTransaction = sessionManager.getSsrcTransaction(null, null, callIdHeader.getCallId(), null);
// 兼容海康 媒体通知 消息from字段不是设备ID的问题
if (ssrcTransaction != null) {
deviceId = ssrcTransaction.getDeviceId();
}
// 查询设备是否存在 // 查询设备是否存在
Device device = redisCatchStorage.getDevice(deviceId); Device device = redisCatchStorage.getDevice(ssrcTransaction.getDeviceId());
// 查询上级平台是否存在 // 查询上级平台是否存在
Platform parentPlatform = storage.queryParentPlatByServerGBId(deviceId); Platform parentPlatform = storage.queryParentPlatByServerGBId(ssrcTransaction.getDeviceId());
try { try {
if (device != null && parentPlatform != null) { if (device != null && parentPlatform != null) {
log.warn("[重复]平台与设备编号重复:{}", deviceId); log.warn("[重复]平台与设备编号重复:{}", ssrcTransaction.getDeviceId());
String hostAddress = request.getRemoteAddress().getHostAddress(); String hostAddress = request.getRemoteAddress().getHostAddress();
int remotePort = request.getRemotePort(); int remotePort = request.getRemotePort();
if (device.getHostAddress().equals(hostAddress + ":" + remotePort)) { if (device.getHostAddress().equals(hostAddress + ":" + remotePort)) {
@ -94,8 +91,8 @@ public class InfoRequestProcessor extends SIPRequestProcessorParent implements I
} }
if (device == null && parentPlatform == null) { if (device == null && parentPlatform == null) {
// 不存在则回复404 // 不存在则回复404
responseAck(request, Response.NOT_FOUND, "device "+ deviceId +" not found"); responseAck(request, Response.NOT_FOUND, "device "+ ssrcTransaction.getDeviceId() +" not found");
log.warn("[设备未找到 ] {}", deviceId); log.warn("[设备未找到 ] {}", ssrcTransaction.getDeviceId());
if (sipSubscribe.getErrorSubscribe(callIdHeader.getCallId()) != null){ if (sipSubscribe.getErrorSubscribe(callIdHeader.getCallId()) != null){
DeviceNotFoundEvent deviceNotFoundEvent = new DeviceNotFoundEvent(evt.getDialog()); DeviceNotFoundEvent deviceNotFoundEvent = new DeviceNotFoundEvent(evt.getDialog());
deviceNotFoundEvent.setCallId(callIdHeader.getCallId()); deviceNotFoundEvent.setCallId(callIdHeader.getCallId());
@ -114,8 +111,9 @@ public class InfoRequestProcessor extends SIPRequestProcessorParent implements I
responseAck(request, Response.NOT_FOUND, "stream " + streamId + " not found"); responseAck(request, Response.NOT_FOUND, "stream " + streamId + " not found");
return; return;
} }
Device device1 = deviceService.getDevice(inviteInfo.getDeviceId()); Device device1 = deviceService.getDeviceByDeviceId(inviteInfo.getDeviceId());
if (inviteInfo.getStreamInfo() != null) { if (inviteInfo.getStreamInfo() != null) {
// 不解析协议, 直接转发给对应的设备
cmder.playbackControlCmd(device1,inviteInfo.getStreamInfo(),new String(evt.getRequest().getRawContent()),eventResult -> { cmder.playbackControlCmd(device1,inviteInfo.getStreamInfo(),new String(evt.getRequest().getRawContent()),eventResult -> {
// 失败的回复 // 失败的回复
try { try {
@ -143,6 +141,4 @@ public class InfoRequestProcessor extends SIPRequestProcessorParent implements I
log.warn("SIP回复时解析异常", e); log.warn("SIP回复时解析异常", e);
} }
} }
} }

View File

@ -65,38 +65,14 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
String channelId = getText(rootElement, "DeviceID"); String channelId = getText(rootElement, "DeviceID");
// 远程启动功能 // 远程启动功能
if (!ObjectUtils.isEmpty(getText(rootElement, "TeleBoot"))) { if (!ObjectUtils.isEmpty(getText(rootElement, "TeleBoot"))) {
// TODO 拒绝远程启动命令 // 拒绝远程启动命令
log.warn("[国标级联]收到平台的远程启动命令, 不处理"); log.warn("[国标级联]收到平台的远程启动命令, 禁用,不允许上级平台随意重启下级平台");
try {
// if (parentPlatform.getServerGBId().equals(targetGBId)) { responseAck(request, Response.FORBIDDEN);
// // 远程启动本平台需要在重新启动程序后先对SipStack解绑 } catch (SipException | InvalidArgumentException | ParseException e) {
// logger.info("执行远程启动本平台命令"); log.error("[命令发送失败] 错误信息: {}", e.getMessage());
// try { }
// cmderFroPlatform.unregister(parentPlatform, null, null); return;
// } catch (InvalidArgumentException | ParseException | SipException e) {
// logger.error("[命令发送失败] 国标级联 注销: {}", e.getMessage());
// }
// taskExecutor.execute(() -> {
// // 远程启动
//// try {
//// Thread.sleep(3000);
//// SipProvider up = (SipProvider) SpringBeanFactory.getBean("udpSipProvider");
//// SipStackImpl stack = (SipStackImpl)up.getSipStack();
//// stack.stop();
//// Iterator listener = stack.getListeningPoints();
//// while (listener.hasNext()) {
//// stack.deleteListeningPoint((ListeningPoint) listener.next());
//// }
//// Iterator providers = stack.getSipProviders();
//// while (providers.hasNext()) {
//// stack.deleteSipProvider((SipProvider) providers.next());
//// }
//// VManageBootstrap.restart();
//// } catch (InterruptedException | ObjectInUseException e) {
//// logger.error("[任务执行失败] 服务重启: {}", e.getMessage());
//// }
// });
// }
} }
DeviceControlType deviceControlType = DeviceControlType.typeOf(rootElement); DeviceControlType deviceControlType = DeviceControlType.typeOf(rootElement);
log.info("[接受deviceControl命令] 命令: {}", deviceControlType); log.info("[接受deviceControl命令] 命令: {}", deviceControlType);

View File

@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify
import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.service.IGbChannelService;
import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager; import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
@ -42,6 +43,9 @@ public class BroadcastNotifyMessageHandler extends SIPRequestProcessorParent imp
@Autowired @Autowired
private IVideoManagerStorage storage; private IVideoManagerStorage storage;
@Autowired
private IGbChannelService channelService;
@Autowired @Autowired
private ISIPCommanderForPlatform commanderForPlatform; private ISIPCommanderForPlatform commanderForPlatform;
@ -94,14 +98,14 @@ public class BroadcastNotifyMessageHandler extends SIPRequestProcessorParent imp
log.info("[国标级联 语音喊话] platform: {}, channel: {}", platform.getServerGBId(), targetId); log.info("[国标级联 语音喊话] platform: {}, channel: {}", platform.getServerGBId(), targetId);
DeviceChannel deviceChannel = storage.queryChannelInParentPlatform(platform.getServerGBId(), targetId); CommonGBChannel channel = channelService.queryOneWithPlatform(platform.getId(), targetId);
if (deviceChannel == null) { if (channel == null) {
log.warn("[国标级联 语音喊话] 未找到通道 platform: {}, channel: {}", platform.getServerGBId(), targetId); log.warn("[国标级联 语音喊话] 未找到通道 platform: {}, channel: {}", platform.getServerGBId(), targetId);
responseAck(request, Response.NOT_FOUND, "TargetID not found"); responseAck(request, Response.NOT_FOUND, "TargetID not found");
return; return;
} }
// 向下级发送语音的喊话请求 // 向下级发送语音的喊话请求
Device device = deviceService.getDevice(deviceChannel.getDeviceId()); Device device = deviceService.getDevice(channel.getGbDeviceDbId());
if (device == null) { if (device == null) {
responseAck(request, Response.NOT_FOUND, "device not found"); responseAck(request, Response.NOT_FOUND, "device not found");
return; return;
@ -110,26 +114,26 @@ public class BroadcastNotifyMessageHandler extends SIPRequestProcessorParent imp
// 查看语音通道是否已经建立并且已经在使用 // 查看语音通道是否已经建立并且已经在使用
if (playService.audioBroadcastInUse(device, targetId)) { if (playService.audioBroadcastInUse(device, targetId)) {
commanderForPlatform.broadcastResultCmd(platform, deviceChannel, sn, false,null, null); commanderForPlatform.broadcastResultCmd(platform, channel, sn, false,null, null);
return; return;
} }
MediaServer mediaServerForMinimumLoad = mediaServerService.getMediaServerForMinimumLoad(null); MediaServer mediaServerForMinimumLoad = mediaServerService.getMediaServerForMinimumLoad(null);
commanderForPlatform.broadcastResultCmd(platform, deviceChannel, sn, true, eventResult->{ commanderForPlatform.broadcastResultCmd(platform, channel, sn, true, eventResult->{
log.info("[国标级联] 语音喊话 回复失败 platform {} 错误:{}/{}", platform.getServerGBId(), eventResult.statusCode, eventResult.msg); log.info("[国标级联] 语音喊话 回复失败 platform {} 错误:{}/{}", platform.getServerGBId(), eventResult.statusCode, eventResult.msg);
}, eventResult->{ }, eventResult->{
// 消息发送成功, 向上级发送invite获取推流 // 消息发送成功, 向上级发送invite获取推流
try { try {
platformService.broadcastInvite(platform, deviceChannel.getDeviceId(), mediaServerForMinimumLoad, (hookData)->{ platformService.broadcastInvite(platform, channel.getGbDeviceId(), mediaServerForMinimumLoad, (hookData)->{
// 上级平台推流成功 // 上级平台推流成功
AudioBroadcastCatch broadcastCatch = audioBroadcastManager.get(device.getDeviceId(), targetId); AudioBroadcastCatch broadcastCatch = audioBroadcastManager.get(device.getDeviceId(), targetId);
if (broadcastCatch != null ) { if (broadcastCatch != null ) {
if (playService.audioBroadcastInUse(device, targetId)) { if (playService.audioBroadcastInUse(device, targetId)) {
log.info("[国标级联] 语音喊话 设备正在使用中 platform {} channel: {}", log.info("[国标级联] 语音喊话 设备正在使用中 platform {} channel: {}",
platform.getServerGBId(), deviceChannel.getDeviceId()); platform.getServerGBId(), channel.getGbDeviceId());
// 查看语音通道已经建立且已经占用 回复BYE // 查看语音通道已经建立且已经占用 回复BYE
platformService.stopBroadcast(platform, deviceChannel, hookData.getStream(), true, hookData.getMediaServer()); platformService.stopBroadcast(platform, channel, hookData.getStream(), true, hookData.getMediaServer());
}else { }else {
// 查看语音通道已经建立但是未占用 // 查看语音通道已经建立但是未占用
broadcastCatch.setApp(hookData.getApp()); broadcastCatch.setApp(hookData.getApp());

View File

@ -41,14 +41,6 @@ public class CatalogQueryMessageHandler extends SIPRequestProcessorParent implem
@Autowired @Autowired
private SIPCommanderFroPlatform cmderFroPlatform; private SIPCommanderFroPlatform cmderFroPlatform;
@Autowired
private SipConfig config;
@Autowired
private EventPublisher publisher;
@Autowired
private IVideoManagerStorage storage;
@Override @Override
public void afterPropertiesSet() throws Exception { public void afterPropertiesSet() throws Exception {
@ -57,7 +49,10 @@ public class CatalogQueryMessageHandler extends SIPRequestProcessorParent implem
@Override @Override
public void handForDevice(RequestEvent evt, Device device, Element element) { public void handForDevice(RequestEvent evt, Device device, Element element) {
try {
// 回复200 OK
responseAck((SIPRequest) evt.getRequest(), Response.FORBIDDEN);
} catch (SipException | InvalidArgumentException | ParseException ignored) {}
} }
@Override @Override
@ -84,6 +79,5 @@ public class CatalogQueryMessageHandler extends SIPRequestProcessorParent implem
} catch (SipException | InvalidArgumentException | ParseException e) { } catch (SipException | InvalidArgumentException | ParseException e) {
log.error("[命令发送失败] 国标级联 目录查询回复: {}", e.getMessage()); log.error("[命令发送失败] 国标级联 目录查询回复: {}", e.getMessage());
} }
} }
} }

View File

@ -48,7 +48,7 @@ public class DeviceInfoQueryMessageHandler extends SIPRequestProcessorParent imp
} }
@Override @Override
public void handForPlatform(RequestEvent evt, Platform parentPlatform, Element rootElement) { public void handForPlatform(RequestEvent evt, Platform platform, Element rootElement) {
log.info("[DeviceInfo查询]消息"); log.info("[DeviceInfo查询]消息");
FromHeader fromHeader = (FromHeader) evt.getRequest().getHeader(FromHeader.NAME); FromHeader fromHeader = (FromHeader) evt.getRequest().getHeader(FromHeader.NAME);
try { try {
@ -68,15 +68,15 @@ public class DeviceInfoQueryMessageHandler extends SIPRequestProcessorParent imp
// 查询这是通道id还是设备id // 查询这是通道id还是设备id
Device device = null; Device device = null;
// 如果id指向平台的国标编号那么就是查询平台的信息 // 如果id指向平台的国标编号那么就是查询平台的信息
if (!parentPlatform.getDeviceGBId().equals(channelId)) { if (!platform.getDeviceGBId().equals(channelId)) {
device = storager.queryDeviceInfoByPlatformIdAndChannelId(parentPlatform.getServerGBId(), channelId); device = storager.queryDeviceInfoByPlatformIdAndChannelId(platform.getServerGBId(), channelId);
if (device ==null){ if (device ==null){
log.error("[平台没有该通道的使用权限]:platformId"+parentPlatform.getServerGBId()+" deviceID:"+channelId); log.error("[平台没有该通道的使用权限]:platformId"+platform.getServerGBId()+" deviceID:"+channelId);
return; return;
} }
} }
try { try {
cmderFroPlatform.deviceInfoResponse(parentPlatform, device, sn, fromHeader.getTag()); cmderFroPlatform.deviceInfoResponse(platform, device, sn, fromHeader.getTag());
} catch (SipException | InvalidArgumentException | ParseException e) { } catch (SipException | InvalidArgumentException | ParseException e) {
log.error("[命令发送失败] 国标级联 DeviceInfo查询回复: {}", e.getMessage()); log.error("[命令发送失败] 国标级联 DeviceInfo查询回复: {}", e.getMessage());
} }

View File

@ -1,8 +1,10 @@
package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.cmd; package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.cmd;
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.Platform; import com.genersoft.iot.vmp.gb28181.bean.Platform;
import com.genersoft.iot.vmp.gb28181.service.IGbChannelService;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; 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.IMessageHandler;
@ -34,7 +36,7 @@ public class DeviceStatusQueryMessageHandler extends SIPRequestProcessorParent i
private QueryMessageHandler queryMessageHandler; private QueryMessageHandler queryMessageHandler;
@Autowired @Autowired
private IVideoManagerStorage storager; private IGbChannelService channelService;
@Autowired @Autowired
private ISIPCommanderForPlatform cmderFroPlatform; private ISIPCommanderForPlatform cmderFroPlatform;
@ -62,13 +64,13 @@ public class DeviceStatusQueryMessageHandler extends SIPRequestProcessorParent i
} }
String sn = rootElement.element("SN").getText(); String sn = rootElement.element("SN").getText();
String channelId = getText(rootElement, "DeviceID"); String channelId = getText(rootElement, "DeviceID");
DeviceChannel deviceChannel = storager.queryChannelInParentPlatform(parentPlatform.getServerGBId(), channelId); CommonGBChannel channel= channelService.queryOneWithPlatform(parentPlatform.getId(), channelId);
if (deviceChannel ==null){ if (channel ==null){
log.error("[平台没有该通道的使用权限]:platformId"+parentPlatform.getServerGBId()+" deviceID:"+channelId); log.error("[平台没有该通道的使用权限]:platformId"+parentPlatform.getServerGBId()+" deviceID:"+channelId);
return; return;
} }
try { try {
cmderFroPlatform.deviceStatusResponse(parentPlatform,channelId, sn, fromHeader.getTag(), "ON".equalsIgnoreCase(deviceChannel.getStatus())); cmderFroPlatform.deviceStatusResponse(parentPlatform, channelId, sn, fromHeader.getTag(), "ON".equalsIgnoreCase(channel.getGbStatus()));
} catch (SipException | InvalidArgumentException | ParseException e) { } catch (SipException | InvalidArgumentException | ParseException e) {
log.error("[命令发送失败] 国标级联 DeviceStatus查询回复: {}", e.getMessage()); log.error("[命令发送失败] 国标级联 DeviceStatus查询回复: {}", e.getMessage());
} }

View File

@ -1,9 +1,12 @@
package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.cmd; package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.cmd;
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.Platform; import com.genersoft.iot.vmp.gb28181.bean.Platform;
import com.genersoft.iot.vmp.gb28181.event.record.RecordEndEventListener; import com.genersoft.iot.vmp.gb28181.event.record.RecordEndEventListener;
import com.genersoft.iot.vmp.gb28181.service.IDeviceService;
import com.genersoft.iot.vmp.gb28181.service.IGbChannelService;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
@ -38,6 +41,12 @@ public class RecordInfoQueryMessageHandler extends SIPRequestProcessorParent imp
@Autowired @Autowired
private IVideoManagerStorage storager; private IVideoManagerStorage storager;
@Autowired
private IGbChannelService channelService;
@Autowired
private IDeviceService deviceService;
@Autowired @Autowired
private SIPCommanderFroPlatform cmderFroPlatform; private SIPCommanderFroPlatform cmderFroPlatform;
@ -85,56 +94,65 @@ public class RecordInfoQueryMessageHandler extends SIPRequestProcessorParent imp
if (typeElement != null) { if (typeElement != null) {
type = typeElement.getText(); type = typeElement.getText();
} }
// 确认是直播还是国标, 国标直接请求下级,直播请求录像管理服务
List<ChannelSourceInfo> channelSources = storager.getChannelSource(parentPlatform.getServerGBId(), channelId);
if (channelSources.get(0).getCount() > 0) { // 国标 // 向国标设备请求录像数据
// 向国标设备请求录像数据 CommonGBChannel channel = channelService.queryOneWithPlatform(parentPlatform.getId(), channelId);
Device device = storager.queryVideoDeviceByPlatformIdAndChannelId(parentPlatform.getServerGBId(), channelId); if (channel == null) {
DeviceChannel deviceChannel = storager.queryChannelInParentPlatform(parentPlatform.getServerGBId(), channelId); log.info("[平台查询录像记录] 未找到通道 {}/{}", parentPlatform.getName(), channelId );
// 接收录像数据
recordEndEventListener.addEndEventHandler(deviceChannel.getDeviceId(), channelId, (recordInfo)->{
try {
log.info("[国标级联] 录像查询收到数据, 通道: {},准备转发===", channelId);
cmderFroPlatform.recordInfo(deviceChannel, parentPlatform, request.getFromTag(), recordInfo);
} catch (SipException | InvalidArgumentException | ParseException e) {
log.error("[命令发送失败] 国标级联 回复录像数据: {}", e.getMessage());
}
});
try {
commander.recordInfoQuery(device, channelId, DateUtil.ISO8601Toyyyy_MM_dd_HH_mm_ss(startTime),
DateUtil.ISO8601Toyyyy_MM_dd_HH_mm_ss(endTime), sn, secrecy, type, (eventResult -> {
// 回复200 OK
try {
responseAck(request, Response.OK);
} catch (SipException | InvalidArgumentException | ParseException e) {
log.error("[命令发送失败] 录像查询回复: {}", e.getMessage());
}
}),(eventResult -> {
// 查询失败
try {
responseAck(request, eventResult.statusCode, eventResult.msg);
} catch (SipException | InvalidArgumentException | ParseException e) {
log.error("[命令发送失败] 录像查询回复: {}", e.getMessage());
}
}));
} catch (InvalidArgumentException | ParseException | SipException e) {
log.error("[命令发送失败] 录像查询: {}", e.getMessage());
}
}else if (channelSources.get(1).getCount() > 0) { // 直播流
// TODO
try {
responseAck(request, Response.NOT_IMPLEMENTED); // 回复未实现
} catch (SipException | InvalidArgumentException | ParseException e) {
log.error("[命令发送失败] 录像查询: {}", e.getMessage());
}
}else { // 错误的请求
try { try {
responseAck(request, Response.BAD_REQUEST); responseAck(request, Response.BAD_REQUEST);
} catch (SipException | InvalidArgumentException | ParseException e) { } catch (SipException | InvalidArgumentException | ParseException e) {
log.error("[命令发送失败] 录像查询: {}", e.getMessage()); log.error("[命令发送失败] [平台查询录像记录] 未找到通道: {}", e.getMessage());
} }
return;
}
if (channel.getStreamProxyId() > 0 || channel.getStreamPushId() > 0) {
log.info("[平台查询录像记录] 不支持查询推流和拉流代理的录像数据 {}/{}", parentPlatform.getName(), channelId );
try {
responseAck(request, Response.NOT_IMPLEMENTED); // 回复未实现
} catch (SipException | InvalidArgumentException | ParseException e) {
log.error("[命令发送失败] 平台查询录像记录: {}", e.getMessage());
}
return;
}
Device device = deviceService.getDevice(channel.getGbDeviceDbId());
if (device == null) {
log.warn("[平台查询录像记录] 未找到通道对应的设备 {}/{}", parentPlatform.getName(), channelId );
try {
responseAck(request, Response.BAD_REQUEST);
} catch (SipException | InvalidArgumentException | ParseException e) {
log.error("[命令发送失败] [平台查询录像记录] 未找到通道对应的设备: {}", e.getMessage());
}
return;
}
// 接收录像数据
recordEndEventListener.addEndEventHandler(channel.getGbDeviceId(), channelId, (recordInfo)->{
try {
log.info("[国标级联] 录像查询收到数据, 通道: {},准备转发===", channelId);
cmderFroPlatform.recordInfo(channel, parentPlatform, request.getFromTag(), recordInfo);
} catch (SipException | InvalidArgumentException | ParseException e) {
log.error("[命令发送失败] 国标级联 回复录像数据: {}", e.getMessage());
}
});
try {
commander.recordInfoQuery(device, channelId, DateUtil.ISO8601Toyyyy_MM_dd_HH_mm_ss(startTime),
DateUtil.ISO8601Toyyyy_MM_dd_HH_mm_ss(endTime), sn, secrecy, type, (eventResult -> {
// 回复200 OK
try {
responseAck(request, Response.OK);
} catch (SipException | InvalidArgumentException | ParseException e) {
log.error("[命令发送失败] 录像查询回复: {}", e.getMessage());
}
}),(eventResult -> {
// 查询失败
try {
responseAck(request, eventResult.statusCode, eventResult.msg);
} catch (SipException | InvalidArgumentException | ParseException e) {
log.error("[命令发送失败] 录像查询回复: {}", e.getMessage());
}
}));
} catch (InvalidArgumentException | ParseException | SipException e) {
log.error("[命令发送失败] 录像查询: {}", e.getMessage());
} }
} }
} }

View File

@ -248,7 +248,7 @@ public class MediaServiceImpl implements IMediaService {
} }
} }
} }
Device device = deviceService.getDevice(inviteInfo.getDeviceId()); Device device = deviceService.getDeviceByDeviceId(inviteInfo.getDeviceId());
if (device != null) { if (device != null) {
try { try {
// 多查询一次防止已经被处理了 // 多查询一次防止已经被处理了

View File

@ -129,7 +129,7 @@ public class RedisAlarmMsgListener implements MessageListener {
} }
}else { }else {
Device device = deviceService.getDevice(gbId); Device device = deviceService.getDeviceByDeviceId(gbId);
Platform platform = storage.queryParentPlatByServerGBId(gbId); Platform platform = storage.queryParentPlatByServerGBId(gbId);
if (device != null && platform == null) { if (device != null && platform == null) {
try { try {

View File

@ -51,7 +51,7 @@ public class ApiControlController {
} }
if (channel == null) {channel = 0;} if (channel == null) {channel = 0;}
if (speed == null) {speed = 0;} if (speed == null) {speed = 0;}
Device device = deviceService.getDevice(serial); Device device = deviceService.getDeviceByDeviceId(serial);
if (device == null) { if (device == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "device[ " + serial + " ]未找到"); throw new ControllerException(ErrorCode.ERROR100.getCode(), "device[ " + serial + " ]未找到");
} }
@ -125,7 +125,7 @@ public class ApiControlController {
} }
if (channel == null) {channel = 0;} if (channel == null) {channel = 0;}
Device device = deviceService.getDevice(serial); Device device = deviceService.getDeviceByDeviceId(serial);
if (device == null) { if (device == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "device[ " + serial + " ]未找到"); throw new ControllerException(ErrorCode.ERROR100.getCode(), "device[ " + serial + " ]未找到");
} }

View File

@ -200,7 +200,7 @@ public class ApiDeviceController {
serial, channel, code, fill, timeout); serial, channel, code, fill, timeout);
} }
Device device = deviceService.getDevice(serial); Device device = deviceService.getDeviceByDeviceId(serial);
String uuid = UUID.randomUUID().toString(); String uuid = UUID.randomUUID().toString();
String key = DeferredResultHolder.CALLBACK_CMD_PRESETQUERY + (ObjectUtils.isEmpty(code) ? serial : code); String key = DeferredResultHolder.CALLBACK_CMD_PRESETQUERY + (ObjectUtils.isEmpty(code) ? serial : code);
DeferredResult<Object> result = new DeferredResult<> (timeout * 1000L); DeferredResult<Object> result = new DeferredResult<> (timeout * 1000L);

View File

@ -82,7 +82,7 @@ public class ApiStreamController {
){ ){
DeferredResult<JSONObject> result = new DeferredResult<>(userSetting.getPlayTimeout().longValue() + 10); DeferredResult<JSONObject> result = new DeferredResult<>(userSetting.getPlayTimeout().longValue() + 10);
Device device = deviceService.getDevice(serial); Device device = deviceService.getDeviceByDeviceId(serial);
if (device == null ) { if (device == null ) {
JSONObject resultJSON = new JSONObject(); JSONObject resultJSON = new JSONObject();
resultJSON.put("error","device[ " + serial + " ]未找到"); resultJSON.put("error","device[ " + serial + " ]未找到");
@ -230,7 +230,7 @@ public class ApiStreamController {
result.put("error","未找到流信息"); result.put("error","未找到流信息");
return result; return result;
} }
Device device = deviceService.getDevice(serial); Device device = deviceService.getDeviceByDeviceId(serial);
if (device == null) { if (device == null) {
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
result.put("error","未找到设备"); result.put("error","未找到设备");