diff --git a/Tiobon.Core.Services/Ghre/Ghre_StudyRuleServices.cs b/Tiobon.Core.Services/Ghre/Ghre_StudyRuleServices.cs index fc91c675..8e8866ee 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_StudyRuleServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_StudyRuleServices.cs @@ -1,4 +1,5 @@  +using System.Collections.Generic; using System.Data; using MongoDB.Driver.Linq; using Newtonsoft.Json.Linq; @@ -328,6 +329,24 @@ public class Ghre_StudyRuleServices : BaseServices>(rule.JobId); + #region 处理部门是否含下阶 + var deptIds = new List(); + if (rule.IsDeptLower == true && DeptIds.Any()) + { + var depts = new List(); + depts = await GetDeptList(depts); + + foreach (var dept in DeptIds) + { + var items = await GetDeptList(depts, dept); + deptIds.AddRange(items.Select(x => x.DeptID).ToList()); + } + deptIds = deptIds.Distinct().ToList(); + if (deptIds.Any()) + DeptIds.AddRange(deptIds); + } + #endregion + var ruleStaffs = await Db.Queryable().Where(x => x.StudyRuleId == ruleId).ToListAsync(); await Db.Updateable().Where(x => x.StudyRuleId == ruleId && x.IsEnable == 1) @@ -469,6 +488,8 @@ public class Ghre_StudyRuleServices : BaseServices(); + depts = await GetDeptList(depts); var rules = await Db.Queryable().Where(x => x.TrainType != "PreWork" && x.TrainType != "Orientation").ToListAsync(); for (int j = 0; j < rules.Count; j++) @@ -491,6 +512,21 @@ public class Ghre_StudyRuleServices : BaseServices>(rule.JobId); + #region 处理部门是否含下阶 + var deptIds = new List(); + if (rule.IsDeptLower == true && DeptIds.Any()) + { + foreach (var dept in DeptIds) + { + var items = await GetDeptList(depts, dept); + deptIds.AddRange(items.Select(x => x.DeptID).ToList()); + } + deptIds = deptIds.Distinct().ToList(); + if (deptIds.Any()) + DeptIds.AddRange(deptIds); + } + #endregion + var staffs = await Db.Queryable() .Where(x => x.Indate != null && x.Indate.Value.Date == dt.Date) .WhereIF(ZoneIds.Any(), x => ZoneIds.Contains(x.ZoneID))