|
|
@ -9,6 +9,9 @@ using Tiobon.Core.Common; |
|
|
|
using Tiobon.Core.Model; |
|
|
|
using Tiobon.Core.Model; |
|
|
|
using Newtonsoft.Json; |
|
|
|
using Newtonsoft.Json; |
|
|
|
using Tiobon.Core.Common.Helper; |
|
|
|
using Tiobon.Core.Common.Helper; |
|
|
|
|
|
|
|
using MySqlX.XDevAPI.Common; |
|
|
|
|
|
|
|
using SqlSugar; |
|
|
|
|
|
|
|
using Google.Protobuf.WellKnownTypes; |
|
|
|
|
|
|
|
|
|
|
|
namespace Tiobon.Core.Services |
|
|
|
namespace Tiobon.Core.Services |
|
|
|
{ |
|
|
|
{ |
|
|
@ -450,8 +453,7 @@ namespace Tiobon.Core.Services |
|
|
|
|
|
|
|
|
|
|
|
#endregion |
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 加入学习 |
|
|
|
#region 获取ESS查询条件 |
|
|
|
|
|
|
|
public async Task<ServiceResult> Join(long courseId) |
|
|
|
public async Task<ServiceResult> Join(long courseId) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var staffId = GetStaffId(); |
|
|
|
var staffId = GetStaffId(); |
|
|
@ -479,5 +481,45 @@ namespace Tiobon.Core.Services |
|
|
|
return ServiceResult.OprateSuccess("加入成功!"); |
|
|
|
return ServiceResult.OprateSuccess("加入成功!"); |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion |
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 记录学习时长 |
|
|
|
|
|
|
|
public async Task<ServiceResult> RecordDuration(long studyRecordId, decimal? duration) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var staffId = GetStaffId(); |
|
|
|
|
|
|
|
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)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ServiceResult.OprateSuccess("记录成功!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<bool> GenerateStaffStudyRecord(ISqlSugarClient Db, long studyRecordId) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var record = await Db.Queryable<Ghre_StudyRecord>().FirstAsync(x => x.Id == studyRecordId); |
|
|
|
|
|
|
|
decimal studyProgress = 0; |
|
|
|
|
|
|
|
var sql = $@"SELECT ISNULL (A.Hours, 0) * 60 + A.Minutes Minutes
|
|
|
|
|
|
|
|
FROM Ghre_CourseWare A |
|
|
|
|
|
|
|
WHERE A.Id IN |
|
|
|
|
|
|
|
(SELECT CourseWareId |
|
|
|
|
|
|
|
FROM Ghre_Course |
|
|
|
|
|
|
|
WHERE Id = '{record.CourseId}' |
|
|
|
|
|
|
|
OR CourseSceneId = '{record.CourseSceneId}' AND IsEnable = 1)";
|
|
|
|
|
|
|
|
var mins = await Db.Ado.GetDecimalAsync(sql); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mins > 0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var duration = record.StudyDuration ?? 0; |
|
|
|
|
|
|
|
studyProgress = (duration / mins)*100; |
|
|
|
|
|
|
|
if (studyProgress > 100) |
|
|
|
|
|
|
|
studyProgress = 100; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sql = $"UPDATE Ghre_StudyRecord SET StudyProgress = ISNULL(StudyProgress, 0)+{studyProgress} WHERE Id='{studyRecordId}'"; |
|
|
|
|
|
|
|
if (studyProgress > 0) await Db.Ado.ExecuteCommandAsync(sql); |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endregion |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |