forked from ddrilling/AsbCloudServer
Добавление даты и ключа пользователя, внесшего изменения в блоки суточного рапорта
This commit is contained in:
parent
8a9a565365
commit
baee2ae139
@ -9,5 +9,7 @@
|
||||
/// Глубина забоя
|
||||
/// </summary>
|
||||
public double Depth { get; set; }
|
||||
|
||||
//TODO: Дописать
|
||||
}
|
||||
}
|
||||
|
@ -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}");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// получение фактических операций для суточного рапорта
|
||||
/// </summary>
|
||||
/// <param name="idWell"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<IEnumerable<WellOperationDto>> 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Заполнение DTO-модели необходимыми данными
|
||||
/// Заполнение DTO-модели данными о пользователях
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="factOperations"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<DailyReportDto> BindDataToDtoAsync(DailyReportDto dto, IEnumerable<WellOperationDto> factOperations, CancellationToken token)
|
||||
private async Task<DailyReportDto> 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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user