From 8685c8e96eeeaa262044f0fdc7827e645f5e22a0 Mon Sep 17 00:00:00 2001
From: 啊鑫 <t2856754968@163.com>
Date: 星期一, 23 十二月 2024 21:50:07 +0800
Subject: [PATCH] 111

---
 service/Warehouse/MesItemTblManager.cs |  169 +++++++++++++++++++++++++------------------------------
 1 files changed, 77 insertions(+), 92 deletions(-)

diff --git a/service/Warehouse/MesItemTblManager.cs b/service/Warehouse/MesItemTblManager.cs
index f5c63c2..9560243 100644
--- a/service/Warehouse/MesItemTblManager.cs
+++ b/service/Warehouse/MesItemTblManager.cs
@@ -52,9 +52,7 @@
     public WarehouseQuery SctlScanDepots(WarehouseQuery query)
     {
         if (query.DepotCode.IsNullOrEmpty())
-        {
             throw new NullReferenceException("璇锋壂搴撲綅鏉$爜");
-        }
 
         var warehouseQuery = Db.Queryable<MesDepotSections, MesDepots>((a, b) =>
                 new JoinQueryInfos(JoinType.Inner, a.DepotGuid == b.Guid))
@@ -63,13 +61,11 @@
             {
                 DepotSectionName = a.DepotSectionName,
                 DepotName = b.DepotName,
-                DepotCode = b.DepotCode,
+                DepotCode = b.DepotCode
             }).First();
 
         if (warehouseQuery == null)
-        {
             throw new Exception("搴撲綅缂栫爜" + query.DepotCode + " 涓嶅瓨鍦紝璇风‘璁わ紒");
-        }
 
         return warehouseQuery;
     }
@@ -84,10 +80,7 @@
         var p_bill_type_id = 100;
         var p_transction_no = 104;
 
-        if (p_section_code.IsNullOrEmpty())
-        {
-            throw new Exception("璇锋壂搴撲綅鏉$爜锛�");
-        }
+        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))
@@ -95,25 +88,19 @@
             .Select((a, b) => b.DepotId).First();
 
         if (!c_depot_code.HasValue)
-        {
             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 + " 涓嶅瓨鍦紝璇风‘璁わ紒");
-        }
 
         var c_num = Db.Queryable<MesInvItemIns, MesInvItemInCDetails>((a, b) =>
                 new JoinQueryInfos(JoinType.Inner, a.Guid == b.ItemInId))
@@ -122,45 +109,29 @@
                              a.TransctionNo == p_transction_no.ToString())
             .Count();
 
-        if (c_num > 0)
-        {
-            throw new Exception("姝ゆ潯鐮佸凡鎵叆搴擄紝鍕块噸澶嶆壂鎻忥紒");
-        }
+        if (c_num > 0) throw new Exception("姝ゆ潯鐮佸凡鎵叆搴擄紝鍕块噸澶嶆壂鎻忥紒");
 
         c_num = Db.Queryable<MesInvItemStocks>()
             .Where(t => t.ItemBarcode == p_item_barcode).Count();
 
-        if (c_num > 0)
-        {
-            throw new Exception("姝ゆ潯鐮佸凡鎵叆搴擄紝鍕块噸澶嶆壂鎻忥紒");
-        }
+        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("姝ゆ潯鐮佷笉灞炰簬璇ラ��鏂欏崟锛岃鏍稿锛�");
-        }
 
         if (c_mes_inv_item_barcodes.Memo != "鐢熶骇閫�鏂�")
-        {
             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("鐢宠鍗曞凡鎾ゅ洖,鏃犳硶鎵爜!");
-        }
+        if (C_MES_ITEM_TBL == null) throw new Exception("鐢宠鍗曞凡鎾ゅ洖,鏃犳硶鎵爜!");
 
-        if (C_MES_ITEM_TBL.Tbl020 == 1)
-        {
-            throw new Exception("鎵爜瀹屾垚,鐢宠鍗曞凡瀹岀粨!");
-        }
+        if (C_MES_ITEM_TBL.Tbl020 == 1) throw new Exception("鎵爜瀹屾垚,鐢宠鍗曞凡瀹岀粨!");
 
         var C_MES_ITEM_TBL_DETAIL = Db.Queryable<MesItemTblDetail>()
             .Where(a => a.Tlmid == C_MES_ITEM_TBL.Id
@@ -168,9 +139,7 @@
             .First();
 
         if (C_MES_ITEM_TBL_DETAIL == null)
-        {
             throw new Exception("鏉$爜涓嶅睘浜庤鐢宠鍗曟槑缁�,鏃犳硶鎵爜!");
-        }
 
         var c_quantity = c_mes_inv_item_barcodes.Quantity;
 
@@ -223,10 +192,7 @@
             }
 
             var hbdy = c_mes_inv_item_barcodes.Hbdy ?? 0;
