Merge branch 'feature/MakeDailyReport' into dev

This commit is contained in:
ngfrolov 2022-08-10 15:52:07 +05:00
commit 8bf7a03821
3 changed files with 80 additions and 4 deletions

View File

@ -94,6 +94,26 @@
/// НПВ /// НПВ
/// </summary> /// </summary>
public string Npv { get; set; } public string Npv { get; set; }
/// <summary>
/// Проработка перед наращиванием
/// </summary>
public string ElaborationBeforeBuilding { get; set; }
/// <summary>
/// Шаблонировка перед наращиванием
/// </summary>
public string TemplatingBeforeBuilding { get; set; }
/// <summary>
/// Промывка перед наращиванием
/// </summary>
public string FlushingBeforeBuilding { get; set; }
/// <summary>
/// Статический замер телесистемы
/// </summary>
public string StaticSurveying { get; set; }
} }
} }

View File

@ -9,6 +9,9 @@ using AsbCloudApp.Services;
using AsbCloudDb.Model; using AsbCloudDb.Model;
using System.Collections.Generic; using System.Collections.Generic;
using AsbCloudApp.Data.DailyReport; using AsbCloudApp.Data.DailyReport;
using AsbCloudApp.Requests;
using AsbCloudInfrastructure.Services.DetectOperations;
using AsbCloudApp.Data.DetectedOperation;
namespace AsbCloudInfrastructure.Services.DailyReport namespace AsbCloudInfrastructure.Services.DailyReport
{ {
@ -17,12 +20,14 @@ namespace AsbCloudInfrastructure.Services.DailyReport
{ {
private readonly IAsbCloudDbContext db; private readonly IAsbCloudDbContext db;
private readonly IWellService wellService; private readonly IWellService wellService;
private readonly IDetectedOperationService detectedOperationService;
private readonly DailyReportMakerExcel dailyReportMaker = new DailyReportMakerExcel(); private readonly DailyReportMakerExcel dailyReportMaker = new DailyReportMakerExcel();
public DailyReportService(IAsbCloudDbContext db, IWellService wellService) public DailyReportService(IAsbCloudDbContext db, IWellService wellService, IDetectedOperationService detectedOperationService)
{ {
this.db = db; this.db = db;
this.wellService = wellService; this.wellService = wellService;
this.detectedOperationService = detectedOperationService;
} }
public async Task<IEnumerable<DailyReportDto>> GetListAsync(int idWell, DateTime? begin, DateTime? end, CancellationToken token) public async Task<IEnumerable<DailyReportDto>> GetListAsync(int idWell, DateTime? begin, DateTime? end, CancellationToken token)
@ -109,19 +114,57 @@ namespace AsbCloudInfrastructure.Services.DailyReport
private async Task<DailyReportDto> MakeDefaultDailyReportAsync(int idWell, DateTime date, CancellationToken token) private async Task<DailyReportDto> MakeDefaultDailyReportAsync(int idWell, DateTime date, CancellationToken token)
{ {
var well = await wellService.GetOrDefaultAsync(idWell, token); var well = await wellService.GetOrDefaultAsync(idWell, token);
var dto = new DailyReportDto() var dto = new DailyReportDto()
{ {
Head = new HeadDto() Head = new HeadDto()
{ {
ReportDate = date.Date, ReportDate = date.Date,
WellName = well?.Caption ?? "", WellName = well?.Caption ?? "",
ClusterName = well?.Cluster ?? "" ClusterName = well?.Cluster ?? "",
} },
TimeBalance = await MakeTimeBalanceAsync(idWell, date, token),
}; };
return dto; return dto;
} }
private async Task<TimeBalanceDto> MakeTimeBalanceAsync(int idWell, DateTime date, CancellationToken token)
{
var stat = await detectedOperationService.GetOperationsStatAsync(new DetectedOperationRequest
{
IdWell = idWell,
GtDate = date.Date,
LtDate = date.Date.AddDays(1)
}, token);
if (stat is null)
return new TimeBalanceDto();
var dto = new TimeBalanceDto()
{
Drilling = $"{GetHoursFromStat(stat, DetectedOperationService.IdOperationRotor, DetectedOperationService.IdOperationSlide):#0.00}",
Flushing = $"{GetHoursFromStat(stat, DetectedOperationService.idOperationFlushing):#0.00}",
Building = $"{GetHoursFromStat(stat, DetectedOperationService.IdOperationSlipsTime):#0.00}",
Elaboration = $"{GetHoursFromStat(stat, DetectedOperationService.IdOperationElaboration):#0.00}",
ElaborationBeforeBuilding = $"{GetHoursFromStat(stat, DetectedOperationService.IdOperationElaborationBeforeBuilding):#0.00}",
TemplatingBeforeBuilding = $"{GetHoursFromStat(stat, DetectedOperationService.IdOperationTemplatingBeforeBuilding):#0.00}",
FlushingBeforeBuilding = $"{GetHoursFromStat(stat, DetectedOperationService.IdOperationFlushingBeforeBuilding):#0.00}",
StaticSurveying = $"{GetHoursFromStat(stat, DetectedOperationService.IdOperationStaticSurveying):#0.00}",
Gis = $"{GetHoursFromStat(stat, DetectedOperationService.IdOperationGis):#0.00}",
Ozc = $"{GetHoursFromStat(stat, DetectedOperationService.IdOperationOzc):#0.00}",
Cementing = $"{GetHoursFromStat(stat, DetectedOperationService.IdOperationCementing):#0.00}",
Npv = $"{GetHoursFromStat(stat, DetectedOperationService.IdOperationNpv):#0.00}",
};
return dto;
}
private static double GetHoursFromStat(IEnumerable<DetectedOperationStatDto> stat, params int[] idCategories)
{
var valueMinutes = stat.Where(o => idCategories.Contains(o.IdCategory))
.Sum(o => o.MinutesTotal);
return valueMinutes / 60d;
}
private static DailyReportDto Convert(AsbCloudDb.Model.DailyReport.DailyReport entity) private static DailyReportDto Convert(AsbCloudDb.Model.DailyReport.DailyReport entity)
{ {
var dto = entity.Info.Adapt<DailyReportDto>(); var dto = entity.Info.Adapt<DailyReportDto>();

View File

@ -21,6 +21,19 @@ namespace AsbCloudInfrastructure.Services.DetectOperations
public const int IdOperationRotor = 1; public const int IdOperationRotor = 1;
public const int IdOperationSlide = 3; public const int IdOperationSlide = 3;
public const int IdOperationSlipsTime = 14; public const int IdOperationSlipsTime = 14;
public const int idOperationFlushing = 22;
public const int IdOperationElaboration = 1022;
public const int idOperationRepair = 1031;
public const int IdOperationGis = 1001;
public const int IdOperationOzc = 1008;
public const int IdOperationCementing = 1040;
public const int IdOperationNpv = 1043;
public const int IdOperationElaborationBeforeBuilding = 18;
public const int IdOperationTemplatingBeforeBuilding = 19;
public const int IdOperationFlushingBeforeBuilding = 20;
public const int IdOperationStaticSurveying = 21;
private readonly IAsbCloudDbContext db; private readonly IAsbCloudDbContext db;
private readonly IWellService wellService; private readonly IWellService wellService;