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/Transaction/YadaPacking.cs |   46 +++++++++++++++++++++++++++-------------------
 1 files changed, 27 insertions(+), 19 deletions(-)

diff --git a/Tiger.Business.MES/Transaction/YadaPacking.cs b/Tiger.Business.MES/Transaction/YadaPacking.cs
index 5f40414..7ea9974 100644
--- a/Tiger.Business.MES/Transaction/YadaPacking.cs
+++ b/Tiger.Business.MES/Transaction/YadaPacking.cs
@@ -399,37 +399,43 @@
                     var ship = db.Queryable<mes_ShipList>().Where(q => q.MoDoc == CurBatch.WO.ORDER_NO && q.Status == 2 && SqlFunc.DateIsSame(q.BusinessDate, DateTime.Now)).First();
                     int CurShipQty = 0;
                     int WaitShipmentCarton = 0;
+                    int WaitShipment = 0;
                     if (ship.IsNullOrEmpty()) { IsPrintCustomerLabel = false; } else
                     {
                         CurShipQty = ship.ShipQty;
+                        IsPrintCustomerLabel = true;
                         SugarParameter[] pars = Biz.Db.Ado.GetParameters(new { BATCH = CurBatch.Batch.BATCH_NO, NodeIdOrName = curNode.NODE_NAME });
                         var list = Biz.Db.Ado.UseStoredProcedure().GetDataTable("SP_MES_GET_NODE_BATCH_COUNT", pars).AsEnumerable().ToList();
                         if (!list.IsNullOrEmpty())
                         {
                             var batchCount = list.Where(q => q["ProdDate"].ToString() == "Whole").FirstOrDefault();
-                            WaitShipmentCarton = batchCount["WaitShipment"].ToInt32();
-                            IsPrintCustomerLabel = batchCount.IsNullOrEmpty() ? false : batchCount["WaitShipment"].ToInt32() >= ship.ShipQty ? false : true;
+                            WaitShipmentCarton = batchCount["WaitShipmentCarton"].ToInt32();
+                            WaitShipment = batchCount["WaitShipment"].ToInt32();
+                            IsPrintCustomerLabel = batchCount.IsNullOrEmpty() ? IsPrintCustomerLabel : batchCount["WaitShipment"].ToInt32() >= ship.ShipQty ? false : true;
                         }
                     }
                     ShippingOrder = IsPrintCustomerLabel ? ship?.ShipDoc ?? "" : "";
                     //缂撳瓨鍑鸿揣鏁伴噺
-                    if (Context.ContainsKey("CurShipQty"))
-                    {
-                        Context["CurShipQty"] = CurShipQty;
-                    }
-                    else
-                    {
-                        Context.Add("CurShipQty", CurShipQty);
-                    }
+                    Context.SetOrAdd("CurShipQty", CurShipQty);
+                    //if (Context.ContainsKey("CurShipQty"))
+                    //{
+                    //    Context["CurShipQty"] = CurShipQty;
+                    //}
+                    //else
+                    //{
+                    //    Context.Add("CurShipQty", CurShipQty);
+                    //}
                     //缂撳瓨鍑鸿揣绠辨暟
-                    if (Context.ContainsKey("CurWaitShipmentCarton"))
-                    {
-                        Context["CurWaitShipmentCarton"] = WaitShipmentCarton;
-                    }
-                    else
-                    {
-                        Context.Add("CurWaitShipmentCarton", WaitShipmentCarton);
-                    }
+                    Context.SetOrAdd("CurWaitShipmentCarton", WaitShipmentCarton);
+                    Context.SetOrAdd("CurWaitShipment", WaitShipment);
+                    //if (Context.ContainsKey("CurWaitShipmentCarton"))
+                    //{
+                    //    Context["CurWaitShipmentCarton"] = WaitShipmentCarton;
+                    //}
+                    //else
+                    //{
+                    //    Context.Add("CurWaitShipmentCarton", WaitShipmentCarton);
+                    //}
 
                     curtime = DateTime.Now;  Logger.Console.Info($"{CurSN} : ***** 12 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime;
                     //缁戝畾鏉$爜鍒板伐鍗�
@@ -971,7 +977,9 @@
             var action = new ApiAction<ShipingInfo>();
             try
             {
-                action.Data = new ShipingInfo() { IsPrintCustomerLabel= IsPrintCustomerLabel,ShipQty = Context["CurShipQty"].ToInt32() };
+                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() };
             }
             catch (Exception ex)
             {

--
Gitblit v1.9.3