Merge branch 'Test_IRC_Net8' of http://192.168.3.68:2000/XCKJ/irc-netcore-api into Test_IRC_Net8
continuous-integration/drone/push Build is passing Details

IRC_NewDev
hang 2024-07-17 14:20:38 +08:00
commit e0aa9fb1d9
3 changed files with 112 additions and 9 deletions

View File

@ -609,6 +609,8 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
{
public string Answer { get; set; }
public string LastTaskAnswer { get; set; }
public bool IsFirstChangeTask { get; set; } = false;
public List<CrterionDictionaryGroup> CrterionDictionaryGroup { get; set; }
@ -1701,6 +1703,11 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
}
public class SetSkipReadingCacheInDto
{
public Guid VisitTaskId { get; set; }
}
public class ResetReadingTaskInDto
{
public Guid VisitTaskId { get; set; }

View File

@ -37,7 +37,7 @@ namespace IRaCIS.Core.Application.Contracts
Task<List<GetManualListOutDto>> GetManualList(GetManualListInDto inDto);
Task ResetReadingRestTime(Guid? userId);
Task<bool> ResetReadingRestTime(Guid? userId);
Task<List<GetReadingPastResultListOutDto>> GetReadingPastResultList(GetReadingPastResultListInDto inDto);

View File

@ -22,6 +22,8 @@ using AutoMapper.QueryableExtensions;
using IRaCIS.Application.Contracts;
using IRaCIS.Core.Domain.Models;
using Microsoft.Extensions.Options;
using System.Linq;
using NPOI.SS.Formula.Functions;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
namespace IRaCIS.Application.Services
@ -872,10 +874,33 @@ namespace IRaCIS.Application.Services
var answers = new List<ReadingTaskQuestionAnswer>();
var lastTaskAnswer = new List<ReadingTaskQuestionAnswer>();
if (visitTaskId != null)
{
answers = await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == visitTaskId).ToListAsync();
var taskInfo = await _visitTaskRepository.Where(x => x.Id == visitTaskId).FirstNotNullAsync();
var laskTaskId = await _visitTaskRepository.Where(x =>
(x.SubjectId == taskInfo.SubjectId && x.TaskState == TaskState.Effect
&& x.IsAnalysisCreate == taskInfo.IsAnalysisCreate
&& x.DoctorUserId == taskInfo.DoctorUserId
&& x.IsSelfAnalysis == taskInfo.IsSelfAnalysis
&& x.VisitTaskNum < taskInfo.VisitTaskNum
&& x.ArmEnum == taskInfo.ArmEnum
&& x.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId
&& x.ReadingCategory == ReadingCategory.Visit) || x.Id == taskInfo.BeforeConvertedTaskId
).OrderByDescending(x => x.VisitTaskNum).Select(x => x.Id).FirstOrDefaultAsync();
if (criterionIdInfo.IsReadingTaskViewInOrder != ReadingOrder.InOrder)
{
// 无序的话 不要查
laskTaskId = Guid.NewGuid();
}
lastTaskAnswer = await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == laskTaskId).ToListAsync();
var taskinfo = await _visitTaskRepository.Where(x => x.Id == visitTaskId).ProjectTo<VisitTaskDto>(_mapper.ConfigurationProvider).FirstNotNullAsync();
if (taskinfo.VisitTaskNum == 0)
@ -920,24 +945,28 @@ namespace IRaCIS.Application.Services
foreach (var item in result)
{
GetDicomReadingAnswer(item, questions, answers);
GetDicomReadingAnswer(item, questions, answers, lastTaskAnswer);
}
return result;
}
private void GetDicomReadingAnswer(DicomReadingQuestionAnswer item, List<DicomReadingQuestionAnswer> questions, List<ReadingTaskQuestionAnswer> answers)
private void GetDicomReadingAnswer(DicomReadingQuestionAnswer item, List<DicomReadingQuestionAnswer> questions, List<ReadingTaskQuestionAnswer> answers, List<ReadingTaskQuestionAnswer> lastTaskAnswers)
{
var answer = answers.Where(x => x.ReadingQuestionTrialId == item.Id).Select(x => x.Answer).FirstIsNullReturnEmpty();
item.Answer = answer.IsNullOrEmpty() ? item.DefaultValue : answer;
var lastTaskAnswer = lastTaskAnswers.Where(x => x.ReadingQuestionTrialId == item.Id).Select(x => x.Answer).FirstIsNullReturnEmpty();
item.LastTaskAnswer = lastTaskAnswer.IsNullOrEmpty() ? item.DefaultValue : lastTaskAnswer;
item.Childrens = questions.Where(x => x.ParentId == item.Id || (x.GroupId == item.Id && x.ParentId == null)).ToList();
if (item.Childrens != null && item.Childrens.Count > 0)
{
foreach (var question in item.Childrens)
{
GetDicomReadingAnswer(question, questions, answers);
GetDicomReadingAnswer(question, questions, answers, lastTaskAnswers);
}
}
@ -2706,6 +2735,45 @@ namespace IRaCIS.Application.Services
/// <summary>
/// 清除跳过阅片的缓存
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<bool> ClearSkipReadingCache()
{
var clearSkipReadingCacheKey = _userInfo.Id.ToString() + "SkipReadingCache";
_provider.Remove(clearSkipReadingCacheKey);
return true;
}
/// <summary>
/// 设置跳过阅片的缓存
/// </summary>
/// <param name="inDto"></param>
/// <returns></returns>
[HttpPost]
public async Task<bool> SetSkipReadingCache(SetSkipReadingCacheInDto inDto )
{
var clearSkipReadingCacheKey = _userInfo.Id.ToString() + "SkipReadingCache";
var clearSkipReadingCache = _provider.Get<string>(clearSkipReadingCacheKey).Value;
if (clearSkipReadingCache == null|| clearSkipReadingCache==string.Empty)
{
List<Guid> cacheIds = new List<Guid>();
cacheIds.Add(inDto.VisitTaskId);
_provider.Set(clearSkipReadingCacheKey, JsonConvert.SerializeObject(cacheIds), TimeSpan.FromHours(24));
}
else
{
List<Guid>? cacheIds=JsonConvert.DeserializeObject<List<Guid>>(clearSkipReadingCache);
cacheIds.Add(inDto.VisitTaskId);
_provider.Set(clearSkipReadingCacheKey, JsonConvert.SerializeObject(cacheIds), TimeSpan.FromHours(24));
}
return true;
}
/// <summary>
/// 获取下一个阅片任务
@ -2730,6 +2798,16 @@ namespace IRaCIS.Application.Services
throw new BusinessValidationFailedException(_localizer["ReadingImage_IDMust"]);
}
#region 跳过阅片
var clearSkipReadingCacheKey = _userInfo.Id.ToString() + "SkipReadingCache";
var clearSkipReadingCache = _provider.Get<string>(clearSkipReadingCacheKey).Value;
List<Guid> cacheSkipIds = new List<Guid>();
if (clearSkipReadingCache != null && clearSkipReadingCache != string.Empty)
{
cacheSkipIds = JsonConvert.DeserializeObject<List<Guid>>(clearSkipReadingCache);
}
#endregion
var trialReadingCriterion = await _readingQuestionCriterionTrialRepository.FindAsync(trialReadingCriterionId ?? Guid.Empty);
if (inDto.VisitTaskId != null)
@ -2770,14 +2848,20 @@ namespace IRaCIS.Application.Services
var subjectIndex = subjectTaskList.Where(x => x.SubjectId == inDto.SubjectId && x.SubjectCode == inDto.SubjectCode).Select(x => x.Index).FirstOrDefault();
var currentSubject = subjectTaskList.Where(x => x.Index >= subjectIndex && !x.ExistReadingApply).OrderBy(x => x.Index).FirstOrDefault();
var currentSubject = subjectTaskList.Where(x => x.Index >= subjectIndex && !x.ExistReadingApply)
// 排除跳过的
.Where(x=> x.UnReadCanReadTaskList.Select(y => y.Id).Intersect(cacheSkipIds).Count()==0)
.OrderBy(x => x.Index).FirstOrDefault();
if (currentSubject == null)
{
throw new BusinessValidationFailedException(_localizer["ReadingImage_TaskFinish"], ApiResponseCodeEnum.CloseCurrentWindows);
}
task = currentSubject.UnReadCanReadTaskList.Select(x => new GetReadingTaskDto()
task = currentSubject.UnReadCanReadTaskList
.Select(x => new GetReadingTaskDto()
{
ReadingCategory = x.ReadingCategory,
SubjectCode = currentSubject.SubjectCode,
@ -2806,12 +2890,21 @@ namespace IRaCIS.Application.Services
})).CurrentPageData;
if (subjectTaskList.Count() == 0)
{
throw new BusinessValidationFailedException(_localizer["ReadingImage_TaskFinish"], ApiResponseCodeEnum.CloseCurrentWindows);
}
var taskList = subjectTaskList.FirstOrDefault()!.UnReadCanReadTaskList;
// 排除跳过的
List<Guid> remainingItems = taskList.Select(x => x.Id).Except(cacheSkipIds).ToList();
taskList = taskList.Where(x => remainingItems.Contains(x.Id)).ToList();
if (taskList.Count() == 0)
{
throw new BusinessValidationFailedException(_localizer["ReadingImage_TaskFinish"], ApiResponseCodeEnum.CloseCurrentWindows);
}
Random random = new Random();
//返回的范围是 0- taskList.Count-1
@ -2995,12 +3088,12 @@ namespace IRaCIS.Application.Services
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task VerifyReadingRestTime()
public async Task<bool> VerifyReadingRestTime()
{
var userTypeEnum = (UserTypeEnum)_userInfo.UserTypeEnumInt;
if (userTypeEnum != UserTypeEnum.IndependentReviewer)
{
return;
return true;
}
var startReadingTimeKey = _userInfo.Id.ToString() + "StartReadingTime";
var startRestTimeKey = _userInfo.Id.ToString() + "StartRestTime";
@ -3045,6 +3138,8 @@ namespace IRaCIS.Application.Services
#endregion
}
return true;
}
/// <summary>
@ -3052,7 +3147,7 @@ namespace IRaCIS.Application.Services
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task ResetReadingRestTime(Guid? userID)
public async Task<bool> ResetReadingRestTime(Guid? userID)
{
if (userID == null)
{
@ -3079,6 +3174,7 @@ namespace IRaCIS.Application.Services
{
_provider.Set(startReadingTimeKey, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), TimeSpan.FromHours(48));
}
return true;
}
/// <summary>