using HH.WCS.Mobox3.Template.Entity.Dto;
|
using HH.WCS.Mobox3.Template.Util.Helper;
|
using Newtonsoft.Json;
|
|
namespace HH.WCS.Mobox3.Template.Controller.Service
|
{
|
/// <summary>
|
/// 第三方实现类
|
/// </summary>
|
public static class ThirdPartyService
|
{
|
/// <summary>
|
/// Http帮助类
|
/// </summary>
|
private static readonly HttpHelper apiHelper = new HttpHelper();
|
|
/// <summary>
|
/// WMS任务创建
|
/// </summary>
|
/// <param name="baseUrl"></param>
|
/// <param name="url"></param>
|
/// <param name="model"></param>
|
/// <typeparam name="T"></typeparam>
|
/// <returns></returns>
|
public static bool CallWMSOperationCreate<T>(string baseUrl, string url, T model)
|
{
|
var request = JsonConvert.SerializeObject(model);
|
|
var response = apiHelper.Post(baseUrl + url, request);
|
|
if (!string.IsNullOrEmpty(response))
|
{
|
var dataResult = JsonConvert.DeserializeObject<ResultDto<object>>(response);
|
|
if (dataResult.code == 0)
|
{
|
LogHelper.Info($"WMS任务创建:CallWMSOperationCreate接口调用成功,入参为{request},返回值为{response}","AMS和WCS接口交互");
|
return true;
|
}
|
}
|
else
|
{
|
LogHelper.Info($"WMS任务创建:CallWMSOperationCreate接口调用失败,入参为{request},返回值为{response}","AMS和WCS接口交互");
|
}
|
|
return false;
|
}
|
|
/// <summary>
|
/// 四向车任务创建
|
/// </summary>
|
/// <param name="baseUrl"></param>
|
/// <param name="url"></param>
|
/// <param name="model"></param>
|
/// <typeparam name="T"></typeparam>
|
/// <returns></returns>
|
public static bool CallCarOperationCreate<T>(string baseUrl, string url, T model)
|
{
|
var request = JsonConvert.SerializeObject(model);
|
|
var response = apiHelper.Post(baseUrl + url, request);
|
|
if (!string.IsNullOrEmpty(response))
|
{
|
var dataResult = JsonConvert.DeserializeObject<ResultDto<string>>(response);
|
|
if (dataResult.code == 0)
|
{
|
LogHelper.Info($"四向车任务创建:CallCarOperationCreate接口调用成功,入参为{request},返回值为{response}","四向车和WCS接口交互");
|
return true;
|
}
|
}
|
else
|
{
|
LogHelper.Info($"四向车任务创建:CallCarOperationCreate接口调用失败,入参为{request},返回值为{response}","四向车和WCS接口交互");
|
}
|
|
return false;
|
}
|
|
/// <summary>
|
/// 四向车任务取消/强制完成
|
/// </summary>
|
/// <param name="baseUrl"></param>
|
/// <param name="url"></param>
|
/// <param name="model"></param>
|
/// <typeparam name="T"></typeparam>
|
/// <returns></returns>
|
public static ResultDto<string> CallCarOperationCommon<T>(string baseUrl, string url, T model)
|
{
|
var result = new ResultDto<string>();
|
result.code = -1;
|
|
var request = JsonConvert.SerializeObject(model);
|
|
var response = apiHelper.Post(baseUrl + url, request);
|
|
if (!string.IsNullOrEmpty(response))
|
{
|
result = JsonConvert.DeserializeObject<ResultDto<string>>(response);
|
|
if (result.code == 0)
|
{
|
LogHelper.Info($"四向车任务取消/强制完成:CallCarOperationCommon接口调用成功,入参为{request},返回值为{response}","四向车和WCS接口交互");
|
}
|
}
|
else
|
{
|
LogHelper.Info($"四向车任务取消/强制完成:CallCarOperationCommon接口调用失败,入参为{request},返回值为{response}","四向车和WCS接口交互");
|
}
|
|
return result;
|
}
|
|
/// <summary>
|
/// 提升机任务
|
/// </summary>
|
/// <param name="baseUrl"></param>
|
/// <param name="url"></param>
|
/// <param name="model"></param>
|
/// <typeparam name="T"></typeparam>
|
/// <returns></returns>
|
public static ResultDto<string> CreateHoister<T>(string baseUrl, string url, T model)
|
{
|
var result = new ResultDto<string>();
|
result.code = -1;
|
|
var request = JsonConvert.SerializeObject(model);
|
|
var response = apiHelper.Post(baseUrl + url, request);
|
|
if (!string.IsNullOrEmpty(response))
|
{
|
result = JsonConvert.DeserializeObject<ResultDto<string>>(response);
|
|
if (result.code == 0)
|
{
|
LogHelper.Info($"提升机任务:CreateHoister接口调用成功,入参为{request},返回值为{response}","四向车和WCS接口交互");
|
}
|
}
|
else
|
{
|
LogHelper.Info($"提升机任务:CreateHoister接口调用失败,入参为{request},返回值为{response}","四向车和WCS接口交互");
|
}
|
|
return result;
|
}
|
}
|
}
|