From 2f4699ff377f0e5ea3640bb3670b2fbfbd56e3fb Mon Sep 17 00:00:00 2001
From: tjx <t2856754968@163.com>
Date: 星期四, 13 十一月 2025 10:47:58 +0800
Subject: [PATCH] 格式化清理代码

---
 StandardPda/MES.Service/service/Warehouse/MesInvItemOutsManager.cs |  165 ++++++++++++++++++------------------------------------
 1 files changed, 55 insertions(+), 110 deletions(-)

diff --git a/StandardPda/MES.Service/service/Warehouse/MesInvItemOutsManager.cs b/StandardPda/MES.Service/service/Warehouse/MesInvItemOutsManager.cs
index fb4a50c..7d44521 100644
--- a/StandardPda/MES.Service/service/Warehouse/MesInvItemOutsManager.cs
+++ b/StandardPda/MES.Service/service/Warehouse/MesInvItemOutsManager.cs
@@ -14,30 +14,26 @@
         var itemOutFrom = oItemOut.from;
         var itemOutLists = oItemOut.items;
 
-      return  UseTransaction(db =>
+        return UseTransaction(db =>
         {
             // 鏍规嵁AsnNo鍜孧esNo瀵规槑缁嗚繘琛屽垎缁�
             var groupedItems = itemOutLists
                 .GroupBy(item => new { item.AsnNo, item.MesNo, item.SqNo })
                 .ToList();
 
-            int result = 1;
+            var result = 1;
             foreach (var group in groupedItems)
             {
-                if (group.Key.AsnNo == null)
-                {
-                    throw new NotImplementedException("AsnNo涓嶈兘涓虹┖");
-                }
+                // if (group.Key.AsnNo == null)
+                // {
+                //     throw new NotImplementedException("AsnNo涓嶈兘涓虹┖");
+                // }
 
                 if (group.Key.MesNo == null)
-                {
                     throw new NotImplementedException("鍏ュ簱鍗曞崟鍙蜂笉鑳戒负绌�");
-                }
 
                 if (group.Key.SqNo == null)
-                {
                     throw new NotImplementedException("閫�璐х敵璇峰崟琛屽彿涓嶈兘涓虹┖");
-                }
 
                 // 鍒涘缓涓�涓复鏃剁殑itemOutFrom瀵硅薄锛屼娇鐢ㄥ垎缁勭殑Key浣滀负涓昏灞炴��
                 var tempItemOutFrom = new ItemOutFrom
@@ -58,37 +54,29 @@
                 switch (tempItemOutFrom.Type)
                 {
                     case "1":
-                        {
-                            var mesInvItemOuts = Db.Queryable<MesInvItemOuts>()
-                                .Where(s => s.BillTypeId == BILL_TYPE_ID
-                                            && s.TransactionNo == TRANSACTION_NO
-                                            && s.ItemOutNo == tempItemOutFrom.RtnNo
-                                            && s.Sapno == tempItemOutFrom.SqNo
-                                )
-                                .Count();
+                    {
+                        var mesInvItemOuts = Db.Queryable<MesInvItemOuts>()
+                            .Where(s => s.BillTypeId == BILL_TYPE_ID
+                                        && s.TransactionNo == TRANSACTION_NO
+                                        && s.ItemOutNo == tempItemOutFrom.RtnNo
+                                        && s.Sapno == tempItemOutFrom.SqNo
+                            )
+                            .Count();
 
-                            if (mesInvItemOuts > 0)
-                            {
-                                throw new NotImplementedException(
-                                    tempItemOutFrom.RtnNo +
-                                    "鐨勯��鏂欑敵璇峰崟宸茬粡瀛樺湪");
-                            }
+                        if (mesInvItemOuts > 0)
+                            throw new NotImplementedException(
+                                tempItemOutFrom.RtnNo +
+                                "鐨勯��鏂欑敵璇峰崟宸茬粡瀛樺湪");
 
-                            // 涓哄綋鍓嶅垎缁勪繚瀛樻暟鎹�
-                            var groupResult = Save(tempItemOutFrom, group.ToList());
-                            if (!groupResult)
-                            {
-                                result = 0;
-                            }
+                        // 涓哄綋鍓嶅垎缁勪繚瀛樻暟鎹�
+                        var groupResult = Save(tempItemOutFrom, group.ToList());
+                        if (!groupResult) result = 0;
 
-                            break;
-                        }
+                        break;
+                    }
                     case "4":
                         var removeResult = Remove(tempItemOutFrom);
-                        if (!removeResult)
-                        {
-                            result = 0;
-                        }
+                        if (!removeResult) result = 0;
 
                         break;
                     default:
@@ -99,8 +87,6 @@
 
             return result;
         }) > 0;
-
-       
     }
 
     private bool Save(ItemOutFrom from, List<ItemOutList> items)
@@ -111,38 +97,29 @@
                         && s.BillNo == from.MesNo
             ).First();
 
-        if (mesInvItemIns == null)
-        {
-            throw new NotImplementedException("閲囪喘鍏ュ簱涓嶅瓨鍦�");
-        }
+        if (mesInvItemIns == null) throw new NotImplementedException("閲囪喘鍏ュ簱涓嶅瓨鍦�");
 
         var mesDepots = Db.Queryable<MesDepots>()
-            .Where(s => s.DepotId == Decimal.Parse(from.DepotId)).First();
+            .Where(s => s.DepotId == decimal.Parse(from.DepotId)).First();
 
         var mesLinkU9 = Db.Queryable<MesLinkU9>()
             .Where(s => s.TableType == "MES_SUPPLIER"
                         && s.U9Id == from.SupperId).First();
 
         if (mesLinkU9 == null)
-        {
             throw new NotImplementedException("渚涘簲鍟咺D涓嶅瓨鍦ㄦ垨鏈悓姝ヤ簬U9");
-        }
 
         var mesSupplier = Db.Queryable<MesSupplier>()
-            .Where(s => s.Id == Decimal.Parse(mesLinkU9.MesId))
+            .Where(s => s.Id == decimal.Parse(mesLinkU9.MesId))
             .First();
 
         if (mesDepots == null)
-        {
             throw new NotImplementedException("[" + from.DepotId +
                                               "]浠撳簱涓嶅瓨鍦紝璇峰悓姝ョ粰MES");
-        }
 
         if (mesSupplier == null)
-        {
             throw new NotImplementedException("[" + from.SupperId +
                                               "]渚涘簲鍟嗕笉瀛樺湪锛岃鍚屾缁橫ES");
-        }
 
         var nextSequenceValue =
             Db.Ado.SqlQuery<decimal>("SELECT SEQ_OUT_ID.NEXTVAL FROM DUAL")
@@ -178,7 +155,7 @@
             WorkNo = from.AsnNo,
             Fmrmode = from.FMRMODE,
             Sapno = from.SqNo,
-            Organizeid = "1002503270000079",
+            Organizeid = "1002503270000079"
         };
 
         // 鍒涘缓閲囪喘閫�鏂欏崟璁板綍
