修改遗漏领取逻辑
continuous-integration/drone/push Build is passing Details

Test_HIR_Net8
hang 2025-09-01 16:06:42 +08:00
parent 6f8f6000ba
commit b869693d63
5 changed files with 180 additions and 6 deletions

View File

@ -2154,7 +2154,7 @@
<returns></returns> <returns></returns>
<exception cref="T:IRaCIS.Core.Infrastructure.BusinessValidationFailedException"></exception> <exception cref="T:IRaCIS.Core.Infrastructure.BusinessValidationFailedException"></exception>
</member> </member>
<member name="M:IRaCIS.Core.Application.Service.UserService.GetUserLoginRoleList(IRaCIS.Core.Application.ViewModel.IRCLoginDto,IRaCIS.Core.Application.Auth.ITokenService,Microsoft.Extensions.Options.IOptionsMonitor{IRaCIS.Core.Domain.Share.SystemEmailSendConfig})"> <member name="M:IRaCIS.Core.Application.Service.UserService.GetUserLoginRoleList(IRaCIS.Core.Application.ViewModel.IRCLoginDto,IRaCIS.Core.Application.Auth.ITokenService,Microsoft.Extensions.Options.IOptionsMonitor{IRaCIS.Core.Domain.Share.SystemEmailSendConfig},Microsoft.Extensions.Options.IOptionsMonitor{IRaCIS.Core.Domain.Share.ServiceVerifyConfigOption})">
<summary> <summary>
账号验证,获取账号角色信息 获取临时token 账号验证,获取账号角色信息 获取临时token
</summary> </summary>
@ -12648,7 +12648,7 @@
<param name="inDto"></param> <param name="inDto"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:IRaCIS.Core.Application.Service.ReadingImageTaskService.#ctor(IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.NoneDicomStudy},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.VisitTask},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.Trial},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingTableQuestionAnswer},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingOncologyTaskInfo},IRaCIS.Core.Application.Service.IVisitTaskHelpeService,IRaCIS.Core.Application.Service.IVisitTaskService,IRaCIS.Core.Application.Contracts.IReadingClinicalDataService,IRaCIS.Core.Application.Service.IReadingCalculateService,IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.SubjectVisit},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.Subject},Microsoft.Extensions.Options.IOptionsMonitor{IRaCIS.Core.Domain.Share.ServiceVerifyConfigOption},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingGlobalTaskInfo},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingCriterionPage},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingTaskRelation},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingJudgeInfo},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadModule},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.DicomInstance},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.OrganInfo},IRaCIS.Core.Application.Service.ReadingCalculate.Interface.ILuganoCalculateService,IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingCustomTag},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingTaskQuestionMark},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingTrialCriterionDictionary},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingTableAnswerRowInfo},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingTableQuestionSystem},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingTableQuestionTrial},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingTaskQuestionAnswer},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingQuestionCriterionTrial},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingQuestionSystem},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.NoneDicomStudyFile},IRaCIS.Core.Application.Service.IGeneralCalculateService,IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingQuestionTrial},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.TaskStudy},IRaCIS.Core.Application.Service.ImageAndDoc.IDownloadAndUploadService,AutoMapper.IMapper,IRaCIS.Core.Domain.Share.IUserInfo,Microsoft.Extensions.Localization.IStringLocalizer,ZiggyCreatures.Caching.Fusion.IFusionCache)"> <member name="M:IRaCIS.Core.Application.Service.ReadingImageTaskService.#ctor(IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.NoneDicomStudy},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.VisitTask},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.Trial},MassTransit.IMessageScheduler,IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingTableQuestionAnswer},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingOncologyTaskInfo},IRaCIS.Core.Application.Service.IVisitTaskHelpeService,IRaCIS.Core.Application.Service.IVisitTaskService,IRaCIS.Core.Application.Contracts.IReadingClinicalDataService,IRaCIS.Core.Application.Service.IReadingCalculateService,IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.SubjectVisit},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.Subject},Microsoft.Extensions.Options.IOptionsMonitor{IRaCIS.Core.Domain.Share.ServiceVerifyConfigOption},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingGlobalTaskInfo},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingCriterionPage},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingTaskRelation},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingJudgeInfo},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadModule},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.DicomInstance},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.OrganInfo},IRaCIS.Core.Application.Service.ReadingCalculate.Interface.ILuganoCalculateService,IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingCustomTag},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingTaskQuestionMark},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingTrialCriterionDictionary},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingTableAnswerRowInfo},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingTableQuestionSystem},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingTableQuestionTrial},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingTaskQuestionAnswer},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingQuestionCriterionTrial},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingQuestionSystem},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.NoneDicomStudyFile},IRaCIS.Core.Application.Service.IGeneralCalculateService,IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingQuestionTrial},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.TaskStudy},IRaCIS.Core.Application.Service.ImageAndDoc.IDownloadAndUploadService,AutoMapper.IMapper,IRaCIS.Core.Domain.Share.IUserInfo,Microsoft.Extensions.Localization.IStringLocalizer,ZiggyCreatures.Caching.Fusion.IFusionCache)">
<summary> <summary>
IR影像阅片 IR影像阅片
</summary> </summary>
@ -12993,6 +12993,14 @@
</summary> </summary>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:IRaCIS.Core.Application.Service.ReadingImageTaskService.ClaimOrCancelSubjectAsync(IRaCIS.Core.Application.Service.Reading.Dto.ClaimSubjectDto)">
<summary>
前端 仅仅释放的时候使用,领取是后端调用该方法
</summary>
<param name="claimSubjectDto"></param>
<returns></returns>
<exception cref="T:IRaCIS.Core.Infrastructure.BusinessValidationFailedException"></exception>
</member>
<member name="M:IRaCIS.Core.Application.Service.ReadingImageTaskService.ResetReadingRestTime(System.Nullable{System.Guid})"> <member name="M:IRaCIS.Core.Application.Service.ReadingImageTaskService.ResetReadingRestTime(System.Nullable{System.Guid})">
<summary> <summary>
重置阅片时间 登录和解锁调用 重置阅片时间 登录和解锁调用

