From 89e876b90b1307ae9a61f2a0180200c98863aac1 Mon Sep 17 00:00:00 2001
From: 南骏 池 <chiffly@163.com>
Date: 星期五, 21 二月 2025 16:24:49 +0800
Subject: [PATCH] 1.委外入参注释
---
MES.Service/service/BasicData/MesPositionManager.cs | 48 ++++++++++++++----------------------------------
1 files changed, 14 insertions(+), 34 deletions(-)
diff --git a/MES.Service/service/BasicData/MesPositionManager.cs b/MES.Service/service/BasicData/MesPositionManager.cs
index 5cd83e4..6b67858 100644
--- a/MES.Service/service/BasicData/MesPositionManager.cs
+++ b/MES.Service/service/BasicData/MesPositionManager.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;
@@ -26,14 +25,11 @@
if (UpdatePositionStatus(db, entity.Id, "B")) // 绂佺敤宀椾綅
return 1;
break;
- case "2":
- if (InsertOrUpdatePosition(db, entity)) // 鎻掑叆鎴栨洿鏂板矖浣�
- return 1;
- break;
case "3":
if (DeletePosition(db, entity.Id)) // 鍒犻櫎宀椾綅
return 1;
break;
+ case "2":
case "4":
if (InsertOrUpdatePosition(db, entity)) // 鎻掑叆鎴栨洿鏂板矖浣�
return 1;
@@ -64,28 +60,17 @@
// 鎻掑叆鎴栨洿鏂板矖浣嶇殑鏂规硶
private bool InsertOrUpdatePosition(SqlSugarScope db, MesPosition entity)
{
- var exists = db.Queryable<MesPosition>().Any(e => e.Id == entity.Id);
- 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<MesPosition>()
+ .Where(s => s.Id == entity.Id).ExecuteCommand();
+ var insert = db.Insertable(entity).ExecuteCommand();
+ return insert > 0;
}
// 鍒犻櫎宀椾綅鐨勬柟娉�
private bool DeletePosition(SqlSugarScope db, decimal positionId)
{
- var deleteById = db.Deleteable<MesPosition>().In(positionId)
- .ExecuteCommand();
+ var deleteById = db.Deleteable<MesPosition>()
+ .Where(s => s.Id == positionId).ExecuteCommand();
if (deleteById > 0)
return true;
@@ -145,16 +130,12 @@
"B")) // 鎵归噺绂佺敤宀椾綅
throw new NotImplementedException("绂佺敤澶辫触");
break;
- case "2":
- if (!InsertPositionBatch(db,
- positionGroup.Value)) // 鎵归噺鎻掑叆宀椾綅
- throw new NotImplementedException("鎻掑叆澶辫触");
- break;
case "3":
if (!DeletePositionBatch(db,
positionGroup.Value)) // 鎵归噺鍒犻櫎宀椾綅
throw new NotImplementedException("鍒犻櫎澶辫触");
break;
+ case "2":
case "4":
if (!InsertOrUpdatePositionBatch(db,
positionGroup.Value)) // 鎵归噺鎻掑叆鎴栨洿鏂板矖浣�
@@ -200,7 +181,10 @@
List<MesPosition> positionList)
{
var ids = positionList.Select(it => it.Id).ToArray();
- var deleteByIds = db.Deleteable<MesPosition>().In(ids).ExecuteCommand();
+
+ var deleteByIds = db.Deleteable<MesPosition>()
+ .Where(s => ids.Contains(s.Id)).ExecuteCommand();
+
if (deleteByIds > 0)
return true;
@@ -211,10 +195,6 @@
private bool InsertOrUpdatePositionBatch(SqlSugarScope db,
List<MesPosition> positionList)
{
- foreach (var entity in positionList)
- if (!InsertOrUpdatePosition(db, entity))
- return false;
-
- return true;
+ return positionList.All(entity => InsertOrUpdatePosition(db, entity));
}
}
\ No newline at end of file
--
Gitblit v1.9.3