From 5dc3cc86f5835369cd830f2a83318b9a8d69cf69 Mon Sep 17 00:00:00 2001
From: 啊鑫 <t2856754968@163.com>
Date: 星期二, 15 七月 2025 16:20:19 +0800
Subject: [PATCH] 11
---
MES.Service/service/BasicData/MesStaffManager.cs | 146 ++++++++++++++++++++++++------------------------
1 files changed, 73 insertions(+), 73 deletions(-)
diff --git a/MES.Service/service/BasicData/MesStaffManager.cs b/MES.Service/service/BasicData/MesStaffManager.cs
index 98908bf..4710865 100644
--- a/MES.Service/service/BasicData/MesStaffManager.cs
+++ b/MES.Service/service/BasicData/MesStaffManager.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;
@@ -59,7 +58,7 @@
}
// 鎻掑叆鎴栨洿鏂板憳宸ョ殑鏂规硶
- private bool InsertOrUpdateStaff(SqlSugarScope db, SysUser sysUser,
+ private bool InsertOrUpdateStaff(SqlSugarScope db, SysUser sysUser,
MesStaff entity)
{
var exists = db.Queryable<SysUser>().Any(u => u.Sid == sysUser.Sid);
@@ -68,7 +67,9 @@
var updateUser = db.Updateable<SysUser>()
.SetColumns(s => s.Fcode == sysUser.Fcode)
.SetColumns(s => s.Fname == sysUser.Fname)
- .SetColumns(s => s.ErpUpdaeDate == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") )
+ .SetColumns(s =>
+ s.ErpUpdaeDate ==
+ DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
.Where(s => s.Sid == sysUser.Sid)
.ExecuteCommand();
if (updateUser > 0)
@@ -91,75 +92,75 @@
return false;
}
- /* private bool InsertOrUpdateStaff(SqlSugarScope db, SysUser sysUser, MesStaff entity)
-{
- try
- {
- // 妫�鏌ョ敤鎴锋槸鍚﹀瓨鍦�
- var userExists = db.Queryable<SysUser>().Any(u => u.Sid == sysUser.Sid);
- if (userExists)
- {
- // 鏇存柊鐢ㄦ埛
- var updateUser = db.Updateable<SysUser>()
- .SetColumns(s => new SysUser
- {
- Fcode = sysUser.Fcode,
- Fname = sysUser.Fname
- })
- .Where(s => s.Sid == sysUser.Sid)
- .ExecuteCommand();
+ /* private bool InsertOrUpdateStaff(SqlSugarScope db, SysUser sysUser, MesStaff entity)
+ {
+ try
+ {
+ // 妫�鏌ョ敤鎴锋槸鍚﹀瓨鍦�
+ var userExists = db.Queryable<SysUser>().Any(u => u.Sid == sysUser.Sid);
+ if (userExists)
+ {
+ // 鏇存柊鐢ㄦ埛
+ var updateUser = db.Updateable<SysUser>()
+ .SetColumns(s => new SysUser
+ {
+ Fcode = sysUser.Fcode,
+ Fname = sysUser.Fname
+ })
+ .Where(s => s.Sid == sysUser.Sid)
+ .ExecuteCommand();
- if (updateUser > 0)
- {
- // 妫�鏌ュ憳宸ユ槸鍚﹀凡瀛樺湪
- var staffExists = db.Queryable<MesStaff>().Any(s => s.Id == entity.Id);
- if (staffExists)
- {
- // 鏇存柊鍛樺伐
- var updateStaff = db.Updateable(entity).Where(s => s.Id == entity.Id).ExecuteCommand();
- if (updateStaff > 0)
- return true;
- }
- else
- {
- // 鎻掑叆鍛樺伐
- var insertStaff = db.Insertable(entity).ExecuteCommand();
- if (insertStaff > 0)
- return true;
- }
- }
- }
- else
- {
- // 鎻掑叆鐢ㄦ埛
- var insertUser = db.Insertable(sysUser).ExecuteCommand();
- if (insertUser > 0)
- {
- // 鎻掑叆鍛樺伐
- var staffExists = db.Queryable<MesStaff>().Any(s => s.Id == entity.Id);
- if (!staffExists)
- {
- var insertStaff = db.Insertable(entity).ExecuteCommand();
- if (insertStaff > 0)
- return true;
- }
- else
- {
- // 濡傛灉鍛樺伐宸插瓨鍦紝鍙互閫夋嫨鏇存柊鎴栨姏鍑哄紓甯�
- throw new Exception("鍛樺伐璁板綍宸插瓨鍦紝鏃犳硶鎻掑叆閲嶅璁板綍銆�");
- }
- }
- }
- }
- catch (Exception ex)
- {
- // 璁板綍鏃ュ織鎴栧鐞嗗紓甯�
- Console.WriteLine($"Error: {ex.Message}");
- }
+ if (updateUser > 0)
+ {
+ // 妫�鏌ュ憳宸ユ槸鍚﹀凡瀛樺湪
+ var staffExists = db.Queryable<MesStaff>().Any(s => s.Id == entity.Id);
+ if (staffExists)
+ {
+ // 鏇存柊鍛樺伐
+ var updateStaff = db.Updateable(entity).Where(s => s.Id == entity.Id).ExecuteCommand();
+ if (updateStaff > 0)
+ return true;
+ }
+ else
+ {
+ // 鎻掑叆鍛樺伐
+ var insertStaff = db.Insertable(entity).ExecuteCommand();
+ if (insertStaff > 0)
+ return true;
+ }
+ }
+ }
+ else
+ {
+ // 鎻掑叆鐢ㄦ埛
+ var insertUser = db.Insertable(sysUser).ExecuteCommand();
+ if (insertUser > 0)
+ {
+ // 鎻掑叆鍛樺伐
+ var staffExists = db.Queryable<MesStaff>().Any(s => s.Id == entity.Id);
+ if (!staffExists)
+ {
+ var insertStaff = db.Insertable(entity).ExecuteCommand();
+ if (insertStaff > 0)
+ return true;
+ }
+ else
+ {
+ // 濡傛灉鍛樺伐宸插瓨鍦紝鍙互閫夋嫨鏇存柊鎴栨姏鍑哄紓甯�
+ throw new Exception("鍛樺伐璁板綍宸插瓨鍦紝鏃犳硶鎻掑叆閲嶅璁板綍銆�");
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ // 璁板綍鏃ュ織鎴栧鐞嗗紓甯�
+ Console.WriteLine($"Error: {ex.Message}");
+ }
- return false;
-}
-*/
+ return false;
+ }
+ */
// 鍒犻櫎鍛樺伐鐨勬柟娉�
private bool DeleteStaff(SqlSugarScope db, SysUser sysUser, decimal staffId)
@@ -229,8 +230,7 @@
Tet = 0,
Prd = 1,
Departmentid = staff.FPostDept,
- CreateDate = DateTime.Now //褰撳墠鏃堕棿
-
+ CreateDate = DateTime.Now //褰撳墠鏃堕棿
};
}
--
Gitblit v1.9.3