阅片休息时间

IRC_NewDev
he 2024-01-12 09:40:35 +08:00
parent 4f93db928f
commit d3ec067224
4 changed files with 83 additions and 47 deletions

View File

@ -13,6 +13,8 @@ using static IRaCIS.Core.Domain.Share.StaticData;
using IRaCIS.Core.Application.ViewModel; using IRaCIS.Core.Application.ViewModel;
using Medallion.Threading; using Medallion.Threading;
using EasyCaching.Core; using EasyCaching.Core;
using IRaCIS.Core.Application.Contracts;
using LoginReturnDTO = IRaCIS.Application.Contracts.LoginReturnDTO;
namespace IRaCIS.Application.Services namespace IRaCIS.Application.Services
{ {
@ -28,8 +30,8 @@ namespace IRaCIS.Application.Services
private readonly IDistributedLockProvider _distributedLockProvider; private readonly IDistributedLockProvider _distributedLockProvider;
private readonly IEasyCachingProvider _cache; private readonly IEasyCachingProvider _cache;
private readonly IReadingImageTaskService _readingImageTaskService;
private readonly IOptionsMonitor<ServiceVerifyConfigOption> _verifyConfig; private readonly IOptionsMonitor<ServiceVerifyConfigOption> _verifyConfig;
public UserService(IRepository<User> userRepository, public UserService(IRepository<User> userRepository,
@ -38,7 +40,8 @@ namespace IRaCIS.Application.Services
IRepository<VerificationCode> verificationCodeRepository, IRepository<VerificationCode> verificationCodeRepository,
IRepository<Doctor> doctorRepository, IRepository<Doctor> doctorRepository,
IEasyCachingProvider cache, IEasyCachingProvider cache,
IRepository<TrialUser> userTrialRepository, IReadingImageTaskService readingImageTaskService,
IRepository<TrialUser> userTrialRepository,
IOptionsMonitor<ServiceVerifyConfigOption> verifyConfig, IOptionsMonitor<ServiceVerifyConfigOption> verifyConfig,
IRepository<UserLog> userLogRepository IRepository<UserLog> userLogRepository
, ,
@ -48,7 +51,8 @@ namespace IRaCIS.Application.Services
_verifyConfig = verifyConfig; _verifyConfig = verifyConfig;
_cache = cache; _cache = cache;
_userRepository = userRepository; this._readingImageTaskService = readingImageTaskService;
_userRepository = userRepository;
_mailVerificationService = mailVerificationService; _mailVerificationService = mailVerificationService;
_verificationCodeRepository = verificationCodeRepository; _verificationCodeRepository = verificationCodeRepository;
_doctorRepository = doctorRepository; _doctorRepository = doctorRepository;
@ -689,6 +693,10 @@ namespace IRaCIS.Application.Services
// 登录 清除缓存 // 登录 清除缓存
_cache.Remove(userLoginReturnModel.BasicInfo.Id.ToString()); _cache.Remove(userLoginReturnModel.BasicInfo.Id.ToString());
// 阅片时间缓存
await _readingImageTaskService.ResetReadingRestTime();
return ResponseOutput.Ok(userLoginReturnModel); return ResponseOutput.Ok(userLoginReturnModel);
} }

View File

@ -36,5 +36,8 @@ namespace IRaCIS.Core.Application.Contracts
Task AddOncologyTask(Guid oncologModuleId); Task AddOncologyTask(Guid oncologModuleId);
Task<List<GetManualListOutDto>> GetManualList(GetManualListInDto inDto); Task<List<GetManualListOutDto>> GetManualList(GetManualListInDto inDto);
}
Task ResetReadingRestTime();
}
} }

View File

