|
|
|
@ -1687,10 +1687,23 @@ 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 Db.Updateable<Ghre_StudyRecord>() |
|
|
|
|
.SetColumns(it => new Ghre_StudyRecord() { StudyDuration = (it.StudyDuration ?? 0) + duration }, true) |
|
|
|
|
.Where(it => it.Id == studyRecordId && it.StaffId == App.User.StaffId) |
|
|
|
|
.ExecuteCommandAsync(); |
|
|
|
|
var standDuration = await Db.Queryable<Ghre_CourseWareAttachment>() |
|
|
|
|
.Where(x => x.Id == attachmentId) |
|
|
|
|
.Select(x => x.LearnDuration) |
|
|
|
|
.FirstAsync() ?? 1000000000; |
|
|
|
|
|
|
|
|
|
var studyDuration = await Db.Queryable<Ghre_StudyRecordDetail>() |
|
|
|
|
.Where(x => x.StudyRecordId == studyRecordId && x.CourseWareAttachmentId == attachmentId) |
|
|
|
|
.SumAsync(it => it.StudyDuration); |
|
|
|
|
|
|
|
|
|
if (standDuration < (studyDuration + duration)) |
|
|
|
|
duration = standDuration - studyDuration; |
|
|
|
|
|
|
|
|
|
if (duration > 0) |
|
|
|
|
await Db.Updateable<Ghre_StudyRecord>() |
|
|
|
|
.SetColumns(it => new Ghre_StudyRecord() { StudyDuration = (it.StudyDuration ?? 0) + duration }, true) |
|
|
|
|
.Where(it => it.Id == studyRecordId && it.StaffId == App.User.StaffId) |
|
|
|
|
.ExecuteCommandAsync(); |
|
|
|
|
|
|
|
|
|
await Task.Factory.StartNew(async () => await GenerateStaffStudyRecord(Db, studyRecordId, duration.Value, attachmentId)); |
|
|
|
|
|
|
|
|
@ -1700,7 +1713,7 @@ WHERE A.Id = '{id}'"; |
|
|
|
|
|
|
|
|
|
public async Task<bool> GenerateStaffStudyRecord(ISqlSugarClient Db, long studyRecordId, decimal duration, long attachmentId) |
|
|
|
|
{ |
|
|
|
|
//_logger.LogInformation($"【记录学习时长】GenerateStaffStudyRecord"); |
|
|
|
|
_logger.LogInformation($"【记录学习时长】GenerateStaffStudyRecord"); |
|
|
|
|
|
|
|
|
|
var record = await Db.Queryable<Ghre_StudyRecord>().FirstAsync(x => x.Id == studyRecordId); |
|
|
|
|
|
|
|
|
@ -1726,7 +1739,7 @@ WHERE A.Id = '{id}'"; |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
decimal studyProgress = 0; |
|
|
|
|
//_logger.LogInformation($"【记录学习时长】studyProgress:{studyProgress}"); |
|
|
|
|
_logger.LogInformation($"【记录学习时长】studyProgress:{studyProgress}"); |
|
|
|
|
|
|
|
|
|
var sql = $@"SELECT SUM(ISNULL (A.Hours, 0) * 60 + A.Minutes) Minutes
|
|
|
|
|
FROM Ghre_CourseWare A |
|
|
|
@ -1747,11 +1760,14 @@ WHERE A.Id = '{id}'"; |
|
|
|
|
if (mins > 0) |
|
|
|
|
{ |
|
|
|
|
duration = record.StudyDuration ?? 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
studyProgress = (duration / mins) * 100; |
|
|
|
|
if (studyProgress > 100) |
|
|
|
|
studyProgress = 100; |
|
|
|
|
} |
|
|
|
|
//_logger.LogInformation($"【记录学习时长】studyProgress1:{studyProgress}"); |
|
|
|
|
_logger.LogInformation($"【记录学习时长】studyProgress1:{studyProgress}"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|