对接老ops
This commit is contained in:
@@ -9,6 +9,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.ServiceModel;
|
||||
using System.Threading.Tasks;
|
||||
using WMS.Web.Core.Dto;
|
||||
using WMS.Web.Core.Internal.Results;
|
||||
using WMS.Web.Domain.Infrastructure;
|
||||
using WMS.Web.Domain.IService;
|
||||
@@ -23,19 +24,28 @@ namespace WMS.Web.Api.Controllers
|
||||
private readonly IErpService _erpService;
|
||||
private IInStockTaskService _inStockTaskService;
|
||||
private IBasicsRepositories _transactionRepositories;
|
||||
private readonly IOpsService _opsService;
|
||||
|
||||
public TestController(IErpService erpService, IInStockTaskService inStockTaskService, IBasicsRepositories transactionRepositories)
|
||||
public TestController(IErpService erpService, IInStockTaskService inStockTaskService,
|
||||
IBasicsRepositories transactionRepositories, IOpsService opsService)
|
||||
{
|
||||
this._erpService = erpService;
|
||||
this._inStockTaskService = inStockTaskService;
|
||||
this._transactionRepositories = transactionRepositories;
|
||||
_opsService = opsService;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("hj")]
|
||||
public async Task<string> TestHJ()
|
||||
{
|
||||
var res = await this._erpService.BillQueryForSubStock();
|
||||
OpsBoxRequest request = new OpsBoxRequest()
|
||||
{
|
||||
StrartTime = DateTime.Now.AddYears(-1),
|
||||
EndTime=DateTime.Now
|
||||
};
|
||||
await _opsService.GetBox(request);
|
||||
//var res = await this._erpService.BillQueryForSubStock();
|
||||
//var result= await this._erpService.BillQueryForPurchaseInStock();
|
||||
//var result = await this._erpService.BillQueryForOrg();
|
||||
var result = await this._erpService.BillQueryForMaterial();
|
||||
|
||||
@@ -43,6 +43,11 @@
|
||||
"ErpId": "ce20210909",
|
||||
"PurchaseInstockFieldKeys": "FBillNo,FUOM,FSupplierId.FName,FPurchaseOrgId.FName,FMaterialName,FMaterialId.FNumber"
|
||||
},
|
||||
"OpsOptions": {
|
||||
"Url": "http://39.108.150.2:8050/",
|
||||
"UserName": "admin",
|
||||
"PassWord": "888888"
|
||||
},
|
||||
"Qiniu": {
|
||||
"AccessKey": "dOsTum4a5qvhPTBbZRPX0pIOU7PZWRX7htKjztms",
|
||||
"SecretKey": "KFxsGbnErkALFfeGdMa8QWTdodJbamMX0iznLe-q",
|
||||
|
||||
@@ -283,6 +283,13 @@
|
||||
<param name="id">仓库id</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Api.Controllers.SysConfigController.GetErp_SubUcStock(System.Int32)">
|
||||
<summary>
|
||||
根据仓库获取金蝶子仓库
|
||||
</summary>
|
||||
<param name="id">仓库id</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Api.Controllers.SysConfigController.GetSubUcStockByName(System.String)">
|
||||
<summary>
|
||||
获取仓位:模糊名称
|
||||
|
||||
@@ -2280,6 +2280,16 @@
|
||||
操作 Id集合
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Core.Dto.OpsBoxRequest">
|
||||
<summary>
|
||||
老ops箱信息请求
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Core.Dto.OpsBoxResponse">
|
||||
<summary>
|
||||
老ops箱信息
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Core.Dto.OutStockTask.GetOutStockTaskByNoResponse">
|
||||
<summary>
|
||||
根据单号搜索出库单任务信息
|
||||
|
||||
@@ -1907,6 +1907,11 @@
|
||||
采购入库:字段
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Domain.Options.OpsOptions">
|
||||
<summary>
|
||||
老ops对接
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Domain.Options.QuartzJobOptions">
|
||||
<summary>
|
||||
Quartz定时任务-配置项
|
||||
@@ -2558,6 +2563,11 @@
|
||||
<param name="sessionId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Domain.Services.Public.OpsService">
|
||||
<summary>
|
||||
ops服务
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Services.Public.RedisClientService.SetStringKey(System.String,System.String,System.Nullable{System.TimeSpan})">
|
||||
<summary>
|
||||
保存单个key value
|
||||
|
||||
19
src/WMS.Web.Core/Dto/OpsBoxRequest.cs
Normal file
19
src/WMS.Web.Core/Dto/OpsBoxRequest.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace WMS.Web.Core.Dto
|
||||
{
|
||||
/// <summary>
|
||||
/// 老ops箱信息请求
|
||||
/// </summary>
|
||||
public class OpsBoxRequest
|
||||
{
|
||||
public DateTime StrartTime { get; set; }
|
||||
public DateTime EndTime { get; set; }
|
||||
public string BoxBillNo { get; set; }
|
||||
|
||||
public int Page { get; set; } = 1;
|
||||
public int Limit { get; set; } = 10000000;
|
||||
}
|
||||
}
|
||||
13
src/WMS.Web.Core/Dto/OpsBoxResponse.cs
Normal file
13
src/WMS.Web.Core/Dto/OpsBoxResponse.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace WMS.Web.Core.Dto
|
||||
{
|
||||
/// <summary>
|
||||
/// 老ops箱信息
|
||||
/// </summary>
|
||||
public class OpsBoxResponse
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -34,12 +34,16 @@ namespace WMS.Web.Domain.Entitys
|
||||
/// <summary>
|
||||
/// 供应商Id
|
||||
/// </summary>
|
||||
public int SupplierId { get; set; }
|
||||
public int? SupplierId { get; set; }
|
||||
/// <summary>
|
||||
/// 组织Id
|
||||
/// </summary>
|
||||
public int? OrgId { get; set; }
|
||||
/// <summary>
|
||||
/// 创建时间(对应老OPS的创建时间)
|
||||
/// </summary>
|
||||
public DateTime CreateTime { get; set; } = DateTime.Now;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 明细
|
||||
/// </summary>
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace WMS.Web.Domain.IService.Public
|
||||
{
|
||||
public interface IHttpClientService
|
||||
{
|
||||
HttpClient BuildHttpClient(Dictionary<string, string> dicDefaultHeaders, int? timeoutSecond = 180);
|
||||
Task<T> GetAsync<T>(string url, int timeoutSecond = 180);
|
||||
Task<T> GetAsync<T>(string url, Dictionary<string, string> dicHeaders, int timeoutSecond = 180);
|
||||
Task<T> PostAsync<T>(string url, string requestBody, int timeoutSecond = 180);
|
||||
|
||||
13
src/WMS.Web.Domain/IService/Public/IOpsService.cs
Normal file
13
src/WMS.Web.Domain/IService/Public/IOpsService.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WMS.Web.Core.Dto;
|
||||
|
||||
namespace WMS.Web.Domain.IService.Public
|
||||
{
|
||||
public interface IOpsService
|
||||
{
|
||||
Task GetBox(OpsBoxRequest request);
|
||||
}
|
||||
}
|
||||
16
src/WMS.Web.Domain/Options/OpsOptions.cs
Normal file
16
src/WMS.Web.Domain/Options/OpsOptions.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace WMS.Web.Domain.Options
|
||||
{
|
||||
/// <summary>
|
||||
/// 老ops对接
|
||||
/// </summary>
|
||||
public class OpsOptions
|
||||
{
|
||||
public string Url { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public string PassWord { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -105,8 +105,8 @@ namespace WMS.Web.Domain.Services.Public
|
||||
/// <returns></returns>
|
||||
public async Task<T> PostAsync<T>(string url, string requestBody, Dictionary<string, string> dicHeaders, int timeoutSecond = 180)
|
||||
{
|
||||
var client = BuildHttpClient(null, timeoutSecond);
|
||||
var requestContent = GenerateStringContent(requestBody, dicHeaders);
|
||||
var client = BuildHttpClient(dicHeaders, timeoutSecond);
|
||||
var requestContent = GenerateStringContent(requestBody, contentHeaders);
|
||||
var response = await client.PostAsync(url, requestContent);
|
||||
var responseContent = await response.Content.ReadAsStringAsync();
|
||||
if (response.IsSuccessStatusCode)
|
||||
@@ -213,7 +213,7 @@ namespace WMS.Web.Domain.Services.Public
|
||||
/// <param name="dicDefaultHeaders"></param>
|
||||
/// <param name="timeoutSecond"></param>
|
||||
/// <returns></returns>
|
||||
private HttpClient BuildHttpClient(Dictionary<string, string> dicDefaultHeaders, int? timeoutSecond)
|
||||
public HttpClient BuildHttpClient(Dictionary<string, string> dicDefaultHeaders, int? timeoutSecond=180)
|
||||
{
|
||||
var httpClient = _clientFactory.CreateClient("ops_client");
|
||||
httpClient.DefaultRequestHeaders.Clear(); //为了使客户端不受最后一个请求的影响,它需要清除DefaultRequestHeaders
|
||||
|
||||
81
src/WMS.Web.Domain/Services/Public/OpsService.cs
Normal file
81
src/WMS.Web.Domain/Services/Public/OpsService.cs
Normal file
@@ -0,0 +1,81 @@
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WMS.Web.Core.Dto;
|
||||
using WMS.Web.Domain.IService.Public;
|
||||
using WMS.Web.Domain.Options;
|
||||
|
||||
namespace WMS.Web.Domain.Services.Public
|
||||
{
|
||||
/// <summary>
|
||||
/// ops服务
|
||||
/// </summary>
|
||||
public class OpsService : IOpsService
|
||||
{
|
||||
private readonly IHttpClientService _httpClientService;
|
||||
private readonly ILogger<OpsService> _logger;
|
||||
private readonly IMemoryCache _memoryCache;
|
||||
private int hours = 10;//过期时间 默认10小时
|
||||
private readonly OpsOptions _option;
|
||||
|
||||
public OpsService(IHttpClientService httpClientService, ILogger<OpsService> logger,
|
||||
IMemoryCache memoryCache, IOptions<OpsOptions> option)
|
||||
{
|
||||
this._memoryCache = memoryCache;
|
||||
this._httpClientService = httpClientService;
|
||||
this._logger = logger;
|
||||
_option = option?.Value;
|
||||
}
|
||||
|
||||
public async Task GetBox(OpsBoxRequest request)
|
||||
{
|
||||
var token = await GetToken();
|
||||
Dictionary<string, string> dicHeaders = new Dictionary<string, string>();
|
||||
dicHeaders.Add("Authorization", "Bearer " + token);
|
||||
//_httpClientService.BuildHttpClient(contentHeaders);
|
||||
var res= await _httpClientService.PostAsync<OpsReponse>(_option.Url + "BarCode/carton-box_api/carton-box", JsonConvert.SerializeObject(request), dicHeaders);
|
||||
}
|
||||
|
||||
private async Task<string> GetToken()
|
||||
{
|
||||
OpsLogin login = new OpsLogin()
|
||||
{
|
||||
hAccount = _option.UserName,
|
||||
hPassword = _option.PassWord
|
||||
};
|
||||
var res = await _httpClientService.PostAsync<OpsReponse>(_option.Url + "api/login", JsonConvert.SerializeObject(login));
|
||||
var token = res.data?.token ?? "";
|
||||
if (string.IsNullOrEmpty(token))
|
||||
_logger.LogInformation("老Ops登录失败:" + res?.errors);
|
||||
return token;
|
||||
}
|
||||
|
||||
}
|
||||
public class OpsLogin
|
||||
{
|
||||
public OpsLogin() { }
|
||||
public string hAccount { get; set; } = "admin";
|
||||
public string hPassword { get; set; } = "888888";
|
||||
}
|
||||
public class OpsInfo
|
||||
{
|
||||
public int code { get; set; }
|
||||
public string message { get; set; }
|
||||
public string date { get; set; }
|
||||
public string token { get; set; }
|
||||
}
|
||||
public class OpsReponse
|
||||
{
|
||||
public int statusCode { get; set; }
|
||||
public bool succeeded { get; set; }
|
||||
public string errors { get; set; }
|
||||
public string extras { get; set; }
|
||||
|
||||
public OpsInfo data { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -174,6 +174,8 @@ namespace WMS.Web.Repositories.DependencyInjection
|
||||
Services.Configure<HttpOptions>(Configuration.GetSection("HttpOptions"));
|
||||
Services.AddOptions<ErpOptions>();
|
||||
Services.Configure<ErpOptions>(Configuration.GetSection("ErpOptions"));
|
||||
Services.AddOptions<OpsOptions>();
|
||||
Services.Configure<OpsOptions>(Configuration.GetSection("OpsOptions"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -234,6 +236,7 @@ namespace WMS.Web.Repositories.DependencyInjection
|
||||
Services.AddTransient<ISingleDataService, SingleDataService>();
|
||||
Services.AddTransient<IErpService, ErpService>();
|
||||
Services.AddTransient<IBackRecordService, BackRecordService>();
|
||||
Services.AddTransient<IOpsService, OpsService>();
|
||||
|
||||
|
||||
Services.AddTransient<IChangeMoveBoxService, ChangeMoveBoxService>();
|
||||
|
||||
Reference in New Issue
Block a user