From 800fd383dd6b1e6d26c0251418be9f11cffe8447 Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Fri, 17 Jan 2025 11:38:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=A6=E4=B9=A0=E6=97=B6=E9=95=BF=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E6=96=B0=E5=A2=9E=E6=AF=8F=E4=B8=AA=E9=99=84=E4=BB=B6?= =?UTF-8?q?=E5=BF=85=E9=A1=BB=E6=89=93=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tiobon.Core.Common/DB/Aop/SqlsugarAop.cs | 4 +- .../Ghre/Ghre_StudyRecordServices.cs | 40 +++- Tiobon.Core/Tiobon.Core.Model.xml | 225 ++++++++++++++++++ Tiobon.Core/Tiobon.Core.xml | 8 +- 4 files changed, 271 insertions(+), 6 deletions(-) diff --git a/Tiobon.Core.Common/DB/Aop/SqlsugarAop.cs b/Tiobon.Core.Common/DB/Aop/SqlsugarAop.cs index 81687b69..707db21d 100644 --- a/Tiobon.Core.Common/DB/Aop/SqlsugarAop.cs +++ b/Tiobon.Core.Common/DB/Aop/SqlsugarAop.cs @@ -92,7 +92,9 @@ public static class SqlSugarAop case DataFilterType.InsertByObject: var dyCreateBy = getType.GetProperty("CreateBy"); var dyCreateTime = getType.GetProperty("CreateTime"); - + BasePoco ent = entityInfo.EntityValue as BasePoco; + if (ent.Id == 0) + ent.Id = SnowFlakeSingle.Instance.NextId(); if (App.User?.ID > 0 && dyCreateBy != null && dyCreateBy.GetValue(entityInfo.EntityValue) == null) { try diff --git a/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs b/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs index 868f1603..8aa23fd9 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs @@ -1334,16 +1334,39 @@ 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); - await Task.Factory.StartNew(async () => await GenerateStaffStudyRecord(Db, studyRecordId)); + await Task.Factory.StartNew(async () => await GenerateStaffStudyRecord(Db, studyRecordId, duration.Value, attachmentId)); return ServiceResult.OprateSuccess("记录成功!"); } - public async Task GenerateStaffStudyRecord(ISqlSugarClient Db, long studyRecordId) + public async Task GenerateStaffStudyRecord(ISqlSugarClient Db, long studyRecordId, decimal duration, long attachmentId) { var record = await Db.Queryable().FirstAsync(x => x.Id == studyRecordId); + var attachment = await Db.Queryable().FirstAsync(x => x.Id == attachmentId); + + var courseWareIds = new List(); + + if (record.CourseId.IsNullOrEmpty()) + courseWareIds = await Db.Queryable().Where(x => x.CourseSceneId == record.CourseSceneId).Select(x => x.CourseWareId).ToListAsync(); + else + courseWareIds = await Db.Queryable().Where(x => x.Id == record.CourseId).Select(x => x.CourseWareId).ToListAsync(); + + + + + #region 记录学习明细 + var detail = new Ghre_StudyRecordDetail() + { + StudyRecordId = studyRecordId, + StaffId = record.StaffId, + CourseWareId = attachment.CourseWareId, + CourseWareAttachmentId = attachmentId, + StudyDuration = duration + }; + await Db.Insertable(detail).ExecuteCommandAsync(); + #endregion decimal studyProgress = 0; var sql = $@"SELECT ISNULL (A.Hours, 0) * 60 + A.Minutes Minutes @@ -1357,13 +1380,22 @@ WHERE A.Id = '{id}'"; if (mins > 0) { - var duration = record.StudyDuration ?? 0; + duration = record.StudyDuration ?? 0; studyProgress = (duration / mins) * 100; if (studyProgress > 100) studyProgress = 100; } - #region 判断所以附件 是否都被打开 + #region 判断所有附件 是否都被打开 + if (studyProgress == 100) + { + var detailWareAttachmentCount = await Db.Queryable().Where(x => x.StudyRecordId == studyRecordId).Select(x => x.CourseWareAttachmentId).Distinct().CountAsync(); + + var wareAttachmentCount = await Db.Queryable().Where(x => courseWareIds.Contains(x.CourseWareId)).CountAsync(); + + if (wareAttachmentCount != detailWareAttachmentCount) + studyProgress = 99; + } #endregion diff --git a/Tiobon.Core/Tiobon.Core.Model.xml b/Tiobon.Core/Tiobon.Core.Model.xml index 6ca3f0c2..1e29a82b 100644 --- a/Tiobon.Core/Tiobon.Core.Model.xml +++ b/Tiobon.Core/Tiobon.Core.Model.xml @@ -5675,6 +5675,106 @@ 员工培训ID + + + 培训记录明细 (Dto.Base) + + + + + 学习记录ID + + + + + 员工ID + + + + + 课件ID + + + + + 附件ID + + + + + 学习时长 + + + + + 备注 + + + + + 默认标志 + + + + + 预留字段1 + + + + + 预留字段2 + + + + + 预留字段3 + + + + + 预留字段4 + + + + + 预留字段5 + + + + + 预留字段6 + + + + + 预留字段7 + + + + + 预留字段8 + + + + + 预留字段9 + + + + + 预留字段10 + + + + + 预留字段11 + + + + + 预留字段12 + + 必选修规则 (Dto.Base) @@ -12787,6 +12887,11 @@ 是否合格 + + + 培训记录明细 (Dto.EditInput) + + 必选修规则 (Dto.EditInput) @@ -13252,6 +13357,11 @@ 是否合格 + + + 培训记录明细 (Dto.InsertInput) + + 必选修规则 (Dto.InsertInput) @@ -19351,6 +19461,106 @@ 员工培训ID + + + 培训记录明细 (Model) + + + + + 学习记录ID + + + + + 员工ID + + + + + 课件ID + + + + + 附件ID + + + + + 学习时长 + + + + + 备注 + + + + + 默认标志 + + + + + 预留字段1 + + + + + 预留字段2 + + + + + 预留字段3 + + + + + 预留字段4 + + + + + 预留字段5 + + + + + 预留字段6 + + + + + 预留字段7 + + + + + 预留字段8 + + + + + 预留字段9 + + + + + 预留字段10 + + + + + 预留字段11 + + + + + 预留字段12 + + 必选修规则 (Model) @@ -27957,6 +28167,21 @@ 考试状态 + + + 培训记录明细(Dto.View1) + + + + + 创建信息 + + + + + 修改信息 + + 必选修规则(Dto.View) diff --git a/Tiobon.Core/Tiobon.Core.xml b/Tiobon.Core/Tiobon.Core.xml index 116a0ddd..3f2090d8 100644 --- a/Tiobon.Core/Tiobon.Core.xml +++ b/Tiobon.Core/Tiobon.Core.xml @@ -1184,12 +1184,13 @@ - + 记录学习时长 + @@ -1199,6 +1200,11 @@ + + + 培训记录明细(Controller) + + 必选修规则(Controller)