U8接口调整,改为异步,响应时间5秒
This commit is contained in:
@@ -5,6 +5,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using U8Server.Util;
|
||||
@@ -23,7 +24,7 @@ namespace ZR.Service.mes.wms_u8
|
||||
/// <param name="urlBase"></param>
|
||||
/// <param name="eRP_WMS_InteractiveModels"></param>
|
||||
/// <returns></returns>
|
||||
public ERP_WMS_interactiveModelResult Inbounded(string urlBase,List<ERP_WMS_interactiveModelQuery> eRP_WMS_InteractiveModels)
|
||||
public ERP_WMS_interactiveModelResult Inbounded(string urlBase, List<ERP_WMS_interactiveModelQuery> eRP_WMS_InteractiveModels)
|
||||
{
|
||||
string url = urlBase + "/wms/mes/inbounded";
|
||||
|
||||
@@ -34,7 +35,7 @@ namespace ZR.Service.mes.wms_u8
|
||||
headers.Add("sign", GetSign.GetBy16Md5());
|
||||
|
||||
string postData = JsonConvert.SerializeObject(eRP_WMS_InteractiveModels);
|
||||
Object result = HttpHelper.HttpPost(url, postData, contentType, 30, headers);
|
||||
Object result = HttpHelper.HttpPost(url, postData, contentType, 5, headers);
|
||||
if (result != null && result is ERP_WMS_interactiveModelResult)
|
||||
{
|
||||
return (ERP_WMS_interactiveModelResult)result;
|
||||
@@ -50,7 +51,7 @@ namespace ZR.Service.mes.wms_u8
|
||||
/// <param name="urlBase"></param>
|
||||
/// <param name="eRP_WMS_InteractiveModels"></param>
|
||||
/// <returns></returns>
|
||||
public ERP_WMS_interactiveModelResult Outbounded(string urlBase, List<ERP_WMS_interactiveModelQuery> eRP_WMS_InteractiveModels)
|
||||
public ERP_WMS_interactiveModelResult Outbounded(string urlBase, List<ERP_WMS_interactiveModelQuery> eRP_WMS_InteractiveModels)
|
||||
{
|
||||
string url = urlBase + "/wms/mes/outbounded";
|
||||
|
||||
@@ -61,7 +62,7 @@ namespace ZR.Service.mes.wms_u8
|
||||
headers.Add("sign", GetSign.GetBy16Md5());
|
||||
|
||||
string postData = JsonConvert.SerializeObject(eRP_WMS_InteractiveModels);
|
||||
Object result = HttpHelper.HttpPost(url, postData, contentType, 30, headers);
|
||||
Object result = HttpHelper.HttpPost(url, postData, contentType, 5, headers);
|
||||
if (result != null && result is ERP_WMS_interactiveModelResult)
|
||||
{
|
||||
return (ERP_WMS_interactiveModelResult)result;
|
||||
@@ -69,5 +70,77 @@ namespace ZR.Service.mes.wms_u8
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 入库接口 - 异步版本
|
||||
/// </summary>
|
||||
public async Task<ERP_WMS_interactiveModelResult> InboundedAsync(string urlBase, List<ERP_WMS_interactiveModelQuery> eRP_WMS_InteractiveModels)
|
||||
{
|
||||
string url = urlBase + "/wms/mes/inbounded";
|
||||
|
||||
string contentType = "application/json";
|
||||
Dictionary<string, string> headers = new Dictionary<string, string>
|
||||
{
|
||||
{ "appid", "gN9yId!!lfwaRoi3" },
|
||||
{ "timestamp", DateTime.Now.ToString("yyyyMMddHHmmss", CultureInfo.InvariantCulture) },
|
||||
{ "sign", GetSign.GetBy16Md5() }
|
||||
};
|
||||
|
||||
string postData = JsonConvert.SerializeObject(eRP_WMS_InteractiveModels);
|
||||
|
||||
try
|
||||
{
|
||||
// 调用HttpHelper的异步方法
|
||||
string resultJson = await HttpHelper.HttpPostAsync(url, postData, contentType, 5, headers);
|
||||
|
||||
// 反序列化结果
|
||||
if (!string.IsNullOrEmpty(resultJson) && resultJson != "异常:*")
|
||||
{
|
||||
return JsonConvert.DeserializeObject<ERP_WMS_interactiveModelResult>(resultJson);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"InboundedAsync 异常: {ex.Message}");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 出库接口 - 异步版本
|
||||
/// </summary>
|
||||
public async Task<ERP_WMS_interactiveModelResult> OutboundedAsync(string urlBase, List<ERP_WMS_interactiveModelQuery> eRP_WMS_InteractiveModels)
|
||||
{
|
||||
string url = urlBase + "/wms/mes/outbounded";
|
||||
|
||||
string contentType = "application/json";
|
||||
Dictionary<string, string> headers = new Dictionary<string, string>
|
||||
{
|
||||
{ "appid", "gN9yId!!lfwaRoi3" },
|
||||
{ "timestamp", DateTime.Now.ToString("yyyyMMddHHmmss", CultureInfo.InvariantCulture) },
|
||||
{ "sign", GetSign.GetBy16Md5() }
|
||||
};
|
||||
|
||||
string postData = JsonConvert.SerializeObject(eRP_WMS_InteractiveModels);
|
||||
|
||||
try
|
||||
{
|
||||
// 调用HttpHelper的异步方法
|
||||
string resultJson = await HttpHelper.HttpPostAsync(url, postData, contentType, 5, headers);
|
||||
|
||||
// 反序列化结果
|
||||
if (!string.IsNullOrEmpty(resultJson) && resultJson != "异常:*")
|
||||
{
|
||||
return JsonConvert.DeserializeObject<ERP_WMS_interactiveModelResult>(resultJson);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"OutboundedAsync 异常: {ex.Message}");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user