-            if (hbdy == 1)
-            {
-                throw new Exception("涓嶆敮鎸佸悎骞舵墦鍗扮殑鏉$爜:" + p_item_barcode);
-            }
+            if (hbdy == 1) throw new Exception("涓嶆敮鎸佸悎骞舵墦鍗扮殑鏉$爜:" + p_item_barcode);
 
             totalResult += db.Insertable(new MesInvItemInCDetails
             {
@@ -321,46 +287,58 @@
             {
                 // 鑹搧閫�鏂� - 鏇存柊宸ュ崟琛�(WOMDAB)鐩稿叧鏁伴噺
                 if (C_MES_ITEM_TBL.Tbl005 == "鑹搧閫�鏂�")
-                {
-                    totalResult += Db.Updateable<Womdab>()
-                        .SetColumns(it => new Womdab 
-                        { 
-                            Dab007 = it.Dab007 - c_mes_inv_item_barcodes.Quantity,  // 鍑忓皯宸ュ崟鏁伴噺
-                            Dab022 = (it.Dab022 ?? 0) + c_mes_inv_item_barcodes.Quantity,  // 澧炲姞閫�鏂欐暟閲�
-                            LpTl = (it.LpTl ?? 0) + (int)c_mes_inv_item_barcodes.Quantity,  // 澧炲姞鑹搧閫�鏂欐暟閲�
-                            Dab020 = (it.Dab020 ?? 0) - c_mes_inv_item_barcodes.Quantity  // 鍑忓皯宸插彂鏂欐暟閲�
-                        })
-                        .Where(it => it.Dab001 == c_mes_inv_item_barcodes.WorkNo 
-                            && it.Dab002 == c_mes_inv_item_barcodes.WorkLine
-                            && it.Dab003 == c_mes_inv_item_barcodes.ItemId.ToString())
-                        .ExecuteCommand();
-                }
-                // 鏉ユ枡涓嶈壇閫�鏂� - 鏇存柊宸ュ崟琛�(WOMDAB)鐩稿叧鏁伴噺
-                else if (C_MES_ITEM_TBL.Tbl005 == "鏉ユ枡涓嶈壇閫�鏂�") 
-                {
                     totalResult += Db.Updateable<Womdab>()
                         .SetColumns(it => new Womdab
                         {
-                            Dab007 = it.Dab007 - c_mes_inv_item_barcodes.Quantity,  // 鍑忓皯宸ュ崟鏁伴噺
-                            Dab022 = (it.Dab022 ?? 0) + c_mes_inv_item_barcodes.Quantity,  // 澧炲姞閫�鏂欐暟閲�
-                            LlBl = (it.LlBl ?? 0) + (int)c_mes_inv_item_barcodes.Quantity,  // 澧炲姞鏉ユ枡涓嶈壇鏁伴噺
-                            Dab020 = (it.Dab020 ?? 0) - c_mes_inv_item_barcodes.Quantity  // 鍑忓皯宸插彂鏂欐暟閲�
+                            Dab007 = it.Dab007 -
+                                     c_mes_inv_item_barcodes.Quantity, // 鍑忓皯宸ュ崟鏁伴噺
+                            Dab022 = (it.Dab022 ?? 0) +
+                                     c_mes_inv_item_barcodes.Quantity, // 澧炲姞閫�鏂欐暟閲�
+                            LpTl = (it.LpTl ?? 0) +
+                                   (int)c_mes_inv_item_barcodes
+                                       .Quantity, // 澧炲姞鑹搧閫�鏂欐暟閲�
+                            Dab020 = (it.Dab020 ?? 0) -
+                                     c_mes_inv_item_barcodes.Quantity // 鍑忓皯宸插彂鏂欐暟閲�
                         })
                         .Where(it => it.Dab001 == c_mes_inv_item_barcodes.WorkNo
-                            && it.Dab002 == c_mes_inv_item_barcodes.WorkLine
-                            && it.Dab003 == c_mes_inv_item_barcodes.ItemId.ToString())
+                                     && it.Dab002 == c_mes_inv_item_barcodes
+                                         .WorkLine
+                                     && it.Dab003 == c_mes_inv_item_barcodes
+                                         .ItemId.ToString())
                         .ExecuteCommand();
-                }
+                // 鏉ユ枡涓嶈壇閫�鏂� - 鏇存柊宸ュ崟琛�(WOMDAB)鐩稿叧鏁伴噺
+                else if (C_MES_ITEM_TBL.Tbl005 == "鏉ユ枡涓嶈壇閫�鏂�")
+                    totalResult += Db.Updateable<Womdab>()
+                        .SetColumns(it => new Womdab
+                        {
+                            Dab007 = it.Dab007 -
+                                     c_mes_inv_item_barcodes.Quantity, // 鍑忓皯宸ュ崟鏁伴噺
+                            Dab022 = (it.Dab022 ?? 0) +
+                                     c_mes_inv_item_barcodes.Quantity, // 澧炲姞閫�鏂欐暟閲�
+                            LlBl = (it.LlBl ?? 0) +
+                                   (int)c_mes_inv_item_barcodes
+                                       .Quantity, // 澧炲姞鏉ユ枡涓嶈壇鏁伴噺
+                            Dab020 = (it.Dab020 ?? 0) -
+                                     c_mes_inv_item_barcodes.Quantity // 鍑忓皯宸插彂鏂欐暟閲�
+                        })
+                        .Where(it => it.Dab001 == c_mes_inv_item_barcodes.WorkNo
+                                     && it.Dab002 == c_mes_inv_item_barcodes
+                                         .WorkLine
+                                     && it.Dab003 == c_mes_inv_item_barcodes
+                                         .ItemId.ToString())
+                        .ExecuteCommand();
 
                 // 鏇存柊閫�鏂欏崟鏄庣粏琛ㄥ凡閫�鏁伴噺
                 totalResult += Db.Updateable<MesItemTblDetail>()
                     .SetColumns(it => new MesItemTblDetail
                     {
-                        Tld006 = (it.Tld006 ?? 0) + (int)c_mes_inv_item_barcodes.Quantity  // 澧炲姞宸查��鏁伴噺
+                        Tld006 = (it.Tld006 ?? 0) +
+                                 (int)c_mes_inv_item_barcodes.Quantity // 澧炲姞宸查��鏁伴噺
                     })
                     .Where(it => it.Tlmid == C_MES_ITEM_TBL.Id
-                        && it.Tld009 == c_mes_inv_item_barcodes.ItemId 
-                        && it.Tld010 == c_mes_inv_item_barcodes.WorkLine)
+                                 && it.Tld009 == c_mes_inv_item_barcodes.ItemId
+                                 && it.Tld010 ==
+                                 c_mes_inv_item_barcodes.WorkLine)
                     .ExecuteCommand();
             }
             // 浣滀笟涓嶈壇閫�鏂� - 鏇存柊宸ュ崟琛ㄥ拰閫�鏂欏崟鏄庣粏琛�
