Merge branch 'Test_IRC_Net8' of https://gitea.frp.extimaging.com/XCKJ/irc-netcore-api into Test_IRC_Net8
continuous-integration/drone/push Build is passing Details

IRC_NewDev
he 2024-09-24 13:08:16 +08:00
commit 9a71e1fa0f
12 changed files with 146 additions and 22 deletions

View File

@ -1,4 +1,5 @@
using IRaCIS.Core.Domain.Share;
using IRaCIS.Core.Infrastructure.Encryption;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Options;
using Newtonsoft.Json.Linq;

View File

@ -47,7 +47,6 @@
<PackageReference Include="AWSSDK.SecurityToken" Version="3.7.400.16" />
<PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.14.1" />
<PackageReference Include="AWSSDK.S3" Version="3.7.402.7" />
<PackageReference Include="BouncyCastle.Cryptography" Version="2.4.0" />
<PackageReference Include="DocX" Version="3.0.1" />
<PackageReference Include="FreeSpire.Doc" Version="12.2.0" />
<PackageReference Include="Hangfire.Core" Version="1.8.14" />

View File

@ -11317,7 +11317,7 @@
<param name="inDto"></param>
<returns></returns>
</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.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.TrialDocument},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.User},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.ReadingSystemCriterionDictionary},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingTrialCriterionDictionary},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.TumorAssessment_RECIST1Point1},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.ReadingQuestionCriterionSystem},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.Application.Interfaces.ITrialEmailNoticeConfigService)">
<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.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.TrialDocument},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.User},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.ReadingSystemCriterionDictionary},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingTrialCriterionDictionary},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.TumorAssessment_RECIST1Point1},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.ReadingQuestionCriterionSystem},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.Interfaces.ITrialEmailNoticeConfigService)">
<summary>
IR影像阅片
</summary>
@ -12437,20 +12437,6 @@
测试加密API 返回的结果
</summary>
</member>
<member name="T:IRaCIS.Core.Application.BusinessFilter.RSAEncryption">
<summary>
https://www.cnblogs.com/NBDWDYS2214143926/p/13329231.html
</summary>
</member>
<member name="M:IRaCIS.Core.Application.BusinessFilter.RSAEncryption.Decrypt(System.String,System.String)">
<summary>
RSA解密
</summary>
<param name="privateKey">私钥</param>
<param name="decryptstring">待解密的字符串(Base64)</param>
<returns>解密后的字符串</returns>
</member>
<!-- Badly formed XML comment ignored for member "M:IRaCIS.Core.Application.BusinessFilter.RSAEncryption.Encrypt(System.String,System.String)" -->
<member name="T:IRaCIS.Core.Application.BusinessFilter.GlobalExceptionHandler">
<summary>
不生效,不知道为啥

View File

@ -415,6 +415,8 @@ namespace IRaCIS.Core.Application.Contracts
[NotDefault]
public string SubjectCode { get; set; }
public Guid? VisitTaskId { get; set; }
}
public class IRTaskUploadedDicomStudyQuery

View File

