Эх сурвалжийг харах

Merge branch 'master' of http://git.12345lm.cn/Fengwo/data-sharing

TANG JIANG 1 жил өмнө
parent
commit
9b1589e3fe

+ 1 - 1
src/DataSharing.Application/Receivers/ProvinceReceiver.cs

@@ -2217,7 +2217,7 @@ namespace DataSharing.Application.Receivers
             var fileJson = _mapper.Map<List<FileJson>>(dto.FileJson);
             var configEnterprise = _channelConfigurationManager.GetConfigurationEnterprise();
             //将待推送数据写入待推送表
-            await InitPushDataAsync("EnterprisePushWorkOrder", "platform/12345/pushWorkOrder", System.Text.Json.JsonSerializer.Serialize(enterpriseData),
+            await InitPushDataAsync("EnterprisePushWorkOrder", YbEnterpriseDefaults.PathEnterprisesWorkOrder, System.Text.Json.JsonSerializer.Serialize(enterpriseData),
                 platformSource: EPlatformSource.Enterprise, fileJson: fileJson, cancellationToken: cancellationToken);
 
         }

+ 5 - 1
src/DataSharing.Host/Controllers/EnterpriseController.cs

@@ -16,6 +16,7 @@ using Microsoft.Extensions.Options;
 using XF.Domain.Filters;
 using XF.Domain.Options;
 using XF.Domain.Repository;
+using static Org.BouncyCastle.Math.EC.ECCurve;
 
 namespace DataSharing.Host.Controllers
 {
@@ -100,7 +101,10 @@ namespace DataSharing.Host.Controllers
             var enterpriseList = _mapper.Map<SelectEnterpriseList>(dto);
 
             var configEnterprise = _channelConfigurationManager.GetConfigurationEnterprise();
-            var response = await _enterpriseClient.RequestAsync<EnterpriseResponse>(configEnterprise.AddressUrl + "platform/12345/selectEnterpriseList", "Post", System.Text.Json.JsonSerializer.Serialize(enterpriseList), HttpContext.RequestAborted);
+            string baseAddress = configEnterprise.AddressUrl;
+            if (!baseAddress.EndsWith('/'))
+                baseAddress += "/";
+            var response = await _enterpriseClient.RequestAsync<EnterpriseResponse>(baseAddress + YbEnterpriseDefaults.PathEnterprisesList, "Post", System.Text.Json.JsonSerializer.Serialize(enterpriseList), HttpContext.RequestAborted);
 
             if (response != null)
             {

+ 15 - 0
src/DataSharing.Share/Dtos/Enterprise/YbEnterpriseDefaults.cs

@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DataSharing.Share.Dtos.Enterprise
+{
+    public class YbEnterpriseDefaults
+    {
+        public const string PathToken = "blade-auth/oauth/getAccessToken";
+        public const string PathEnterprisesList = "platform/12345/selectEnterpriseList";
+        public const string PathEnterprisesWorkOrder = "platform/12345/pushWorkOrder";
+    }
+}

+ 3 - 2
src/DataSharing/Enterprise/EnterpriseClient.cs

@@ -6,6 +6,7 @@ using System.Net.Http.Headers;
 using XF.Domain.Cache;
 using XF.Domain.Dependency;
 using XF.Domain.Exceptions;
+using static IdentityModel.OidcConstants;
 
 namespace DataSharing.Enterprise
 {
@@ -41,7 +42,7 @@ namespace DataSharing.Enterprise
             var token = cacheToken.GetOrSet(KeyToken,
                    d => GetTokenAsync(cancellationToken).GetAwaiter().GetResult(),
                    TimeSpan.FromMinutes(118));
-
+            _logger.LogWarning("请求接口地址:--------------" + url);
             var configEnterprise = channelconfigManager.GetConfigurationEnterprise();
             return await httpInvoker.RequestStringContentAsync<TResponse>(url, httpMethod, stringContent,
                 d => d.SetHttpClient(configEnterprise.AddressUrl, token), cancellationToken);
@@ -71,7 +72,7 @@ namespace DataSharing.Enterprise
 
             var request = new ClientCredentialsTokenRequest
             {
-                Address = $"{baseAddress}blade-auth/oauth/getAccessToken",
+                Address = $"{baseAddress}{YbEnterpriseDefaults.PathToken}",
                 Headers =
                 {
                     Accept =

+ 9 - 5
src/DataSharing/Enterprise/EnterprisePusherProviderService.cs

@@ -66,11 +66,11 @@ namespace DataSharing.Enterprise
                     try
                     {
                         #region 读取数据
-                        var baseAddress = businessFile.BaseUrl;
-                        if (!baseAddress.EndsWith('/'))
-                            baseAddress += "/";
+                        var baseAddressFile = businessFile.BaseUrl;
+                        if (!baseAddressFile.EndsWith('/'))
+                            baseAddressFile += "/";
 
-                        string url = string.Format("{0}{1}?Source={2}&Id={3}", baseAddress, businessFile.DownloadUrlAddress, businessFile.Source, item.FileId);
+                        string url = string.Format("{0}{1}?Source={2}&Id={3}", baseAddressFile, businessFile.DownloadUrlAddress, businessFile.Source, item.FileId);
                         using (var client = _httpClientFactory.CreateClient())
                         using (var response = await client.GetAsync(url))
                         {
@@ -110,7 +110,11 @@ namespace DataSharing.Enterprise
                 request = System.Text.Json.JsonSerializer.Serialize(data);
             }
             var config = _channelConfigurationManager.GetConfigurationEnterprise();
-            var enterprise = await _enterpriseClient.RequestAsync<EnterpriseResponse>(config.AddressUrl + dto.Path, dto.HttpMethod, request, cancellationToken);
+            string baseAddress = config.AddressUrl;
+            if (!baseAddress.EndsWith('/'))
+                baseAddress += "/";
+
+            var enterprise = await _enterpriseClient.RequestAsync<EnterpriseResponse>(baseAddress + dto.Path, dto.HttpMethod, request, cancellationToken);
             //如果推送成功修改数据状态
             if (enterprise != null)
             {