@ -2573,62 +2573,87 @@ namespace IRaCIS.Application.Services
[HttpPost] [HttpPost]
public async Task VerifyReadingRestTime() public async Task VerifyReadingRestTime()
{ {
var cacheKey = _userInfo.Id.ToString()+ "RestTime"; var startReadingTimeKey = _userInfo.Id.ToString()+ "StartReadingTime";
var startRestTimeKey = _userInfo.Id.ToString() + "StartRestTime";
int readingMinute = 120; // 为60整数
var value = _provider.Get<string>(cacheKey).Value; int restMinute = 10; //
if (value == null)
var startReadingTime = _provider.Get<string>(startReadingTimeKey).Value;
var startRestTime = _provider.Get<string>(startReadingTimeKey).Value;
if (startReadingTime == null && startRestTime == null)
{ {
_provider.Set(cacheKey, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), TimeSpan.FromHours(5)); _provider.Set(startReadingTimeKey, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), TimeSpan.FromHours(48));
// _cache.Set(cacheKey, DateTime.Now.ToString(), TimeSpan.FromHours(5));
} }
else else if (startRestTimeKey != null)
{ {
var cacheStartRestTime = DateTime.Parse(startReadingTime!.ToString());
int timespanMin = (DateTime.Now - cacheStartRestTime).Minutes;
if (timespanMin <= restMinute)
{
throw new BusinessValidationFailedException(_localizer["ReadingImage_NeedRest", readingMinute/60, restMinute]);
}
else
{
// 休息时间>10分钟 删除休息时间的缓存 记录开始阅片时间
_provider.Remove(startRestTimeKey);
_provider.Set(startReadingTimeKey, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), TimeSpan.FromHours(48));
}
}
// 如果开始阅片时间 不为空
else if (startReadingTime != null)
{
#region 两小时 #region 两小时
var cacheDate = DateTime.Parse(value.ToString()); var cacheDate = DateTime.Parse(startReadingTime!.ToString());
int timespanMin = (DateTime.Now - cacheDate).Minutes; int timespanMin = (DateTime.Now - cacheDate).Minutes;
if (timespanMin > 120 && timespanMin < 130) if (timespanMin > readingMinute)
{ {
throw new BusinessValidationFailedException(_localizer["ReadingImage_NeedRest", 2, 10]);
_provider.Remove(startReadingTimeKey);
_provider.Set(startRestTimeKey, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), TimeSpan.FromHours(48));
throw new BusinessValidationFailedException(_localizer["ReadingImage_NeedRest", readingMinute / 60, restMinute]);
} }
else if (timespanMin > 130)
{
cacheDate = cacheDate.AddMinutes((Math.Floor((double)(timespanMin / 130))) * 130);
_provider.Set(cacheKey, cacheDate.ToString(), TimeSpan.FromHours(5));
// _cache.Set(cacheKey, cacheDate.ToString(), TimeSpan.FromHours(5));
}
#endregion #endregion
#region 测试用的5分钟
//var cacheDate = DateTime.Parse(value.ToString());
//int timespanMin = (DateTime.Now - cacheDate).Minutes;
//if (timespanMin >= 5 && timespanMin <= 10)
//{
// throw new BusinessValidationFailedException("您已连续阅片2个小时请休息20分钟后再继续阅片。");
//}
//else if (timespanMin > 10)
//{
// cacheDate = cacheDate.AddMinutes((Math.Floor((double)(timespanMin / 10))) * 10);
// _provider.Set(cacheKey, cacheDate.ToString(), TimeSpan.FromHours(5));
//}
#endregion
} }
} }
/// <summary> /// <summary>
/// 签名提交任务修改状态 /// 重置阅片时间 登录和解锁调用
/// </summary> /// </summary>
/// <param name="visitTaskId"></param>
/// <returns></returns> /// <returns></returns>
private async Task SubmitTaskChangeState(Guid visitTaskId) [HttpPost]
public async Task ResetReadingRestTime()
{
var startReadingTimeKey = _userInfo.Id.ToString() + "StartReadingTime";
var startRestTimeKey = _userInfo.Id.ToString() + "StartRestTime";
//int readingMinute = 120; // 为60整数
int restMinute = 10; //
var startReadingTime = _provider.Get<string>(startReadingTimeKey).Value;
var startRestTime = _provider.Get<string>(startReadingTimeKey).Value;
if (startRestTimeKey != null)
{
var cacheStartRestTime = DateTime.Parse(startReadingTime!.ToString());
int timespanMin = (DateTime.Now - cacheStartRestTime).Minutes;
if (timespanMin > restMinute)
{
_provider.Remove(startRestTimeKey);
}
}
else if (startReadingTime != null)
{
_provider.Set(startReadingTimeKey, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), TimeSpan.FromHours(48));
}
}
/// <summary>
/// 签名提交任务修改状态
/// </summary>
/// <param name="visitTaskId"></param>
/// <returns></returns>
private async Task SubmitTaskChangeState(Guid visitTaskId)
{ {
await VerifyTaskIsSign(visitTaskId); await VerifyTaskIsSign(visitTaskId);
await _visitTaskRepository.UpdatePartialFromQueryAsync(visitTaskId, x => new VisitTask() await _visitTaskRepository.UpdatePartialFromQueryAsync(visitTaskId, x => new VisitTask()

View File

@ -1822,8 +1822,8 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
result = SpleenAssessment.Normal; result = SpleenAssessment.Normal;
} }
//1、基线期 状态为“肿大” //1、基线期 状态为“肿大”
//与基线相比脾肿大增加的百分比 < 50 //与基线相比脾肿大增加的百分比 < -50
else if (baseLineState.EqEnum(SpleenAssessment.Swelling) && percentage < 50) else if (baseLineState.EqEnum(SpleenAssessment.Swelling) && percentage < -50)
{ {
result = SpleenAssessment.Remission; result = SpleenAssessment.Remission;
} }