|
|
@ -11,7 +11,8 @@ using Newtonsoft.Json; |
|
|
|
using Tiobon.Core.Common.Helper; |
|
|
|
using Tiobon.Core.Common.Helper; |
|
|
|
using SqlSugar; |
|
|
|
using SqlSugar; |
|
|
|
using static Tiobon.Core.Model.Consts; |
|
|
|
using static Tiobon.Core.Model.Consts; |
|
|
|
using Microsoft.IdentityModel.Tokens; |
|
|
|
using Tiobon.Core.Common.DB.Dapper.Extensions; |
|
|
|
|
|
|
|
using MongoDB.Driver.Linq; |
|
|
|
|
|
|
|
|
|
|
|
namespace Tiobon.Core.Services |
|
|
|
namespace Tiobon.Core.Services |
|
|
|
{ |
|
|
|
{ |
|
|
@ -97,6 +98,110 @@ namespace Tiobon.Core.Services |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override async Task<long> Add(InsertGhre_StudyRecordInput entity) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (await Db.Queryable<Ghre_StudyRecord>() |
|
|
|
|
|
|
|
.WhereIF(!entity.CourseId.IsNullOrEmpty(), x => x.CourseId == entity.CourseId) |
|
|
|
|
|
|
|
.WhereIF(!entity.CourseSceneId.IsNullOrEmpty(), x => x.CourseSceneId == entity.CourseSceneId) |
|
|
|
|
|
|
|
.AnyAsync(x => x.StaffId == entity.StaffId)) |
|
|
|
|
|
|
|
throw new Exception("该用户存在相同学习记录!"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (entity.BeginTime != null && entity.EndTime != null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (entity.EndTime < entity.BeginTime) |
|
|
|
|
|
|
|
throw new Exception("学习结束时间需大于学习开始时间!"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (entity.EndTime > DateTime.Now) |
|
|
|
|
|
|
|
throw new Exception("学习结束时间需小于当前时间!"); |
|
|
|
|
|
|
|
TimeSpan timeDifference = entity.EndTime.Value - entity.BeginTime.Value; |
|
|
|
|
|
|
|
entity.StudyDuration = (decimal)timeDifference.TotalMinutes; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var snap = await Db.Queryable<Ghre_CourseSnap>().FirstAsync(x => x.CourseId == entity.CourseId); |
|
|
|
|
|
|
|
entity.CourseSnapId = snap?.Id; |
|
|
|
|
|
|
|
entity.CourseType = "ManualInsert"; |
|
|
|
|
|
|
|
var result = await base.Add(entity); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var examRecord = new Ghre_ExamRecord() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
StudyRecordId = result, |
|
|
|
|
|
|
|
StaffId = entity.StaffId, |
|
|
|
|
|
|
|
CourseSnapId = snap?.Id, |
|
|
|
|
|
|
|
Score = entity.Score, |
|
|
|
|
|
|
|
AdjustScore = entity.AdjustScore, |
|
|
|
|
|
|
|
ExamDate = entity.ExamDate, |
|
|
|
|
|
|
|
IsPass = entity.IsPass, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
await Db.Insertable(examRecord).ExecuteCommandAsync(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override async Task<bool> Update(long Id, EditGhre_StudyRecordInput editModel) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (await Db.Queryable<Ghre_StudyRecord>() |
|
|
|
|
|
|
|
.WhereIF(!editModel.CourseId.IsNullOrEmpty(), x => x.CourseId == editModel.CourseId) |
|
|
|
|
|
|
|
.WhereIF(!editModel.CourseSceneId.IsNullOrEmpty(), x => x.CourseSceneId == editModel.CourseSceneId) |
|
|
|
|
|
|
|
.AnyAsync(x => x.StaffId == editModel.StaffId && x.Id != Id)) |
|
|
|
|
|
|
|
throw new Exception("该用户存在相同学习记录!"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (editModel.BeginTime != null && editModel.EndTime != null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (editModel.EndTime < editModel.BeginTime) |
|
|
|
|
|
|
|
throw new Exception("学习结束时间需大于学习开始时间!"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (editModel.EndTime > DateTime.Now) |
|
|
|
|
|
|
|
throw new Exception("学习结束时间需小于当前时间!"); |
|
|
|
|
|
|
|
TimeSpan timeDifference = editModel.EndTime.Value - editModel.BeginTime.Value; |
|
|
|
|
|
|
|
editModel.StudyDuration = (decimal)timeDifference.TotalMinutes; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var snap = await Db.Queryable<Ghre_CourseSnap>().FirstAsync(x => x.CourseId == editModel.CourseId); |
|
|
|
|
|
|
|
editModel.CourseSnapId = snap?.Id; |
|
|
|
|
|
|
|
editModel.CourseType = "ManualInsert"; |
|
|
|
|
|
|
|
var result = await base.Update(Id, editModel); |
|
|
|
|
|
|
|
var snapId = snap?.Id; |
|
|
|
|
|
|
|
await Db.Updateable<Ghre_ExamRecord>() |
|
|
|
|
|
|
|
.SetColumns(it => new Ghre_ExamRecord() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
StaffId = editModel.StaffId, |
|
|
|
|
|
|
|
CourseSnapId = snapId, |
|
|
|
|
|
|
|
Score = editModel.Score, |
|
|
|
|
|
|
|
AdjustScore = editModel.AdjustScore, |
|
|
|
|
|
|
|
ExamDate = editModel.ExamDate, |
|
|
|
|
|
|
|
IsPass = editModel.IsPass |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.Where(it => it.StudyRecordId == Id) |
|
|
|
|
|
|
|
.ExecuteCommandAsync(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override async Task<ServiceFormResult<Ghre_StudyRecordDto>> QueryForm(QueryForm body) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var result = await base.QueryForm(body); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var DT_TableDataT1 = result.result.DT_TableDataT1; |
|
|
|
|
|
|
|
for (int i = 0; i < DT_TableDataT1.Count; i++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var record = await Db.Queryable<Ghre_ExamRecord>().FirstAsync(x => x.StudyRecordId == DT_TableDataT1[i].Id); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (record != null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
DT_TableDataT1[i].Score = record.Score; |
|
|
|
|
|
|
|
DT_TableDataT1[i].AdjustScore = record.AdjustScore; |
|
|
|
|
|
|
|
if (record.ExamDate != null) |
|
|
|
|
|
|
|
DT_TableDataT1[i].ExamDate = record.ExamDate.Value.ToString(); |
|
|
|
|
|
|
|
if (record.IsPass != null) |
|
|
|
|
|
|
|
DT_TableDataT1[i].IsPass = record.IsPass == true ? "true" : "false"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
result.result.DT_TableDataT1 = DT_TableDataT1; |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#region 获取ESS查询条件 |
|
|
|
#region 获取ESS查询条件 |
|
|
|
public async Task<ServiceResult<CoursePublicSearch>> QueryESSSearchFields(QueryBody body) |
|
|
|
public async Task<ServiceResult<CoursePublicSearch>> QueryESSSearchFields(QueryBody body) |
|
|
|
{ |
|
|
|
{ |
|
|
|