必选项规则设定 新人入职培训,新增参数控制自动匹配新入职人员

master
xiaochanghai 5 months ago
parent 4696badcf2
commit ab080e6cb3
  1. 30
      Tiobon.Core.Services/Ghre/Ghre_StudyRuleServices.cs
  2. 2
      Tiobon.Core.Services/ReportServices.cs

@ -343,7 +343,33 @@ public class Ghre_StudyRuleServices : BaseServices<Ghre_StudyRule, Ghre_StudyRul
var ruleStaffIds = ruleStaffs.Select(x => x.StaffId).ToList(); var ruleStaffIds = ruleStaffs.Select(x => x.StaffId).ToList();
#region 抓取新入职员工
var inStaffIds = new List<int>();
if (rule.TrainType == "NewStaff")
{
int month = 3;
var config = await Db.Queryable<Ghre_Config>().Where(x => x.ConfigCode == "New_Staff_Month").FirstAsync();
if (config != null)
{
try
{
month = Convert.ToInt32(config.ConfigValue);
}
catch (Exception)
{
}
var dateTime = DateTime.Now.AddMonths(-month);
inStaffIds = await Db.Queryable<Ghra_Staff>()
.Where(x => x.OutDate == null || (x.OutDate != null && x.Indate != null && x.Indate.Value.Date >= dateTime.Date && x.Indate.Value.Date <= DateTime.Now.Date))
.Select(x => x.StaffID).ToListAsync();
}
}
#endregion
var staffs = await Db.Queryable<Ghra_Staff>() var staffs = await Db.Queryable<Ghra_Staff>()
.WhereIF(inStaffIds.Any(), x => inStaffIds.Contains(x.StaffID))
.Where(x => x.OutDate == null || (x.OutDate != null && x.Indate != null && x.Indate.Value.Date <= DateTime.Now.Date && x.Indate.Value.Date >= DateTime.Now.Date)) .Where(x => x.OutDate == null || (x.OutDate != null && x.Indate != null && x.Indate.Value.Date <= DateTime.Now.Date && x.Indate.Value.Date >= DateTime.Now.Date))
.WhereIF(ZoneIds.Any(), x => ZoneIds.Contains(x.ZoneID)) .WhereIF(ZoneIds.Any(), x => ZoneIds.Contains(x.ZoneID))
.WhereIF(DeptIds.Any(), x => DeptIds.Contains(x.DeptID)) .WhereIF(DeptIds.Any(), x => DeptIds.Contains(x.DeptID))
@ -355,7 +381,7 @@ public class Ghre_StudyRuleServices : BaseServices<Ghre_StudyRule, Ghre_StudyRul
if (!staffs.IsNull()) if (!staffs.IsNull())
{ {
DateTime courseTime = Db.GetDate(); var courseTime = Db.GetDate();
var snap = await Db.Queryable<Ghre_CourseSnap>().FirstAsync(x => x.CourseId == rule.CourseId); var snap = await Db.Queryable<Ghre_CourseSnap>().FirstAsync(x => x.CourseId == rule.CourseId);
if (staffs.Any()) if (staffs.Any())
@ -413,7 +439,7 @@ public class Ghre_StudyRuleServices : BaseServices<Ghre_StudyRule, Ghre_StudyRul
StaffId = staff.StaffID, StaffId = staff.StaffID,
StudyRuleId = ruleId, StudyRuleId = ruleId,
Status = "SUCCESS", Status = "SUCCESS",
RemarkSz = "生成成功" RemarkSz = inStaffIds.Where(o => o == staff.StaffID).Any() ? $"生成成功,{month}月内入职员工" : "生成成功"
}); });
if (exam != null) if (exam != null)

@ -45,7 +45,7 @@ public partial class ReportServices : BaseServices<RootEntityTkey<int>>, IReport
if (filter.orderBy.IsNotEmptyOrNull()) if (filter.orderBy.IsNotEmptyOrNull())
filter.orderBy = "Indate DESC"; filter.orderBy = "Indate DESC";
condition = $"Indate >= '{DateTimeHelper.ConvertToDayString(dateTime)}' AND OutDate IS NULL"; condition = $"Indate >= '{DateTimeHelper.ConvertToDayString(dateTime)}' AND Indate <= '{DateTimeHelper.ConvertToDayString(DateTime.Now)}' AND OutDate IS NULL";
var result = await _staffServices.QueryFilterPage(filter, condition, IsEnable); var result = await _staffServices.QueryFilterPage(filter, condition, IsEnable);
return result; return result;

Loading…
Cancel
Save