From b957cfb89c9968f47cc5ce9795e6ffb05bc57fd8 Mon Sep 17 00:00:00 2001
From: 啊鑫 <t2856754968@163.com>
Date: 星期三, 30 十月 2024 16:05:48 +0800
Subject: [PATCH] 11

---
 MES.Service/service/BasicData/MesDepotsManager.cs |   24 +++++++-----------------
 1 files changed, 7 insertions(+), 17 deletions(-)

diff --git a/MES.Service/service/BasicData/MesDepotsManager.cs b/MES.Service/service/BasicData/MesDepotsManager.cs
index f1c7591..6f5da5a 100644
--- a/MES.Service/service/BasicData/MesDepotsManager.cs
+++ b/MES.Service/service/BasicData/MesDepotsManager.cs
@@ -23,14 +23,11 @@
                     if (UpdateDepotStatus(db, entity.DepotId, "B")) return 1;
 
                     break;
-                case "2":
-                    if (InsertDepot(db, entity)) return 1;
-
-                    break;
                 case "3":
                     if (DeleteDepot(db, entity.DepotId)) return 1;
 
                     break;
+                case "2":
                 case "4":
                     if (InsertOrUpdate(db, entity)) return 1;
 
@@ -71,8 +68,8 @@
     // 鍒犻櫎浠撳簱鐨勬柟娉�
     private bool DeleteDepot(SqlSugarScope db, decimal depotId)
     {
-        var deleteById = db.Deleteable<MesDepots>().In(depotId)
-            .ExecuteCommand();
+        var deleteById = db.Deleteable<MesDepots>()
+            .Where(s => s.DepotId == depotId).ExecuteCommand();
         if (deleteById > 0)
             return true;
 
@@ -139,16 +136,12 @@
                                 "B")) // 鎵归噺绂佺敤浠撳簱
                             throw new NotImplementedException("绂佺敤澶辫触");
                         break;
-                    case "2":
-                        if (!InsertDepotBatch(db,
-                                depotsGroup.Value)) // 鎵归噺鎻掑叆浠撳簱
-                            throw new NotImplementedException("鎻掑叆澶辫触");
-                        break;
                     case "3":
                         if (!DeleteDepotBatch(db,
                                 depotsGroup.Value)) // 鎵归噺鍒犻櫎浠撳簱
                             throw new NotImplementedException("鍒犻櫎澶辫触");
                         break;
+                    case "2":
                     case "4":
                         if (!InsertOrUpdateBatch(db,
                                 depotsGroup.Value)) // 鎵归噺鎻掑叆鎴栨洿鏂颁粨搴�
@@ -195,7 +188,8 @@
     {
         var ids = depotList.Select(it => it.DepotId).ToArray();
         var deleteByIds =
-            db.Deleteable<MesDepots>().In(ids).ExecuteCommand();
+            db.Deleteable<MesDepots>()
+                .Where(s => ids.Contains(s.DepotId)).ExecuteCommand();
         if (deleteByIds > 0)
             return true;
 
@@ -206,10 +200,6 @@
     private bool InsertOrUpdateBatch(SqlSugarScope db,
         List<MesDepots> depotList)
     {
-        foreach (var entity in depotList)
-            if (!InsertOrUpdate(db, entity))
-                return false;
-
-        return true;
+        return depotList.All(entity => InsertOrUpdate(db, entity));
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3