From e767e09ef347b57d4880d438b9b8e040b0dee384 Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Wed, 14 May 2025 10:49:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=BE=E7=A8=8B=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E5=9C=BA=E6=99=AF=E5=88=86=E6=9E=90=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tiobon.Core.Api/Tiobon.Core.Model.xml | 2 +- Tiobon.Core.Model/Consts.cs | 4 +- .../ViewModels/Extend/CourseAndScene.cs | 9 ++++ Tiobon.Core.Services/CommonServices.cs | 13 ++++- .../Ghre/Ghre_CourseServices.cs | 53 +++++++++++++++++++ Tiobon.Core/Tiobon.Core.Model.xml | 2 +- 6 files changed, 78 insertions(+), 5 deletions(-) diff --git a/Tiobon.Core.Api/Tiobon.Core.Model.xml b/Tiobon.Core.Api/Tiobon.Core.Model.xml index 66975c7f..7d5b30aa 100644 --- a/Tiobon.Core.Api/Tiobon.Core.Model.xml +++ b/Tiobon.Core.Api/Tiobon.Core.Model.xml @@ -41045,7 +41045,7 @@ - 培训记录-学习状态 + 培训记录-完成状态 diff --git a/Tiobon.Core.Model/Consts.cs b/Tiobon.Core.Model/Consts.cs index b8b27d31..d19f9579 100644 --- a/Tiobon.Core.Model/Consts.cs +++ b/Tiobon.Core.Model/Consts.cs @@ -271,9 +271,9 @@ public class Consts #endregion - #region 培训记录-学习状态 + #region 培训记录-完成状态 /// - /// 培训记录-学习状态 + /// 培训记录-完成状态 /// public static class DIC_STUDY_RECORD_STUDY_COMPLETE_STATUS diff --git a/Tiobon.Core.Model/ViewModels/Extend/CourseAndScene.cs b/Tiobon.Core.Model/ViewModels/Extend/CourseAndScene.cs index 5d1b21e5..02ffd9b1 100644 --- a/Tiobon.Core.Model/ViewModels/Extend/CourseAndScene.cs +++ b/Tiobon.Core.Model/ViewModels/Extend/CourseAndScene.cs @@ -6,4 +6,13 @@ public class CourseAndScene public string CourseNo { get; set; } public string Type { get; set; } public string CourseName { get; set; } + public int RequiredCount { get; set; } = 0; + + public int ElectiveCount { get; set; } = 0; + public int CompleteCount { get; set; } = 0; + public int OpenClassCount { get; set; } = 0; + public decimal? TotalStudyDuration { get; set; } = 0; + public string AvgStudyDuration { get; set; } = "0"; + public decimal? AvgScore { get; set; } = 0; + public decimal PassPercent { get; set; } = 0; } diff --git a/Tiobon.Core.Services/CommonServices.cs b/Tiobon.Core.Services/CommonServices.cs index c77cc156..f2043418 100644 --- a/Tiobon.Core.Services/CommonServices.cs +++ b/Tiobon.Core.Services/CommonServices.cs @@ -858,8 +858,19 @@ public partial class CommonServices : BaseServices>, ICommon var index = -1; switch (param.menuName) { - case "F_SurveyQuestionPool": case "F_Training_CourseAndScene_Report": + { + 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.fnTitle = "分析"; } + toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "CopyYN").FirstOrDefault(); + if (toolbar != null) { toolbar.fnKey = "TBD4YN"; } + break; + } + case "F_SurveyQuestionPool": case "F_QuestionBank": toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "NewYN").FirstOrDefault(); if (toolbar != null) { toolbar.fnKey = "TBD1YN"; } diff --git a/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs b/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs index 997e86a9..4b2a4dc5 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs @@ -1,4 +1,5 @@ using NPOI.SS.UserModel; +using System.Net; using static Tiobon.Core.Model.Consts; namespace Tiobon.Core.Services; @@ -1408,6 +1409,57 @@ public class Ghre_CourseServices : BaseServices(sql1); + for (int i = 0; i < data.Count; i++) + { + data[i].RequiredCount = await Db.Queryable() + .Where(x => (x.CourseSceneId == data[i].Id || x.CourseId == data[i].Id) && x.OpenClassId == null && x.CourseType.Contains("Required")) + .CountAsync(); + + data[i].ElectiveCount = await Db.Queryable() + .Where(x => (x.CourseSceneId == data[i].Id || x.CourseId == data[i].Id) && x.OpenClassId == null && x.CourseType.Contains("Elective")) + .CountAsync(); + + + data[i].OpenClassCount = await Db.Queryable() + .Where(x => (x.CourseSceneId == data[i].Id || x.CourseId == data[i].Id) && x.OpenClassId != null) + .CountAsync(); + + data[i].CompleteCount = await Db.Queryable() + .Where(x => (x.CourseSceneId == data[i].Id || x.CourseId == data[i].Id) && x.CompleteStatus == DIC_STUDY_RECORD_STUDY_COMPLETE_STATUS.FINISHED) + .CountAsync(); + + var studyRecordIds = await Db.Queryable() + .Where(x => x.CourseSceneId == data[i].Id || x.CourseId == data[i].Id) + .Select(x => x.Id) + .ToListAsync(); + + data[i].TotalStudyDuration = await Db.Queryable() + .Where(x => x.StudyRecordId != null && studyRecordIds.Contains(x.StudyRecordId.Value)) + .SumAsync(x => x.StudyDuration); + data[i].TotalStudyDuration = data[i].TotalStudyDuration ?? 0; + if (data[i].TotalStudyDuration > 0) + { + var avgStudyDuration = data[i].TotalStudyDuration / (studyRecordIds.Count); + + data[i].AvgStudyDuration = avgStudyDuration.TrimDecimalString(2); + } + + data[i].AvgScore = await Db.Queryable() + .Where(x => x.StudyRecordId != null && studyRecordIds.Contains(x.StudyRecordId.Value)) + .AvgAsync(x => x.Score); + + data[i].AvgScore = data[i].AvgScore ?? 0; + + var examCount = await Db.Queryable() + .Where(x => x.StudyRecordId != null && studyRecordIds.Contains(x.StudyRecordId.Value)) + .CountAsync(); + var passCount = await Db.Queryable() + .Where(x => x.StudyRecordId != null && studyRecordIds.Contains(x.StudyRecordId.Value) && x.IsPass == true) + .CountAsync(); + if (passCount > 0 && examCount > 0) + data[i].PassPercent = passCount / examCount; + } + totalCount = await Db.Ado.GetIntAsync("SELECT COUNT(0) from Ghre_CourseScene_V A WHERE 1=1"); @@ -1615,6 +1667,7 @@ public class Ghre_CourseServices : BaseServices x.QuestionId == questionErrorRankings[i].Id).Count(); questionErrorRankings[i].ErrorCount = recordDetails.Where(x => x.QuestionId == questionErrorRankings[i].Id && x.IsCorrect != true).Count(); diff --git a/Tiobon.Core/Tiobon.Core.Model.xml b/Tiobon.Core/Tiobon.Core.Model.xml index 66975c7f..7d5b30aa 100644 --- a/Tiobon.Core/Tiobon.Core.Model.xml +++ b/Tiobon.Core/Tiobon.Core.Model.xml @@ -41045,7 +41045,7 @@ - 培训记录-学习状态 + 培训记录-完成状态