diff --git a/Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamRecordController.cs b/Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamRecordController.cs index 0cdaa8d7..223e62fa 100644 --- a/Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamRecordController.cs +++ b/Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamRecordController.cs @@ -56,4 +56,16 @@ public class Ghre_ExamRecordController : BaseController + /// 获取考试信息 + /// + /// 学习记录ID/考试记录ID + /// + [HttpPost("QueryExam/{id}")] + public async Task> QueryExamAsync( long id) + { + return await _service.QueryExamAsync(id); + } } \ No newline at end of file diff --git a/Tiobon.Core.Api/Tiobon.Core.Model.xml b/Tiobon.Core.Api/Tiobon.Core.Model.xml index 8ac26bed..76e11b67 100644 --- a/Tiobon.Core.Api/Tiobon.Core.Model.xml +++ b/Tiobon.Core.Api/Tiobon.Core.Model.xml @@ -2640,6 +2640,11 @@ 试卷ID + + + 培训记录ID + + 员工ID @@ -8001,6 +8006,11 @@ 试卷ID + + + 培训记录ID + + 员工ID @@ -13020,6 +13030,86 @@ 学分 + + + 课程名称 + + + + + 考试名称 + + + + + 考试开始时间 + + + + + 考试结束时间 + + + + + Wait 等待考试, Examing 考试中, End 考试结束 + + + + + 剩余时间 + + + + + 头像 + + + + + 员工姓名 + + + + + 工号 + + + + + 部门 + + + + + 部门编号 + + + + + 最终得分 + + + + + 实际考试时长 + + + + + 可重考 + + + + + 出分中 + + + + + 出分时间 + + 员工ID diff --git a/Tiobon.Core.Api/Tiobon.Core.xml b/Tiobon.Core.Api/Tiobon.Core.xml index 542f0e98..1586af2b 100644 --- a/Tiobon.Core.Api/Tiobon.Core.xml +++ b/Tiobon.Core.Api/Tiobon.Core.xml @@ -841,6 +841,13 @@ + + + 获取考试信息 + + 学习记录ID/考试记录ID + + Ghre_ExamRecordDetail(Controller) diff --git a/Tiobon.Core.IServices/Ghre/IGhre_ExamRecordServices.cs b/Tiobon.Core.IServices/Ghre/IGhre_ExamRecordServices.cs index 0bacdfe9..e8d9b411 100644 --- a/Tiobon.Core.IServices/Ghre/IGhre_ExamRecordServices.cs +++ b/Tiobon.Core.IServices/Ghre/IGhre_ExamRecordServices.cs @@ -17,5 +17,7 @@ namespace Tiobon.Core.IServices Task> ExtendAsync(long examRecordId); Task CommentAsync(Ghre_ExamRecordExtend extend, long examRecordId); + + Task> QueryExamAsync(long id); } } \ No newline at end of file diff --git a/Tiobon.Core.Model/Base/Ghre/Ghre_ExamRecord.Dto.Base.cs b/Tiobon.Core.Model/Base/Ghre/Ghre_ExamRecord.Dto.Base.cs index 44b5d912..46508526 100644 --- a/Tiobon.Core.Model/Base/Ghre/Ghre_ExamRecord.Dto.Base.cs +++ b/Tiobon.Core.Model/Base/Ghre/Ghre_ExamRecord.Dto.Base.cs @@ -6,7 +6,7 @@ * * Ver 变更日期 负责人 变更内容 * ─────────────────────────────────── -*V0.01 2024/7/18 13:11:42 SimonHsiao 初版 +*V0.01 2024/7/24 13:42:13 SimonHsiao 初版 * * Copyright(c) 2024 Tiobon Corporation. All Rights Reserved. *┌──────────────────────────────────┐ @@ -32,6 +32,11 @@ namespace Tiobon.Core.Model.Models /// public long? ExamId { get; set; } + /// + /// 培训记录ID + /// + public long? StudyRecordId { get; set; } + /// /// 员工ID /// diff --git a/Tiobon.Core.Model/Models/Ghre/Ghre_ExamRecord.cs b/Tiobon.Core.Model/Models/Ghre/Ghre_ExamRecord.cs index 1188484a..3f0afb43 100644 --- a/Tiobon.Core.Model/Models/Ghre/Ghre_ExamRecord.cs +++ b/Tiobon.Core.Model/Models/Ghre/Ghre_ExamRecord.cs @@ -6,7 +6,7 @@ * * Ver 变更日期 负责人 变更内容 * ─────────────────────────────────── -*V0.01 2024/7/18 13:11:42 SimonHsiao 初版 +*V0.01 2024/7/24 13:42:13 SimonHsiao 初版 * * Copyright(c) 2024 Tiobon Corporation. All Rights Reserved. *┌──────────────────────────────────┐ @@ -34,6 +34,11 @@ namespace Tiobon.Core.Model.Models /// public long? ExamId { get; set; } + /// + /// 培训记录ID + /// + public long? StudyRecordId { get; set; } + /// /// 员工ID /// diff --git a/Tiobon.Core.Services/Ghre/Ghre_ExamRecordServices.cs b/Tiobon.Core.Services/Ghre/Ghre_ExamRecordServices.cs index d35557a7..c0c3b503 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_ExamRecordServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_ExamRecordServices.cs @@ -11,6 +11,7 @@ using System.Text.RegularExpressions; using System.Net; using Tiobon.Core.Common.Helper; using AgileObjects.AgileMapper.Extensions; +using Tiobon.Core.Common.DB.Dapper.Extensions; namespace Tiobon.Core.Services; @@ -354,36 +355,85 @@ public class Ghre_ExamRecordServices : BaseServices().AnyAsync(x => x.Id == id)) + //if (await Db.Queryable().AnyAsync(x => x.Id == id)) + //{ + // var examRecord = await Db.Queryable().FirstAsync(x => x.ExamId == id); + // if (examRecord != null) + // examRecordId = examRecord.Id; + // else + // { + // var insrt = new InsertGhre_ExamRecordInput() + // { + + // }; + // examRecordId = await base.Add(insrt); + // } + //} + + if (await Db.Queryable().AnyAsync(x => x.Id == id)) { - var examRecord = await Db.Queryable().FirstAsync(x => x.ExamId == id); + var examRecord = await Db.Queryable().FirstAsync(x => x.StudyRecordId == id); + if (examRecord != null) examRecordId = examRecord.Id; else { + + var studyRecord = await Db.Queryable().FirstAsync(x => x.Id == id); + string sql = @$"SELECT A.StaffId, + A.Source, + A.ExamId, + B.Id, + B.LinkType, + B.CourseId, + B.CourseSceneId, + B.ExamPaperId, + B.CoverUrl, + B.ExamNo, + B.ExamName, + B.DateType, + B.BeginTime, + B.EndTime, + B.AfterHowLong, + B.ExamMode, + B.ExamPlace, + B.IsLinkOpenClass, + B.OpenClassId, + B.Status + FROM Ghre_ExamStaff A + JOIN Ghre_Exam B + ON A.ExamId = B.Id + AND B.Status = 'Released' + AND A.IsEnable = B.IsEnable + AND B.CourseId = '{studyRecord.CourseId}' + WHERE A.IsEnable = 1 + AND ( B.DateType = 'AfterHowLong' + OR ( B.DateType = 'ExamDate' + AND B.BeginTime >= GETDATE () + AND B.EndTime <= GETDATE ())) + AND A.StaffId = {studyRecord.StaffId}"; + + var exam = await Db.Ado.SqlQuerySingleAsync(sql); + if (exam is null) + return ServiceResult.OprateFailed("该门课程勿需考试!"); + var insrt = new InsertGhre_ExamRecordInput() { - + ExamId = exam.Id, + StudyRecordId = studyRecord.Id, + StaffId = studyRecord.StaffId, + CourseSnapId = studyRecord.CourseSnapId, + ExamPaperId = exam.ExamPaperId, + ExamDate = DateTime.Now.Date, + RetakeTimes = 0, + Status = "Wait", + ScoreStatus = "NoScore" }; examRecordId = await base.Add(insrt); } } - if (await Db.Queryable().AnyAsync(x => x.Id == id)) - { - var studyRecord = await Db.Queryable().FirstAsync(x => x.Id == id); - - //if (examRecord != null) - // examRecordId = examRecord.Id; - //else - //{ - // var insrt = new InsertGhre_ExamRecordInput() - // { - - // }; - // examRecordId = await base.Add(insrt); - //} - } + if (examRecordId == 0) examRecordId = id; var records = await QueryFilterPage(body, $"Id='{examRecordId}'"); diff --git a/Tiobon.Core/Tiobon.Core.Model.xml b/Tiobon.Core/Tiobon.Core.Model.xml index 8ac26bed..76e11b67 100644 --- a/Tiobon.Core/Tiobon.Core.Model.xml +++ b/Tiobon.Core/Tiobon.Core.Model.xml @@ -2640,6 +2640,11 @@ 试卷ID + + + 培训记录ID + + 员工ID @@ -8001,6 +8006,11 @@ 试卷ID + + + 培训记录ID + + 员工ID @@ -13020,6 +13030,86 @@ 学分 + + + 课程名称 + + + + + 考试名称 + + + + + 考试开始时间 + + + + + 考试结束时间 + + + + + Wait 等待考试, Examing 考试中, End 考试结束 + + + + + 剩余时间 + + + + + 头像 + + + + + 员工姓名 + + + + + 工号 + + + + + 部门 + + + + + 部门编号 + + + + + 最终得分 + + + + + 实际考试时长 + + + + + 可重考 + + + + + 出分中 + + + + + 出分时间 + + 员工ID diff --git a/Tiobon.Core/Tiobon.Core.xml b/Tiobon.Core/Tiobon.Core.xml index 542f0e98..1586af2b 100644 --- a/Tiobon.Core/Tiobon.Core.xml +++ b/Tiobon.Core/Tiobon.Core.xml @@ -841,6 +841,13 @@ + + + 获取考试信息 + + 学习记录ID/考试记录ID + + Ghre_ExamRecordDetail(Controller)