From 4db3ba3f84456c27fdd9be76ff76c17101270914 Mon Sep 17 00:00:00 2001 From: 啊鑫 <t2856754968@163.com> Date: 星期三, 24 九月 2025 14:12:48 +0800 Subject: [PATCH] 111 --- service/Warehouse/MesItemQtManager.cs | 34 ++++++++++++++++++++++------------ 1 files changed, 22 insertions(+), 12 deletions(-) diff --git a/service/Warehouse/MesItemQtManager.cs b/service/Warehouse/MesItemQtManager.cs index e6438e5..dc04c4b 100644 --- a/service/Warehouse/MesItemQtManager.cs +++ b/service/Warehouse/MesItemQtManager.cs @@ -117,23 +117,33 @@ if (existingBarcode) throw new Exception("姝ゆ潯鐮佸凡缁忔壂鐮佸嚭搴�,鍕块噸澶嶆壂鎻忥紒"); // 鑾峰彇鏉$爜淇℃伅 - var barcode = Db.Queryable<MesInvItemBarcodes>() - .Where(it => it.ItemBarcode == p_item_barcode) - .First(); - - if (barcode == null) - throw new Exception($"mes涓笉瀛樺湪姝ゆ潯鐮�,璇锋牳瀵癸紒{p_item_barcode}"); + MesInvItemBarcodes barcode; + try + { + barcode = Db.Queryable<MesInvItemBarcodes>() + .Where(it => it.ItemBarcode == p_item_barcode) + .First(); + } + catch + { + throw new Exception($"MES涓笉瀛樺湪姝ゆ潯鐮侊紝鏉$爜鍙凤細{p_item_barcode}锛岃鏍稿锛�"); + } // 鑾峰彇搴撳瓨淇℃伅 - var stock = Db.Queryable<MesInvItemStocks>() - .Where(it => it.ItemBarcode == p_item_barcode && it.Quantity > 0) - .First(); - - if (stock == null) - throw new Exception($"搴撳瓨涓棤姝ゆ潯鐮侊紝璇锋鏌ユ潯鐮佹槸鍚︽湭鍏ュ簱鎴栧凡鍑哄簱锛亄p_item_barcode}"); + MesInvItemStocks stock; + try + { + stock = Db.Queryable<MesInvItemStocks>() + .Where(it => it.ItemBarcode == p_item_barcode && it.Quantity > 0) + .First(); + } + catch + { + throw new Exception($"搴撳瓨涓棤姝ゆ潯鐮侊紝鏉$爜鍙凤細{p_item_barcode}锛岃妫�鏌ユ潯鐮佹槸鍚︽湭鍏ュ簱鎴栧凡鍑哄簱锛�"); + } if (string.IsNullOrEmpty(stock.DepotsCode)) -- Gitblit v1.9.3