修改相关问题
This commit is contained in:
@@ -58,6 +58,22 @@ public class OnboardingAuditService : IOnboardingAuditService
|
|||||||
var contractStartDate = await ResolveContractStartDate(task.Id);
|
var contractStartDate = await ResolveContractStartDate(task.Id);
|
||||||
|
|
||||||
var employee = employeeInfo.Adapt<ObEmployee>();
|
var employee = employeeInfo.Adapt<ObEmployee>();
|
||||||
|
if (string.IsNullOrWhiteSpace(employee.EmployeeNo))
|
||||||
|
{
|
||||||
|
var taskContractIds = await _db.Queryable<ObTaskContract>()
|
||||||
|
.Where(item => item.TaskId == task.Id)
|
||||||
|
.Select(item => item.Id)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
if (taskContractIds.Count > 0)
|
||||||
|
{
|
||||||
|
employee.EmployeeNo = await _db.Queryable<ObTaskContractVariable>()
|
||||||
|
.Where(item => taskContractIds.Contains(item.TaskContractId) && item.VariableCode == "hr.EmployeeNo" && item.VariableValue != null && item.VariableValue != "")
|
||||||
|
.OrderBy(item => item.SortCode)
|
||||||
|
.Select(item => item.VariableValue)
|
||||||
|
.FirstAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
employee.Id = global::SimpleAdmin.Core.Utils.CommonUtils.GetSingleId();
|
employee.Id = global::SimpleAdmin.Core.Utils.CommonUtils.GetSingleId();
|
||||||
employee.CompanyId = task.CompanyId;
|
employee.CompanyId = task.CompanyId;
|
||||||
employee.DepartmentId = task.DepartmentId;
|
employee.DepartmentId = task.DepartmentId;
|
||||||
|
|||||||
@@ -167,6 +167,40 @@ public class OnboardingEmployeeService : IOnboardingEmployeeService
|
|||||||
.OrderBy(item => item.CreateTime)
|
.OrderBy(item => item.CreateTime)
|
||||||
.OrderBy(item => item.Id)
|
.OrderBy(item => item.Id)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(employee.EmployeeNo))
|
||||||
|
{
|
||||||
|
var snapshotEmployeeNo = contractSnapshots
|
||||||
|
.Select(item => item.EmployeeNo)
|
||||||
|
.FirstOrDefault(val => !string.IsNullOrWhiteSpace(val));
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(snapshotEmployeeNo))
|
||||||
|
{
|
||||||
|
snapshotEmployeeNo = contractSnapshots
|
||||||
|
.Select(item => ExtractEmployeeNoFromVariables(item.VariablesJson))
|
||||||
|
.FirstOrDefault(val => !string.IsNullOrWhiteSpace(val));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(snapshotEmployeeNo) && contracts.Count > 0)
|
||||||
|
{
|
||||||
|
var contractIds = contracts.Select(c => c.Id).ToList();
|
||||||
|
snapshotEmployeeNo = await _db.Queryable<ObTaskContractVariable>()
|
||||||
|
.Where(item => contractIds.Contains(item.TaskContractId) && item.VariableCode == "hr.EmployeeNo" && item.VariableValue != null && item.VariableValue != "")
|
||||||
|
.OrderBy(item => item.SortCode)
|
||||||
|
.Select(item => item.VariableValue)
|
||||||
|
.FirstAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(snapshotEmployeeNo))
|
||||||
|
{
|
||||||
|
employee.EmployeeNo = snapshotEmployeeNo;
|
||||||
|
await _db.Updateable<ObEmployee>()
|
||||||
|
.SetColumns(item => new ObEmployee { EmployeeNo = snapshotEmployeeNo })
|
||||||
|
.Where(item => item.Id == employee.Id && (item.EmployeeNo == null || item.EmployeeNo == ""))
|
||||||
|
.ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var materials = await GetEmployeeMaterials(task?.Id);
|
var materials = await GetEmployeeMaterials(task?.Id);
|
||||||
var electronicSignProcess = task == null
|
var electronicSignProcess = task == null
|
||||||
? null
|
? null
|
||||||
@@ -858,7 +892,9 @@ public class OnboardingEmployeeService : IOnboardingEmployeeService
|
|||||||
if (value != null)
|
if (value != null)
|
||||||
cell.Value = value;
|
cell.Value = value;
|
||||||
|
|
||||||
var templateNumberFormat = worksheet.Cells[1, templateColumn.Index]
|
// 表头可能因复制粘贴带有日期等显示格式;数据格式应读取模板数据行,
|
||||||
|
// 未配置时再使用字段类型定义的默认格式,避免薪资数值显示成日期。
|
||||||
|
var templateNumberFormat = worksheet.Cells[2, templateColumn.Index]
|
||||||
.Style.Numberformat.Format;
|
.Style.Numberformat.Format;
|
||||||
cell.Style.Numberformat.Format = string.IsNullOrWhiteSpace(templateNumberFormat)
|
cell.Style.Numberformat.Format = string.IsNullOrWhiteSpace(templateNumberFormat)
|
||||||
|| string.Equals(
|
|| string.Equals(
|
||||||
@@ -1113,6 +1149,43 @@ public class OnboardingEmployeeService : IOnboardingEmployeeService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string ExtractEmployeeNoFromVariables(string variablesJson)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(variablesJson))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var doc = global::System.Text.Json.JsonDocument.Parse(variablesJson);
|
||||||
|
var root = doc.RootElement;
|
||||||
|
if (root.ValueKind == global::System.Text.Json.JsonValueKind.Object)
|
||||||
|
{
|
||||||
|
foreach (var prop in root.EnumerateObject())
|
||||||
|
{
|
||||||
|
if (string.Equals(prop.Name, "hr.EmployeeNo", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
if (prop.Value.ValueKind == global::System.Text.Json.JsonValueKind.Object
|
||||||
|
&& prop.Value.TryGetProperty("variableValue", out var valProp)
|
||||||
|
&& valProp.ValueKind == global::System.Text.Json.JsonValueKind.String)
|
||||||
|
{
|
||||||
|
return valProp.GetString();
|
||||||
|
}
|
||||||
|
if (prop.Value.ValueKind == global::System.Text.Json.JsonValueKind.String)
|
||||||
|
{
|
||||||
|
return prop.Value.GetString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// 忽略异常 JSON
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private static DateTime? ParseDate(string value)
|
private static DateTime? ParseDate(string value)
|
||||||
{
|
{
|
||||||
return DateTime.TryParse(value, out var date) ? date.Date : null;
|
return DateTime.TryParse(value, out var date) ? date.Date : null;
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user