From 531f16f2f15bf792e3e719e00abb57a95356dedd Mon Sep 17 00:00:00 2001 From: Rodney Chen <rodney.chen@hotmail.com> Date: 星期一, 21 四月 2025 12:04:15 +0800 Subject: [PATCH] Merge branch 'master' of http://47.115.28.255:8110/r/TigerClouds-Tech/Server/TigerApi6_2024 --- Tiger.Business.MES/Transaction/YadaPacking.cs | 77 +++++++++++++++++++++++--------------- 1 files changed, 47 insertions(+), 30 deletions(-) diff --git a/Tiger.Business.MES/Transaction/YadaPacking.cs b/Tiger.Business.MES/Transaction/YadaPacking.cs index afed3d3..160715d 100644 --- a/Tiger.Business.MES/Transaction/YadaPacking.cs +++ b/Tiger.Business.MES/Transaction/YadaPacking.cs @@ -70,10 +70,10 @@ // //action.LocaleMsg = new("MES.Transaction.PackingNode.Submit.QtyError", input.Qty); // return SetOutPutMqttMsg(action, input.Locale); //} - if (input.Options.ContainsKey("IsPrintCustomerLabel")) - { - IsPrintCustomerLabel = input.Options["IsPrintCustomerLabel"].ToBoolean(); - } + //if (input.Options.ContainsKey("IsPrintCustomerLabel")) + //{ + // IsPrintCustomerLabel = input.Options["IsPrintCustomerLabel"].ToBoolean(); + //} //if (input.Options.ContainsKey("ShippingOrder")) //{ @@ -298,8 +298,11 @@ { action.Data.ShortMsg = new("宸ュ簭寮傚父", ShortMessage.Types.Error); action.Data.OperInfo = CurOperInfo(input.Locale); + RemoveCurSnFromCurPackage(Context.ContainsKey("CurPackage") ? (Context["CurPackage"] as WipPkg).Item : null); + ResetNode(); //action.CatchExceptionWithLog(ex, $"鍖呰宸ュ簭锛氭彁浜ゆ搷浣滄暟鎹紓甯�"); action.CatchExceptionWithLog(ex, Biz.L("MES.Transaction.PackingNode.SubmitException")); + } debug.Log(new StackFrame(true), "***** 9", info => { ConsoleExt.WriteLine(info.ToString()); }); return SetOutPutMqttMsg(action, input.Locale); @@ -349,7 +352,6 @@ FLOW_SN = input.SN, STATUS = MES_WIP_DATA.STATUSs.Init.GetValue(), ITEM_CODE = CurBatch.WO.ITEM_CODE, - QTY = 1, WORK_ORDER = CurBatch.Batch.ORDER_NO, BATCH_NO = CurBatch.Batch.BATCH_NO, FTY_CODE = CurFactory.FTY_CODE, @@ -401,10 +403,15 @@ debug.Log(new StackFrame(true), "***** 11", info => { ConsoleExt.WriteLine(info.ToString()); }); //鑾峰彇鍑鸿揣鐘舵�� - var ship = U9CDB.Queryable<mes_ShipList>().Where(q => q.MoDoc == CurBatch.WO.ORDER_NO && q.Status == 2 && SqlFunc.DateIsSame(q.BusinessDate, DateTime.Now)).First(); - int CurShipQty = 0; + //var ship = U9CDB.Queryable<mes_ShipList>().Where(q => q.MoDoc == CurBatch.WO.ORDER_NO && q.Status == 2 && SqlFunc.DateIsSame(q.BusinessDate, DateTime.Now)).First(); + var ships = U9CDB.Queryable<mes_ShipList>().Where(q => q.MoDoc == CurBatch.WO.ORDER_NO).ToList(); + var shippingOrders = ships.Where(q=> q.Status != 2).Select(x=>x.ShipDoc).ToList(); + var oldShipment = ships.Any(q => q.Status != 2) ? ships.Where(x => x.Status != 2).Sum(t => t.ShipQty) : 0; + var ship = ships.Where(q => q.Status == 2 && q.BusinessDate.Date == DateTime.Now.Date).FirstOrDefault(); + double CurShipQty = 0; int WaitShipmentCarton = 0; int WaitShipment = 0; + int oWaitShipmentCarton = 0; if (ship.IsNullOrEmpty()) { IsPrintCustomerLabel = false; } else { @@ -414,34 +421,21 @@ var list = MainDB.Ado.UseStoredProcedure().GetDataTable("SP_MES_GET_NODE_BATCH_COUNT", pars).AsEnumerable().ToList(); if (!list.IsNullOrEmpty()) { + var sublist = list.Where(q=> shippingOrders.Contains(q["SHIPPING_ORDER"]) && q["ProdDate"].ToString() != "Whole").ToList(); + oWaitShipmentCarton = sublist.IsNullOrEmpty() ? 0 : sublist.Sum(q => q["WaitShipmentCarton"].ToInt32()); var batchCount = list.Where(q => q["ProdDate"].ToString() == "Whole").FirstOrDefault(); - WaitShipmentCarton = batchCount["WaitShipmentCarton"].ToInt32(); + WaitShipmentCarton = batchCount["WaitShipmentCarton"].ToInt32()- oWaitShipmentCarton; WaitShipment = batchCount["WaitShipment"].ToInt32(); - IsPrintCustomerLabel = batchCount.IsNullOrEmpty() ? IsPrintCustomerLabel : batchCount["WaitShipment"].ToInt32() >= ship.ShipQty ? false : true; + IsPrintCustomerLabel = batchCount.IsNullOrEmpty() ? IsPrintCustomerLabel : batchCount["WaitShipment"].ToInt32() - oldShipment >= ship.ShipQty ? false : true; } } ShippingOrder = IsPrintCustomerLabel ? ship?.ShipDoc ?? "" : ""; //缂撳瓨鍑鸿揣鏁伴噺 + Context.SetOrAdd("CuroldShipment", oldShipment); Context.SetOrAdd("CurShipQty", CurShipQty); - //if (Context.ContainsKey("CurShipQty")) - //{ - // Context["CurShipQty"] = CurShipQty; - //} - //else - //{ - // Context.Add("CurShipQty", CurShipQty); - //} //缂撳瓨鍑鸿揣绠辨暟 Context.SetOrAdd("CurWaitShipmentCarton", WaitShipmentCarton); Context.SetOrAdd("CurWaitShipment", WaitShipment); - //if (Context.ContainsKey("CurWaitShipmentCarton")) - //{ - // Context["CurWaitShipmentCarton"] = WaitShipmentCarton; - //} - //else - //{ - // Context.Add("CurWaitShipmentCarton", WaitShipmentCarton); - //} debug.Log(new StackFrame(true), "***** 12", info => { ConsoleExt.WriteLine(info.ToString()); }); //缁戝畾鏉$爜鍒板伐鍗� @@ -457,7 +451,6 @@ FLOW_SN = wipSN.SN, TRAY_SN = wipSN.TRAY_SN, STATUS = BIZ_MES_WO_SN.STATUSs.NotInput.GetValue(), - QTY = 1, }); } } @@ -487,6 +480,7 @@ wipSN.OPER_CODE = curNode.OPER_CODE; wipSN.SEGMENT = curNode.SEGMENT; wipSN.OPERATION_TIME = DateTime.Now; + wipSN.OPERATION_END = DateTime.Now; wipSN.SHIPPING_ORDER = ShippingOrder; wipSN.UNBIND_FLAG = "N"; var curShiftPeriod = GetShiftPeriodForNow(); @@ -708,6 +702,7 @@ catch (Exception ex) { action.Data.ShortMsg = new("宸ユ寮傚父", ShortMessage.Types.Error); + RemoveCurSnFromCurPackage(Context.ContainsKey("CurPackage") ? (Context["CurPackage"] as WipPkg).Item : null); ResetNode(); //action.CatchExceptionWithLog(ex, $"{curNode.NODE_NAME}锛氬伐搴忚妭鐐瑰伐姝ユ彁浜ゆ暟鎹紓甯革紝璇锋鏌ュ伐搴忚妭鐐硅缃�"); action.CatchExceptionWithLog(ex, Biz.L("MES.Transaction.PackingNode.NodeSubmitException", curNode.NODE_NAME)); @@ -752,6 +747,7 @@ wipSN.OPER_CODE = curNode.OPER_CODE; wipSN.SEGMENT = curNode.SEGMENT; wipSN.OPERATION_TIME = DateTime.Now; + wipSN.OPERATION_END = DateTime.Now; } var wipHiss = new List<MES_WIP_HIS>(); @@ -775,7 +771,7 @@ var db = GetCommitDB(); //鏁版嵁淇濆瓨閫昏緫 db.Updateable(_woSns, UserCode).UpdateColumns(q => new { q.UPDATE_TIME, q.UPDATE_USER, q.STATUS }).ExecuteCommand(); - db.Updateable(_wipSns, UserCode).UpdateColumns(q => new { q.UPDATE_TIME, q.UPDATE_USER, q.STATUS, q.NODE_ID, q.NODE_NAME, q.OPER_CODE, q.SEGMENT, q.OPERATION_TIME }).ExecuteCommand(); + db.Updateable(_wipSns, UserCode).UpdateColumns(q => new { q.UPDATE_TIME, q.UPDATE_USER, q.STATUS, q.NODE_ID, q.NODE_NAME, q.OPER_CODE, q.SEGMENT, q.OPERATION_TIME, q.OPERATION_END }).ExecuteCommand(); db.Storageable(_wipHiss, UserCode).ExecuteCommand(); if (_pkgList.Any()) { @@ -791,7 +787,7 @@ } }; } - + //throw new Exception("鍝�"); //淇濆瓨鏁版嵁搴� SaveStepsCommitActionToDB(endAction); @@ -958,7 +954,7 @@ try { var CurPkg = Context.ContainsKey("CurPackage") ? Context["CurPackage"] as WipPkg : null; - var LabelPV = MainDB.Queryable<BAS_LABEL_PV>().ToList(); + var LabelPV = MainDB.Queryable<BAS_PROCESS_VAR>().ToList(); var label = CurPkg.Item.LABEL_CODE.IsNullOrEmpty() ? null : MainDB.Queryable<BAS_LABEL_TEMP>().Where(q => q.LABEL_CODE == CurPkg.Item.LABEL_CODE).IncludesAllFirstLayer().First(); var printLb = SetLabelVariables(LabelPV, label, new PackingAction(), CurPkg); action.Data = new PackingActionOutput() @@ -987,7 +983,8 @@ action.Data = new ShipingInfo() { IsPrintCustomerLabel = IsPrintCustomerLabel, - ShipQty = Context.GetOrDefault("CurWaitShipment").ToInt32() >= Context.GetOrDefault("CurShipQty").ToInt32() ? CurBatch.Batch.PLAN_QTY - Context.GetOrDefault("CurShipQty").ToInt32() : Context.GetOrDefault("CurShipQty").ToInt32() + OldShipQty = Context.GetOrDefault("CuroldShipment").ToInt32(), + ShipQty = Context.GetOrDefault("CurWaitShipment").ToInt32() - Context.GetOrDefault("CuroldShipment").ToInt32() >= Context.GetOrDefault("CurShipQty").ToInt32() ? CurBatch.Batch.PLAN_QTY - Context.GetOrDefault("CuroldShipment").ToInt32() - Context.GetOrDefault("CurShipQty").ToInt32() : Context.GetOrDefault("CurShipQty").ToInt32() }; } catch (Exception ex) @@ -1008,6 +1005,26 @@ NodeCmd = null; } + public void RemoveCurSnFromCurPackage(WipPkgItem pkgItem) + { + if (!pkgItem.IsNullOrEmpty()) + { + var delItem = pkgItem.Items.Where(q => CurWipSNs.Any(sn => q.WipSNs.ContainsKey(sn.ID))).ToList(); + if (delItem.Any()) + { + pkgItem.Items.RemoveAll(q => CurWipSNs.Any(sn => q.WipSNs.ContainsKey(sn.ID))); + pkgItem.IsFinished = false; + } + else + { + foreach (var item in pkgItem.Items) + { + RemoveCurSnFromCurPackage(item); + } + } + } + } + public override bool Close(bool needSaveHistoryLog = false) { //needSaveHistoryLog = true; -- Gitblit v1.9.3