|
|
|
@ -1607,85 +1607,182 @@ public class Ghre_ExamRecordServices : BaseServices<Ghre_ExamRecord, Ghre_ExamRe |
|
|
|
|
(x.IsIssueCertificate == null || x.IsIssueCertificate == false)) |
|
|
|
|
.ToListAsync(); |
|
|
|
|
_logger.LogInformation($"【发放证书】查询到{records.Count}条考试数据"); |
|
|
|
|
if (!records.Any()) |
|
|
|
|
return ServiceResult.OprateSuccess("发放成功!"); |
|
|
|
|
|
|
|
|
|
var certificates = new List<Ghre_Certificate>(); |
|
|
|
|
var rules = await Db.Queryable<Ghre_CertificateRule>().Where(x => x.SendRule == "ExamPass").ToListAsync(); |
|
|
|
|
for (int i = 0; i < records.Count; i++) |
|
|
|
|
var rules = new List<Ghre_CertificateRule>(); |
|
|
|
|
if (records.Any()) |
|
|
|
|
{ |
|
|
|
|
var record = records[i]; |
|
|
|
|
if (record.CourseId.IsNotEmptyOrNull()) |
|
|
|
|
{ |
|
|
|
|
var rules1 = rules.Where(x => x.CourseId1 != null && x.CourseId1.Contains(record.CourseId.ObjToString())).ToList(); |
|
|
|
|
|
|
|
|
|
for (int j = 0; j < rules1.Count; j++) |
|
|
|
|
var certificates = new List<Ghre_Certificate>(); |
|
|
|
|
rules = await Db.Queryable<Ghre_CertificateRule>().Where(x => x.SendRule == "ExamPass").ToListAsync(); |
|
|
|
|
for (int i = 0; i < records.Count; i++) |
|
|
|
|
{ |
|
|
|
|
var record = records[i]; |
|
|
|
|
if (record.CourseId.IsNotEmptyOrNull()) |
|
|
|
|
{ |
|
|
|
|
var rule = rules1[j]; |
|
|
|
|
var courseIds = JsonHelper.JsonToObj<List<long>>(rule.CourseId1); |
|
|
|
|
courseIds = courseIds.Distinct().ToList(); |
|
|
|
|
if (courseIds.Any()) |
|
|
|
|
var rules1 = rules.Where(x => x.CourseId1 != null && x.CourseId1.Contains(record.CourseId.ObjToString())).ToList(); |
|
|
|
|
|
|
|
|
|
for (int j = 0; j < rules1.Count; j++) |
|
|
|
|
{ |
|
|
|
|
if (courseIds.Count() == |
|
|
|
|
await Db.Queryable<Ghre_ExamRecord>() |
|
|
|
|
.Where(x => |
|
|
|
|
x.ValidBeginTime != null && |
|
|
|
|
x.ValidEndTime != null && |
|
|
|
|
x.ValidBeginTime <= now && |
|
|
|
|
x.ValidEndTime >= now && |
|
|
|
|
x.StaffId == record.StaffId && |
|
|
|
|
x.CourseId != null && |
|
|
|
|
x.IsPass == true && |
|
|
|
|
courseIds.Contains(x.CourseId.Value)).CountAsync()) |
|
|
|
|
var rule = rules1[j]; |
|
|
|
|
var courseIds = JsonHelper.JsonToObj<List<long>>(rule.CourseId1); |
|
|
|
|
courseIds = courseIds.Distinct().ToList(); |
|
|
|
|
if (courseIds.Any()) |
|
|
|
|
{ |
|
|
|
|
string ValidityPeriod = string.Empty; |
|
|
|
|
DateTime? ValidityPeriodTime = null; |
|
|
|
|
|
|
|
|
|
if (rule.ValidityType == "StaticDuration" && rule.StaticNum != null) |
|
|
|
|
if (courseIds.Count() == |
|
|
|
|
await Db.Queryable<Ghre_ExamRecord>() |
|
|
|
|
.Where(x => |
|
|
|
|
x.ValidBeginTime != null && |
|
|
|
|
x.ValidEndTime != null && |
|
|
|
|
x.ValidBeginTime <= now && |
|
|
|
|
x.ValidEndTime >= now && |
|
|
|
|
x.StaffId == record.StaffId && |
|
|
|
|
x.CourseId != null && |
|
|
|
|
x.IsPass == true && |
|
|
|
|
courseIds.Contains(x.CourseId.Value)).CountAsync()) |
|
|
|
|
{ |
|
|
|
|
ValidityPeriodTime = now.AddDays(rule.StaticNum.Value); |
|
|
|
|
ValidityPeriod = DateTimeHelper.ConvertToOnlySecondString(ValidityPeriodTime); |
|
|
|
|
string ValidityPeriod = string.Empty; |
|
|
|
|
DateTime? ValidityPeriodTime = null; |
|
|
|
|
|
|
|
|
|
if (rule.ValidityType == "StaticDuration" && rule.StaticNum != null) |
|
|
|
|
{ |
|
|
|
|
ValidityPeriodTime = now.AddDays(rule.StaticNum.Value); |
|
|
|
|
ValidityPeriod = DateTimeHelper.ConvertToOnlySecondString(ValidityPeriodTime); |
|
|
|
|
} |
|
|
|
|
else if (rule.ValidityType == "Option" && rule.ValidityTime != null) |
|
|
|
|
{ |
|
|
|
|
ValidityPeriodTime = rule.ValidityTime; |
|
|
|
|
ValidityPeriod = DateTimeHelper.ConvertToSecondString(ValidityPeriodTime); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
else if (rule.ValidityType == "Unlimited") |
|
|
|
|
{ |
|
|
|
|
ValidityPeriodTime = DateTime.MaxValue; |
|
|
|
|
ValidityPeriod = "长期"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//发放证书 |
|
|
|
|
certificates.Add(new Ghre_Certificate() |
|
|
|
|
{ |
|
|
|
|
CertificateRuleId = rule.Id, |
|
|
|
|
StaffId = record.StaffId, |
|
|
|
|
CourseId = record.CourseId, |
|
|
|
|
AwardDate = now, |
|
|
|
|
ValidityPeriod = ValidityPeriod, |
|
|
|
|
ValidityPeriodTime = ValidityPeriodTime, |
|
|
|
|
Reverse1 = "考试通过发放" |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
else if (rule.ValidityType == "Option" && rule.ValidityTime != null) |
|
|
|
|
{ |
|
|
|
|
ValidityPeriodTime = rule.ValidityTime; |
|
|
|
|
ValidityPeriod = DateTimeHelper.ConvertToSecondString(ValidityPeriodTime); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
else if (rule.ValidityType == "Unlimited") |
|
|
|
|
{ |
|
|
|
|
ValidityPeriodTime = DateTime.MaxValue; |
|
|
|
|
ValidityPeriod = "长期"; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else if (record.CourseSceneId.IsNotEmptyOrNull()) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
//发放证书 |
|
|
|
|
certificates.Add(new Ghre_Certificate() |
|
|
|
|
{ |
|
|
|
|
CertificateRuleId = rule.Id, |
|
|
|
|
StaffId = record.StaffId, |
|
|
|
|
CourseId = record.CourseId, |
|
|
|
|
AwardDate = now, |
|
|
|
|
ValidityPeriod = ValidityPeriod, |
|
|
|
|
ValidityPeriodTime = ValidityPeriodTime, |
|
|
|
|
Reverse1 = "考试通过发放" |
|
|
|
|
} |
|
|
|
|
record.IsIssueCertificate = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
await Db.Insertable(certificates).ExecuteReturnSnowflakeIdListAsync(); |
|
|
|
|
await Db.Updateable(records) |
|
|
|
|
.UpdateColumns(it => new { it.IsIssueCertificate }, true) |
|
|
|
|
.ExecuteCommandAsync(); |
|
|
|
|
} |
|
|
|
|
if (await Db.Queryable<Ghre_CertificateRule>().Where(x => x.SendRule == "CourseFinish").AnyAsync() |
|
|
|
|
&& await Db.Queryable<Ghre_StudyRecord>() |
|
|
|
|
.Where(x => |
|
|
|
|
x.StudyStatus == "HasFinish" && |
|
|
|
|
(x.IsIssueCertificate == null || x.IsIssueCertificate == false)) |
|
|
|
|
.AnyAsync()) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
var studyRecords = await Db.Queryable<Ghre_StudyRecord>() |
|
|
|
|
.Where(x => |
|
|
|
|
x.StudyStatus == "HasFinish" && |
|
|
|
|
(x.IsIssueCertificate == null || x.IsIssueCertificate == false)) |
|
|
|
|
.ToListAsync(); |
|
|
|
|
|
|
|
|
|
rules = await Db.Queryable<Ghre_CertificateRule>().Where(x => x.SendRule == "CourseFinish").ToListAsync(); |
|
|
|
|
var certificates = new List<Ghre_Certificate>(); |
|
|
|
|
|
|
|
|
|
for (int i = 0; i < studyRecords.Count; i++) |
|
|
|
|
{ |
|
|
|
|
var record = studyRecords[i]; |
|
|
|
|
if (record.CourseId.IsNotEmptyOrNull()) |
|
|
|
|
{ |
|
|
|
|
var rules1 = rules.Where(x => x.CourseId1 != null && x.CourseId1.Contains(record.CourseId.ObjToString())).ToList(); |
|
|
|
|
|
|
|
|
|
for (int j = 0; j < rules1.Count; j++) |
|
|
|
|
{ |
|
|
|
|
var rule = rules1[j]; |
|
|
|
|
var courseIds = JsonHelper.JsonToObj<List<long>>(rule.CourseId1); |
|
|
|
|
courseIds = courseIds.Distinct().ToList(); |
|
|
|
|
if (courseIds.Any()) |
|
|
|
|
{ |
|
|
|
|
if (courseIds.Count() == |
|
|
|
|
await Db.Queryable<Ghre_ExamRecord>() |
|
|
|
|
.Where(x => |
|
|
|
|
x.ValidBeginTime != null && |
|
|
|
|
x.ValidEndTime != null && |
|
|
|
|
x.ValidBeginTime <= now && |
|
|
|
|
x.ValidEndTime >= now && |
|
|
|
|
x.StaffId == record.StaffId && |
|
|
|
|
x.CourseId != null && |
|
|
|
|
x.IsPass == true && |
|
|
|
|
courseIds.Contains(x.CourseId.Value)).CountAsync()) |
|
|
|
|
{ |
|
|
|
|
string ValidityPeriod = string.Empty; |
|
|
|
|
DateTime? ValidityPeriodTime = null; |
|
|
|
|
|
|
|
|
|
if (rule.ValidityType == "StaticDuration" && rule.StaticNum != null) |
|
|
|
|
{ |
|
|
|
|
ValidityPeriodTime = now.AddDays(rule.StaticNum.Value); |
|
|
|
|
ValidityPeriod = DateTimeHelper.ConvertToOnlySecondString(ValidityPeriodTime); |
|
|
|
|
} |
|
|
|
|
else if (rule.ValidityType == "Option" && rule.ValidityTime != null) |
|
|
|
|
{ |
|
|
|
|
ValidityPeriodTime = rule.ValidityTime; |
|
|
|
|
ValidityPeriod = DateTimeHelper.ConvertToSecondString(ValidityPeriodTime); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
else if (rule.ValidityType == "Unlimited") |
|
|
|
|
{ |
|
|
|
|
ValidityPeriodTime = DateTime.MaxValue; |
|
|
|
|
ValidityPeriod = "长期"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//发放证书 |
|
|
|
|
certificates.Add(new Ghre_Certificate() |
|
|
|
|
{ |
|
|
|
|
CertificateRuleId = rule.Id, |
|
|
|
|
StaffId = record.StaffId, |
|
|
|
|
CourseId = record.CourseId, |
|
|
|
|
AwardDate = now, |
|
|
|
|
ValidityPeriod = ValidityPeriod, |
|
|
|
|
ValidityPeriodTime = ValidityPeriodTime, |
|
|
|
|
Reverse1 = "考试通过发放" |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
else if (record.CourseSceneId.IsNotEmptyOrNull()) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
record.IsIssueCertificate = true; |
|
|
|
|
} |
|
|
|
|
else if (record.CourseSceneId.IsNotEmptyOrNull()) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
record.IsIssueCertificate = true; |
|
|
|
|
|
|
|
|
|
await Db.Insertable(certificates).ExecuteReturnSnowflakeIdListAsync(); |
|
|
|
|
await Db.Updateable(records) |
|
|
|
|
.UpdateColumns(it => new { it.IsIssueCertificate }, true) |
|
|
|
|
.ExecuteCommandAsync(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
await Db.Insertable(certificates).ExecuteReturnSnowflakeIdListAsync(); |
|
|
|
|
await Db.Updateable(records) |
|
|
|
|
.UpdateColumns(it => new { it.IsIssueCertificate }, true) |
|
|
|
|
.ExecuteCommandAsync(); |
|
|
|
|
return ServiceResult.OprateSuccess("发放成功!"); |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|