This commit is contained in:
he
2022-11-24 14:26:05 +08:00
parent ab6a965a90
commit ebd2f08a2c
3 changed files with 68 additions and 4 deletions
@@ -12,6 +12,7 @@ using IRaCIS.Core.Application.ViewModel;
using IRaCIS.Core.Application.Interfaces;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Microsoft.Extensions.Caching.Memory;
namespace IRaCIS.Application.Services
{
@@ -49,6 +50,7 @@ namespace IRaCIS.Application.Services
private readonly IRepository<NoneDicomStudyFile> _noneDicomStudyFileSystem;
private readonly IRepository<ReadingQuestionTrial> _readingQuestionTrialRepository;
private readonly IMemoryCache _cache;
private readonly ITrialEmailNoticeConfigService _trialEmailNoticeConfigService;
@@ -69,6 +71,7 @@ namespace IRaCIS.Application.Services
IRepository<ReadingCriterionPage> readingCriterionPageRepository,
IRepository<ReadingJudgeInfo> readingJudgeInfoRepository,
IRepository<ReadModule> readModuleRepository,
IMemoryCache cache,
IRepository<ReadingCriterionDictionary> readingCriterionDictionaryRepository,
IRepository<TumorAssessment> tumorAssessmentRepository,
IRepository<ReadingTableAnswerRowInfo> readingTableAnswerRowInfoRepository,
@@ -110,7 +113,7 @@ namespace IRaCIS.Application.Services
this._readingQuestionSystem = ReadingQuestionSystem;
this._noneDicomStudyFileSystem = noneDicomStudyFileSystem;
this._readingQuestionTrialRepository = readingQuestionTrialRepository;
this._cache = cache;
this._trialEmailNoticeConfigService = trialEmailNoticeConfigService;
}
@@ -1189,6 +1192,11 @@ namespace IRaCIS.Application.Services
[HttpPost]
public async Task<GetReadingTaskDto> GetNextTask(GetNextTaskInDto inDto)
{
if (inDto.VisitTaskId == null)
{
await VerifyReadingRestTime();
}
GetReadingTaskDto? task = new GetReadingTaskDto();
var trialReadingCriterionId = inDto.TrialReadingCriterionId;
@@ -1318,7 +1326,55 @@ namespace IRaCIS.Application.Services
return task;
}
/// <summary>
/// 验证阅片休息时间
/// </summary>
/// <returns></returns>
private async Task VerifyReadingRestTime()
{
var cacheKey = _userInfo.Id.ToString();
var value = _cache.Get(cacheKey);
if (value == null)
{
_cache.Set(cacheKey, DateTime.Now.ToString(), TimeSpan.FromHours(5));
}
else
{
//var cacheDate = DateTime.Parse(value.ToString());
//int timespanMin = (DateTime.Now - cacheDate).Minutes;
//if (timespanMin > 120 && timespanMin < 140)
//{
// throw new BusinessValidationFailedException("您已连续阅片两个小时,请休息一会!");
//}
//else if (timespanMin > 140)
//{
// cacheDate = cacheDate.AddMinutes((Math.Floor((double)(timespanMin / 140)))*140);
// _cache.Set(cacheKey, cacheDate.ToString(), TimeSpan.FromHours(5));
//}
var cacheDate = DateTime.Parse(value.ToString());
int timespanMin = (DateTime.Now - cacheDate).Minutes;
if (timespanMin > 5 && timespanMin < 10)
{
throw new BusinessValidationFailedException("您已连续阅片两个小时,请休息一会!");
}
else if (timespanMin > 10)
{
cacheDate = cacheDate.AddMinutes((Math.Floor((double)(timespanMin / 10))) * 10);
_cache.Set(cacheKey, cacheDate.ToString(), TimeSpan.FromHours(5));
}
}
}
/// <summary>
/// 签名提交任务修改状态