From 8d771316d68f1523bcdf30c97d3a55107cb5ae56 Mon Sep 17 00:00:00 2001 From: 啊鑫 <t2856754968@163.com> Date: 星期四, 04 九月 2025 10:53:31 +0800 Subject: [PATCH] 111 --- MES.Service/service/BasicData/MesDepotsManager.cs | 72 +++++++++-------------------------- 1 files changed, 19 insertions(+), 53 deletions(-) diff --git a/MES.Service/service/BasicData/MesDepotsManager.cs b/MES.Service/service/BasicData/MesDepotsManager.cs index dc15001..eb746d6 100644 --- a/MES.Service/service/BasicData/MesDepotsManager.cs +++ b/MES.Service/service/BasicData/MesDepotsManager.cs @@ -42,7 +42,7 @@ } // 鏇存柊浠撳簱鐘舵�佺殑鏂规硶 - private bool UpdateDepotStatus(SqlSugarScope db, long depotId, + private bool UpdateDepotStatus(SqlSugarScope db, decimal depotId, string status) { var result = db.Updateable<MesDepots>() @@ -93,9 +93,9 @@ { DepotCode = depots.FNumber, DepotName = depots.FName, - DepotId = string.IsNullOrEmpty(depots.Id) - ? DateTimeOffset.UtcNow.ToUnixTimeSeconds() - : long.Parse(depots.Id), + // DepotId = string.IsNullOrEmpty(depots.Id) + // ? DateTimeOffset.UtcNow.ToUnixTimeSeconds() + // : Convert.ToInt32(depots.Id), IsFkc = depots.FAllowMinusQty, CreateBy = depots.FPrincipal, Depottype = depots.FStockProperty, @@ -103,14 +103,14 @@ Zuid = depots.FGroup, DocumentStatus = depots.FDocumentStatus, - UseOrg = string.IsNullOrEmpty(depots.FUseOrgId) - ? 1 - : long.Parse(depots.FUseOrgId), - CreateOrg = string.IsNullOrEmpty(depots.FCreateOrgId) - ? 1 - : long.Parse(depots.FCreateOrgId), - CreateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), - LastupdateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), + FSubsidiary = string.IsNullOrEmpty(depots.FUseOrgId) + ? "1" + : depots.FUseOrgId, + Fumbrella = string.IsNullOrEmpty(depots.FCreateOrgId) + ? "1" + : depots.FCreateOrgId, + CreateDate = DateTime.Now, + LastupdateDate = DateTime.Now, Company = "1000", Factory = "1000" }; @@ -130,49 +130,15 @@ // SaveList 鏂规硶鐢ㄤ簬淇濆瓨澶氫釜浠撳簱璁板綍锛屾牴鎹被鍨嬫壒閲忔墽琛屼笉鍚岀殑鎿嶄綔 public bool SaveList(List<ErpDepots> erpDepots) { - var list = new List<MesDepots>(); - erpDepots.ForEach(s => + if (erpDepots == null || !erpDepots.Any()) { - var entity = GetMesDepots(s); // 灏� ErpDepots 杞崲涓� MesDepots - entity.Type = s.Type; - list.Add(entity); - }); + Console.WriteLine("璀﹀憡: 浼犲叆鐨勫垪琛ㄤ负绌�"); + return false; + } - var groupBy = list.GroupBy(s => s.Type) - .ToDictionary(g => g.Key, g => g.ToList()); - return UseTransaction(db => - { - foreach (var depotsGroup in groupBy) - switch (depotsGroup.Key) - { - case "0": - if (!UpdateDepotStatusBatch(db, depotsGroup.Value, - "A")) // 鎵归噺鍚敤浠撳簱 - throw new NotImplementedException("鍚敤澶辫触"); - break; - case "1": - if (!UpdateDepotStatusBatch(db, depotsGroup.Value, - "B")) // 鎵归噺绂佺敤浠撳簱 - throw new NotImplementedException("绂佺敤澶辫触"); - break; - case "3": - if (!DeleteDepotBatch(db, - depotsGroup.Value)) // 鎵归噺鍒犻櫎浠撳簱 - throw new NotImplementedException("鍒犻櫎澶辫触"); - break; - case "2": - case "4": - if (!InsertOrUpdateBatch(db, - depotsGroup.Value)) // 鎵归噺鎻掑叆鎴栨洿鏂颁粨搴� - throw new NotImplementedException("鍚屾澶辫触"); - break; - default: - throw new ArgumentNullException( - $"type娌℃湁{depotsGroup.Key}杩欎釜绫诲瀷鐨勫弬鏁�"); - } - - return 1; - }) > 0; + // 閫愭潯澶勭悊锛屽叏閮ㄦ垚鍔熸墠杩斿洖true锛堜簨鍔″唴鎵归噺澶勭悊鏇翠紭锛屾澶勪繚鎸佸師鏈夐�昏緫锛� + var result = erpDepots.Select(Save).ToList(); + return result.All(b => b); } // 鎵归噺鏇存柊浠撳簱鐘舵�佺殑鏂规硶 -- Gitblit v1.9.3