|
@ -1,6 +1,9 @@ |
|
|
package org.dromara.sample.manage.controller; |
|
|
package org.dromara.sample.manage.controller; |
|
|
|
|
|
|
|
|
import cn.hutool.core.convert.Convert; |
|
|
import cn.hutool.core.convert.Convert; |
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
|
import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper; |
|
|
import com.fasterxml.jackson.core.JsonProcessingException; |
|
|
import com.fasterxml.jackson.core.JsonProcessingException; |
|
|
import com.fasterxml.jackson.databind.ObjectMapper; |
|
|
import com.fasterxml.jackson.databind.ObjectMapper; |
|
|
import io.seata.common.util.StringUtils; |
|
|
import io.seata.common.util.StringUtils; |
|
@ -9,6 +12,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; |
|
|
import jakarta.annotation.Resource; |
|
|
import jakarta.annotation.Resource; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import net.bytebuddy.implementation.bytecode.Throw; |
|
|
import net.bytebuddy.implementation.bytecode.Throw; |
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils; |
|
|
import org.apache.dubbo.config.annotation.DubboReference; |
|
|
import org.apache.dubbo.config.annotation.DubboReference; |
|
|
import org.apache.http.client.methods.CloseableHttpResponse; |
|
|
import org.apache.http.client.methods.CloseableHttpResponse; |
|
|
import org.apache.http.client.methods.HttpGet; |
|
|
import org.apache.http.client.methods.HttpGet; |
|
@ -28,11 +32,16 @@ import org.dromara.common.sdk.mqtt.property.PropertySetPublish; |
|
|
import org.dromara.common.sdk.mqtt.services.ServicesPublish; |
|
|
import org.dromara.common.sdk.mqtt.services.ServicesPublish; |
|
|
import org.dromara.common.sdk.mqtt.services.ServicesReplyReceiver; |
|
|
import org.dromara.common.sdk.mqtt.services.ServicesReplyReceiver; |
|
|
import org.dromara.common.sdk.mqtt.services.TopicServicesRequest; |
|
|
import org.dromara.common.sdk.mqtt.services.TopicServicesRequest; |
|
|
|
|
|
import org.dromara.common.translation.annotation.Translation; |
|
|
import org.dromara.sample.common.util.Md5Utils; |
|
|
import org.dromara.sample.common.util.Md5Utils; |
|
|
|
|
|
import org.dromara.sample.manage.mapper.IDeviceStreamMapper; |
|
|
import org.dromara.sample.manage.model.dto.*; |
|
|
import org.dromara.sample.manage.model.dto.*; |
|
|
|
|
|
import org.dromara.sample.manage.model.entity.DeviceStreamEntity; |
|
|
|
|
|
import org.dromara.sample.manage.service.IDeviceStreamService; |
|
|
import org.dromara.sample.media.mapper.IFileMapper; |
|
|
import org.dromara.sample.media.mapper.IFileMapper; |
|
|
import org.dromara.system.api.RemoteConfigService; |
|
|
import org.dromara.system.api.RemoteConfigService; |
|
|
import org.json.JSONObject; |
|
|
import org.json.JSONObject; |
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.web.bind.annotation.*; |
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
|
import java.net.URI; |
|
|
import java.net.URI; |
|
@ -69,6 +78,9 @@ public class MegaphoneController { |
|
|
@DubboReference |
|
|
@DubboReference |
|
|
private RemoteConfigService remoteConfigService; |
|
|
private RemoteConfigService remoteConfigService; |
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
IDeviceStreamMapper deviceStreamMapper; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 喊话器-开始播放文档(对应遥控器的录音广播模式) |
|
|
* 喊话器-开始播放文档(对应遥控器的录音广播模式) |
|
|
* Get the topology list of all online devices in one workspace. |
|
|
* Get the topology list of all online devices in one workspace. |
|
@ -247,6 +259,7 @@ public class MegaphoneController { |
|
|
*/ |
|
|
*/ |
|
|
@PostMapping("/{workspace_id}/getStreamIp") |
|
|
@PostMapping("/{workspace_id}/getStreamIp") |
|
|
@Operation(summary = "获取媒体流ip。", description = "获取媒体流ip。") |
|
|
@Operation(summary = "获取媒体流ip。", description = "获取媒体流ip。") |
|
|
|
|
|
@Transactional |
|
|
public HttpResultResponse getStreamIp(@PathVariable("workspace_id") String workspaceId, |
|
|
public HttpResultResponse getStreamIp(@PathVariable("workspace_id") String workspaceId, |
|
|
@RequestBody Map<String,Object>objectMap |
|
|
@RequestBody Map<String,Object>objectMap |
|
|
) { |
|
|
) { |
|
@ -254,18 +267,55 @@ public class MegaphoneController { |
|
|
//发送mqtt
|
|
|
//发送mqtt
|
|
|
String s = remoteConfigService.selectStreamIp(); |
|
|
String s = remoteConfigService.selectStreamIp(); |
|
|
DisobeyDTO param = Convert.convert(DisobeyDTO.class, objectMap); |
|
|
DisobeyDTO param = Convert.convert(DisobeyDTO.class, objectMap); |
|
|
if (StringUtils.isNotEmpty(param.getModel())){ |
|
|
|
|
|
String[] split = param.getModel().split(","); |
|
|
if (param.getOpen() == 1){ |
|
|
for (String type : split){ |
|
|
if (StringUtils.isNotEmpty(param.getModel())){ |
|
|
List<String> list = new ArrayList<>(); |
|
|
String[] split = param.getModel().split(","); |
|
|
list.add(type); |
|
|
for (String type : split){ |
|
|
DisobeyDTO disobeyDTO = new DisobeyDTO(); |
|
|
List<DeviceStreamEntity> deviceStreamEntities = deviceStreamMapper.selectList(new QueryWrapper<DeviceStreamEntity>().eq("rtmp_url", param.getRtmpUrl()) |
|
|
disobeyDTO.setUrl(s); |
|
|
.eq("stream_type", type)); |
|
|
disobeyDTO.setOpen(param.getOpen()); |
|
|
if (CollectionUtils.isEmpty(deviceStreamEntities)){ |
|
|
disobeyDTO.setType(list); |
|
|
DeviceStreamEntity deviceStreamEntity = new DeviceStreamEntity(); |
|
|
disobeyDTO.setRtmpUrl(param.getRtmpUrl()); |
|
|
deviceStreamEntity.setStreamType(type); |
|
|
gatewayPublish.publish(top,new CommonTopicRequest<>() |
|
|
deviceStreamEntity.setCreateTime(new Date()); |
|
|
.setData(Objects.requireNonNull(disobeyDTO)),1); |
|
|
deviceStreamEntity.setUpdateTime(new Date()); |
|
|
|
|
|
deviceStreamEntity.setRtmpUrl(param.getRtmpUrl()); |
|
|
|
|
|
deviceStreamMapper.insert(deviceStreamEntity); |
|
|
|
|
|
List<String> list = new ArrayList<>(); |
|
|
|
|
|
list.add(type); |
|
|
|
|
|
DisobeyDTO disobeyDTO = new DisobeyDTO(); |
|
|
|
|
|
disobeyDTO.setUrl(s); |
|
|
|
|
|
disobeyDTO.setOpen(param.getOpen()); |
|
|
|
|
|
disobeyDTO.setType(list); |
|
|
|
|
|
disobeyDTO.setRtmpUrl(param.getRtmpUrl()); |
|
|
|
|
|
gatewayPublish.publish(top,new CommonTopicRequest<>() |
|
|
|
|
|
.setData(Objects.requireNonNull(disobeyDTO)),1); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (param.getOpen() == 2){ |
|
|
|
|
|
if (StringUtils.isNotEmpty(param.getModel())){ |
|
|
|
|
|
String[] split = param.getModel().split(","); |
|
|
|
|
|
for (String type : split){ |
|
|
|
|
|
List<DeviceStreamEntity> deviceStreamEntities = deviceStreamMapper.selectList(new QueryWrapper<DeviceStreamEntity>().eq("rtmp_url", param.getRtmpUrl()) |
|
|
|
|
|
.eq("stream_type", type)); |
|
|
|
|
|
if (CollectionUtils.isNotEmpty(deviceStreamEntities)){ |
|
|
|
|
|
deviceStreamMapper.delete(new QueryWrapper<DeviceStreamEntity>().eq("rtmp_url", param.getRtmpUrl()) |
|
|
|
|
|
.eq("stream_type", type)); |
|
|
|
|
|
List<String> list = new ArrayList<>(); |
|
|
|
|
|
list.add(type); |
|
|
|
|
|
DisobeyDTO disobeyDTO = new DisobeyDTO(); |
|
|
|
|
|
disobeyDTO.setUrl(s); |
|
|
|
|
|
disobeyDTO.setOpen(param.getOpen()); |
|
|
|
|
|
disobeyDTO.setType(list); |
|
|
|
|
|
disobeyDTO.setRtmpUrl(param.getRtmpUrl()); |
|
|
|
|
|
gatewayPublish.publish(top,new CommonTopicRequest<>() |
|
|
|
|
|
.setData(Objects.requireNonNull(disobeyDTO)),1); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}else { |
|
|
|
|
|
deviceStreamMapper.delete(new QueryWrapper<DeviceStreamEntity>().eq("rtmp_url", param.getRtmpUrl())); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return HttpResultResponse.success(); |
|
|
return HttpResultResponse.success(); |
|
@ -296,6 +346,15 @@ public class MegaphoneController { |
|
|
return HttpResultResponse.success(megaphoneDTO); |
|
|
return HttpResultResponse.success(megaphoneDTO); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/getStreamType") |
|
|
|
|
|
@Operation(summary = "获取开启的算法类型。", description = "获取开启的算法类型。") |
|
|
|
|
|
public HttpResultResponse<List<DeviceStreamEntity>> getStreamType(@RequestParam String rtmpUrl |
|
|
|
|
|
) { |
|
|
|
|
|
List<DeviceStreamEntity> deviceStreamEntities = deviceStreamMapper.selectList(new LambdaQueryWrapper<DeviceStreamEntity>().eq(DeviceStreamEntity::getRtmpUrl, rtmpUrl)); |
|
|
|
|
|
return HttpResultResponse.success(deviceStreamEntities); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 获取媒体流ip |
|
|
* 获取媒体流ip |
|
|