修改问题

pull/7/head
刘鑫 3 months ago
parent 94c6fc880b
commit 1b7bf6e69a
  1. 35
      WeiCloud.Fusion/AlarmService/Alarm.DomainService/DahAlarm/DahuaGeneralCtlService.cs
  2. 2
      WeiCloud.Fusion/AlarmService/Alarm.DomainService/DahAlarm/IDahuaGeneralCtlService.cs
  3. 2
      WeiCloud.Fusion/AlarmService/AlarmService.API/Controllers/AlarmController.cs
  4. 2
      WeiCloud.Fusion/AlarmService/AlarmService.API/appsettings.json
  5. 2
      WeiCloud.Fusion/VideoService/Video.API/Controllers/DaHua/VideoManageController.cs
  6. 20
      WeiCloud.Fusion/VideoService/Video.Application/RequestDto/DahuaVideoQueryDto.cs
  7. 18
      WeiCloud.Fusion/VideoService/Video.DomainService/Dahvision/DahuaGeneralCtlService.cs
  8. 2
      WeiCloud.Fusion/VideoService/Video.DomainService/Dahvision/IDahuaGeneralCtlService.cs
  9. 2
      WeiCloud.Fusion/VideoService/Video.DomainService/Dahvision/IRootVideoPlaybackService.cs
  10. 2
      WeiCloud.Fusion/VideoService/Video.DomainService/Dahvision/RootVideoPlaybackService.cs

@ -11,6 +11,7 @@ using System;
using System.Net.Http.Json; using System.Net.Http.Json;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization;
using WeiCloud.Core.BaseModels; using WeiCloud.Core.BaseModels;
namespace Alarm.DomainService.DahAlarm namespace Alarm.DomainService.DahAlarm
@ -119,8 +120,8 @@ namespace Alarm.DomainService.DahAlarm
Subsystem = new SubsystemConfig Subsystem = new SubsystemConfig
{ {
SubsystemType = 0, SubsystemType = 0,
Name = "192.168.21.43_alarm", Name = _configuration["DahuaAuth:SubsystemName"],
Magic = "192.168.21.43" Magic = _configuration["DahuaAuth:SubsystemMagic"]
} }
} }
}; };
@ -132,8 +133,8 @@ namespace Alarm.DomainService.DahAlarm
{ {
Content = JsonContent.Create(req, options: new JsonSerializerOptions Content = JsonContent.Create(req, options: new JsonSerializerOptions
{ {
DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
PropertyNamingPolicy = System.Text.Json.JsonNamingPolicy.CamelCase PropertyNamingPolicy = new AllLowerCaseNamingPolicy()
}) })
}; };
@ -185,14 +186,14 @@ namespace Alarm.DomainService.DahAlarm
/// <param name="dto"></param> /// <param name="dto"></param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="NotImplementedException"></exception> /// <exception cref="NotImplementedException"></exception>
public async Task<ApiResult<bool>> HandleAsync(EventEnvelopeDto dto) public async Task<DaHApiResult<bool>> HandleAsync(EventEnvelopeDto dto)
{ {
ApiResult<bool> result = new() { Code = 200, Msg = "接口调用成功", Data = true }; DaHApiResult<bool> result = new() { Code = "200", Msg = "接口调用成功", Data = true };
try try
{ {
if (dto is null) if (dto is null)
{ {
result.Code = 500; result.Code = "500";
result.Msg = "请求参数不能为空"; result.Msg = "请求参数不能为空";
result.Data = false; result.Data = false;
_logger.LogWarning("大华报警事件订阅回调处理失败,参数不能为空"); _logger.LogWarning("大华报警事件订阅回调处理失败,参数不能为空");
@ -216,11 +217,29 @@ namespace Alarm.DomainService.DahAlarm
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "大华报警事件订阅回调处理异常"); _logger.LogError(ex, "大华报警事件订阅回调处理异常");
result.Code = 500; result.Code = "500";
result.Msg = "大华报警事件订阅回调处理异常"; result.Msg = "大华报警事件订阅回调处理异常";
result.Data = false; result.Data = false;
} }
return result; return result;
} }
/// <summary>
/// 取消订阅某个报警事件
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
public async Task<DaHApiResult<object>> DeleteSubscribe(string name)
{
throw new NotImplementedException("该方法未实现");
}
/// <summary>
/// 转换小写
/// </summary>
private class AllLowerCaseNamingPolicy : JsonNamingPolicy
{
public override string ConvertName(string name) => name.ToLowerInvariant();
}
} }
} }

@ -23,6 +23,6 @@ namespace Alarm.DomainService.DahAlarm
/// <param name="env"></param> /// <param name="env"></param>
/// <param name="ct"></param> /// <param name="ct"></param>
/// <returns></returns> /// <returns></returns>
Task<ApiResult<bool>> HandleAsync(EventEnvelopeDto env); Task<DaHApiResult<bool>> HandleAsync(EventEnvelopeDto env);
} }
} }