@@ -188,24 +165,18 @@
         {
             // 妫�鏌ュ繀瑕佸瓧娈垫槸鍚︿负绌�
             if (string.IsNullOrEmpty(itemOutList.SrcDocNo))
-            {
                 throw new NotImplementedException("閲囪喘璁㈠崟鍙蜂笉鑳戒负绌�");
-            }
 
             if (string.IsNullOrEmpty(itemOutList.SrcDocLineNo))
-            {
                 throw new NotImplementedException("閲囪喘璁㈠崟琛屽彿涓嶈兘涓虹┖");
-            }
 
-            if (string.IsNullOrEmpty(itemOutList.AsnLineNo))
-            {
-                throw new NotImplementedException("ASN琛屽彿涓嶈兘涓虹┖");
-            }
+            //if (string.IsNullOrEmpty(itemOutList.AsnLineNo))
+            //{
+            //    throw new NotImplementedException("ASN琛屽彿涓嶈兘涓虹┖");
+            //}
 
             if (string.IsNullOrEmpty(itemOutList.itemId))
-            {
                 throw new NotImplementedException("鐗╂枡ID涓嶈兘涓虹┖");
-            }
 
             var mesRohInData = Db.Queryable<MesRohInData>()
                 .Where(s => s.BillNo == itemOutList.SrcDocNo
@@ -213,69 +184,59 @@
                 .First();
 
             if (mesRohInData == null)
-            {
                 throw new NotImplementedException("閲囪喘璁㈠崟涓嶅瓨鍦�");
-            }
 
-            var deliveryDetail = Db.Queryable<DeliveryDetail>()
-                .Where(a => a.Zzasn == from.AsnNo
-                            && Int32.Parse(a.ZzitemId) ==
-                            Int32.Parse(itemOutList.AsnLineNo))
-                .Count();
+            // var deliveryDetail = Db.Queryable<DeliveryDetail>()
+            //     .Where(a => a.Zzasn == from.AsnNo
+            //                 && Int32.Parse(a.ZzitemId) ==
+            //                 Int32.Parse(itemOutList.AsnLineNo))
+            //     .Count();
 
-            if (deliveryDetail <= 0)
-            {
-                throw new NotImplementedException("[" + from.AsnNo + "]鐨勬槑缁嗚[" +
-                                                  itemOutList.AsnLineNo +
-                                                  "]涓嶅瓨鍦�");
-            }
+            // if (deliveryDetail <= 0)
+            // {
+            //     throw new NotImplementedException("[" + from.AsnNo + "]鐨勬槑缁嗚[" +
+            //                                       itemOutList.AsnLineNo +
+            //                                       "]涓嶅瓨鍦�");
+            // }
 
             var itemIdLinkU9 = Db.Queryable<MesLinkU9>()
                 .Where(s => s.TableType == "MES_ITEMS"
                             && s.U9Id == itemOutList.itemId).First();
 
             if (mesLinkU9 == null)
-            {
                 throw new NotImplementedException("渚涘簲鍟咺D涓嶅瓨鍦ㄦ垨鏈悓姝ヤ簬U9");
-            }
 
             var mesItems = Db.Queryable<MesItems>()
-                .Where(s => s.Id == Decimal.Parse(itemIdLinkU9.MesId))
+                .Where(s => s.Id == decimal.Parse(itemIdLinkU9.MesId))
                 .First();
 
             if (mesItems == null)
-            {
                 throw new NotImplementedException("[" + itemOutList.itemId +
                                                   "]鐗╂枡涓嶅瓨鍦紝璇峰悓姝ョ粰MES");
-            }
 
             var mesInvItemInCItems = Db.Queryable<MesInvItemInCItems>()
                 .Where(s => s.ItemInId == mesInvItemIns.Id
                             && s.ItemNo == mesItems.ItemNo
                             && s.Ebeln == itemOutList.SrcDocNo
                             && s.EbelnLineNo ==
-                            Decimal.Parse(itemOutList.SrcDocLineNo)
+                            decimal.Parse(itemOutList.SrcDocLineNo)
                             && s.SuppNo == mesSupplier.SuppNo
-                            && Convert.ToInt32(s.ZzitemId) ==
-                            Convert.ToInt32(itemOutList.AsnLineNo)).First();
+                    // && Convert.ToInt32(s.ZzitemId) == Convert.ToInt32(itemOutList.AsnLineNo)
+                ).First();
 
             if (mesInvItemInCItems == null)
-            {
                 throw new NotImplementedException("娌℃湁瀵瑰簲鐨勫叆搴撴槑缁�");
-            }
 
 
             // 纭繚CbillNo涓嶄负绌�
             if (string.IsNullOrEmpty(mesInvItemIns.CbillNo))
-            {
                 throw new NotImplementedException("鍏ュ簱鍗曞叧鑱旂殑閲囪喘鍗曞彿涓嶈兘涓虹┖");
-            }
 
             mesInvItemOutItems.Add(new MesInvItemOutItems
             {
                 ItemOutId = nextSequenceValue,
                 ItemNo = mesItems.ItemNo,
-                Quantity = Decimal.Parse(itemOutList.qty),
+                Quantity = decimal.Parse(itemOutList.qty),
                 CreateBy = "PL017",
                 CreateDate = DateTime.Now,
                 Factory = "1000",
@@ -283,9 +244,9 @@
                 DepotCode = mesDepots.DepotCode,
                 WorkNo = itemOutList.SrcDocNo, // 纭繚WorkNo鏈夊��
                 WorkLine =
-                    Decimal.Parse(itemOutList.SrcDocLineNo), // 纭繚WorkLine鏈夊��
-                EbelnK3id = Decimal.Parse(mesRohInData.ErpId),
-                LineK3id = Decimal.Parse(mesRohInData.EbelnK3id),
+                    decimal.Parse(itemOutList.SrcDocLineNo), // 纭繚WorkLine鏈夊��
+                EbelnK3id = decimal.Parse(mesRohInData.ErpId),
+                LineK3id = decimal.Parse(mesRohInData.EbelnK3id),
                 FType = 0,
                 Status = 0,
                 PbillNo = mesInvItemIns.CbillNo, // 纭繚PbillNo鏈夊��
@@ -293,27 +254,21 @@
                 RkLine = mesInvItemInCItems.Id, // 纭繚RkLine鏈夊��
                 RkQty = mesInvItemInCItems.Quantity,
                 TlQty = 0,
-                ItemId = Decimal.Parse(itemIdLinkU9.MesId), // 纭繚ItemId鏈夊��
+                ItemId = decimal.Parse(itemIdLinkU9.MesId), // 纭繚ItemId鏈夊��
                 SqNo = itemOutList.SqNo, // 纭繚ItemId鏈夊��
-                ZzitemId = itemOutList.AsnLineNo, // 纭繚ItemId鏈夊��
+                ZzitemId = itemOutList.AsnLineNo // 纭繚ItemId鏈夊��
                 // Unit = item.Unit,
             });
         }
 
         var outItemCommand = Db.Insertable(mesInvItemOutItems)
             .PageSize(1).IgnoreColumnsNull().ExecuteCommand();
