排查牛尾环境学习进度无法展开问题

master
xiaochanghai 3 months ago
parent ea531c2049
commit 82119ad8ac
  1. 45
      Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs

@ -1,9 +1,9 @@
using MongoDB.Driver.Linq; using Microsoft.Extensions.Logging;
using MongoDB.Driver.Linq;
using NPOI.HSSF.UserModel; using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel; using NPOI.SS.UserModel;
using NPOI.SS.Util; using NPOI.SS.Util;
using NPOI.XSSF.UserModel; using NPOI.XSSF.UserModel;
using Org.BouncyCastle.Crypto;
using static Tiobon.Core.DataAccess.ReportHelper; using static Tiobon.Core.DataAccess.ReportHelper;
using static Tiobon.Core.Model.Consts; using static Tiobon.Core.Model.Consts;
@ -15,15 +15,17 @@ namespace Tiobon.Core.Services;
public class Ghre_StudyRecordServices : BaseServices<Ghre_StudyRecord, Ghre_StudyRecordDto, InsertGhre_StudyRecordInput, EditGhre_StudyRecordInput>, IGhre_StudyRecordServices public class Ghre_StudyRecordServices : BaseServices<Ghre_StudyRecord, Ghre_StudyRecordDto, InsertGhre_StudyRecordInput, EditGhre_StudyRecordInput>, IGhre_StudyRecordServices
{ {
private readonly IBaseRepository<Ghre_StudyRecord> _dal; private readonly IBaseRepository<Ghre_StudyRecord> _dal;
private readonly ILogger<Ghre_StudyRecordServices> _logger;
private IGhre_CourseServices _ghre_CourseServices; private IGhre_CourseServices _ghre_CourseServices;
public Ghre_StudyRecordServices(ICaching caching, public Ghre_StudyRecordServices(ICaching caching,
IGhre_CourseServices ghre_CourseServices, IGhre_CourseServices ghre_CourseServices,
IBaseRepository<Ghre_StudyRecord> dal) IBaseRepository<Ghre_StudyRecord> dal, ILogger<Ghre_StudyRecordServices> logger)
{ {
this._dal = dal; this._dal = dal;
base.BaseDal = dal; base.BaseDal = dal;
base._caching = caching; base._caching = caching;
_ghre_CourseServices = ghre_CourseServices; _ghre_CourseServices = ghre_CourseServices;
_logger = logger;
} }
public override async Task<ServicePageResult<Ghre_StudyRecordDto>> QueryFilterPage(QueryBody filter, string condition, bool? IsEnable = true) public override async Task<ServicePageResult<Ghre_StudyRecordDto>> QueryFilterPage(QueryBody filter, string condition, bool? IsEnable = true)
{ {
@ -1558,35 +1560,43 @@ WHERE A.Id = '{id}'";
if (course.CourseStandardDuration.IsNull()) if (course.CourseStandardDuration.IsNull())
{ {
sql = $@"SELECT SUM (ISNULL (A.Hours, 0) * 60 + A.Minutes) Minutes if (course.CourseId.IsNotEmptyOrNull())
sql = $@"SELECT SUM (ISNULL (A.Hours, 0) * 60 + A.Minutes) Minutes
FROM Ghre_CourseWare A FROM Ghre_CourseWare A
WHERE A.Id IN WHERE A.Id IN
(SELECT CourseWareId (SELECT CourseWareId
FROM Ghre_Course FROM Ghre_Course
WHERE (Id = '{course.CourseId}' OR CourseSceneId = '{course.CourseSceneId}' OR CourseSceneIds like '%{course.CourseSceneId}%') AND IsEnable = 1)"; WHERE (Id = '{course.CourseId}') AND IsEnable = 1)";
else
sql = $@"SELECT SUM (ISNULL (A.Hours, 0) * 60 + A.Minutes) Minutes
FROM Ghre_CourseWare A
WHERE A.Id IN
(SELECT CourseWareId
FROM Ghre_Course
WHERE (CourseSceneId = '{course.CourseSceneId}' OR CourseSceneIds like '%{course.CourseSceneId}%') AND IsEnable = 1)";
var mins = await Db.Ado.GetDecimalAsync(sql); var mins = await Db.Ado.GetDecimalAsync(sql);
course.CourseStandardDuration1 = mins; course.CourseStandardDuration1 = mins;
} }
if (course.StudyDuration1.IsNull()) if (course.StudyDuration1.IsNull())
course.StudyDuration = $"0 分 0 秒"; course.StudyDuration = $"0 小时 0 分 0 秒";
else else
{ {
var dt = DateTime.Now; var dt = DateTime.Now;
var dt1 = dt.AddMinutes((double)course.StudyDuration1); var dt1 = dt.AddMinutes((double)course.StudyDuration1);
var subTract = dt1.Subtract(dt); var subTract = dt1.Subtract(dt);
course.StudyDuration = $"{subTract.Minutes} 分 {subTract.Seconds} 秒"; course.StudyDuration = $"{subTract.Hours} 小时 {subTract.Minutes} 分 {subTract.Seconds} 秒";
} }
if (course.CourseStandardDuration1.IsNull()) if (course.CourseStandardDuration1.IsNull())
course.CourseStandardDuration = $"0 分 0 秒"; course.CourseStandardDuration = $"0 小时 0 分 0 秒";
else else
{ {
var dt = DateTime.Now; var dt = DateTime.Now;
var dt1 = dt.AddMinutes((double)course.CourseStandardDuration1); var dt1 = dt.AddMinutes((double)course.CourseStandardDuration1);
var subTract = dt1.Subtract(dt); var subTract = dt1.Subtract(dt);
course.CourseStandardDuration = $"{subTract.Minutes} 分 {subTract.Seconds} 秒"; course.CourseStandardDuration = $"{subTract.Hours} 小时 {subTract.Minutes} 分 {subTract.Seconds} 秒";
} }
return ServiceResult<Ghre_StudyRecordCourse>.OprateSuccess("查询成功!", course); return ServiceResult<Ghre_StudyRecordCourse>.OprateSuccess("查询成功!", course);
} }
@ -1649,6 +1659,8 @@ WHERE A.Id = '{id}'";
public async Task<bool> GenerateStaffStudyRecord(ISqlSugarClient Db, long studyRecordId, decimal duration, long attachmentId) public async Task<bool> GenerateStaffStudyRecord(ISqlSugarClient Db, long studyRecordId, decimal duration, long attachmentId)
{ {
//_logger.LogInformation($"【记录学习时长】GenerateStaffStudyRecord");
var record = await Db.Queryable<Ghre_StudyRecord>().FirstAsync(x => x.Id == studyRecordId); var record = await Db.Queryable<Ghre_StudyRecord>().FirstAsync(x => x.Id == studyRecordId);
var attachment = await Db.Queryable<Ghre_CourseWareAttachment>().FirstAsync(x => x.Id == attachmentId); var attachment = await Db.Queryable<Ghre_CourseWareAttachment>().FirstAsync(x => x.Id == attachmentId);
@ -1673,13 +1685,21 @@ WHERE A.Id = '{id}'";
#endregion #endregion
decimal studyProgress = 0; decimal studyProgress = 0;
//_logger.LogInformation($"【记录学习时长】studyProgress:{studyProgress}");
var sql = $@"SELECT SUM(ISNULL (A.Hours, 0) * 60 + A.Minutes) Minutes var sql = $@"SELECT SUM(ISNULL (A.Hours, 0) * 60 + A.Minutes) Minutes
FROM Ghre_CourseWare A FROM Ghre_CourseWare A
WHERE A.Id IN WHERE A.Id IN
(SELECT CourseWareId (SELECT CourseWareId
FROM Ghre_Course FROM Ghre_Course
WHERE (Id = '{record.CourseId}' WHERE (Id = '{record.CourseId}') AND IsEnable = 1)";
OR CourseSceneId = '{record.CourseSceneId}' if(record.CourseId.IsNullOrEmpty())
sql = $@"SELECT SUM(ISNULL (A.Hours, 0) * 60 + A.Minutes) Minutes
FROM Ghre_CourseWare A
WHERE A.Id IN
(SELECT CourseWareId
FROM Ghre_Course
WHERE (CourseSceneId = '{record.CourseSceneId}'
OR CourseSceneIds like '%{record.CourseSceneId}%') AND IsEnable = 1)"; OR CourseSceneIds like '%{record.CourseSceneId}%') AND IsEnable = 1)";
var mins = await Db.Ado.GetDecimalAsync(sql); var mins = await Db.Ado.GetDecimalAsync(sql);
@ -1690,6 +1710,9 @@ WHERE A.Id = '{id}'";
if (studyProgress > 100) if (studyProgress > 100)
studyProgress = 100; studyProgress = 100;
} }
//_logger.LogInformation($"【记录学习时长】studyProgress1:{studyProgress}");
#region 判断所有附件 是否都被打开 #region 判断所有附件 是否都被打开
if (studyProgress == 100) if (studyProgress == 100)

Loading…
Cancel
Save