@@ -369,59 +347,66 @@
                 totalResult += Db.Updateable<Womdab>()
                     .SetColumns(it => new Womdab
                     {
-                        Dab022 = (it.Dab022 ?? 0) + c_mes_inv_item_barcodes.Quantity,  // 澧炲姞閫�鏂欐暟閲�
-                        ZyBl = (it.ZyBl ?? 0) + (int)c_mes_inv_item_barcodes.Quantity,  // 澧炲姞浣滀笟涓嶈壇鏁伴噺
-                        Dab020 = (it.Dab020 ?? 0) - c_mes_inv_item_barcodes.Quantity  // 鍑忓皯宸插彂鏂欐暟閲�
+                        Dab022 = (it.Dab022 ?? 0) +
+                                 c_mes_inv_item_barcodes.Quantity, // 澧炲姞閫�鏂欐暟閲�
+                        ZyBl = (it.ZyBl ?? 0) +
+                               (int)c_mes_inv_item_barcodes
+                                   .Quantity, // 澧炲姞浣滀笟涓嶈壇鏁伴噺
+                        Dab020 = (it.Dab020 ?? 0) -
+                                 c_mes_inv_item_barcodes.Quantity // 鍑忓皯宸插彂鏂欐暟閲�
                     })
                     .Where(it => it.Dab001 == c_mes_inv_item_barcodes.WorkNo
-                        && it.Dab002 == c_mes_inv_item_barcodes.WorkLine
-                        && it.Dab003 == c_mes_inv_item_barcodes.ItemId.ToString())
+                                 && it.Dab002 ==
+                                 c_mes_inv_item_barcodes.WorkLine
+                                 && it.Dab003 == c_mes_inv_item_barcodes.ItemId
+                                     .ToString())
                     .ExecuteCommand();
 
                 // 鏇存柊閫�鏂欏崟鏄庣粏琛ㄥ凡閫�鏁伴噺
                 totalResult += Db.Updateable<MesItemTblDetail>()
                     .SetColumns(it => new MesItemTblDetail
                     {
-                        Tld006 = (it.Tld006 ?? 0) + (int)c_mes_inv_item_barcodes.Quantity  // 澧炲姞宸查��鏁伴噺
+                        Tld006 = (it.Tld006 ?? 0) +
+                                 (int)c_mes_inv_item_barcodes.Quantity // 澧炲姞宸查��鏁伴噺
                     })
                     .Where(it => it.Tlmid == C_MES_ITEM_TBL.Id
-                        && it.Tld009 == c_mes_inv_item_barcodes.ItemId
-                        && it.Tld010 == c_mes_inv_item_barcodes.WorkLine)
+                                 && it.Tld009 == c_mes_inv_item_barcodes.ItemId
+                                 && it.Tld010 ==
+                                 c_mes_inv_item_barcodes.WorkLine)
                     .ExecuteCommand();
             }
 
             // 濡傛灉寰呴��鏁伴噺绛変簬鏈閫�鏂欐暟閲忥紝鍒欐洿鏂版槑缁嗗畬鎴愮姸鎬�
