From d263ecbe2af8e688d74c47d5b46fd3fbe5f2e0d8 Mon Sep 17 00:00:00 2001
From: hang <87227557@qq.com>
Date: Sat, 27 Sep 2025 23:35:22 +0800
Subject: [PATCH] =?UTF-8?q?=E9=97=AD=E5=8C=85=E9=92=88=E5=AF=B9=E7=A8=BD?=
=?UTF-8?q?=E6=9F=A5=E7=9A=84=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../IRaCIS.Core.Application.xml | 96 +-
.../Service/Document/AuditDocumentService.cs | 619 +-
.../Document/DTO/AuditDocumentViewModel.cs | 6 +
.../Service/Document/_MapConfig.cs | 3 +-
IRaCIS.Core.Application/TestService.cs | 57 +
IRaCIS.Core.Domain/Document/AuditDocument.cs | 33 +
.../Context/IRaCISDBContext.cs | 2 +
.../AuditDocumentConfigration.cs | 40 +
...20250926134643_modifyAudictDoc.Designer.cs | 20336 ++++++++++++++++
.../20250926134643_modifyAudictDoc.cs | 78 +
.../IRaCISDBContextModelSnapshot.cs | 61 +
.../_IRaCIS/IQueryablePageListExtensions.cs | 10 +
12 files changed, 21172 insertions(+), 169 deletions(-)
create mode 100644 IRaCIS.Core.Infra.EFCore/EntityConfigration/AuditDocumentConfigration.cs
create mode 100644 IRaCIS.Core.Infra.EFCore/Migrations/20250926134643_modifyAudictDoc.Designer.cs
create mode 100644 IRaCIS.Core.Infra.EFCore/Migrations/20250926134643_modifyAudictDoc.cs
diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml
index 576d505a7..9c0eb0902 100644
--- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml
+++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml
@@ -1483,7 +1483,7 @@
-
+
稽查文档
@@ -1510,12 +1510,72 @@
+
+
+ 插入闭包表关系
+
+
+
+
+ 获取文件树形结构 (传Id 根节点就是自己)
+
+
+
+
+
+
+ 设置是否授权
+
+
+
+
+
+
+ 复制文件或者文件夹
+
+
+
+
+
+
+ 移动文件或者文件夹 到其他文件夹
+
+
+
+
+
+ 删除稽查文档
+
+
+
+
+
+
+ 把历史版本设置为当前版本--修改 维护闭包表,之间的闭包关系指向新版本文件
+
+
+
获取稽查文档
+
+
+
+
+ 获取历史版本
+
+
+
+
+
+
+ 获取面包屑导航
+
+
+
@@ -1534,7 +1594,7 @@
- 新增稽查文档
+ 新增稽查文档 (批量上传文件时才是数组,文件夹时单个对象)
@@ -1545,9 +1605,9 @@
-
+
- 获取面包屑导航
+ 删除稽查文档
@@ -1559,13 +1619,6 @@
-
-
- 删除稽查文档
-
-
-
-
移动文件或者文件夹 到其他文件夹
@@ -1579,19 +1632,6 @@
-
-
- 获取历史版本
-
-
-
-
-
-
- 把历史版本设置为当前版本
-
-
-
设置是否授权
@@ -14298,6 +14338,14 @@
+
+
+ 重建闭包表
+
+
+
+
+
清理一致性分析任务
diff --git a/IRaCIS.Core.Application/Service/Document/AuditDocumentService.cs b/IRaCIS.Core.Application/Service/Document/AuditDocumentService.cs
index 1e5934de1..a1a3a6a03 100644
--- a/IRaCIS.Core.Application/Service/Document/AuditDocumentService.cs
+++ b/IRaCIS.Core.Application/Service/Document/AuditDocumentService.cs
@@ -20,6 +20,8 @@ using NPOI.POIFS.Properties;
using Org.BouncyCastle.Crypto;
using Microsoft.AspNetCore.Http;
using IRaCIS.Core.Application.Contracts;
+using Microsoft.EntityFrameworkCore;
+using static Microsoft.Extensions.Logging.EventSource.LoggingEventSource;
namespace IRaCIS.Core.Application.Service;
@@ -29,7 +31,7 @@ namespace IRaCIS.Core.Application.Service;
///
[ApiExplorerSettings(GroupName = "FileRecord")]
public class AuditDocumentService(IRepository _auditDocumentRepository, IRepository _auditRecordRepository,
- IRepository _auditRecordPermissionRepository, IRepository _auditRecordIdentityUserRepository,
+ IRepository _auditRecordPermissionRepository, IRepository _auditRecordIdentityUserRepository, IRepository _auditDocumentClosureRepository,
IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer) : BaseService
{
@@ -131,9 +133,15 @@ public class AuditDocumentService(IRepository _auditDocumentRepos
///
public async Task SetAuditRecordPermission(SetAuditRecordPermissionCommand inCommand)
{
- if (_auditRecordPermissionRepository.Any(t => t.AuditRecordId == inCommand.AuditRecordId && t.AuditDocumentId == inCommand.AuditDocumentId))
- {
+ var find = _auditRecordPermissionRepository.FirstOrDefaultAsync(t => t.AuditRecordId == inCommand.AuditRecordId && t.AuditDocumentId == inCommand.AuditDocumentId);
+ if (find == null && inCommand.IsAuthorization)
+ {
+ await _auditRecordPermissionRepository.AddAsync(new AuditRecordPermission() { AuditRecordId = inCommand.AuditRecordId, AuditDocumentId = inCommand.AuditDocumentId }, true);
+ }
+ else
+ {
+ await _auditRecordPermissionRepository.DeleteFromQueryAsync(t => t.AuditRecordId == inCommand.AuditRecordId && t.AuditDocumentId == inCommand.AuditDocumentId, true);
}
return ResponseOutput.Ok();
@@ -142,14 +150,331 @@ public class AuditDocumentService(IRepository _auditDocumentRepos
#endregion
+ #region 闭包修改
+
+ ///
+ /// 插入闭包表关系
+ ///
+ private async Task AddClosureRelationsAsync(Guid nodeId, Guid? parentId)
+ {
+ var closures = new List();
+
+ // 自身关系
+ closures.Add(new AuditDocumentClosure
+ {
+ AncestorId = nodeId,
+ DescendantId = nodeId,
+ Depth = 0
+ });
+
+ if (parentId.HasValue)
+ {
+ // 查出所有父级的祖先
+ var parentClosures = await _auditDocumentClosureRepository
+ .Where(c => c.DescendantId == parentId.Value).Select(t => new { t.AncestorId, t.Depth })
+ .ToListAsync();
+
+ // 生成父级的所有祖先到新节点的关系
+ foreach (var pc in parentClosures)
+ {
+ closures.Add(new AuditDocumentClosure
+ {
+ AncestorId = pc.AncestorId,
+ DescendantId = nodeId,
+ Depth = pc.Depth + 1
+ });
+ }
+ }
+
+ await _auditDocumentClosureRepository.AddRangeAsync(closures);
+ await _auditDocumentClosureRepository.SaveChangesAsync();
+ }
+
+ ///
+ /// 获取文件树形结构 (传Id 根节点就是自己)
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task> GetAuditDocumentData_New(GetAuditDocumentDataInDto inDto)
+ {
+
+ var defalutSortArray = new string[] { nameof(AuditDocumentData.AuditDocumentTypeEnum), nameof(AuditDocumentData.Name) };
+ if (inDto.SortField.IsNotNullOrEmpty())
+ {
+ defalutSortArray = new string[] { nameof(AuditDocumentData.AuditDocumentTypeEnum), inDto.SortField + (inDto.Asc ? " asc" : " desc") };
+ inDto.SortField = string.Empty;
+ }
+
+ //匹配节点子查询
+ var matchedList = await _auditDocumentRepository.Where(x => x.AuditDocumentTypeEnum != AuditDocumentType.HistoricalVersion)
+ .WhereIf(inDto.IsAuthorization != null, x => x.IsAuthorization == inDto.IsAuthorization)
+ .WhereIf(inDto.AuditRecordId != null, x => x.IsAuthorization == inDto.IsAuthorization)
+ .WhereIf(inDto.Name.IsNotNullOrEmpty(), n => n.Name.Contains(inDto.Name))
+
+ .SelectMany(t => t.AncestorList).Select(t => t.Ancestor)//祖先包含自己
+ .Distinct() //可能包含相同的祖先
+ .ProjectTo(_mapper.ConfigurationProvider)
+ .SortToListAsync(defalutSortArray);
+
+ #region 针对某次稽查 授权展示
+ //某个稽查记录
+ if (inDto.AuditRecordId != null)
+ {
+ //找到该稽查记录 授权文件的所有父节点Id
+
+ var matchDocIdQuery = _auditRecordPermissionRepository.Where(t => t.AuditRecordId == inDto.AuditRecordId).Select(t => t.AuditDocumentId);
+
+ var parentIdList = _auditDocumentClosureRepository.Where(t => matchDocIdQuery.Contains(t.DescendantId)).Select(t => t.AncestorId).Distinct().ToList();
+ if (inDto.IsAuthorization == true)
+ {
+ //只查看授权的
+ matchedList = matchedList.Where(t => parentIdList.Contains((Guid)t.Id)).ToList();
+ }
+
+
+ foreach (var ancestorId in parentIdList)
+ {
+ var find = matchedList.FirstOrDefault(t => t.Id == ancestorId);
+
+ if (find != null)
+ {
+ //如果前端不想用新字段,那么就覆盖之前的授权字段
+ find.IsCurrentAuditRecordAuthorization = true;
+ }
+ }
+
+ }
+ #endregion
+
+
+
+ // 构建字典并拼装树
+ var dict = matchedList.ToDictionary(n => n.Id, t => t);
+
+ foreach (var node in dict.Values)
+ {
+ if (node.ParentId.HasValue && dict.TryGetValue(node.ParentId.Value, out var parent))
+ parent.Children.Add(node);
+ }
+
+ var query = dict.Values.Where(n => n.ParentId == null);
+
+ PageOutput result = new PageOutput()
+ {
+ PageIndex = inDto.PageIndex,
+ PageSize = inDto.PageSize,
+ TotalCount = query.Count(),
+ };
+
+ var root = query.Skip(inDto.PageSize * (inDto.PageIndex - 1)).Take(inDto.PageSize).ToList();
+
+ result.CurrentPageData = root;
+
+ return result;
+
+ }
+
+
+
+ ///
+ /// 设置是否授权
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task SetIsAuthorization_New(SetIsAuthorizationInDto inDto)
+ {
+ //闭包表中找到 设置Id为祖先的所有 后代 包括自己
+ var matchIdQuery = _auditDocumentClosureRepository.Where(t => inDto.Ids.Contains(t.AncestorId)).Select(t => t.DescendantId);
+
+ await _auditDocumentRepository.BatchUpdateNoTrackingAsync(t => matchIdQuery.Contains(t.Id), u => new AuditDocument() { IsAuthorization = inDto.IsAuthorization });
+
+ return ResponseOutput.Ok();
+
+ }
+
+ ///
+ /// 复制文件或者文件夹
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task CopyFileOrFolder_New(MovieFileOrFolderInDto inDto)
+ {
+
+ foreach (var id in inDto.Ids)
+ {
+
+ //当前节点的后代(包括自己) 拷贝的节点以及子节点
+ var nodeList = await _auditDocumentClosureRepository.Where(t => t.AncestorId == id).Select(t => t.Descendant).ToListAsync();
+
+
+ foreach (var node in nodeList)
+ {
+ //设置新节点Id
+ node.Id = NewId.NextSequentialGuid();
+
+ //建立新的闭包关系
+ await AddClosureRelationsAsync(node.Id, inDto.ParentId);
+ }
+
+ }
+
+ return ResponseOutput.Ok();
+ }
+
+ ///
+ /// 移动文件或者文件夹 到其他文件夹
+ ///
+ ///
+ [HttpPost]
+ public async Task MovieFileOrFolder_New(MovieFileOrFolderInDto inDto)
+ {
+ //闭包表中找到 设置Id为祖先的所有 后代 包括自己
+ var matchIdQuery = _auditDocumentClosureRepository.Where(t => inDto.Ids.Contains(t.AncestorId)).Select(t => t.DescendantId);
+
+ //无法将当前文件夹移动到当前目录以及子文件夹
+
+ if (matchIdQuery.Any(t => t == inDto.ParentId))
+ {
+ throw new BusinessValidationFailedException(_localizer["AuditDocument_CanNotMove"]);
+ }
+
+ foreach (var id in inDto.Ids)
+ {
+
+ //移动ParentId
+ var node = await _auditDocumentRepository.FirstOrDefaultAsync(t => t.Id == id);
+
+ node.ParentId = inDto.ParentId;
+ await _auditDocumentRepository.SaveChangesAsync();
+
+
+
+ // 删除原有闭包关系
+
+ await _auditDocumentClosureRepository.BatchDeleteNoTrackingAsync(t => t.DescendantId == id || t.AncestorId == id);
+
+ //建立新的闭包关系
+ await AddClosureRelationsAsync(node.Id, inDto.ParentId);
+
+ }
+
+ return ResponseOutput.Ok();
+ }
+
+
+ ///
+ /// 删除稽查文档
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task DeleteAuditDocument_New(DeleteAuditDocumentInDto inDto)
+ {
+ //闭包表中找到 设置Id为祖先的所有 后代 包括自己
+ var matchList = _auditDocumentClosureRepository.Where(t => inDto.Ids.Contains(t.AncestorId)).Select(t => new { t.DescendantId, t.Descendant.MainFileId });
+
+ //删除自己以及后代
+ var success = await _auditDocumentRepository.DeleteFromQueryAsync(t => matchList.Select(t => t.DescendantId).Distinct().Contains(t.Id), true);
+
+ //找到有版本的
+ var mainFileIdList = matchList.Where(t => t.MainFileId != null).ToList();
+
+ foreach (var item in mainFileIdList)
+ {
+ var historicalVersionList = await _auditDocumentRepository.Where(x => x.MainFileId == item.MainFileId).OrderBy(x => x.Version).ToListAsync();
+
+ var num = 1;
+ foreach (var historical in historicalVersionList)
+ {
+ await _auditDocumentRepository.UpdatePartialFromQueryAsync(historical.Id, x => new AuditDocument()
+ {
+ Version = num,
+ });
+ num++;
+ }
+ }
+ await _auditDocumentRepository.SaveChangesAsync();
+
+ return ResponseOutput.Ok();
+
+ }
+
+
+ ///
+ /// 把历史版本设置为当前版本--修改 维护闭包表,之间的闭包关系指向新版本文件
+ ///
+ ///
+ [HttpPost]
+ public async Task SetCurrentVersion(SetCurrentVersionInDto inDto)
+ {
+ var file = await _auditDocumentRepository.Where(x => x.Id == inDto.Id).FirstNotNullAsync();
+ if (file.AuditDocumentTypeEnum != AuditDocumentType.HistoricalVersion)
+ {
+ throw new BusinessValidationFailedException(_localizer["AuditDocument_CanNotSetCurrentVersion"]);
+ }
+
+ var mainFile = await _auditDocumentRepository.Where(x => x.Id == file.MainFileId).FirstNotNullAsync();
+
+ var historicalVersionIds = await _auditDocumentRepository.Where(x => x.MainFileId == mainFile.Id && x.Id != inDto.Id).OrderBy(x => x.Version).Select(x => x.Id).ToListAsync();
+
+ historicalVersionIds.Add(mainFile.Id);
+ await _auditDocumentRepository.UpdatePartialFromQueryAsync(inDto.Id, x => new AuditDocument()
+ {
+ MainFileId = null,
+ ParentId = mainFile.ParentId,
+ AuditDocumentTypeEnum = AuditDocumentType.File,
+ });
+
+ int num = 1;
+ foreach (var item in historicalVersionIds)
+ {
+ await _auditDocumentRepository.UpdatePartialFromQueryAsync(item, x => new AuditDocument()
+ {
+ MainFileId = inDto.Id,
+ ParentId = null,
+ Version = num,
+ AuditDocumentTypeEnum = AuditDocumentType.HistoricalVersion
+ });
+ num++;
+ }
+
+ await _auditDocumentRepository.SaveChangesAsync();
+
+ #region 闭包修改
+
+
+ //版本设计这里,当前版本才有parentId 不是当前版本就没有parentId->移动的时候还要维护历史版本的parentid
+ //增加闭包,所以这里要维护闭包表
+
+ await _auditDocumentClosureRepository.BatchUpdateNoTrackingAsync(t => t.AncestorId == mainFile.Id, t => new AuditDocumentClosure() { AncestorId = inDto.Id });
+
+ await _auditDocumentClosureRepository.BatchUpdateNoTrackingAsync(t => t.DescendantId == mainFile.Id, t => new AuditDocumentClosure() { DescendantId = inDto.Id });
+
+ #endregion
+
+
+ return ResponseOutput.Ok();
+
+ }
+
+
+
+ #endregion
+
+
+ #region 增加闭包设计 不用修改地方
///
/// 获取稽查文档
///
///
///
+ ///
[HttpPost]
public async Task> GetAuditDocumentList(AuditDocumentQuery inQuery)
{
@@ -160,6 +485,65 @@ public class AuditDocumentService(IRepository _auditDocumentRepos
return pageList;
}
+ ///
+ /// 获取历史版本
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task> GetHistoricalVersion(GetHistoricalVersionInDto inDto)
+ {
+
+ List result = new List();
+
+ result = await _auditDocumentRepository.Where(x => x.MainFileId == inDto.Id).ProjectTo(_mapper.ConfigurationProvider).OrderByDescending(x => x.Version).ToListAsync();
+ var currentData = await _auditDocumentRepository.Where(x => x.Id == inDto.Id).ProjectTo(_mapper.ConfigurationProvider).FirstNotNullAsync();
+ currentData.IsCurrentVersion = true;
+
+ result.Insert(0, currentData);
+
+ return result;
+ }
+
+
+ ///
+ /// 获取面包屑导航
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task> GetBreadcrumbData(GetBreadcrumbDataInDto inDto)
+ {
+ List result = new List();
+
+ await findParent(result, inDto.Id);
+ async Task findParent(List datas, Guid id)
+ {
+ var data = await _auditDocumentRepository.Where(x => x.Id == id).ProjectTo(_mapper.ConfigurationProvider).FirstNotNullAsync();
+ datas.Add(data);
+ if (data.ParentId != null)
+ {
+ await findParent(datas, data.ParentId.Value);
+ }
+
+ }
+
+ result.Reverse();
+
+ return result;
+
+ }
+
+
+
+
+
+
+ #endregion
+
+ #region 闭包维护关系,只处理最底层调用 AddOrUpdateAuditDocument
+
+
///
/// 修改稽查文档
///
@@ -198,8 +582,13 @@ public class AuditDocumentService(IRepository _auditDocumentRepos
return ResponseOutput.Ok(result);
}
+
+
+
+
+
///
- /// 新增稽查文档
+ /// 新增稽查文档 (批量上传文件时才是数组,文件夹时单个对象)
///
///
///
@@ -210,6 +599,8 @@ public class AuditDocumentService(IRepository _auditDocumentRepos
inDto.ForEach(x => x.IsUpdate = false);
await addData(inDto);
+
+ //构建父子关系,然后返回Id
async Task addData(List data)
{
foreach (var item in data)
@@ -234,33 +625,41 @@ public class AuditDocumentService(IRepository _auditDocumentRepos
return ResponseOutput.Ok(resultData);
}
-
-
///
/// 通用方法
///
///
private async Task AddOrUpdateAuditDocument(AuditDocumentAddOrEdit inDto)
{
-
+ //同一层级不能加同名的文件
var alikeData = await _auditDocumentRepository.Where(x => x.Id != inDto.Id && x.ParentId == inDto.ParentId && x.Name == inDto.Name && x.AuditDocumentTypeEnum == inDto.AuditDocumentTypeEnum).FirstOrDefaultAsync();
+
+ //同层级找到了同名的
if (alikeData != null)
{
+
if (inDto.AuditDocumentTypeEnum == AuditDocumentType.Folder)
{
+ //更新
if (inDto.IsUpdate)
{
throw new BusinessValidationFailedException(_localizer["AuditDocument_CanNotAddFolder"]);
}
else
{
+ //添加相同目录,已存在,那么就不处理
return alikeData;
}
}
else
{
+ //同名文件,那么作为版本处理(首先插入)
+
var entityData = await _auditDocumentRepository.InsertOrUpdateAsync(inDto, true);
+
+ //找到该同名文件的历史版本
var historicalVersionIds = await _auditDocumentRepository.Where(x => x.MainFileId == alikeData.Id).OrderBy(x => x.Version).Select(x => x.Id).ToListAsync();
+ //加上当前的同名文件 一起重新设置版本号
historicalVersionIds.Add(alikeData.Id);
int num = 1;
@@ -272,44 +671,96 @@ public class AuditDocumentService(IRepository _auditDocumentRepos
ParentId = null,
Version = num,
AuditDocumentTypeEnum = AuditDocumentType.HistoricalVersion
- }, true);
+ });
num++;
+
+ await _auditDocumentRepository.SaveChangesAsync();
+ }
+
+ if (inDto.Id == null)
+ {
+ //维护新增闭包关系
+ await AddClosureRelationsAsync(entityData.Id, entityData.ParentId);
}
return entityData;
}
}
-
+ //同层级没找到同名的文件,那么走正常的新增 和更新
var entity = await _auditDocumentRepository.InsertOrUpdateAsync(inDto, true);
+
+ if (inDto.Id == null)
+ {
+ //维护新增闭包关系
+ await AddClosureRelationsAsync(entity.Id, entity.ParentId);
+ }
+
return entity;
}
+ #endregion
+
+
+ #region 闭包后续废弃方法
+
+
+
///
- /// 获取面包屑导航
+ /// 删除稽查文档
///
///
///
[HttpPost]
- public async Task> GetBreadcrumbData(GetBreadcrumbDataInDto inDto)
+ public async Task DeleteAuditDocument(DeleteAuditDocumentInDto inDto)
{
- List result = new List();
-
- await findParent(result, inDto.Id);
- async Task findParent(List datas, Guid id)
+ var data = await _auditDocumentRepository.Select(x => new DeleteAudit()
{
- var data = await _auditDocumentRepository.Where(x => x.Id == id).ProjectTo(_mapper.ConfigurationProvider).FirstNotNullAsync();
- datas.Add(data);
- if (data.ParentId != null)
+ Id = x.Id,
+ ParentId = x.ParentId,
+ MainFileId = x.MainFileId
+ }).ToListAsync();
+
+ List DeleteId = inDto.Ids;
+
+ finId(inDto.Ids, data);
+
+ void finId(List deletids, List deletes)
+ {
+ DeleteId.AddRange(deletids);
+
+ var temp = deletes.Where(x => (x.ParentId != null && deletids.Contains(x.ParentId.Value)) || (x.MainFileId != null && deletids.Contains(x.MainFileId.Value))).Select(x => x.Id).ToList();
+ if (temp.Count() > 0)
{
- await findParent(datas, data.ParentId.Value);
+ finId(temp, deletes);
}
+ }
+
+ DeleteId = DeleteId.Distinct().ToList();
+ var mainFileId = await _auditDocumentRepository.Where(x => DeleteId.Contains(x.Id) && x.MainFileId != null).Select(x => x.MainFileId).Distinct().ToListAsync();
+ var success = await _auditDocumentRepository.DeleteFromQueryAsync(t => DeleteId.Distinct().Contains(t.Id), true);
+
+ foreach (var item in mainFileId)
+ {
+ var historicalVersionList = await _auditDocumentRepository.Where(x => x.MainFileId == item).OrderBy(x => x.Version).ToListAsync();
+
+ var num = 1;
+ foreach (var historical in historicalVersionList)
+ {
+ await _auditDocumentRepository.UpdatePartialFromQueryAsync(historical.Id, x => new AuditDocument()
+ {
+ Version = num,
+ }, true);
+ num++;
+ }
+
+
}
- result.Reverse();
- return result;
+ return ResponseOutput.Ok();
+
}
@@ -403,65 +854,6 @@ public class AuditDocumentService(IRepository _auditDocumentRepos
GetChildren(x, dataList, historyList);
}
}
-
- ///
- /// 删除稽查文档
- ///
- ///
- ///
- [HttpPost]
- public async Task DeleteAuditDocument(DeleteAuditDocumentInDto inDto)
- {
- var data = await _auditDocumentRepository.Select(x => new DeleteAudit()
- {
- Id = x.Id,
- ParentId = x.ParentId,
- MainFileId = x.MainFileId
- }).ToListAsync();
-
- List DeleteId = inDto.Ids;
-
- finId(inDto.Ids, data);
-
- void finId(List deletids, List deletes)
- {
- DeleteId.AddRange(deletids);
-
- var temp = deletes.Where(x => (x.ParentId != null && deletids.Contains(x.ParentId.Value)) || (x.MainFileId != null && deletids.Contains(x.MainFileId.Value))).Select(x => x.Id).ToList();
- if (temp.Count() > 0)
- {
- finId(temp, deletes);
- }
- }
-
- DeleteId = DeleteId.Distinct().ToList();
- var mainFileId = await _auditDocumentRepository.Where(x => DeleteId.Contains(x.Id) && x.MainFileId != null).Select(x => x.MainFileId).Distinct().ToListAsync();
- var success = await _auditDocumentRepository.DeleteFromQueryAsync(t => DeleteId.Distinct().Contains(t.Id), true);
-
- foreach (var item in mainFileId)
- {
- var historicalVersionList = await _auditDocumentRepository.Where(x => x.MainFileId == item).OrderBy(x => x.Version).ToListAsync();
-
- var num = 1;
- foreach (var historical in historicalVersionList)
- {
- await _auditDocumentRepository.UpdatePartialFromQueryAsync(historical.Id, x => new AuditDocument()
- {
- Version = num,
- }, true);
- num++;
- }
-
-
-
- }
-
-
- return ResponseOutput.Ok();
-
-
- }
-
///
/// 移动文件或者文件夹 到其他文件夹
///
@@ -575,70 +967,6 @@ public class AuditDocumentService(IRepository _auditDocumentRepos
return ResponseOutput.Ok();
}
- ///
- /// 获取历史版本
- ///
- ///
- ///
- [HttpPost]
- public async Task> GetHistoricalVersion(GetHistoricalVersionInDto inDto)
- {
-
- List result = new List();
-
- result = await _auditDocumentRepository.Where(x => x.MainFileId == inDto.Id).ProjectTo(_mapper.ConfigurationProvider).OrderByDescending(x => x.Version).ToListAsync();
- var currentData = await _auditDocumentRepository.Where(x => x.Id == inDto.Id).ProjectTo(_mapper.ConfigurationProvider).FirstNotNullAsync();
- currentData.IsCurrentVersion = true;
-
- result.Insert(0, currentData);
-
- return result;
- }
-
- ///
- /// 把历史版本设置为当前版本
- ///
- ///
- [HttpPost]
- public async Task SetCurrentVersion(SetCurrentVersionInDto inDto)
- {
- var file = await _auditDocumentRepository.Where(x => x.Id == inDto.Id).FirstNotNullAsync();
- if (file.AuditDocumentTypeEnum != AuditDocumentType.HistoricalVersion)
- {
- throw new BusinessValidationFailedException(_localizer["AuditDocument_CanNotSetCurrentVersion"]);
- }
-
- var mainFile = await _auditDocumentRepository.Where(x => x.Id == file.MainFileId).FirstNotNullAsync();
-
- var historicalVersionIds = await _auditDocumentRepository.Where(x => x.MainFileId == mainFile.Id && x.Id != inDto.Id).OrderBy(x => x.Version).Select(x => x.Id).ToListAsync();
-
- historicalVersionIds.Add(mainFile.Id);
- await _auditDocumentRepository.UpdatePartialFromQueryAsync(inDto.Id, x => new AuditDocument()
- {
- MainFileId = null,
- ParentId = mainFile.ParentId,
- AuditDocumentTypeEnum = AuditDocumentType.File,
- });
-
- int num = 1;
- foreach (var item in historicalVersionIds)
- {
- await _auditDocumentRepository.UpdatePartialFromQueryAsync(item, x => new AuditDocument()
- {
- MainFileId = inDto.Id,
- ParentId = null,
- Version = num,
- AuditDocumentTypeEnum = AuditDocumentType.HistoricalVersion
- });
- num++;
- }
-
- await _auditDocumentRepository.SaveChangesAsync();
-
-
- return ResponseOutput.Ok();
-
- }
///
/// 设置是否授权
@@ -700,6 +1028,9 @@ public class AuditDocumentService(IRepository _auditDocumentRepos
}
}
+ #endregion
+
+
}
diff --git a/IRaCIS.Core.Application/Service/Document/DTO/AuditDocumentViewModel.cs b/IRaCIS.Core.Application/Service/Document/DTO/AuditDocumentViewModel.cs
index b67be4a32..9dee2cadf 100644
--- a/IRaCIS.Core.Application/Service/Document/DTO/AuditDocumentViewModel.cs
+++ b/IRaCIS.Core.Application/Service/Document/DTO/AuditDocumentViewModel.cs
@@ -104,6 +104,9 @@ public class GetAuditDocumentDataInDto : PageInput
public bool? IsAuthorization { get; set; }
public string Name { get; set; } = string.Empty;
+
+ //当前稽查记录Id
+ public Guid? AuditRecordId { get; set; }
}
public class GetAuditDocumentDataOutDto
@@ -125,6 +128,9 @@ public class AuditDocumentData : AuditDocumentUpdateDto
public int HistoricalVersionsCount { get; set; }
public List Children { get; set; } = new List() { };
+
+ public bool? IsCurrentAuditRecordAuthorization { get; set; }
+
}
public class AuditDocumentView : AuditDocumentAddOrEdit
diff --git a/IRaCIS.Core.Application/Service/Document/_MapConfig.cs b/IRaCIS.Core.Application/Service/Document/_MapConfig.cs
index 97848e01e..2e2b617f7 100644
--- a/IRaCIS.Core.Application/Service/Document/_MapConfig.cs
+++ b/IRaCIS.Core.Application/Service/Document/_MapConfig.cs
@@ -29,7 +29,8 @@ namespace IRaCIS.Core.Application.Service
CreateMap();
CreateMap();
CreateMap();
- CreateMap();
+ CreateMap()
+ .ForMember(d => d.HistoricalVersionsCount, u => u.MapFrom(s => s.AuditDocumentOldVersionList.Count()));
CreateMap().ReverseMap();
CreateMap()
.ForMember(d => d.AttachmentCount, u => u.MapFrom(s => s.SystemDocumentAttachmentList.Count()))
diff --git a/IRaCIS.Core.Application/TestService.cs b/IRaCIS.Core.Application/TestService.cs
index 31ef1f498..ba4f6d478 100644
--- a/IRaCIS.Core.Application/TestService.cs
+++ b/IRaCIS.Core.Application/TestService.cs
@@ -73,6 +73,63 @@ namespace IRaCIS.Core.Application.Service
ILogger _logger, IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer) : BaseService
{
public static int IntValue = 100;
+
+ ///
+ /// 重建闭包表
+ ///
+ ///
+ ///
+ ///
+ [AllowAnonymous]
+ public async Task RebuildAuditDocumentClosureAsync([FromServices]IRepository _auditDocumentClosureRepository, [FromServices] IRepository _auditDocumentRepository)
+ {
+ var documents = await _auditDocumentRepository.Where().Select(t=>new {t.Id,t.ParentId}).ToListAsync();
+
+ var closures = new List();
+
+ // 建立一个字典,加快查找
+ var lookup = documents.ToDictionary(d => d.Id, d => d.ParentId);
+
+ foreach (var doc in documents)
+ {
+ // 1️ 自己 -> 自己 (depth = 0)
+ closures.Add(new AuditDocumentClosure
+ {
+ AncestorId = doc.Id,
+ DescendantId = doc.Id,
+ Depth = 0
+ });
+
+ // 2️ 递归向上找所有祖先
+ int depth = 1;
+ var currentParentId = doc.ParentId;
+
+ while (currentParentId.HasValue)
+ {
+ closures.Add(new AuditDocumentClosure
+ {
+ AncestorId = currentParentId.Value,
+ DescendantId = doc.Id,
+ Depth = depth
+ });
+
+ depth++;
+
+ // 继续向上查找
+ if (!lookup.TryGetValue(currentParentId.Value, out var nextParent))
+ break;
+
+ currentParentId = nextParent;
+ }
+ }
+
+
+
+ await _auditDocumentClosureRepository.AddRangeAsync(closures);
+ await _auditDocumentClosureRepository.SaveChangesAsync();
+ }
+
+
///
/// 清理一致性分析任务
///
diff --git a/IRaCIS.Core.Domain/Document/AuditDocument.cs b/IRaCIS.Core.Domain/Document/AuditDocument.cs
index 801ba5f63..4abcc87ce 100644
--- a/IRaCIS.Core.Domain/Document/AuditDocument.cs
+++ b/IRaCIS.Core.Domain/Document/AuditDocument.cs
@@ -11,7 +11,19 @@ namespace IRaCIS.Core.Domain.Models
[Table("AuditDocument")]
public class AuditDocument : BaseFullAuditEntity
{
+ // 0=自己, 1=直接子节点, 2=孙节点...
+ [JsonIgnore]
+ public List AncestorList { get; set; } = new List();
+ [JsonIgnore]
+ public List DescendantList { get; set; } = new List();
+
+ [JsonIgnore]
+ public List AuditDocumentOldVersionList { get; set; }
+
+ [JsonIgnore]
+ [ForeignKey(nameof(MainFileId))]
+ public AuditDocument MainAuditDocument { get; set; }
///
/// 文件夹名或者文件名
///
@@ -81,6 +93,27 @@ namespace IRaCIS.Core.Domain.Models
}
+ ///
+ /// 稽查文档闭包表
+ ///
+ public class AuditDocumentClosure : Entity
+ {
+ [JsonIgnore]
+
+ public AuditDocument Ancestor { get; set; }
+
+ [JsonIgnore]
+
+ public AuditDocument Descendant { get; set; }
+
+ [Comment("祖先")]
+ public Guid AncestorId { get; set; }
+
+ [Comment("后代")]
+ public Guid DescendantId { get; set; }
+ public int Depth { get; set; } // 0=自己, 1=直接子节点, 2=孙节点...
+ }
+
public class AuditRecord : BaseFullAuditEntity
{
diff --git a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs
index fe750de68..f8b4aee21 100644
--- a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs
+++ b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs
@@ -679,7 +679,9 @@ public class IRaCISDBContext : DbContext
public virtual DbSet AuditRecordIdentityUser { get; set; }
public virtual DbSet AuditRecordPermission { get; set; }
+ public virtual DbSet AuditDocumentClosure { get; set; }
+
}
public class TestLength : Entity
diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/AuditDocumentConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/AuditDocumentConfigration.cs
new file mode 100644
index 000000000..8e904cc95
--- /dev/null
+++ b/IRaCIS.Core.Infra.EFCore/EntityConfigration/AuditDocumentConfigration.cs
@@ -0,0 +1,40 @@
+using IRaCIS.Core.Domain.Models;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+
+
+namespace IRaCIS.Core.Infra.EFCore.EntityConfigration
+{
+ public class AuditDocumentConfigration : IEntityTypeConfiguration
+ {
+
+
+ public void Configure(EntityTypeBuilder builder)
+ {
+
+ builder.HasMany(r => r.AncestorList).WithOne(t => t.Descendant).HasForeignKey(f => f.DescendantId);
+
+ builder.HasMany(r => r.DescendantList).WithOne(t => t.Ancestor).HasForeignKey(f => f.AncestorId);
+
+
+ builder.HasMany(r => r.AuditDocumentOldVersionList).WithOne(t => t.MainAuditDocument).HasForeignKey(f => f.MainFileId);
+
+
+ // builder.HasOne(r => r.WordFileRecord)
+ //.WithOne(t => t.WordFileRecord)
+ //.HasForeignKey(t => t.WordFileRecordId)
+ //.OnDelete(DeleteBehavior.Cascade);
+ // builder.HasOne(r => r.PDFFileRecord).WithOne().HasForeignKey(f => f.TrialFileTypeId);
+
+ // builder.HasOne(r => r.WordFileRecord).WithOne().HasForeignKey(f => f.TrialFileTypeId);
+
+ // builder.HasOne(r => r.SignFileRecord).WithOne().HasForeignKey(f => f.TrialFileTypeId);
+
+ // builder.HasOne(r => r.HistoryFileRecord).WithOne().HasForeignKey(f => f.TrialFileTypeId);
+
+ }
+ }
+
+
+
+}
diff --git a/IRaCIS.Core.Infra.EFCore/Migrations/20250926134643_modifyAudictDoc.Designer.cs b/IRaCIS.Core.Infra.EFCore/Migrations/20250926134643_modifyAudictDoc.Designer.cs
new file mode 100644
index 000000000..641522a8d
--- /dev/null
+++ b/IRaCIS.Core.Infra.EFCore/Migrations/20250926134643_modifyAudictDoc.Designer.cs
@@ -0,0 +1,20336 @@
+//
+using System;
+using IRaCIS.Core.Infra.EFCore;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace IRaCIS.Core.Infra.EFCore.Migrations
+{
+ [DbContext(typeof(IRaCISDBContext))]
+ [Migration("20250926134643_modifyAudictDoc")]
+ partial class modifyAudictDoc
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "8.0.19")
+ .HasAnnotation("Relational:MaxIdentifierLength", 128);
+
+ SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
+
+ modelBuilder.Entity("IRaCIS.Core.Domain.Models.Attachment", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("Code")
+ .IsRequired()
+ .HasMaxLength(400)
+ .HasColumnType("nvarchar(400)")
+ .HasComment("编码");
+
+ b.Property("CreateTime")
+ .HasColumnType("datetime2");
+
+ b.Property("CreateUserId")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("DoctorId")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("ExpiryDate")
+ .HasColumnType("datetime2")
+ .HasComment("过期时间");
+
+ b.Property("FileName")
+ .IsRequired()
+ .HasMaxLength(400)
+ .HasColumnType("nvarchar(400)");
+
+ b.Property("IsAuthorizedView")
+ .HasColumnType("bit");
+
+ b.Property("IsOfficial")
+ .HasColumnType("bit")
+ .HasComment("是否正式简历");
+
+ b.Property("Language")
+ .HasColumnType("int")
+ .HasComment("1 中文 2为英文");
+
+ b.Property("Path")
+ .IsRequired()
+ .HasMaxLength(1000)
+ .HasColumnType("nvarchar(1000)");
+
+ b.Property("TrialId")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("Type")
+ .IsRequired()
+ .HasMaxLength(400)
+ .HasColumnType("nvarchar(400)")
+ .HasComment("文件类型名");
+
+ b.Property("UpdateTime")
+ .HasColumnType("datetime2");
+
+ b.Property("UpdateUserId")
+ .HasColumnType("uniqueidentifier");
+
+ b.HasKey("Id");
+
+ b.HasIndex("CreateUserId");
+
+ b.HasIndex("DoctorId");
+
+ b.ToTable("Attachment", t =>
+ {
+ t.HasComment("医生 - 简历|证书 文档表");
+ });
+ });
+
+ modelBuilder.Entity("IRaCIS.Core.Domain.Models.AuditDocument", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("AuditDocumentTypeEnum")
+ .HasColumnType("int");
+
+ b.Property("CreateTime")
+ .HasColumnType("datetime2");
+
+ b.Property("CreateUserId")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("FileFormat")
+ .IsRequired()
+ .HasMaxLength(400)
+ .HasColumnType("nvarchar(400)");
+
+ b.Property("FilePath")
+ .IsRequired()
+ .HasMaxLength(1000)
+ .HasColumnType("nvarchar(1000)");
+
+ b.Property("FileSize")
+ .HasPrecision(18, 2)
+ .HasColumnType("decimal(18,2)");
+
+ b.Property("IsAuthorization")
+ .HasColumnType("bit");
+
+ b.Property("MainFileId")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(400)
+ .HasColumnType("nvarchar(400)");
+
+ b.Property("ParentId")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("UpdateTime")
+ .HasColumnType("datetime2");
+
+ b.Property("UpdateUserId")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("Version")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("CreateUserId");
+
+ b.HasIndex("MainFileId");
+
+ b.ToTable("AuditDocument", t =>
+ {
+ t.HasComment("稽查文档管理");
+ });
+ });
+
+ modelBuilder.Entity("IRaCIS.Core.Domain.Models.AuditDocumentClosure", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("AncestorId")
+ .HasColumnType("uniqueidentifier")
+ .HasComment("祖先");
+
+ b.Property("Depth")
+ .HasColumnType("int");
+
+ b.Property("DescendantId")
+ .HasColumnType("uniqueidentifier")
+ .HasComment("后代");
+
+ b.HasKey("Id");
+
+ b.HasIndex("AncestorId");
+
+ b.HasIndex("DescendantId");
+
+ b.ToTable("AuditDocumentClosure");
+ });
+
+ modelBuilder.Entity("IRaCIS.Core.Domain.Models.AuditRecord", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("AuditContent")
+ .IsRequired()
+ .HasMaxLength(400)
+ .HasColumnType("nvarchar(400)");
+
+ b.Property("AuditState")
+ .HasColumnType("int")
+ .HasComment("稽查状态");
+
+ b.Property("AuditTime")
+ .HasColumnType("date")
+ .HasComment("稽查日期");
+
+ b.Property("AuditType")
+ .HasColumnType("int")
+ .HasComment("稽查形式");
+
+ b.Property("BeginTime")
+ .HasColumnType("datetime2");
+
+ b.Property("CompanyName")
+ .IsRequired()
+ .HasMaxLength(400)
+ .HasColumnType("nvarchar(400)");
+
+ b.Property("CreateTime")
+ .HasColumnType("datetime2");
+
+ b.Property("CreateUserId")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("EndTime")
+ .HasColumnType("datetime2");
+
+ b.Property("UpdateTime")
+ .HasColumnType("datetime2");
+
+ b.Property("UpdateUserId")
+ .HasColumnType("uniqueidentifier");
+
+ b.HasKey("Id");
+
+ b.HasIndex("CreateUserId");
+
+ b.ToTable("AuditRecord");
+ });
+
+ modelBuilder.Entity("IRaCIS.Core.Domain.Models.AuditRecordIdentityUser", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("AuditRecordId")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("CreateTime")
+ .HasColumnType("datetime2");
+
+ b.Property("CreateUserId")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("IdentityUserId")
+ .HasColumnType("uniqueidentifier");
+
+ b.HasKey("Id");
+
+ b.HasIndex("AuditRecordId");
+
+ b.HasIndex("CreateUserId");
+
+ b.HasIndex("IdentityUserId");
+
+ b.ToTable("AuditRecordIdentityUser");
+ });
+
+ modelBuilder.Entity("IRaCIS.Core.Domain.Models.AuditRecordPermission", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("AuditDocumentId")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("AuditRecordId")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("CreateTime")
+ .HasColumnType("datetime2");
+
+ b.Property("CreateUserId")
+ .HasColumnType("uniqueidentifier");
+
+ b.HasKey("Id");
+
+ b.HasIndex("AuditDocumentId");
+
+ b.HasIndex("AuditRecordId");
+
+ b.HasIndex("CreateUserId");
+
+ b.ToTable("AuditRecordPermission");
+ });
+
+ modelBuilder.Entity("IRaCIS.Core.Domain.Models.CRO", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("CROCode")
+ .IsRequired()
+ .HasMaxLength(400)
+ .HasColumnType("nvarchar(400)");
+
+ b.Property("CROName")
+ .IsRequired()
+ .HasMaxLength(400)
+ .HasColumnType("nvarchar(400)");
+
+ b.Property("CRONameCN")
+ .IsRequired()
+ .HasMaxLength(400)
+ .HasColumnType("nvarchar(400)");
+
+ b.Property("CreateTime")
+ .HasColumnType("datetime2");
+
+ b.Property("CreateUserId")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("IsTrialLevel")
+ .HasColumnType("bit")
+ .HasComment("是否是项目级别");
+
+ b.Property("TrialId")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("UpdateTime")
+ .HasColumnType("datetime2");
+
+ b.Property("UpdateUserId")
+ .HasColumnType("uniqueidentifier");
+
+ b.HasKey("Id");
+
+ b.HasIndex("CreateUserId");
+
+ b.ToTable("CROCompany", t =>
+ {
+ t.HasComment("机构 - CRO");
+ });
+ });
+
+ modelBuilder.Entity("IRaCIS.Core.Domain.Models.CheckChallengeDialog", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("CreateTime")
+ .HasColumnType("datetime2");
+
+ b.Property("CreateUserId")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("IsCRCNeedReply")
+ .HasColumnType("bit")
+ .HasComment("CRC是否需要回复 前端使用");
+
+ b.Property("ParamInfo")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)")
+ .HasComment("核查的检查信息Json");
+
+ b.Property("SubjectVisitId")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("TalkContent")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("UserTypeEnum")
+ .HasColumnType("int")
+ .HasComment("核查过程中的操作用户类型");
+
+ b.HasKey("Id");
+
+ b.HasIndex("CreateUserId");
+
+ b.HasIndex("SubjectVisitId");
+
+ b.ToTable("CheckChallengeDialog", t =>
+ {
+ t.HasComment("一致性核查 - 对话记录表");
+ });
+ });
+
+ modelBuilder.Entity("IRaCIS.Core.Domain.Models.ClinicalAnswerRowInfo", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("ClinicalFormId")
+ .HasColumnType("uniqueidentifier")
+ .HasComment("表单Id");
+
+ b.Property("CreateTime")
+ .HasColumnType("datetime2");
+
+ b.Property("CreateUserId")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("QuestionId")
+ .HasColumnType("uniqueidentifier")
+ .HasComment("问题Id");
+
+ b.Property("RowIndex")
+ .HasColumnType("int");
+
+ b.Property("SubjectId")
+ .HasColumnType("uniqueidentifier")
+ .HasComment("受试者Id");
+
+ b.HasKey("Id");
+
+ b.HasIndex("CreateUserId");
+
+ b.ToTable("ClinicalAnswerRowInfo", t =>
+ {
+ t.HasComment("受试者 - 临床表单表格问题行记录");
+ });
+ });
+
+ modelBuilder.Entity("IRaCIS.Core.Domain.Models.ClinicalDataSystemSet", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("ClinicalDataLevel")
+ .HasColumnType("int");
+
+ b.Property("ClinicalDataSetEnName")
+ .IsRequired()
+ .HasMaxLength(400)
+ .HasColumnType("nvarchar(400)");
+
+ b.Property("ClinicalDataSetEnum")
+ .HasColumnType("int")
+ .HasComment("枚举(字典里面取的)");
+
+ b.Property("ClinicalDataSetName")
+ .IsRequired()
+ .HasMaxLength(400)
+ .HasColumnType("nvarchar(400)");
+
+ b.Property("ClinicalUploadType")
+ .HasColumnType("int")
+ .HasComment("上传方式");
+
+ b.Property("CreateTime")
+ .HasColumnType("datetime2");
+
+ b.Property("CreateUserId")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("CriterionEnumListStr")
+ .IsRequired()
+ .HasMaxLength(1000)
+ .HasColumnType("nvarchar(1000)");
+
+ b.Property("EnFileName")
+ .IsRequired()
+ .HasMaxLength(400)
+ .HasColumnType("nvarchar(400)");
+
+ b.Property("EnPath")
+ .IsRequired()
+ .HasMaxLength(400)
+ .HasColumnType("nvarchar(400)");
+
+ b.Property("FileName")
+ .IsRequired()
+ .HasMaxLength(400)
+ .HasColumnType("nvarchar(400)");
+
+ b.Property("IsApply")
+ .HasColumnType("bit")
+ .HasComment("是否应用");
+
+ b.Property("IsEnable")
+ .HasColumnType("bit");
+
+ b.Property("Path")
+ .IsRequired()
+ .HasMaxLength(1000)
+ .HasColumnType("nvarchar(1000)");
+
+ b.Property("UploadRole")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("CreateUserId");
+
+ b.ToTable("ClinicalDataSystemSet", t =>
+ {
+ t.HasComment("系统 - 临床数据配置");
+ });
+ });
+
+ modelBuilder.Entity("IRaCIS.Core.Domain.Models.ClinicalDataTrialSet", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("ClinicalDataLevel")
+ .HasColumnType("int")
+ .HasComment("临床级别");
+
+ b.Property("ClinicalDataSetEnName")
+ .IsRequired()
+ .HasMaxLength(400)
+ .HasColumnType("nvarchar(400)");
+
+ b.Property("ClinicalDataSetName")
+ .IsRequired()
+ .HasMaxLength(400)
+ .HasColumnType("nvarchar(400)");
+
+ b.Property("ClinicalUploadType")
+ .HasColumnType("int")
+ .HasComment("上传方式");
+
+ b.Property("CreateTime")
+ .HasColumnType("datetime2");
+
+ b.Property("CreateUserId")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("CriterionEnumListStr")
+ .IsRequired()
+ .HasMaxLength(1000)
+ .HasColumnType("nvarchar(1000)");
+
+ b.Property("EnFileName")
+ .IsRequired()
+ .HasMaxLength(400)
+ .HasColumnType("nvarchar(400)");
+
+ b.Property("EnPath")
+ .IsRequired()
+ .HasMaxLength(400)
+ .HasColumnType("nvarchar(400)");
+
+ b.Property("FileName")
+ .IsRequired()
+ .HasMaxLength(400)
+ .HasColumnType("nvarchar(400)");
+
+ b.Property("IsApply")
+ .HasColumnType("bit")
+ .HasComment("是否应用");
+
+ b.Property("IsConfirm")
+ .HasColumnType("bit");
+
+ b.Property("Path")
+ .IsRequired()
+ .HasMaxLength(1000)
+ .HasColumnType("nvarchar(1000)");
+
+ b.Property("SystemClinicalDataSetId")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("TrialId")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("UploadRole")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("CreateUserId");
+
+ b.HasIndex("SystemClinicalDataSetId");
+
+ b.HasIndex("TrialId");
+
+ b.ToTable("ClinicalDataTrialSet", t =>
+ {
+ t.HasComment("项目 - 临床数据适应标准配置");
+ });
+ });
+
+ modelBuilder.Entity("IRaCIS.Core.Domain.Models.ClinicalForm", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("CheckDate")
+ .HasColumnType("datetime2")
+ .HasComment("检查日期");
+
+ b.Property("ClinicalDataTrialSetId")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("CreateTime")
+ .HasColumnType("datetime2");
+
+ b.Property("CreateUserId")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("PicturePath")
+ .IsRequired()
+ .HasMaxLength(1000)
+ .HasColumnType("nvarchar(1000)")
+ .HasComment("截图地址");
+
+ b.Property("ReadingId")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("SubjectId")
+ .HasColumnType("uniqueidentifier")
+ .HasComment("受试者Id");
+
+ b.Property("TrialId")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("VisitId")
+ .HasColumnType("uniqueidentifier");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ClinicalDataTrialSetId");
+
+ b.HasIndex("CreateUserId");
+
+ b.HasIndex("ReadingId");
+
+ b.HasIndex("SubjectId");
+
+ b.ToTable("ClinicalForm", t =>
+ {
+ t.HasComment("受试者 - 临床表单");
+ });
+ });
+
+ modelBuilder.Entity("IRaCIS.Core.Domain.Models.ClinicalQuestionAnswer", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("Answer")
+ .IsRequired()
+ .HasMaxLength(1000)
+ .HasColumnType("nvarchar(1000)");
+
+ b.Property("ClinicalDataTrialSetId")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("ClinicalFormId")
+ .HasColumnType("uniqueidentifier")
+ .HasComment("表单Id");
+
+ b.Property("CreateTime")
+ .HasColumnType("datetime2");
+
+ b.Property("CreateUserId")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("QuestionId")
+ .HasColumnType("uniqueidentifier")
+ .HasComment("问题Id");
+
+ b.Property("SubjectId")
+ .HasColumnType("uniqueidentifier")
+ .HasComment("受试者Id");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ClinicalFormId");
+
+ b.HasIndex("CreateUserId");
+
+ b.ToTable("ClinicalQuestionAnswer", t =>
+ {
+ t.HasComment("受试者 - 临床表单问题答案");
+ });
+ });
+
+ modelBuilder.Entity("IRaCIS.Core.Domain.Models.ClinicalTableAnswer", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("Answer")
+ .IsRequired()
+ .HasMaxLength(1000)
+ .HasColumnType("nvarchar(1000)")
+ .HasComment("答案");
+
+ b.Property("ClinicalFormId")
+ .HasColumnType("uniqueidentifier")
+ .HasComment("表单Id");
+
+ b.Property("CreateTime")
+ .HasColumnType("datetime2");
+
+ b.Property("CreateUserId")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("QuestionId")
+ .HasColumnType("uniqueidentifier")
+ .HasComment("问题Id");
+
+ b.Property("RowId")
+ .HasColumnType("uniqueidentifier")
+ .HasComment("答案行的Id");
+
+ b.Property("SubjectId")
+ .HasColumnType("uniqueidentifier")
+ .HasComment("受试者Id");
+
+ b.Property("TableQuestionId")
+ .HasColumnType("uniqueidentifier");
+
+ b.HasKey("Id");
+
+ b.HasIndex("CreateUserId");
+
+ b.HasIndex("RowId");
+
+ b.ToTable("ClinicalTableAnswer", t =>
+ {
+ t.HasComment("受试者 - 临床表单表格问题答案");
+ });
+ });
+
+ modelBuilder.Entity("IRaCIS.Core.Domain.Models.CommonDocument", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("BusinessScenarioEnum")
+ .HasColumnType("int")
+ .HasComment("业务场景");
+
+ b.Property("Code")
+ .IsRequired()
+ .HasMaxLength(400)
+ .HasColumnType("nvarchar(400)");
+
+ b.Property("CreateTime")
+ .HasColumnType("datetime2");
+
+ b.Property("CreateUserId")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("CriterionTypeEnum")
+ .HasColumnType("int")
+ .HasComment("系统标准枚举");
+
+ b.Property("DeleteUserId")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("DeletedTime")
+ .HasColumnType("datetime2");
+
+ b.Property("Description")
+ .IsRequired()
+ .HasMaxLength(400)
+ .HasColumnType("nvarchar(400)");
+
+ b.Property("FileTypeEnum")
+ .HasColumnType("int")
+ .HasComment("类型-上传|导出|邮件附件");
+
+ b.Property("IsDeleted")
+ .HasColumnType("bit");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(400)
+ .HasColumnType("nvarchar(400)");
+
+ b.Property("NameCN")
+ .IsRequired()
+ .HasMaxLength(400)
+ .HasColumnType("nvarchar(400)");
+
+ b.Property("Path")
+ .IsRequired()
+ .HasMaxLength(400)
+ .HasColumnType("nvarchar(400)");
+
+ b.Property("UpdateTime")
+ .HasColumnType("datetime2");
+
+ b.Property("UpdateUserId")
+ .HasColumnType("uniqueidentifier");
+
+ b.HasKey("Id");
+
+ b.HasIndex("CreateUserId");
+
+ b.ToTable("CommonDocument", t =>
+ {
+ t.HasComment("数据上传 | 数据导出 | 邮件附件 文件记录表 (需要同步)");
+ });
+ });
+
+ modelBuilder.Entity("IRaCIS.Core.Domain.Models.CriterionNidusSystem", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("CreateTime")
+ .HasColumnType("datetime2");
+
+ b.Property("CreateUserId")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("CriterionId")
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("IsSystemCriterion")
+ .HasColumnType("bit");
+
+ b.Property