From 706b85f10a01393f66cbb9412de271af36156698 Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期三, 27 十一月 2024 19:05:45 +0800 Subject: [PATCH] 一些更改 --- Tiger.Business.MES/iERP/MES_U9C.cs | 238 +++++++++++++++++++++++++++++----------------------------- 1 files changed, 119 insertions(+), 119 deletions(-) diff --git a/Tiger.Business.MES/iERP/MES_U9C.cs b/Tiger.Business.MES/iERP/MES_U9C.cs index 6c3009e..c83fce5 100644 --- a/Tiger.Business.MES/iERP/MES_U9C.cs +++ b/Tiger.Business.MES/iERP/MES_U9C.cs @@ -64,127 +64,127 @@ } //淇濆瓨鎴愬姛锛岃皟鐢║9C鎺ュ彛-娴嬭瘯鐢� - int i = 1; - List<BIZ_ERP_PROD_IN_BTH> ErpProdInBths = new List<BIZ_ERP_PROD_IN_BTH>(); - foreach (var item in input.RcvRptDocBases.Where(q => q.Status != "Y")) - { - var ErpProdInBth = Biz.Db.Queryable<BIZ_ERP_PROD_IN_BTH>().Where(q => q.WORK_ORDER == item.WorkOrder).First(); - item.Status = "Y"; - if (!ErpProdInBth.IsNullOrEmpty()) - { - ErpProdInBth.ORDER_NO = $"XX001-{i}"; - ErpProdInBth.IS_HANDLED = "Y"; - ErpProdInBth.HANDLED_DATE = DateTime.Now; - ErpProdInBths.Add(ErpProdInBth); - } - foreach (var p in input.PrintJsons) - { - var d = p.Items.Where(q => q.WORK_ORDER == item.WorkOrder).FirstOrDefault(); - if (!d.IsNullOrEmpty()) - { - d.ORDER_NO = $"XX001-{i}"; - d.STATUS = "Y"; - } - } - i++; - } - var _db = Biz.Db; - var _dbTran = _db.UseTran(() => - { - _db.Updateable(ErpProdInBths, "U9C_RcvRptDocCreate").UpdateColumns(x => new { x.ORDER_NO, x.REMARK, x.IS_HANDLED, x.HANDLED_DATE }).ExecuteCommand(); - }); - if (!dbTran.IsSuccess) - { - action.CatchExceptionWithLog(dbTran.ErrorException, $"鏁版嵁澶勭悊澶辫触"); - Logger.Interface.Error(action.Message); - IsSuccessed = false; - } - input.ErpProdInBths = ErpProdInBths; + //int i = 1; + //List<BIZ_ERP_PROD_IN_BTH> ErpProdInBths = new List<BIZ_ERP_PROD_IN_BTH>(); + //foreach (var item in input.RcvRptDocBases.Where(q => q.Status != "Y")) + //{ + // var ErpProdInBth = Biz.Db.Queryable<BIZ_ERP_PROD_IN_BTH>().Where(q => q.WORK_ORDER == item.WorkOrder).First(); + // item.Status = "Y"; + // if (!ErpProdInBth.IsNullOrEmpty()) + // { + // ErpProdInBth.ORDER_NO = $"XX001-{i}"; + // ErpProdInBth.IS_HANDLED = "Y"; + // ErpProdInBth.HANDLED_DATE = DateTime.Now; + // ErpProdInBths.Add(ErpProdInBth); + // } + // foreach (var p in input.PrintJsons) + // { + // var d = p.Items.Where(q => q.WORK_ORDER == item.WorkOrder).FirstOrDefault(); + // if (!d.IsNullOrEmpty()) + // { + // d.ORDER_NO = $"XX001-{i}"; + // d.STATUS = "Y"; + // } + // } + // i++; + //} + //var _db = Biz.Db; + //var _dbTran = _db.UseTran(() => + //{ + // _db.Updateable(ErpProdInBths, "U9C_RcvRptDocCreate").UpdateColumns(x => new { x.ORDER_NO, x.REMARK, x.IS_HANDLED, x.HANDLED_DATE }).ExecuteCommand(); + //}); + //if (!dbTran.IsSuccess) + //{ + // action.CatchExceptionWithLog(dbTran.ErrorException, $"鏁版嵁澶勭悊澶辫触"); + // Logger.Interface.Error(action.Message); + // IsSuccessed = false; + //} + //input.ErpProdInBths = ErpProdInBths; //淇濆瓨鎴愬姛锛岃皟鐢║9C鎺ュ彛 - //if (IsSuccessed) - //{ - // var u9CLoginResult = await HttpHelper.GetAsync<U9CLoginResult>($"{U9CAuthLoginUrl}userCode=admin{secret}"); - // if (u9CLoginResult.Success) - // { - // var token = u9CLoginResult.Data; - // Logger.Interface.Info($"U9C鐧诲綍token: {token}"); - // List<BIZ_ERP_PROD_IN_BTH> ErpProdInBths = new List<BIZ_ERP_PROD_IN_BTH>(); - // foreach (var item in input.RcvRptDocBases.Where(q=>q.Status != "Y")) - // { - // 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, - // } - // } - // } - // }; - // var response = await HttpHelper.PostAsync(RcvRptDocCreateUrl, JsonConvert.SerializeObject(param), new Dictionary<string, string>() { { "token", token } }); - // var result = JsonConvert.DeserializeObject<U9CResult>(response.Message); - // var ErpProdInBth = Biz.Db.Queryable<BIZ_ERP_PROD_IN_BTH>().Where(q => q.WORK_ORDER == item.WorkOrder).First(); - // if (result != null) - // { - // if (result.Success && result.Data[0].m_isSucess) - // { - // Logger.Interface.Info($"鐢熸垚鍏ュ簱鍗曟帴鍙f彁浜son: {JsonConvert.SerializeObject(param)}锛岃繑鍥濲son: {response.Message}"); - // item.Status = "Y"; - // if (!ErpProdInBth.IsNullOrEmpty()) - // { - // ErpProdInBth.ORDER_NO = result.Data[0].m_code; - // ErpProdInBth.IS_HANDLED = "Y"; - // ErpProdInBth.HANDLED_DATE = DateTime.Now; - // ErpProdInBths.Add(ErpProdInBth); - // } - // foreach (var p in input.PrintJsons) - // { - // var d = p.Items.Where(q => q.WORK_ORDER == item.WorkOrder).FirstOrDefault(); - // if (!d.IsNullOrEmpty()) - // { - // d.ORDER_NO = result.Data[0].m_code; - // } - // } - // Logger.Interface.Info($"鐢熸垚鍏ュ簱鍗曟垚鍔�"); - // } - // else - // { - // action.IsSuccessed = false; - // action.LocaleMsg = new($"{action.Message}; {result.Data[0].m_errorMsg}"); - // item.Status = "F"; - // if (!ErpProdInBth.IsNullOrEmpty()) - // { - // ErpProdInBth.REMARK = result.Data[0].m_errorMsg; - // ErpProdInBth.IS_HANDLED = "F"; - // ErpProdInBth.HANDLED_DATE = DateTime.Now; - // ErpProdInBths.Add(ErpProdInBth); - // } - // Logger.Interface.Info($"鐢熸垚鍏ュ簱鍗曞け璐�:{result.Data[0].m_errorMsg}"); - // } - // } - // } - // var _db = Biz.Db; - // var _dbTran = _db.UseTran(() => - // { - // _db.Updateable(ErpProdInBths, "U9C_RcvRptDocCreate").UpdateColumns(x => new { x.ORDER_NO, x.REMARK, x.IS_HANDLED, x.HANDLED_DATE }).ExecuteCommand(); - // }); - // if (!dbTran.IsSuccess) - // { - // action.CatchExceptionWithLog(dbTran.ErrorException, $"鏁版嵁澶勭悊澶辫触"); - // Logger.Interface.Error(action.Message); - // IsSuccessed = false; - // } - // input.ErpProdInBths = ErpProdInBths; - // } - //} + if (IsSuccessed) + { + var u9CLoginResult = await HttpHelper.GetAsync<U9CLoginResult>($"{U9CAuthLoginUrl}userCode=admin{secret}"); + if (u9CLoginResult.Success) + { + var token = u9CLoginResult.Data; + Logger.Interface.Info($"U9C鐧诲綍token: {token}"); + List<BIZ_ERP_PROD_IN_BTH> ErpProdInBths = new List<BIZ_ERP_PROD_IN_BTH>(); + foreach (var item in input.RcvRptDocBases.Where(q => q.Status != "Y")) + { + 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, + } + } + } + }; + var response = await HttpHelper.PostAsync(RcvRptDocCreateUrl, JsonConvert.SerializeObject(param), new Dictionary<string, string>() { { "token", token } }); + var result = JsonConvert.DeserializeObject<U9CResult>(response.Message); + var ErpProdInBth = Biz.Db.Queryable<BIZ_ERP_PROD_IN_BTH>().Where(q => q.WORK_ORDER == item.WorkOrder).First(); + if (result != null) + { + if (result.Success && result.Data[0].m_isSucess) + { + Logger.Interface.Info($"鐢熸垚鍏ュ簱鍗曟帴鍙f彁浜son: {JsonConvert.SerializeObject(param)}锛岃繑鍥濲son: {response.Message}"); + item.Status = "Y"; + if (!ErpProdInBth.IsNullOrEmpty()) + { + ErpProdInBth.ORDER_NO = result.Data[0].m_code; + ErpProdInBth.IS_HANDLED = "Y"; + ErpProdInBth.HANDLED_DATE = DateTime.Now; + ErpProdInBths.Add(ErpProdInBth); + } + foreach (var p in input.PrintJsons) + { + var d = p.Items.Where(q => q.WORK_ORDER == item.WorkOrder).FirstOrDefault(); + if (!d.IsNullOrEmpty()) + { + d.ORDER_NO = result.Data[0].m_code; + } + } + Logger.Interface.Info($"鐢熸垚鍏ュ簱鍗曟垚鍔�"); + } + else + { + action.IsSuccessed = false; + action.LocaleMsg = new($"{action.Message}; {result.Data[0].m_errorMsg}"); + item.Status = "F"; + if (!ErpProdInBth.IsNullOrEmpty()) + { + ErpProdInBth.REMARK = result.Data[0].m_errorMsg; + ErpProdInBth.IS_HANDLED = "F"; + ErpProdInBth.HANDLED_DATE = DateTime.Now; + ErpProdInBths.Add(ErpProdInBth); + } + Logger.Interface.Info($"鐢熸垚鍏ュ簱鍗曞け璐�:{result.Data[0].m_errorMsg}"); + } + } + } + var _db = Biz.Db; + var _dbTran = _db.UseTran(() => + { + _db.Updateable(ErpProdInBths, "U9C_RcvRptDocCreate").UpdateColumns(x => new { x.ORDER_NO, x.REMARK, x.IS_HANDLED, x.HANDLED_DATE }).ExecuteCommand(); + }); + if (!dbTran.IsSuccess) + { + action.CatchExceptionWithLog(dbTran.ErrorException, $"鏁版嵁澶勭悊澶辫触"); + Logger.Interface.Error(action.Message); + IsSuccessed = false; + } + input.ErpProdInBths = ErpProdInBths; + } + } action.Data = input; } catch (System.Exception ex) -- Gitblit v1.9.3