From 5543c73e991dd0fb37c25365f688dc821394e09c Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期三, 27 十一月 2024 00:50:35 +0800
Subject: [PATCH] 一些优化

---
 Tiger.Business.MES/Transaction/YadaPacking.cs |   12 +++++++++---
 Tiger.Business.MES/Transaction/Position.cs    |    4 ++--
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/Tiger.Business.MES/Transaction/Position.cs b/Tiger.Business.MES/Transaction/Position.cs
index 6bc6cc8..d279ca6 100644
--- a/Tiger.Business.MES/Transaction/Position.cs
+++ b/Tiger.Business.MES/Transaction/Position.cs
@@ -675,12 +675,12 @@
                                 case "GetXH":
                                     return "";
                                 case "GetCardNo":
-                                    return $"{Context["CurWaitShipmentCarton"].ToInt32() + 1}";
+                                    return $"{Context.GetOrDefault("CurWaitShipmentCarton").ToInt32() + 1}";
                                 case "GetCardTotal":
                                     var total = "";
                                     var _curaction = curAction is PackingAction ? curAction as PackingAction : null;
                                     if (!_curaction.IsNullOrEmpty()) {
-                                        total = $"{Math.Ceiling(Context["CurShipQty"].ToDecimal()/_curaction.PkgRule.GetTotalQty().ToDecimal())}";
+                                        total = $"{Math.Ceiling(Context.GetOrDefault("CurShipQty").ToDecimal()/_curaction.PkgRule.GetTotalQty().ToDecimal())}";
                                     }
                                     return total;
                                 case "GetModelSpec": //Model+绌烘牸+SPEC,
diff --git a/Tiger.Business.MES/Transaction/YadaPacking.cs b/Tiger.Business.MES/Transaction/YadaPacking.cs
index 2efbd3f..7ea9974 100644
--- a/Tiger.Business.MES/Transaction/YadaPacking.cs
+++ b/Tiger.Business.MES/Transaction/YadaPacking.cs
@@ -399,16 +399,19 @@
                     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 ?? "" : "";
@@ -424,6 +427,7 @@
                     //}
                     //缂撳瓨鍑鸿揣绠辨暟
                     Context.SetOrAdd("CurWaitShipmentCarton", WaitShipmentCarton);
+                    Context.SetOrAdd("CurWaitShipment", WaitShipment);
                     //if (Context.ContainsKey("CurWaitShipmentCarton"))
                     //{
                     //    Context["CurWaitShipmentCarton"] = WaitShipmentCarton;
@@ -973,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