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/MesItemsManager.cs | 86 +++++++++++++++---------------------------- 1 files changed, 30 insertions(+), 56 deletions(-) diff --git a/MES.Service/service/BasicData/MesItemsManager.cs b/MES.Service/service/BasicData/MesItemsManager.cs index a8933ba..87bbcf5 100644 --- a/MES.Service/service/BasicData/MesItemsManager.cs +++ b/MES.Service/service/BasicData/MesItemsManager.cs @@ -44,39 +44,15 @@ public bool SaveList(List<ErpItems> items) { - var list = items.Select(GetMesItems).ToList(); - var groupBy = list.GroupBy(s => s.Type) - .ToDictionary(g => g.Key, g => g.ToList()); - - return UseTransaction(db => + if (items == null || !items.Any()) { - foreach (var itemGroup in groupBy) - switch (itemGroup.Key) - { - case "0": - if (!UpdateItemStatusBatch(db, itemGroup.Value, "A")) - throw new NotImplementedException("鍚敤澶辫触"); - break; - case "1": - if (!UpdateItemStatusBatch(db, itemGroup.Value, "B")) - throw new NotImplementedException("绂佺敤澶辫触"); - break; - case "3": - if (!DeleteItemBatch(db, itemGroup.Value)) - throw new NotImplementedException("鍒犻櫎澶辫触"); - break; - case "2": - case "4": - if (!InsertOrUpdateBatch(db, itemGroup.Value)) - throw new NotImplementedException("鍚屾澶辫触"); - break; - default: - throw new ArgumentNullException( - $"type娌℃湁{itemGroup.Key}杩欎釜绫诲瀷鐨勫弬鏁�"); - } - - return 1; - }) > 0; + Console.WriteLine("璀﹀憡: 浼犲叆鐨勭墿鏂欏垪琛ㄤ负绌�"); + return false; + } + + // 閫愭潯澶勭悊锛屽叏閮ㄦ垚鍔熸墠杩斿洖true锛堜簨鍔″唴鎵归噺澶勭悊鏇翠紭锛屾澶勪繚鎸佸師鏈夐�昏緫锛� + var result = items.Select(Save).ToList(); + return result.All(b => b); } private bool UpdateItemStatus(SqlSugarScope db, decimal itemId, @@ -113,36 +89,37 @@ private MesItems GetMesItems(ErpItems item) { + var id = string.IsNullOrEmpty(item.Id) + ? DateTimeOffset.UtcNow.ToUnixTimeSeconds() + : long.Parse(item.Id); var entity = new MesItems { - Id = string.IsNullOrEmpty(item.Id) - ? DateTimeOffset.UtcNow.ToUnixTimeSeconds() - : long.Parse(item.Id), + Id = id, Type = item.Type, ItemNo = item.FNumber, ItemName = item.FName, ItemModel = item.FSpecification, ItemUnit = item.FBaseUnitId, - Lowlimit = !string.IsNullOrEmpty(item.FSafeStock) - ? Convert.ToDecimal(item.FSafeStock) - : null, - Highlimit = !string.IsNullOrEmpty(item.FMaxStock) - ? Convert.ToDecimal(item.FMaxStock) - : null, - PrdPack = !string.IsNullOrEmpty(item.FMinPackCount) - ? Convert.ToDecimal(item.FMinPackCount) - : null, + // Lowlimit = !string.IsNullOrEmpty(item.FSafeStock) + // ? Convert.ToDecimal(item.FSafeStock) + // : null, + // Highlimit = !string.IsNullOrEmpty(item.FMaxStock) + // ? Convert.ToDecimal(item.FMaxStock) + // : null, + // PrdPack = !string.IsNullOrEmpty(item.FMinPackCount) + // ? Convert.ToDecimal(item.FMinPackCount) + // : null, DepotCode = item.FStockId, Fmaterialgroup = item.FMaterialGroup, Remarks = item.FDescription, - Ffinishreceiptoverrate = - !string.IsNullOrEmpty(item.FFinishReceiptOverRate) - ? Convert.ToInt32(item.FFinishReceiptOverRate) - : null, + // Ffinishreceiptoverrate = + // !string.IsNullOrEmpty(item.FFinishReceiptOverRate) + // ? Convert.ToInt32(item.FFinishReceiptOverRate) + // : null, Fissuetype = item.FIssueType, - Fisbatchmanage = !string.IsNullOrEmpty(item.FIsBatchManage) - ? Convert.ToInt32(item.FIsBatchManage) - : null, + // Fisbatchmanage = !string.IsNullOrEmpty(item.FIsBatchManage) + // ? Convert.ToInt32(item.FIsBatchManage) + // : null, Fpurchaserid = item.FPurchaserId, Fpurchaseunitid = item.FPurchaseUnitId, Storeunit = item.FStoreUnitID, @@ -161,11 +138,8 @@ LossPercent = item.FLOSSPERCENT, MnemonicCode = item.FMnemonicCode, ExpPeriod = item.FExpPeriod, - EItemId = !string.IsNullOrEmpty(item.Id) - ? long.Parse(item.Id) - : null, - ItemId = - !string.IsNullOrEmpty(item.Id) ? long.Parse(item.Id) : null, + EItemId = id, + ItemId = id, LastupdateDate = DateTime.Now, CreateDate = DateTime.Now, Company = "1000", -- Gitblit v1.9.3