|
|
|
@ -342,6 +342,10 @@ public class Ghre_StudyRuleServices : BaseServices<Ghre_StudyRule, Ghre_StudyRul |
|
|
|
|
if (!rule.JobId.IsNull()) |
|
|
|
|
JobIds = JsonHelper.JsonToObj<List<int?>>(rule.JobId); |
|
|
|
|
|
|
|
|
|
await Db.Deleteable<Ghre_StudyRecord>().Where(x => x.StudyRuleId == ruleId && x.BeginTime == null).ExecuteCommandAsync(); |
|
|
|
|
await Db.Deleteable<Ghre_ExamStaff>().Where(x => x.StudyRuleId == ruleId).ExecuteCommandAsync(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 处理部门是否含下阶 |
|
|
|
|
var deptIds = new List<int?>(); |
|
|
|
|
if (rule.IsDeptLower == true && DeptIds.Any()) |
|
|
|
@ -404,7 +408,7 @@ public class Ghre_StudyRuleServices : BaseServices<Ghre_StudyRule, Ghre_StudyRul |
|
|
|
|
.WhereIF(!ruleStaffIds.IsNull() && ruleStaffIds.Any(), x => ruleStaffIds.Contains(x.StaffID)) |
|
|
|
|
.ToListAsync(); |
|
|
|
|
|
|
|
|
|
if (!staffs.IsNull()) |
|
|
|
|
if (staffs.Any()) |
|
|
|
|
{ |
|
|
|
|
var courseTime = Db.GetDate(); |
|
|
|
|
var snap = await Db.Queryable<Ghre_CourseSnap>().FirstAsync(x => x.CourseId == rule.CourseId); |
|
|
|
@ -414,8 +418,6 @@ public class Ghre_StudyRuleServices : BaseServices<Ghre_StudyRule, Ghre_StudyRul |
|
|
|
|
var inserts = new List<Ghre_StudyRecord>(); |
|
|
|
|
var insertExamStaffs = new List<Ghre_ExamStaff>(); |
|
|
|
|
var insertResults = new List<Ghre_StudyRuleResult>(); |
|
|
|
|
await Db.Deleteable<Ghre_StudyRecord>().Where(x => x.StudyRuleId == ruleId && x.BeginTime == null).ExecuteCommandAsync(); |
|
|
|
|
await Db.Deleteable<Ghre_ExamStaff>().Where(x => x.StudyRuleId == ruleId).ExecuteCommandAsync(); |
|
|
|
|
|
|
|
|
|
//var exam = await Db.Queryable<Ghre_Exam>() |
|
|
|
|
// .WhereIF(rule.CourseId != null, x => x.CourseId == rule.CourseId) |
|
|
|
@ -423,8 +425,8 @@ public class Ghre_StudyRuleServices : BaseServices<Ghre_StudyRule, Ghre_StudyRul |
|
|
|
|
// .FirstAsync(x => x.Status == Consts.DicExamStatus.RELEASED); |
|
|
|
|
|
|
|
|
|
var exam = await Db.Queryable<Ghre_Exam>() |
|
|
|
|
.Where(x => x.Status == Consts.DIC_EXAM_STATUS.RELEASED |
|
|
|
|
&& ((x.DateType == Consts.DicExamDateType.EXAM_DATE |
|
|
|
|
.Where(x => x.Status == DIC_EXAM_STATUS.RELEASED |
|
|
|
|
&& ((x.DateType == DicExamDateType.EXAM_DATE |
|
|
|
|
&& x.BeginTime.Value.Date <= DateTime.Now.Date && x.EndTime.Value.Date >= DateTime.Now.Date) || x.DateType == Consts.DicExamDateType.AFTER_HOW_LONG)) |
|
|
|
|
.WhereIF(!rule.CourseId.IsNull(), x => x.CourseId == rule.CourseId) |
|
|
|
|
.WhereIF(!rule.CourseSceneId.IsNull(), x => x.CourseSceneId == rule.CourseSceneId) |
|
|
|
@ -465,7 +467,7 @@ public class Ghre_StudyRuleServices : BaseServices<Ghre_StudyRule, Ghre_StudyRul |
|
|
|
|
StaffId = staff.StaffID, |
|
|
|
|
StudyRuleId = ruleId, |
|
|
|
|
Status = "SUCCESS", |
|
|
|
|
RemarkSz = inStaffIds.Where(o => o == staff.StaffID).Any() ? $"生成成功,{month}月内入职员工" : "生成成功" |
|
|
|
|
RemarkSz = inStaffIds.Where(o => o == staff.StaffID).Any() ? $"生成成功,{month}月内入职员工!" : "生成成功!" |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
if (exam != null) |
|
|
|
@ -478,13 +480,29 @@ public class Ghre_StudyRuleServices : BaseServices<Ghre_StudyRule, Ghre_StudyRul |
|
|
|
|
Source = "StudyRule" + rule.RuleType |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
else insertResults.Add(new Ghre_StudyRuleResult() |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
StaffId = staff.StaffID, |
|
|
|
|
StudyRuleId = ruleId, |
|
|
|
|
Status = "FAIL", |
|
|
|
|
RemarkSz = "生成失败,该课程学习记录已被其他规则生成!" |
|
|
|
|
}); |
|
|
|
|
if (record.StudyRuleId == ruleId) |
|
|
|
|
{ |
|
|
|
|
insertResults.Add(new Ghre_StudyRuleResult() |
|
|
|
|
{ |
|
|
|
|
StaffId = staff.StaffID, |
|
|
|
|
StudyRuleId = ruleId, |
|
|
|
|
Status = "SUCCESS", |
|
|
|
|
RemarkSz = "生成成功!" |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
insertResults.Add(new Ghre_StudyRuleResult() |
|
|
|
|
{ |
|
|
|
|
StaffId = staff.StaffID, |
|
|
|
|
StudyRuleId = ruleId, |
|
|
|
|
Status = "FAIL", |
|
|
|
|
RemarkSz = "生成失败,该课程学习记录已被存在!" |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (inserts.Any()) |
|
|
|
@ -506,6 +524,20 @@ public class Ghre_StudyRuleServices : BaseServices<Ghre_StudyRule, Ghre_StudyRul |
|
|
|
|
.ExecuteCommandAsync(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#region 处理异动后人员转选修 |
|
|
|
|
var staffIds = staffs.Select(x => x.StaffID).ToList(); |
|
|
|
|
|
|
|
|
|
var recordIds = await Db.Queryable<Ghre_StudyRecord>() |
|
|
|
|
.Where(x => x.StudyRuleId == ruleId && !staffIds.Contains(x.StaffId.Value) && |
|
|
|
|
x.StudyStatus != DIC_STUDY_RECORD_STUDY_STATUS.HAS_FINISH && x.Reverse9 != "异动转入选修") |
|
|
|
|
.Select(x => x.Id).ToListAsync(); |
|
|
|
|
if (recordIds.Any()) |
|
|
|
|
await Db.Updateable<Ghre_StudyRecord>() |
|
|
|
|
.Where(x => recordIds.Contains(x.Id)) |
|
|
|
|
.SetColumns(it => new Ghre_StudyRecord() { CourseType = "Elective", Reverse9 = "异动转入选修" }) |
|
|
|
|
.ExecuteCommandAsync(); |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
await Db.Ado.CommitTranAsync(); |
|
|
|
|
|
|
|
|
|
string sql = @"UPDATE A
|
|
|
|
@ -519,13 +551,23 @@ public class Ghre_StudyRuleServices : BaseServices<Ghre_StudyRule, Ghre_StudyRul |
|
|
|
|
await Db.Ado.RollbackTranAsync(); |
|
|
|
|
|
|
|
|
|
await Db.Updateable<Ghre_StudyRule>().Where(x => x.Id == ruleId) |
|
|
|
|
.SetColumns(it => new Ghre_StudyRule() { Result = E.Message })//类只能在表达示里面不能提取 |
|
|
|
|
.SetColumns(it => new Ghre_StudyRule() { Result = E.Message }) |
|
|
|
|
.ExecuteCommandAsync(); |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public async Task StaffIn() |
|
|
|
|
{ |
|
|
|
|
var rules = await Db.Queryable<Ghre_StudyRule>().Where(x => x.TrainType != DIC_TRAINING_STUDY_RULE_TRAIN_TYPE.Year && x.TrainType != DIC_TRAINING_STUDY_RULE_TRAIN_TYPE.Orientation).ToListAsync(); |
|
|
|
|
|
|
|
|
|
for (int j = 0; j < rules.Count; j++) |
|
|
|
|
{ |
|
|
|
|
await GenerateStaffStudyRecord(Db, rules[j].Id); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public async Task StaffIn2() |
|
|
|
|
{ |
|
|
|
|
var dt = Db.GetDate(); |
|
|
|
|
var depts = new List<Ghro_Dept>(); |
|
|
|
|