-        if (outItemCommand <= 0)
-        {
-            throw new Exception("鍒涘缓閲囪喘閫�鏂欏崟瀛愯〃澶辫触");
-        }
+        if (outItemCommand <= 0) throw new Exception("鍒涘缓閲囪喘閫�鏂欏崟瀛愯〃澶辫触");
 
         // 鎻掑叆閲囪喘閫�鏂欏崟璁板綍
         var insertResult = Db.Insertable(mesInvItemOuts).IgnoreColumns(true)
             .ExecuteCommand();
-        if (insertResult <= 0)
-        {
-            throw new Exception("鍒涘缓閲囪喘閫�鏂欏崟澶辫触");
-        }
+        if (insertResult <= 0) throw new Exception("鍒涘缓閲囪喘閫�鏂欏崟澶辫触");
 
         return outItemCommand + insertResult >= 2;
     }
@@ -327,15 +282,11 @@
                         && s.ItemOutNo == from.RtnNo).ToList();
 
         if (mesInvItemOuts == null || mesInvItemOuts.Count == 0)
-        {
             throw new NotImplementedException("鎵句笉鍒板搴旂殑閲囪喘閫�鏂欏崟: " + from.RtnNo);
-        }
 
         // 妫�鏌ユ槸鍚︽湁宸插鏍哥殑鍗曟嵁锛屽鏋滃瓨鍦ㄥ凡瀹℃牳(Status=1)鍒欎笉鍏佽鍒犻櫎
         if (mesInvItemOuts.Any(item => item.Status == 1))
