From 9d1c279b4b30aeec65868dba059dc6f01fa5c690 Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Wed, 21 May 2025 13:44:43 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=9C=BA=E6=99=AF=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=9C=BA=E6=99=AF=E8=AF=B4=E6=98=8E=E7=BB=B4=E6=8A=A4?= =?UTF-8?q?=20=E8=AF=BE=E7=A8=8B=E8=AF=A6=E6=83=85=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=BF=94=E5=9B=9E=20=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E5=9C=BA=E6=99=AF=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tiobon.Core.Api/Tiobon.Core.Model.xml | 10 + .../Base/Ghre/Ghre_CourseScene.Dto.Base.cs | 8 +- .../Models/Ghre/Ghre_CourseScene.cs | 8 +- .../Extend/Ghre_StudyRecordCourse.cs | 2 +- .../Ghre/Ghre_ExamRecordServices.cs | 217 +++++++++++++----- .../Ghre/Ghre_StudyRecordServices.cs | 3 +- Tiobon.Core/Tiobon.Core.Model.xml | 10 + 7 files changed, 194 insertions(+), 64 deletions(-) diff --git a/Tiobon.Core.Api/Tiobon.Core.Model.xml b/Tiobon.Core.Api/Tiobon.Core.Model.xml index 0f29892b..1507345f 100644 --- a/Tiobon.Core.Api/Tiobon.Core.Model.xml +++ b/Tiobon.Core.Api/Tiobon.Core.Model.xml @@ -3700,6 +3700,11 @@ 学分规则ID + + + 场景说明 + + 课程列表 @@ -23217,6 +23222,11 @@ 学分规则ID + + + 场景说明 + + Ghre_CourseSnap (Model) diff --git a/Tiobon.Core.Model/Base/Ghre/Ghre_CourseScene.Dto.Base.cs b/Tiobon.Core.Model/Base/Ghre/Ghre_CourseScene.Dto.Base.cs index c78af7a5..be8dc7e5 100644 --- a/Tiobon.Core.Model/Base/Ghre/Ghre_CourseScene.Dto.Base.cs +++ b/Tiobon.Core.Model/Base/Ghre/Ghre_CourseScene.Dto.Base.cs @@ -6,7 +6,7 @@ * * Ver 变更日期 负责人 变更内容 * ─────────────────────────────────── -*V0.01 2025/4/8 17:21:17 SimonHsiao 初版 +*V0.01 2025/5/21 11:04:51 SimonHsiao 初版 * * Copyright(c) 2025 Tiobon Corporation. All Rights Reserved. *┌──────────────────────────────────┐ @@ -171,6 +171,12 @@ public class Ghre_CourseSceneBase /// public long? CreditRuleId { get; set; } + /// + /// 场景说明 + /// + [Display(Name = "SceneDescription"), Description("场景说明"), MaxLength(200, ErrorMessage = "场景说明 不能超过 200 个字符")] + public string SceneDescription { get; set; } + /// /// 课程列表 /// diff --git a/Tiobon.Core.Model/Models/Ghre/Ghre_CourseScene.cs b/Tiobon.Core.Model/Models/Ghre/Ghre_CourseScene.cs index 047b4e16..6dbe84d8 100644 --- a/Tiobon.Core.Model/Models/Ghre/Ghre_CourseScene.cs +++ b/Tiobon.Core.Model/Models/Ghre/Ghre_CourseScene.cs @@ -6,7 +6,7 @@ * * Ver 变更日期 负责人 变更内容 * ─────────────────────────────────── -*V0.01 2025/4/8 17:21:17 SimonHsiao 初版 +*V0.01 2025/5/21 11:04:51 SimonHsiao 初版 * * Copyright(c) 2025 Tiobon Corporation. All Rights Reserved. *┌──────────────────────────────────┐ @@ -171,4 +171,10 @@ public class Ghre_CourseScene : BasePoco /// 学分规则ID /// public long? CreditRuleId { get; set; } + + /// + /// 场景说明 + /// + [Display(Name = "SceneDescription"), Description("场景说明"), MaxLength(200, ErrorMessage = "场景说明 不能超过 200 个字符")] + public string SceneDescription { get; set; } } diff --git a/Tiobon.Core.Model/ViewModels/Extend/Ghre_StudyRecordCourse.cs b/Tiobon.Core.Model/ViewModels/Extend/Ghre_StudyRecordCourse.cs index a5e44902..df4b16e1 100644 --- a/Tiobon.Core.Model/ViewModels/Extend/Ghre_StudyRecordCourse.cs +++ b/Tiobon.Core.Model/ViewModels/Extend/Ghre_StudyRecordCourse.cs @@ -27,7 +27,7 @@ public class Ghre_StudyRecordCourse public decimal? CourseStandardDuration1 { get; set; } public string StudyDuration { get; set; } public string CourseStandardDuration { get; set; } - + public string SceneDescription { get; set; } public List CourseWareList { get; set; } public List CourseRemarkSzs { get; set; } diff --git a/Tiobon.Core.Services/Ghre/Ghre_ExamRecordServices.cs b/Tiobon.Core.Services/Ghre/Ghre_ExamRecordServices.cs index 4900372f..06cc8f36 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_ExamRecordServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_ExamRecordServices.cs @@ -1607,85 +1607,182 @@ public class Ghre_ExamRecordServices : BaseServices(); - var rules = await Db.Queryable().Where(x => x.SendRule == "ExamPass").ToListAsync(); - for (int i = 0; i < records.Count; i++) + var rules = new List(); + if (records.Any()) { - var record = records[i]; - if (record.CourseId.IsNotEmptyOrNull()) - { - var rules1 = rules.Where(x => x.CourseId1 != null && x.CourseId1.Contains(record.CourseId.ObjToString())).ToList(); - for (int j = 0; j < rules1.Count; j++) + var certificates = new List(); + rules = await Db.Queryable().Where(x => x.SendRule == "ExamPass").ToListAsync(); + for (int i = 0; i < records.Count; i++) + { + var record = records[i]; + if (record.CourseId.IsNotEmptyOrNull()) { - var rule = rules1[j]; - var courseIds = JsonHelper.JsonToObj>(rule.CourseId1); - courseIds = courseIds.Distinct().ToList(); - if (courseIds.Any()) + var rules1 = rules.Where(x => x.CourseId1 != null && x.CourseId1.Contains(record.CourseId.ObjToString())).ToList(); + + for (int j = 0; j < rules1.Count; j++) { - if (courseIds.Count() == - await Db.Queryable() - .Where(x => - x.ValidBeginTime != null && - x.ValidEndTime != null && - x.ValidBeginTime <= now && - x.ValidEndTime >= now && - x.StaffId == record.StaffId && - x.CourseId != null && - x.IsPass == true && - courseIds.Contains(x.CourseId.Value)).CountAsync()) + var rule = rules1[j]; + var courseIds = JsonHelper.JsonToObj>(rule.CourseId1); + courseIds = courseIds.Distinct().ToList(); + if (courseIds.Any()) { - string ValidityPeriod = string.Empty; - DateTime? ValidityPeriodTime = null; - - if (rule.ValidityType == "StaticDuration" && rule.StaticNum != null) + if (courseIds.Count() == + await Db.Queryable() + .Where(x => + x.ValidBeginTime != null && + x.ValidEndTime != null && + x.ValidBeginTime <= now && + x.ValidEndTime >= now && + x.StaffId == record.StaffId && + x.CourseId != null && + x.IsPass == true && + courseIds.Contains(x.CourseId.Value)).CountAsync()) { - ValidityPeriodTime = now.AddDays(rule.StaticNum.Value); - ValidityPeriod = DateTimeHelper.ConvertToOnlySecondString(ValidityPeriodTime); + string ValidityPeriod = string.Empty; + DateTime? ValidityPeriodTime = null; + + if (rule.ValidityType == "StaticDuration" && rule.StaticNum != null) + { + ValidityPeriodTime = now.AddDays(rule.StaticNum.Value); + ValidityPeriod = DateTimeHelper.ConvertToOnlySecondString(ValidityPeriodTime); + } + else if (rule.ValidityType == "Option" && rule.ValidityTime != null) + { + ValidityPeriodTime = rule.ValidityTime; + ValidityPeriod = DateTimeHelper.ConvertToSecondString(ValidityPeriodTime); + + } + else if (rule.ValidityType == "Unlimited") + { + ValidityPeriodTime = DateTime.MaxValue; + ValidityPeriod = "长期"; + } + + //发放证书 + certificates.Add(new Ghre_Certificate() + { + CertificateRuleId = rule.Id, + StaffId = record.StaffId, + CourseId = record.CourseId, + AwardDate = now, + ValidityPeriod = ValidityPeriod, + ValidityPeriodTime = ValidityPeriodTime, + Reverse1 = "考试通过发放" + + }); } - else if (rule.ValidityType == "Option" && rule.ValidityTime != null) - { - ValidityPeriodTime = rule.ValidityTime; - ValidityPeriod = DateTimeHelper.ConvertToSecondString(ValidityPeriodTime); + } + } - } - else if (rule.ValidityType == "Unlimited") - { - ValidityPeriodTime = DateTime.MaxValue; - ValidityPeriod = "长期"; - } + } + else if (record.CourseSceneId.IsNotEmptyOrNull()) + { - //发放证书 - certificates.Add(new Ghre_Certificate() - { - CertificateRuleId = rule.Id, - StaffId = record.StaffId, - CourseId = record.CourseId, - AwardDate = now, - ValidityPeriod = ValidityPeriod, - ValidityPeriodTime = ValidityPeriodTime, - Reverse1 = "考试通过发放" + } + record.IsIssueCertificate = true; + } - }); + await Db.Insertable(certificates).ExecuteReturnSnowflakeIdListAsync(); + await Db.Updateable(records) + .UpdateColumns(it => new { it.IsIssueCertificate }, true) + .ExecuteCommandAsync(); + } + if (await Db.Queryable().Where(x => x.SendRule == "CourseFinish").AnyAsync() + && await Db.Queryable() + .Where(x => + x.StudyStatus == "HasFinish" && + (x.IsIssueCertificate == null || x.IsIssueCertificate == false)) + .AnyAsync()) + { + + var studyRecords = await Db.Queryable() + .Where(x => + x.StudyStatus == "HasFinish" && + (x.IsIssueCertificate == null || x.IsIssueCertificate == false)) + .ToListAsync(); + + rules = await Db.Queryable().Where(x => x.SendRule == "CourseFinish").ToListAsync(); + var certificates = new List(); + + for (int i = 0; i < studyRecords.Count; i++) + { + var record = studyRecords[i]; + if (record.CourseId.IsNotEmptyOrNull()) + { + var rules1 = rules.Where(x => x.CourseId1 != null && x.CourseId1.Contains(record.CourseId.ObjToString())).ToList(); + + for (int j = 0; j < rules1.Count; j++) + { + var rule = rules1[j]; + var courseIds = JsonHelper.JsonToObj>(rule.CourseId1); + courseIds = courseIds.Distinct().ToList(); + if (courseIds.Any()) + { + if (courseIds.Count() == + await Db.Queryable() + .Where(x => + x.ValidBeginTime != null && + x.ValidEndTime != null && + x.ValidBeginTime <= now && + x.ValidEndTime >= now && + x.StaffId == record.StaffId && + x.CourseId != null && + x.IsPass == true && + courseIds.Contains(x.CourseId.Value)).CountAsync()) + { + string ValidityPeriod = string.Empty; + DateTime? ValidityPeriodTime = null; + + if (rule.ValidityType == "StaticDuration" && rule.StaticNum != null) + { + ValidityPeriodTime = now.AddDays(rule.StaticNum.Value); + ValidityPeriod = DateTimeHelper.ConvertToOnlySecondString(ValidityPeriodTime); + } + else if (rule.ValidityType == "Option" && rule.ValidityTime != null) + { + ValidityPeriodTime = rule.ValidityTime; + ValidityPeriod = DateTimeHelper.ConvertToSecondString(ValidityPeriodTime); + + } + else if (rule.ValidityType == "Unlimited") + { + ValidityPeriodTime = DateTime.MaxValue; + ValidityPeriod = "长期"; + } + + //发放证书 + certificates.Add(new Ghre_Certificate() + { + CertificateRuleId = rule.Id, + StaffId = record.StaffId, + CourseId = record.CourseId, + AwardDate = now, + ValidityPeriod = ValidityPeriod, + ValidityPeriodTime = ValidityPeriodTime, + Reverse1 = "考试通过发放" + + }); + } } } + } + else if (record.CourseSceneId.IsNotEmptyOrNull()) + { + } + record.IsIssueCertificate = true; } - else if (record.CourseSceneId.IsNotEmptyOrNull()) - { - } - record.IsIssueCertificate = true; + + await Db.Insertable(certificates).ExecuteReturnSnowflakeIdListAsync(); + await Db.Updateable(records) + .UpdateColumns(it => new { it.IsIssueCertificate }, true) + .ExecuteCommandAsync(); } - await Db.Insertable(certificates).ExecuteReturnSnowflakeIdListAsync(); - await Db.Updateable(records) - .UpdateColumns(it => new { it.IsIssueCertificate }, true) - .ExecuteCommandAsync(); return ServiceResult.OprateSuccess("发放成功!"); } #endregion diff --git a/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs b/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs index 009faf41..bf32aa19 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs @@ -1514,7 +1514,8 @@ WHERE A.Status !='Temporary' AND A.Status !='Close' AND A.IsEnable=1 AND ( E A.CourseEndTime, A.StandardDuration CourseStandardDuration1, - A.StudyDuration StudyDuration1 + A.StudyDuration StudyDuration1, +G.SceneDescription FROM Ghre_StudyRecord A LEFT JOIN Ghre_Course B ON A.CourseId = B.Id LEFT JOIN Ghra_Staff c ON B.TeacherId = c.StaffID diff --git a/Tiobon.Core/Tiobon.Core.Model.xml b/Tiobon.Core/Tiobon.Core.Model.xml index 0f29892b..1507345f 100644 --- a/Tiobon.Core/Tiobon.Core.Model.xml +++ b/Tiobon.Core/Tiobon.Core.Model.xml @@ -3700,6 +3700,11 @@ 学分规则ID + + + 场景说明 + + 课程列表 @@ -23217,6 +23222,11 @@ 学分规则ID + + + 场景说明 + + Ghre_CourseSnap (Model)