From ebd2f08a2cf90f074454f4692d64684cb4849fa1 Mon Sep 17 00:00:00 2001 From: he <10978375@qq.com> Date: Thu, 24 Nov 2022 14:26:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.API/Startup.cs | 2 + .../Service/Management/UserService.cs | 12 +++- .../ReadingImageTaskService.cs | 58 ++++++++++++++++++- 3 files changed, 68 insertions(+), 4 deletions(-) diff --git a/IRaCIS.Core.API/Startup.cs b/IRaCIS.Core.API/Startup.cs index 3b185cb4f..9401c48d5 100644 --- a/IRaCIS.Core.API/Startup.cs +++ b/IRaCIS.Core.API/Startup.cs @@ -154,6 +154,8 @@ namespace IRaCIS.Core.API //services.AddSingleton(); + services.AddMemoryCache(); + } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. diff --git a/IRaCIS.Core.Application/Service/Management/UserService.cs b/IRaCIS.Core.Application/Service/Management/UserService.cs index f90e0e6f6..73ee067cd 100644 --- a/IRaCIS.Core.Application/Service/Management/UserService.cs +++ b/IRaCIS.Core.Application/Service/Management/UserService.cs @@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Mvc; using Panda.DynamicWebApi.Attributes; using Microsoft.AspNetCore.Authorization; using Microsoft.Extensions.Options; +using Microsoft.Extensions.Caching.Memory; namespace IRaCIS.Application.Services { @@ -19,19 +20,22 @@ namespace IRaCIS.Application.Services private readonly IRepository _doctorRepository; private readonly IRepository _userTrialRepository; + private readonly IMemoryCache _cache; + private readonly IOptionsMonitor _verifyConfig; public UserService(IRepository userRepository, IMailVerificationService mailVerificationService, IRepository verificationCodeRepository, IRepository doctorRepository, + IMemoryCache cache, IRepository userTrialRepository, IOptionsMonitor verifyConfig ) { _verifyConfig = verifyConfig; - + _cache = cache; _userRepository = userRepository; _mailVerificationService = mailVerificationService; _verificationCodeRepository = verificationCodeRepository; @@ -610,7 +614,8 @@ namespace IRaCIS.Application.Services userLoginReturnModel.BasicInfo = loginDoctor; - + // 登录 清除缓存 + _cache.Remove(userLoginReturnModel.BasicInfo.Id.ToString()); return ResponseOutput.Ok(userLoginReturnModel); } @@ -622,7 +627,8 @@ namespace IRaCIS.Application.Services userLoginReturnModel.BasicInfo = loginUser; - + // 登录 清除缓存 + _cache.Remove(userLoginReturnModel.BasicInfo.Id.ToString()); return ResponseOutput.Ok(userLoginReturnModel); } diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs index d271c1c84..2201abf5e 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs @@ -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 _noneDicomStudyFileSystem; private readonly IRepository _readingQuestionTrialRepository; + private readonly IMemoryCache _cache; private readonly ITrialEmailNoticeConfigService _trialEmailNoticeConfigService; @@ -69,6 +71,7 @@ namespace IRaCIS.Application.Services IRepository readingCriterionPageRepository, IRepository readingJudgeInfoRepository, IRepository readModuleRepository, + IMemoryCache cache, IRepository readingCriterionDictionaryRepository, IRepository tumorAssessmentRepository, IRepository 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 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; } + /// + /// 验证阅片休息时间 + /// + /// + 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)); + + } + + + + } + + + + } /// /// 签名提交任务修改状态