From e8aef02a3b8a6b6c5f0b13798f318aa7dc56e13f Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期三, 19 二月 2025 14:37:22 +0800 Subject: [PATCH] 雅达-添加生成条码的异步方法及相关参数类 --- Tiger.Business.MES/iERP/MES_U9C.cs | 68 ++++++++++++++++++++++++++++++++- Tiger.Model.Net/Entitys/MES/ParameterEntity/U9CParameter.cs | 33 ++++++++++++++++ 2 files changed, 98 insertions(+), 3 deletions(-) diff --git a/Tiger.Business.MES/iERP/MES_U9C.cs b/Tiger.Business.MES/iERP/MES_U9C.cs index 8b8a297..608f3cc 100644 --- a/Tiger.Business.MES/iERP/MES_U9C.cs +++ b/Tiger.Business.MES/iERP/MES_U9C.cs @@ -32,10 +32,13 @@ public static string RcvRptDocCreateUrl { get; set; } = ApiConfig.IsTestServer ? Cache.SysParam["RcvRptDocCreateUrl_Test", "U9CUrl"].PARAM_VALUE : Cache.SysParam["RcvRptDocCreateUrl", "U9CUrl"].PARAM_VALUE; //"http://172.16.80.20/u9C/webapi/RcvRptDoc/Create"; 娴嬭瘯 //public static string RcvRptDocCreateUrl - //{ get; set; } = Cache.SysParam["RcvRptDocCreateUrl", "U9CUrl"].PARAM_VALUE; //姝e紡 + //{ get; set; } = Cache.SysParam["RcvRptDocCreateUrl", "U9CUrl"].PARAM_VALUE; //姝e紡 public static string U9CBarcodeCreateUrl { get; set; } = ApiConfig.IsTestServer ? Cache.SysParam["U9CBarcodeCreateUrl_Test", "U9CUrl"].PARAM_VALUE : Cache.SysParam["U9CBarcodeCreateUrl", "U9CUrl"].PARAM_VALUE; + + public static string CreateBarCodeByAssignQtyUrl + { get; set; } = ApiConfig.IsTestServer ? Cache.SysParam["CreateBarCodeByAssignQty_Test", "U9CUrl"].PARAM_VALUE : Cache.SysParam["CreateBarCodeByAssignQty", "U9CUrl"].PARAM_VALUE; /// <summary> /// 鍏ュ簱鍗曟帴鍙� @@ -137,13 +140,14 @@ Logger.Interface.Info($"鐢熸垚鍏ュ簱鍗曟垚鍔�"); //鏉$爜涓绘。 - BarcodeCreateInput barcodeCreateInput = new() { + BarcodeCreateInput barcodeCreateInput = new() + { RevDocId = result.Data[0].m_iD, userId = input.userId, token = token, IsLogin = false, }; - U9CBarcodeCreate(barcodeCreateInput); + await U9CBarcodeCreate(barcodeCreateInput); } else { @@ -250,6 +254,64 @@ return action; } + /// <summary> + /// 鍗婃垚鍝佺敓鎴愭潯鐮佹帴鍙� + /// </summary> + /// <param name="input"></param> + /// <returns></returns> + public async Task<ApiAction<BarcodeCreateInput>> U9CCreateBarCodeByAssignQty(BarcodeCreateByAssignQtyInput input) + { + Logger.Interface.Info($"/**\r\n *杩涘叆鍗婃垚鍝佺敓鎴愭潯鐮佹帴鍙�....\r\n */\r\n"); //鍥哄畾鍐欐硶 + var action = new ApiAction<BarcodeCreateInput>(); + try + { + if (input.IsLogin) + { + var u9CLoginResult = await HttpHelper.GetAsync<U9CLoginResult>($"{U9CAuthLoginUrl}userCode={input.userId}{secret}"); + if (u9CLoginResult.Success) + { + input.token = u9CLoginResult.Data; + Logger.Interface.Info($"U9C鐧诲綍token: {input.token}"); + } + } + List<BarcodeCreateByAssignQtyParam> param = new() { + new() { + CreateBarCodeEntitys = new(){ + new CreateBarCodeEntitys + { + EntityID = input.RevDocId, //鍏ュ簱鍗旾D + EntityType="UFIDA.U9.Complete.RCVRpt.RcvRptDocLine" + } + }, + BarCodeRuleID = "1002308220305008", + CreateBarCodeItemQty = input.CreateBarCodeItemQty, + LabelQty = input.LabelQty, + } + }; + var response = await HttpHelper.PostAsync(CreateBarCodeByAssignQtyUrl, JsonConvert.SerializeObject(param), new Dictionary<string, string>() { { "token", input.token } }); + var result = JsonConvert.DeserializeObject<BarcodeCreateByAssignQtyResult>(response.Message); + if (result != null) + { + if (result.Success) + { + Logger.Interface.Info($"鍗婃垚鍝佺敓鎴愭潯鐮佹帴鍙f彁浜son: {JsonConvert.SerializeObject(param)}锛岃繑鍥濲son: {response.Message}"); + } + else + { + action.IsSuccessed = false; + action.LocaleMsg = new($"{action.Message}; {result.Data.ErrorMessage}"); + Logger.Interface.Info($"鍗婃垚鍝佺敓鎴愭潯鐮佸け璐�:{result.Data.ErrorMessage}"); + } + } + } + catch (System.Exception ex) + { + action.CatchExceptionWithLog(ex, "鍗婃垚鍝佺敓鎴愭潯鐮佸紓甯�"); + } + Logger.Interface.Info($"/* 鍗婃垚鍝佺敓鎴愭潯鐮佹帴鍙g粨鏉� */\r\n"); //鍥哄畾鍐欐硶 + return action; + } + private List<BAS_LABEL_TEMP> GetLabels(List<InStorePrintJson> printJsons) { List<BAS_LABEL_TEMP> labels = new List<BAS_LABEL_TEMP>(); diff --git a/Tiger.Model.Net/Entitys/MES/ParameterEntity/U9CParameter.cs b/Tiger.Model.Net/Entitys/MES/ParameterEntity/U9CParameter.cs index 4aa8a11..9525622 100644 --- a/Tiger.Model.Net/Entitys/MES/ParameterEntity/U9CParameter.cs +++ b/Tiger.Model.Net/Entitys/MES/ParameterEntity/U9CParameter.cs @@ -120,6 +120,39 @@ public string EntityType { get; set; } } + public class BarcodeCreateByAssignQtyInput: BarcodeCreateInput + { + public int CreateBarCodeItemQty { get; set; } + public int LabelQty { get; set; } + } + + public class BarcodeCreateByAssignQtyParam + { + public string BarCodeRuleID { get; set; } + public List<CreateBarCodeEntitys> CreateBarCodeEntitys { get; set; } + public int CreateBarCodeItemQty { get; set; } + public int LabelQty { get; set; } + } + + public class CreateBarCodeEntitys + { + public string EntityID { get; set; } + public string EntityType { get; set; } = "UFIDA.U9.Complete.RCVRpt.RcvRptDocLine"; + } + + public class BarcodeCreateByAssignQtyResult : U9CBaseResult + { + public BarcodeCreateByAssignQtyData Data { get; set; } + } + + public class BarcodeCreateByAssignQtyData { + public string ErrorMessage { get; set; } + public string OtherID { get; set; } + public string CreatedBarCodes { get; set; } + public bool IsSuccess { get; set; } + public List<string> Data { get; set; } + } + public class MOKey { public string DocNo { get; set; } -- Gitblit v1.9.3