From 4d921f7de40cc17549bb8c2f9a69588843deb96c Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Tue, 30 Jul 2024 16:41:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BF=85=E9=80=89=E4=BF=AE=E8=A7=84=E5=88=99?= =?UTF-8?q?=E7=94=9F=E6=88=90=E5=AD=A6=E4=B9=A0=E8=AE=B0=E5=BD=95=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E7=94=9F=E6=88=90=E8=A7=84=E5=88=99=E7=BB=93=E6=9E=9C?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tiobon.Core.Api/Tiobon.Core.Model.xml | 25 ++ Tiobon.Core.Model/Consts.cs | 33 +++ Tiobon.Core.Services/CommonServices.cs | 21 +- .../Ghre/Ghre_StudyRuleServices.cs | 119 +++++++- Tiobon.Core/Tiobon.Core.Model.xml | 260 ++++++++++++++++++ Tiobon.Core/Tiobon.Core.xml | 5 + 6 files changed, 450 insertions(+), 13 deletions(-) diff --git a/Tiobon.Core.Api/Tiobon.Core.Model.xml b/Tiobon.Core.Api/Tiobon.Core.Model.xml index 91459d3a..f9a5172a 100644 --- a/Tiobon.Core.Api/Tiobon.Core.Model.xml +++ b/Tiobon.Core.Api/Tiobon.Core.Model.xml @@ -12587,6 +12587,31 @@ 考试管理-关联类型-場景 + + + 培训记录-课程状态-进行中 + + + + + 培训记录-课程状态-已结束 + + + + + 培训记录-学习状态-未参与 + + + + + 培训记录-学习状态-未完成 + + + + + 培训记录-学习状态-已完成 + + 无任何权限 diff --git a/Tiobon.Core.Model/Consts.cs b/Tiobon.Core.Model/Consts.cs index 87fdf628..a7b79347 100644 --- a/Tiobon.Core.Model/Consts.cs +++ b/Tiobon.Core.Model/Consts.cs @@ -42,4 +42,37 @@ public class Consts /// public const string DIC_EXAM_DATE_TYPE_COURSE_SCENE = "CourseSceneId"; #endregion + + #region 培训记录-课程状态 + + /// + /// 培训记录-课程状态-进行中 + /// + public const string DIC_STUDY_RECORD_COURSE_STATUS_IN = "In"; + + /// + /// 培训记录-课程状态-已结束 + /// + public const string DIC_STUDY_RECORD_COURSE_STATUS_OVER = "Over"; + + #endregion + + #region 培训记录-学习状态 + + /// + /// 培训记录-学习状态-未参与 + /// + public const string DIC_STUDY_RECORD_STUDY_STATUS_NO_JOIN = "NoJoin"; + + /// + /// 培训记录-学习状态-未完成 + /// + public const string DIC_STUDY_RECORD_STUDY_STATUS_FINISH = "NoFinish"; + + /// + /// 培训记录-学习状态-已完成 + /// + public const string DIC_STUDY_RECORD_STUDY_STATUS_HAS_FINISH = "HasFinish"; + + #endregion } \ No newline at end of file diff --git a/Tiobon.Core.Services/CommonServices.cs b/Tiobon.Core.Services/CommonServices.cs index de164d5d..60eebe63 100644 --- a/Tiobon.Core.Services/CommonServices.cs +++ b/Tiobon.Core.Services/CommonServices.cs @@ -1061,7 +1061,6 @@ public partial class CommonServices : BaseServices>, ICommon result.JM_PageControlT1.Toolbar.RemoveAt(index); break; case "F_SchoolManage": - case "F_RequiredElectiveRules": case "F_WorkLicenseManage": case "F_TeacherManage": toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "NewYN").FirstOrDefault(); @@ -1101,6 +1100,26 @@ public partial class CommonServices : BaseServices>, ICommon toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "DetailYN").FirstOrDefault(); if (toolbar != null) { toolbar.fnKey = "TBD3YN"; } break; + case "F_RequiredElectiveRules": + toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "NewYN").FirstOrDefault(); + if (toolbar != null) toolbar.fnKey = "TBD1YN"; + toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "UpdateYN").FirstOrDefault(); + if (toolbar != null) toolbar.fnKey = "TBD2YN"; + toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "DetailYN").FirstOrDefault(); + if (toolbar != null) toolbar.fnKey = "TBD3YN"; + toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "CopyYN").FirstOrDefault(); + if (toolbar != null) toolbar.fnKey = "TBD4YN"; + result.JM_PageControlT1.Toolbar.Add(new Toolbar() + { + display = true, + fnKey = "TBD5YN", + fnTitle = "结果", + fnType = "row", + icon = "ghr-preview", + position = "left" + }); + break; + } #endregion diff --git a/Tiobon.Core.Services/Ghre/Ghre_StudyRuleServices.cs b/Tiobon.Core.Services/Ghre/Ghre_StudyRuleServices.cs index b0e9898f..a429658a 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_StudyRuleServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_StudyRuleServices.cs @@ -11,6 +11,9 @@ using Newtonsoft.Json; using Tiobon.Core.Common.Helper; using Org.BouncyCastle.Crypto; using SqlSugar; +using MathNet.Numerics.Distributions; +using MongoDB.Driver.Linq; +using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime; namespace Tiobon.Core.Services; @@ -166,6 +169,7 @@ public class Ghre_StudyRuleServices : BaseServices await GenerateStaffStudyRecord(Db, Id)); return result; } @@ -191,21 +195,112 @@ public class Ghre_StudyRuleServices : BaseServices GenerateStaffStudyRecord(ISqlSugarClient Db, long ruleId) { - var rule = await Db.Queryable().FirstAsync(x => x.Id == ruleId); - var ruleStaffs = await Db.Queryable().Where(x => x.StudyRuleId == ruleId).ToListAsync(); + try + { + await Db.Ado.BeginTranAsync(); + + var rule = await Db.Queryable().FirstAsync(x => x.Id == ruleId); + var ruleStaffs = await Db.Queryable().Where(x => x.StudyRuleId == ruleId).ToListAsync(); + + await Db.Updateable().Where(x => x.StudyRuleId == ruleId && x.IsEnable == 1) + .SetColumns(it => new Ghre_StudyRuleResult() { IsEnable = 0 })//类只能在表达示里面不能提取 + .ExecuteCommandAsync(); + + var ruleStaffIds = ruleStaffs.Select(x => x.StaffId).ToList(); + + var staffs = await Db.Queryable() + .WhereIF(rule.ZoneId != null, x => x.ZoneID == rule.ZoneId) + .WhereIF(rule.DeptId != null, x => x.DeptID == rule.DeptId) + .WhereIF(rule.TitleId != null, x => x.TitleID == rule.TitleId) + .WhereIF(rule.GradeId != null, x => x.GradeID == rule.GradeId) + .WhereIF(rule.JobId != null, x => x.JobID == rule.JobId) + .WhereIF(ruleStaffIds != null && ruleStaffIds.Any(), x => ruleStaffIds.Contains(x.StaffID)) + .WhereIF(rule.GradeId != null, x => x.GradeID == rule.GradeId) + .ToListAsync(); + + if (staffs != null) + { + DateTime courseTime = Db.GetDate(); + var snap = await Db.Queryable().FirstAsync(x => x.CourseId == rule.CourseId); + if (staffs.Any()) + { + var inserts = new List(); + var insertResults = new List(); + await Db.Deleteable().Where(x => x.StudyRuleId == ruleId && x.BeginTime == null).ExecuteCommandAsync(); + + for (int i = 0; i < staffs.Count; i++) + { + var staff = staffs[i]; + + var record = await Db.Queryable() + .Where(x => x.StudyRuleId != ruleId && x.StaffId == staff.StaffID) + .WhereIF(!string.IsNullOrWhiteSpace(rule.Year), x => x.Year == rule.Year) + .FirstAsync(); + if (record is null) + { + inserts.Add(new Ghre_StudyRecord() + { + StaffId = staff.StaffID, + CourseSnapId = snap.Id, + CourseId = rule.CourseId, + StudyRuleId = ruleId, + JoinTime = courseTime, + CourseBeginTime = courseTime, + CourseEndTime = courseTime.AddMonths(rule.DeadlineMonth ?? 3), + CourseType = rule.RuleType, + CourseStatus = Consts.DIC_STUDY_RECORD_COURSE_STATUS_IN, + StudyStatus = Consts.DIC_STUDY_RECORD_STUDY_STATUS_NO_JOIN, + Year = rule.Year + }); + 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 = "生成失败,该课程学习记录已被其他规则生成!" + }); + } - var ruleStaffIds = ruleStaffs.Select(x => x.StaffId).ToList(); + if (inserts.Any()) + await Db.Insertable(inserts).ExecuteReturnSnowflakeIdListAsync(); + if (insertResults.Any()) + await Db.Insertable(insertResults).ExecuteReturnSnowflakeIdListAsync(); - var staffs = await Db.Queryable() - .WhereIF(rule.ZoneId != null, x => x.ZoneID == rule.ZoneId) - .WhereIF(rule.DeptId != null, x => x.DeptID == rule.DeptId) - .WhereIF(rule.TitleId != null, x => x.TitleID == rule.TitleId) - .WhereIF(rule.GradeId != null, x => x.GradeID == rule.GradeId) - .WhereIF(rule.JobId != null, x => x.JobID == rule.JobId) - .WhereIF(ruleStaffIds != null && ruleStaffIds.Any(), x => ruleStaffIds.Contains(x.StaffID)) - .WhereIF(rule.GradeId != null, x => x.GradeID == rule.GradeId) - .ToListAsync(); + rule.RemarkSz = "数据生成成功"; + } + else + { + rule.RemarkSz = "未匹配到相关关人员数据!"; + + } + await Db.Updateable().Where(x => x.Id == ruleId) + .SetColumns(it => new Ghre_StudyRule() { RemarkSz = rule.RemarkSz })//类只能在表达示里面不能提取 + .ExecuteCommandAsync(); + } + + + await Db.Ado.CommitTranAsync(); + + + string sql = @"UPDATE A + SET A.StaffName = B.StaffName, a.StaffNo = B.StaffNo + FROM Ghre_StudyRuleResult A LEFT JOIN Ghra_Staff B ON A.StaffId = B.StaffID + WHERE A.StaffName IS NULL"; + await Db.Ado.ExecuteCommandAsync(sql); + } + catch (Exception) + { + await Db.Ado.RollbackTranAsync(); + } return true; } } \ No newline at end of file diff --git a/Tiobon.Core/Tiobon.Core.Model.xml b/Tiobon.Core/Tiobon.Core.Model.xml index 872b7bcc..f9a5172a 100644 --- a/Tiobon.Core/Tiobon.Core.Model.xml +++ b/Tiobon.Core/Tiobon.Core.Model.xml @@ -3965,6 +3965,11 @@ 学习状态 + + + 年度 + + 备注 @@ -4165,6 +4170,106 @@ 预留字段12 + + + 必选修规则结果 (Dto.Base) + + + + + 必选修规则ID + + + + + 人员ID + + + + + 工号 + + + + + 员工姓名 + + + + + 状态 + + + + + 备注 + + + + + 默认标志 + + + + + 预留字段1 + + + + + 预留字段2 + + + + + 预留字段3 + + + + + 预留字段4 + + + + + 预留字段5 + + + + + 预留字段6 + + + + + 预留字段7 + + + + + 预留字段8 + + + + + 预留字段9 + + + + + 预留字段10 + + + + + 预留字段11 + + + + + 预留字段12 + + 必选修规则人员 (Dto.Base) @@ -5242,6 +5347,11 @@ 必选修规则 (Dto.EditInput) + + + 必选修规则结果 (Dto.EditInput) + + 必选修规则人员 (Dto.EditInput) @@ -5427,6 +5537,11 @@ 必选修规则 (Dto.InsertInput) + + + 必选修规则结果 (Dto.InsertInput) + + 必选修规则人员 (Dto.InsertInput) @@ -9596,6 +9711,11 @@ 学习状态 + + + 年度 + + 备注 @@ -9796,6 +9916,106 @@ 预留字段12 + + + 必选修规则结果 (Model) + + + + + 必选修规则ID + + + + + 人员ID + + + + + 工号 + + + + + 员工姓名 + + + + + 状态 + + + + + 备注 + + + + + 默认标志 + + + + + 预留字段1 + + + + + 预留字段2 + + + + + 预留字段3 + + + + + 预留字段4 + + + + + 预留字段5 + + + + + 预留字段6 + + + + + 预留字段7 + + + + + 预留字段8 + + + + + 预留字段9 + + + + + 预留字段10 + + + + + 预留字段11 + + + + + 预留字段12 + + 必选修规则人员 (Model) @@ -12217,6 +12437,21 @@ 修改信息 + + + 必选修规则结果(Dto.View) + + + + + 创建信息 + + + + + 修改信息 + + 必选修规则人员(Dto.View) @@ -12352,6 +12587,31 @@ 考试管理-关联类型-場景 + + + 培训记录-课程状态-进行中 + + + + + 培训记录-课程状态-已结束 + + + + + 培训记录-学习状态-未参与 + + + + + 培训记录-学习状态-未完成 + + + + + 培训记录-学习状态-已完成 + + 无任何权限 diff --git a/Tiobon.Core/Tiobon.Core.xml b/Tiobon.Core/Tiobon.Core.xml index d1809c72..3fd8f67e 100644 --- a/Tiobon.Core/Tiobon.Core.xml +++ b/Tiobon.Core/Tiobon.Core.xml @@ -956,6 +956,11 @@ 必选修规则(Controller) + + + 必选修规则结果(Controller) + + 必选修规则人员(Controller)