@ -36,7 +36,7 @@ namespace AlarmService.API.Controllers
/// <param name="env"></param> /// <param name="env"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
public async Task<ApiResult<bool>> DahuaAuthCallback(EventEnvelopeDto env) public async Task<DaHApiResult<bool>> DahuaAuthCallback(EventEnvelopeDto env)
{ {
return await _generalCtlService.HandleAsync(env); return await _generalCtlService.HandleAsync(env);
} }

@ -27,6 +27,6 @@
"Password": "Admin123", "Password": "Admin123",
"Callback": "http://demo.weienergy.cn:5000/api/Alarm/DahuaAuthCallback", "Callback": "http://demo.weienergy.cn:5000/api/Alarm/DahuaAuthCallback",
"SubsystemName": "192.168.21.43_alarm", "SubsystemName": "192.168.21.43_alarm",
"SubsystemMagic": "192.168.21.43" "SubsystemMagic": "192.168.21.43_5001"
} }
} }

@ -49,7 +49,7 @@ namespace Video.API.Controllers.DaHua
/// <param name="dto"></param> /// <param name="dto"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost("rtspplayback/dh")] [HttpPost("rtspplayback/dh")]
public async Task<ApiResult<UrlDataDto>> RtspPlaybackByTime(RtspPlaybackReqDto dto) public async Task<ApiResult<UrlDataDto>> RtspPlaybackByTime(RtspPlayBackReqDto dto)
{ {
return await _rootVideoPlaybackService.RtspPlaybackByTime(dto); return await _rootVideoPlaybackService.RtspPlaybackByTime(dto);
} }

@ -8,7 +8,7 @@ namespace Video.Application
/// <summary> /// <summary>
/// hls、rtmp回放请求的数据部分 /// hls、rtmp回放请求的数据部分
/// </summary> /// </summary>
public class PlaybackReqDto public class PlaybackItem
{ {
/// <summary> /// <summary>
/// 通道ID(格式如:1000018$1$0$0) /// 通道ID(格式如:1000018$1$0$0)
@ -56,7 +56,15 @@ namespace Video.Application
/// <summary> /// <summary>
/// hls、rtmp回放请求的数据部分 /// hls、rtmp回放请求的数据部分
/// </summary> /// </summary>
public class RtspPlaybackReqDto public class PlaybackReqDto
{
public PlaybackItem Data { get; set; }
}
/// <summary>
///rtsp回放请求的数据部分
/// </summary>
public class RtspPlaybackItem
{ {
/// <summary> /// <summary>
/// 通道ID(格式如:1000018$1$0$0) /// 通道ID(格式如:1000018$1$0$0)
@ -95,6 +103,14 @@ namespace Video.Application
public string RecordSource { get; set; } public string RecordSource { get; set; }
} }
/// <summary>
/// rtsp请求dto
/// </summary>
public class RtspPlayBackReqDto
{
public RtspPlaybackItem Data { get; set; }
}
/// <summary> /// <summary>
/// 通道分页查询请求参数实体 /// 通道分页查询请求参数实体
/// </summary> /// </summary>

@ -33,7 +33,7 @@ namespace Video.DomainService
}); });
/// <summary> /// <summary>
/// 录像回放 /// hls等录像回放
/// </summary> /// </summary>
/// <param name="dto"></param> /// <param name="dto"></param>
/// <returns></returns> /// <returns></returns>
@ -41,7 +41,7 @@ namespace Video.DomainService
public async Task<DaHApiResult<UrlDataDto>> RecordVideoUrl(PlaybackReqDto dto) public async Task<DaHApiResult<UrlDataDto>> RecordVideoUrl(PlaybackReqDto dto)
{ {
// 1) 参数校验 + 早退 // 1) 参数校验 + 早退
if (dto == null || string.IsNullOrWhiteSpace(dto.ChannelId)) if (dto == null || string.IsNullOrWhiteSpace(dto.Data.ChannelId))
{ {
_logger.LogWarning("录像请求失败:通道ID不能为空"); _logger.LogWarning("录像请求失败:通道ID不能为空");
return new DaHApiResult<UrlDataDto> { Success = false, Code = "1007", Msg = "通道ID不能为空" }; return new DaHApiResult<UrlDataDto> { Success = false, Code = "1007", Msg = "通道ID不能为空" };
@ -77,7 +77,7 @@ namespace Video.DomainService
_logger.LogWarning("录像请求业务失败: {Body}", body); _logger.LogWarning("录像请求业务失败: {Body}", body);
return new DaHApiResult<UrlDataDto> { Success = false, Code = "1008", Msg = "录像请求失败" }; return new DaHApiResult<UrlDataDto> { Success = false, Code = "1008", Msg = "录像请求失败" };
} }
result.Data!.Url = result.Data.Url + "?token=" + token;
return result; return result;
} }
catch (Exception ex) catch (Exception ex)
@ -238,7 +238,7 @@ namespace Video.DomainService
_logger.LogWarning("实时流请求业务失败: {Body}", body); _logger.LogWarning("实时流请求业务失败: {Body}", body);
return new DaHApiResult<UrlDataDto> { Success = false, Code = "1010", Msg = "实时流请求失败" }; return new DaHApiResult<UrlDataDto> { Success = false, Code = "1010", Msg = "实时流请求失败" };
} }
result.Data!.Url = result.Data.Url + "?token=" + token;
return result; return result;
} }
catch (Exception ex) catch (Exception ex)
@ -305,10 +305,10 @@ namespace Video.DomainService
/// <param name="dto"></param> /// <param name="dto"></param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="NotImplementedException"></exception> /// <exception cref="NotImplementedException"></exception>
public async Task<DaHApiResult<UrlDataDto>> RtspPlaybackByTime(RtspPlaybackReqDto dto) public async Task<DaHApiResult<UrlDataDto>> RtspPlaybackByTime(RtspPlayBackReqDto dto)
{ {
// 参数校验 + 早退 // 参数校验 + 早退
if (dto == null || string.IsNullOrWhiteSpace(dto.ChannelId)) if (dto == null || string.IsNullOrWhiteSpace(dto.Data.ChannelId))
{ {
_logger.LogWarning("录像请求失败:通道ID不能为空"); _logger.LogWarning("录像请求失败:通道ID不能为空");
return new DaHApiResult<UrlDataDto> { Success = false, Code = "1007", Msg = "通道ID不能为空" }; return new DaHApiResult<UrlDataDto> { Success = false, Code = "1007", Msg = "通道ID不能为空" };
@ -343,7 +343,7 @@ namespace Video.DomainService
_logger.LogWarning("录像请求业务失败: {Body}", body); _logger.LogWarning("录像请求业务失败: {Body}", body);
return new DaHApiResult<UrlDataDto> { Success = false, Code = "1008", Msg = "录像请求失败" }; return new DaHApiResult<UrlDataDto> { Success = false, Code = "1008", Msg = "录像请求失败" };
} }
result.Data!.Url = result.Data.Url + "?token=" + token;
return result; return result;
} }
catch (Exception ex) catch (Exception ex)
@ -390,12 +390,12 @@ namespace Video.DomainService
} }
var result = JsonSerializer.Deserialize<DaHApiResult<UrlDataDto>>(body); var result = JsonSerializer.Deserialize<DaHApiResult<UrlDataDto>>(body);
if (result == null || !result.Success || result.Code != "100") if (result == null || !result.Success)
{ {
_logger.LogWarning("实时流请求业务失败: {Body}", body); _logger.LogWarning("实时流请求业务失败: {Body}", body);
return new DaHApiResult<UrlDataDto> { Success = false, Code = "1010", Msg = "实时流请求失败" }; return new DaHApiResult<UrlDataDto> { Success = false, Code = "1010", Msg = "实时流请求失败" };
} }
result.Data!.Url = result.Data.Url + "?token=" + result.Data!.Token;
return result; return result;
} }
catch (Exception ex) catch (Exception ex)

