From c6494a547258df9180f181dc00d6e4dd1633ec36 Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期四, 13 二月 2025 19:03:15 +0800 Subject: [PATCH] 更新数据库配置和出货逻辑 --- Tiger.Business.MES/Transaction/YadaPacking.cs | 19 ++++++++++++++----- Tiger.Model.Net/Entitys/MES/ParameterEntity/PositionParameter.cs | 1 + 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Tiger.Business.MES/Transaction/YadaPacking.cs b/Tiger.Business.MES/Transaction/YadaPacking.cs index eda33f4..ff1d57f 100644 --- a/Tiger.Business.MES/Transaction/YadaPacking.cs +++ b/Tiger.Business.MES/Transaction/YadaPacking.cs @@ -302,7 +302,7 @@ 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); @@ -403,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(); + //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(); decimal CurShipQty = 0; int WaitShipmentCarton = 0; int WaitShipment = 0; + int oWaitShipmentCarton = 0; if (ship.IsNullOrEmpty()) { IsPrintCustomerLabel = false; } else { @@ -416,14 +421,17 @@ 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); //缂撳瓨鍑鸿揣绠辨暟 Context.SetOrAdd("CurWaitShipmentCarton", WaitShipmentCarton); @@ -973,7 +981,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) diff --git a/Tiger.Model.Net/Entitys/MES/ParameterEntity/PositionParameter.cs b/Tiger.Model.Net/Entitys/MES/ParameterEntity/PositionParameter.cs index 0d32bf9..e375aff 100644 --- a/Tiger.Model.Net/Entitys/MES/ParameterEntity/PositionParameter.cs +++ b/Tiger.Model.Net/Entitys/MES/ParameterEntity/PositionParameter.cs @@ -336,6 +336,7 @@ public class ShipingInfo { public bool IsPrintCustomerLabel { get; set; } + public int OldShipQty { get; set; } public int ShipQty { get; set; } } -- Gitblit v1.9.3