forked from ddrilling/AsbCloudServer
Фикс формирования DTO
This commit is contained in:
parent
b6cbc63267
commit
053b210401
@ -12,21 +12,6 @@ public class VersionDto
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int IdWell { get; set; }
|
public int IdWell { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// дата начала бурения (заполнения данных на панели)
|
|
||||||
/// </summary>
|
|
||||||
public DateTime DrillingStartDate { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// идентификатор временной зоны
|
|
||||||
/// </summary>
|
|
||||||
public string? TimeZoneId { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// смещение в часах относительно UTC
|
|
||||||
/// </summary>
|
|
||||||
public double TimeZoneOffsetTotalHours { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// название скважины
|
/// название скважины
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -66,9 +51,4 @@ public class VersionDto
|
|||||||
/// версия ПО ПЛК Памп мастер
|
/// версия ПО ПЛК Памп мастер
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string? PumpPlcVersion { get; set; }
|
public string? PumpPlcVersion { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// комментарий
|
|
||||||
/// </summary>
|
|
||||||
public string? Comment { get; set; }
|
|
||||||
}
|
}
|
@ -80,29 +80,43 @@ public class TelemetryService : ITelemetryService
|
|||||||
|
|
||||||
public async Task<IEnumerable<VersionDto>> GetVersionsAsync(VersionRequest request, CancellationToken token)
|
public async Task<IEnumerable<VersionDto>> GetVersionsAsync(VersionRequest request, CancellationToken token)
|
||||||
{
|
{
|
||||||
var wells = db.Set<Well>()
|
var query = db.Set<Well>()
|
||||||
.Include(x => x.RelationCompaniesWells)
|
.Include(x => x.RelationCompaniesWells)
|
||||||
|
.ThenInclude(x => x.Company)
|
||||||
|
.Include(x => x.Cluster)
|
||||||
|
.ThenInclude(c => c.Deposit)
|
||||||
.Where(x => x.RelationCompaniesWells.Any(y => y.IdCompany == request.IdCompany));
|
.Where(x => x.RelationCompaniesWells.Any(y => y.IdCompany == request.IdCompany));
|
||||||
|
|
||||||
if (request.IdWellState.HasValue)
|
if (request.IdWellState.HasValue)
|
||||||
wells = wells.Where(x => x.IdState == request.IdWellState);
|
query = query.Where(x => x.IdState == request.IdWellState);
|
||||||
|
|
||||||
if (request.IdsWell?.Any() == true)
|
if (request.IdsWell?.Any() == true)
|
||||||
wells = wells.Where(x => request.IdsWell.Contains(x.Id));
|
query = query.Where(x => request.IdsWell.Contains(x.Id));
|
||||||
|
|
||||||
var idTelemetries = await wells.Where(x => x.IdTelemetry.HasValue)
|
var wells = await query.Where(x => x.IdTelemetry.HasValue)
|
||||||
.Select(x => x.IdTelemetry!.Value)
|
.ToDictionaryAsync(x => x.Id, x => x, token);
|
||||||
.ToArrayAsync(token);
|
|
||||||
|
var idTelemetries = wells.Select(x => x.Value.IdTelemetry!.Value);
|
||||||
|
|
||||||
var telemetries = GetTelemetryCache()
|
var telemetries = GetTelemetryCache()
|
||||||
.Where(x => idTelemetries.Contains(x.Id))
|
.Where(x => idTelemetries.Contains(x.Id))
|
||||||
.OrderBy(x => x.Info.DrillingStartDate);
|
.OrderBy(x => x.Info.DrillingStartDate);
|
||||||
|
|
||||||
var dtos = telemetries.Select(x =>
|
var dtos = telemetries.Select(x =>
|
||||||
{
|
{
|
||||||
var dto = x.Info.Adapt<VersionDto>();
|
var well = wells[x.Well!.Id];
|
||||||
dto.IdWell = x.Well!.Id;
|
|
||||||
dto.DrillingStartDate = x.Info.DrillingStartDate.ToRemoteDateTime(dto.TimeZoneOffsetTotalHours);
|
var dto = new VersionDto
|
||||||
|
{
|
||||||
|
IdWell = well.Id,
|
||||||
|
Well = well.Caption,
|
||||||
|
Cluster = well.Cluster.Caption,
|
||||||
|
Deposit = well.Cluster.Deposit.Caption,
|
||||||
|
Customer = well.RelationCompaniesWells.Select(r => r.Company).FirstOrDefault(c => c.IdCompanyType == 1)?.Caption,
|
||||||
|
HmiVersion = x.Info.HmiVersion,
|
||||||
|
SaubPlcVersion = x.Info.SaubPlcVersion,
|
||||||
|
SpinPlcVersion = x.Info.SpinPlcVersion,
|
||||||
|
};
|
||||||
|
|
||||||
return dto;
|
return dto;
|
||||||
});
|
});
|
||||||
@ -110,6 +124,7 @@ public class TelemetryService : ITelemetryService
|
|||||||
return dtos;
|
return dtos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[Obsolete("This method will be private. Use TelemetryDto.TimeZone prop.")]
|
[Obsolete("This method will be private. Use TelemetryDto.TimeZone prop.")]
|
||||||
public SimpleTimezoneDto GetTimezone(int idTelemetry)
|
public SimpleTimezoneDto GetTimezone(int idTelemetry)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user