xiaochanghai 4 months ago
parent 105f046334
commit 36f2ee0a5d
  1. 2
      Tiobon.Core.Extensions/HostedService/QuartzJobHostedService.cs
  2. 24
      Tiobon.Core.Services/Ghre/Ghre_ExamRecordServices.cs
  3. 1
      Tiobon.Core.Tasks/QuartzNet/Jobs/Job_AutoIssueCertificate_Quartz.cs

@ -21,7 +21,7 @@ public class QuartzJobHostedService : IHostedService
public async Task StartAsync(CancellationToken cancellationToken) public async Task StartAsync(CancellationToken cancellationToken)
{ {
_logger.LogInformation("Start QuartzJob Service!"); _logger.LogInformation("---Start QuartzJob Service!");
await DoWork(); await DoWork();
} }

@ -1,4 +1,5 @@
using AgileObjects.AgileMapper.Extensions; using AgileObjects.AgileMapper.Extensions;
using Microsoft.Extensions.Logging;
using MongoDB.Driver.Linq; using MongoDB.Driver.Linq;
using System.Net; using System.Net;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
@ -13,14 +14,16 @@ public class Ghre_ExamRecordServices : BaseServices<Ghre_ExamRecord, Ghre_ExamRe
{ {
private readonly IBaseRepository<Ghre_ExamRecord> _dal; private readonly IBaseRepository<Ghre_ExamRecord> _dal;
//private readonly IGhre_ExamPaperServices _ghre_ExamPaperServices; //private readonly IGhre_ExamPaperServices _ghre_ExamPaperServices;
private readonly ILogger<Ghre_ExamRecordServices> _logger;
public Ghre_ExamRecordServices(ICaching caching, public Ghre_ExamRecordServices(ICaching caching,
//IGhre_ExamPaperServices ghre_ExamPaperServices, //IGhre_ExamPaperServices ghre_ExamPaperServices,
IBaseRepository<Ghre_ExamRecord> dal) IBaseRepository<Ghre_ExamRecord> dal, ILogger<Ghre_ExamRecordServices> logger)
{ {
this._dal = dal; this._dal = dal;
base.BaseDal = dal; base.BaseDal = dal;
base._caching = caching; base._caching = caching;
//_ghre_ExamPaperServices = ghre_ExamPaperServices; //_ghre_ExamPaperServices = ghre_ExamPaperServices;
_logger = logger;
} }
public override async Task<ServicePageResult<Ghre_ExamRecordDto>> QueryFilterPage(QueryBody filter, string condition, bool? IsEnable = true) public override async Task<ServicePageResult<Ghre_ExamRecordDto>> QueryFilterPage(QueryBody filter, string condition, bool? IsEnable = true)
@ -1463,6 +1466,7 @@ public class Ghre_ExamRecordServices : BaseServices<Ghre_ExamRecord, Ghre_ExamRe
x.IsPass == true && x.IsPass == true &&
(x.IsIssueCertificate == null || x.IsIssueCertificate == false)) (x.IsIssueCertificate == null || x.IsIssueCertificate == false))
.ToListAsync(); .ToListAsync();
_logger.LogInformation($"【发放证书】查询到{records.Count}条考试数据");
if (!records.Any()) if (!records.Any())
return ServiceResult.OprateSuccess("发放成功!"); return ServiceResult.OprateSuccess("发放成功!");
@ -1498,11 +1502,21 @@ public class Ghre_ExamRecordServices : BaseServices<Ghre_ExamRecord, Ghre_ExamRe
DateTime? ValidityPeriodTime = null; DateTime? ValidityPeriodTime = null;
if (rule.ValidityType == "StaticDuration" && rule.StaticNum != null) if (rule.ValidityType == "StaticDuration" && rule.StaticNum != null)
{
ValidityPeriodTime = now.AddDays(rule.StaticNum.Value); ValidityPeriodTime = now.AddDays(rule.StaticNum.Value);
ValidityPeriod = DateTimeHelper.ConvertToOnlySecondString(ValidityPeriodTime);
}
else if (rule.ValidityType == "Option" && rule.ValidityTime != null) else if (rule.ValidityType == "Option" && rule.ValidityTime != null)
{
ValidityPeriodTime = rule.ValidityTime; ValidityPeriodTime = rule.ValidityTime;
ValidityPeriod = DateTimeHelper.ConvertToSecondString(ValidityPeriodTime);
}
else if (rule.ValidityType == "Unlimited") else if (rule.ValidityType == "Unlimited")
{
ValidityPeriodTime = DateTime.MaxValue; ValidityPeriodTime = DateTime.MaxValue;
ValidityPeriod = "长期";
}
//发放证书 //发放证书
certificates.Add(new Ghre_Certificate() certificates.Add(new Ghre_Certificate()
@ -1511,8 +1525,10 @@ public class Ghre_ExamRecordServices : BaseServices<Ghre_ExamRecord, Ghre_ExamRe
StaffId = record.StaffId, StaffId = record.StaffId,
CourseId = record.CourseId, CourseId = record.CourseId,
AwardDate = now, AwardDate = now,
//ValidityPeriod = ValidityPeriod, ValidityPeriod = ValidityPeriod,
ValidityPeriodTime = ValidityPeriodTime ValidityPeriodTime = ValidityPeriodTime,
Reverse1 = "考试通过发放"
}); });
} }
} }
@ -1526,7 +1542,7 @@ public class Ghre_ExamRecordServices : BaseServices<Ghre_ExamRecord, Ghre_ExamRe
record.IsIssueCertificate = true; record.IsIssueCertificate = true;
} }
await Db.Insertable(certificates).ExecuteReturnSnowflakeIdAsync(); await Db.Insertable(certificates).ExecuteReturnSnowflakeIdListAsync();
await Db.Updateable(records) await Db.Updateable(records)
.UpdateColumns(it => new { it.IsIssueCertificate }, true) .UpdateColumns(it => new { it.IsIssueCertificate }, true)
.ExecuteCommandAsync(); .ExecuteCommandAsync();

@ -32,5 +32,6 @@ public class Job_AutoIssueCertificate_Quartz : JobBase, IJob
{ {
if (jobid > 0) if (jobid > 0)
await _services.IssueCertificate(); await _services.IssueCertificate();
} }
} }

Loading…
Cancel
Save