修改匿名化配置,更新缓存,同时增加代码自动替换excel 关键字
parent
924347361a
commit
020c5280b3
|
|
@ -17516,17 +17516,17 @@
|
||||||
</member>
|
</member>
|
||||||
<member name="F:IRaCIS.Core.Application.ViewModel.AccessToDialogueEnum.Question">
|
<member name="F:IRaCIS.Core.Application.ViewModel.AccessToDialogueEnum.Question">
|
||||||
<summary>
|
<summary>
|
||||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
质疑
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="F:IRaCIS.Core.Application.ViewModel.AccessToDialogueEnum.Consistency">
|
<member name="F:IRaCIS.Core.Application.ViewModel.AccessToDialogueEnum.Consistency">
|
||||||
<summary>
|
<summary>
|
||||||
һ<EFBFBD><EFBFBD><EFBFBD>Ժ˲<EFBFBD>
|
一致性核查
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="T:IRaCIS.Core.Application.ViewModel.CopyFrontAuditConfigItemDto">
|
<member name="T:IRaCIS.Core.Application.ViewModel.CopyFrontAuditConfigItemDto">
|
||||||
<summary>
|
<summary>
|
||||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
复制
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="T:IRaCIS.Core.Application.ViewModel.SystemNoticeView">
|
<member name="T:IRaCIS.Core.Application.ViewModel.SystemNoticeView">
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
using IRaCIS.Core.Application.Helper;
|
||||||
using IRaCIS.Core.Application.Interfaces;
|
using IRaCIS.Core.Application.Interfaces;
|
||||||
using IRaCIS.Core.Application.ViewModel;
|
using IRaCIS.Core.Application.ViewModel;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
@ -13,7 +14,7 @@ namespace IRaCIS.Core.Application.Service
|
||||||
/// SystemAnonymizationService
|
/// SystemAnonymizationService
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ApiExplorerSettings(GroupName = "Image")]
|
[ApiExplorerSettings(GroupName = "Image")]
|
||||||
public class SystemAnonymizationService(IRepository<SystemAnonymization> _systemAnonymizationRepository, IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer) : BaseService, ISystemAnonymizationService
|
public class SystemAnonymizationService(IRepository<SystemAnonymization> _systemAnonymizationRepository, IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer, IFusionCache _fusionCache) : BaseService, ISystemAnonymizationService
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -37,6 +38,7 @@ namespace IRaCIS.Core.Application.Service
|
||||||
|
|
||||||
var entity = await _systemAnonymizationRepository.InsertOrUpdateAsync(addOrEditSystemAnonymization, true);
|
var entity = await _systemAnonymizationRepository.InsertOrUpdateAsync(addOrEditSystemAnonymization, true);
|
||||||
|
|
||||||
|
await _fusionCache.SetAsync(CacheKeys.SystemAnonymization, CacheHelper.GetSystemAnonymizationListAsync(_systemAnonymizationRepository), TimeSpan.FromDays(7));
|
||||||
|
|
||||||
return ResponseOutput.Ok(entity.Id.ToString());
|
return ResponseOutput.Ok(entity.Id.ToString());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using Aliyun.OSS;
|
using Aliyun.OSS;
|
||||||
|
using ClosedXML.Excel;
|
||||||
using FellowOakDicom;
|
using FellowOakDicom;
|
||||||
using FellowOakDicom.Imaging;
|
using FellowOakDicom.Imaging;
|
||||||
using IRaCIS.Application.Contracts;
|
using IRaCIS.Application.Contracts;
|
||||||
|
|
@ -56,6 +57,126 @@ namespace IRaCIS.Core.Application.Service
|
||||||
{
|
{
|
||||||
public static int IntValue = 100;
|
public static int IntValue = 100;
|
||||||
|
|
||||||
|
static string ReplaceText(string text, Dictionary<string, string> replaceRules)
|
||||||
|
{
|
||||||
|
foreach (var rule in replaceRules)
|
||||||
|
{
|
||||||
|
text = text.Replace(rule.Key, rule.Value, StringComparison.OrdinalIgnoreCase);
|
||||||
|
}
|
||||||
|
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
public async Task<IResponseOutput> ExcelReplaceKeyWord()
|
||||||
|
{
|
||||||
|
string folderPath = @"C:\Users\PC\Downloads\SystemData(1)\SystemData\DataTemplate";
|
||||||
|
|
||||||
|
var replaceRules = new Dictionary<string, string>
|
||||||
|
{
|
||||||
|
["受试者"] = "试验参与者",
|
||||||
|
["Subject"] = "Participant"
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (var file in Directory.GetFiles(folderPath, "*.xlsx", SearchOption.AllDirectories))
|
||||||
|
{
|
||||||
|
Console.WriteLine($"处理文件:{file}");
|
||||||
|
|
||||||
|
using var workbook = new XLWorkbook(file);
|
||||||
|
|
||||||
|
bool changed = false;
|
||||||
|
|
||||||
|
foreach (var ws in workbook.Worksheets.ToList())
|
||||||
|
{
|
||||||
|
#region Sheet名称
|
||||||
|
|
||||||
|
var originalName = ws.Name;
|
||||||
|
|
||||||
|
string newSheetName = ReplaceText(originalName, replaceRules);
|
||||||
|
|
||||||
|
if (newSheetName != ws.Name)
|
||||||
|
{
|
||||||
|
ws.Name = newSheetName;
|
||||||
|
changed = true;
|
||||||
|
|
||||||
|
Console.WriteLine($"Sheet重命名:{originalName}->{newSheetName}");
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 单元格内容
|
||||||
|
|
||||||
|
var usedCells = ws.CellsUsed();
|
||||||
|
|
||||||
|
foreach (var cell in usedCells)
|
||||||
|
{
|
||||||
|
if (cell.IsEmpty())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
string value = cell.GetString();
|
||||||
|
|
||||||
|
if (value.Contains("{{") || (value.Contains("}}")))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
string newValue = ReplaceText(value, replaceRules);
|
||||||
|
|
||||||
|
if (value != newValue)
|
||||||
|
{
|
||||||
|
cell.Value = newValue;
|
||||||
|
changed = true;
|
||||||
|
|
||||||
|
Console.WriteLine($"单元格内容替换:{value}->{newValue}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 公式(可选)
|
||||||
|
|
||||||
|
//foreach (var cell in ws.CellsUsed(c => c.HasFormula))
|
||||||
|
//{
|
||||||
|
// var formula = cell.FormulaA1;
|
||||||
|
|
||||||
|
// var newFormula = ReplaceText(formula, replaceRules);
|
||||||
|
|
||||||
|
// if (formula != newFormula)
|
||||||
|
// {
|
||||||
|
// cell.FormulaA1 = newFormula;
|
||||||
|
// changed = true;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changed)
|
||||||
|
{
|
||||||
|
workbook.Save();
|
||||||
|
|
||||||
|
Console.WriteLine($"已保存:{file}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 文件名替换
|
||||||
|
var fileName = Path.GetFileName(file);
|
||||||
|
var newFileName = ReplaceText(fileName, replaceRules);
|
||||||
|
|
||||||
|
if (fileName != newFileName)
|
||||||
|
{
|
||||||
|
var newPath = Path.Combine(
|
||||||
|
Path.GetDirectoryName(file)!,
|
||||||
|
newFileName);
|
||||||
|
|
||||||
|
File.Move(file, newPath, true);
|
||||||
|
|
||||||
|
Console.WriteLine($"文件重命名:{fileName} -> {newFileName}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return ResponseOutput.Ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public class ModelVerifyCommand
|
public class ModelVerifyCommand
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue