Browse Source

部分单元测试提交

Murphy 3 years ago
parent
commit
2468ee754d
21 changed files with 682 additions and 12 deletions
  1. 1 0
      MicroServices/Business/Buissness.UnitTest/Buissness.TestBase.csproj
  2. 19 8
      MicroServices/Business/Buissness.UnitTest/CoreTestBaseModule.cs
  3. 13 0
      MicroServices/Business/Buissness.UnitTest/MongoCollection.cs
  4. 14 0
      MicroServices/Business/Buissness.UnitTest/MongoDbCollectionFixtureBase.cs
  5. 27 0
      MicroServices/Business/Buissness.UnitTest/MongoDbFixture.cs
  6. 0 1
      MicroServices/Business/Business.Application.Contracts/Business.Application.Contracts.csproj
  7. 29 0
      MicroServices/Business/Business.Application.Contracts/WMS/ISyncKingdeeAppService.cs
  8. 0 1
      MicroServices/Business/Business.Application/Business.Application.csproj
  9. 38 0
      MicroServices/Business/Business.Application/WMS/SyncKingdeeAppService.cs
  10. 207 0
      MicroServices/Business/Business.Core/HttpHelper/DefaultCoreClient.cs
  11. 16 0
      MicroServices/Business/Business.Core/HttpHelper/HttpMember.cs
  12. 18 0
      MicroServices/Business/Business.Core/HttpHelper/HttpMethod.cs
  13. 21 0
      MicroServices/Business/Business.Core/HttpHelper/HttpParameter.cs
  14. 18 0
      MicroServices/Business/Business.Core/HttpHelper/HttpPropertyAttribute.cs
  15. 16 0
      MicroServices/Business/Business.Core/HttpHelper/ICoreClient.cs
  16. 18 0
      MicroServices/Business/Business.Core/HttpHelper/IRequest.cs
  17. 51 0
      MicroServices/Business/Business.Core/HttpHelper/Response.cs
  18. 113 0
      MicroServices/Business/Business.Core/Utilities/HttpHelper.cs
  19. 0 1
      MicroServices/Business/Business.HttpApi/Business.HttpApi.csproj
  20. 53 0
      MicroServices/Business/Business.HttpApi/Controllers/WMS/KingdeeController.cs
  21. 10 1
      MicroServices/Business/Bussiness.ApplicationTest/ResourceExamineManagement/ResourceExamineAppService_Tests.cs

+ 1 - 0
MicroServices/Business/Buissness.UnitTest/Buissness.TestBase.csproj

@@ -8,6 +8,7 @@
 
   <ItemGroup>
     <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
+    <PackageReference Include="Mongo2Go" Version="3.1.3" />
     <PackageReference Include="NSubstitute" Version="4.2.2" />
     <PackageReference Include="Shouldly" Version="4.1.0" />
     <PackageReference Include="Volo.Abp.Authorization" Version="4.4.0" />

+ 19 - 8
MicroServices/Business/Buissness.UnitTest/CoreTestBaseModule.cs

@@ -23,15 +23,26 @@ namespace Buissness.TestBase
     {
         public override void PreConfigureServices(ServiceConfigurationContext context)
         {
-            PreConfigure<AbpIdentityServerBuilderOptions>(options =>
-            {
-                options.AddDeveloperSigningCredential = false;
-            });
+            //PreConfigure<AbpIdentityServerBuilderOptions>(options =>
+            //{
+            //    options.AddDeveloperSigningCredential = false;
+            //});
 
-            PreConfigure<IIdentityServerBuilder>(identityServerBuilder =>
-            {
-                identityServerBuilder.AddDeveloperSigningCredential(false, System.Guid.NewGuid().ToString());
-            });
+            //PreConfigure<IIdentityServerBuilder>(identityServerBuilder =>
+            //{
+            //    identityServerBuilder.AddDeveloperSigningCredential(false, System.Guid.NewGuid().ToString());
+            //});
+
+
+            //var stringArray = MongoDbFixture.ConnectionString.Split('?');
+            //var connectionString = stringArray[0].EnsureEndsWith('/') +
+            //                           "Db_" +
+            //                       Guid.NewGuid().ToString("N") + "/?" + stringArray[1];
+
+            //Configure<AbpDbConnectionOptions>(options =>
+            //{
+            //    options.ConnectionStrings.Default = connectionString;
+            //});
         }
 
         public override void ConfigureServices(ServiceConfigurationContext context)

+ 13 - 0
MicroServices/Business/Buissness.UnitTest/MongoCollection.cs

@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Buissness.TestBase
+{
+    public class MongoCollection : MongoDbCollectionFixtureBase
+    {
+
+    }
+}

+ 14 - 0
MicroServices/Business/Buissness.UnitTest/MongoDbCollectionFixtureBase.cs

@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace Buissness.TestBase
+{
+    public class MongoDbCollectionFixtureBase : ICollectionFixture<MongoDbFixture>
+    {
+
+    }
+}

+ 27 - 0
MicroServices/Business/Buissness.UnitTest/MongoDbFixture.cs

@@ -0,0 +1,27 @@
+using Mongo2Go;
+using MongoDB.Driver.Core.Configuration;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Buissness.TestBase
+{
+    public class MongoDbFixture : IDisposable
+    {
+        private static readonly MongoDbRunner MongoDbRunner;
+        public static readonly string ConnectionString;
+
+        static MongoDbFixture()
+        {
+            MongoDbRunner = MongoDbRunner.Start(singleNodeReplSet: true, singleNodeReplSetWaitTimeout: 20);
+            ConnectionString = MongoDbRunner.ConnectionString;
+        }
+
+        public void Dispose()
+        {
+            MongoDbRunner?.Dispose();
+        }
+    }
+}

+ 0 - 1
MicroServices/Business/Business.Application.Contracts/Business.Application.Contracts.csproj

@@ -43,7 +43,6 @@
   </ItemGroup>
 
   <ItemGroup>
-    <Folder Include="WMS\" />
     <Folder Include="MES\" />
   </ItemGroup>
 

+ 29 - 0
MicroServices/Business/Business.Application.Contracts/WMS/ISyncKingdeeAppService.cs

@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Volo.Abp.Application.Services;
+
+namespace Business.ResourceExamineManagement
+{
+    /// <summary>
+    /// 流水号生成
+    /// </summary>
+    public interface ISyncKingdeeAppService : IApplicationService
+    {
+        /// <summary>
+        /// 同步金蝶供应商
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        string SyncSupplier();
+
+        /// <summary>
+        /// 同步金蝶物料表
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        string SyncMaterial();
+    }
+}

+ 0 - 1
MicroServices/Business/Business.Application/Business.Application.csproj

@@ -29,7 +29,6 @@
   <ItemGroup>
     <Folder Include="MES\" />
     <Folder Include="QMS\" />
-    <Folder Include="WMS\" />
   </ItemGroup>
 
 </Project>

+ 38 - 0
MicroServices/Business/Business.Application/WMS/SyncKingdeeAppService.cs

@@ -0,0 +1,38 @@
+using Business.ResourceExamineManagement.Dto;
+using Bussiness.Model.MES.IC;
+using Bussiness.Model.SystemData;
+using Bussiness.Model.Tech;
+using Bussiness.MongoModel.MES.IC;
+using Microsoft.Extensions.Configuration;
+using System;
+using System.Collections.Generic;
+using System.Text.RegularExpressions;
+using Volo.Abp.Application.Services;
+using Volo.Abp.Domain.Repositories;
+
+namespace Business.ResourceExamineManagement
+{
+    public class SyncKingdeeAppService : ApplicationService, ISyncKingdeeAppService
+    {
+        private readonly IRepository<sys_serial_number, long> _sys_serial_number;
+
+        public SyncKingdeeAppService(IRepository<sys_serial_number, long> sys_serial_number) {
+            _sys_serial_number = sys_serial_number;
+        }
+        public string SyncSupplier()
+        {
+            IConfiguration configuration = new ConfigurationBuilder().SetBasePath(Environment.CurrentDirectory).AddJsonFile("appsettings.json").Build();
+            var test111=configuration["AuthServer:Authority"];
+            List<mes_technique> _Techniques= new List<mes_technique>();
+            _Techniques.Add(new mes_technique { level = 1, tech_name = "1111" });
+            _Techniques.Add(new mes_technique { level = 2, tech_name = "2222" });
+            _Techniques.Add(new mes_technique { level = 3, tech_name = "333" });
+            return "";
+        }
+
+       public string SyncMaterial()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

+ 207 - 0
MicroServices/Business/Business.Core/HttpHelper/DefaultCoreClient.cs

@@ -0,0 +1,207 @@
+using Amazon.Runtime.Internal;
+using Newtonsoft.Json.Serialization;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Business.Core.HttpHelper
+{
+    public class DefaultCoreClient : ICoreClient
+    {
+        public string Endpoint { get; }
+        public string ContentType { get; set; }
+        public string UserAgent { get; set; }
+        public string Accept { get; set; }
+        public string Host { get; set; }
+        public string Referer { get; set; }
+        public bool KeepAlive { get; set; }
+        public int Timeout { get; set; }
+        public CookieContainer CookieContainer { get; set; }
+        public DefaultCoreClient(string endpoint)
+        {
+            Endpoint = endpoint;
+            KeepAlive = true;
+            Timeout = 10000;
+            ContentType = "application/x-www-form-urlencoded";
+            UserAgent = "Mozilla/5.0 (Linux; Android 10; WLZ-AL10 Build/HUAWEIWLZ-AL10; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045513 Mobile Safari/537.36 MMWEBID/4985 MicroMessenger/7.0.22.1820(0x2700163B) Process/tools WeChat/arm64 Weixin NetType/WIFI Language/zh_CN ABI/arm64";
+            Accept = "*/*";
+            Host = "wx.sxhealth.net";
+            Referer = "wx.sxhealth.net";
+            CookieContainer _container = new CookieContainer();
+            _container.Add(new Cookie("JSESSIONID", "AA644E43F2FDB7159DEC7BED2E7A2EAF", "/sxsrmyynew", "wx.sxhealth.net"));
+            CookieContainer = _container;
+        }
+
+        protected virtual byte[] BuildBody(IDictionary<string, object> paras)
+        {
+            JsonSerializerSettings settings = new JsonSerializerSettings
+            {
+                ContractResolver = new CamelCasePropertyNamesContractResolver()
+            };
+            string s = JsonConvert.SerializeObject(paras, settings);
+            return Encoding.UTF8.GetBytes(s);
+        }
+        protected virtual T ReadBody<T>(HttpWebResponse rsp)
+        {
+            T t;
+            using (Stream responseStream = rsp.GetResponseStream())
+            {
+                using (StreamReader streamReader = new StreamReader(responseStream, Encoding.UTF8))
+                {
+                    string text = streamReader.ReadToEnd();
+                    if (string.IsNullOrEmpty(text))
+                    {
+                        t = default(T);
+                    }
+                    else
+                    {
+                        Type typeFromHandle = typeof(T);
+                        string name = typeFromHandle.Name;
+                        if (name != null)
+                        {
+                            if (name == "String")
+                            {
+                                return (T)((object)Convert.ChangeType(text, typeFromHandle));
+                            }
+                            if (name == "Int32")
+                            {
+                                return (T)((object)Convert.ChangeType(int.Parse(text), typeFromHandle));
+                            }
+                            if (name == "Double")
+                            {
+                                return (T)((object)Convert.ChangeType(double.Parse(text), typeFromHandle));
+                            }
+                            if (name == "DateTime")
+                            {
+                                return (T)((object)Convert.ChangeType(DateTime.Parse(text), typeFromHandle));
+                            }
+                        }
+                        t = JsonConvert.DeserializeObject<T>(text);
+                    }
+                }
+            }
+            return t;
+        }
+        protected virtual string ReadError(HttpWebResponse rsp)
+        {
+            string result;
+            using (Stream responseStream = rsp.GetResponseStream())
+            {
+                using (StreamReader streamReader = new StreamReader(responseStream, Encoding.UTF8))
+                {
+                    result = streamReader.ReadToEnd();
+                }
+            }
+            return result;
+        }
+
+        HttpWebRequest BuildRequest(IRequest req)
+        {
+            Type attribute = typeof(HttpPropertyAttribute);
+            Dictionary<HttpMember, Dictionary<string, object>> dictionary = req.GetType().GetProperties()
+                .Where(p => p.IsDefined(attribute, false))
+                .Select(p => new HttpParameter(
+                    ((HttpPropertyAttribute)p.GetCustomAttributes(attribute, false).First()).Member,
+                    p.Name,
+                    p.GetValue(req)
+                 ))
+                .GroupBy(p => p.Member)
+                .ToDictionary(g => g.Key, g => g.ToDictionary(p => p.Name, p => p.Value));
+            string path = req.GetPath();
+            string text = string.IsNullOrEmpty(path) ? Endpoint : (Endpoint + "/" + path);
+            HttpWebRequest httpWebRequest = WebRequest.Create(text) as HttpWebRequest;
+            httpWebRequest.Method = req.GetMethod().ToString();
+            httpWebRequest.KeepAlive = KeepAlive;
+            httpWebRequest.Timeout = Timeout;
+            httpWebRequest.ContentType = ContentType;
+            httpWebRequest.UserAgent = UserAgent;
+            httpWebRequest.Accept = Accept;
+            httpWebRequest.Host = Host;
+            httpWebRequest.Referer = Referer;
+            httpWebRequest.CookieContainer = CookieContainer;
+            if (dictionary.TryGetValue(HttpMember.Header, out Dictionary<string, object> dictionary2))
+            {
+                foreach (KeyValuePair<string, object> keyValuePair in dictionary2)
+                {
+                    httpWebRequest.Headers.Add(keyValuePair.Key, keyValuePair.Value.ToString());
+                }
+            }
+            if (dictionary.TryGetValue(HttpMember.Body, out Dictionary<string, object> paras))
+            {
+                byte[] array = BuildBody(paras);
+                httpWebRequest.ContentLength = array.Length;
+                using (Stream requestStream = httpWebRequest.GetRequestStream())
+                {
+                    requestStream.Write(array, 0, array.Length);
+                    return httpWebRequest;
+                }
+            }
+            if (dictionary.TryGetValue(HttpMember.From, out Dictionary<string, object> paras2))
+            {
+                string s = string.Join("&", paras2.Select(r => $"{r.Key}={r.Value}").ToArray());
+                byte[] array = Encoding.UTF8.GetBytes(s);
+                httpWebRequest.ContentLength = array.Length;
+                using (Stream requestStream = httpWebRequest.GetRequestStream())
+                {
+                    requestStream.Write(array, 0, array.Length);
+                    return httpWebRequest;
+                }
+            }
+            return httpWebRequest;
+        }
+        public virtual Response Execute(IRequest req)
+        {
+            Response result;
+            try
+            {
+                using (HttpWebResponse httpWebResponse = BuildRequest(req).GetResponse() as HttpWebResponse)
+                {
+                    result = new Response(httpWebResponse.StatusCode, null);
+                }
+            }
+            catch (Exception ex)
+            {
+                if (ex is WebException && (ex as WebException).Response != null)
+                {
+                    using (HttpWebResponse httpWebResponse2 = (ex as WebException).Response as HttpWebResponse)
+                    {
+                        return new Response(httpWebResponse2.StatusCode, ReadError(httpWebResponse2));
+                    }
+                }
+                result = new Response(HttpStatusCode.InternalServerError, ex.Message);
+            }
+            return result;
+        }
+        public virtual Response<T> Execute<T>(IRequest<T> req)
+        {
+            Response<T> result;
+            try
+            {
+                using (HttpWebResponse httpWebResponse = BuildRequest(req).GetResponse() as HttpWebResponse)
+                {
+                    result = new Response<T>(httpWebResponse.StatusCode, ReadBody<T>(httpWebResponse), null);
+                }
+            }
+            catch (Exception ex)
+            {
+                if (ex is WebException && (ex as WebException).Response != null)
+                {
+                    using (HttpWebResponse httpWebResponse2 = (ex as WebException).Response as HttpWebResponse)
+                    {
+                        return new Response<T>(httpWebResponse2.StatusCode, default(T), ReadError(httpWebResponse2));
+                    }
+                }
+                result = new Response<T>(HttpStatusCode.InternalServerError, default(T), ex.Message);
+            }
+            return result;
+        }
+        public IAsyncResult BeginExecute(IRequest req, AsyncCallback callback)
+        {
+            return BuildRequest(req).BeginGetResponse(callback, req);
+        }
+    }
+}

+ 16 - 0
MicroServices/Business/Business.Core/HttpHelper/HttpMember.cs

@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Business.Core.HttpHelper
+{
+    public enum HttpMember
+    {
+        Query,
+        Header,
+        Body,
+        From
+    }
+}

+ 18 - 0
MicroServices/Business/Business.Core/HttpHelper/HttpMethod.cs

@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Business.Core.HttpHelper
+{
+    public enum HttpMethod
+    {
+        GET,
+        POST,
+        PUT,
+        DELETE,
+        HEAD,
+        OPTIONS
+    }
+}

+ 21 - 0
MicroServices/Business/Business.Core/HttpHelper/HttpParameter.cs

@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Business.Core.HttpHelper
+{
+    public class HttpParameter
+    {
+        public HttpMember Member { get; }
+        public string Name { get; private set; }
+        public object Value { get; }
+        public HttpParameter(HttpMember member, string name, object value)
+        {
+            Member = member;
+            Name = name;
+            Value = value;
+        }
+    }
+}

+ 18 - 0
MicroServices/Business/Business.Core/HttpHelper/HttpPropertyAttribute.cs

@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Business.Core.HttpHelper
+{
+    [AttributeUsage(AttributeTargets.Property)]
+    public sealed class HttpPropertyAttribute : Attribute
+    {
+        public HttpMember Member { get; }
+        public HttpPropertyAttribute(HttpMember member)
+        {
+            Member = member;
+        }
+    }
+}

+ 16 - 0
MicroServices/Business/Business.Core/HttpHelper/ICoreClient.cs

@@ -0,0 +1,16 @@
+using Amazon.Runtime.Internal;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Business.Core.HttpHelper
+{
+    public interface ICoreClient
+    {
+        Response Execute(IRequest req);
+        Response<T> Execute<T>(IRequest<T> req);
+        IAsyncResult BeginExecute(IRequest req, AsyncCallback callback);
+    }
+}

+ 18 - 0
MicroServices/Business/Business.Core/HttpHelper/IRequest.cs

@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Business.Core.HttpHelper
+{
+    public interface IRequest
+    {
+        string GetPath();
+        HttpMethod GetMethod();
+    }
+
+    public interface IRequest<T> : IRequest
+    {
+    }
+}

+ 51 - 0
MicroServices/Business/Business.Core/HttpHelper/Response.cs

@@ -0,0 +1,51 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Business.Core.HttpHelper
+{
+    public class Validation
+    {
+        public string Error { get; set; }
+        public Validation(string error = null)
+        {
+            Error = error;
+        }
+        public bool Success
+        {
+            get { return Error == null; }
+        }
+        public bool Fail
+        {
+            get { return Error != null; }
+        }
+    }
+    public class Validation<T> : Validation
+    {
+        public T Body { get; }
+        public Validation(T body = default(T), string error = null) : base(error)
+        {
+            Body = body;
+        }
+    }
+
+    public class Response : Validation
+    {
+        public HttpStatusCode HttpCode { get; }
+        public Response(HttpStatusCode code, string error = null) : base(error)
+        {
+            HttpCode = code;
+        }
+    }
+    public class Response<T> : Validation<T>
+    {
+        public HttpStatusCode HttpCode { get; }
+        public Response(HttpStatusCode code, T body = default(T), string error = null) : base(body, error)
+        {
+            HttpCode = code;
+        }
+    }
+}

+ 113 - 0
MicroServices/Business/Business.Core/Utilities/HttpHelper.cs

@@ -0,0 +1,113 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Business.Core.Utilities
+{
+    public class HttpHelper
+    {/// <summary>
+     /// 发起POST同步请求
+     /// 
+     /// </summary>
+     /// <param name="url"></param>
+     /// <param name="postData"></param>
+     /// <param name="contentType">application/xml、application/json、application/text、application/x-www-form-urlencoded</param>
+     /// <param name="headers">填充消息头</param>        
+     /// <returns></returns>
+        public static string HttpPost(string url, string postData = null, string contentType = null, int timeOut = 30, Dictionary<string, string> headers = null)
+        {
+            postData = postData ?? "";
+            using (HttpClient client = new HttpClient())
+            {
+                if (headers != null)
+                {
+                    foreach (var header in headers)
+                        client.DefaultRequestHeaders.Add(header.Key, header.Value);
+                }
+                using (HttpContent httpContent = new StringContent(postData, Encoding.UTF8))
+                {
+                    if (contentType != null)
+                        httpContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(contentType);
+
+                    HttpResponseMessage response = client.PostAsync(url, httpContent).Result;
+                    return response.Content.ReadAsStringAsync().Result;
+                }
+            }
+        }
+
+
+        /// <summary>
+        /// 发起POST异步请求
+        /// </summary>
+        /// <param name="url"></param>
+        /// <param name="postData"></param>
+        /// <param name="contentType">application/xml、application/json、application/text、application/x-www-form-urlencoded</param>
+        /// <param name="headers">填充消息头</param>        
+        /// <returns></returns>
+        public static async Task<string> HttpPostAsync(string url, string postData = null, string contentType = null, int timeOut = 30, Dictionary<string, string> headers = null)
+        {
+            postData = postData ?? "";
+            using (HttpClient client = new HttpClient())
+            {
+                client.Timeout = new TimeSpan(0, 0, timeOut);
+                if (headers != null)
+                {
+                    foreach (var header in headers)
+                        client.DefaultRequestHeaders.Add(header.Key, header.Value);
+                }
+                using (HttpContent httpContent = new StringContent(postData, Encoding.UTF8))
+                {
+                    if (contentType != null)
+                        httpContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(contentType);
+
+                    HttpResponseMessage response = await client.PostAsync(url, httpContent);
+                    return await response.Content.ReadAsStringAsync();
+                }
+            }
+        }
+
+        /// <summary>
+        /// 发起GET同步请求
+        /// </summary>
+        /// <param name="url"></param>
+        /// <param name="headers"></param>
+        /// <param name="contentType"></param>
+        /// <returns></returns>
+        public static string HttpGet(string url, Dictionary<string, string> headers = null)
+        {
+            using (HttpClient client = new HttpClient())
+            {
+                if (headers != null)
+                {
+                    foreach (var header in headers)
+                        client.DefaultRequestHeaders.Add(header.Key, header.Value);
+                }
+                HttpResponseMessage response = client.GetAsync(url).Result;
+                return response.Content.ReadAsStringAsync().Result;
+            }
+        }
+
+        /// <summary>
+        /// 发起GET异步请求
+        /// </summary>
+        /// <param name="url"></param>
+        /// <param name="headers"></param>
+        /// <param name="contentType"></param>
+        /// <returns></returns>
+        public static async Task<string> HttpGetAsync(string url, Dictionary<string, string> headers = null)
+        {
+            using (HttpClient client = new HttpClient())
+            {
+                if (headers != null)
+                {
+                    foreach (var header in headers)
+                        client.DefaultRequestHeaders.Add(header.Key, header.Value);
+                }
+                HttpResponseMessage response = await client.GetAsync(url);
+                return await response.Content.ReadAsStringAsync();
+            }
+        }
+    }
+}

+ 0 - 1
MicroServices/Business/Business.HttpApi/Business.HttpApi.csproj

@@ -25,7 +25,6 @@
   </ItemGroup>
 
   <ItemGroup>
-    <Folder Include="Controllers\WMS\" />
     <Folder Include="Controllers\MES\" />
     <Folder Include="Controllers\DOP\" />
   </ItemGroup>

+ 53 - 0
MicroServices/Business/Business.HttpApi/Controllers/WMS/KingdeeController.cs

@@ -0,0 +1,53 @@
+using Business.Core.Utilities;
+using Business.ResourceExamineManagement;
+using Bussiness.Model.SystemData;
+using Microsoft.AspNetCore.Mvc;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Volo.Abp;
+using Volo.Abp.AspNetCore.Mvc;
+using static Business.Permissions.BusinessPermissions;
+
+namespace Business.Controllers.WMS
+{
+    /// <summary>
+    /// 金蝶数据同步接口
+    /// </summary>
+    [RemoteService]
+    [Area("Business")]
+    [Route("api/business/kingdee")]
+    public class KingdeeController : AbpController
+    {
+        private readonly ISyncKingdeeAppService _SerialNumberAppService;
+
+        public KingdeeController(ISyncKingdeeAppService SerialNumberAppService)
+        {
+            _SerialNumberAppService = SerialNumberAppService;
+        }
+
+        /// <summary>
+        /// 同步供应商
+        /// </summary>
+        /// <returns></returns>
+        [HttpGet]
+        [Route("syncsupplier")]
+        public string SyncSupplier()
+        {
+            return _SerialNumberAppService.SyncSupplier();
+        }
+
+        /// <summary>
+        /// 同步供应商
+        /// </summary>
+        /// <returns></returns>
+        [HttpGet]
+        [Route("syncmaterial")]
+        public string SyncMaterial()
+        {
+            return _SerialNumberAppService.SyncMaterial();
+        }
+    }
+}

+ 10 - 1
MicroServices/Business/Bussiness.ApplicationTest/ResourceExamineManagement/ResourceExamineAppService_Tests.cs

@@ -6,6 +6,7 @@ using System.Threading.Tasks;
 using Business.ResourceExamineManagement;
 using Business.ResourceExamineManagement.Dto;
 using Bussiness.ApplicationTest;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Shouldly;
 using Volo.Abp.Identity;
 using Xunit;
@@ -24,7 +25,15 @@ namespace Bussiness.ApplicationTest.ResourceExamineManagement
         public async Task Should_ThrowExcetion()
         {
             var testInput = new SeorderentryDto { factoryId = 10201, sorderId = 111111, tenantId = 102 };
-            await Assert.ThrowsAsync<NotImplementedException>(async () => await _resourceExamineAppService.ReceiveResult(testInput));
+            await Xunit.Assert.ThrowsAsync<NotImplementedException>(async () => await _resourceExamineAppService.ReceiveResult(testInput));
+        }
+
+        [Fact]
+        [ExpectedException(typeof(NotImplementedException))]
+        public async Task Should_ThrowExcetion_Second()
+        {
+            var testInput = new SeorderentryDto { factoryId = 10201, sorderId = 111111, tenantId = 102 };
+            await _resourceExamineAppService.ReceiveResult(testInput);
         }
     }
 }