From 9f3217da2ecabd0be9074bfdf3b32e4ccefcdb0c Mon Sep 17 00:00:00 2001 From: LiuXin Date: Mon, 22 Sep 2025 16:18:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=B8=AA=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E4=BF=A1=E6=81=AF=E6=9F=A5=E8=AF=A2=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Common.Shared.Application.csproj | 2 +- .../SunPlaceBoardWorkOrderResDto.cs | 2 +- .../DaHua/VideoManageController.cs | 6 -- .../ResponeDto/RecordDataResDto.cs | 64 +++++++++++++++++++ .../Video.Application.csproj | 5 +- .../Dahvision/DahuaGeneralCtlService.cs | 40 +++++++++++- 6 files changed, 106 insertions(+), 13 deletions(-) create mode 100644 WeiCloud.Fusion/VideoService/Video.Application/ResponeDto/RecordDataResDto.cs diff --git a/WeiCloud.Fusion/Common.SharedService/Common.Shared.Application/Common.Shared.Application.csproj b/WeiCloud.Fusion/Common.SharedService/Common.Shared.Application/Common.Shared.Application.csproj index 66060be..e0b4d32 100644 --- a/WeiCloud.Fusion/Common.SharedService/Common.Shared.Application/Common.Shared.Application.csproj +++ b/WeiCloud.Fusion/Common.SharedService/Common.Shared.Application/Common.Shared.Application.csproj @@ -7,7 +7,7 @@ Common.Shared.Application - 3.2.0 + 3.3.0 zrh-lx zrh-lx 包含所有公共使用的 DTO、契约、接口模型等,供微服务之间共享使用 diff --git a/WeiCloud.Fusion/Common.SharedService/Common.Shared.Application/SafetyFirePro/ResponseDto/SunPlaceBoardWorkOrderResDto.cs b/WeiCloud.Fusion/Common.SharedService/Common.Shared.Application/SafetyFirePro/ResponseDto/SunPlaceBoardWorkOrderResDto.cs index 5220c2e..8087694 100644 --- a/WeiCloud.Fusion/Common.SharedService/Common.Shared.Application/SafetyFirePro/ResponseDto/SunPlaceBoardWorkOrderResDto.cs +++ b/WeiCloud.Fusion/Common.SharedService/Common.Shared.Application/SafetyFirePro/ResponseDto/SunPlaceBoardWorkOrderResDto.cs @@ -1023,7 +1023,7 @@ namespace Common.Shared.Application.SafetyFirePro.ResponseDto /// 验收结果,1通过,2不通过 /// [JsonPropertyName("status")] - public string Status { get; set; } = string.Empty; // 按你标注的"验收结果"设为string,可根据实际JSON改为int? + public int? Status { get; set; } // 按你标注的"验收结果"设为string,可根据实际JSON改为int? /// /// 验收人姓名 diff --git a/WeiCloud.Fusion/VideoService/Video.API/Controllers/DaHua/VideoManageController.cs b/WeiCloud.Fusion/VideoService/Video.API/Controllers/DaHua/VideoManageController.cs index b37b30a..65f8490 100644 --- a/WeiCloud.Fusion/VideoService/Video.API/Controllers/DaHua/VideoManageController.cs +++ b/WeiCloud.Fusion/VideoService/Video.API/Controllers/DaHua/VideoManageController.cs @@ -50,12 +50,6 @@ namespace Video.API.Controllers.DaHua return await _dahGeneralCtlService.RecordVideoUrl(dto, ipaddress); } - // 全局设置(只在测试环境使用!) - private static readonly HttpClient _http = new HttpClient(new HttpClientHandler - { - ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator - }); - /// /// 大华的录像回放地址(rtsp) /// diff --git a/WeiCloud.Fusion/VideoService/Video.Application/ResponeDto/RecordDataResDto.cs b/WeiCloud.Fusion/VideoService/Video.Application/ResponeDto/RecordDataResDto.cs new file mode 100644 index 0000000..6ecd4a4 --- /dev/null +++ b/WeiCloud.Fusion/VideoService/Video.Application/ResponeDto/RecordDataResDto.cs @@ -0,0 +1,64 @@ +using System.Text.Json.Serialization; + +namespace Video.Application.ResponeDto +{ + public class RecordDataResDto + { + /// + /// 录像记录集合 + /// + [JsonPropertyName("records")] + public List Records { get; set; } + } + + public class Record + { + [JsonPropertyName("channelId")] + public string ChannelId { get; set; } + + [JsonPropertyName("recordSource")] + public string RecordSource { get; set; } + + [JsonPropertyName("recordType")] + public string RecordType { get; set; } + + /// + /// 开始时间(时间戳,秒) + /// + [JsonPropertyName("startTime")] + public string StartTime { get; set; } + + /// + /// 结束时间(时间戳,秒) + /// + [JsonPropertyName("endTime")] + public string EndTime { get; set; } + + [JsonPropertyName("recordName")] + public string RecordName { get; set; } + + [JsonPropertyName("fileLength")] + public string FileLength { get; set; } + + [JsonPropertyName("planId")] + public string PlanId { get; set; } + + [JsonPropertyName("ssId")] + public string SsId { get; set; } + + [JsonPropertyName("diskId")] + public string DiskId { get; set; } + + [JsonPropertyName("streamId")] + public string StreamId { get; set; } + + [JsonPropertyName("forgotten")] + public string Forgotten { get; set; } + + [JsonPropertyName("streamType")] + public string StreamType { get; set; } + + [JsonPropertyName("videoRecordType")] + public string VideoRecordType { get; set; } + } +} \ No newline at end of file diff --git a/WeiCloud.Fusion/VideoService/Video.Application/Video.Application.csproj b/WeiCloud.Fusion/VideoService/Video.Application/Video.Application.csproj index b234dd2..e603622 100644 --- a/WeiCloud.Fusion/VideoService/Video.Application/Video.Application.csproj +++ b/WeiCloud.Fusion/VideoService/Video.Application/Video.Application.csproj @@ -7,8 +7,9 @@ - - + + + diff --git a/WeiCloud.Fusion/VideoService/Video.DomainService/Dahvision/DahuaGeneralCtlService.cs b/WeiCloud.Fusion/VideoService/Video.DomainService/Dahvision/DahuaGeneralCtlService.cs index 844275a..d596d2f 100644 --- a/WeiCloud.Fusion/VideoService/Video.DomainService/Dahvision/DahuaGeneralCtlService.cs +++ b/WeiCloud.Fusion/VideoService/Video.DomainService/Dahvision/DahuaGeneralCtlService.cs @@ -6,6 +6,7 @@ using NPOI.XWPF.UserModel; using System.Net.Http.Json; using System.Text; using System.Text.Json; +using Video.Application.ResponeDto; using Video.DomainService.Dahvision; namespace Video.DomainService @@ -339,6 +340,7 @@ namespace Video.DomainService /// /// rtsp录像回放 + /// TODO:后续增加一个调用视频信息接口,去得到里面recordType=多少 /// (播放命令:ffplay -rtsp_transport tcp -i "rtsp://demo.weienergy.cn:15210/dss/monitor/param/cameraid=1000021%24104%26substream=1?token=430")强制走tcp /// /// @@ -362,12 +364,44 @@ namespace Video.DomainService return new DaHApiResult { Success = false, Code = "1009", Msg = "token无效" }; } + //查询普通录像信息,这块是为了知道recordType=多少 + var urls = $"https://{_configuration["DahuaAuth:Host"]}/evo-apigw/admin/API/SS/Record/QueryRecords"; + if (ipaddress != null) + { + urls = $"https://{ipaddress}/evo-apigw/admin/API/SS/Record/QueryRecords"; + } + RtspPlayBackReqDto reqDto = new RtspPlayBackReqDto() + { + Data = new() + { + ChannelId = dto.Data.ChannelId, + RecordSource = dto.Data.RecordSource, + startTime = dto.Data.startTime, + EndTime = dto.Data.EndTime, + StreamType = dto.Data.StreamType, + RecordType = "0" + } + }; + using var reqs = new HttpRequestMessage(HttpMethod.Post, urls) + { + Content = JsonContent.Create(reqDto) // 关键:把 dto 放进请求体 + }; + reqs.Headers.TryAddWithoutValidation("Authorization", token); + + using var resp = await _http.SendAsync(reqs); + var bodys = await resp.Content.ReadAsStringAsync(); + var resultRecord = JsonSerializer.Deserialize>(bodys); + if (resultRecord == null || !resultRecord.Success) + { + _logger.LogWarning("查询普通录像信息: {Body}", bodys); + return new DaHApiResult { Success = false, Code = "1008", Msg = "查询普通录像信息" }; + } var url = $"https://{_configuration["DahuaAuth:Host"]}/evo-apigw/admin/API/SS/Playback/StartPlaybackByTime"; if (ipaddress != null) { url = $"https://{ipaddress}/evo-apigw/admin/API/SS/Playback/StartPlaybackByTime"; } - + dto.Data.RecordType = resultRecord.Data!.Records[0].RecordType; using var req = new HttpRequestMessage(HttpMethod.Post, url) { Content = JsonContent.Create(dto) // 关键:把 dto 放进请求体 @@ -376,8 +410,8 @@ namespace Video.DomainService try { - using var resp = await _http.SendAsync(req); // 关键:用 SendAsync 发送 req - var body = await resp.Content.ReadAsStringAsync(); + using var rep = await _http.SendAsync(req); + var body = await rep.Content.ReadAsStringAsync(); if (!resp.IsSuccessStatusCode) { -- 2.36.2