This commit is contained in:
fuenmao
2026-08-28 17:33:30 +08:00
parent 58804be611
commit f5b40e5659
10 changed files with 537 additions and 5 deletions
@@ -44,6 +44,8 @@ public class OnboardingAuditService : IOnboardingAuditService
throw Oops.Bah("该身份证号或手机号已存在正式员工");
}
var contractStartDate = await ResolveContractStartDate(task.Id);
var employee = employeeInfo.Adapt<ObEmployee>();
employee.Id = global::SimpleAdmin.Core.Utils.CommonUtils.GetSingleId();
employee.CompanyId = task.CompanyId;
@@ -61,7 +63,8 @@ public class OnboardingAuditService : IOnboardingAuditService
employee.College = employeeInfo.GraduatedSchool;
employee.BirthDate = ParseDate(employeeInfo.Birthday);
employee.ContactAddress = employeeInfo.CurrentAddress;
employee.EntryDate = ParseDate(employeeInfo.OnboardingDate);
employee.EntryDate = contractStartDate;
employee.ContractStartDate = contractStartDate;
employee.Remark = employeeInfo.OtherRemarks;
employee.ExtraInfoJson = global::System.Text.Json.JsonSerializer.Serialize(employeeInfo);
employee.Status = CommonStatusConst.ENABLE;
@@ -170,6 +173,48 @@ public class OnboardingAuditService : IOnboardingAuditService
return task;
}
/// <summary>
/// 从任务签署材料参数中读取唯一的合同开始日期,作为正式员工入职日期。
/// </summary>
private async Task<DateTime> ResolveContractStartDate(long taskId)
{
var taskContractIds = await _db.Queryable<ObTaskContract>()
.Where(item => item.TaskId == taskId)
.Select(item => item.Id)
.ToListAsync();
if (taskContractIds.Count == 0)
throw Oops.Bah("入职任务没有签署材料,无法确定入职日期");
var startDateValues = await _db.Queryable<ObTaskContractVariable>()
.Where(item => taskContractIds.Contains(item.TaskContractId)
&& item.VariableCode == "hr.ContractStartDate")
.Select(item => item.VariableValue)
.ToListAsync();
var normalizedValues = startDateValues
.Where(item => !string.IsNullOrWhiteSpace(item))
.Select(item => item.Trim())
.Distinct(StringComparer.OrdinalIgnoreCase)
.ToList();
if (normalizedValues.Count == 0)
throw Oops.Bah("签署材料参数“合同开始日期”尚未填写,无法生成正式员工档案");
var parsedDates = new List<DateTime>();
foreach (var value in normalizedValues)
{
if (!DateTime.TryParse(value, out var parsedDate))
throw Oops.Bah("签署材料参数“合同开始日期”格式不正确");
parsedDates.Add(parsedDate.Date);
}
var distinctDates = parsedDates.Distinct().ToList();
if (distinctDates.Count > 1)
throw Oops.Bah("多个签署材料的合同开始日期不一致,请统一后再审核通过");
return distinctDates[0];
}
/// <summary>
/// 将登记表中的日期文本转换为正式员工档案日期。
/// </summary>