From a4ae3bf5f1826e8e29a95da3dc2c947d713d4ebb Mon Sep 17 00:00:00 2001 From: 南骏 池 <chiffly@163.com> Date: 星期五, 06 六月 2025 15:38:14 +0800 Subject: [PATCH] 1.仓库信息储存逻辑调整 2.生产订单接口优化。 --- MES.Service/service/BasicData/MesDepotsManager.cs | 54 ++++++++++++++++++------------------------------------ 1 files changed, 18 insertions(+), 36 deletions(-) diff --git a/MES.Service/service/BasicData/MesDepotsManager.cs b/MES.Service/service/BasicData/MesDepotsManager.cs index f495080..1a6bee0 100644 --- a/MES.Service/service/BasicData/MesDepotsManager.cs +++ b/MES.Service/service/BasicData/MesDepotsManager.cs @@ -1,5 +1,4 @@ -锘縰sing Castle.Core.Resource; -using MES.Service.DB; +锘縰sing MES.Service.DB; using MES.Service.Dto.webApi; using MES.Service.Modes; using SqlSugar; @@ -24,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; @@ -72,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; @@ -83,22 +79,11 @@ // 鎻掑叆鎴栨洿鏂颁粨搴撶殑鏂规硶 private bool InsertOrUpdate(SqlSugarScope db, MesDepots entity) { - var exists = db.Queryable<MesDepots>() - .Any(e => e.DepotId == entity.DepotId); - if (exists) - { - var update = db.Updateable(entity).ExecuteCommand(); - if (update > 0) - return true; - } - else - { - var insert = db.Insertable(entity).ExecuteCommand(); - if (insert > 0) - return true; - } - - return false; + db.Deleteable<MesDepots>() + .Where(s => s.DepotId == entity.DepotId) + .ExecuteCommand(); + var insert = db.Insertable(entity).ExecuteCommand(); + return insert > 0; } // 灏� ErpDepots 瀵硅薄杞崲涓� MesDepots 瀵硅薄鐨勬柟娉� @@ -106,6 +91,7 @@ { return new MesDepots { + Guid = depots.Id, DepotCode = depots.FNumber, DepotName = depots.FName, DepotId = Convert.ToDecimal(depots.Id), @@ -116,9 +102,12 @@ Zuid = depots.FGroup, FSubsidiary = depots.FUseOrgId, Fumbrella = depots.FCreateOrgId, - CreateDate = DateTime.Now, LastupdateDate = DateTime.Now, + SupplierId = depots.FSUPPLIERID, + ClientId = depots.ClientId, + Department = depots.Fdeptid, + Phone = depots.Phone, Company = "1000", Factory = "1000" }; @@ -152,16 +141,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)) // 鎵归噺鎻掑叆鎴栨洿鏂颁粨搴� @@ -208,7 +193,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; @@ -219,10 +205,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