啊鑫
2024-10-30 c02ff3f682398f022488f98b87a79d4a8e04b5dd
MES.Service/service/BasicData/MesStaffManager.cs
@@ -27,7 +27,6 @@
                    break;
                case "2":
                case "4":
                    DeleteStaff(db, sysUser, entity.Id);
                    if (InsertOrUpdateStaff(db, sysUser, entity)) // 插入或更新员工
                        return 1;
                    break;
@@ -62,6 +61,12 @@
    private bool InsertOrUpdateStaff(SqlSugarScope db, SysUser sysUser,
        MesStaff entity)
    {
        db.Deleteable<SysUser>()
            .Where(s => s.Account == sysUser.Account).ExecuteCommand();
        db.Deleteable<MesStaff>()
            .Where(s => s.Id == entity.Id).ExecuteCommand();
        var insertUser = db.Insertable(sysUser).ExecuteCommand();
        if (insertUser <= 0) return false;
        var insertStaff = db.Insertable(entity).ExecuteCommand();
@@ -200,7 +205,6 @@
    private bool InsertStaffBatch(SqlSugarScope db, List<SysUser> userList,
        List<MesStaff> staffList)
    {
        var userInsert = userList.FindAll(s => s.Type == "2");
        var executeCommand = db.Insertable(userInsert).ExecuteCommand();
        if (executeCommand <= 0) throw new ArgumentNullException("审核失败");
@@ -232,12 +236,6 @@
    private bool InsertOrUpdateBatch(SqlSugarScope db, List<SysUser> userList,
        List<MesStaff> staffList)
    {
        foreach (var sysUser in userList)
        {
            var entity = staffList.First(s => s.StaffNo == sysUser.Account);
            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();
    }
}