修改
continuous-integration/drone/push Build is passing

This commit is contained in:
he
2024-09-27 13:06:16 +08:00
parent ccf154e5e5
commit 55f261b080
4 changed files with 51 additions and 45 deletions
@@ -1,4 +1,6 @@
using IRaCIS.Core.Application.Service.Reading.Dto;
using IRaCIS.Core.Application.Helper;
using IRaCIS.Core.Application.Service.Reading.Dto;
using IRaCIS.Core.Domain.Models;
using IRaCIS.Core.Domain.Share;
using IRaCIS.Core.Infra.EFCore.Common;
using MassTransit;
@@ -6,56 +8,38 @@ using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using MiniExcelLibs;
using System.Data;
using System.IO;
using System.Text;
namespace IRaCIS.Core.Application.Service.ReadingCalculate
{
public class GeneralCalculateService : BaseService, IGeneralCalculateService
public class GeneralCalculateService(IRepository<ReadingTableQuestionAnswer> _readingTableQuestionAnswerRepository,
IRepository<VisitTask> _visitTaskRepository,
IRepository<ReadingQuestionCriterionTrial> _readingQuestionCriterionTrialRepository,
ILogger<GeneralCalculateService> _logger,
IRepository<ReadingTableQuestionTrial> _readingTableQuestionTrialRepository,
IRepository<ReadingTableAnswerRowInfo> _readingTableAnswerRowInfoRepository,
IRepository<ReadingQuestionTrial> _readingQuestionTrialRepository,
IRepository<SubjectVisit> _subjectVisitRepository,
IRepository<TumorAssessment_RECIST1Point1> _tumorAssessmentRepository,
IRepository<ReadingTaskQuestionAnswer> _readingTaskQuestionAnswerRepository,
IRepository<InspectionFile> _inspectionFileRepository,
IOSSService oSSService
) : BaseService, IGeneralCalculateService
{
private readonly IRepository<ReadingTableQuestionAnswer> _readingTableQuestionAnswerRepository;
private readonly IRepository<VisitTask> _visitTaskRepository;
private readonly IRepository<ReadingQuestionCriterionTrial> _readingQuestionCriterionTrialRepository;
private readonly ILogger<GeneralCalculateService> _logger;
private readonly IRepository<ReadingTableQuestionTrial> _readingTableQuestionTrialRepository;
private readonly IRepository<ReadingTableAnswerRowInfo> _readingTableAnswerRowInfoRepository;
private readonly IRepository<ReadingQuestionTrial> _readingQuestionTrialRepository;
private readonly IRepository<SubjectVisit> _subjectVisitRepository;
private readonly IRepository<TumorAssessment_RECIST1Point1> _tumorAssessmentRepository;
private readonly IRepository<ReadingTaskQuestionAnswer> _readingTaskQuestionAnswerRepository;
public GeneralCalculateService(
IRepository<ReadingTableQuestionAnswer> readingTableQuestionAnswerRepository,
IRepository<VisitTask> visitTaskRepository,
IRepository<ReadingQuestionCriterionTrial> readingQuestionCriterionTrialRepository,
ILogger<GeneralCalculateService> logger,
IRepository<ReadingTableQuestionTrial> readingTableQuestionTrialRepository,
IRepository<ReadingTableAnswerRowInfo> readingTableAnswerRowInfoRepository,
IRepository<ReadingQuestionTrial> readingQuestionTrialRepository,
IRepository<SubjectVisit> subjectVisitRepository,
IRepository<TumorAssessment_RECIST1Point1> tumorAssessmentRepository,
IRepository<ReadingTaskQuestionAnswer> readingTaskQuestionAnswerRepository
)
{
this._readingTableQuestionAnswerRepository = readingTableQuestionAnswerRepository;
this._visitTaskRepository = visitTaskRepository;
this._readingQuestionCriterionTrialRepository = readingQuestionCriterionTrialRepository;
this._logger = logger;
this._readingTableQuestionTrialRepository = readingTableQuestionTrialRepository;
this._readingTableAnswerRowInfoRepository = readingTableAnswerRowInfoRepository;
this._readingQuestionTrialRepository = readingQuestionTrialRepository;
this._subjectVisitRepository = subjectVisitRepository;
this._tumorAssessmentRepository = tumorAssessmentRepository;
this._readingTaskQuestionAnswerRepository = readingTaskQuestionAnswerRepository;
}
/// <summary>
/// 从上传文件中获取Datatable
/// </summary>
/// <returns></returns>
public async Task<DataTable> GetDataTableFromUpload(IFormFile file)
public async Task<DataTable> GetDataTableFromUpload(IFormFile file,string pathCode,Guid trialId)
{
DataTable result = new DataTable();
var fileFolder = "Upload\\";
if (!Directory.Exists(fileFolder))
@@ -66,11 +50,15 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
var fileName = DateTime.Now.ToString("yyyyMMddHHmmss") +
Path.GetExtension(file.FileName);
var filePath = Path.Combine(fileFolder, fileName);
var fileStream = new MemoryStream();
try
{
using (var stream = new FileStream(filePath, FileMode.Create))
{
file.CopyTo(stream);
await stream.CopyToAsync(fileStream);
stream.Position = 0;
result = stream.QueryAsDataTable(useHeaderRow: false);
}
@@ -80,6 +68,21 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
File.Delete(filePath);
}
try
{
var ossRelativePath = await oSSService.UploadToOSSAsync(fileStream, pathCode, file.FileName);
await _inspectionFileRepository.AddAsync(new InspectionFile() { FileName = file.FileName, RelativePath = ossRelativePath, TrialId = trialId });
}
catch (Exception)
{
}
File.Delete(filePath);
// 创建一个要删除的行集合