From 81e1b63444d403ee59eaf4338d5e956f7a75cbf0 Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Fri, 2 Aug 2024 14:06:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=9F=A5=E7=9C=8B=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E5=AD=A6=E4=B9=A0=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Ghre/Ghre_StudyRecordController.cs | 16 ++ Tiobon.Core.Api/Tiobon.Core.xml | 8 + .../Ghre/IGhre_StudyRecordServices.cs | 10 +- .../Extend/Ghre_StudyRecordCourse.cs | 53 +++++++ .../Ghre/Ghre_CourseServices.cs | 10 ++ .../Ghre/Ghre_StudyRecordServices.cs | 150 ++++++++++++++++++ Tiobon.Core/Tiobon.Core.xml | 8 + 7 files changed, 251 insertions(+), 4 deletions(-) create mode 100644 Tiobon.Core.Model/ViewModels/Extend/Ghre_StudyRecordCourse.cs diff --git a/Tiobon.Core.Api/Controllers/Ghre/Ghre_StudyRecordController.cs b/Tiobon.Core.Api/Controllers/Ghre/Ghre_StudyRecordController.cs index 148c6e2b..fd01dcb5 100644 --- a/Tiobon.Core.Api/Controllers/Ghre/Ghre_StudyRecordController.cs +++ b/Tiobon.Core.Api/Controllers/Ghre/Ghre_StudyRecordController.cs @@ -38,4 +38,20 @@ public class Ghre_StudyRecordController : BaseController + /// 获取课程 + /// + /// + /// + /// + [HttpPost, Route("QueryCourse/{id}")] + public async Task> QueryCourse([FromBody] QueryBody body, long id) + { + return await _service.QueryCourse(body, id); + } + #endregion } \ No newline at end of file diff --git a/Tiobon.Core.Api/Tiobon.Core.xml b/Tiobon.Core.Api/Tiobon.Core.xml index 94b1f492..76d37dbe 100644 --- a/Tiobon.Core.Api/Tiobon.Core.xml +++ b/Tiobon.Core.Api/Tiobon.Core.xml @@ -947,6 +947,14 @@ + + + 获取课程 + + + + + 必选修规则(Controller) diff --git a/Tiobon.Core.IServices/Ghre/IGhre_StudyRecordServices.cs b/Tiobon.Core.IServices/Ghre/IGhre_StudyRecordServices.cs index 7ad173a5..1f4e925d 100644 --- a/Tiobon.Core.IServices/Ghre/IGhre_StudyRecordServices.cs +++ b/Tiobon.Core.IServices/Ghre/IGhre_StudyRecordServices.cs @@ -4,15 +4,17 @@ using Tiobon.Core.Model; using Tiobon.Core.Model.Models; namespace Tiobon.Core.IServices -{ - /// - /// 培训记录(自定义服务接口) - /// +{ + /// + /// 培训记录(自定义服务接口) + /// public interface IGhre_StudyRecordServices :IBaseServices { Task> QueryESSSearchFields(QueryBody body); Task> QueryESS(QueryBody filter, string condition, bool? IsEnable = true); + + Task> QueryCourse(QueryBody body, long id); } } \ No newline at end of file diff --git a/Tiobon.Core.Model/ViewModels/Extend/Ghre_StudyRecordCourse.cs b/Tiobon.Core.Model/ViewModels/Extend/Ghre_StudyRecordCourse.cs new file mode 100644 index 00000000..041407c1 --- /dev/null +++ b/Tiobon.Core.Model/ViewModels/Extend/Ghre_StudyRecordCourse.cs @@ -0,0 +1,53 @@ +using Tiobon.Core.Model.Models; + +namespace Tiobon.Core.Model; + +public class Ghre_StudyRecordCourse +{ + public long Id { get; set; } + public long? CourseId { get; set; } + public long? CourseSceneId { get; set; } + public string CourseName { get; set; } + public bool UseDefaultCoverImage { get; set; } + public string DefaultCoverImageName { get; set; } + public string CoverUrl { get; set; } + public int StandardHour { get; set; } + public int CreditPoints { get; set; } + public string CourseDateString { get; set; } + public int StudyProgress { get; set; } = 0; + public string CourseRemarkSz { get; set; } + public string TeacherName { get; set; } + public string TeacherEName { get; set; } + public string TeacherPhotoUrl { get; set; } + public string DeptOrSchoolName { get; set; } + public string TeacherRemarkSz { get; set; } + + + public List CourseWareList { get; set; } + + + public List CourseTeacherList { get; set; } +} +public class Ghre_StudyRecordCourseWare +{ + public long Id { get; set; } + public string CourseName { get; set; } + public long? CourseId { get; set; } + public string Source { get; set; } + public string Link { get; set; } + + public List Attachments { get; set; } + +} + +public class Ghre_StudyRecordCourseTeacher +{ + public long Id { get; set; } + public string TeacherName { get; set; } + public string TeacherEName { get; set; } + public string TeacherPhotoUrl { get; set; } + public string DeptOrSchoolName { get; set; } + public string TeacherRemarkSz { get; set; } + + public string CourseName { get; set; } +} diff --git a/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs b/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs index aa163495..a6a9ea93 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs @@ -367,6 +367,16 @@ public class Ghre_CourseServices : BaseServices().FirstAsync(x => x.StaffId == entity.TeacherId); + if (!teacher.IsNull()) + { + entity.SchoolTeacherId = teacher.Id; + //entity.SchoolId = teacher.SchoolId; + } + } return await base.Add(entity); } diff --git a/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs b/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs index 924057bd..63f871ef 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs @@ -300,5 +300,155 @@ namespace Tiobon.Core.Services } #endregion + + + #region 获取课程 + /// + /// 获取课程 + /// + /// + /// + public async Task> QueryCourse(QueryBody body, long id) + { + var course = new Ghre_StudyRecordCourse(); + + string sql = @$"SELECT A.Id, + A.CourseId, + A.CourseSceneId, + ISNULL (B.CourseName, G.SceneName) CourseName, + B.UseDefaultCoverImage, + B.DefaultCoverImageName, + B.CoverUrl, + B.SchoolTeacherId, + B.SchoolId, + B.InOrOut, + E.TeacherName, + -- E.TeacherEName, + + + CASE B.InOrOut + WHEN 'In' THEN C.StaffEname + WHEN 'Out' THEN NULL + ELSE NULL + END AS TeacherEName, + E.PhotoUrl TeacherPhotoUrl, + CASE B.InOrOut + WHEN 'In' + THEN + dbo.FO_DeptInfo (E.DeptID, + getdate (), + 1, + 'DeptFullPateName') + WHEN 'Out' + THEN + F.SchoolName + ELSE + NULL + END AS DeptOrSchoolName, + E.SkillPoints TeacherRemarkSz, + B.StandardHour, + B.CreditPoints, + B.Outline CourseRemarkSz, + A.StudyProgress + FROM Ghre_StudyRecord A + LEFT JOIN Ghre_Course B ON A.CourseId = B.Id + LEFT JOIN Ghra_Staff c ON B.TeacherId = c.StaffID + LEFT JOIN Ghre_Teacher E ON B.SchoolTeacherId = E.Id + LEFT JOIN Ghre_School F ON B.SchoolId = F.Id + LEFT JOIN Ghre_CourseScene G ON A.CourseSceneId = G.Id + WHERE A.Id = '{id}'"; + course = await Db.Ado.SqlQuerySingleAsync(sql); + + if (course.CourseSceneId.IsNull()) + { + sql = @$"SELECT A.Id, A.Source, A.Link + FROM Ghre_CourseWare A + WHERE A.CourseIds LIKE '%{course.CourseId}%' AND A.IsEnable = 1"; + + course.CourseWareList = await Db.Ado.SqlQueryAsync(sql); + + course.CourseWareList.ForEach(x => + { + x.CourseId = course.CourseId; + x.CourseName = course.CourseName; + }); + course.CourseTeacherList = + [ + new Ghre_StudyRecordCourseTeacher() { + TeacherName = course.TeacherName, + TeacherEName = course.TeacherEName, + TeacherPhotoUrl = course.TeacherPhotoUrl, + DeptOrSchoolName = course.DeptOrSchoolName, + TeacherRemarkSz = course.TeacherRemarkSz + } + ]; + } + else + { + course.CourseWareList = new List(); + course.CourseTeacherList = new List(); + var courses = await Db.Queryable().Where(x => x.CourseSceneId == course.CourseSceneId && x.Status == Consts.DIC_COURSE_STATUS.RELEASED).ToListAsync(); + + for (int i = 0; i < courses.Count; i++) + { + var course1 = courses[i]; + + sql = @$"SELECT A.Id, A.Source, A.Link + FROM Ghre_CourseWare A + WHERE A.CourseIds LIKE '%{course1.Id}%' AND A.IsEnable = 1"; + + var courseWareList = await Db.Ado.SqlQueryAsync(sql); + courseWareList.ForEach(x => + { + x.CourseId = course.CourseId; + x.CourseName = course.CourseName; + }); + course.CourseWareList.AddRange(courseWareList); + + + + sql = $@"SELECT a.ID, + C.TeacherName, + CASE A.InOrOut + WHEN 'In' THEN B.StaffEname + WHEN 'Out' THEN NULL + ELSE NULL + END AS TeacherEName, + C.PhotoUrl TeacherPhotoUrl, + CASE A.InOrOut + WHEN 'In' + THEN + dbo.FO_DeptInfo (b.DeptID, + getdate (), + 1, + 'DeptFullPateName') + WHEN 'Out' + THEN + D.SchoolName + ELSE + NULL + END AS DeptOrSchoolName, + c.SkillPoints TeacherRemarkSz, + a.CourseName + FROM Ghre_Course A + LEFT JOIN Ghra_Staff B ON A.TeacherId = B.StaffID + LEFT JOIN Ghre_Teacher C ON A.SchoolTeacherId = C.Id + LEFT JOIN Ghre_School D ON C.SchoolId = D.Id + WHERE a.id = '{course1.Id}'"; + + course.CourseTeacherList.Add(await Db.Ado.SqlQuerySingleAsync(sql)); + + } + } + + for (int j = 0; j < course.CourseWareList.Count; j++) + { + course.CourseWareList[j].Attachments = await Db.Queryable().Where(x => x.CourseWareId == course.CourseWareList[j].Id).ToListAsync(); + } + + return ServiceResult.OprateSuccess("查询成功!", course); + } + + #endregion } } \ No newline at end of file diff --git a/Tiobon.Core/Tiobon.Core.xml b/Tiobon.Core/Tiobon.Core.xml index 94b1f492..76d37dbe 100644 --- a/Tiobon.Core/Tiobon.Core.xml +++ b/Tiobon.Core/Tiobon.Core.xml @@ -947,6 +947,14 @@ + + + 获取课程 + + + + + 必选修规则(Controller)