From e3e83612fc66410b8e010cd3fec9d2c0a5588337 Mon Sep 17 00:00:00 2001 From: he <109787524@qq.com> Date: Tue, 22 Jul 2025 15:57:15 +0800 Subject: [PATCH] =?UTF-8?q?Reapply=20"=E4=BF=AE=E6=94=B9=E7=A8=BD=E6=9F=A5?= =?UTF-8?q?"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 36750cc81cd21d88c5f510b4ce746bd32b41bf99. --- .../ReadingImageTaskService.cs | 112 +++++++++++++----- .../Common/AuditingData.cs | 2 +- 2 files changed, 81 insertions(+), 33 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs index a30bad09f..59ee1e8b1 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs @@ -2196,51 +2196,99 @@ namespace IRaCIS.Core.Application.Service async Task addOrEditmark(List addOrUpdatemarkList) { + #region 老的代码 + //var markids = addOrUpdatemarkList.Select(x => x.MarkId).Where(x => x != null).Distinct().ToList(); - var markids= addOrUpdatemarkList.Select(x => x.MarkId).Where(x => x != null).Distinct().ToList(); + //var markQuestionIds = addOrUpdatemarkList.Select(y => (Guid?)y.QuestionId).ToList(); - var markQuestionIds= addOrUpdatemarkList.Select(y => (Guid?)y.QuestionId).ToList(); - - // 绑定的历史标记的话 相当于要把历史标记改为现在的标记 先删再添加 得到的结果一样 - await _readingTaskQuestionMarkRepository.BatchDeleteNoTrackingAsync(x => markids.Contains(x.MarkId)&&x.QuestionId==null ); + //// 绑定的历史标记的话 相当于要把历史标记改为现在的标记 先删再添加 得到的结果一样 + //await _readingTaskQuestionMarkRepository.BatchDeleteNoTrackingAsync(x => markids.Contains(x.MarkId) && x.QuestionId == null); - // 这里还不能直接删除 因为可能该问题绑定的原标记为a 现在新绑定的标记要为b 那么就需要把原标记a的绑定关系删除 + //// 这里还不能直接删除 因为可能该问题绑定的原标记为a 现在新绑定的标记要为b 那么就需要把原标记a的绑定关系删除 - var oldMark=await _readingTaskQuestionMarkRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && markQuestionIds.Contains(x.QuestionId) && x.MarkId != null).ToListAsync(); + //var oldMark = await _readingTaskQuestionMarkRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && markQuestionIds.Contains(x.QuestionId) && x.MarkId != null).ToListAsync(); - // 这里稽查又要记录为新增 只能把原标记记录为先删除再添加 不然稽查又对不上 - List oldAddMark=new List (); + //// 这里稽查又要记录为新增 只能把原标记记录为先删除再添加 不然稽查又对不上 + //List oldAddMark = new List(); - foreach (var item in oldMark) + //foreach (var item in oldMark) + //{ + // if (addOrUpdatemarkList.Any(x => x.QuestionId == item.QuestionId && x.MarkId != item.MarkId)) + // { + // var olditem = item.Clone(); + + // olditem.QuestionId = null; + // olditem.TableQuestionId = null; + // olditem.RowId = null; + // olditem.RowIndex = null; + // oldAddMark.Add(olditem); + // } + //} + + //await _readingTaskQuestionMarkRepository.BatchDeleteNoTrackingAsync(x => x.VisitTaskId == inDto.VisitTaskId && markQuestionIds.Contains(x.QuestionId)); + + //var datetime = DateTime.Now; + + //var markList = _mapper.Map, List>(addOrUpdatemarkList); + //markList.ForEach(x => + //{ + // x.Id = NewId.NextGuid(); + // x.VisitTaskId = inDto.VisitTaskId; + // x.CreateTime = datetime; + // x.FristAddTaskId = questionMarkList.Where(y => y.QuestionId == x.QuestionId).Select(x => x.FristAddTaskId).FirstOrDefault() ?? inDto.VisitTaskId; + //}); + //// 原来移除关系的 已经删除 这里要添加 为什么要先删再加 因为稽查需要记录 稽查的记录方式为Add + //oldAddMark.AddRange(markList); + //await _readingTaskQuestionMarkRepository.AddRangeAsync(oldAddMark); + #endregion + + foreach (var item in addOrUpdatemarkList) { - if (addOrUpdatemarkList.Any(x => x.QuestionId == item.QuestionId && x.MarkId != item.MarkId)) + var oldMark = await _readingTaskQuestionMarkRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.QuestionId == item.QuestionId).FirstOrDefaultAsync(); + if (oldMark != null) { - var olditem = item.Clone(); + // 这种情况要先移除原来标记的绑定关系 + if (oldMark.MarkId != item.MarkId) + { + await _readingTaskQuestionMarkRepository.UpdatePartialFromQueryAsync(x => x.Id == oldMark.Id, x => new ReadingTaskQuestionMark() + { + QuestionId = null, + TableQuestionId = null, + RowId = null, + RowIndex = null, + }); - olditem.QuestionId = null; - olditem.TableQuestionId = null; - olditem.RowId = null; - olditem.RowIndex = null; - oldAddMark.Add(olditem); + var newMark = _mapper.Map(item); + newMark.Id = NewId.NextGuid(); + newMark.VisitTaskId = inDto.VisitTaskId; + newMark.FristAddTaskId = inDto.VisitTaskId; + await _readingTaskQuestionMarkRepository.AddAsync(newMark); + } + else + { + // 这种情况直接更新 + await _readingTaskQuestionMarkRepository.UpdatePartialFromQueryAsync(x => x.Id == oldMark.Id, x => new ReadingTaskQuestionMark() + { + MeasureData = item.MeasureData ?? string.Empty, + OtherMeasureData = item.OtherMeasureData ?? string.Empty, + PicturePath = item.PicturePath ?? string.Empty, + OtherPicturePath = item.OtherPicturePath ?? string.Empty, + MarkTool = item.MarkTool ?? string.Empty, + + }); + } + } + else + { + var newMark = _mapper.Map(item); + newMark.Id = NewId.NextGuid(); + newMark.VisitTaskId = inDto.VisitTaskId; + newMark.FristAddTaskId = inDto.VisitTaskId; + await _readingTaskQuestionMarkRepository.AddAsync(newMark); } } - await _readingTaskQuestionMarkRepository.BatchDeleteNoTrackingAsync(x => x.VisitTaskId == inDto.VisitTaskId && markQuestionIds.Contains(x.QuestionId)); - - var datetime = DateTime.Now; - - var markList = _mapper.Map, List>(addOrUpdatemarkList); - markList.ForEach(x => - { - x.Id = NewId.NextGuid(); - x.VisitTaskId = inDto.VisitTaskId; - x.CreateTime = datetime; - x.FristAddTaskId = questionMarkList.Where(y => y.QuestionId == x.QuestionId).Select(x => x.FristAddTaskId).FirstOrDefault() ?? inDto.VisitTaskId; - }); - // 原来移除关系的 已经删除 这里要添加 为什么要先删再加 因为稽查需要记录 稽查的记录方式为Add - oldAddMark.AddRange(markList); - await _readingTaskQuestionMarkRepository.AddRangeAsync(oldAddMark); } diff --git a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs index 26bb4439e..0e830cf62 100644 --- a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs +++ b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs @@ -3181,7 +3181,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common TableQuestionName = tableQuestionName, Answer = answer, LiverSegmentation = liverSegmentation, - }, _userInfo.AuditIdentification); + }); } //保存影像质量 多条记录,只记录一条稽查