From eab13f60bbdc8ea275c6dd7b6424cdfc7769f6e1 Mon Sep 17 00:00:00 2001
From: 啊鑫 <t2856754968@163.com>
Date: 星期三, 27 八月 2025 16:53:15 +0800
Subject: [PATCH] 111111

---
 MES.Service/service/BasicData/MesSupplierManager.cs |   53 +++++++++++++++++++----------------------------------
 1 files changed, 19 insertions(+), 34 deletions(-)

diff --git a/MES.Service/service/BasicData/MesSupplierManager.cs b/MES.Service/service/BasicData/MesSupplierManager.cs
index 022fb52..bec3b07 100644
--- a/MES.Service/service/BasicData/MesSupplierManager.cs
+++ b/MES.Service/service/BasicData/MesSupplierManager.cs
@@ -43,41 +43,15 @@
 
     public bool SaveList(List<ErpSupplier> suppliers)
     {
-        var list = suppliers.Select(GetMesSupplier).ToList();
-        var groupBy = list.GroupBy(s => s.Type)
-            .ToDictionary(g => g.Key, g => g.ToList());
-
-        return UseTransaction(db =>
+        if (suppliers == null || !suppliers.Any())
         {
-            foreach (var supplierGroup in groupBy)
-                switch (supplierGroup.Key)
-                {
-                    case "0":
-                        if (!UpdateSupplierStatusBatch(db, supplierGroup.Value,
-                                "A"))
-                            throw new NotImplementedException("鍚敤澶辫触");
-                        break;
-                    case "1":
-                        if (!UpdateSupplierStatusBatch(db, supplierGroup.Value,
-                                "B"))
-                            throw new NotImplementedException("绂佺敤澶辫触");
-                        break;
-                    case "3":
-                        if (!DeleteSupplierBatch(db, supplierGroup.Value))
-                            throw new NotImplementedException("鍒犻櫎澶辫触");
-                        break;
-                    case "2":
-                    case "4":
-                        if (!InsertOrUpdateBatch(db, supplierGroup.Value))
-                            throw new NotImplementedException("鍚屾澶辫触");
-                        break;
-                    default:
-                        throw new ArgumentNullException(
-                            $"type娌℃湁{supplierGroup.Key}杩欎釜绫诲瀷鐨勫弬鏁�");
-                }
+            Console.WriteLine("璀﹀憡: 浼犲叆鐨勫垪琛ㄤ负绌�");
+            return false;
+        }
 
-            return 1;
-        }) > 0;
+        // 閫愭潯澶勭悊锛屽叏閮ㄦ垚鍔熸墠杩斿洖true锛堜簨鍔″唴鎵归噺澶勭悊鏇翠紭锛屾澶勪繚鎸佸師鏈夐�昏緫锛�
+        var result = suppliers.Select(Save).ToList();
+        return result.All(b => b);
     }
 
     private bool UpdateSupplierStatus(SqlSugarScope db, decimal supplierId,
@@ -114,7 +88,7 @@
 
     private MesSupplier GetMesSupplier(ErpSupplier supplier)
     {
-        return new MesSupplier
+        var entity = new MesSupplier
         {
             Id = string.IsNullOrEmpty(supplier.Id)
                 ? DateTimeOffset.UtcNow.ToUnixTimeSeconds()
@@ -139,6 +113,17 @@
             Company = "1000",
             Factory = "1000",
         };
+
+        var mesSupplier = Db.Queryable<MesSupplier>()
+            .Where(s => s.SuppNo == entity.SuppNo)
+            .First();
+
+        if (mesSupplier != null)
+        {
+            entity.Id = mesSupplier.Id;
+        }
+
+        return entity;
     }
 
     private bool UpdateSupplierStatusBatch(SqlSugarScope db,

--
Gitblit v1.9.3