View File

@ -0,0 +1,38 @@
using IRaCIS.Core.Domain;
using IRaCIS.Core.Domain._DomainEvent;
using IRaCIS.Core.Domain.Models;
using MassTransit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IRaCIS.Core.Application.MassTransit.Consumer
{
public class SubjectCriterionClaimCancelConsumer(IRepository<VisitTask> _visitTaskRepository) : IConsumer<SubjectCriterionClaimCancelEvent>
{
public async Task Consume(ConsumeContext<SubjectCriterionClaimCancelEvent> context)
{
Log.Logger.Warning($"定时任务取消领取!{context.Message.ToJsonStr()}");
bool isInOrder = context.Message.IsInOrder;
if (isInOrder)
{
Guid subjectId = (Guid)context.Message.SubjectId;
Guid trialReadingCriterionId = (Guid)context.Message.TrialReadingCriterionId;
await _visitTaskRepository.BatchUpdateNoTrackingAsync(t => t.SubjectId == subjectId && t.TrialReadingCriterionId == trialReadingCriterionId && t.ReadingTaskState != ReadingTaskState.HaveSigned, u => new VisitTask() { SubjectCriterionClaimUserId = null });
}
else
{
Guid id = (Guid)context.Message.VisitTaskId;
await _visitTaskRepository.UpdatePartialFromQueryAsync(t => t.Id == id && t.ReadingTaskState != ReadingTaskState.HaveSigned, u => new VisitTask() { DoctorUserId = null }, true);
}
}
}
}

View File

@ -3074,4 +3074,17 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
//{ //{
//} //}
public class ClaimSubjectDto
{
public bool IsInOrder { get; set; }
public Guid? VisitTaskId { get; set; }
public Guid TrialReadingCriterionId { get; set; }
public Guid SubejctId { get; set; }
public bool IsClaim { get; set; }
}
} }

View File

