From baee2ae139823d6b0a15c38bf161183ebed8d9ca Mon Sep 17 00:00:00 2001 From: Olga Nemt Date: Wed, 22 Mar 2023 11:29:53 +0500 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=B4=D0=B0=D1=82=D1=8B=20=D0=B8=20=D0=BA?= =?UTF-8?q?=D0=BB=D1=8E=D1=87=D0=B0=20=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8F,=20=D0=B2=D0=BD=D0=B5?= =?UTF-8?q?=D1=81=D1=88=D0=B5=D0=B3=D0=BE=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B2=20=D0=B1=D0=BB=D0=BE=D0=BA?= =?UTF-8?q?=D0=B8=20=D1=81=D1=83=D1=82=D0=BE=D1=87=D0=BD=D0=BE=D0=B3=D0=BE?= =?UTF-8?q?=20=D1=80=D0=B0=D0=BF=D0=BE=D1=80=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Data/DailyReport/OperationStatDto.cs | 2 + .../DailyReportBlocks/TimeBalanceBlock.cs | 73 ++++++++----------- .../DailyReport/DailyReportService.cs | 52 ++++++++----- 3 files changed, 68 insertions(+), 59 deletions(-) diff --git a/AsbCloudApp/Data/DailyReport/OperationStatDto.cs b/AsbCloudApp/Data/DailyReport/OperationStatDto.cs index 03a84801..8d53db14 100644 --- a/AsbCloudApp/Data/DailyReport/OperationStatDto.cs +++ b/AsbCloudApp/Data/DailyReport/OperationStatDto.cs @@ -9,5 +9,7 @@ /// Глубина забоя /// public double Depth { get; set; } + + //TODO: Дописать } } diff --git a/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/TimeBalanceBlock.cs b/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/TimeBalanceBlock.cs index ed6eab74..f347ce69 100644 --- a/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/TimeBalanceBlock.cs +++ b/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/TimeBalanceBlock.cs @@ -6,8 +6,8 @@ namespace AsbCloudInfrastructure.Services.DailyReport.DailyReportBlocks class TimeBalanceBlock : BlockAbstract { private readonly TimeBalanceDto blockDto; - public CellAddress AddressTitle { get; } - public CellAddress AddressDrilling { get; set; } + public CellAddress AddressTitle { get; } + public CellAddress AddressDrilling { get; set; } public CellAddress AddressFlushing { get; set; } public CellAddress AddressBuilding { get; set; } public CellAddress AddressElaboration { get; set; } @@ -31,7 +31,7 @@ namespace AsbCloudInfrastructure.Services.DailyReport.DailyReportBlocks public CellAddress AddressPvoValue { get; set; } public CellAddress AddressPgrValue { get; set; } public CellAddress AddressGisValue { get; set; } - public CellAddress AddressOzc { get; set; } + public CellAddress AddressOzc { get; set; } public CellAddress AddressEngineeringWorks { get; set; } public CellAddress AddressTakingMeasure { get; set; } public CellAddress AddressCementing { get; set; } @@ -93,9 +93,9 @@ namespace AsbCloudInfrastructure.Services.DailyReport.DailyReportBlocks public override void Draw(IXLWorksheet sheet) { - sheet.Range(AddressTitle.RowNumber, AddressTitle.ColumnNumber, AddressTitle.RowNumber, AddressTitle.ColumnNumber + 1) - .Merge() - .SetValue("БАЛАНС ВРЕМЕНИ"); + sheet.Range(AddressTitle.RowNumber, AddressTitle.ColumnNumber, AddressTitle.RowNumber, AddressTitle.ColumnNumber + 1) + .Merge() + .SetValue("БАЛАНС ВРЕМЕНИ"); sheet.Cell(AddressDrilling) ._SetValue("Бурение", true); sheet.Cell(AddressFlushing) @@ -108,18 +108,7 @@ namespace AsbCloudInfrastructure.Services.DailyReport.DailyReportBlocks ._SetValue("Расширка", true); sheet.Cell(AddressRepair) ._SetValue("Ремонт", true); - sheet.Cell(AddressDrillingValue) - ._SetValue($"{blockDto.Drilling}"); - sheet.Cell(AddressFlushingValue) - ._SetValue($"{blockDto.Flushing}"); - sheet.Cell(AddressBuildingValue) - ._SetValue($"{blockDto.Building}"); - sheet.Cell(AddressElaborationValue) - ._SetValue($"{blockDto.Elaboration}"); - sheet.Cell(AddressExtensionValue) - ._SetValue($"{blockDto.Extension}"); - sheet.Cell(AddressRepairValue) - ._SetValue($"{blockDto.Repair}"); + //TODO: дописать timebalance sheet.Cell(AddressKnbk) ._SetValue("КНБК"); sheet.Cell(AddressSpo) @@ -132,18 +121,18 @@ namespace AsbCloudInfrastructure.Services.DailyReport.DailyReportBlocks ._SetValue("ПГР"); sheet.Cell(AddressGis) ._SetValue("ГИС"); - sheet.Cell(AddressKnbkValue) - ._SetValue($"{blockDto.Knbk}"); - sheet.Cell(AddressSpoValue) - ._SetValue($"{blockDto.Spo}"); - sheet.Cell(AddressPzrValue) - ._SetValue($"{blockDto.Pzr}"); - sheet.Cell(AddressPvoValue) - ._SetValue($"{blockDto.Pvo}"); - sheet.Cell(AddressPgrValue) - ._SetValue($"{blockDto.Pgr}"); - sheet.Cell(AddressGisValue) - ._SetValue($"{blockDto.Gis}"); + //sheet.Cell(AddressKnbkValue) + // ._SetValue($"{blockDto.Knbk}"); + //sheet.Cell(AddressSpoValue) + // ._SetValue($"{blockDto.Spo}"); + //sheet.Cell(AddressPzrValue) + // ._SetValue($"{blockDto.Pzr}"); + //sheet.Cell(AddressPvoValue) + // ._SetValue($"{blockDto.Pvo}"); + //sheet.Cell(AddressPgrValue) + // ._SetValue($"{blockDto.Pgr}"); + //sheet.Cell(AddressGisValue) + // ._SetValue($"{blockDto.Gis}"); sheet.Cell(AddressOzc) ._SetValue("ОЗЦ"); sheet.Cell(AddressEngineeringWorks) @@ -156,18 +145,18 @@ namespace AsbCloudInfrastructure.Services.DailyReport.DailyReportBlocks ._SetValue("Простой"); sheet.Cell(AddressNpv) ._SetValue("НПВ"); - sheet.Cell(AddressOzcValue) - ._SetValue($"{blockDto.Ozc}"); - sheet.Cell(AddressEngineeringWorksValue) - ._SetValue($"{blockDto.EngineeringWorks}"); - sheet.Cell(AddressTakingMeasureValue) - ._SetValue($"{blockDto.TakingMeasure}"); - sheet.Cell(AddressCementingValue) - ._SetValue($"{blockDto.Cementing}"); - sheet.Cell(AddressSimpleValue) - ._SetValue($"{blockDto.Simple}"); - sheet.Cell(AddressNpvValue) - ._SetValue($"{blockDto.Npv}"); + //sheet.Cell(AddressOzcValue) + // ._SetValue($"{blockDto.Ozc}"); + //sheet.Cell(AddressEngineeringWorksValue) + // ._SetValue($"{blockDto.EngineeringWorks}"); + //sheet.Cell(AddressTakingMeasureValue) + // ._SetValue($"{blockDto.TakingMeasure}"); + //sheet.Cell(AddressCementingValue) + // ._SetValue($"{blockDto.Cementing}"); + //sheet.Cell(AddressSimpleValue) + // ._SetValue($"{blockDto.Simple}"); + //sheet.Cell(AddressNpvValue) + // ._SetValue($"{blockDto.Npv}"); } } diff --git a/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs b/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs index fa012334..1cc5f2b7 100644 --- a/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs +++ b/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs @@ -68,6 +68,32 @@ namespace AsbCloudInfrastructure.Services.DailyReport var entities = await query.OrderByDescending(e => e.StartDate).ToListAsync(token); + var dtos = entities.Select(Convert).ToList(); + + var factOperationsForDtos = await getFactOperationsForDailyReportAsync(idWell, token); + + foreach (var dto in dtos) + { + dto.TimeBalance.OperationsStat = (factOperationsForDtos + .Where(o => DateOnly.FromDateTime(o.DateStart) == dto.StartDate) + .GroupBy(o => o.IdCategory) + .Select(g => new OperationStatDto() { Depth = g.Sum(o => o.DepthEnd - o.DepthStart) })); + + await SetUserNamesToDailyReportDtoAsync(dto, token); + } + + + return dtos; + } + + /// + /// получение фактических операций для суточного рапорта + /// + /// + /// + /// + private async Task> getFactOperationsForDailyReportAsync(int idWell, CancellationToken token) + { var request = new WellOperationRequest() { IdWell = idWell, @@ -75,45 +101,37 @@ namespace AsbCloudInfrastructure.Services.DailyReport }; var factOperations = await wellOperationRepository.GetAsync(request, token); - - var dtos = entities.Select(Convert); - var result = await Task.WhenAll(dtos.Select(i => BindDataToDtoAsync(i, factOperations, token))); - return result; + return factOperations; } /// - /// Заполнение DTO-модели необходимыми данными + /// Заполнение DTO-модели данными о пользователях /// /// - /// /// /// - private async Task BindDataToDtoAsync(DailyReportDto dto, IEnumerable factOperations, CancellationToken token) + private async Task SetUserNamesToDailyReportDtoAsync(DailyReportDto dto, CancellationToken token) { var blocks = new ItemInfoDto[] { dto.Head, dto.Bha, dto.NoDrilling, + dto.TimeBalance, dto.Saub, - dto.Sign, - dto.TimeBalance + dto.Sign }; foreach (var block in blocks) { if (block.IdUser is not null) { - var userDto = await userRepository.GetOrDefaultAsync(block.IdUser.Value, token); - if (userDto is not null) - block.UserName = string.Format("{0} {1} {2}", userDto.Surname, userDto.Name, userDto.Patronymic); + var user = await userRepository.GetOrDefaultAsync(block.IdUser.Value, token); + block.UserName = user is not null + ? string.Format("{0} {1} {2}", user.Surname, user.Name, user.Patronymic) + : String.Empty; } } - dto.TimeBalance.OperationsStat = (factOperations - .Where(o => DateOnly.FromDateTime(o.DateStart) == dto.StartDate) - .GroupBy(o => o.IdCategory) - .Select(g => new OperationStatDto() { Depth = g.Sum(o => o.DepthEnd - o.DepthStart) })); - return dto; }