From 4db3ba3f84456c27fdd9be76ff76c17101270914 Mon Sep 17 00:00:00 2001
From: 啊鑫 <t2856754968@163.com>
Date: 星期三, 24 九月 2025 14:12:48 +0800
Subject: [PATCH] 111
---
service/Wom/WwGdManager.cs | 161 ++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 114 insertions(+), 47 deletions(-)
diff --git a/service/Wom/WwGdManager.cs b/service/Wom/WwGdManager.cs
index 34953f2..b96e906 100644
--- a/service/Wom/WwGdManager.cs
+++ b/service/Wom/WwGdManager.cs
@@ -267,27 +267,40 @@
if (p_section_code.IsNullOrEmpty()) throw new Exception("璇锋壂搴撲綅鏉$爜锛�");
// 鑾峰彇搴撲綅淇℃伅
- var c_depot_code = Db.Queryable<MesDepotSections, MesDepots>((a, b) =>
- new JoinQueryInfos(JoinType.Inner, a.DepotGuid == b.Guid))
- .Where((a, b) => a.DepotSectionCode == p_section_code)
- .Select((a, b) => b.DepotId).First();
+ int? c_depot_code;
+ try
+ {
+ c_depot_code = Db.Queryable<MesDepotSections, MesDepots>((a, b) =>
+ new JoinQueryInfos(JoinType.Inner, a.DepotGuid == b.Guid))
+ .Where((a, b) => a.DepotSectionCode == p_section_code)
+ .Select((a, b) => b.DepotId).First();
+ }
+ catch
+ {
+ throw new Exception($"搴撲綅缂栫爜 {p_section_code} 涓嶅瓨鍦紝璇风‘璁わ紒");
+ }
- if (!c_depot_code.HasValue)
- throw new Exception("搴撲綅缂栫爜" + p_section_code + " 涓嶅瓨鍦紝璇风‘璁わ紒");
+ MesDepotSections mesDepotSections;
+ try
+ {
+ mesDepotSections = Db.Queryable<MesDepotSections>()
+ .Where(a => a.DepotSectionCode == p_section_code).First();
+ }
+ catch
+ {
+ throw new Exception($"搴撲綅缂栫爜 {p_section_code} 涓嶅瓨鍦紝璇风‘璁わ紒");
+ }
- // 鑾峰彇搴撲綅鍒嗗尯淇℃伅
- var mesDepotSections = Db.Queryable<MesDepotSections>()
- .Where(a => a.DepotSectionCode == p_section_code).First();
-
- if (mesDepotSections == null)
- throw new Exception("搴撲綅缂栫爜" + p_section_code + " 涓嶅瓨鍦紝璇风‘璁わ紒");
-
- // 鑾峰彇搴撲綅鍩虹淇℃伅
- var c_mes_depots = Db.Queryable<MesDepots>()
- .Where(b => b.Guid == mesDepotSections.DepotGuid).First();
-
- if (c_mes_depots == null)
- throw new Exception("搴撲綅缂栫爜" + p_section_code + " 涓嶅瓨鍦紝璇风‘璁わ紒");
+ MesDepots c_mes_depots;
+ try
+ {
+ c_mes_depots = Db.Queryable<MesDepots>()
+ .Where(b => b.Guid == mesDepotSections.DepotGuid).First();
+ }
+ catch
+ {
+ throw new Exception($"搴撲綅缂栫爜 {p_section_code} 瀵瑰簲鐨勪粨搴撲笉瀛樺湪锛岃纭锛�");
+ }
// 妫�鏌ユ潯鐮佹槸鍚﹀凡鍏ュ簱
var c_num = Db.Queryable<MesInvItemIns, MesInvItemInCDetails>((a, b) =>
@@ -305,11 +318,16 @@
if (c_num > 0) throw new Exception("姝ゆ潯鐮佸凡鎵叆搴擄紝鍕块噸澶嶆壂鎻忥紒");
// 鑾峰彇鏉$爜淇℃伅
- var c_mes_inv_item_barcodes = Db.Queryable<MesInvItemBarcodes>()
- .Where(t => t.ItemBarcode == p_item_barcode).First();
-
- if (c_mes_inv_item_barcodes == null)
- throw new Exception("姝ゆ潯鐮佷笉灞炰簬璇ラ��鏂欏崟锛岃鏍稿锛�");
+ MesInvItemBarcodes c_mes_inv_item_barcodes;
+ try
+ {
+ c_mes_inv_item_barcodes = Db.Queryable<MesInvItemBarcodes>()
+ .Where(t => t.ItemBarcode == p_item_barcode).First();
+ }
+ catch
+ {
+ throw new Exception($"鏉$爜 {p_item_barcode} 涓嶅睘浜庤閫�鏂欏崟锛岃鏍稿锛�");
+ }
@@ -317,41 +335,90 @@
// throw new Exception("姝ゆ潯鐮佷笉鏄敓浜ч��鏂欐潯鐮侊紝涓嶅彲浣跨敤鐢熶骇閫�鏂欐ā鍧楋紒");
// 鑾峰彇閫�鏂欏崟淇℃伅
- var C_MES_ITEM_TBL = Db.Queryable<MesItemTbl>()
- .Where(a => a.BillNo == c_mes_inv_item_barcodes.BillNo
- && (a.Tbl013 ?? 0) == 1).First();
-
- if (C_MES_ITEM_TBL == null) throw new Exception("鐢宠鍗曞凡鎾ゅ洖,鏃犳硶鎵爜!");
+ MesItemTbl C_MES_ITEM_TBL;
+ try
+ {
+ C_MES_ITEM_TBL = Db.Queryable<MesItemTbl>()
+ .Where(a => a.BillNo == c_mes_inv_item_barcodes.BillNo
+ && (a.Tbl013 ?? 0) == 1).First();
+ }
+ catch
+ {
+ throw new Exception($"鐢宠鍗� {c_mes_inv_item_barcodes.BillNo} 宸叉挙鍥炴垨涓嶅瓨鍦紝鏃犳硶鎵爜锛�");
+ }
if (C_MES_ITEM_TBL.Tbl020 == 1) throw new Exception("鎵爜瀹屾垚,鐢宠鍗曞凡瀹岀粨!");
// 妫�鏌ュ伐鍗曚俊鎭�
- var wwgd = Db.Queryable<WwGd>()
- .Where(a => a.Id.ToString() == C_MES_ITEM_TBL.Tbl002)
- .First();
+ WwGd wwgd;
+ try
+ {
+ wwgd = Db.Queryable<WwGd>()
+ .Where(a => a.Id.ToString() == C_MES_ITEM_TBL.Tbl002)
+ .First();
+ }
+ catch
+ {
+ throw new Exception($"鐢宠鍗曞搴旂殑宸ュ崟涓嶅瓨鍦ㄦ垨宸插垹闄わ紝鍗曟嵁鍙凤細{C_MES_ITEM_TBL.Tbl002}锛屾棤娉曟壂鐮侊紒");
+ }
- if (wwgd == null) throw new Exception("鐢宠鍗曞搴旂殑宸ュ崟涓嶅瓨鍦ㄦ垨宸插垹闄�,鏃犳硶鎵爜!");
-
- // 妫�鏌ュ伐鍗曚俊鎭�
- var WWRWD = Db.Queryable<ProductionOrder>()
- .Where(a => a.OrderNo == wwgd.Daa014)
- .First();
+ // 妫�鏌ョ敓浜ц鍗曚俊鎭�
+ ProductionOrder WWRWD;
+ try
+ {
+ WWRWD = Db.Queryable<ProductionOrder>()
+ .Where(a => a.OrderNo == wwgd.Daa014)
+ .First();
+ }
+ catch
+ {
+ throw new Exception($"宸ュ崟 {wwgd.Daa014} 瀵瑰簲鐨勭敓浜ц鍗曚笉瀛樺湪锛岃纭锛�");
+ }
// 鑾峰彇閫�鏂欏崟鏄庣粏
- var C_MES_ITEM_TBL_DETAIL = Db.Queryable<MesItemTblDetail>()
- .Where(a => a.Tlid == c_mes_inv_item_barcodes.AboutGuid)
- .First();
-
- if (C_MES_ITEM_TBL_DETAIL == null)
- throw new Exception("鏉$爜涓嶅睘浜庤鐢宠鍗曟槑缁�,鏃犳硶鎵爜!");
+ MesItemTblDetail C_MES_ITEM_TBL_DETAIL;
+ try
+ {
+ C_MES_ITEM_TBL_DETAIL = Db.Queryable<MesItemTblDetail>()
+ .Where(a => a.Tlid == c_mes_inv_item_barcodes.AboutGuid)
+ .First();
+ }
+ catch
+ {
+ throw new Exception($"鏉$爜 {p_item_barcode} 涓嶅睘浜庤鐢宠鍗曟槑缁嗭紝鏃犳硶鎵爜锛�");
+ }
//鍒ゆ柇璐т富淇℃伅
- var CABerpid = Db.Queryable<WwGdDetail>().Where(womdab => womdab.Id.ToString() == C_MES_ITEM_TBL_DETAIL.Tld013).Select(womdab => womdab.Erpid).First();
+ int? CABerpid;
+ try
+ {
+ CABerpid = Db.Queryable<WwGdDetail>()
+ .Where(womdab => womdab.Id.ToString() == C_MES_ITEM_TBL_DETAIL.Tld013)
+ .Select(womdab => womdab.Erpid)
+ .First();
+ }
+ catch
+ {
+ throw new Exception($"鐢ㄦ枡娓呭崟鏄庣粏涓嶅瓨鍦紝鏄庣粏ID锛歿C_MES_ITEM_TBL_DETAIL.Tld013}锛岃鑱旂郴绠$悊鍛橈紒");
+ }
- var WWCAB = Db.Queryable<ProductionOrderSub>().Where(womcab => womcab.ErpId == CABerpid.Value.ToString()).First();
+ if (!CABerpid.HasValue)
+ throw new Exception("鐢ㄦ枡娓呭崟ERP ID涓虹┖锛岃鑱旂郴绠$悊鍛橈紒");
+ ProductionOrderSub WWCAB;
+ try
+ {
+ WWCAB = Db.Queryable<ProductionOrderSub>()
+ .Where(womcab => womcab.ErpId == CABerpid.Value.ToString())
+ .First();
+ }
+ catch
+ {
+ throw new Exception($"鐢熶骇璁㈠崟瀛愰」涓嶅瓨鍦紝ERP ID锛歿CABerpid.Value}锛岃鑱旂郴绠$悊鍛橈紒");
+ }
- if ( String.IsNullOrEmpty(WWCAB.Owner)) throw new Exception("鐢ㄦ枡娓呭崟璐т富淇℃伅涓嶅瓨鍦�,鏃犳硶鎵爜锛岃鑱旂郴绠$悊鍛�!");
+ if (string.IsNullOrEmpty(WWCAB.Owner))
+ throw new Exception($"鐢ㄦ枡娓呭崟璐т富淇℃伅涓嶅瓨鍦紝鐢熶骇璁㈠崟瀛愰」 ERP ID锛歿CABerpid.Value}锛屾棤娉曟壂鐮侊紝璇疯仈绯荤鐞嗗憳锛�");
//var owner_type = "";
//if (Db.Queryable<SysOrganization>().Any(x => x.Fid == ownerId))
--
Gitblit v1.9.3