必选修规则优化,新增处理人员异动

master
xiaochanghai 1 month ago
parent 8ee089e0a5
commit 7486b18896
  1. 13
      Tiobon.Core.Api/Controllers/Ghre/Ghre_StudyRuleController.cs
  2. 7
      Tiobon.Core.Api/Tiobon.Core.xml
  3. 5
      Tiobon.Core.IServices/Ghre/IGhre_StudyRuleServices.cs
  4. 68
      Tiobon.Core.Services/Ghre/Ghre_StudyRuleServices.cs

@ -11,4 +11,17 @@ public class Ghre_StudyRuleController : BaseController<IGhre_StudyRuleServices,
public Ghre_StudyRuleController(IGhre_StudyRuleServices service) : base(service)
{
}
#region 记录
/// <summary>
/// 记录
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpPost("StaffIn")]
public async Task StaffIn(long id) => await _service.StaffIn();
#endregion
}

@ -1509,6 +1509,13 @@
必选修规则(Controller)
</summary>
</member>
<member name="M:Tiobon.Core.Api.Controllers.Ghre_StudyRuleController.StaffIn(System.Int64)">
<summary>
记录
</summary>
<param name="id"></param>
<returns></returns>
</member>
<member name="T:Tiobon.Core.Api.Controllers.Ghre_StudyRuleResultController">
<summary>
必选修规则结果(Controller)

@ -1,7 +1,4 @@
using Tiobon.Core.IServices.BASE;
using Tiobon.Core.Model.Models;
namespace Tiobon.Core.IServices;
namespace Tiobon.Core.IServices;
/// <summary>
/// 必选修规则(自定义服务接口)

@ -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>();

Loading…
Cancel
Save