sjz
3 天以前 5de35354e8dfcb4933350d0d1b645d400bcf23ab
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)
        {