From 0bf76ef3a9b626c23d866a7b0350fb523a7e0263 Mon Sep 17 00:00:00 2001 From: LiuXin Date: Mon, 24 Nov 2025 10:16:33 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E4=B8=80?= =?UTF-8?q?=E4=B8=8B=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SunPalaceBoardSafetyService.cs | 2 +- .../ThirdPartyProviderService.cs | 78 ++++++++++++++++--- 2 files changed, 69 insertions(+), 11 deletions(-) diff --git a/WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.DomainService/ShenZhouShengAn/SunPalaceBoardSafetyService.cs b/WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.DomainService/ShenZhouShengAn/SunPalaceBoardSafetyService.cs index e917fec..3b93eab 100644 --- a/WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.DomainService/ShenZhouShengAn/SunPalaceBoardSafetyService.cs +++ b/WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.DomainService/ShenZhouShengAn/SunPalaceBoardSafetyService.cs @@ -98,7 +98,7 @@ namespace ThirdPartyServices.DomainService.ShenZhouShengAn } //获取单位信息 - HttpClientResult branchs = await _tokenProviderService.GetBranchPermissions(token, loginUsers.Data.Uid); + HttpClientResult branchs = await _tokenProviderService.GetBranchPermissions(token, loginUsers.Data.Ubpid); if (branchs.Code == "Error" || branchs.Data == null || branchs.Data.BranchPermissionIds == null || branchs.Data.BranchPermissionIds.Length == 0) { _logger.LogWarning("GetProductionRiskEchart接口获取单位信息失败"); diff --git a/WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.DomainService/ShenZhouShengAn/ThirdPartyProviderService.cs b/WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.DomainService/ShenZhouShengAn/ThirdPartyProviderService.cs index 9bc8dd6..39130cf 100644 --- a/WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.DomainService/ShenZhouShengAn/ThirdPartyProviderService.cs +++ b/WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.DomainService/ShenZhouShengAn/ThirdPartyProviderService.cs @@ -1,4 +1,5 @@ using Microsoft.Extensions.Logging; +using Org.BouncyCastle.Ocsp; using System.Net.Http.Headers; using System.Net.Http.Json; using System.Text.Json; @@ -89,13 +90,28 @@ namespace ThirdPartyServices.DomainService.ShenZhouShengAn { HttpClientResult result = new HttpClientResult() { Code = "Success", Message = "请求成功" }; - result = await SendAndParseAsync>( - "https://zrh.szdunan.cn/v1/api/branch/index_no_check_branch", - token, - ubpid, - HttpMethod.Post); + try + { + // 构造表单参数(key必须是"ubpid",和Postman一致) + var formData = new Dictionary + { + { "ubpid", ubpid.ToString() } // 转换为字符串,匹配表单提交格式 + }; - return result; + // 调用表单提交方法,而非JSON提交 + result = await SendFormAndParseAsync>( + "https://zrh.szdunan.cn/v1/api/branch/index_no_check_branch", + token, + formData, + HttpMethod.Post); + + return result; + } + catch (Exception ex) + { + _logger.LogError(ex, "获取分支权限失败"); + return new HttpClientResult { Code = "Error", Message = $"请求异常:{ex.Message}" }; + } } /// @@ -110,10 +126,7 @@ namespace ThirdPartyServices.DomainService.ShenZhouShengAn public async Task SendJsonAsync(string url, string? token, TRequest? payload, HttpMethod method) { using var request = new HttpRequestMessage(method, url); - if (!string.IsNullOrWhiteSpace(token)) - { - request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token); - } + request.Headers.TryAddWithoutValidation("Authorization", "Bearer " + token); // 写入 JSON 请求体(POST、PUT、PATCH 等适用) if (payload != null && method != HttpMethod.Get) { @@ -166,5 +179,50 @@ namespace ThirdPartyServices.DomainService.ShenZhouShengAn { return SendAndParseAsync(url, token, null, method); } + + /// + /// 发送表单格式请求(适配 multipart/form-data) + /// + public async Task SendFormDataAsync(string url, string? token, Dictionary formData, HttpMethod method) + { + using var request = new HttpRequestMessage(method, url); + request.Headers.TryAddWithoutValidation("Authorization", "Bearer " + token); + request.Headers.TryAddWithoutValidation("Accept", "*/*"); + + // 构造 multipart/form-data 表单数据 + var formContent = new MultipartFormDataContent(); + foreach (var item in formData) + { + // 添加表单参数(key=ubpid, value=31) + formContent.Add(new StringContent(item.Value), item.Key); + } + request.Content = formContent; + + var response = await _httpClient.SendAsync(request); + + if (!response.IsSuccessStatusCode) + { + var error = await response.Content.ReadAsStringAsync(); + throw new Exception($"请求失败:{response.StatusCode}, 内容:{error}"); + } + + return await response.Content.ReadAsStringAsync(); + } + + /// + /// 表单请求 + 解析结果(适配 BranchResDto) + /// + public async Task SendFormAndParseAsync( + string url, + string? token, + Dictionary formData, + HttpMethod method) + { + var responseContent = await SendFormDataAsync(url, token, formData, method); + return JsonSerializer.Deserialize(responseContent, new JsonSerializerOptions + { + PropertyNameCaseInsensitive = true // 忽略大小写匹配(避免字段名大小写问题) + }) ?? throw new Exception("反序列化返回结果失败"); + } } } \ No newline at end of file From 6a2e7282127ce5bb4dc9ed3d225c1cd4470ce21b Mon Sep 17 00:00:00 2001 From: LiuXin Date: Mon, 24 Nov 2025 11:30:21 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ShenZhouShengAn/SunPalaceBoardSafetyService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.DomainService/ShenZhouShengAn/SunPalaceBoardSafetyService.cs b/WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.DomainService/ShenZhouShengAn/SunPalaceBoardSafetyService.cs index 3b93eab..ff87ee4 100644 --- a/WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.DomainService/ShenZhouShengAn/SunPalaceBoardSafetyService.cs +++ b/WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.DomainService/ShenZhouShengAn/SunPalaceBoardSafetyService.cs @@ -315,7 +315,7 @@ namespace ThirdPartyServices.DomainService.ShenZhouShengAn } //获取单位信息 - HttpClientResult branchs = await _tokenProviderService.GetBranchPermissions(token, loginUsers.Data.Uid); + HttpClientResult branchs = await _tokenProviderService.GetBranchPermissions(token, loginUsers.Data.Ubpid); if (branchs.Code == "Error" || branchs.Data == null || branchs.Data.BranchPermissionIds == null || branchs.Data.BranchPermissionIds.Length == 0) { _logger.LogWarning("GetProductionRiskEchart接口获取单位信息失败"); @@ -525,7 +525,7 @@ namespace ThirdPartyServices.DomainService.ShenZhouShengAn } //获取单位信息 - HttpClientResult branchs = await _tokenProviderService.GetBranchPermissions(token, loginUsers.Data.Uid); + HttpClientResult branchs = await _tokenProviderService.GetBranchPermissions(token, loginUsers.Data.Ubpid); if (branchs.Code == "Error" || branchs.Data == null || branchs.Data.BranchPermissionIds == null || branchs.Data.BranchPermissionIds.Length == 0) { _logger.LogWarning("GetStatistics接口获取单位信息失败"); From 8f15bde91d8caec3e6d49baee20add6124342bae Mon Sep 17 00:00:00 2001 From: LiuXin Date: Tue, 25 Nov 2025 10:50:49 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SunPlaceBoardWorkOrderResDto.cs | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) 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 d70ade4..2fd9edc 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 @@ -400,13 +400,19 @@ namespace Common.Shared.Application.SafetyFirePro.ResponseDto /// 计划结束时间 /// [JsonPropertyName("end_at")] - public string End_at { get; set; } + public string? End_at { get; set; } + + /// + /// 计划开始时间 + /// + [JsonPropertyName("real_start_at")] + public string? Real_start_at { get; set; } /// /// 实际结束时间 /// [JsonPropertyName("finish_time")] - public string Finish_time { get; set; } + public string? Finish_time { get; set; } /// /// 作业ID @@ -418,31 +424,25 @@ namespace Common.Shared.Application.SafetyFirePro.ResponseDto /// 作业名称 /// [JsonPropertyName("name")] - public string Name { get; set; } + public string? Name { get; set; } /// /// 作业编号 /// [JsonPropertyName("number")] - public string Number { get; set; } + public string? Number { get; set; } /// /// 作业人员信息 /// [JsonPropertyName("operators")] - public List Operators { get; set; } + public List Operators { get; set; } = []; /// /// 作业负责人信息 /// [JsonPropertyName("principal_info")] - public PrincipalInfo Principal_info { get; set; } - - /// - /// 实际开始作业时间 - /// - [JsonPropertyName("real_start_at")] - public string Real_start_at { get; set; } + public PrincipalInfo Principal_info { get; set; } = new PrincipalInfo(); /// /// 作业地点id @@ -454,19 +454,19 @@ namespace Common.Shared.Application.SafetyFirePro.ResponseDto /// 作业地点信息 /// [JsonPropertyName("region")] - public Region Region { get; set; } + public Region Region { get; set; } = new Region(); /// /// 作业检查信息 /// [JsonPropertyName("Supervises")] - public List Supervises { get; set; } + public List Supervises { get; set; } = []; /// /// 作业计划开始时间 /// [JsonPropertyName("start_at")] - public string Start_at { get; set; } + public string? Start_at { get; set; } /// /// 作业状态 @@ -491,6 +491,12 @@ namespace Common.Shared.Application.SafetyFirePro.ResponseDto [JsonPropertyName("name")] public string Name { get; set; } + + /// + /// 创建时间 + /// + [JsonPropertyName("created_at")] + public string? Created_at { get; set; } } public class ApprovalTask From 5623227ed087658a616204c8be8358a5523e6d53 Mon Sep 17 00:00:00 2001 From: LiuXin Date: Tue, 25 Nov 2025 10:51:11 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Common.Shared.Application/Common.Shared.Application.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 e252f5a..5026abf 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 - 4.2 + 4.3 zrh-lx zrh-lx 包含所有公共使用的 DTO、契约、接口模型等,供微服务之间共享使用