From baa7d3abea49a36b1ca83d29343e720647ee2b8b Mon Sep 17 00:00:00 2001
From: 南骏 池 <chiffly@163.com>
Date: 星期一, 05 五月 2025 10:29:55 +0800
Subject: [PATCH] 1.生产订单新增同步时间。 2.采购订单新增同步时间。 3.员工新增账号逻辑优化。 4.基础信息+业务单据增加route储存单号。
---
MES.Service/service/BasicData/MesStaffManager.cs | 130 ++++++++++++++++---------------------------
1 files changed, 49 insertions(+), 81 deletions(-)
diff --git a/MES.Service/service/BasicData/MesStaffManager.cs b/MES.Service/service/BasicData/MesStaffManager.cs
index 42269b8..8921d64 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;
@@ -62,47 +61,37 @@
private bool InsertOrUpdateStaff(SqlSugarScope db, SysUser sysUser,
MesStaff entity)
{
- var exists = db.Queryable<SysUser>().Any(u => u.Sid == sysUser.Sid);
- if (exists)
- {
- var updateUser = db.Updateable<SysUser>()
- .SetColumns(s => s.Fcode == sysUser.Fcode)
- .SetColumns(s => s.Fname == sysUser.Fname)
- .Where(s => s.Sid == sysUser.Sid)
- .ExecuteCommand();
- if (updateUser > 0)
- {
- var updateStaff = db.Updateable(entity).ExecuteCommand();
- if (updateStaff > 0)
- return true;
- }
- }
- else
+
+ var exists = db.Queryable<SysUser>().Any(u => u.Account == sysUser.Account);
+ if (!exists)
{
var insertUser = db.Insertable(sysUser).ExecuteCommand();
- if (insertUser > 0)
- {
- var insertStaff = db.Insertable(entity).ExecuteCommand();
- if (insertStaff > 0)
- return true;
- }
+ if (insertUser <= 0) return false;
}
- return false;
+ //db.Deleteable<SysUser>()
+ // .Where(s => s.Account == sysUser.Account).ExecuteCommand();
+
+ db.Deleteable<MesStaff>()
+ .Where(s => s.Id == entity.Id).ExecuteCommand();
+
+
+
+ var insertStaff = db.Insertable(entity).ExecuteCommand();
+ return insertStaff > 0;
}
// 鍒犻櫎鍛樺伐鐨勬柟娉�
private bool DeleteStaff(SqlSugarScope db, SysUser sysUser, decimal staffId)
{
var deleteUser = db.Deleteable<SysUser>()
- .Where(s => s.Sid == sysUser.Sid).ExecuteCommand();
- if (deleteUser > 0)
- {
- var deleteStaff =
- db.Deleteable<MesStaff>().In(staffId).ExecuteCommand();
- if (deleteStaff > 0)
- return true;
- }
+ .Where(s => s.Account == sysUser.Account).ExecuteCommand();
+ if (deleteUser <= 0) throw new NotImplementedException("鍙嶅鏍稿け璐�");
+ var deleteStaff =
+ db.Deleteable<MesStaff>()
+ .Where(s => s.Id == staffId).ExecuteCommand();
+ if (deleteStaff > 0)
+ return true;
throw new NotImplementedException("鍙嶅鏍稿け璐�");
}
@@ -116,14 +105,15 @@
StaffNo = staff.FStaffNumber,
StaffName = staff.FName,
DepartmentName = staff.FPostDept,
- PositionName = staff.FPost,
+ PositionCode = staff.FPostId,
PhoneNumber = staff.FMobile,
Remark = staff.FDescription,
FforbidStatus = staff.FForbidStatus,
- FSubsidiary = staff.FUSEORGID,
- Fumbrella = staff.FCREATEORGID,
+ FSubsidiary = staff.FUseOrgId,
+ Fumbrella = staff.FCreateOrgId,
CreateDate = DateTime.Now,
- LastupdateDate = DateTime.Now
+ LastupdateDate = DateTime.Now,
+ Type = staff.Type
};
if (staff.FStaffStartDate != null)
@@ -138,26 +128,12 @@
{
return new SysUser
{
- Sid = Convert.ToDecimal(staff.Id),
- Fcode = staff.FStaffNumber,
- Fname = staff.FName,
- Fpassword = "8+()./,", // 鍒濆瀵嗙爜
- Fsystem = "瀹佹尝鍒╃壒鑸�",
- Lever = 0,
- Fcompany = "1000",
- Ffactory = "1000",
- DelFlag = 0,
- Ismanager = 0,
- Isacq = 0,
- ExpField9 = "1020",
- QmUser = 0,
- Status = 0,
- Isdeparture = 0,
- CheckFlag = 0,
- ExpFiel12 = 0,
- Dev = 0,
- Tet = 0,
- Prd = 1
+ Account = staff.FStaffNumber,
+ UserName = staff.FName,
+ Password = "E1ADC3949BA59ABBE56E057F2F883E", // 鍒濆瀵嗙爜
+ DepartNo = staff.FPostDept,
+ Type = staff.Type,
+ CreateTime = DateTime.Now
};
}
@@ -195,16 +171,12 @@
"B")) // 鎵归噺绂佺敤鍛樺伐
throw new NotImplementedException("绂佺敤澶辫触");
break;
- case "2":
- if (!InsertStaffBatch(db, userList,
- staffGroup.Value)) // 鎵归噺鎻掑叆鍛樺伐
- throw new NotImplementedException("鎻掑叆澶辫触");
- break;
case "3":
if (!DeleteStaffBatch(db, userList,
staffGroup.Value)) // 鎵归噺鍒犻櫎鍛樺伐
throw new NotImplementedException("鍒犻櫎澶辫触");
break;
+ case "2":
case "4":
if (!InsertOrUpdateBatch(db, userList,
staffGroup.Value)) // 鎵归噺鎻掑叆鎴栨洿鏂板憳宸�
@@ -238,11 +210,11 @@
private bool InsertStaffBatch(SqlSugarScope db, List<SysUser> userList,
List<MesStaff> staffList)
{
- var userInsert = userList.FindAll(s => s.Type == "INSERT");
+ var userInsert = userList.FindAll(s => s.Type == "2");
var executeCommand = db.Insertable(userInsert).ExecuteCommand();
- if (executeCommand > 0)
- if (db.Insertable(staffList).ExecuteCommand() > 0)
- return true;
+ if (executeCommand <= 0) throw new ArgumentNullException("瀹℃牳澶辫触");
+ if (db.Insertable(staffList).ExecuteCommand() > 0)
+ return true;
throw new ArgumentNullException("瀹℃牳澶辫触");
}
@@ -251,17 +223,16 @@
private bool DeleteStaffBatch(SqlSugarScope db, List<SysUser> userList,
List<MesStaff> staffList)
{
- var sid = userList.FindAll(s => s.Type == "DELETE").Select(s => s.Sid)
+ var sid = userList.FindAll(s => s.Type == "3").Select(s => s.Account)
.ToArray();
var result = db.Deleteable<SysUser>()
- .Where(s => sid.Contains(s.Sid)).ExecuteCommand();
+ .Where(s => sid.Contains(s.Account)).ExecuteCommand();
- if (result > 0)
- {
- var ids = staffList.Select(it => it.Id).ToArray();
- if (db.Deleteable<MesStaff>().In(ids).ExecuteCommand() > 0)
- return true;
- }
+ if (result <= 0) throw new ArgumentNullException("鍙嶅鏍稿け璐�");
+ var ids = staffList.Select(it => it.Id).ToArray();
+ if (db.Deleteable<MesStaff>()
+ .Where(s => ids.Contains(s.Id)).ExecuteCommand() > 0)
+ return true;
throw new ArgumentNullException("鍙嶅鏍稿け璐�");
}
@@ -270,12 +241,9 @@
private bool InsertOrUpdateBatch(SqlSugarScope db, List<SysUser> userList,
List<MesStaff> staffList)
{
- foreach (var sysUser in userList)
- {
- var entity = staffList.First(s => s.Id == sysUser.Sid);
- if (!InsertOrUpdateStaff(db, sysUser, entity)) return false;
- }
-
- return true;
+ return !(from sysUser in userList
+ let entity = staffList.First(s => s.StaffNo == sysUser.Account)
+ where !InsertOrUpdateStaff(db, sysUser, entity)
+ select sysUser).Any();
}
}
\ No newline at end of file
--
Gitblit v1.9.3