@ -112,8 +112,14 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
{
await SubejctRandomReadingTaskNameDeal(inQuery.SubjectId, inQuery.TrialReadingCriterionId);
//要根据标准阅片顺序,确定是否查询单个任务的,还是查询所有的
var criterionInfo = await _readingQuestionCriterionTrialRepository.Where(t => t.Id == inQuery.TrialReadingCriterionId)
.Select(t => new { t.IsReadingTaskViewInOrder }).FirstNotNullAsync();
var query = _visitTaskRepository.Where(t => t.SubjectId == inQuery.SubjectId && t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId && t.SourceSubjectVisitId != null
&& t.DoctorUserId == _userInfo.Id && t.TaskState == TaskState.Effect)
//满足 有序或者随机只看到当前任务的dicom 非dicom检查
.WhereIf(criterionInfo.IsReadingTaskViewInOrder != ReadingOrder.SubjectRandom && inQuery.VisitTaskId != null, t => t.Id == inQuery.VisitTaskId)
.Select(u => new SubjectImageUploadDTO()
{
VisitTaskId = u.Id,
@ -587,10 +593,12 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
public async Task<List<TaskNoneDicomStudyDTO>> GetIRUploadTaskNoneDicomStudyList(IRUploadStudyQuery inQuery)
{
var info = await _readingQuestionCriterionTrialRepository.Where(t => t.Id == inQuery.TrialReadingCriterionId)
.Select(t => new { t.IsImageFilter, t.CriterionModalitys }).FirstNotNullAsync();
.Select(t => new { t.IsImageFilter, t.CriterionModalitys,t.IsReadingTaskViewInOrder }).FirstNotNullAsync();
var query = from u in _visitTaskRepository.Where(t => t.SubjectId == inQuery.SubjectId && t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId
&& t.SourceSubjectVisitId != null && t.DoctorUserId == _userInfo.Id && t.TaskState == TaskState.Effect)
//满足 有序或者随机只看到当前任务的dicom 非dicom检查
.WhereIf(info.IsReadingTaskViewInOrder != ReadingOrder.SubjectRandom && inQuery.VisitTaskId != null, t => t.Id == inQuery.VisitTaskId)
join ns in _noneDicomStudyReposiotry.Where(t => t.SubjectId == inQuery.SubjectId).WhereIf(info.IsImageFilter, t => ("|" + info.CriterionModalitys + "|").Contains("|" + t.Modality + "|"))
on u.SourceSubjectVisitId equals ns.SubjectVisitId
@ -745,7 +753,6 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
public async Task<List<SubjectCRCImageUploadedStudyDto>> GetSubjectImageDownloadSelectList(IRReadingDownloadQuery inQuery)
{
//要根据标准阅片顺序,确定是否查询单个任务的,还是查询所有的
var criterionInfo = await _readingQuestionCriterionTrialRepository.Where(t => t.Id == inQuery.TrialReadingCriterionId)
.Select(t => new { t.IsReadingTaskViewInOrder }).FirstNotNullAsync();

View File

@ -13,6 +13,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NPOI.SS.Formula.Functions;
using Panda.DynamicWebApi.Attributes;
using ZiggyCreatures.Caching.Fusion;
@ -60,6 +61,7 @@ namespace IRaCIS.Core.Application.Service
IRepository<NoneDicomStudyFile> _noneDicomStudyFileSystem,
IGeneralCalculateService _generalCalculateService,
IRepository<ReadingQuestionTrial> _readingQuestionTrialRepository,
IRepository<TaskStudy> _taskStudyRepository,
ITrialEmailNoticeConfigService _trialEmailNoticeConfigService) : BaseService, IReadingImageTaskService
{
@ -2603,6 +2605,14 @@ namespace IRaCIS.Core.Application.Service
[HttpPost]
public async Task<IResponseOutput> VerifyVisitTaskQuestions(VerifyVisitTaskQuestionsInDto inDto)
{
//验证后处理影像必须传
if (_visitTaskRepository.Any(t => t.Id==inDto.VisitTaskId && t.TrialReadingCriterion.ImageUploadEnum != ReadingImageUpload.None))
{
if (!_taskStudyRepository.Any(t => t.VisitTaskId == inDto.VisitTaskId))
{
return ResponseOutput.NotOk("ReadingImage_BackImageNotExist");
}
}
await VerifyTaskIsSign(inDto.VisitTaskId);
await VerifyDefaultQuestionBeAnswer(inDto);

View File

@ -6,6 +6,7 @@ using IRaCIS.Core.Application.Helper;
using IRaCIS.Core.Application.ViewModel;
using IRaCIS.Core.Domain.Share;
using IRaCIS.Core.Infrastructure;
using IRaCIS.Core.Infrastructure.Encryption;
using IRaCIS.Core.Infrastructure.NewtonsoftJson;
using MassTransit;
using Medallion.Threading;
@ -104,6 +105,19 @@ namespace IRaCIS.Core.Application.Service
public string TestName { get; set; }
}
public async Task<IResponseOutput> TestAutoEncretpt([FromServices] IRepository<TestLength> _testLengthRepository)
{
await _testLengthRepository.AddAsync(new TestLength() { Name = "zhouhang1" });
await _testLengthRepository.AddAsync(new TestLength() { Name = "hewentao" });
await _testLengthRepository.SaveChangesAsync();
var list = _testLengthRepository.Where().ToList();
var exist = await _testLengthRepository.AnyAsync(t => t.Name == "zhouhang1");
return ResponseOutput.Ok(list, exist);
}
public async Task<IResponseOutput> TestJson()
{
@ -280,7 +294,7 @@ namespace IRaCIS.Core.Application.Service
var encreptMd5 = AesEncryption.Encrypt(MD5Helper.Md5("123456"), key);
Console.WriteLine(encreptMd5);
var decrept= AesEncryption.Decrypt(encreptMd5, key);
var decrept = AesEncryption.Decrypt(encreptMd5, key);
Console.WriteLine();

View File

@ -0,0 +1,21 @@
using IRaCIS.Core.Infrastructure.Encryption;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Microsoft.EntityFrameworkCore.ValueGeneration;
namespace IRaCIS.Core.Infra.EFCore;
/// <summary>
/// 某列保留前面几位,后续加密
/// </summary>
public class PartialEncryptionConverter : ValueConverter<string, string>
{
private readonly int _unencryptedPrefixLength;
public PartialEncryptionConverter(int unencryptedPrefixLength)
: base(
plainText => AesEncryption.EncryptPartial(plainText, unencryptedPrefixLength),
encryptedText => AesEncryption.DecryptPartial(encryptedText, unencryptedPrefixLength))
{
_unencryptedPrefixLength = unencryptedPrefixLength;
}
}

View File

@ -1,8 +1,12 @@
using IRaCIS.Core.Domain.Models;
using IRaCIS.Core.Infra.EFCore.Common;
using IRaCIS.Core.Infrastructure.Encryption;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using System.ComponentModel;
using System.Data;
using System.Reflection;
using System.Security.Cryptography;
using System.Text;
using UserTypeGroup = IRaCIS.Core.Domain.Models.UserTypeGroup;
namespace IRaCIS.Core.Infra.EFCore;
@ -54,6 +58,13 @@ public class IRaCISDBContext : DbContext
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<TestLength>(entity =>
{
// 使用部分加密值转换器,前 2 个字符不加密,方便模糊搜索
entity.Property(e => e.Name)
.HasConversion(new PartialEncryptionConverter(2));
});
#region pgsql codefirst 配置 暂时屏蔽
//if (base.Database.IsNpgsql())
//{
@ -544,6 +555,18 @@ public class IRaCISDBContext : DbContext
public virtual DbSet<TrialImageDownload> TrialImageDownload { get; set; }
public virtual DbSet<TestLength> TestLength { get; set; }
}
public class TestLength : Entity
{
public string Name { get; set; }
}
}

View File

@ -18,6 +18,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.8" />
<PackageReference Include="SharpCompress" Version="0.38.0" />
<PackageReference Include="SharpZipLib" Version="1.4.2" />
<PackageReference Include="BouncyCastle.Cryptography" Version="2.4.0" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.4.5" />
</ItemGroup>

View File

@ -3,9 +3,11 @@ using Org.BouncyCastle.Crypto.Engines;
using Org.BouncyCastle.Crypto.Modes;
using Org.BouncyCastle.Crypto.Paddings;
using Org.BouncyCastle.Crypto.Parameters;
using System;
using System.Security.Cryptography;
using System.Text;
namespace IRaCIS.Core.Application.BusinessFilter;
namespace IRaCIS.Core.Infrastructure.Encryption;
public class AesEncryption
{
@ -84,4 +86,60 @@ public class AesEncryption
Array.Resize(ref output, length); // 调整输出数组大小以适应实际数据长度
return output;
}
public static string DefaultKey = "12345678901234567890123456789012";
public static string EncryptPartial(string plainText, int unencryptedPrefixLength)
{
if (plainText.Length <= unencryptedPrefixLength)
{
return Encrypt(plainText, DefaultKey); // 如果文本太短,直接加密
}
var prefix = plainText.Substring(0, unencryptedPrefixLength);
var suffix = plainText.Substring(unencryptedPrefixLength);
return prefix + Encrypt(suffix, DefaultKey); // 前缀保留,后缀加密
}
public static string DecryptPartial(string encryptedText, int unencryptedPrefixLength)
{
if (encryptedText.Length <= unencryptedPrefixLength)
{
return Decrypt(encryptedText, DefaultKey); // 如果文本太短,直接解密
}
var prefix = encryptedText.Substring(0, unencryptedPrefixLength);
var suffix = encryptedText.Substring(unencryptedPrefixLength);
return prefix + Decrypt(suffix, DefaultKey); // 前缀保留,后缀解密
}
//public static string Encrypt(string plainText)
//{
// using var aes = Aes.Create();
// aes.Key = Encoding.UTF8.GetBytes(EncryptionKey);
// aes.Mode = CipherMode.ECB; // 根据需要选择加密模式,这里使用 ECB 模式
// aes.Padding = PaddingMode.PKCS7;
// var encryptor = aes.CreateEncryptor();
// var plainBytes = Encoding.UTF8.GetBytes(plainText);
// var encryptedBytes = encryptor.TransformFinalBlock(plainBytes, 0, plainBytes.Length);
// return Convert.ToBase64String(encryptedBytes);
//}
//public static string Decrypt(string encryptedText)
//{
// using var aes = Aes.Create();
// aes.Key = Encoding.UTF8.GetBytes(EncryptionKey);
// aes.Mode = CipherMode.ECB;
// aes.Padding = PaddingMode.PKCS7;
// var decryptor = aes.CreateDecryptor();
// var encryptedBytes = Convert.FromBase64String(encryptedText);
// var decryptedBytes = decryptor.TransformFinalBlock(encryptedBytes, 0, encryptedBytes.Length);
// return Encoding.UTF8.GetString(decryptedBytes);
//}
}

View File

@ -4,9 +4,11 @@ using Org.BouncyCastle.Crypto.Engines;
using Org.BouncyCastle.Crypto.Generators;
using Org.BouncyCastle.OpenSsl;
using Org.BouncyCastle.Security;
using System;
using System.IO;
using System.Text;
namespace IRaCIS.Core.Application.BusinessFilter;
namespace IRaCIS.Core.Infrastructure.Encryption;
/// <summary>
/// https://www.cnblogs.com/NBDWDYS2214143926/p/13329231.html