-        {
             throw new NotImplementedException("瀛樺湪宸插鏍哥殑閲囪喘閫�鏂欏崟锛屼笉鍏佽鍒犻櫎");
-        }
 
         // 鍒犻櫎鎵�鏈夌浉鍏冲崟鎹�
         foreach (var itemOut in mesInvItemOuts)
@@ -346,10 +297,8 @@
                 .ToList();
 
             if (mesInvItemOutItems == null || mesInvItemOutItems.Count == 0)
-            {
                 throw new NotImplementedException(
                     $"鎵句笉鍒伴噰璐��鏂欏崟[{itemOut.ItemOutNo}]瀵瑰簲鐨勬槑缁�");
-            }
 
             // 鍒犻櫎閲囪喘閫�鏂欏崟鏄庣粏
             var deleteItemsResult = Db.Deleteable<MesInvItemOutItems>()
@@ -357,9 +306,7 @@
                 .ExecuteCommand();
 
             if (deleteItemsResult <= 0)
-            {
                 throw new Exception($"鍒犻櫎閲囪喘閫�鏂欏崟[{itemOut.ItemOutNo}]鏄庣粏澶辫触");
-            }
 
             // 鍒犻櫎閲囪喘閫�鏂欏崟
             var deleteResult = Db.Deleteable<MesInvItemOuts>()
@@ -367,9 +314,7 @@
                 .ExecuteCommand();
 
             if (deleteResult <= 0)
-            {
                 throw new Exception($"鍒犻櫎閲囪喘閫�鏂欏崟[{itemOut.ItemOutNo}]澶辫触");
-            }
         }
 
         return true;

--
Gitblit v1.9.3