@ -12,13 +12,18 @@ using IRaCIS.Core.Infra.EFCore.Common;
using IRaCIS.Core.Infrastructure; using IRaCIS.Core.Infrastructure;
using MassTransit; using MassTransit;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using NPOI.POIFS.Properties; using NPOI.POIFS.Properties;
using NPOI.SS.Formula.Functions; using NPOI.SS.Formula.Functions;
using Panda.DynamicWebApi.Attributes; using Panda.DynamicWebApi.Attributes;
using System.Reactive.Concurrency;
using ZiggyCreatures.Caching.Fusion; using ZiggyCreatures.Caching.Fusion;
using IRaCIS.Core.Domain.BaseModel;
using IRaCIS.Core.Domain._DomainEvent;
namespace IRaCIS.Core.Application.Service namespace IRaCIS.Core.Application.Service
{ {
@ -30,6 +35,7 @@ namespace IRaCIS.Core.Application.Service
IRepository<NoneDicomStudy> _noneDicomStudyRepository, IRepository<NoneDicomStudy> _noneDicomStudyRepository,
IRepository<VisitTask> _visitTaskRepository, IRepository<VisitTask> _visitTaskRepository,
IRepository<Trial> _trialRepository, IRepository<Trial> _trialRepository,
IMessageScheduler _scheduler,
IRepository<ReadingTableQuestionAnswer> _readingTableQuestionAnswerRepository, IRepository<ReadingTableQuestionAnswer> _readingTableQuestionAnswerRepository,
IRepository<ReadingOncologyTaskInfo> _readingOncologyTaskInfoRepository, IRepository<ReadingOncologyTaskInfo> _readingOncologyTaskInfoRepository,
IVisitTaskHelpeService _visitTaskHelpeService, IVisitTaskHelpeService _visitTaskHelpeService,
@ -72,9 +78,9 @@ namespace IRaCIS.Core.Application.Service
[HttpPost] [HttpPost]
public async Task<TNMValueDto?> GetTNMValue(TNMValueDto inDto) public async Task<TNMValueDto?> GetTNMValue(TNMValueDto inDto)
{ {
var result= await _visitTaskRepository.Where(x=>x.Id==inDto.VisitTaskId).Select(x => new TNMValueDto() var result = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Select(x => new TNMValueDto()
{ {
VisitTaskId=inDto.VisitTaskId, VisitTaskId = inDto.VisitTaskId,
TNMValue = x.TNMValue TNMValue = x.TNMValue
}).FirstOrDefaultAsync(); }).FirstOrDefaultAsync();
return result; return result;
@ -93,7 +99,7 @@ namespace IRaCIS.Core.Application.Service
await _visitTaskRepository.UpdatePartialFromQueryAsync(x => x.Id == inDto.VisitTaskId, x => new VisitTask() await _visitTaskRepository.UpdatePartialFromQueryAsync(x => x.Id == inDto.VisitTaskId, x => new VisitTask()
{ {
TNMValue = inDto.TNMValue TNMValue = inDto.TNMValue
},true); }, true);
return inDto; return inDto;
} }
@ -771,6 +777,11 @@ namespace IRaCIS.Core.Application.Service
} }
if (await _visitTaskRepository.AnyAsync(x => x.Id == visitTaskid && x.DoctorUserId != _userInfo.UserRoleId && x.SubjectCriterionClaimUserId != _userInfo.UserRoleId))
{
throw new BusinessValidationFailedException(_localizer["其他人已领取该任务,不允许操作"]);
}
if (await _visitTaskRepository.AnyAsync(x => x.Id == visitTaskid && x.TaskState != TaskState.Effect)) if (await _visitTaskRepository.AnyAsync(x => x.Id == visitTaskid && x.TaskState != TaskState.Effect))
{ {
throw new BusinessValidationFailedException(_localizer["ReadingImage_Beinvalid"]); throw new BusinessValidationFailedException(_localizer["ReadingImage_Beinvalid"]);
@ -2858,7 +2869,11 @@ namespace IRaCIS.Core.Application.Service
TrialReadingCriterionId = x.TrialReadingCriterionId, TrialReadingCriterionId = x.TrialReadingCriterionId,
}).FirstOrDefault(); }).FirstOrDefault();
if (task != null)
{
// 有序 自动领取该Subject
await ClaimOrCancelSubjectAsync(new ClaimSubjectDto() { IsClaim = true, SubejctId = task.SubjectId, TrialReadingCriterionId = task.TrialReadingCriterionId, VisitTaskId = task.VisitTaskId, IsInOrder = true });
}
} }
else if (inDto.SubjectId != null && trialReadingCriterion.IsReadingTaskViewInOrder == ReadingOrder.SubjectRandom) else if (inDto.SubjectId != null && trialReadingCriterion.IsReadingTaskViewInOrder == ReadingOrder.SubjectRandom)
@ -2985,6 +3000,12 @@ namespace IRaCIS.Core.Application.Service
TrialReadingCriterionId = x.TrialReadingCriterionId, TrialReadingCriterionId = x.TrialReadingCriterionId,
}).Skip(skipcount).FirstOrDefaultAsync(); }).Skip(skipcount).FirstOrDefaultAsync();
if (task != null)
{
// 无序
await ClaimOrCancelSubjectAsync(new ClaimSubjectDto() { IsClaim = true, VisitTaskId = task.VisitTaskId, IsInOrder = false });
}
} }
if (task == null) if (task == null)
@ -3172,6 +3193,77 @@ namespace IRaCIS.Core.Application.Service
return true; return true;
} }
/// <summary>
/// 前端 仅仅释放的时候使用,领取是后端调用该方法
/// </summary>
/// <param name="claimSubjectDto"></param>
/// <returns></returns>
/// <exception cref="BusinessValidationFailedException"></exception>
[HttpPost]
public async Task ClaimOrCancelSubjectAsync(ClaimSubjectDto claimSubjectDto)
{
//有序 用SubjectCriterionClaimUserId 某个标准的所有任务,该字段保持一致
if (claimSubjectDto.IsInOrder)
{
if (claimSubjectDto.IsClaim)
{
//每个subject 每个标准的领取放在 任务上 免得加表
if (_visitTaskRepository.Any(t => t.Id == claimSubjectDto.SubejctId && t.TrialReadingCriterionId == claimSubjectDto.TrialReadingCriterionId
&& t.SubjectCriterionClaimUserId != _userInfo.UserRoleId && t.SubjectCriterionClaimUserId != null))
{
throw new BusinessValidationFailedException(_localizer["ReadingImageTask_TaskTaken"]);
}
else
{
await _visitTaskRepository.BatchUpdateNoTrackingAsync(t => t.SubjectId == claimSubjectDto.SubejctId && t.TrialReadingCriterionId == claimSubjectDto.TrialReadingCriterionId, u => new VisitTask() { SubjectCriterionClaimUserId = _userInfo.UserRoleId });
//列表可以看到当前阅片人是谁
await _visitTaskRepository.BatchUpdateNoTrackingAsync(t => t.Id == claimSubjectDto.VisitTaskId, u => new VisitTask() { DoctorUserId = _userInfo.UserRoleId });
}
var domainEvent = new SubjectCriterionClaimCancelEvent() { SubjectId = claimSubjectDto.SubejctId, TrialReadingCriterionId = claimSubjectDto.TrialReadingCriterionId, IsInOrder = claimSubjectDto.IsInOrder };
await _scheduler.SchedulePublish(DateTime.Now.AddDays(1), (object)domainEvent);
//BackgroundJob.Schedule<IObtainTaskAutoCancelJob>(t => t.CancelQCObtaion(subjectVisitId, DateTime.Now), TimeSpan.FromHours(1));
}
else
{
await _visitTaskRepository.BatchUpdateNoTrackingAsync(t => t.SubjectId == claimSubjectDto.SubejctId && t.TrialReadingCriterionId == claimSubjectDto.TrialReadingCriterionId && t.ReadingTaskState != ReadingTaskState.HaveSigned, u => new VisitTask() { SubjectCriterionClaimUserId = null });
}
}
//无序 直接用DoctorUserId 当做领取人
else
{
if (claimSubjectDto.IsClaim)
{
if (_visitTaskRepository.Any(t => t.Id == claimSubjectDto.VisitTaskId && t.DoctorUserId != _userInfo.UserRoleId && t.DoctorUserId != null))
{
throw new BusinessValidationFailedException(_localizer["ReadingImageTask_TaskTaken"]);
}
else
{
await _visitTaskRepository.UpdatePartialFromQueryAsync(t => t.Id == claimSubjectDto.VisitTaskId, u => new VisitTask() { DoctorUserId = _userInfo.UserRoleId }, true);
}
var domainEvent = new SubjectCriterionClaimCancelEvent() { VisitTaskId = claimSubjectDto.VisitTaskId, IsInOrder = claimSubjectDto.IsInOrder };
await _scheduler.SchedulePublish(DateTime.Now.AddDays(1), (object)domainEvent);
}
}
}
/// <summary> /// <summary>
/// 重置阅片时间 登录和解锁调用 /// 重置阅片时间 登录和解锁调用
/// </summary> /// </summary>

View File

@ -0,0 +1,23 @@
using IRaCIS.Core.Domain.BaseModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IRaCIS.Core.Domain._DomainEvent
{
public class SubjectCriterionClaimCancelEvent : DomainEvent
{
public Guid? SubjectId { get; set; }
public Guid? TrialReadingCriterionId { get; set; }
public Guid? VisitTaskId { get; set; }
public bool IsInOrder { get; set; }
}
}