using Tiger.Model; using SqlSugar; using System; using System.Collections.Generic; using System.Linq.Expressions; using System.Text; using System.Threading.Tasks; using Rhea.Common; using System.Net; using System.Linq; using Newtonsoft.Json; using Tiger.IBusiness; using Microsoft.AspNetCore.Http; using Tiger.Model.Minsun; using Org.BouncyCastle.Asn1.Tsp; using Tiger.Model.Entitys.MES.Position; using Apache.NMS.ActiveMQ.Commands; using System.Security.Cryptography; using System.Diagnostics; using Tiger.Model.Entitys.MES.U9C; using Newtonsoft.Json.Linq; using System.Security.Policy; using NetTaste; namespace Tiger.Business.WMS { public partial class WMS_U9C : IWMS_U9C { public static string U9CAuthLoginUrl { get; set; } = ApiConfig.IsTestServer ? Cache.SysParam["U9CAuthLoginUrl_Test", "U9CUrl"].PARAM_VALUE : Cache.SysParam["U9CAuthLoginUrl", "U9CUrl"].PARAM_VALUE; // "http://172.16.80.20/U9C/webapi/OAuth2/AuthLogin?"; 测试 //public static string U9CAuthLoginUrl { get; set; } = Cache.SysParam["U9CAuthLoginUrl", "U9CUrl"].PARAM_VALUE; //正式 public static string secret = "&entcode=02&orgcode=101&clientid=mes&clientsecret=12c8ee7e9bb74ad2a6a0fb3315c8af20"; public static string CreateRcvBySrcASNUrl { get; set; } = ApiConfig.IsTestServer ? Cache.SysParam["CreateRcvBySrcASNUrl_Test", "U9CUrl"].PARAM_VALUE : Cache.SysParam["CreateRcvBySrcASNUrl", "U9CUrl"].PARAM_VALUE; //"http://172.16.80.20/U9C/webapi/Receivement/CreateRcvBySrcASN"; 测试 public static string CreateReceivementUrl { get; set; } = ApiConfig.IsTestServer ? Cache.SysParam["CreateReceivementUrl_Test", "U9CUrl"].PARAM_VALUE : Cache.SysParam["CreateReceivementUrl", "U9CUrl"].PARAM_VALUE; //"http://172.16.80.20/U9C/webapi/Receivement/CreateReceivement"; 测试 public static string SubmitLineUrl { get; set; } = ApiConfig.IsTestServer ? Cache.SysParam["SubmitLineUrl_Test", "U9CUrl"].PARAM_VALUE : Cache.SysParam["SubmitLineUrl", "U9CUrl"].PARAM_VALUE; //http://172.16.80.20/u9c/webapi/Receivement/SubmitLine; 测试 public static string ApproveLineUrl { get; set; } = ApiConfig.IsTestServer ? Cache.SysParam["ApproveLineUrl_Test", "U9CUrl"].PARAM_VALUE : Cache.SysParam["ApproveLineUrl", "U9CUrl"].PARAM_VALUE; //http://172.16.80.20/u9c/webapi/Receivement/ApproveLine; 测试 /// /// 新增收货单-来源ASN单接口 /// /// /// public async Task> CreateRcvBySrcASN(CreateRcvBySrcASNInput input) { Logger.Interface.Info($"/**\r\n *进入新增收货单-来源ASN单接口....\r\n */\r\n"); //固定写法 var action = new ApiAction(); try { if (input.IsLogin) { var u9CLoginResult = await HttpHelper.GetAsync($"{U9CAuthLoginUrl}userCode={input.userId}{secret}"); if (u9CLoginResult.Success) { input.token = u9CLoginResult.Data; Logger.Interface.Info($"U9C登录token: {input.token}"); } } List param = new() { new() { aSNToRcvTransDTOs = new(){ new(){ TransQty=new() { m_amount1= input.CurRevQty, m_uOM1 = new() { UOMMain = "1002212260110007", UOMMain_SKey=new(){ ID="1002212260110007", }, UOMSub_SKey = new(){ ID="1002212260110007", } }, }, ASNLineKey=input.ASNLineKey, } } } }; var response = await HttpHelper.PostAsync(CreateRcvBySrcASNUrl, JsonConvert.SerializeObject(param), new Dictionary() { { "token", input.token } }); var result = JsonConvert.DeserializeObject(response.Message); if (result != null) { if (result.Success && result.Data[0].IsSucess) { Logger.Interface.Info($"新增收货单-来源ASN单接口提交Json: {JsonConvert.SerializeObject(param)},返回Json: {response.Message}"); } else { action.IsSuccessed = false; action.LocaleMsg = new($"{action.Message}; {result.Data[0].ErrorMsg}"); Logger.Interface.Info($"新增收货单-来源ASN单失败:{result.Data[0].ErrorMsg}"); } } } catch (System.Exception ex) { action.CatchExceptionWithLog(ex, "新增收货单-来源ASN单异常"); } Logger.Interface.Info($"/* 新增收货单-来源ASN单接口结束 */\r\n"); //固定写法 return action; } /// /// 新增收货单-无来源接口 /// /// /// public async Task> CreateReceivement(CreateReceivementInput input) { Logger.Interface.Info($"/**\r\n *进入新增收货单-无来源接口....\r\n */\r\n"); //固定写法 var action = new ApiAction(); try { if (input.IsLogin) { var u9CLoginResult = await HttpHelper.GetAsync($"{U9CAuthLoginUrl}userCode={input.userId}{secret}"); if (u9CLoginResult.Success) { input.token = u9CLoginResult.Data; Logger.Interface.Info($"U9C登录token: {input.token}"); } } CreateReceivementParam param = new() { rcvDTO = new() { BusinessDate = DateTime.Now, Supplier = new() { m_code = "C.9999" }, RcvDocType = new() { m_code = "RCV01" }, RcvLines= new() { }, IsRcvByChangeable =true, IsPriceListChangeable = true, IsConfirmTermChangeable = true, IsPaymentTermChangeable = true, IsLineApprove= true, }, OtherID = "WMS" }; var response = await HttpHelper.PostAsync(CreateReceivementUrl, JsonConvert.SerializeObject(param), new Dictionary() { { "token", input.token } }); var result = JsonConvert.DeserializeObject(response.Message); if (result != null) { if (result.Success && result.Data[0].IsSucess) { Logger.Interface.Info($"新增收货单-无来源接口提交Json: {JsonConvert.SerializeObject(param)},返回Json: {response.Message}"); } else { action.IsSuccessed = false; action.LocaleMsg = new($"{action.Message}; {result.Data[0].ErrorMsg}"); Logger.Interface.Info($"新增收货-单无来源失败:{result.Data[0].ErrorMsg}"); } } } catch (System.Exception ex) { action.CatchExceptionWithLog(ex, "新增收货单-无来源异常"); } Logger.Interface.Info($"/* 新增收货单-无来源接口结束 */\r\n"); //固定写法 return action; } /// /// 收货单-行审核总入口接口 /// /// /// public async Task> ReceivementApproveLine(SubmitLineInput input) { Logger.Interface.Info($"/**\r\n *进入收货单-行审核总入口接口....\r\n */\r\n"); //固定写法 var action = new ApiAction(); try { if (input.IsLogin) { var u9CLoginResult = await HttpHelper.GetAsync($"{U9CAuthLoginUrl}userCode={input.userId}{secret}"); if (u9CLoginResult.Success) { input.token = u9CLoginResult.Data; Logger.Interface.Info($"U9C登录token: {input.token}"); } } var response = await HttpHelper.PostAsync(ApproveLineUrl, JsonConvert.SerializeObject(input.param), new Dictionary() { { "token", input.token } }); var result = JsonConvert.DeserializeObject(response.Message); if (result != null) { if (result.Success && result.Data[0].IsSucess) { Logger.Interface.Info($"收货单-行审核总入口接口提交Json: {JsonConvert.SerializeObject(input.param)},返回Json: {response.Message}"); } else { action.IsSuccessed = false; action.LocaleMsg = new($"{action.Message}; {result.Data[0].ErrorMsg}"); Logger.Interface.Info($"收货单-行审核总入口接口失败:{result.Data[0].ErrorMsg}"); } } action = await SubmitLine(input); if (action.IsSuccessed) { action = await ApproveLine(input); } } catch (System.Exception ex) { action.CatchExceptionWithLog(ex, "收货单-行审核总入口异常"); } Logger.Interface.Info($"/* 收货单-行审核总方法接口结束 */\r\n"); //固定写法 return action; } /// /// 收货单-行提交 /// /// /// private async Task> SubmitLine(SubmitLineInput input) { Logger.Interface.Info($"/**\r\n *进入收货单-行提交接口....\r\n */\r\n"); //固定写法 var action = new ApiAction(); try { if (input.IsLogin) { var u9CLoginResult = await HttpHelper.GetAsync($"{U9CAuthLoginUrl}userCode={input.userId}{secret}"); if (u9CLoginResult.Success) { input.token = u9CLoginResult.Data; Logger.Interface.Info($"U9C登录token: {input.token}"); } } var response = await HttpHelper.PostAsync(SubmitLineUrl, JsonConvert.SerializeObject(input.param), new Dictionary() { { "token", input.token } }); var result = JsonConvert.DeserializeObject(response.Message); if (result != null) { if (result.Success && result.Data[0].IsSucess) { Logger.Interface.Info($"收货单-行提交接口提交Json: {JsonConvert.SerializeObject(input.param)},返回Json: {response.Message}"); } else { action.IsSuccessed = false; action.LocaleMsg = new($"{action.Message}; {result.Data[0].ErrorMsg}"); Logger.Interface.Info($"收货单-行提交接口失败:{result.Data[0].ErrorMsg}"); } } } catch (System.Exception ex) { action.CatchExceptionWithLog(ex, "收货单-行提交异常"); } Logger.Interface.Info($"/* 收货单-行提交接口结束 */\r\n"); //固定写法 return action; } /// /// 收货单-行审核 /// /// /// private async Task> ApproveLine(SubmitLineInput input) { Logger.Interface.Info($"/**\r\n *进入收货单-行审核接口....\r\n */\r\n"); //固定写法 var action = new ApiAction(); try { if (input.IsLogin) { var u9CLoginResult = await HttpHelper.GetAsync($"{U9CAuthLoginUrl}userCode={input.userId}{secret}"); if (u9CLoginResult.Success) { input.token = u9CLoginResult.Data; Logger.Interface.Info($"U9C登录token: {input.token}"); } } var response = await HttpHelper.PostAsync(ApproveLineUrl, JsonConvert.SerializeObject(input.param), new Dictionary() { { "token", input.token } }); var result = JsonConvert.DeserializeObject(response.Message); if (result != null) { if (result.Success && result.Data[0].IsSucess) { Logger.Interface.Info($"收货单-行审核接口提交Json: {JsonConvert.SerializeObject(input.param)},返回Json: {response.Message}"); } else { action.IsSuccessed = false; action.LocaleMsg = new($"{action.Message}; {result.Data[0].ErrorMsg}"); Logger.Interface.Info($"收货单-行审核接口失败:{result.Data[0].ErrorMsg}"); } } } catch (System.Exception ex) { action.CatchExceptionWithLog(ex, "收货单-行审核异常"); } Logger.Interface.Info($"/* 收货单-行审核接口结束 */\r\n"); //固定写法 return action; } } }