From aa7d6bef3b1f3437b69ef21f8af4ace39939d2b9 Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期五, 17 一月 2025 01:57:45 +0800
Subject: [PATCH] 优化库存管理和标签重打印逻辑

---
 Tiger.Business.WMS/Transaction/ReprintLabel.cs |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/Tiger.Business.WMS/Transaction/ReprintLabel.cs b/Tiger.Business.WMS/Transaction/ReprintLabel.cs
index 8ec081f..d87b28a 100644
--- a/Tiger.Business.WMS/Transaction/ReprintLabel.cs
+++ b/Tiger.Business.WMS/Transaction/ReprintLabel.cs
@@ -15,6 +15,7 @@
 using Tiger.IBusiness;
 using Tiger.Model.MES.Yada;
 using Apache.NMS.ActiveMQ.Commands;
+using System.Diagnostics;
 
 namespace Tiger.Business.WMS.Transaction
 {
@@ -58,7 +59,8 @@
                     action.LocaleMsg = Biz.L("WMS.RePrint.ScanItem.SnEmptyFailure");
                     return SetOutPutMqttMsg(action, input.Locale);
                 }
-                var LotNos = Biz.DataSource["YadaU9C"].Client.Queryable<mes_WhLotCodeQtyInfo>().Where(t => t.Bin == input.SN).ToList();
+                var LotNos = Biz.DataSource["YadaU9C"].Client.Ado.SqlQuery<mes_WhLotCodeQtyInfo>($"select *,'' as ID from mes_WhLotCodeQtyInfo where Bin = '{input.SN}'"); 
+                //Biz.DataSource["YadaU9C"].Client.Queryable<mes_WhLotCodeQtyInfo>().Where(t => t.Bin == input.SN).ToList();
                 CurScanShelf = new ScanShelfInfo();
                 // 鏌ヨ璐ф灦淇℃伅
                 var whUnit = await Biz.Db.Queryable<V_WH_UNIT>().Where(t => (t.SHELF_CODE.ToUpper() == input.SN || t.LOCATION_CODE.ToUpper() == input.SN) && t.AUTH_ORG == OrgCode).IncludesAllFirstLayer().FirstAsync();
@@ -91,6 +93,12 @@
                     CurScanShelf.IsSmartRack = false;
                     LocationCode = whUnit.LOCATION_CODE;
                 }
+                else {
+                    action.IsSuccessed = false;
+                    //action.LocaleMsg = Biz.L("璇疯緭鍏ユ垨鎵弿鏈夋晥鐨勮揣鏋�/鍌ㄤ綅鐮�");
+                    action.LocaleMsg = Biz.L("WMS.Default.ScanShelf.ShelfCanNotEmpty");
+                    return action;
+                }
                 var temps = new List<TemplateInput>();
                 foreach (var item in LotNos)
                 {
@@ -106,7 +114,12 @@
                     };
                     temps.Add(temp);
                 }
-                Biz.Db.Storageable(LotNos, UserCode).ExecuteCommand();
+
+                var y = Biz.Db.Storageable(LotNos, UserCode)
+                               .WhereColumns(t => new { t.ItemCode, t.LotCode })
+                               .ToStorage();
+                y.AsInsertable.ExecuteCommand();
+                y.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand();
                 action.Data.Data = temps;
                 action.LocaleMsg = Biz.L("WMS.RePrint.ScanItem.ScanSuccessed");
             }
@@ -314,7 +327,6 @@
                         throw dbTran.ErrorException;
                     }
 
-                    LocationCode = "";
                     action.Data.Data = rePrints;
                     action.LocaleMsg = Biz.L("搴撲綅鎵规鏉$爜涓婃灦鎴愬姛");
                 }

--
Gitblit v1.9.3