From c6d9fc76d16c944e64d6490eb2a6d866fd7a38f0 Mon Sep 17 00:00:00 2001
From: tjx <t2856754968@163.com>
Date: 星期三, 12 十一月 2025 09:06:01 +0800
Subject: [PATCH] 11
---
MES.Service/service/BasicData/MesStaffManager.cs | 27 +++++++++++++++------------
1 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/MES.Service/service/BasicData/MesStaffManager.cs b/MES.Service/service/BasicData/MesStaffManager.cs
index d0eb8b7..28a1ef5 100644
--- a/MES.Service/service/BasicData/MesStaffManager.cs
+++ b/MES.Service/service/BasicData/MesStaffManager.cs
@@ -49,12 +49,12 @@
}
// 鎻掑叆鎴栨洿鏂板憳宸ョ殑鏂规硶
- private bool InsertOrUpdateStaff(SqlSugarScope db,MesStaff entity)
+ private bool InsertOrUpdateStaff(SqlSugarScope db, MesStaff entity)
{
- var exists = db.Queryable<MesStaff>().Any(e => e.Id == entity.Id);
+ var exists = db.Queryable<MesStaff>().Any(e => e.Id == entity.Id && e.StaffNo==entity.StaffNo);
if (exists)
{
- var update = db.Updateable(entity).ExecuteCommand();
+ var update = db.Updateable(entity).Where(e => e.Id == entity.Id && e.StaffNo == entity.StaffNo).ExecuteCommand();
return true;
}
else
@@ -90,9 +90,8 @@
};
if (staff.FStaffStartDate != null)
- {
- entity.StartDate = DateTime.ParseExact(staff.FStaffStartDate, "yyyy-MM-dd HH:mm:ss", null);
- }
+ entity.StartDate = DateTime.ParseExact(staff.FStaffStartDate,
+ "yyyy-MM-dd HH:mm:ss", null);
return entity;
}
@@ -108,15 +107,17 @@
switch (staffGroup.Key)
{
case "0":
- if (!UpdateStaffStatusBatch(db, staffGroup.Value,"A")) // 鎵归噺鍚敤鍛樺伐
+ if (!UpdateStaffStatusBatch(db, staffGroup.Value,
+ "A")) // 鎵归噺鍚敤鍛樺伐
throw new NotImplementedException("鍚敤澶辫触");
break;
case "1":
- if (!UpdateStaffStatusBatch(db, staffGroup.Value,"B")) // 鎵归噺绂佺敤鍛樺伐
+ if (!UpdateStaffStatusBatch(db, staffGroup.Value,
+ "B")) // 鎵归噺绂佺敤鍛樺伐
throw new NotImplementedException("绂佺敤澶辫触");
break;
case "2":
- if (!InsertStaffBatch(db,staffGroup.Value)) // 鎵归噺鎻掑叆鍛樺伐
+ if (!InsertStaffBatch(db, staffGroup.Value)) // 鎵归噺鎻掑叆鍛樺伐
throw new NotImplementedException("鎻掑叆澶辫触");
break;
case "3":
@@ -124,11 +125,13 @@
throw new NotImplementedException("鍒犻櫎澶辫触");
break;
case "4":
- if (!InsertOrUpdateBatch(db,staffGroup.Value)) // 鎵归噺鎻掑叆鎴栨洿鏂板憳宸�
+ if (!InsertOrUpdateBatch(db,
+ staffGroup.Value)) // 鎵归噺鎻掑叆鎴栨洿鏂板憳宸�
throw new NotImplementedException("鍚屾澶辫触");
break;
default:
- throw new ArgumentNullException($"type娌℃湁{staffGroup.Key}杩欎釜绫诲瀷鐨勫弬鏁�");
+ throw new ArgumentNullException(
+ $"type娌℃湁{staffGroup.Key}杩欎釜绫诲瀷鐨勫弬鏁�");
}
return 1;
@@ -145,7 +148,7 @@
}
// 鎵归噺鎻掑叆鍛樺伐鐨勬柟娉�
- private bool InsertStaffBatch(SqlSugarScope db,List<MesStaff> staffList)
+ private bool InsertStaffBatch(SqlSugarScope db, List<MesStaff> staffList)
{
foreach (var entity in staffList)
{
--
Gitblit v1.9.3