-            if ((C_MES_ITEM_TBL_DETAIL.Tld005 ?? 0) - (C_MES_ITEM_TBL_DETAIL.Tld006 ?? 0) == c_mes_inv_item_barcodes.Quantity)
-            {
+            if ((C_MES_ITEM_TBL_DETAIL.Tld005 ?? 0) -
+                (C_MES_ITEM_TBL_DETAIL.Tld006 ?? 0) ==
+                c_mes_inv_item_barcodes.Quantity)
                 totalResult += Db.Updateable<MesItemTblDetail>()
-                    .SetColumns(it => new MesItemTblDetail { Tld008 = 1 })  // 璁剧疆瀹屾垚鏍囧織
+                    .SetColumns(it => new MesItemTblDetail
+                        { Tld008 = 1 }) // 璁剧疆瀹屾垚鏍囧織
                     .Where(it => it.Tlid == C_MES_ITEM_TBL_DETAIL.Tlid)
                     .ExecuteCommand();
-            }
 
             // 妫�鏌ラ��鏂欏崟鏄惁鎵�鏈夋槑缁嗛兘宸插畬鎴�
-            var remainingCount = Db.Queryable<MesItemTbl, MesItemTblDetail>((a, b) => 
-                new JoinQueryInfos(JoinType.Left, a.Id == b.Tlmid))
-                .Where((a, b) => a.BillNo == p_bill_no && (b.Tld005 ?? 0) - (b.Tld006 ?? 0) > 0)
+            var remainingCount = Db.Queryable<MesItemTbl, MesItemTblDetail>(
+                    (a, b) =>
+                        new JoinQueryInfos(JoinType.Left, a.Id == b.Tlmid))
+                .Where((a, b) =>
+                    a.BillNo == p_bill_no &&
+                    (b.Tld005 ?? 0) - (b.Tld006 ?? 0) > 0)
                 .Count();
 
             // 濡傛灉鎵�鏈夋槑缁嗛兘宸插畬鎴愶紝鍒欐洿鏂伴��鏂欏崟鐘舵�佷负宸插畬鎴�
             if (remainingCount < 1)
-            {
                 totalResult += Db.Updateable<MesItemTbl>()
-                    .SetColumns(it => it.Tbl020 == 1 )  // 璁剧疆瀹屾垚鏍囧織
+                    .SetColumns(it => it.Tbl020 == 1) // 璁剧疆瀹屾垚鏍囧織
                     .Where(it => it.BillNo == p_bill_no)
                     .ExecuteCommand();
-            }
-            
-            if (totalResult < 3)
-            {
-                throw new Exception("鎻掑叆澶辫触");
-            }
+
+            if (totalResult < 3) throw new Exception("鎻掑叆澶辫触");
 
             return totalResult;
         });
-        
+
         // 璁剧疆杩斿洖缁撴灉
         // c_result = $"001[,{c_mes_inv_item_barcodes.ItemNo},{c_quantity},鎵爜鎴愬姛锛�,鍙傝�冨簱浣岪鐗╂枡@寰呴��鏁伴噺{c_in_field_valT}";
 

--
Gitblit v1.9.3