From 5de35354e8dfcb4933350d0d1b645d400bcf23ab Mon Sep 17 00:00:00 2001 From: sjz <1240968267@qq.com> Date: 星期二, 22 七月 2025 15:30:09 +0800 Subject: [PATCH] 优化多组织 --- MES.Service/service/BasicData/MesDepotsManager.cs | 15 +++++++-------- 1 files changed, 7 insertions(+), 8 deletions(-) diff --git a/MES.Service/service/BasicData/MesDepotsManager.cs b/MES.Service/service/BasicData/MesDepotsManager.cs index 3087d0b..ae137ed 100644 --- a/MES.Service/service/BasicData/MesDepotsManager.cs +++ b/MES.Service/service/BasicData/MesDepotsManager.cs @@ -53,10 +53,10 @@ // 鎻掑叆鏂颁粨搴撶殑鏂规硶 private bool InsertDepot(SqlSugarScope db, MesDepots entity) { - var exists = db.Queryable<MesDepots>().Any(e => e.DepotId == entity.DepotId); + var exists = db.Queryable<MesDepots>().Any(e => e.DepotId == entity.DepotId && e.DepotCode == entity.DepotCode); if (exists) { - var result = db.Updateable<MesDepots>().ExecuteCommand(); + var result = db.Updateable(entity).Where(e => e.DepotId == entity.DepotId && e.DepotCode == entity.DepotCode).ExecuteCommand(); return true; } else @@ -76,10 +76,10 @@ // 鎻掑叆鎴栨洿鏂颁粨搴撶殑鏂规硶 private bool InsertOrUpdate(SqlSugarScope db, MesDepots entity) { - var exists = db.Queryable<MesDepots>().Any(e => e.DepotId == entity.DepotId); + var exists = db.Queryable<MesDepots>().Any(e => e.DepotId == entity.DepotId && e.DepotCode == entity.DepotCode); if (exists) { - var update = db.Updateable(entity).ExecuteCommand(); + var update = db.Updateable(entity).Where(e => e.DepotId == entity.DepotId && e.DepotCode == entity.DepotCode).ExecuteCommand(); return true; } else @@ -109,8 +109,8 @@ Depottype = depots.FStockProperty, IsNg = depots.FForbidStatus, Zuid = depots.FGroup, - CreateOrg= Convert.ToDecimal(depots.FCreateOrgId), - UseOrg= Convert.ToDecimal(depots.FUseOrgId), + CreateOrg = Convert.ToDecimal(depots.FCreateOrgId), + UseOrg = Convert.ToDecimal(depots.FUseOrgId), CreateDate = DateTime.Now, Company = "1000", Factory = "1000" @@ -156,8 +156,7 @@ } // 鎵归噺鏇存柊浠撳簱鐘舵�佺殑鏂规硶 - private bool UpdateDepotStatusBatch(SqlSugarScope db, - List<MesDepots> depotList, string status) + private bool UpdateDepotStatusBatch(SqlSugarScope db,List<MesDepots> depotList, string status) { var ids = depotList.Select(it => it.DepotId).ToArray(); var result = db.Updateable<MesDepots>().SetColumns(s => s.IsNg == status).Where(s => ids.Contains(s.DepotId)).ExecuteCommand(); -- Gitblit v1.9.3