必选修规则生成数据新增处理部门是否含下阶

master
xiaochanghai 9 months ago
parent 8bc52a134b
commit 0e9f1e361e
  1. 36
      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<Ghre_StudyRule, Ghre_StudyRul
if (!rule.JobId.IsNull())
JobIds = JsonHelper.JsonToObj<List<int?>>(rule.JobId);
#region 处理部门是否含下阶
var deptIds = new List<int?>();
if (rule.IsDeptLower == true && DeptIds.Any())
{
var depts = new List<Ghro_Dept>();
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<Ghre_StudyRuleStaff>().Where(x => x.StudyRuleId == ruleId).ToListAsync();
await Db.Updateable<Ghre_StudyRuleResult>().Where(x => x.StudyRuleId == ruleId && x.IsEnable == 1)
@ -469,6 +488,8 @@ public class Ghre_StudyRuleServices : BaseServices<Ghre_StudyRule, Ghre_StudyRul
public async Task StaffIn()
{
var dt = Db.GetDate();
var depts = new List<Ghro_Dept>();
depts = await GetDeptList(depts);
var rules = await Db.Queryable<Ghre_StudyRule>().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<Ghre_StudyRule, Ghre_StudyRul
if (!rule.JobId.IsNull())
JobIds = JsonHelper.JsonToObj<List<int?>>(rule.JobId);
#region 处理部门是否含下阶
var deptIds = new List<int?>();
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<Ghra_Staff>()
.Where(x => x.Indate != null && x.Indate.Value.Date == dt.Date)
.WhereIF(ZoneIds.Any(), x => ZoneIds.Contains(x.ZoneID))

Loading…
Cancel
Save