@ -27,7 +27,7 @@ namespace Video.DomainService
/// </summary> /// </summary>
/// <param name="dto"></param> /// <param name="dto"></param>
/// <returns></returns> /// <returns></returns>
Task<DaHApiResult<UrlDataDto>> RtspPlaybackByTime(RtspPlaybackReqDto dto); Task<DaHApiResult<UrlDataDto>> RtspPlaybackByTime(RtspPlayBackReqDto dto);
/// <summary> /// <summary>
/// 设备通道分页查询,需要用于HlsRecordVideo /// 设备通道分页查询,需要用于HlsRecordVideo

@ -32,7 +32,7 @@ namespace Video.DomainService
/// </summary> /// </summary>
/// <param name="dto"></param> /// <param name="dto"></param>
/// <returns></returns> /// <returns></returns>
Task<ApiResult<UrlDataDto>> RtspPlaybackByTime(RtspPlaybackReqDto dto); Task<ApiResult<UrlDataDto>> RtspPlaybackByTime(RtspPlayBackReqDto dto);
/// <summary> /// <summary>
/// 大华设备通道分页查询 /// 大华设备通道分页查询

@ -140,7 +140,7 @@ namespace Video.DomainService
/// </summary> /// </summary>
/// <param name="dto"></param> /// <param name="dto"></param>
/// <returns></returns> /// <returns></returns>
public async Task<ApiResult<UrlDataDto>> RtspPlaybackByTime(RtspPlaybackReqDto dto) public async Task<ApiResult<UrlDataDto>> RtspPlaybackByTime(RtspPlayBackReqDto dto)
{ {
ApiResult<UrlDataDto> result = new ApiResult<UrlDataDto>() { Code = 200, Msg = "接口调用成功" }; ApiResult<UrlDataDto> result = new ApiResult<UrlDataDto>() { Code = 200, Msg = "接口调用成功" };

Loading…
Cancel
Save