From 33bc76a753638c67dabef8633965ebe57b12e9b3 Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Mon, 31 Mar 2025 13:18:10 +0800 Subject: [PATCH] =?UTF-8?q?ESS=E7=AB=AF=E9=92=88=E5=AF=B9=E6=AF=8F?= =?UTF-8?q?=E4=B8=AA=E9=99=84=E4=BB=B6=E7=9A=84=E5=B1=95=E7=A4=BA=E5=BA=94?= =?UTF-8?q?=E5=AD=A6=E4=B9=A0=E6=97=B6=E9=95=BF=E3=80=81=E5=B7=B2=E5=AD=A6?= =?UTF-8?q?=E4=B9=A0=E6=97=B6=E9=95=BF=E3=80=81=E5=AD=A6=E4=B9=A0=E5=AE=8C?= =?UTF-8?q?=E6=88=90=E7=99=BE=E5=88=86=E6=AF=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tiobon.Core.Api/Tiobon.Core.Model.xml | 11 ++++ Tiobon.Core.Common/Helper/UtilHelper.cs | 51 +++++++++++++++++++ .../Ghre/Ghre_CourseWare.Dto.InsertInput.cs | 10 ++-- .../Ghre_CourseWareAttachment.Dto.View.cs | 6 +++ .../Extend/Ghre_StudyRecordCourse.cs | 2 +- Tiobon.Core.Services/CommonServices.cs | 9 +++- .../Ghre/Ghre_CourseWareServices.cs | 1 + .../Ghre/Ghre_StudyRecordServices.cs | 42 ++++++++++++++- Tiobon.Core/Tiobon.Core.Model.xml | 21 ++++++++ 9 files changed, 147 insertions(+), 6 deletions(-) diff --git a/Tiobon.Core.Api/Tiobon.Core.Model.xml b/Tiobon.Core.Api/Tiobon.Core.Model.xml index 19b95d82..c1e4420d 100644 --- a/Tiobon.Core.Api/Tiobon.Core.Model.xml +++ b/Tiobon.Core.Api/Tiobon.Core.Model.xml @@ -15382,6 +15382,12 @@ 课件 (Dto.InsertInput) + + + + 已学习进度百分比 + + 课件附件 (Dto.InsertInput) @@ -31967,6 +31973,11 @@ 修改信息 + + + 已学习进度百分比 + + 学分记录(Dto.View) diff --git a/Tiobon.Core.Common/Helper/UtilHelper.cs b/Tiobon.Core.Common/Helper/UtilHelper.cs index 61d4b46e..c915efac 100644 --- a/Tiobon.Core.Common/Helper/UtilHelper.cs +++ b/Tiobon.Core.Common/Helper/UtilHelper.cs @@ -157,6 +157,57 @@ public static class UtilHelper return errorValue; } + + + #region 去除后面多余的零 + /// + /// 去除后面多余的零 + /// + /// + /// + public static string RemoveZero(this decimal? dValue) + { + if (dValue.IsNullOrEmpty()) + return null; + return RemoveZero(dValue.Value); + } + ///// + ///// 去除后面多余的零 + ///// + ///// + ///// + //public static string RemoveZero(decimal? dValue) + //{ + // if (dValue.IsNullOrEmpty()) + // return null; + // return RemoveZero(dValue.Value); + //} + /// + /// 去除后面多余的零 + /// + /// + /// + public static string RemoveZero(decimal dValue) + { + string sResult = dValue.ToString(); + if (sResult.IndexOf(".") < 0) + return sResult; + int iIndex = sResult.Length - 1; + for (int i = sResult.Length - 1; i >= 0; i--) + { + if (sResult.Substring(i, 1) != "0") + { + iIndex = i; + break; + } + } + sResult = sResult.Substring(0, iIndex + 1); + if (sResult.EndsWith(".")) + sResult = sResult.Substring(0, sResult.Length - 1); + return sResult; + } + #endregion + /// /// /// diff --git a/Tiobon.Core.Model/Insert/Ghre/Ghre_CourseWare.Dto.InsertInput.cs b/Tiobon.Core.Model/Insert/Ghre/Ghre_CourseWare.Dto.InsertInput.cs index 3b2d7d65..f7427b30 100644 --- a/Tiobon.Core.Model/Insert/Ghre/Ghre_CourseWare.Dto.InsertInput.cs +++ b/Tiobon.Core.Model/Insert/Ghre/Ghre_CourseWare.Dto.InsertInput.cs @@ -37,8 +37,12 @@ public class Ghre_CourseWareLink public string LinkAddress { get; set; } /// - /// 学习时长(分钟) - /// - [Display(Name = "LearnDuration"), Description("学习时长(分钟)"), Column(TypeName = "decimal(20,2)")] + /// 学习时长(分钟) public decimal? LearnDuration { get; set; } + + /// + /// 已学习进度百分比 + /// + public decimal? HasLearnDuration { get; set; } + public decimal? HasLearnPercent { get; set; } } \ No newline at end of file diff --git a/Tiobon.Core.Model/View/Ghre/Ghre_CourseWareAttachment.Dto.View.cs b/Tiobon.Core.Model/View/Ghre/Ghre_CourseWareAttachment.Dto.View.cs index 525fd990..938fbe49 100644 --- a/Tiobon.Core.Model/View/Ghre/Ghre_CourseWareAttachment.Dto.View.cs +++ b/Tiobon.Core.Model/View/Ghre/Ghre_CourseWareAttachment.Dto.View.cs @@ -31,4 +31,10 @@ public class Ghre_CourseWareAttachmentDto : Ghre_CourseWareAttachment /// 修改信息 /// public string UpdateDataInfo { get; set; } + public decimal? HasLearnDuration { get; set; } + + /// + /// 已学习进度百分比 + /// + public decimal? HasLearnPercent { get; set; } } diff --git a/Tiobon.Core.Model/ViewModels/Extend/Ghre_StudyRecordCourse.cs b/Tiobon.Core.Model/ViewModels/Extend/Ghre_StudyRecordCourse.cs index ec448bbb..a5e44902 100644 --- a/Tiobon.Core.Model/ViewModels/Extend/Ghre_StudyRecordCourse.cs +++ b/Tiobon.Core.Model/ViewModels/Extend/Ghre_StudyRecordCourse.cs @@ -43,7 +43,7 @@ public class Ghre_StudyRecordCourseWare public string Source { get; set; } public string Link { get; set; } - public List Attachments { get; set; } + public List Attachments { get; set; } public List Links { get; set; } diff --git a/Tiobon.Core.Services/CommonServices.cs b/Tiobon.Core.Services/CommonServices.cs index 7a177704..adcba07f 100644 --- a/Tiobon.Core.Services/CommonServices.cs +++ b/Tiobon.Core.Services/CommonServices.cs @@ -1051,7 +1051,14 @@ public partial class CommonServices : BaseServices>, ICommon index = result.JM_PageControlT1.Toolbar.FindIndex(x => x.fnKey == "BatchUpdateYN"); if (index >= 0) result.JM_PageControlT1.Toolbar.RemoveAt(index); - + 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.Insert(0, new Toolbar() { display = true, diff --git a/Tiobon.Core.Services/Ghre/Ghre_CourseWareServices.cs b/Tiobon.Core.Services/Ghre/Ghre_CourseWareServices.cs index 4a057442..4cfbe89e 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_CourseWareServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_CourseWareServices.cs @@ -127,6 +127,7 @@ public class Ghre_CourseWareServices : BaseServices() + .Where(x => x.StudyRecordId == id) + .GroupBy(x => new { x.CourseWareAttachmentId, x.CourseWareId }) + .Select(x => new + { + x.CourseWareAttachmentId, + x.CourseWareId, + StudyDuration = SqlFunc.AggregateSumNoNull(x.StudyDuration) + }) + .ToListAsync(); + for (int j = 0; j < course.CourseWareList.Count; j++) { var attachments = await Db.Queryable().Where(x => x.CourseWareId == course.CourseWareList[j].Id).ToListAsync(); - course.CourseWareList[j].Attachments = attachments.Where(x => x.AttachFileExtension != "http").OrderBy(x => x.SortNo).ToList(); + + var attachmentDtos = attachments.Where(x => x.AttachFileExtension != "http").OrderBy(x => x.SortNo).ToList(); + + course.CourseWareList[j].Attachments = Mapper.Map(attachmentDtos).ToANew>(); if (course.CourseWareList[j].Attachments != null && course.CourseWareList[j].Attachments.Any()) course.CourseWareList[j].Attachments.ForEach(x => x.RelativePath = "/Advanced" + x.RelativePath); + course.CourseWareList[j].Attachments.ForEach(x => + { + x.HasLearnDuration = details.FirstOrDefault(o => o.CourseWareAttachmentId == x.Id)?.StudyDuration ?? 0; + if (x.HasLearnDuration != 0 && x.LearnDuration != 0) + { + x.HasLearnPercent = (x.HasLearnDuration / x.LearnDuration) * 100; + if (x.HasLearnPercent > 100) + x.HasLearnPercent = 100; + x.HasLearnPercent = x.HasLearnPercent.RemoveZero().ObjToDecimal(); + } + }); + course.CourseWareList[j].Links = attachments .Where(x => x.AttachFileExtension == "http") .OrderBy(x => x.SortNo) @@ -1553,7 +1580,20 @@ WHERE A.Id = '{id}'"; Id = x.Id, LinkName = x.AttachmentName, LinkAddress = x.RelativePath, + LearnDuration = x.LearnDuration }).ToList(); + + course.CourseWareList[j].Links.ForEach(x => + { + x.HasLearnDuration = details.FirstOrDefault(o => o.CourseWareAttachmentId == x.Id)?.StudyDuration ?? 0; + if (x.HasLearnDuration != 0 && x.LearnDuration != 0) + { + x.HasLearnPercent = (x.HasLearnDuration / x.LearnDuration) * 100; + if (x.HasLearnPercent > 100) + x.HasLearnPercent = 100; + x.HasLearnPercent = x.HasLearnPercent.RemoveZero().ObjToDecimal(); + } + }); } if (course.CourseBeginTime != null && course.CourseEndTime != null) diff --git a/Tiobon.Core/Tiobon.Core.Model.xml b/Tiobon.Core/Tiobon.Core.Model.xml index e77f05f3..c1e4420d 100644 --- a/Tiobon.Core/Tiobon.Core.Model.xml +++ b/Tiobon.Core/Tiobon.Core.Model.xml @@ -3590,6 +3590,11 @@ 排序 + + + 学习时长(分钟) + + 学分记录 (Dto.Base) @@ -15377,6 +15382,12 @@ 课件 (Dto.InsertInput) + + + + 已学习进度百分比 + + 课件附件 (Dto.InsertInput) @@ -19541,6 +19552,11 @@ 排序 + + + 学习时长(分钟) + + 学分记录 (Model) @@ -31957,6 +31973,11 @@ 修改信息 + + + 已学习进度百分比 + + 学分记录(Dto.View)