|
|
@ -1,10 +1,12 @@ |
|
|
|
using Microsoft.Extensions.Logging; |
|
|
|
using Microsoft.Extensions.Logging; |
|
|
|
using Microsoft.IdentityModel.Tokens; |
|
|
|
|
|
|
|
using MongoDB.Driver.Linq; |
|
|
|
using MongoDB.Driver.Linq; |
|
|
|
using NPOI.HSSF.UserModel; |
|
|
|
using NPOI.HSSF.UserModel; |
|
|
|
|
|
|
|
using NPOI.SS.Formula.Functions; |
|
|
|
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 Tiobon.Core.Model.Models; |
|
|
|
|
|
|
|
using static System.Runtime.InteropServices.JavaScript.JSType; |
|
|
|
using static Tiobon.Core.DataAccess.ReportHelper; |
|
|
|
using static Tiobon.Core.DataAccess.ReportHelper; |
|
|
|
using static Tiobon.Core.Model.Consts; |
|
|
|
using static Tiobon.Core.Model.Consts; |
|
|
|
|
|
|
|
|
|
|
@ -2016,4 +2018,119 @@ ORDER BY {filter.orderBy}"; |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion |
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 发放学分 |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
|
|
/// 发放学分 |
|
|
|
|
|
|
|
/// </summary> |
|
|
|
|
|
|
|
/// <returns></returns> |
|
|
|
|
|
|
|
public async Task<ServiceResult> IssueCredit() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var now = DateTime.Now; |
|
|
|
|
|
|
|
//抓取当天提交考试的数据 |
|
|
|
|
|
|
|
var records = await Db.Queryable<Ghre_StudyRecord>() |
|
|
|
|
|
|
|
.Where(x => x.StudyProgress == 100 && (x.IsIssueCredit == null || x.IsIssueCredit == false)) |
|
|
|
|
|
|
|
.Take(100) |
|
|
|
|
|
|
|
.ToListAsync(); |
|
|
|
|
|
|
|
_logger.LogInformation($"【学分发放】查询到{records.Count}条考试数据"); |
|
|
|
|
|
|
|
if (!records.Any()) |
|
|
|
|
|
|
|
return ServiceResult.OprateSuccess("发放成功!"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var creditPoints = new List<Ghre_CreditPoint>(); |
|
|
|
|
|
|
|
for (int i = 0; i < records.Count; i++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
long? creditRuleId = null; |
|
|
|
|
|
|
|
long? courseCreditPoints = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var record = records[i]; |
|
|
|
|
|
|
|
if (record.CourseId.IsNotEmptyOrNull()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
creditRuleId = await Db.Queryable<Ghre_Course>().Where(x => x.Id == record.CourseId).Select(x => x.CreditRuleId).FirstAsync(); |
|
|
|
|
|
|
|
courseCreditPoints = await Db.Queryable<Ghre_Course>().Where(x => x.Id == record.CourseId).Select(x => x.CreditPoints).FirstAsync(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (record.CourseSceneId.IsNotEmptyOrNull()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
creditRuleId = await Db.Queryable<Ghre_CourseScene>().Where(x => x.Id == record.CourseId).Select(x => x.CreditRuleId).FirstAsync(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (courseCreditPoints <= 0) |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (creditRuleId != null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var creditRule = await Db.Queryable<Ghre_CreditRule>().Where(x => x.Id == record.CourseId).Select(x => new |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
x.RuleType, |
|
|
|
|
|
|
|
x.ScoreRange, |
|
|
|
|
|
|
|
x.StudyCompletedPercent, |
|
|
|
|
|
|
|
x.ExamPassPercent |
|
|
|
|
|
|
|
}).FirstAsync(); |
|
|
|
|
|
|
|
if (creditRule != null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var creditPoint = new Ghre_CreditPoint() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
StaffId = record.StaffId, |
|
|
|
|
|
|
|
StudyRecordId = record.Id, |
|
|
|
|
|
|
|
ExamId = record.ExamId, |
|
|
|
|
|
|
|
CreditRuleId = creditRuleId, |
|
|
|
|
|
|
|
Date = DateTime.Now |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
if (creditRule.RuleType == "StudyCompletedPercent")//学习完成 |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
creditPoint.CreditPoints = ((courseCreditPoints * creditRule.StudyCompletedPercent) / 100).ObjToInt(); |
|
|
|
|
|
|
|
record.IsIssueCredit = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (creditRule.RuleType == "ExamPassPercent")//考试合格 |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (record.ExamId != null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (await Db.Queryable<Ghre_ExamRecord>().Where(x => x.StudyRecordId == record.Id && x.IsPass == true && x.Status == "ExamEnd").AnyAsync()) |
|
|
|
|
|
|
|
creditPoint.CreditPoints = ((courseCreditPoints * creditRule.ExamPassPercent) / 100).ObjToInt(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (creditRule.RuleType == "ScoreRanges")//分数段 |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var scoreRanges = JsonHelper.JsonToObj<List<CreditRuleScoreRange>>(creditRule.ScoreRange); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (record.ExamId != null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var examRecord = await Db.Queryable<Ghre_ExamRecord>().Where(x => x.StudyRecordId == record.Id && x.ScoreStatus == "HasScore" && x.IsPass == true && x.Status == "ExamEnd").FirstAsync(); |
|
|
|
|
|
|
|
if (examRecord != null && examRecord.Score > 0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var exam = await Db.Queryable<Ghre_Exam>().Where(x => x.Id == examRecord.ExamId).FirstAsync(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (exam != null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var examPaper = await Db.Queryable<Ghre_ExamPaper>().Where(x => x.Id == examRecord.ExamId).FirstAsync(); |
|
|
|
|
|
|
|
if (examPaper != null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var percent = (examRecord.Score / examPaper.TotalScore) * 100; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
percent = scoreRanges.Where(x => x.StartScore > percent && x.EndScore <= percent).Select(x => x.Credit).FirstOrDefault(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (percent != null) |
|
|
|
|
|
|
|
creditPoint.CreditPoints = ((courseCreditPoints * percent) / 100).ObjToInt(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (creditPoint.CreditPoints > 0) |
|
|
|
|
|
|
|
creditPoints.Add(creditPoint); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await Db.Insertable(creditPoints).ExecuteReturnSnowflakeIdListAsync(); |
|
|
|
|
|
|
|
await Db.Updateable(records) |
|
|
|
|
|
|
|
.UpdateColumns(it => new { it.IsIssueCredit }, true) |
|
|
|
|
|
|
|
.ExecuteCommandAsync(); |
|
|
|
|
|
|
|
return ServiceResult.OprateSuccess("发放成功!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endregion |
|
|
|
} |
|
|
|
} |