修复相关bug
This commit is contained in:
-7
@@ -202,10 +202,6 @@ public class OnboardingContractTemplateService : DbRepository<ObContractTemplate
|
|||||||
.ExecuteCommandAsync();
|
.ExecuteCommandAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
await Context.Deleteable<ObContractScope>()
|
|
||||||
.Where(it => input.Ids.Contains(it.TemplateId))
|
|
||||||
.ExecuteCommandAsync();
|
|
||||||
|
|
||||||
await Context.Deleteable<ObContractTemplatePosition>()
|
await Context.Deleteable<ObContractTemplatePosition>()
|
||||||
.Where(item => input.Ids.Contains(item.ContractTemplateId))
|
.Where(item => input.Ids.Contains(item.ContractTemplateId))
|
||||||
.ExecuteCommandAsync();
|
.ExecuteCommandAsync();
|
||||||
@@ -245,9 +241,6 @@ public class OnboardingContractTemplateService : DbRepository<ObContractTemplate
|
|||||||
await Context.Deleteable<ObTemplateVariable>()
|
await Context.Deleteable<ObTemplateVariable>()
|
||||||
.Where(it => it.TemplateVersionId == version.Id)
|
.Where(it => it.TemplateVersionId == version.Id)
|
||||||
.ExecuteCommandAsync();
|
.ExecuteCommandAsync();
|
||||||
await Context.Deleteable<ObContractScope>()
|
|
||||||
.Where(it => it.TemplateVersionId == version.Id)
|
|
||||||
.ExecuteCommandAsync();
|
|
||||||
await Context.Deleteable<ObContractTemplateVersion>()
|
await Context.Deleteable<ObContractTemplateVersion>()
|
||||||
.In(version.Id)
|
.In(version.Id)
|
||||||
.ExecuteCommandAsync();
|
.ExecuteCommandAsync();
|
||||||
|
|||||||
+10
-8
@@ -112,12 +112,11 @@ public class OnboardingEntryConfigService : IOnboardingEntryConfigService
|
|||||||
OnboardingPermissionCodes.EntryConfigManageAll,
|
OnboardingPermissionCodes.EntryConfigManageAll,
|
||||||
"入职字段");
|
"入职字段");
|
||||||
|
|
||||||
var isReferenced = await _db.Queryable<ObFormRequirement>()
|
|
||||||
|
var isReferencedByTask = await _db.Queryable<ObTaskFormRequirement>()
|
||||||
.AnyAsync(x => input.Ids.Contains(x.FieldId));
|
.AnyAsync(x => input.Ids.Contains(x.FieldId));
|
||||||
var isReferencedByTemplate = await _db.Queryable<ObOnboardingTemplateFormField>()
|
if (isReferencedByTask)
|
||||||
.AnyAsync(x => input.Ids.Contains(x.FieldId));
|
throw Oops.Bah("字段已被入职任务引用,不能删除,可改为停用");
|
||||||
if (isReferenced || isReferencedByTemplate)
|
|
||||||
throw Oops.Bah("字段已被入职模板引用,不能删除");
|
|
||||||
|
|
||||||
await _db.Deleteable<ObFormField>().In(input.Ids).ExecuteCommandAsync();
|
await _db.Deleteable<ObFormField>().In(input.Ids).ExecuteCommandAsync();
|
||||||
}
|
}
|
||||||
@@ -196,13 +195,16 @@ public class OnboardingEntryConfigService : IOnboardingEntryConfigService
|
|||||||
OnboardingPermissionCodes.EntryConfigManageAll,
|
OnboardingPermissionCodes.EntryConfigManageAll,
|
||||||
"资料类型");
|
"资料类型");
|
||||||
|
|
||||||
var isReferenced = await _db.Queryable<ObMaterialRequirement>()
|
|
||||||
.AnyAsync(x => input.Ids.Contains(x.MaterialTypeId));
|
|
||||||
var isReferencedByTemplate = await _db.Queryable<ObOnboardingTemplateMaterial>()
|
var isReferencedByTemplate = await _db.Queryable<ObOnboardingTemplateMaterial>()
|
||||||
.AnyAsync(x => input.Ids.Contains(x.MaterialTypeId));
|
.AnyAsync(x => input.Ids.Contains(x.MaterialTypeId));
|
||||||
if (isReferenced || isReferencedByTemplate)
|
if (isReferencedByTemplate)
|
||||||
throw Oops.Bah("资料类型已被入职模板引用,不能删除");
|
throw Oops.Bah("资料类型已被入职模板引用,不能删除");
|
||||||
|
|
||||||
|
var isReferencedByTask = await _db.Queryable<ObTaskMaterialRequirement>()
|
||||||
|
.AnyAsync(x => input.Ids.Contains(x.MaterialTypeId));
|
||||||
|
if (isReferencedByTask)
|
||||||
|
throw Oops.Bah("资料类型已被入职任务引用,不能删除,可改为停用");
|
||||||
|
|
||||||
var hasUploads = await _db.Queryable<ObTaskMaterial>()
|
var hasUploads = await _db.Queryable<ObTaskMaterial>()
|
||||||
.AnyAsync(x => input.Ids.Contains(x.MaterialTypeId));
|
.AnyAsync(x => input.Ids.Contains(x.MaterialTypeId));
|
||||||
if (hasUploads)
|
if (hasUploads)
|
||||||
|
|||||||
+22
-1
@@ -117,6 +117,28 @@ public class OnboardingTaskLifecycleService : IOnboardingTaskLifecycleService
|
|||||||
.Select(x => x.Id)
|
.Select(x => x.Id)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
|
var signProcessIds = await _db.Queryable<ObElectronicSignProcess>()
|
||||||
|
.Where(x => x.TaskId == task.Id)
|
||||||
|
.Select(x => x.Id)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
if (signProcessIds.Count > 0)
|
||||||
|
{
|
||||||
|
await _db.Deleteable<ObElectronicSignEvent>()
|
||||||
|
.Where(x => x.SignProcessId.HasValue
|
||||||
|
&& signProcessIds.Contains(x.SignProcessId.Value))
|
||||||
|
.ExecuteCommandAsync();
|
||||||
|
await _db.Deleteable<ObElectronicSignDocument>()
|
||||||
|
.Where(x => signProcessIds.Contains(x.SignProcessId))
|
||||||
|
.ExecuteCommandAsync();
|
||||||
|
await _db.Deleteable<ObElectronicSignProcess>()
|
||||||
|
.Where(x => signProcessIds.Contains(x.Id))
|
||||||
|
.ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
await _db.Deleteable<ObEmployeeContractSnapshot>()
|
||||||
|
.Where(x => x.TaskId == task.Id)
|
||||||
|
.ExecuteCommandAsync();
|
||||||
if (taskContractIds.Count > 0)
|
if (taskContractIds.Count > 0)
|
||||||
{
|
{
|
||||||
await _db.Deleteable<ObTaskContractVariable>()
|
await _db.Deleteable<ObTaskContractVariable>()
|
||||||
@@ -130,7 +152,6 @@ public class OnboardingTaskLifecycleService : IOnboardingTaskLifecycleService
|
|||||||
await _db.Deleteable<ObTaskMaterial>().Where(x => x.TaskId == task.Id).ExecuteCommandAsync();
|
await _db.Deleteable<ObTaskMaterial>().Where(x => x.TaskId == task.Id).ExecuteCommandAsync();
|
||||||
await _db.Deleteable<ObTaskEmployeeInfo>().Where(x => x.TaskId == task.Id).ExecuteCommandAsync();
|
await _db.Deleteable<ObTaskEmployeeInfo>().Where(x => x.TaskId == task.Id).ExecuteCommandAsync();
|
||||||
await _db.Deleteable<ObTaskFormRequirement>().Where(x => x.TaskId == task.Id).ExecuteCommandAsync();
|
await _db.Deleteable<ObTaskFormRequirement>().Where(x => x.TaskId == task.Id).ExecuteCommandAsync();
|
||||||
await _db.Deleteable<ObTaskFormValue>().Where(x => x.TaskId == task.Id).ExecuteCommandAsync();
|
|
||||||
await _db.Deleteable<ObTaskOperationLog>().Where(x => x.TaskId == task.Id).ExecuteCommandAsync();
|
await _db.Deleteable<ObTaskOperationLog>().Where(x => x.TaskId == task.Id).ExecuteCommandAsync();
|
||||||
await _db.Deleteable<ObTaskAudit>().Where(x => x.TaskId == task.Id).ExecuteCommandAsync();
|
await _db.Deleteable<ObTaskAudit>().Where(x => x.TaskId == task.Id).ExecuteCommandAsync();
|
||||||
await _db.Deleteable<ObOnboardingTask>().In(task.Id).ExecuteCommandAsync();
|
await _db.Deleteable<ObOnboardingTask>().In(task.Id).ExecuteCommandAsync();
|
||||||
|
|||||||
+3
-1
@@ -126,7 +126,9 @@ public class OnboardingPublicSubmissionService : IOnboardingPublicSubmissionServ
|
|||||||
?? throw Oops.Bah("请先完整填写基本信息");
|
?? throw Oops.Bah("请先完整填写基本信息");
|
||||||
|
|
||||||
// 最终提交必须重新执行全量校验,不能只依赖员工手机端的页面校验。
|
// 最终提交必须重新执行全量校验,不能只依赖员工手机端的页面校验。
|
||||||
OnboardingEmployeeInfoValidator.ValidateAndNormalize(info);
|
var formRequirements =
|
||||||
|
await OnboardingEmployeeFieldRequirementSnapshot.GetForTask(_db, task.Id);
|
||||||
|
OnboardingEmployeeInfoValidator.ValidateAndNormalize(info, formRequirements);
|
||||||
EnsureIdentityInformationConfirmed(input, info);
|
EnsureIdentityInformationConfirmed(input, info);
|
||||||
await _db.Updateable(info).ExecuteCommandAsync();
|
await _db.Updateable(info).ExecuteCommandAsync();
|
||||||
|
|
||||||
|
|||||||
+68
@@ -0,0 +1,68 @@
|
|||||||
|
namespace SimpleAdmin.Application;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 生成并读取入职登记表内置员工字段的任务级必填快照。
|
||||||
|
/// </summary>
|
||||||
|
internal static class OnboardingEmployeeFieldRequirementSnapshot
|
||||||
|
{
|
||||||
|
private const string EmployeeVariablePrefix = "employee.";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据当前内置员工变量配置创建一份任务快照。
|
||||||
|
/// </summary>
|
||||||
|
public static async Task<List<ObTaskFormRequirement>> BuildFromCurrentDefinitions(
|
||||||
|
SqlSugarScope db,
|
||||||
|
long taskId)
|
||||||
|
{
|
||||||
|
var definitions = await db.Queryable<ObVariableDefinition>()
|
||||||
|
.Where(item => item.IsBuiltIn
|
||||||
|
&& item.VariableCategory == ContractVariableType.Employee)
|
||||||
|
.OrderBy(item => item.SortCode)
|
||||||
|
.OrderBy(item => item.Id)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
return definitions.Select(definition => new ObTaskFormRequirement
|
||||||
|
{
|
||||||
|
Id = global::SimpleAdmin.Core.Utils.CommonUtils.GetSingleId(),
|
||||||
|
TaskId = taskId,
|
||||||
|
FieldId = definition.Id,
|
||||||
|
FieldCode = definition.VariableCode,
|
||||||
|
FieldName = definition.VariableName,
|
||||||
|
DataType = definition.DataType,
|
||||||
|
Required = definition.Required,
|
||||||
|
SortCode = definition.SortCode
|
||||||
|
}).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 读取任务冻结配置;历史任务没有员工字段快照时使用当前配置兼容。
|
||||||
|
/// </summary>
|
||||||
|
public static async Task<List<ObTaskFormRequirement>> GetForTask(
|
||||||
|
SqlSugarScope db,
|
||||||
|
long taskId)
|
||||||
|
{
|
||||||
|
var snapshots = await db.Queryable<ObTaskFormRequirement>()
|
||||||
|
.Where(item => item.TaskId == taskId)
|
||||||
|
.OrderBy(item => item.SortCode)
|
||||||
|
.ToListAsync();
|
||||||
|
if (snapshots.Any(IsEmployeeField))
|
||||||
|
return snapshots;
|
||||||
|
|
||||||
|
var compatibilitySnapshots = await BuildFromCurrentDefinitions(db, taskId);
|
||||||
|
if (snapshots.Count == 0)
|
||||||
|
return compatibilitySnapshots;
|
||||||
|
|
||||||
|
snapshots.AddRange(compatibilitySnapshots);
|
||||||
|
return snapshots.OrderBy(item => item.SortCode).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 判断快照是否对应入职登记表内置员工字段。
|
||||||
|
/// </summary>
|
||||||
|
public static bool IsEmployeeField(ObTaskFormRequirement requirement)
|
||||||
|
{
|
||||||
|
return requirement?.FieldCode?.StartsWith(
|
||||||
|
EmployeeVariablePrefix,
|
||||||
|
StringComparison.OrdinalIgnoreCase) == true;
|
||||||
|
}
|
||||||
|
}
|
||||||
+54
-10
@@ -16,9 +16,11 @@ internal static class OnboardingEmployeeInfoValidator
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 规范化文本,并校验固定登记表字段的格式。
|
/// 规范化文本,并按照任务冻结配置校验固定登记表必填项及字段格式。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void ValidateAndNormalize(ObTaskEmployeeInfo input)
|
public static void ValidateAndNormalize(
|
||||||
|
ObTaskEmployeeInfo input,
|
||||||
|
IReadOnlyCollection<ObTaskFormRequirement> fieldRequirements = null)
|
||||||
{
|
{
|
||||||
input.EmployeeName = input.EmployeeName?.Trim();
|
input.EmployeeName = input.EmployeeName?.Trim();
|
||||||
input.Phone = input.Phone?.Trim();
|
input.Phone = input.Phone?.Trim();
|
||||||
@@ -26,20 +28,27 @@ internal static class OnboardingEmployeeInfoValidator
|
|||||||
input.IdCardNumber = input.IdCardNumber?.Trim().ToUpperInvariant();
|
input.IdCardNumber = input.IdCardNumber?.Trim().ToUpperInvariant();
|
||||||
input.BankCardNumber = global::System.Text.RegularExpressions.Regex.Replace(
|
input.BankCardNumber = global::System.Text.RegularExpressions.Regex.Replace(
|
||||||
input.BankCardNumber ?? string.Empty,
|
input.BankCardNumber ?? string.Empty,
|
||||||
"[\\s-]",
|
@"[\s-]",
|
||||||
string.Empty);
|
string.Empty);
|
||||||
input.BankName = input.BankName?.Trim();
|
input.BankName = input.BankName?.Trim();
|
||||||
input.BankAccountName = input.EmployeeName;
|
input.BankAccountName = input.EmployeeName;
|
||||||
|
|
||||||
|
ValidateRequiredFields(input, fieldRequirements);
|
||||||
|
|
||||||
|
// 电子签约实名认证始终依赖以下三项,不能通过后台配置关闭。
|
||||||
if (string.IsNullOrWhiteSpace(input.EmployeeName) || input.EmployeeName.Length > 100)
|
if (string.IsNullOrWhiteSpace(input.EmployeeName) || input.EmployeeName.Length > 100)
|
||||||
throw Oops.Bah("员工姓名不能为空且不能超过 100 个字符");
|
throw Oops.Bah("员工姓名不能为空且不能超过 100 个字符");
|
||||||
|
|
||||||
if (input.Gender != "男" && input.Gender != "女")
|
if (!string.IsNullOrWhiteSpace(input.Gender)
|
||||||
|
&& input.Gender != "男"
|
||||||
|
&& input.Gender != "女")
|
||||||
|
{
|
||||||
throw Oops.Bah("请选择正确的性别");
|
throw Oops.Bah("请选择正确的性别");
|
||||||
|
}
|
||||||
|
|
||||||
if (!global::System.Text.RegularExpressions.Regex.IsMatch(
|
if (!global::System.Text.RegularExpressions.Regex.IsMatch(
|
||||||
input.Phone ?? string.Empty,
|
input.Phone ?? string.Empty,
|
||||||
"^1[3-9]\\d{9}$"))
|
@"^1[3-9]\d{9}$"))
|
||||||
{
|
{
|
||||||
throw Oops.Bah("请输入正确的 11 位手机号码");
|
throw Oops.Bah("请输入正确的 11 位手机号码");
|
||||||
}
|
}
|
||||||
@@ -51,10 +60,11 @@ internal static class OnboardingEmployeeInfoValidator
|
|||||||
ValidateOptionalEmail(input.Email);
|
ValidateOptionalEmail(input.Email);
|
||||||
ValidateOptionalNumber(input.Height, "身高", 100M, 250M, "厘米");
|
ValidateOptionalNumber(input.Height, "身高", 100M, 250M, "厘米");
|
||||||
ValidateOptionalNumber(input.Weight, "体重", 30M, 300M, "公斤");
|
ValidateOptionalNumber(input.Weight, "体重", 30M, 300M, "公斤");
|
||||||
ValidateBankCard(input.BankCardNumber);
|
if (!string.IsNullOrWhiteSpace(input.BankCardNumber))
|
||||||
|
ValidateBankCard(input.BankCardNumber);
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(input.BankName) || input.BankName.Length > 100)
|
if (!string.IsNullOrWhiteSpace(input.BankName) && input.BankName.Length > 100)
|
||||||
throw Oops.Bah("开户银行名称不能为空且不能超过 100 个字符");
|
throw Oops.Bah("开户银行名称不能超过 100 个字符");
|
||||||
|
|
||||||
ValidateOptionalContactPhone(input.EmergencyPhone);
|
ValidateOptionalContactPhone(input.EmergencyPhone);
|
||||||
ValidateEducationHistory(input.EducationHistoryJson);
|
ValidateEducationHistory(input.EducationHistoryJson);
|
||||||
@@ -63,6 +73,40 @@ internal static class OnboardingEmployeeInfoValidator
|
|||||||
ValidateJson(input.CustomVariablesJson, global::System.Text.Json.JsonValueKind.Object, "员工补充变量");
|
ValidateJson(input.CustomVariablesJson, global::System.Text.Json.JsonValueKind.Object, "员工补充变量");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 按任务快照校验后台配置为必填的内置员工字段。
|
||||||
|
/// </summary>
|
||||||
|
private static void ValidateRequiredFields(
|
||||||
|
ObTaskEmployeeInfo input,
|
||||||
|
IReadOnlyCollection<ObTaskFormRequirement> fieldRequirements)
|
||||||
|
{
|
||||||
|
if (fieldRequirements == null || fieldRequirements.Count == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
foreach (var requirement in fieldRequirements.Where(item =>
|
||||||
|
item.Required
|
||||||
|
&& OnboardingEmployeeFieldRequirementSnapshot.IsEmployeeField(item)))
|
||||||
|
{
|
||||||
|
var separatorIndex = requirement.FieldCode.LastIndexOf('.');
|
||||||
|
var propertyName = separatorIndex >= 0
|
||||||
|
? requirement.FieldCode[(separatorIndex + 1)..]
|
||||||
|
: requirement.FieldCode;
|
||||||
|
var property = typeof(ObTaskEmployeeInfo).GetProperty(
|
||||||
|
propertyName,
|
||||||
|
global::System.Reflection.BindingFlags.Instance
|
||||||
|
| global::System.Reflection.BindingFlags.Public
|
||||||
|
| global::System.Reflection.BindingFlags.IgnoreCase);
|
||||||
|
if (property == null)
|
||||||
|
{
|
||||||
|
throw Oops.Bah(
|
||||||
|
$"内置员工变量“{requirement.FieldCode}”没有对应的入职登记表字段,请联系管理员");
|
||||||
|
}
|
||||||
|
|
||||||
|
var value = property.GetValue(input)?.ToString();
|
||||||
|
if (string.IsNullOrWhiteSpace(value))
|
||||||
|
throw Oops.Bah($"请填写入职登记表“{requirement.FieldName}”");
|
||||||
|
}
|
||||||
|
}
|
||||||
private static bool TryValidateIdCard(
|
private static bool TryValidateIdCard(
|
||||||
string idCardNumber,
|
string idCardNumber,
|
||||||
out DateTime birthday,
|
out DateTime birthday,
|
||||||
@@ -106,7 +150,7 @@ internal static class OnboardingEmployeeInfoValidator
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ValidateBirthday(string birthdayText, DateTime idCardBirthday)
|
private static void ValidateBirthday(string birthdayText, DateTime? idCardBirthday)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(birthdayText))
|
if (string.IsNullOrWhiteSpace(birthdayText))
|
||||||
return;
|
return;
|
||||||
@@ -120,7 +164,7 @@ internal static class OnboardingEmployeeInfoValidator
|
|||||||
if (!birthdayIsValid || birthday.Date > DateTime.Today)
|
if (!birthdayIsValid || birthday.Date > DateTime.Today)
|
||||||
throw Oops.Bah("请输入正确的出生日期");
|
throw Oops.Bah("请输入正确的出生日期");
|
||||||
|
|
||||||
if (birthday.Date != idCardBirthday.Date)
|
if (idCardBirthday.HasValue && birthday.Date != idCardBirthday.Value.Date)
|
||||||
throw Oops.Bah("出生日期与身份证号码不一致");
|
throw Oops.Bah("出生日期与身份证号码不一致");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+16
-2
@@ -40,6 +40,8 @@ public class OnboardingPublicTaskService : IOnboardingPublicTaskService
|
|||||||
.Where(item => item.TaskId == task.Id)
|
.Where(item => item.TaskId == task.Id)
|
||||||
.OrderBy(item => item.SortCode)
|
.OrderBy(item => item.SortCode)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
var formRequirements =
|
||||||
|
await OnboardingEmployeeFieldRequirementSnapshot.GetForTask(_db, task.Id);
|
||||||
|
|
||||||
var contracts = await _db.Queryable<ObTaskContract>()
|
var contracts = await _db.Queryable<ObTaskContract>()
|
||||||
.Where(item => item.TaskId == task.Id)
|
.Where(item => item.TaskId == task.Id)
|
||||||
@@ -106,7 +108,17 @@ public class OnboardingPublicTaskService : IOnboardingPublicTaskService
|
|||||||
Contracts = contracts,
|
Contracts = contracts,
|
||||||
DynamicValues = new List<ObTaskFormValue>(),
|
DynamicValues = new List<ObTaskFormValue>(),
|
||||||
Materials = materialOutputs,
|
Materials = materialOutputs,
|
||||||
FormFields = new List<OnboardingPublicFormFieldOutput>(),
|
FormFields = formRequirements
|
||||||
|
.Where(OnboardingEmployeeFieldRequirementSnapshot.IsEmployeeField)
|
||||||
|
.Select(requirement => new OnboardingPublicFormFieldOutput
|
||||||
|
{
|
||||||
|
FieldId = requirement.FieldId,
|
||||||
|
FieldCode = requirement.FieldCode,
|
||||||
|
FieldName = requirement.FieldName,
|
||||||
|
DataType = requirement.DataType,
|
||||||
|
OptionsJson = requirement.OptionsJson,
|
||||||
|
Required = requirement.Required
|
||||||
|
}).ToList(),
|
||||||
MaterialRequirements = materialRequirements.Select(requirement => new OnboardingPublicMaterialOutput
|
MaterialRequirements = materialRequirements.Select(requirement => new OnboardingPublicMaterialOutput
|
||||||
{
|
{
|
||||||
MaterialTypeId = requirement.MaterialTypeId,
|
MaterialTypeId = requirement.MaterialTypeId,
|
||||||
@@ -134,7 +146,9 @@ public class OnboardingPublicTaskService : IOnboardingPublicTaskService
|
|||||||
throw Oops.Bah("当前任务不可编辑");
|
throw Oops.Bah("当前任务不可编辑");
|
||||||
}
|
}
|
||||||
|
|
||||||
OnboardingEmployeeInfoValidator.ValidateAndNormalize(input);
|
var formRequirements =
|
||||||
|
await OnboardingEmployeeFieldRequirementSnapshot.GetForTask(_db, task.Id);
|
||||||
|
OnboardingEmployeeInfoValidator.ValidateAndNormalize(input, formRequirements);
|
||||||
await _identityValidationService.EnsureNoDuplicate(
|
await _identityValidationService.EnsureNoDuplicate(
|
||||||
task.Id,
|
task.Id,
|
||||||
input.EmployeeName,
|
input.EmployeeName,
|
||||||
|
|||||||
@@ -161,6 +161,11 @@ public class OnboardingTaskService : IOnboardingTaskService
|
|||||||
CreateTime = DateTime.Now
|
CreateTime = DateTime.Now
|
||||||
}).ExecuteCommandAsync();
|
}).ExecuteCommandAsync();
|
||||||
|
|
||||||
|
var employeeFieldRequirements =
|
||||||
|
await OnboardingEmployeeFieldRequirementSnapshot.BuildFromCurrentDefinitions(_db, taskId);
|
||||||
|
if (employeeFieldRequirements.Count > 0)
|
||||||
|
await _db.Insertable(employeeFieldRequirements).ExecuteCommandAsync();
|
||||||
|
|
||||||
var contracts = contractConfigs.Select(config =>
|
var contracts = contractConfigs.Select(config =>
|
||||||
{
|
{
|
||||||
var template = contractTemplates.First(item => item.Id == config.ContractTemplateId);
|
var template = contractTemplates.First(item => item.Id == config.ContractTemplateId);
|
||||||
@@ -295,6 +300,10 @@ public class OnboardingTaskService : IOnboardingTaskService
|
|||||||
.Where(item => item.TaskId == sourceTask.Id)
|
.Where(item => item.TaskId == sourceTask.Id)
|
||||||
.OrderBy(item => item.SortCode)
|
.OrderBy(item => item.SortCode)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
var sourceEmployeeFieldRequirements =
|
||||||
|
(await OnboardingEmployeeFieldRequirementSnapshot.GetForTask(_db, sourceTask.Id))
|
||||||
|
.Where(OnboardingEmployeeFieldRequirementSnapshot.IsEmployeeField)
|
||||||
|
.ToList();
|
||||||
var sourceContractIds = sourceContracts.Select(item => item.Id).ToList();
|
var sourceContractIds = sourceContracts.Select(item => item.Id).ToList();
|
||||||
var sourceManualVariables = await _db.Queryable<ObTaskContractVariable>()
|
var sourceManualVariables = await _db.Queryable<ObTaskContractVariable>()
|
||||||
.Where(item => sourceContractIds.Contains(item.TaskContractId)
|
.Where(item => sourceContractIds.Contains(item.TaskContractId)
|
||||||
@@ -334,6 +343,7 @@ public class OnboardingTaskService : IOnboardingTaskService
|
|||||||
sourceTask,
|
sourceTask,
|
||||||
sourceContracts,
|
sourceContracts,
|
||||||
sourceMaterialRequirements,
|
sourceMaterialRequirements,
|
||||||
|
sourceEmployeeFieldRequirements,
|
||||||
initialContractVariables,
|
initialContractVariables,
|
||||||
expiryHours,
|
expiryHours,
|
||||||
item.Remark.Trim());
|
item.Remark.Trim());
|
||||||
@@ -361,6 +371,7 @@ public class OnboardingTaskService : IOnboardingTaskService
|
|||||||
ObOnboardingTask sourceTask,
|
ObOnboardingTask sourceTask,
|
||||||
List<ObTaskContract> sourceContracts,
|
List<ObTaskContract> sourceContracts,
|
||||||
List<ObTaskMaterialRequirement> sourceMaterialRequirements,
|
List<ObTaskMaterialRequirement> sourceMaterialRequirements,
|
||||||
|
List<ObTaskFormRequirement> sourceEmployeeFieldRequirements,
|
||||||
List<OnboardingInitialContractVariableInput> initialContractVariables,
|
List<OnboardingInitialContractVariableInput> initialContractVariables,
|
||||||
int expiryHours,
|
int expiryHours,
|
||||||
string remark)
|
string remark)
|
||||||
@@ -405,6 +416,24 @@ public class OnboardingTaskService : IOnboardingTaskService
|
|||||||
CreateTime = now
|
CreateTime = now
|
||||||
}).ExecuteCommandAsync();
|
}).ExecuteCommandAsync();
|
||||||
|
|
||||||
|
if (sourceEmployeeFieldRequirements.Count > 0)
|
||||||
|
{
|
||||||
|
var copiedEmployeeFieldRequirements = sourceEmployeeFieldRequirements.Select(source =>
|
||||||
|
new ObTaskFormRequirement
|
||||||
|
{
|
||||||
|
Id = global::SimpleAdmin.Core.Utils.CommonUtils.GetSingleId(),
|
||||||
|
TaskId = taskId,
|
||||||
|
FieldId = source.FieldId,
|
||||||
|
FieldCode = source.FieldCode,
|
||||||
|
FieldName = source.FieldName,
|
||||||
|
DataType = source.DataType,
|
||||||
|
OptionsJson = source.OptionsJson,
|
||||||
|
Required = source.Required,
|
||||||
|
SortCode = source.SortCode
|
||||||
|
}).ToList();
|
||||||
|
await _db.Insertable(copiedEmployeeFieldRequirements).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
|
||||||
var copiedContracts = sourceContracts.Select(source => new ObTaskContract
|
var copiedContracts = sourceContracts.Select(source => new ObTaskContract
|
||||||
{
|
{
|
||||||
Id = global::SimpleAdmin.Core.Utils.CommonUtils.GetSingleId(),
|
Id = global::SimpleAdmin.Core.Utils.CommonUtils.GetSingleId(),
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
-- 入职登记表内置员工字段必填规则的任务快照表。
|
||||||
|
-- 可在本地、测试和正式环境重复执行。
|
||||||
|
|
||||||
|
SET NAMES utf8mb4;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `ob_task_form_requirement` (
|
||||||
|
`Id` BIGINT NOT NULL COMMENT '主键',
|
||||||
|
`TaskId` BIGINT NOT NULL COMMENT '入职任务Id',
|
||||||
|
`FieldId` BIGINT NOT NULL COMMENT '原字段或变量定义Id',
|
||||||
|
`FieldCode` VARCHAR(100) NOT NULL COMMENT '冻结字段编码',
|
||||||
|
`FieldName` VARCHAR(200) NOT NULL COMMENT '冻结字段名称',
|
||||||
|
`DataType` VARCHAR(50) NOT NULL COMMENT '冻结数据类型',
|
||||||
|
`OptionsJson` JSON NULL COMMENT '冻结选项JSON',
|
||||||
|
`Required` TINYINT(1) NOT NULL DEFAULT 1 COMMENT '是否必填',
|
||||||
|
`SortCode` INT NULL COMMENT '显示顺序',
|
||||||
|
`Status` VARCHAR(20) NULL DEFAULT 'enable' COMMENT '状态',
|
||||||
|
`CreateTime` DATETIME(3) NULL COMMENT '创建时间',
|
||||||
|
`UpdateTime` DATETIME(3) NULL COMMENT '更新时间',
|
||||||
|
`CreateUserId` BIGINT NULL COMMENT '创建者Id',
|
||||||
|
`UpdateUserId` BIGINT NULL COMMENT '修改者Id',
|
||||||
|
`CreateUser` VARCHAR(200) NULL COMMENT '创建人',
|
||||||
|
`UpdateUser` VARCHAR(200) NULL COMMENT '更新人',
|
||||||
|
`IsDelete` TINYINT(1) NULL DEFAULT 0 COMMENT '软删除',
|
||||||
|
`ExtJson` LONGTEXT NULL COMMENT '扩展信息',
|
||||||
|
PRIMARY KEY (`Id`),
|
||||||
|
UNIQUE KEY `uk_ob_task_form_requirement` (`TaskId`, `FieldId`),
|
||||||
|
KEY `idx_ob_task_form_requirement_task_sort` (`TaskId`, `SortCode`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='任务入职登记字段必填快照';
|
||||||
Reference in New Issue
Block a user