forked from ddrilling/AsbCloudServer
Переписан метод GetTimezone (метод больше не маппит в dto)
This commit is contained in:
parent
e2cd8cbfd2
commit
626c3cb238
@ -270,10 +270,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
{
|
{
|
||||||
var dto = base.Convert(entity);
|
var dto = base.Convert(entity);
|
||||||
|
|
||||||
if (entity.Timezone is null)
|
dto.StartDate = wellOperationRepository.FirstOperationDate(entity.Id);
|
||||||
dto.Timezone = GetTimezone(entity.Id);
|
|
||||||
|
|
||||||
dto.StartDate = wellOperationRepository.FirstOperationDate(entity.Id)?.ToOffset(TimeSpan.FromHours(dto.Timezone.Hours));
|
|
||||||
dto.WellType = entity.WellType.Caption;
|
dto.WellType = entity.WellType.Caption;
|
||||||
dto.Cluster = entity.Cluster.Caption;
|
dto.Cluster = entity.Cluster.Caption;
|
||||||
dto.Deposit = entity.Cluster.Deposit.Caption;
|
dto.Deposit = entity.Cluster.Deposit.Caption;
|
||||||
@ -296,47 +293,10 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
|
|
||||||
public SimpleTimezoneDto GetTimezone(int idWell)
|
public SimpleTimezoneDto GetTimezone(int idWell)
|
||||||
{
|
{
|
||||||
var well = GetOrDefault(idWell)
|
var cache = GetCache();
|
||||||
|
var cacheItem = cache.FirstOrDefault(d => d.Id == idWell)
|
||||||
?? throw new ArgumentInvalidException(nameof(idWell), $"idWell: {idWell} does not exist.");
|
?? throw new ArgumentInvalidException(nameof(idWell), $"idWell: {idWell} does not exist.");
|
||||||
return GetTimezone(well);
|
return cacheItem.Timezone.Adapt<SimpleTimezoneDto>();
|
||||||
}
|
|
||||||
|
|
||||||
private SimpleTimezoneDto GetTimezone(WellDto wellDto)
|
|
||||||
{
|
|
||||||
if (wellDto.Timezone is not null)
|
|
||||||
return wellDto.Timezone;
|
|
||||||
|
|
||||||
if (wellDto.Telemetry is not null)
|
|
||||||
{
|
|
||||||
var timezone = telemetryService.GetTimezone(wellDto.Telemetry.Id);
|
|
||||||
if (timezone is not null)
|
|
||||||
return timezone;
|
|
||||||
}
|
|
||||||
|
|
||||||
var well = GetQuery().FirstOrDefault(w => w.Id == wellDto.Id);
|
|
||||||
|
|
||||||
if (well is not null)
|
|
||||||
{
|
|
||||||
var point = GetCoordinates(well);
|
|
||||||
if (point is not null)
|
|
||||||
{
|
|
||||||
if (point.Timezone is not null)
|
|
||||||
{
|
|
||||||
return point.Timezone.Adapt<SimpleTimezoneDto>();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (point.Latitude is not null & point.Longitude is not null)
|
|
||||||
{
|
|
||||||
var timezone = timezoneService.GetOrDefaultByCoordinates(point.Latitude!.Value, point.Longitude!.Value);
|
|
||||||
if (timezone is not null)
|
|
||||||
{
|
|
||||||
return timezone;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new Exception($"Can't find timezone for well {wellDto.Caption} id: {wellDto.Id}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsTelemetryAssignedToDifferentWell(WellDto wellDto)
|
private bool IsTelemetryAssignedToDifferentWell(WellDto wellDto)
|
||||||
|
Loading…
Reference in New Issue
Block a user