From bac00867161f23b32a4f0057c97ca52e8639bf49 Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Mon, 19 May 2025 17:17:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=BC=80=E7=8F=AD=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Ghre/Ghre_CourseServices.cs | 8 +- .../Ghre/Ghre_StudyRecordServices.cs | 183 +++++++++++------- 2 files changed, 115 insertions(+), 76 deletions(-) diff --git a/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs b/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs index a5d217ff..a7fbdaa4 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs @@ -1506,7 +1506,9 @@ public class Ghre_CourseServices : BaseServices().Where(x => x.CourseId == id && x.OpenClassId != null).CountAsync(); + var OpenClassCount = await Db.Queryable() + .Where(x => x.CourseId == id && x.OpenClassId != null) + .CountAsync(); data.OpenClassCount = OpenClassCount; var studyRecordIds = await Db.Queryable().Where(x => x.CourseId == id).Select(x => x.Id).ToListAsync(); @@ -1742,7 +1744,9 @@ public class Ghre_CourseServices : BaseServices().Where(x => x.CourseSceneId == id && x.OpenClassId != null).CountAsync(); + var OpenClassCount = await Db.Queryable() + .Where(x => x.CourseSceneId == id && x.OpenClassId != null) + .CountAsync(); data.OpenClassCount = OpenClassCount; var studyRecordIds = await Db.Queryable().Where(x => x.CourseSceneId == id).Select(x => x.Id).ToListAsync(); diff --git a/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs b/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs index 8e40c7f8..009faf41 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs @@ -1169,9 +1169,9 @@ FROM Ghre_OpenClass A LEFT JOIN Ghre_Course C ON A.LinkId = C.Id LEFT JOIN Ghre_CourseScene D ON A.LinkId = D.Id LEFT JOIN Ghre_ExamRecord E ON A.Id = E.OpenClassId AND E.StaffId = '{staffId}' - LEFT JOIN Ghre_StudyRecord F ON A.Id = F.OpenClassId And F.IsEnable=1 - LEFT JOIN Ghre_OpenClassFeedback G ON A.Id = G.OpenClassId AND G.Source = 'Trainee' AND G.StaffId = '9' -WHERE A.Status !='Temporary' AND A.IsEnable=1 AND ( EXISTS + LEFT JOIN Ghre_StudyRecord F ON A.Id = F.OpenClassId And F.IsEnable=1 AND F.StaffId = '{staffId}' + LEFT JOIN Ghre_OpenClassFeedback G ON A.Id = G.OpenClassId AND G.Source = 'Trainee' AND G.StaffId = '{staffId}' +WHERE A.Status !='Temporary' AND A.Status !='Close' AND A.IsEnable=1 AND ( EXISTS (SELECT 1 FROM Ghre_OpenClassStaff C WHERE C.OpenClassId = A.ID AND c.StaffId = '{staffId}') @@ -1311,75 +1311,108 @@ WHERE A.Status !='Temporary' AND A.IsEnable=1 AND ( EXISTS x.ShowStudyBtn = true; x.ShowExamBtn = true; } + if (openClassStaffs.Any(o => o.OpenClassId == x.Id)) + { + if (dt >= x.CourseBeginDate && dt <= x.CourseEndDate && (x.OpenClassStatus == "Publish" || x.OpenClassStatus == "Opening") && openClassStaffs.Any(o => o.OpenClassId == x.Id)) + x.DisableStudyBtn = false; - if (dt >= x.CourseBeginDate && dt <= x.CourseEndDate && (x.OpenClassStatus == "Publish" || x.OpenClassStatus == "Opening") && openClassStaffs.Any(o => o.OpenClassId == x.Id)) - x.DisableStudyBtn = false; - - if (x.CourseBeginDate != null && x.CourseEndDate != null) - x.CourseDateString = DateTimeHelper.ConvertToDayString(x.CourseBeginDate) + "~" + DateTimeHelper.ConvertToDayString(x.CourseEndDate); + if (x.CourseBeginDate != null && x.CourseEndDate != null) + x.CourseDateString = DateTimeHelper.ConvertToDayString(x.CourseBeginDate) + "~" + DateTimeHelper.ConvertToDayString(x.CourseEndDate); - if (x.IsRequireStudy == false) - x.ShowStudyBtn = false; + if (x.IsRequireStudy == false) + x.ShowStudyBtn = false; - if (dt >= x.CourseBeginDate && dt <= x.CourseEndDate) - x.DisableStudyBtn = false; - else - x.DisableStudyBtn = true; + if (dt >= x.CourseBeginDate && dt <= x.CourseEndDate) + x.DisableStudyBtn = false; + else + x.DisableStudyBtn = true; - if (!x.ExamId.IsNull()) - { - if (x.ExamBeginDate != null && x.ExamEndDate != null) - x.ExamDateString = DateTimeHelper.ConvertToDayString(x.ExamBeginDate) + "~" + DateTimeHelper.ConvertToDayString(x.ExamEndDate); - else x.ExamDateString = $"学完{x.AfterHowLong}天"; - } + if (!x.ExamId.IsNull()) + { + if (x.ExamBeginDate != null && x.ExamEndDate != null) + x.ExamDateString = DateTimeHelper.ConvertToDayString(x.ExamBeginDate) + "~" + DateTimeHelper.ConvertToDayString(x.ExamEndDate); + else x.ExamDateString = $"学完{x.AfterHowLong}天"; + } - //if (x.CourseBeginDate != null && x.CourseEndDate != null) - // if (x.StudyProgress >= 100 || !(x.CourseBeginDate.Value.Date <= DateTime.Now.Date && x.CourseEndDate.Value.Date >= DateTime.Now.Date)) - // x.DisableStudyBtn = true; - if (!x.ExamId.IsNull() && x.ExamBeginDate != null && x.ExamEndDate != null && x.ExamBeginDate <= dt && x.ExamEndDate >= dt) - x.DisableExamBtn = false; + //if (x.CourseBeginDate != null && x.CourseEndDate != null) + // if (x.StudyProgress >= 100 || !(x.CourseBeginDate.Value.Date <= DateTime.Now.Date && x.CourseEndDate.Value.Date >= DateTime.Now.Date)) + // x.DisableStudyBtn = true; + if (!x.ExamId.IsNull() && x.ExamBeginDate != null && x.ExamEndDate != null && x.ExamBeginDate <= dt && x.ExamEndDate >= dt) + x.DisableExamBtn = false; - if (x.StudyProgress >= 100 && x.ExamId.IsNotEmptyOrNull() && x.IsRequireStudy != false) - x.DisableExamBtn = false; + if (x.StudyProgress >= 100 && x.ExamId.IsNotEmptyOrNull() && x.IsRequireStudy != false) + x.DisableExamBtn = false; - if (x.FeedbackOrderId.IsNotEmptyOrNull()) - x.DisableFeedbackBtn = false; + if (x.FeedbackOrderId.IsNotEmptyOrNull() && x.OpenClassStatus == "Opening") + { - if (x.ShowFeedbackBtn == true && x.StudyProgress < 100) - { - x.DisableFeedbackBtn = true; - } + if (x.ShowFeedbackBtn == true && x.StudyProgress >= 100) + x.DisableFeedbackBtn = false; + } + else + x.ShowFeedbackBtn = false; - #region 处理学习进度 + #region 处理学习进度 - if (x.ExamId.IsNull()) - x.ShowExamBtn = false; + if (x.ExamId.IsNull()) + x.ShowExamBtn = false; - if (!x.ExamId.IsNull() && x.FeedbackOrderId.IsNull()) - { - if (x.ExamStatus == DIC_EXAM_RECORD_STATUS.WAIT || x.ExamStatus.IsNull()) - x.StudyProgress = x.StudyProgress / 2; - else if (x.ExamStatus == DIC_EXAM_RECORD_STATUS.EXAMING) - x.StudyProgress = 75; - else if (x.ExamStatus == DIC_EXAM_RECORD_STATUS.EXAM_END) - x.StudyProgress = 100; + //if (!x.ExamId.IsNull() && x.FeedbackOrderId.IsNull()) + //{ + // if (x.ExamStatus == DIC_EXAM_RECORD_STATUS.WAIT || x.ExamStatus.IsNull()) + // x.StudyProgress = x.StudyProgress / 2; + // else if (x.ExamStatus == DIC_EXAM_RECORD_STATUS.EXAMING) + // x.StudyProgress = 75; + // else if (x.ExamStatus == DIC_EXAM_RECORD_STATUS.EXAM_END) + // x.StudyProgress = 100; + //} + + //if (!x.ExamId.IsNull() && !x.FeedbackOrderId.IsNull()) + //{ + // if (x.ExamStatus == DIC_EXAM_RECORD_STATUS.WAIT) + // x.StudyProgress = x.StudyProgress / 3; + // else if (x.ExamStatus == DIC_EXAM_RECORD_STATUS.EXAMING) + // x.StudyProgress = 45; + // else if (x.ExamStatus == DIC_EXAM_RECORD_STATUS.EXAM_END) + // x.StudyProgress = 60; + //} + + //if (x.OpenClassFeedbackStatus.IsNotEmptyOrNull()) + // if (x.OpenClassFeedbackStatus == "N") + // x.StudyProgress = 83; + // else x.StudyProgress = 100; + if (x.IsRequireStudy == true) + { + if (x.ShowStudyBtn == true && x.ShowExamBtn == true && x.ShowFeedbackBtn == false) + { + if (x.ExamStatus == DIC_EXAM_RECORD_STATUS.WAIT || x.ExamStatus.IsNull()) + x.StudyProgress = x.StudyProgress / 2; + else if (x.ExamStatus == DIC_EXAM_RECORD_STATUS.EXAMING) + x.StudyProgress = 75; + else if (x.ExamStatus == DIC_EXAM_RECORD_STATUS.EXAM_END) + x.StudyProgress = 100; + } + else if (x.ShowStudyBtn == true && x.ShowExamBtn == true && x.ShowFeedbackBtn == true) + { + if (x.ExamStatus == DIC_EXAM_RECORD_STATUS.WAIT || x.ExamStatus.IsNull()) + x.StudyProgress = x.StudyProgress / 3; + else if (x.ExamStatus == DIC_EXAM_RECORD_STATUS.EXAMING) + x.StudyProgress = 50; + else if (x.ExamStatus == DIC_EXAM_RECORD_STATUS.EXAM_END) + x.StudyProgress = 75; + + if (x.OpenClassFeedbackStatus == "Y") + x.StudyProgress = 100; + } + } + #endregion } - - if (!x.ExamId.IsNull() && !x.FeedbackOrderId.IsNull()) + else { - if (x.ExamStatus == DIC_EXAM_RECORD_STATUS.WAIT) - x.StudyProgress = x.StudyProgress / 3; - else if (x.ExamStatus == DIC_EXAM_RECORD_STATUS.EXAMING) - x.StudyProgress = 45; - else if (x.ExamStatus == DIC_EXAM_RECORD_STATUS.EXAM_END) - x.StudyProgress = 60; + x.ShowExamBtn = false; + x.ShowFeedbackBtn = false; + x.ShowStudyBtn = false; } - - if (x.OpenClassFeedbackStatus.IsNotEmptyOrNull()) - if (x.OpenClassFeedbackStatus == "N") - x.StudyProgress = 83; - else x.StudyProgress = 100; - #endregion }); return new ServicePageResult(filter.pageNum, total, filter.pageSize, entitys); @@ -1423,7 +1456,9 @@ WHERE A.Status !='Temporary' AND A.IsEnable=1 AND ( EXISTS id = await base.Add(studyRecord); } else - id = await Db.Queryable().Where(x => x.OpenClassId == id || x.Id == id).Select(x => x.Id).FirstAsync(); + id = await Db.Queryable() + .Where(x => (x.OpenClassId == id || x.Id == id) && x.StaffId == App.User.StaffId) + .Select(x => x.Id).FirstAsync(); #endregion string sql = @$"SELECT A.Id, @@ -1770,23 +1805,23 @@ WHERE A.Id = '{id}'"; //var sql = $"UPDATE Ghre_StudyRecord SET StudyDuration = ISNULL(StudyDuration, 0)+{duration} WHERE Id='{studyRecordId}' AND StaffId='{staffId}'"; //await Db.Ado.ExecuteCommandAsync(sql); - var standDuration = await Db.Queryable() - .Where(x => x.Id == attachmentId) - .Select(x => x.LearnDuration) - .FirstAsync() ?? 1000000000; - - var studyDuration = await Db.Queryable() - .Where(x => x.StudyRecordId == studyRecordId && x.CourseWareAttachmentId == attachmentId) - .SumAsync(it => it.StudyDuration); + //var standDuration = await Db.Queryable() + // .Where(x => x.Id == attachmentId) + // .Select(x => x.LearnDuration) + // .FirstAsync() ?? 1000000000; - if (standDuration < (studyDuration + duration)) - duration = standDuration - studyDuration; + //var studyDuration = await Db.Queryable() + // .Where(x => x.StudyRecordId == studyRecordId && x.CourseWareAttachmentId == attachmentId) + // .SumAsync(it => it.StudyDuration); + //decimal? duration1 = 0; + //if (standDuration < (studyDuration + duration)) + // duration1 = standDuration - studyDuration; - if (duration > 0) - await Db.Updateable() - .SetColumns(it => new Ghre_StudyRecord() { StudyDuration = (it.StudyDuration ?? 0) + duration }, true) - .Where(it => it.Id == studyRecordId && it.StaffId == App.User.StaffId) - .ExecuteCommandAsync(); + //if (duration1 > 0) + await Db.Updateable() + .SetColumns(it => new Ghre_StudyRecord() { StudyDuration = (it.StudyDuration ?? 0) + duration }, true) + .Where(it => it.Id == studyRecordId && it.StaffId == App.User.StaffId) + .ExecuteCommandAsync(); await GenerateStaffStudyRecord(Db, studyRecordId, duration.Value, attachmentId);