From c6342a8eb6d2c40e9a21deab63b5babb3def3025 Mon Sep 17 00:00:00 2001 From: Rodney Chen <rodney.chen@hotmail.com> Date: 星期日, 13 四月 2025 17:14:50 +0800 Subject: [PATCH] 物料扩展表增加字段 上架需要按物料的默认储位进行限制,不允许上架到其他储位 没有默认储位则不限制,需要记录并调用接口反写到U9 --- Tiger.Business.MES/iERP/MES_U9C.cs | 163 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 158 insertions(+), 5 deletions(-) diff --git a/Tiger.Business.MES/iERP/MES_U9C.cs b/Tiger.Business.MES/iERP/MES_U9C.cs index f375315..409c02d 100644 --- a/Tiger.Business.MES/iERP/MES_U9C.cs +++ b/Tiger.Business.MES/iERP/MES_U9C.cs @@ -26,13 +26,19 @@ { public partial class MES_U9C : IMES_U9C { - public static string U9CAuthLoginUrl { get; set; } = Cache.SysParam["U9CAuthLoginUrl_Test", "U9CUrl"].PARAM_VALUE; // "http://172.16.80.20/U9C/webapi/OAuth2/AuthLogin?"; 娴嬭瘯 + 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; //姝e紡 public static string secret = "&entcode=02&orgcode=101&clientid=mes&clientsecret=12c8ee7e9bb74ad2a6a0fb3315c8af20"; public static string RcvRptDocCreateUrl - { get; set; } = Cache.SysParam["RcvRptDocCreateUrl_Test", "U9CUrl"].PARAM_VALUE; //"http://172.16.80.20/u9C/webapi/RcvRptDoc/Create"; 娴嬭瘯 + { 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> /// 鍏ュ簱鍗曟帴鍙� @@ -53,10 +59,29 @@ // item.Status = "Y"; // if (!ErpProdInBth.IsNullOrEmpty()) // { - // ErpProdInBth.ORDER_NO = $"YDRKD24120000{5+i}"; + // ErpProdInBth.ORDER_NO = $"YDRKD24120000{5 + i}"; // ErpProdInBth.IS_HANDLED = "Y"; // ErpProdInBth.HANDLED_DATE = DateTime.Now; // } + // List<RcvRptDocCreateParam> param = new() { + // new() { + // CompleteList = new(){ + // new CompleteList + // { + // MOKey = new MOKey { DocNo = item.WorkOrder }, + // Wh = new Wh { Code = item.WhCode }, + // DescFlexField = new DescFlexField { PrivateDescSeg1 = item.PkgQty.ToString() }, + // Item = new Item { Code = item.ItemCode }, + // CompleteQty = item.CompleteQty, + // OutputType = item.OutputType, + // StorageType = item.StorageType, + // DocState = item.DocState, + // } + // }, + // Remark = "鎺ュ彛鐢熸垚", + // BusinessDate = DateTime.Now, + // } + // }; // foreach (var p in input.PrintJsons) // { // var d = p.Items.Where(q => q.WORK_ORDER == item.WorkOrder).FirstOrDefault(); @@ -77,7 +102,7 @@ //{ // action.CatchExceptionWithLog(_dbTran.ErrorException, $"鏁版嵁澶勭悊澶辫触"); // Logger.Interface.Error(action.Message); - // IsSuccessed = false; + // //IsSuccessed = false; //} //淇濆瓨鎴愬姛锛岃皟鐢║9C鎺ュ彛 @@ -132,6 +157,16 @@ } } Logger.Interface.Info($"鐢熸垚鍏ュ簱鍗曟垚鍔�"); + + //鏉$爜涓绘。 + BarcodeCreateInput barcodeCreateInput = new() + { + RevDocId = result.Data[0].m_iD, + userId = input.userId, + token = token, + IsLogin = false, + }; + await U9CBarcodeCreate(barcodeCreateInput); } else { @@ -179,6 +214,124 @@ return action; } + /// <summary> + /// 鍏ュ簱鍗曟潯鐮佷富妗f帴鍙� + /// </summary> + /// <param name="input"></param> + /// <returns></returns> + public async Task<ApiAction<BarcodeCreateInput>> U9CBarcodeCreate(BarcodeCreateInput input) + { + Logger.Interface.Info($"/**\r\n *杩涘叆鍏ュ簱鍗曟潯鐮佷富妗f帴鍙�....\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<BarcodeCreateParam> param = new() { + new() { + CreateEntityKeys = new(){ + new CreateEntityKeys + { + ID = input.RevDocId, //鍏ュ簱鍗旾D + EntityType="UFIDA.U9.Complete.RCVRpt.RcvRptDoc" + } + }, + IsCreateHeadBarCode = true, + BarCodeRuleCode = "DJCPRK01", + GenerateCount = 1, + BCQty = 1, + } + }; + var response = await HttpHelper.PostAsync(U9CBarcodeCreateUrl, JsonConvert.SerializeObject(param), new Dictionary<string, string>() { { "token", input.token } }); + var result = JsonConvert.DeserializeObject<U9CResult>(response.Message); + if (result != null) + { + if (result.Success && result.Data[0].m_isSucess) + { + Logger.Interface.Info($"鐢熸垚鍏ュ簱鍗曟潯鐮佷富妗f帴鍙f彁浜son: {JsonConvert.SerializeObject(param)}锛岃繑鍥濲son: {response.Message}"); + } + else + { + action.IsSuccessed = false; + action.LocaleMsg = new($"{action.Message}; {result.Data[0].m_errorMsg}"); + Logger.Interface.Info($"鐢熸垚鍏ュ簱鍗曟潯鐮佷富妗eけ璐�:{result.Data[0].m_errorMsg}"); + } + } + } + catch (System.Exception ex) + { + action.CatchExceptionWithLog(ex, "鐢熸垚鍏ュ簱鍗曟潯鐮佷富妗e紓甯�"); + } + Logger.Interface.Info($"/* 鍏ュ簱鍗曟潯鐮佷富妗f帴鍙g粨鏉� */\r\n"); //鍥哄畾鍐欐硶 + return action; + } + + /// <summary> + /// 鍗婃垚鍝佺敓鎴愭潯鐮佹帴鍙� + /// </summary> + /// <param name="input"></param> + /// <returns></returns> + public async Task<ApiAction<List<string>>> U9CCreateBarCodeByAssignQty(BarcodeCreateByAssignQtyInput input) + { + Logger.Interface.Info($"/**\r\n *杩涘叆鍗婃垚鍝佺敓鎴愭潯鐮佹帴鍙�....\r\n */\r\n"); //鍥哄畾鍐欐硶 + var action = new ApiAction<List<string>>(new List<string>()); + 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.RevDocLineId, //鍏ュ簱鍗旾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 && result.Data.IsSuccess) + { + Logger.Interface.Info($"鍗婃垚鍝佺敓鎴愭潯鐮佹帴鍙f彁浜son: {JsonConvert.SerializeObject(param)}锛岃繑鍥濲son: {response.Message}"); + action.Data = result.Data.Data; + } + 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>(); -- Gitblit v1.9.3