From cdc9cb5828c014646de65204bb0fcba6aa0b238e Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Fri, 28 Mar 2025 16:46:36 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=9C=BA=E6=99=AF=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E8=AE=BE=E7=BD=AE=E9=A1=B5=E9=9D=A2=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E7=AE=A1=E7=90=86=E5=A4=9A=E9=80=89=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=EF=BC=8C=E4=BF=9D=E5=AD=98=E5=90=8E=E8=A6=81=E8=83=BD?= =?UTF-8?q?=E5=8F=8D=E5=86=99=E5=88=B0=E5=B7=B2=E5=8F=91=E5=B8=83=E7=9A=84?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E7=AE=A1=E7=90=86=E4=B8=AD=E7=9A=84=E2=80=9C?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=9C=BA=E6=99=AF=E2=80=9D=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=20=E5=B0=86=E7=8E=B0=E5=9C=A8=E8=AF=BE=E7=A8=8B=E5=9C=BA?= =?UTF-8?q?=E6=99=AF=E5=88=97=E8=A1=A8=E9=A1=B5=E7=9A=84=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E6=8E=92=E5=BA=8F=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=9B=B4=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E5=9C=A8=E8=AF=BE=E7=A8=8B=E5=9C=BA=E6=99=AF=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E6=88=96=E7=BB=B4=E6=8A=A4=E9=A1=B5=E9=9D=A2=E9=87=8C?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E8=AF=BE=E7=A8=8B=E6=8E=92=E5=BA=8F=E5=8F=8A?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tiobon.Core.Api/Tiobon.Core.Model.xml | 5 + .../Base/Ghre/Ghre_CourseScene.Dto.Base.cs | 7 +- .../Ghre/Ghre_CourseSceneServices.cs | 68 +++++++--- .../Ghre/Ghre_ExamRecordServices.cs | 125 ++++++++++-------- 4 files changed, 131 insertions(+), 74 deletions(-) diff --git a/Tiobon.Core.Api/Tiobon.Core.Model.xml b/Tiobon.Core.Api/Tiobon.Core.Model.xml index fd2ae5e8..e77f05f3 100644 --- a/Tiobon.Core.Api/Tiobon.Core.Model.xml +++ b/Tiobon.Core.Api/Tiobon.Core.Model.xml @@ -3120,6 +3120,11 @@ 默认封面图Name + + + 课程列表 + + Ghre_CourseSnap (Dto.Base) diff --git a/Tiobon.Core.Model/Base/Ghre/Ghre_CourseScene.Dto.Base.cs b/Tiobon.Core.Model/Base/Ghre/Ghre_CourseScene.Dto.Base.cs index 8fea909b..56e7382e 100644 --- a/Tiobon.Core.Model/Base/Ghre/Ghre_CourseScene.Dto.Base.cs +++ b/Tiobon.Core.Model/Base/Ghre/Ghre_CourseScene.Dto.Base.cs @@ -150,8 +150,6 @@ public class Ghre_CourseSceneBase [Display(Name = "CoverUrl"), Description("封面图"), MaxLength(2000, ErrorMessage = "封面图 不能超过 2000 个字符")] public string CoverUrl { get; set; } - public List CourseIds { get; set; } = new List(); - /// /// 是否使用默认封面 /// @@ -162,4 +160,9 @@ public class Ghre_CourseSceneBase /// [Display(Name = "DefaultCoverImageName"), Description("默认封面图Name"), MaxLength(32, ErrorMessage = "默认封面图Name 不能超过 32 个字符")] public string DefaultCoverImageName { get; set; } + + /// + /// 课程列表 + /// + public List Courses { get; set; } = new List(); } diff --git a/Tiobon.Core.Services/Ghre/Ghre_CourseSceneServices.cs b/Tiobon.Core.Services/Ghre/Ghre_CourseSceneServices.cs index 105e6b78..aa996133 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_CourseSceneServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_CourseSceneServices.cs @@ -1,7 +1,4 @@ -using NPOI.SS.UserModel; -using Tiobon.Core.IServices; - -namespace Tiobon.Core.Services; +namespace Tiobon.Core.Services; /// /// 课程场景 (服务) @@ -46,31 +43,70 @@ public class Ghre_CourseSceneServices : BaseServices Add(InsertGhre_CourseSceneInput entity) { - if (entity.CourseIds != null && entity.CourseIds.Any()) + var courseIds = new List(); + if (entity.Courses != null && entity.Courses.Any()) { + courseIds = entity.Courses.Select(x => x.Id).ToList(); + entity.CourseId = JsonHelper.ObjToJson(courseIds); - entity.CourseId = JsonHelper.ObjToJson(entity.CourseIds); - - var list = Db.Queryable().Where(x => entity.CourseIds.Contains(x.Id.ToString())).Select(x => x.CourseName).ToList(); + var list = Db.Queryable().Where(x => courseIds.Contains(x.Id)).Select(x => x.CourseName).ToList(); - entity.CourseName = string.Join("、", list.Select(x => x).ToArray()); + entity.CourseName = string.Join("、", list.ToArray()); + } + var id = await base.Add(entity); + var courses = Db.Queryable().Where(x => courseIds.Contains(x.Id)).ToList(); + for (int i = 0; i < courses.Count; i++) + { + var courseSceneIds = new List(); + if (courses[i].CourseSceneIds.IsNotEmptyOrNull()) + courseSceneIds = JsonHelper.JsonToObj>(courses[i].CourseSceneIds); + courseSceneIds.Add(id); + courses[i].CourseSceneIds = JsonHelper.ObjToJson(courseSceneIds); + await Db.Updateable(courses).UpdateColumns(it => new { it.CourseSceneIds }, true)//true表示追加AOP赋值列 + .ExecuteCommandAsync(); } - return await base.Add(entity); + return id; } public override async Task Update(long Id, EditGhre_CourseSceneInput editModel) { - - if (editModel.CourseIds != null && editModel.CourseIds.Any()) + var courseIds = new List(); + if (editModel.Courses != null && editModel.Courses.Any()) { + courseIds = editModel.Courses.Select(x => x.Id).ToList(); + editModel.CourseId = JsonHelper.ObjToJson(courseIds); - editModel.CourseId = JsonHelper.ObjToJson(editModel.CourseIds); - - var list = Db.Queryable().Where(x => editModel.CourseIds.Contains(x.Id.ToString())).Select(x => x.CourseName).ToList(); + var list = Db.Queryable().Where(x => courseIds.Contains(x.Id)).Select(x => x.CourseName).ToList(); editModel.CourseName = string.Join("、", list.Select(x => x).ToArray()); } - return await base.Update(Id, editModel); + var result = await base.Update(Id, editModel); + + var courses = await Db.Queryable().Where(x => x.CourseSceneIds != null && x.CourseSceneIds.Contains(Id.ObjToString())).ToListAsync(); + + for (int j = 0; j < courses.Count; j++) + { + var courseSceneIds = new List(); + if (courses[j].CourseSceneIds.IsNotEmptyOrNull()) + courseSceneIds = JsonHelper.JsonToObj>(courses[j].CourseSceneIds); + courseSceneIds = courseSceneIds.Where(x => x != Id).ToList(); + courses[j].CourseSceneIds = JsonHelper.ObjToJson(courseSceneIds); + await Db.Updateable(courses).UpdateColumns(it => new { it.CourseSceneIds }, true)//true表示追加AOP赋值列 + .ExecuteCommandAsync(); + } + courses = Db.Queryable().Where(x => courseIds.Contains(x.Id)).ToList(); + for (int i = 0; i < courses.Count; i++) + { + var courseSceneIds = new List(); + if (courses[i].CourseSceneIds.IsNotEmptyOrNull()) + courseSceneIds = JsonHelper.JsonToObj>(courses[i].CourseSceneIds); + courseSceneIds.Add(Id); + courses[i].CourseSceneIds = JsonHelper.ObjToJson(courseSceneIds); + await Db.Updateable(courses).UpdateColumns(it => new { it.CourseSceneIds }, true)//true表示追加AOP赋值列 + .ExecuteCommandAsync(); + } + + return result; } #region Excel导入 diff --git a/Tiobon.Core.Services/Ghre/Ghre_ExamRecordServices.cs b/Tiobon.Core.Services/Ghre/Ghre_ExamRecordServices.cs index 2bdcf747..fed79d19 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_ExamRecordServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_ExamRecordServices.cs @@ -1114,89 +1114,102 @@ public class Ghre_ExamRecordServices : BaseServices().FirstAsync(x => x.Id == studyRecordId); + _logger.LogInformation($"【DealPass:{studyRecordId}】1"); - var record = await Db.Queryable().FirstAsync(x => x.Id == studyRecordId); + var studyRecord = await Db.Queryable().FirstAsync(x => x.Id == record.StudyRecordId); + var examPaper = await Db.Queryable().FirstAsync(x => x.Id == record.ExamPaperId); + _logger.LogInformation($"【DealPass:{studyRecordId}】PassScore:{examPaper.PassScore},Score:{record.Score},PassScore:{record.AdjustScore},"); - var studyRecord = await Db.Queryable().FirstAsync(x => x.Id == record.StudyRecordId); - var examPaper = await Db.Queryable().FirstAsync(x => x.Id == record.ExamPaperId); - record.IsPass = examPaper.PassScore > ((record.Score ?? 0) + (record.AdjustScore ?? 0)) ? false : true; + record.IsPass = examPaper.PassScore > ((record.Score ?? 0) + (record.AdjustScore ?? 0)) ? false : true; + _logger.LogInformation($"【DealPass:{studyRecordId}】IsPass:{record.IsPass}"); - record.FinallyIsPass = record.IsPass; + record.FinallyIsPass = record.IsPass; - await Db.Updateable(record).UpdateColumns(it => new { it.IsPass, it.FinallyIsPass }, true)//true表示追加AOP赋值列 - .ExecuteCommandAsync(); + await Db.Updateable(record).UpdateColumns(it => new { it.IsPass, it.FinallyIsPass }, true)//true表示追加AOP赋值列 + .ExecuteCommandAsync(); - await Db.Deleteable().Where(x => x.ExamId == studyRecord.ExamId).ExecuteCommandAsync(); + await Db.Deleteable().Where(x => x.ExamId == studyRecord.ExamId).ExecuteCommandAsync(); - if (record.IsPass == true) - { - if (studyRecord.CourseSceneId.IsNull()) + if (record.IsPass == true) { - var course = await Db.Queryable().FirstAsync(x => x.Id == studyRecord.CourseId); - #region 学分发放 - var creditPoint = new Ghre_CreditPoint() + if (studyRecord.CourseSceneId.IsNull()) { - CourseId = studyRecord.CourseId, - CourseSnapId = studyRecord.CourseSnapId, - StaffId = studyRecord.StaffId, - ExamId = studyRecord.ExamId, - Date = DateTime.Now.Date, - CreditPoints = course.CreditPoints - }; - - await Db.Insertable(creditPoint).ExecuteReturnSnowflakeIdListAsync(); - #endregion - - #region 证书发放 - - #endregion - } - else - { - var courses = await Db.Queryable().Where(x => x.CourseSceneId == studyRecord.CourseSceneId).ToListAsync(); - - for (int i = 0; i < courses.Count; i++) - { - var snap = await Db.Queryable().FirstAsync(x => x.CourseId == courses[i].Id); - + var course = await Db.Queryable().FirstAsync(x => x.Id == studyRecord.CourseId); #region 学分发放 var creditPoint = new Ghre_CreditPoint() { - CourseId = courses[i].Id, - CourseSnapId = snap?.Id, + CourseId = studyRecord.CourseId, + CourseSnapId = studyRecord.CourseSnapId, StaffId = studyRecord.StaffId, ExamId = studyRecord.ExamId, Date = DateTime.Now.Date, - CreditPoints = courses[i].CreditPoints + CreditPoints = course.CreditPoints }; await Db.Insertable(creditPoint).ExecuteReturnSnowflakeIdListAsync(); #endregion + + #region 证书发放 + + #endregion } + else + { + var courses = await Db.Queryable().Where(x => x.CourseSceneId == studyRecord.CourseSceneId).ToListAsync(); - } + for (int i = 0; i < courses.Count; i++) + { + var snap = await Db.Queryable().FirstAsync(x => x.CourseId == courses[i].Id); - } + #region 学分发放 + var creditPoint = new Ghre_CreditPoint() + { + CourseId = courses[i].Id, + CourseSnapId = snap?.Id, + StaffId = studyRecord.StaffId, + ExamId = studyRecord.ExamId, + Date = DateTime.Now.Date, + CreditPoints = courses[i].CreditPoints + }; + + await Db.Insertable(creditPoint).ExecuteReturnSnowflakeIdListAsync(); + #endregion + } - #region 处理培训记录有效时间 - if (studyRecord.StudyRuleId != null) - { - var studyRule = await Db.Queryable().FirstAsync(x => x.Id == studyRecord.StudyRuleId); - if (studyRule != null && studyRule.ResultValidPeriod != null) + } + + } + + #region 处理培训记录有效时间 + if (studyRecord.StudyRuleId != null) { - studyRecord.ValidBeginTime = DateTime.Now; - studyRecord.ValidEndTime = studyRecord.ValidBeginTime.Value.AddMonths(studyRule.ResultValidPeriod.Value); + var studyRule = await Db.Queryable().FirstAsync(x => x.Id == studyRecord.StudyRuleId); + if (studyRule != null && studyRule.ResultValidPeriod != null) + { + studyRecord.ValidBeginTime = DateTime.Now; + studyRecord.ValidEndTime = studyRecord.ValidBeginTime.Value.AddMonths(studyRule.ResultValidPeriod.Value); - await Db.Updateable(studyRecord).UpdateColumns(it => new { it.ValidBeginTime, it.ValidEndTime }, true)//true表示追加AOP赋值列 - .ExecuteCommandAsync(); + await Db.Updateable(studyRecord).UpdateColumns(it => new { it.ValidBeginTime, it.ValidEndTime }, true)//true表示追加AOP赋值列 + .ExecuteCommandAsync(); - record.ValidBeginTime = studyRecord.ValidBeginTime; - record.ValidEndTime = studyRecord.ValidEndTime; - await Db.Updateable(record).UpdateColumns(it => new { it.ValidBeginTime, it.ValidEndTime }) - .ExecuteCommandAsync(); + record.ValidBeginTime = studyRecord.ValidBeginTime; + record.ValidEndTime = studyRecord.ValidEndTime; + await Db.Updateable(record).UpdateColumns(it => new { it.ValidBeginTime, it.ValidEndTime }) + .ExecuteCommandAsync(); + } } + #endregion + _logger.LogInformation($"【DealPass:{studyRecordId}】2"); + + } + catch (Exception E) + { + _logger.LogInformation($"【DealPass:{studyRecordId}】Message:{E.Message}"); + _logger.LogInformation($"【DealPass:{studyRecordId}】StackTrace:{E.StackTrace}"); } - #endregion } public async Task ViewExamPaperCallBackAsync(long examRecordId)