forked from ddrilling/AsbCloudServer
Merge branch 'feature/#30435481-unification-date/time' into feature/refactoring_well_operation
# Conflicts: # AsbCloudApp/Data/WellOperationPlanDto.cs # AsbCloudApp/Repositories/IWellOperationRepository.cs # AsbCloudApp/Requests/WellOperationRequest.cs # AsbCloudDb/Migrations/AsbCloudDbContextModelSnapshot.cs # AsbCloudInfrastructure/Repository/WellOperationRepository.cs # AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs # AsbCloudInfrastructure/Services/SAUB/TelemetryDataBaseService.cs # AsbCloudInfrastructure/Services/WellService.cs # AsbCloudInfrastructure/XLExtentions.cs # AsbCloudWebApi/Controllers/WellOperationController.cs
This commit is contained in:
commit
640ad8cdc3
@ -74,7 +74,7 @@ public class DailyReportDto : IId,
|
||||
/// <summary>
|
||||
/// Дата последнего обновления
|
||||
/// </summary>
|
||||
public DateTime? DateLastUpdate { get; set; }
|
||||
public DateTimeOffset? DateLastUpdate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Блок фактической траектории
|
||||
|
@ -21,6 +21,6 @@ namespace AsbCloudApp.Data.DrillTestReport
|
||||
/// <summary>
|
||||
/// Дата отчета
|
||||
/// </summary>
|
||||
public DateTime Date { get; set; } = DateTime.Now;
|
||||
public DateTimeOffset Date { get; set; } = DateTimeOffset.Now;
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,6 @@ namespace AsbCloudApp.Data.DrillTestReport
|
||||
/// Дата и время
|
||||
/// </summary>
|
||||
[Required]
|
||||
public DateTime DateTime { get; set; }
|
||||
public DateTimeOffset DateTime { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ namespace AsbCloudApp.Data
|
||||
/// дата загрузки
|
||||
/// </summary>
|
||||
[Required]
|
||||
public DateTime UploadDate { get; set; }
|
||||
public DateTimeOffset UploadDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// размер в байтах
|
||||
|
@ -33,7 +33,7 @@ namespace AsbCloudApp.Data
|
||||
/// Необязательно указывать в запросе на создание.
|
||||
/// </summary>
|
||||
[Required]
|
||||
public DateTime DateCreated { get; set; }
|
||||
public DateTimeOffset DateCreated { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Полезный комментарий
|
||||
|
@ -20,12 +20,12 @@ namespace AsbCloudApp.Data
|
||||
/// <summary>
|
||||
/// Дата начала ограничения
|
||||
/// </summary>
|
||||
public DateTime DateStart { get; set; }
|
||||
public DateTimeOffset DateStart { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Дата окончания ограничения
|
||||
/// </summary>
|
||||
public DateTime DateEnd { get; set; }
|
||||
public DateTimeOffset DateEnd { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Глубина начала ограничения
|
||||
|
@ -18,7 +18,7 @@ public class ManualDto : IId
|
||||
/// <summary>
|
||||
/// Дата загрузки
|
||||
/// </summary>
|
||||
public DateTime DateDownload { get; set; }
|
||||
public DateTimeOffset DateDownload { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Id автора
|
||||
|
@ -36,7 +36,7 @@ namespace AsbCloudApp.Data
|
||||
/// отметка времени замера
|
||||
/// </summary>
|
||||
[Required]
|
||||
public DateTime Timestamp { get; set; }
|
||||
public DateTimeOffset Timestamp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// данные замера
|
||||
|
@ -16,7 +16,7 @@ namespace AsbCloudApp.Data
|
||||
/// дата появления события
|
||||
/// </summary>
|
||||
[Required]
|
||||
public DateTime DateTime { get; set; }
|
||||
public DateTimeOffset DateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// категория события
|
||||
|
@ -42,17 +42,17 @@ public class NotificationDto : IId
|
||||
/// Дата регистрации уведомления
|
||||
/// </summary>
|
||||
[Required]
|
||||
public DateTime RegistrationDate { get; set; }
|
||||
public DateTimeOffset RegistrationDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Дата отправки уведомления
|
||||
/// </summary>
|
||||
public DateTime? SentDate { get; set; }
|
||||
public DateTimeOffset? SentDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Дата прочтения уведомления
|
||||
/// </summary>
|
||||
public DateTime? ReadDate { get; set; }
|
||||
public DateTimeOffset? ReadDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Состояние уведомления
|
||||
@ -82,12 +82,12 @@ public class NotificationDto : IId
|
||||
ReadDate = null;
|
||||
break;
|
||||
case 1:
|
||||
SentDate = DateTime.UtcNow;
|
||||
SentDate = DateTimeOffset.UtcNow;
|
||||
ReadDate = null;
|
||||
break;
|
||||
case 2:
|
||||
SentDate = DateTime.UtcNow;
|
||||
ReadDate = DateTime.UtcNow;
|
||||
SentDate = DateTimeOffset.UtcNow;
|
||||
ReadDate = DateTimeOffset.UtcNow;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public class ProcessMapReportDataSaubStatDto
|
||||
/// на начало интервала
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public DateTime DateStart { get; set; }
|
||||
public DateTimeOffset DateStart { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Режим бурения (Ротор/слайд/ручной)
|
||||
|
@ -44,7 +44,7 @@ public class ProcessMapReportWellDrillingDto
|
||||
/// на начало интервала
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public DateTime DateStart { get; set; }
|
||||
public DateTimeOffset DateStart { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Время мех бурения, ч
|
||||
|
@ -29,17 +29,17 @@ namespace AsbCloudApp.Data
|
||||
/// <summary>
|
||||
/// Дата формирования
|
||||
/// </summary>
|
||||
public DateTime Date { get; set; }
|
||||
public DateTimeOffset Date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Дата начала рапорта
|
||||
/// </summary>
|
||||
public DateTime Begin { get; set; }
|
||||
public DateTimeOffset Begin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Дата окончания рапорта
|
||||
/// </summary>
|
||||
public DateTime End { get; set; }
|
||||
public DateTimeOffset End { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// шаг между точками диаграммы
|
||||
|
@ -33,7 +33,7 @@ namespace AsbCloudApp.Data.SAUB
|
||||
/// <summary>
|
||||
/// отметка времени создания запроса
|
||||
/// </summary>
|
||||
public DateTime UploadDate { get; set; } = DateTime.Now;
|
||||
public DateTimeOffset UploadDate { get; set; } = DateTimeOffset.Now;
|
||||
|
||||
/// <summary>
|
||||
/// время в секундах актуальности этого запроса
|
||||
|
@ -15,7 +15,7 @@ namespace AsbCloudApp.Data.SAUB
|
||||
/// <summary>
|
||||
/// отметка времени
|
||||
/// </summary>
|
||||
public DateTime Date { get; set; }
|
||||
public DateTimeOffset Date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// глубина забоя
|
||||
|
@ -10,7 +10,7 @@ namespace AsbCloudApp.Data.SAUB
|
||||
/// <summary>
|
||||
/// отметка времени
|
||||
/// </summary>
|
||||
public DateTime DateTime { get; set; }
|
||||
public DateTimeOffset DateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Наработка талевого каната с момента перетяжки каната, т*км
|
||||
|
@ -39,13 +39,13 @@ namespace AsbCloudApp.Data
|
||||
/// Начало бурения
|
||||
/// </summary>
|
||||
[Required]
|
||||
public DateTime DrillStart { get; set; }
|
||||
public DateTimeOffset DrillStart { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Конец бурения
|
||||
/// </summary>
|
||||
[Required]
|
||||
public DateTime DrillEnd { get; set; }
|
||||
public DateTimeOffset DrillEnd { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Бурильщик
|
||||
|
@ -11,12 +11,12 @@ namespace AsbCloudApp.Data
|
||||
/// <summary>
|
||||
/// Дата и время начала
|
||||
/// </summary>
|
||||
public DateTime? Start { get; set; }
|
||||
public DateTimeOffset? Start { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Дата и время окончания
|
||||
/// </summary>
|
||||
public DateTime? End { get; set; }
|
||||
public DateTimeOffset? End { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Глубина, м
|
||||
|
@ -42,7 +42,7 @@ namespace AsbCloudApp.Data
|
||||
/// дата прихода последней телеметрии
|
||||
/// </summary>
|
||||
[Required]
|
||||
public DateTime LastTelemetryDate { get; set; }
|
||||
public DateTimeOffset LastTelemetryDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Статистика по секциям
|
||||
|
@ -46,7 +46,7 @@ namespace AsbCloudApp.Data.Trajectory
|
||||
/// <summary>
|
||||
/// Дата загрузки
|
||||
/// </summary>
|
||||
public DateTime UpdateDate { get; set; }
|
||||
public DateTimeOffset UpdateDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ИД пользователя
|
||||
|
@ -67,12 +67,12 @@ namespace AsbCloudApp.Data
|
||||
/// <summary>
|
||||
/// Дата/время первой операции
|
||||
/// </summary>
|
||||
public DateTime? StartDate { get; set; }
|
||||
public DateTimeOffset? StartDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Дата/время кода приходили данные последний раз
|
||||
/// </summary>
|
||||
public DateTime LastTelemetryDate { get; set; }
|
||||
public DateTimeOffset LastTelemetryDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ID телеметрии
|
||||
|
@ -82,14 +82,14 @@ namespace AsbCloudApp.Data
|
||||
/// <para>Дата начала первой фактической операции</para>
|
||||
/// <para>Используется как дата начала бурения</para>
|
||||
/// </summary>
|
||||
public DateTime? FirstFactOperationDateStart { get; set; }
|
||||
public DateTimeOffset? FirstFactOperationDateStart { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// <para>Дата окончания последней прогнозируемой операции</para>
|
||||
/// <para>Если скважина завершена, то дата окончания последней фактической операции</para>
|
||||
/// <para>Используется как прогноз окончания бурения</para>
|
||||
/// </summary>
|
||||
public DateTime? LastPredictOperationDateEnd { get; set; }
|
||||
public DateTimeOffset? LastPredictOperationDateEnd { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Рейсовая скорость проходки, последнего рейса
|
||||
|
1
AsbCloudApp/Data/WellOperationPlanDto.cs
Normal file
1
AsbCloudApp/Data/WellOperationPlanDto.cs
Normal file
@ -0,0 +1 @@
|
||||
|
@ -1,6 +1,4 @@
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Requests;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@ -53,7 +51,7 @@ namespace AsbCloudApp.Repositories
|
||||
Task<int> InsertRangeAsync(IEnumerable<WellOperationDto> dtos, bool deleteBeforeInsert, CancellationToken token);
|
||||
|
||||
/// <summary>
|
||||
/// Обновить несколько существующую операций
|
||||
/// Обновить существующую операцию
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="token"></param>
|
||||
|
@ -33,12 +33,12 @@ namespace AsbCloudApp.Requests
|
||||
/// <summary>
|
||||
/// Дата начала периода
|
||||
/// </summary>
|
||||
public DateTime? Begin { get; set; }
|
||||
public DateTimeOffset? Begin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Дата окончания периода
|
||||
/// </summary>
|
||||
public DateTime? End { get; set; }
|
||||
public DateTimeOffset? End { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Признак удаления
|
||||
|
@ -17,12 +17,12 @@ namespace AsbCloudApp.Requests
|
||||
/// <summary>
|
||||
/// Больше или равно дате
|
||||
/// </summary>
|
||||
public DateTime? GtDate { get; set; }
|
||||
public DateTimeOffset? GtDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Меньше или равно дате
|
||||
/// </summary>
|
||||
public DateTime? LtDate { get; set; }
|
||||
public DateTimeOffset? LtDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Больше или равно глубины забоя
|
||||
|
@ -17,12 +17,12 @@ namespace AsbCloudApp.Requests
|
||||
/// <summary>
|
||||
/// начальная дата
|
||||
/// </summary>
|
||||
public DateTime? Begin { get; set; }
|
||||
public DateTimeOffset? Begin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// конечная дата
|
||||
/// </summary>
|
||||
public DateTime? End { get; set; }
|
||||
public DateTimeOffset? End { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// строка поиска
|
||||
|
@ -15,10 +15,10 @@ public class NotificationDeleteRequest
|
||||
/// <summary>
|
||||
/// Меньше или равно дате отправки
|
||||
/// </summary>
|
||||
public DateTime? LtSentDate { get; set; }
|
||||
public DateTimeOffset? LtSentDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Меньше или равно дате прочтения
|
||||
/// </summary>
|
||||
public DateTime? LtReadDate { get; set; }
|
||||
public DateTimeOffset? LtReadDate { get; set; }
|
||||
}
|
@ -20,5 +20,5 @@ public class ProcessMapPlanRequest
|
||||
/// <summary>
|
||||
/// Дата обновления
|
||||
/// </summary>
|
||||
public DateTime? UpdateFrom { get; set; }
|
||||
public DateTimeOffset? UpdateFrom { get; set; }
|
||||
}
|
@ -24,12 +24,12 @@ public class ReportParametersRequest: IValidatableObject
|
||||
/// <summary>
|
||||
/// Дата начала интервала
|
||||
/// </summary>
|
||||
public DateTime Begin { get; set; } = default;
|
||||
public DateTimeOffset Begin { get; set; } = default;
|
||||
|
||||
/// <summary>
|
||||
/// Дата окончания интервала
|
||||
/// </summary>
|
||||
public DateTime End { get; set; } = default;
|
||||
public DateTimeOffset End { get; set; } = default;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
@ -37,7 +37,7 @@ public class ReportParametersRequest: IValidatableObject
|
||||
if (End < Begin)
|
||||
yield return new("End mast be less then begin");
|
||||
|
||||
if (Begin < new DateTime(2000, 1, 1))
|
||||
if (Begin < new DateTimeOffset(2000, 1, 1, 0, 0, 0, TimeSpan.Zero))
|
||||
yield return new("Begin mast be > 2000-1-1");
|
||||
}
|
||||
}
|
@ -9,7 +9,7 @@ namespace AsbCloudApp.Requests
|
||||
/// </summary>
|
||||
public class SubsystemRequest: RequestBase, IValidatableObject
|
||||
{
|
||||
private static readonly DateTime validationMinDate = new DateTime(2020,01,01,0,0,0,DateTimeKind.Utc);
|
||||
private static readonly DateTimeOffset validationMinDate = new DateTimeOffset(2020,01,01,0,0,0, TimeSpan.Zero);
|
||||
|
||||
/// <summary>
|
||||
/// идентификатор скважины
|
||||
|
@ -15,10 +15,10 @@ public class TrajectoryRequest : RequestBase
|
||||
/// <summary>
|
||||
/// Больше или равно дате
|
||||
/// </summary>
|
||||
public DateTime? GeDate { get; set; }
|
||||
public DateTimeOffset? GeDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Меньше или равно дате
|
||||
/// </summary>
|
||||
public DateTime? LeDate { get; set; }
|
||||
public DateTimeOffset? LeDate { get; set; }
|
||||
}
|
@ -42,12 +42,4 @@ public interface IDailyReportService
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<PaginationContainer<DailyReportDto>> GetAsync(int idWell, FileReportRequest request, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Получить диапазон дат по которым возможно сформировать суточный отчёты
|
||||
/// </summary>
|
||||
/// <param name="idWell"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<DatesRangeDto?> GetDatesRangeAsync(int idWell, CancellationToken cancellationToken);
|
||||
}
|
@ -46,7 +46,7 @@ namespace AsbCloudApp.Services
|
||||
/// <param name="stepSeconds"></param>
|
||||
/// <param name="format"></param>
|
||||
/// <returns></returns>
|
||||
int GetReportPagesCount(int idWell, DateTime begin, DateTime end,
|
||||
int GetReportPagesCount(int idWell, DateTimeOffset begin, DateTimeOffset end,
|
||||
int stepSeconds, int format);
|
||||
|
||||
/// <summary>
|
||||
|
@ -19,7 +19,7 @@ namespace AsbCloudApp.Services
|
||||
/// <param name="workTime"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<ScheduleDto>> GetAsync(int idWell, DateTime workTime, CancellationToken token);
|
||||
Task<IEnumerable<ScheduleDto>> GetAsync(int idWell, DateTimeOffset workTime, CancellationToken token);
|
||||
|
||||
/// <summary>
|
||||
/// получить бурильщика по idWell и времени
|
||||
@ -28,7 +28,7 @@ namespace AsbCloudApp.Services
|
||||
/// <param name="workTime"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<DrillerDto?> GetOrDefaultDrillerAsync(int idWell, DateTime workTime, CancellationToken token);
|
||||
Task<DrillerDto?> GetOrDefaultDrillerAsync(int idWell, DateTimeOffset workTime, CancellationToken token);
|
||||
|
||||
/// <summary>
|
||||
/// Получить расписание смен
|
||||
|
@ -72,7 +72,7 @@ namespace AsbCloudApp.Services
|
||||
/// </summary>
|
||||
/// <param name="idWell"></param>
|
||||
/// <returns></returns>
|
||||
DateTime GetLastTelemetryDate(int idWell);
|
||||
DateTimeOffset GetLastTelemetryDate(int idWell);
|
||||
|
||||
//TODO: выяснить и удалить отсюда
|
||||
/// <summary>
|
||||
|
@ -49,7 +49,7 @@ public class NotificationService
|
||||
var notification = new NotificationDto
|
||||
{
|
||||
IdUser = request.IdUser,
|
||||
RegistrationDate = DateTime.UtcNow,
|
||||
RegistrationDate = DateTimeOffset.UtcNow,
|
||||
IdNotificationCategory = notificationCategory.Id,
|
||||
Title = request.Title,
|
||||
Message = request.Message,
|
||||
@ -71,7 +71,7 @@ public class NotificationService
|
||||
Console.WriteLine(ex.Message);
|
||||
}
|
||||
|
||||
notification.SentDate = DateTime.UtcNow;
|
||||
notification.SentDate = DateTimeOffset.UtcNow;
|
||||
await notificationRepository.UpdateAsync(notification, cancellationToken);
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ public class NotificationService
|
||||
if(isRead && !notification.SentDate.HasValue)
|
||||
throw new ArgumentInvalidException(nameof(isRead), "Уведомление не может быть прочитано");
|
||||
|
||||
notification.ReadDate = isRead ? DateTime.UtcNow : null;
|
||||
notification.ReadDate = isRead ? DateTimeOffset.UtcNow : null;
|
||||
|
||||
await notificationRepository.UpdateAsync(notification,
|
||||
cancellationToken);
|
||||
@ -119,7 +119,7 @@ public class NotificationService
|
||||
|
||||
var tasks = notifications.Select(notification =>
|
||||
{
|
||||
notification.SentDate = DateTime.UtcNow;
|
||||
notification.SentDate = DateTimeOffset.UtcNow;
|
||||
return notificationRepository.UpdateAsync(notification, cancellationToken);
|
||||
});
|
||||
|
||||
|
@ -18,7 +18,7 @@ public class DailyReport : IId
|
||||
public int IdWell { get; set; }
|
||||
|
||||
[Column("date_last_update", TypeName = "timestamp with time zone"), Comment("Дата последнего обновления")]
|
||||
public DateTime? DateLastUpdate { get; set; }
|
||||
public DateTimeOffset? DateLastUpdate { get; set; }
|
||||
|
||||
[Column("date", TypeName = "date"), Comment("Дата формирования отчёта")]
|
||||
public DateOnly Date { get; set; }
|
||||
|
@ -15,8 +15,8 @@ public class Manual : IId
|
||||
[Column("name"), Comment("Название")]
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
[Column("date_download"), Comment("Дата загрузки")]
|
||||
public DateTime DateDownload { get; set; }
|
||||
[Column("date_download", TypeName = "timestamp with time zone"), Comment("Дата загрузки")]
|
||||
public DateTimeOffset DateDownload { get; set; }
|
||||
|
||||
[Column("id_directory"), Comment("Id директории")]
|
||||
public int IdDirectory { get; set; }
|
||||
|
@ -25,13 +25,13 @@ public class Notification : IId
|
||||
public string Message { get; set; } = null!;
|
||||
|
||||
[Column("registration_date"), Comment("Дата регистрации уведомления")]
|
||||
public DateTime RegistrationDate { get; set; }
|
||||
public DateTimeOffset RegistrationDate { get; set; }
|
||||
|
||||
[Column("sent_date"), Comment("Дата отправки уведомления")]
|
||||
public DateTime? SentDate { get; set; }
|
||||
public DateTimeOffset? SentDate { get; set; }
|
||||
|
||||
[Column("read_date"), Comment("Дата прочтения уведомления")]
|
||||
public DateTime? ReadDate { get; set; }
|
||||
public DateTimeOffset? ReadDate { get; set; }
|
||||
|
||||
[Column("id_transport_type"), Comment("Id типа доставки уведомления")]
|
||||
public int IdTransportType { get; set; }
|
||||
|
@ -27,7 +27,7 @@ namespace AsbCloudInfrastructure.Background
|
||||
|
||||
await notificationService.SendAsync(notification, token);
|
||||
|
||||
notification.SentDate = DateTime.UtcNow;
|
||||
notification.SentDate = DateTimeOffset.UtcNow;
|
||||
await notificationRepository.UpdateAsync(notification, token);
|
||||
|
||||
}
|
||||
|
@ -1,80 +1,85 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AsbCloudApp.Data.DailyReport;
|
||||
using AsbCloudApp.Data.DailyReport.Blocks.Sign;
|
||||
using AsbCloudApp.Data.DailyReport.Blocks.Subsystems;
|
||||
using AsbCloudApp.Data.DailyReport.Blocks.TimeBalance;
|
||||
using AsbCloudApp.Repositories;
|
||||
using AsbCloudApp.Requests;
|
||||
using AsbCloudApp.Services;
|
||||
using AsbCloudDb;
|
||||
using AsbCloudDb.Model;
|
||||
using AsbCloudDb.Model.DailyReports;
|
||||
using Mapster;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AsbCloudInfrastructure.Repository;
|
||||
|
||||
public class DailyReportRepository : CrudRepositoryBase<DailyReportDto, DailyReport>,
|
||||
IDailyReportRepository
|
||||
IDailyReportRepository
|
||||
{
|
||||
public DailyReportRepository(IAsbCloudDbContext dbContext)
|
||||
: base(dbContext)
|
||||
{
|
||||
}
|
||||
private IWellService wellService;
|
||||
|
||||
public async Task<IEnumerable<DailyReportDto>> GetAsync(int idWell, FileReportRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var skip = request.Skip ?? 0;
|
||||
var take = request.Take ?? 10;
|
||||
public DailyReportRepository(IAsbCloudDbContext dbContext, IWellService wellService)
|
||||
: base(dbContext)
|
||||
{
|
||||
this.wellService = wellService;
|
||||
}
|
||||
|
||||
var query = GetQuery().Where(d => d.IdWell == idWell);
|
||||
public async Task<IEnumerable<DailyReportDto>> GetAsync(int idWell, FileReportRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var skip = request.Skip ?? 0;
|
||||
var take = request.Take ?? 10;
|
||||
|
||||
if (request.GeDate.HasValue)
|
||||
query = query.Where(d => d.Date >= request.GeDate.Value);
|
||||
|
||||
if (request.LeDate.HasValue)
|
||||
query = query.Where(d => d.Date <= request.LeDate.Value);
|
||||
var query = GetQuery().Where(d => d.IdWell == idWell);
|
||||
|
||||
query = request.SortFields?.Any() == true ?
|
||||
query.SortBy(request.SortFields) :
|
||||
query.OrderBy(d => d.Date);
|
||||
if (request.GeDate.HasValue)
|
||||
query = query.Where(d => d.Date >= request.GeDate.Value);
|
||||
|
||||
var entities = await query
|
||||
.Skip(skip)
|
||||
.Take(take)
|
||||
.AsNoTracking()
|
||||
.ToArrayAsync(cancellationToken);
|
||||
if (request.LeDate.HasValue)
|
||||
query = query.Where(d => d.Date <= request.LeDate.Value);
|
||||
|
||||
var dtos = entities.Select(Convert);
|
||||
query = request.SortFields?.Any() == true ?
|
||||
query.SortBy(request.SortFields) :
|
||||
query.OrderBy(d => d.Date);
|
||||
|
||||
return dtos;
|
||||
}
|
||||
var entities = await query
|
||||
.Skip(skip)
|
||||
.Take(take)
|
||||
.AsNoTracking()
|
||||
.ToArrayAsync(cancellationToken);
|
||||
|
||||
public async Task<DailyReportDto?> GetOrDefaultAsync(int idWell, DateOnly date, CancellationToken cancellationToken)
|
||||
{
|
||||
var entity = await GetQuery()
|
||||
.AsNoTracking()
|
||||
.SingleOrDefaultAsync(d => d.IdWell == idWell && d.Date == date, cancellationToken);
|
||||
var timezoneOffset = wellService.GetTimezone(idWell).Offset;
|
||||
var dtos = entities.Select(entity => Convert(entity, timezoneOffset));
|
||||
|
||||
return entity is null ? null : Convert(entity);
|
||||
}
|
||||
return dtos;
|
||||
}
|
||||
|
||||
protected override DailyReportDto Convert(DailyReport src)
|
||||
{
|
||||
var dto = new DailyReportDto
|
||||
{
|
||||
Id = src.Id,
|
||||
IdWell = src.IdWell,
|
||||
DateLastUpdate = src.DateLastUpdate,
|
||||
Date = src.Date,
|
||||
SignBlock = src.SignBlock?.Adapt<SignBlockDto>(),
|
||||
TimeBalanceBlock = src.TimeBalanceBlock?.Adapt<TimeBalanceBlockDto>(),
|
||||
SubsystemBlock = src.SubsystemBlock?.Adapt<SubsystemBlockDto>()
|
||||
};
|
||||
|
||||
return dto;
|
||||
}
|
||||
public async Task<DailyReportDto?> GetOrDefaultAsync(int idWell, DateOnly date, CancellationToken cancellationToken)
|
||||
{
|
||||
var entity = await GetQuery()
|
||||
.AsNoTracking()
|
||||
.SingleOrDefaultAsync(d => d.IdWell == idWell && d.Date == date, cancellationToken);
|
||||
|
||||
return entity is null ? null : Convert(entity);
|
||||
}
|
||||
|
||||
protected DailyReportDto Convert(DailyReport src, TimeSpan timezoneOffset)
|
||||
{
|
||||
var dto = new DailyReportDto
|
||||
{
|
||||
Id = src.Id,
|
||||
IdWell = src.IdWell,
|
||||
DateLastUpdate = src.DateLastUpdate?.ToOffset(timezoneOffset),
|
||||
Date = src.Date,
|
||||
SignBlock = src.SignBlock?.Adapt<SignBlockDto>(),
|
||||
TimeBalanceBlock = src.TimeBalanceBlock?.Adapt<TimeBalanceBlockDto>(),
|
||||
SubsystemBlock = src.SubsystemBlock?.Adapt<SubsystemBlockDto>()
|
||||
};
|
||||
|
||||
return dto;
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ using AsbCloudApp.Services;
|
||||
using AsbCloudDb.Model;
|
||||
using Mapster;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
@ -111,7 +112,8 @@ namespace AsbCloudInfrastructure.Repository
|
||||
{
|
||||
var dto = well.Adapt<WellDto>();
|
||||
dto.WellType = well.WellType.Caption;
|
||||
dto.LastTelemetryDate = wellService.GetLastTelemetryDate(well.Id);
|
||||
dto.LastTelemetryDate = wellService.GetLastTelemetryDate(well.Id)
|
||||
.ToOffset(TimeSpan.FromHours(well.Timezone.Hours));
|
||||
dto.Cluster = gCluster.Key.Caption;
|
||||
dto.Deposit = gDeposit.Key.Caption;
|
||||
return dto;
|
||||
|
@ -36,9 +36,6 @@ namespace AsbCloudInfrastructure.Repository
|
||||
var query = dbSetConfigured
|
||||
.Where(e => e.IdWell == request.IdWell);
|
||||
|
||||
double timezoneOffsetHours = query.FirstOrDefault()
|
||||
?.Well.Timezone.Hours ?? 5d;
|
||||
|
||||
if (request.IdCategory is not null)
|
||||
query = query.Where(x => x.IdCategory == request.IdCategory);
|
||||
|
||||
@ -53,13 +50,13 @@ namespace AsbCloudInfrastructure.Repository
|
||||
|
||||
if (request.Begin is not null)
|
||||
{
|
||||
var beginUtc = request.Begin.Value.ToUtcDateTimeOffset(timezoneOffsetHours);
|
||||
var beginUtc = request.Begin.Value.ToUniversalTime();
|
||||
query = query.Where(e => e.UploadDate >= beginUtc);
|
||||
}
|
||||
|
||||
if (request.End is not null)
|
||||
{
|
||||
var endUtc = request.End.Value.ToUtcDateTimeOffset(timezoneOffsetHours);
|
||||
var endUtc = request.End.Value.ToUniversalTime();
|
||||
query = query.Where(e => e.UploadDate <= endUtc);
|
||||
}
|
||||
|
||||
@ -184,7 +181,7 @@ namespace AsbCloudInfrastructure.Repository
|
||||
|
||||
var newFileMark = fileMarkDto.Adapt<FileMark>();
|
||||
newFileMark.Id = default;
|
||||
newFileMark.DateCreated = DateTime.UtcNow;
|
||||
newFileMark.DateCreated = DateTimeOffset.UtcNow;
|
||||
newFileMark.IdUser = idUser;
|
||||
newFileMark.User = null!;
|
||||
|
||||
@ -244,7 +241,7 @@ namespace AsbCloudInfrastructure.Repository
|
||||
IdAuthor = newItem.IdAuthor,
|
||||
IdCategory = newItem.IdCategory,
|
||||
Name = newItem.Name,
|
||||
UploadDate = DateTime.UtcNow,
|
||||
UploadDate = DateTimeOffset.UtcNow,
|
||||
IsDeleted = false,
|
||||
Size = newItem.Size,
|
||||
};
|
||||
@ -278,11 +275,11 @@ namespace AsbCloudInfrastructure.Repository
|
||||
private static FileInfoDto Convert(FileInfo entity, double timezoneOffset)
|
||||
{
|
||||
var dto = entity.Adapt<FileInfoDto>();
|
||||
dto.UploadDate = entity.UploadDate.ToRemoteDateTime(timezoneOffset);
|
||||
dto.UploadDate = entity.UploadDate.ToOffset(TimeSpan.FromHours(timezoneOffset));
|
||||
dto.FileMarks = entity.FileMarks.Select(m =>
|
||||
{
|
||||
var mark = m.Adapt<FileMarkDto>();
|
||||
mark.DateCreated = m.DateCreated.ToRemoteDateTime(timezoneOffset);
|
||||
mark.DateCreated = m.DateCreated.ToOffset(TimeSpan.FromHours(timezoneOffset));
|
||||
return mark;
|
||||
});
|
||||
return dto;
|
||||
|
@ -39,8 +39,8 @@ namespace AsbCloudInfrastructure.Repository
|
||||
IdWell = request.IdWell,
|
||||
IdTelemetry = x.IdTelemetry,
|
||||
IdFeedRegulator = x.IdFeedRegulator,
|
||||
DateStart = DateTime.SpecifyKind(x.DateStart.UtcDateTime + timezoneSpan, DateTimeKind.Unspecified),
|
||||
DateEnd = DateTime.SpecifyKind(x.DateEnd.UtcDateTime + timezoneSpan, DateTimeKind.Unspecified),
|
||||
DateStart = x.DateStart.ToOffset(timezoneSpan),
|
||||
DateEnd = x.DateEnd.ToOffset(timezoneSpan),
|
||||
DepthStart = x.DepthStart,
|
||||
DepthEnd = x.DepthEnd
|
||||
});
|
||||
@ -56,13 +56,13 @@ namespace AsbCloudInfrastructure.Repository
|
||||
|
||||
if (request.GtDate.HasValue)
|
||||
{
|
||||
var gtDate = request.GtDate.Value.ToUtcDateTimeOffset(timezoneHours);
|
||||
var gtDate = request.GtDate.Value.ToUniversalTime();
|
||||
query = query.Where(x => x.DateEnd >= gtDate);
|
||||
}
|
||||
|
||||
if (request.LtDate.HasValue)
|
||||
{
|
||||
var ltDate = request.LtDate.Value.ToUtcDateTimeOffset(timezoneHours);
|
||||
var ltDate = request.LtDate.Value.ToUniversalTime();
|
||||
query = query.Where(x => x.DateStart <= ltDate);
|
||||
}
|
||||
|
||||
|
@ -110,10 +110,10 @@ public class NotificationRepository : CrudRepositoryBase<NotificationDto, Notifi
|
||||
query = query.Where(n => n.IdNotificationCategory == request.IdCategory.Value);
|
||||
|
||||
if (request.LtSentDate.HasValue)
|
||||
query = query.Where(n => n.SentDate <= request.LtSentDate.Value);
|
||||
query = query.Where(n => n.SentDate <= request.LtSentDate.Value.ToUniversalTime());
|
||||
|
||||
if (request.LtReadDate.HasValue)
|
||||
query = query.Where(n => n.ReadDate <= request.LtReadDate.Value);
|
||||
query = query.Where(n => n.ReadDate <= request.LtReadDate.Value.ToUniversalTime());
|
||||
|
||||
dbContext.Notifications.RemoveRange(query);
|
||||
|
||||
|
@ -24,7 +24,7 @@ namespace AsbCloudInfrastructure.Repository
|
||||
this.wellService = wellService;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<ScheduleDto>> GetAsync(int idWell, DateTime workTime, CancellationToken token)
|
||||
public async Task<IEnumerable<ScheduleDto>> GetAsync(int idWell, DateTimeOffset workTime, CancellationToken token)
|
||||
{
|
||||
var entities = await BuildQuery(idWell, workTime)
|
||||
.AsNoTracking()
|
||||
@ -33,7 +33,7 @@ namespace AsbCloudInfrastructure.Repository
|
||||
return entities.Select(Convert);
|
||||
}
|
||||
|
||||
public async Task<DrillerDto?> GetOrDefaultDrillerAsync(int idWell, DateTime workTime, CancellationToken token)
|
||||
public async Task<DrillerDto?> GetOrDefaultDrillerAsync(int idWell, DateTimeOffset workTime, CancellationToken token)
|
||||
{
|
||||
var entities = await BuildQuery(idWell, workTime)
|
||||
.AsNoTracking()
|
||||
@ -43,8 +43,7 @@ namespace AsbCloudInfrastructure.Repository
|
||||
return null;
|
||||
|
||||
var hoursOffset = wellService.GetTimezone(idWell).Hours;
|
||||
var remoteDate = workTime.ToUtcDateTimeOffset(hoursOffset).ToRemoteDateTime(hoursOffset);
|
||||
var time = new TimeOnly(remoteDate.Hour, remoteDate.Minute, remoteDate.Second);
|
||||
var time = new TimeOnly(workTime.Hour, workTime.Minute, workTime.Second);
|
||||
|
||||
var entity = entities.FirstOrDefault(s =>
|
||||
s.ShiftStart > s.ShiftEnd ^
|
||||
@ -69,11 +68,11 @@ namespace AsbCloudInfrastructure.Repository
|
||||
|
||||
}
|
||||
|
||||
private IQueryable<Schedule> BuildQuery(int idWell, DateTime workTime)
|
||||
private IQueryable<Schedule> BuildQuery(int idWell, DateTimeOffset workTime)
|
||||
{
|
||||
var hoursOffset = wellService.GetTimezone(idWell).Hours;
|
||||
|
||||
var workTimeDateTime = workTime.ToUtcDateTimeOffset(hoursOffset);
|
||||
var workTimeDateTime = workTime.ToUniversalTime();
|
||||
|
||||
return GetQuery().Where(s => s.IdWell == idWell
|
||||
&& s.DrillStart <= workTimeDateTime
|
||||
@ -82,19 +81,20 @@ namespace AsbCloudInfrastructure.Repository
|
||||
|
||||
protected override Schedule Convert(ScheduleDto dto)
|
||||
{
|
||||
var hoursOffset = wellService.GetTimezone(dto.IdWell).Hours;
|
||||
var entity = base.Convert(dto);
|
||||
entity.DrillStart = dto.DrillStart.ToUtcDateTimeOffset(hoursOffset);
|
||||
entity.DrillEnd = dto.DrillEnd.ToUtcDateTimeOffset(hoursOffset);
|
||||
entity.DrillStart = dto.DrillStart.ToUniversalTime();
|
||||
entity.DrillEnd = dto.DrillEnd.ToUniversalTime();
|
||||
return entity;
|
||||
}
|
||||
|
||||
protected override ScheduleDto Convert(Schedule entity)
|
||||
{
|
||||
var hoursOffset = wellService.GetTimezone(entity.IdWell).Hours;
|
||||
var timeSpan = TimeSpan.FromHours(hoursOffset);
|
||||
|
||||
var dto = base.Convert(entity);
|
||||
dto.DrillStart = entity.DrillStart.ToRemoteDateTime(hoursOffset);
|
||||
dto.DrillEnd = entity.DrillEnd.ToRemoteDateTime(hoursOffset);
|
||||
dto.DrillStart = entity.DrillStart.ToOffset(timeSpan);
|
||||
dto.DrillEnd = entity.DrillEnd.ToOffset(timeSpan);
|
||||
return dto;
|
||||
}
|
||||
}
|
||||
|
@ -50,15 +50,14 @@ namespace AsbCloudInfrastructure.Repository
|
||||
{
|
||||
var result = base.Convert(src);
|
||||
var timezoneOffsetHours = wellService.GetTimezone(src.IdWell).Hours;
|
||||
result.UploadDate = src.UploadDate.ToRemoteDateTime(timezoneOffsetHours);
|
||||
result.UploadDate = src.UploadDate.ToOffset(TimeSpan.FromHours(timezoneOffsetHours));
|
||||
return result;
|
||||
}
|
||||
|
||||
protected override SetpointsRequest Convert(SetpointsRequestDto src)
|
||||
{
|
||||
var result = base.Convert(src);
|
||||
var timezoneOffsetHours = wellService.GetTimezone(src.IdWell).Hours;
|
||||
result.UploadDate = src.UploadDate.ToUtcDateTimeOffset(timezoneOffsetHours);
|
||||
result.UploadDate = src.UploadDate.ToUniversalTime();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ using AsbCloudApp.Services;
|
||||
using AsbCloudDb.Model;
|
||||
using Mapster;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
@ -93,14 +94,14 @@ namespace AsbCloudInfrastructure.Repository
|
||||
{
|
||||
var entity = dto.Adapt<TelemetryWirelineRunOut>();
|
||||
entity.IdTelemetry = idTelemetry;
|
||||
entity.DateTime = dto.DateTime.ToUtcDateTimeOffset(timezoneOffset);
|
||||
entity.DateTime = dto.DateTime.ToUniversalTime();
|
||||
return entity;
|
||||
}
|
||||
|
||||
private static TelemetryWirelineRunOutDto Convert(TelemetryWirelineRunOut entity, WellDto well, double timezoneOffset)
|
||||
{
|
||||
var dto = entity.Adapt<TelemetryWirelineRunOutDto>();
|
||||
dto.DateTime = entity.DateTime.ToRemoteDateTime(timezoneOffset);
|
||||
dto.DateTime = entity.DateTime.ToOffset(TimeSpan.FromHours(timezoneOffset));
|
||||
dto.WellInfo = well;
|
||||
return dto;
|
||||
}
|
||||
|
@ -37,11 +37,10 @@ namespace AsbCloudInfrastructure.Repository
|
||||
if (!trajectoryRows.All(r => r.IdWell == idWell))
|
||||
throw new ArgumentInvalidException(nameof(trajectoryRows), "Все строки должны относиться к одной скважине");
|
||||
|
||||
var offsetHours = wellService.GetTimezone(idWell).Hours;
|
||||
var entities = trajectoryRows
|
||||
.Select(e =>
|
||||
{
|
||||
var entity = Convert(e, offsetHours);
|
||||
var entity = Convert(e);
|
||||
entity.Id = 0;
|
||||
return entity;
|
||||
});
|
||||
@ -52,8 +51,7 @@ namespace AsbCloudInfrastructure.Repository
|
||||
|
||||
public async Task<int> AddAsync(Tdto trajectoryRow, CancellationToken token)
|
||||
{
|
||||
var offsetHours = wellService.GetTimezone(trajectoryRow.IdWell).Hours;
|
||||
var entity = Convert(trajectoryRow, offsetHours);
|
||||
var entity = Convert(trajectoryRow);
|
||||
entity.Id = 0;
|
||||
db.Set<TEntity>().Add(entity);
|
||||
return await db.SaveChangesAsync(token)
|
||||
@ -98,8 +96,7 @@ namespace AsbCloudInfrastructure.Repository
|
||||
|
||||
public async Task<int> UpdateAsync(Tdto row, CancellationToken token)
|
||||
{
|
||||
var offsetHours = wellService.GetTimezone(row.IdWell).Hours;
|
||||
var entity = Convert(row, offsetHours);
|
||||
var entity = Convert(row);
|
||||
db.Set<TEntity>().Update(entity);
|
||||
return await db.SaveChangesAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
@ -108,14 +105,14 @@ namespace AsbCloudInfrastructure.Repository
|
||||
private static Tdto Convert(TEntity entity, double offsetHours)
|
||||
{
|
||||
var dto = entity.Adapt<Tdto>();
|
||||
dto.UpdateDate = entity.UpdateDate.ToRemoteDateTime(offsetHours);
|
||||
dto.UpdateDate = entity.UpdateDate.ToOffset(TimeSpan.FromHours(offsetHours));
|
||||
return dto;
|
||||
}
|
||||
|
||||
private static TEntity Convert(Tdto dto, double offsetHours)
|
||||
private static TEntity Convert(Tdto dto)
|
||||
{
|
||||
var entity = dto.Adapt<TEntity>();
|
||||
entity.UpdateDate = DateTime.Now.ToUtcDateTimeOffset(offsetHours);
|
||||
entity.UpdateDate = DateTimeOffset.Now;
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
@ -38,13 +38,13 @@ namespace AsbCloudInfrastructure.Repository
|
||||
|
||||
if (request.GeDate.HasValue)
|
||||
{
|
||||
var geDate = request.GeDate.Value.ToUtcDateTimeOffset(timezone.Hours);
|
||||
var geDate = request.GeDate.Value.ToUniversalTime();
|
||||
query = query.Where(r => r.DateTime >= geDate);
|
||||
}
|
||||
|
||||
if (request.LeDate.HasValue)
|
||||
{
|
||||
var leDate = request.LeDate.Value.ToUtcDateTimeOffset(timezone.Hours);
|
||||
var leDate = request.LeDate.Value.ToUniversalTime();
|
||||
query = query.Where(r => r.DateTime <= leDate);
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ public class DailyReportService : IDailyReportService
|
||||
editableBlock.IdUser = idUser;
|
||||
editableBlock.LastUpdateDate = DateTime.UtcNow;
|
||||
|
||||
dailyReport.DateLastUpdate = DateTime.UtcNow;
|
||||
dailyReport.DateLastUpdate = DateTimeOffset.UtcNow;
|
||||
|
||||
if (dailyReport.Id == 0)
|
||||
return await dailyReportRepository.InsertAsync(dailyReport, cancellationToken);
|
||||
@ -107,9 +107,10 @@ public class DailyReportService : IDailyReportService
|
||||
IdWell = well.Id
|
||||
};
|
||||
|
||||
var geDate = dailyReport.Date.ToDateTime(TimeOnly.MinValue, DateTimeKind.Unspecified);
|
||||
var leDate = dailyReport.Date.AddDays(1).ToDateTime(TimeOnly.MinValue, DateTimeKind.Unspecified);
|
||||
|
||||
var offsetHours = wellService.GetTimezone(dailyReport.IdWell).Hours;
|
||||
var geDate = new DateTimeOffset(dailyReport.Date, TimeOnly.MinValue, TimeSpan.FromHours(offsetHours));
|
||||
var leDate = new DateTimeOffset(dailyReport.Date.AddDays(1), TimeOnly.MinValue, TimeSpan.FromHours(offsetHours));
|
||||
|
||||
var factOperationRequest = new WellOperationRequest(new []{ idWell })
|
||||
{
|
||||
OperationType = WellOperation.IdOperationTypeFact,
|
||||
@ -130,12 +131,12 @@ public class DailyReportService : IDailyReportService
|
||||
dailyReport.DepthStart = factWellOperations.FirstOrDefault()?.DepthStart;
|
||||
dailyReport.DepthEnd = factWellOperations.LastOrDefault()?.DepthEnd;
|
||||
|
||||
await UpdateTimeBalanceBlockAsync(dailyReport, factWellOperations, cancellationToken);
|
||||
await UpdateSubsystemBlockAsync(dailyReport, cancellationToken);
|
||||
await UpdateTimeBalanceBlockAsync(dailyReport, factWellOperations, geDate, leDate, cancellationToken);
|
||||
await UpdateSubsystemBlockAsync(dailyReport, geDate, leDate, cancellationToken);
|
||||
|
||||
await AddTrajectoryBlockAsync(dailyReport, cancellationToken);
|
||||
await AddScheduleBlockAsync(dailyReport, cancellationToken);
|
||||
await AddProcessMapWellDrillingBlockAsync(dailyReport, cancellationToken);
|
||||
await AddTrajectoryBlockAsync(dailyReport, geDate, leDate, cancellationToken);
|
||||
await AddScheduleBlockAsync(dailyReport, geDate, cancellationToken);
|
||||
await AddProcessMapWellDrillingBlockAsync(dailyReport, geDate, leDate, cancellationToken);
|
||||
|
||||
AddFactWellOperationBlock(dailyReport, factWellOperations);
|
||||
|
||||
@ -152,34 +153,32 @@ public class DailyReportService : IDailyReportService
|
||||
Items = Enumerable.Empty<DailyReportDto>()
|
||||
};
|
||||
|
||||
var datesRange = await GetDatesRangeAsync(idWell, cancellationToken);
|
||||
var datesRange = await wellOperationRepository.GetDatesRangeAsync(idWell, WellOperation.IdOperationTypeFact, cancellationToken);
|
||||
|
||||
if (datesRange is null)
|
||||
return result;
|
||||
|
||||
var dailyReports = new List<DailyReportDto>();
|
||||
|
||||
if (request.GeDate.HasValue)
|
||||
{
|
||||
var startDate = new DateTime(request.GeDate.Value.Year, request.GeDate.Value.Month,
|
||||
request.GeDate.Value.Day);
|
||||
TimeSpan offset = wellService.GetTimezone(idWell).Offset;
|
||||
|
||||
if (startDate.Date >= datesRange.From.Date)
|
||||
if (request.GeDate.HasValue)
|
||||
{
|
||||
var startDate = new DateTimeOffset(request.GeDate.Value, TimeOnly.MinValue, offset);
|
||||
|
||||
if (startDate >= datesRange.From)
|
||||
datesRange.From = startDate;
|
||||
}
|
||||
|
||||
if (request.LeDate.HasValue)
|
||||
{
|
||||
var finishDate = new DateTime(request.LeDate.Value.Year, request.LeDate.Value.Month,
|
||||
request.LeDate.Value.Day);
|
||||
var finishDate = new DateTimeOffset(request.LeDate.Value, TimeOnly.MinValue, offset);
|
||||
|
||||
if (finishDate.Date <= datesRange.To.Date)
|
||||
if (finishDate <= datesRange.To)
|
||||
datesRange.To = finishDate;
|
||||
}
|
||||
|
||||
if (datesRange.From.AddDays(result.Skip) <= datesRange.To)
|
||||
result.Count = (int)(Math.Ceiling((datesRange.To - DateTime.UnixEpoch).TotalDays) -
|
||||
Math.Floor((datesRange.From - DateTime.UnixEpoch).TotalDays)) + 1;
|
||||
result.Count = (int)(Math.Ceiling((datesRange.To - DateTimeOffset.UnixEpoch).TotalDays)
|
||||
- Math.Floor((datesRange.From - DateTimeOffset.UnixEpoch).TotalDays));
|
||||
|
||||
var existingDailyReports = await dailyReportRepository.GetAsync(idWell, request, cancellationToken);
|
||||
|
||||
@ -227,11 +226,11 @@ public class DailyReportService : IDailyReportService
|
||||
IdWell = idWell
|
||||
};
|
||||
|
||||
var geDate = date.ToDateTime(TimeOnly.MinValue, DateTimeKind.Unspecified);
|
||||
var leDate = date.AddDays(1).ToDateTime(TimeOnly.MinValue, DateTimeKind.Unspecified);
|
||||
var geDate = new DateTimeOffset(date, TimeOnly.MinValue, offset);
|
||||
var leDate = new DateTimeOffset(date.AddDays(1), TimeOnly.MinValue, offset);
|
||||
|
||||
var factWellOperationPerDay = factWellOperations.Where(o => o.DateStart.Date >= geDate &&
|
||||
o.DateStart.Date <= leDate);
|
||||
var factWellOperationPerDay = factWellOperations.Where(o => o.DateStart >= geDate &&
|
||||
o.DateStart <= leDate);
|
||||
|
||||
AddFactWellOperationBlock(dailyReport, factWellOperationPerDay);
|
||||
|
||||
@ -239,36 +238,8 @@ public class DailyReportService : IDailyReportService
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<DatesRangeDto?> GetDatesRangeAsync(int idWell, CancellationToken cancellationToken)
|
||||
{
|
||||
var timezone = wellService.GetTimezone(idWell);
|
||||
var currentDate = DateTimeOffset.UtcNow.ToRemoteDateTime(timezone.Hours);
|
||||
|
||||
var factOperationDatesRange = await wellOperationRepository.GetDatesRangeAsync(idWell, WellOperation.IdOperationTypeFact,
|
||||
cancellationToken);
|
||||
|
||||
if (factOperationDatesRange is null)
|
||||
return null;
|
||||
|
||||
var from = (factOperationDatesRange.From.AddDays(1) <= DateTime.UtcNow ?
|
||||
factOperationDatesRange.From :
|
||||
currentDate.AddDays(-1))
|
||||
.Date;
|
||||
|
||||
var to = (factOperationDatesRange.To.AddDays(1) <= DateTime.UtcNow ?
|
||||
factOperationDatesRange.To :
|
||||
currentDate.AddDays(-1))
|
||||
.Date;
|
||||
|
||||
return new DatesRangeDto
|
||||
{
|
||||
From = from,
|
||||
To = to
|
||||
};
|
||||
}
|
||||
|
||||
private async Task UpdateTimeBalanceBlockAsync(DailyReportDto dailyReport, IEnumerable<WellOperationDto> factWellOperations,
|
||||
CancellationToken cancellationToken)
|
||||
DateTimeOffset geDateStart, DateTimeOffset leDateEnd, CancellationToken cancellationToken)
|
||||
{
|
||||
const int idWellOperationSlipsTime = 5011;
|
||||
|
||||
@ -277,10 +248,7 @@ public class DailyReportService : IDailyReportService
|
||||
dailyReport.TimeBalanceBlock.SectionName = wellOperationRepository.GetSectionTypes()
|
||||
.FirstOrDefault(s => s.Id == dailyReport.TimeBalanceBlock.IdSection)?.Caption;
|
||||
|
||||
var geDateStart = dailyReport.Date.ToDateTime(TimeOnly.MinValue, DateTimeKind.Unspecified);
|
||||
var leDateEnd = dailyReport.Date.AddDays(1).ToDateTime(TimeOnly.MinValue, DateTimeKind.Unspecified);
|
||||
|
||||
dailyReport.TimeBalanceBlock.WellOperationSlipsTimeCount = (await detectedOperationService.GetAsync(
|
||||
dailyReport.TimeBalanceBlock.WellOperationSlipsTimeCount = (await detectedOperationService.GetAsync(
|
||||
new DetectedOperationByWellRequest
|
||||
{
|
||||
IdsCategories = new[] { idWellOperationSlipsTime },
|
||||
@ -295,11 +263,9 @@ public class DailyReportService : IDailyReportService
|
||||
}
|
||||
}
|
||||
|
||||
private async Task AddTrajectoryBlockAsync(DailyReportDto dailyReport, CancellationToken cancellationToken)
|
||||
private async Task AddTrajectoryBlockAsync(DailyReportDto dailyReport,
|
||||
DateTimeOffset geDate, DateTimeOffset leDate, CancellationToken cancellationToken)
|
||||
{
|
||||
var geDate = dailyReport.Date.ToDateTime(TimeOnly.MinValue, DateTimeKind.Utc);
|
||||
var leDate = dailyReport.Date.AddDays(1).ToDateTime(TimeOnly.MinValue, DateTimeKind.Utc);
|
||||
|
||||
var trajectory = (await trajectoryFactNnbRepository.GetByRequestAsync(new TrajectoryRequest
|
||||
{
|
||||
IdWell = dailyReport.IdWell,
|
||||
@ -316,11 +282,9 @@ public class DailyReportService : IDailyReportService
|
||||
};
|
||||
}
|
||||
|
||||
private async Task AddScheduleBlockAsync(DailyReportDto dailyReport, CancellationToken cancellationToken)
|
||||
private async Task AddScheduleBlockAsync(DailyReportDto dailyReport, DateTimeOffset workDate, CancellationToken cancellationToken)
|
||||
{
|
||||
var workDate = dailyReport.Date.ToDateTime(TimeOnly.MinValue, DateTimeKind.Unspecified);
|
||||
|
||||
dailyReport.ScheduleBlock = (await scheduleRepository.GetAsync(dailyReport.IdWell, workDate, cancellationToken))
|
||||
dailyReport.ScheduleBlock = (await scheduleRepository.GetAsync(dailyReport.IdWell, workDate, cancellationToken))
|
||||
.Select(s => new ScheduleRecordDto
|
||||
{
|
||||
ShiftStart = s.ShiftStart,
|
||||
@ -331,7 +295,8 @@ public class DailyReportService : IDailyReportService
|
||||
});
|
||||
}
|
||||
|
||||
private async Task UpdateSubsystemBlockAsync(DailyReportDto dailyReport, CancellationToken cancellationToken)
|
||||
private async Task UpdateSubsystemBlockAsync(DailyReportDto dailyReport,
|
||||
DateTimeOffset geDate, DateTimeOffset leDate, CancellationToken cancellationToken)
|
||||
{
|
||||
dailyReport.SubsystemBlock ??= new SubsystemBlockDto();
|
||||
|
||||
@ -343,9 +308,6 @@ public class DailyReportService : IDailyReportService
|
||||
{
|
||||
IdWell = dailyReport.IdWell
|
||||
}, cancellationToken);
|
||||
|
||||
var geDate = dailyReport.Date.ToDateTime(TimeOnly.MinValue, DateTimeKind.Unspecified);
|
||||
var leDate = dailyReport.Date.AddDays(1).ToDateTime(TimeOnly.MinValue, DateTimeKind.Unspecified);
|
||||
|
||||
var subsystemsStatPerDay = await subsystemService.GetStatAsync(new SubsystemRequest
|
||||
{
|
||||
@ -369,11 +331,9 @@ public class DailyReportService : IDailyReportService
|
||||
}
|
||||
}
|
||||
|
||||
private async Task AddProcessMapWellDrillingBlockAsync(DailyReportDto dailyReport, CancellationToken cancellationToken)
|
||||
private async Task AddProcessMapWellDrillingBlockAsync(DailyReportDto dailyReport,
|
||||
DateTimeOffset geDate, DateTimeOffset leDate, CancellationToken cancellationToken)
|
||||
{
|
||||
var geDate = dailyReport.Date.ToDateTime(TimeOnly.MinValue, DateTimeKind.Unspecified);
|
||||
var leDate = dailyReport.Date.AddDays(1).ToDateTime(TimeOnly.MinValue, DateTimeKind.Unspecified);
|
||||
|
||||
var request = new DataSaubStatRequest();
|
||||
dailyReport.ProcessMapWellDrillingBlock = (await processMapReportDrillingService.GetAsync(dailyReport.IdWell, request,
|
||||
cancellationToken)).Where(p => p.DateStart >= geDate && p.DateStart <= leDate)
|
||||
@ -412,11 +372,10 @@ public class DailyReportService : IDailyReportService
|
||||
|
||||
private async Task<bool> IsDateDailyReportInRangeAsync(int idWell, DateOnly dateDailyReport, CancellationToken cancellationToken)
|
||||
{
|
||||
var datesRange = await GetDatesRangeAsync(idWell, cancellationToken);
|
||||
var datesRange = await wellOperationRepository.GetDatesRangeAsync(idWell, WellOperation.IdOperationTypeFact, cancellationToken);
|
||||
|
||||
if (datesRange is null)
|
||||
return false;
|
||||
|
||||
var from = DateOnly.FromDateTime(datesRange.From.DateTime);
|
||||
var to = DateOnly.FromDateTime(datesRange.To.DateTime);
|
||||
|
||||
|
@ -265,8 +265,8 @@ public class DetectedOperationService : IDetectedOperationService
|
||||
dto.OperationValue = operationValues.FirstOrDefault(v => v.IdOperationCategory == dto.IdCategory
|
||||
&& v.DepthStart <= dto.DepthStart
|
||||
&& v.DepthEnd > dto.DepthStart);
|
||||
|
||||
var dateStart = dto.DateStart;
|
||||
|
||||
var dateStart = dto.DateStart.ToUniversalTime();
|
||||
var timeStart = new TimeDto(dateStart);
|
||||
var driller = schedules.FirstOrDefault(s =>
|
||||
s.DrillStart <= dateStart &&
|
||||
|
@ -49,7 +49,7 @@ namespace AsbCloudInfrastructure.Services.DrillTestReport
|
||||
well.Deposit ?? "-",
|
||||
well.Cluster ?? "-",
|
||||
well.Caption ?? "-"),
|
||||
Date = DateTime.Now,
|
||||
Date = DateTimeOffset.Now,
|
||||
};
|
||||
|
||||
var fileName = string.Format("Drill_test_{0}.xlsx", dto.TimeStampStart.ToString("dd.mm.yyyy_HH_MM_ss"));
|
||||
@ -78,15 +78,15 @@ namespace AsbCloudInfrastructure.Services.DrillTestReport
|
||||
var dtos = await drillTestRepository.GetAllAsync(telemetry.Id, request, cancellationToken);
|
||||
foreach (var dto in dtos)
|
||||
{
|
||||
var remoteDateTime = dto.TimeStampStart.ToRemoteDateTime(timezone.Hours);
|
||||
var remoteDateTime = dto.TimeStampStart.ToOffset(TimeSpan.FromHours(timezone.Hours));
|
||||
|
||||
reports.Add(new DrillTestReportInfoDto
|
||||
{
|
||||
FileName = string.Format("Drill_test_{0}", dto.TimeStampStart.DateTime),
|
||||
FileName = string.Format("Drill_test_{0}", remoteDateTime),
|
||||
DrillDepth = (dto.Params
|
||||
.Where(p => p.DepthDrillStep.HasValue)
|
||||
.Sum(x => x.DepthDrillStep) ?? 0) + dto.DepthStart,
|
||||
DateTime = dto.TimeStampStart.DateTime,
|
||||
DateTime = remoteDateTime,
|
||||
Id = dto.Id,
|
||||
});
|
||||
}
|
||||
|
@ -480,7 +480,7 @@ namespace AsbCloudInfrastructure.Services.DrillingProgram
|
||||
IdWell = fileEntity.IdWell,
|
||||
Name = fileEntity.Name,
|
||||
Size = fileEntity.Size,
|
||||
UploadDate = fileEntity.UploadDate.ToRemoteDateTime(timezoneOffset),
|
||||
UploadDate = fileEntity.UploadDate.ToOffset(TimeSpan.FromHours(timezoneOffset)),
|
||||
};
|
||||
|
||||
var marks = fileEntity.FileMarks?.Where(m => !m.IsDeleted);
|
||||
@ -489,7 +489,7 @@ namespace AsbCloudInfrastructure.Services.DrillingProgram
|
||||
part.File.FileMarks = marks.Select(m =>
|
||||
{
|
||||
var mark = m.Adapt<FileMarkDto>();
|
||||
mark.DateCreated = m.DateCreated.ToRemoteDateTime(timezoneOffset);
|
||||
mark.DateCreated = m.DateCreated.ToOffset(TimeSpan.FromHours(timezoneOffset));
|
||||
return mark;
|
||||
});
|
||||
var hasReject = marks.Any(m => m.IdMarkType == idMarkTypeReject);
|
||||
|
@ -11,7 +11,7 @@ namespace AsbCloudInfrastructure.Services.DrillingProgram
|
||||
{
|
||||
private const string directionDirectorPositionName = "Руководитель направления по ТСБ";
|
||||
|
||||
private readonly DateTime totalDate;
|
||||
private readonly DateTimeOffset totalDate;
|
||||
private readonly FileMarkDto? acceptDirectionDirector;
|
||||
private readonly List<FileMarkDto> acceptsOthers;
|
||||
private readonly WellDto well;
|
||||
@ -157,7 +157,7 @@ namespace AsbCloudInfrastructure.Services.DrillingProgram
|
||||
.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Left);
|
||||
}
|
||||
|
||||
private static string FormatDate(DateTime dateTime)
|
||||
private static string FormatDate(DateTimeOffset dateTime)
|
||||
=> $"{dateTime.Day:00}.{dateTime.Month:00}.{dateTime.Year:00}";
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
return (float)result;
|
||||
}
|
||||
|
||||
private DateTime GetDate(double depth, LimitingParameterDataDto dto)
|
||||
private DateTimeOffset GetDate(double depth, LimitingParameterDataDto dto)
|
||||
{
|
||||
var a = depth - dto.DepthStart;
|
||||
var b = dto.DepthEnd - dto.DepthStart;
|
||||
|
@ -57,7 +57,7 @@ public class ManualCatalogService : IManualCatalogService
|
||||
var manual = new ManualDto
|
||||
{
|
||||
Name = name,
|
||||
DateDownload = DateTime.UtcNow,
|
||||
DateDownload = DateTimeOffset.UtcNow,
|
||||
IdDirectory = idDirectory,
|
||||
IdCategory = IdFileCategory,
|
||||
IdAuthor = idAuthor
|
||||
|
@ -87,8 +87,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
throw new ArgumentInvalidException(nameof(dto), "wrong idCategory");
|
||||
if (!dto.Data.Any())
|
||||
throw new ArgumentInvalidException(nameof(dto), "data.data is not optional");
|
||||
var timezone = wellService.GetTimezone(idWell);
|
||||
var entity = Convert(dto, timezone.Hours);
|
||||
var entity = Convert(dto);
|
||||
entity.IdWell = idWell;
|
||||
db.Measures.Add(entity);
|
||||
return db.SaveChangesAsync(token);
|
||||
@ -110,7 +109,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
|
||||
var timezone = wellService.GetTimezone(idWell);
|
||||
entity.IdWell = idWell;
|
||||
entity.Timestamp = dto.Timestamp.ToUtcDateTimeOffset(timezone.Hours);
|
||||
entity.Timestamp = dto.Timestamp.ToOffset(TimeSpan.FromHours(timezone.Hours));
|
||||
entity.Data = dto.Data.Adapt<RawData>();
|
||||
|
||||
return await db.SaveChangesAsync(token).ConfigureAwait(false);
|
||||
@ -142,13 +141,13 @@ namespace AsbCloudInfrastructure.Services
|
||||
{
|
||||
var dto = entity.Adapt<MeasureDto>();
|
||||
dto.CategoryName = entity.Category?.Name ?? String.Empty;
|
||||
dto.Timestamp = entity.Timestamp.ToRemoteDateTime(hours);
|
||||
dto.Timestamp = entity.Timestamp.ToOffset(TimeSpan.FromHours(hours));
|
||||
return dto;
|
||||
}
|
||||
private Measure Convert(MeasureDto dto, double hours)
|
||||
private Measure Convert(MeasureDto dto)
|
||||
{
|
||||
var entity = dto.Adapt<Measure>();
|
||||
entity.Timestamp = dto.Timestamp.ToUtcDateTimeOffset(hours);
|
||||
entity.Timestamp = dto.Timestamp.ToUniversalTime();
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ public class ProcessMapReportDrillingService : IProcessMapReportDrillingService
|
||||
var result = new ProcessMapReportDataSaubStatDto()
|
||||
{
|
||||
IdWellSectionType = wellSectionType.Id,
|
||||
DateStart = firstElemInInterval.DateStart.DateTime,
|
||||
DateStart = firstElemInInterval.DateStart,
|
||||
WellSectionTypeName = wellSectionType.Caption,
|
||||
DepthStart = firstElemInInterval.DepthStart,
|
||||
DepthEnd = lastElemInInterval.DepthEnd,
|
||||
|
@ -64,11 +64,11 @@ public class ReportService : IReportService
|
||||
return work.Id;
|
||||
}
|
||||
|
||||
public int GetReportPagesCount(int idWell, DateTime begin, DateTime end, int stepSeconds, int format)
|
||||
public int GetReportPagesCount(int idWell, DateTimeOffset begin, DateTimeOffset end, int stepSeconds, int format)
|
||||
{
|
||||
var timezoneOffset = wellService.GetTimezone(idWell).Hours;
|
||||
var beginRemote = begin.ToTimeZoneOffsetHours(timezoneOffset);
|
||||
var endRemote = end.ToTimeZoneOffsetHours(timezoneOffset);
|
||||
var beginRemote = begin.DateTime.ToTimeZoneOffsetHours(timezoneOffset);
|
||||
var endRemote = end.DateTime.ToTimeZoneOffsetHours(timezoneOffset);
|
||||
|
||||
var generator = GetReportGenerator(idWell, beginRemote, endRemote, stepSeconds, format, db);
|
||||
var pagesCount = generator.GetPagesCount();
|
||||
@ -87,6 +87,7 @@ public class ReportService : IReportService
|
||||
public async Task<IEnumerable<ReportPropertiesDto>> GetAllReportsByWellAsync(int idWell, CancellationToken token)
|
||||
{
|
||||
var timezoneOffset = wellService.GetTimezone(idWell).Hours;
|
||||
var timeSpan = TimeSpan.FromHours(timezoneOffset);
|
||||
var propertiesQuery = db.ReportProperties.Include(r => r.File)
|
||||
.Where(p => p.IdWell == idWell)
|
||||
.OrderBy(o => o.File.UploadDate)
|
||||
@ -106,12 +107,12 @@ public class ReportService : IReportService
|
||||
IdWell = p.File.IdWell,
|
||||
Name = p.File.Name,
|
||||
Size = p.File.Size,
|
||||
UploadDate = p.File.UploadDate.ToRemoteDateTime(timezoneOffset),
|
||||
UploadDate = p.File.UploadDate.ToOffset(timeSpan),
|
||||
},
|
||||
IdWell = p.IdWell,
|
||||
Date = p.File.UploadDate.ToRemoteDateTime(timezoneOffset),
|
||||
Begin = p.Begin.ToRemoteDateTime(timezoneOffset),
|
||||
End = p.End.ToRemoteDateTime(timezoneOffset),
|
||||
Date = p.File.UploadDate.ToOffset(timeSpan),
|
||||
Begin = p.Begin.ToOffset(timeSpan),
|
||||
End = p.End.ToOffset(timeSpan),
|
||||
Step = p.Step,
|
||||
Format = p.Format == 0 ? ".pdf" : ".las"
|
||||
});
|
||||
@ -127,10 +128,10 @@ public class ReportService : IReportService
|
||||
CancellationToken token)
|
||||
{
|
||||
var timezoneOffset = wellService.GetTimezone(idWell).Hours;
|
||||
var beginRemote = request.Begin.ToTimeZoneOffsetHours(timezoneOffset);
|
||||
var endRemote = request.End.ToTimeZoneOffsetHours(timezoneOffset);
|
||||
var beginUtc = request.Begin.ToUtcDateTimeOffset(timezoneOffset);
|
||||
var endUtc = request.End.ToUtcDateTimeOffset(timezoneOffset);
|
||||
var beginRemote = request.Begin.DateTime;
|
||||
var endRemote = request.End.DateTime;
|
||||
var beginUtc = request.Begin.ToUniversalTime();
|
||||
var endUtc = request.End.ToUniversalTime();
|
||||
|
||||
var tempDir = Path.Combine(Path.GetTempPath(), "report");
|
||||
|
||||
|
@ -72,13 +72,13 @@ namespace AsbCloudInfrastructure.Services.SAUB
|
||||
|
||||
if (request.Begin is not null)
|
||||
{
|
||||
var beginUtc = request.Begin.Value.ToUtcDateTimeOffset(timezone.Hours);
|
||||
var beginUtc = request.Begin.Value.ToUniversalTime();
|
||||
query = query.Where(m => m.DateTime >= beginUtc);
|
||||
}
|
||||
|
||||
if (request.End is not null)
|
||||
{
|
||||
var endUtc = request.End.Value.ToUtcDateTimeOffset(timezone.Hours);
|
||||
var endUtc = request.End.Value.ToUniversalTime();
|
||||
query = query.Where(m => m.DateTime <= endUtc);
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ namespace AsbCloudInfrastructure.Services.SAUB
|
||||
WellDepth = message.WellDepth
|
||||
};
|
||||
|
||||
messageDto.DateTime = message.DateTime.ToRemoteDateTime(timezone.Hours);
|
||||
messageDto.DateTime = message.DateTime.ToOffset(TimeSpan.FromHours(timezone.Hours));
|
||||
|
||||
if (message.IdTelemetryUser is not null)
|
||||
{
|
||||
@ -150,7 +150,7 @@ namespace AsbCloudInfrastructure.Services.SAUB
|
||||
var entity = dto.Adapt<TelemetryMessage>();
|
||||
entity.Id = 0;
|
||||
entity.IdTelemetry = telemetry.Id;
|
||||
entity.DateTime = dto.Date.ToUtcDateTimeOffset(timezone.Hours);
|
||||
entity.DateTime = dto.Date.ToOffset(TimeSpan.FromHours(timezone.Hours));
|
||||
db.TelemetryMessages.Add(entity);
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,6 @@ namespace AsbCloudInfrastructure.Services.SAUB
|
||||
foreach (var item in filtered)
|
||||
{
|
||||
item.IdState = 2;
|
||||
item.UploadDate = DateTime.SpecifyKind(item.UploadDate, DateTimeKind.Utc);
|
||||
}
|
||||
|
||||
await setpointsRepository.UpdateRangeAsync(filtered, token);
|
||||
|
@ -102,7 +102,7 @@ namespace AsbCloudInfrastructure.Services.SAUB
|
||||
if (dateBegin == default)
|
||||
{
|
||||
var dateRange = telemetryDataCache.GetOrDefaultDataDateRange(telemetry.Id);
|
||||
dateBeginUtc = (dateRange?.To.UtcDateTime ?? DateTime.UtcNow)
|
||||
dateBeginUtc = (dateRange?.To ?? DateTimeOffset.UtcNow)
|
||||
.AddSeconds(-intervalSec);
|
||||
}
|
||||
else
|
||||
|
@ -156,7 +156,9 @@ namespace AsbCloudInfrastructure.Services.SAUB
|
||||
var to = cacheItem.LastData[^1].DateTime;
|
||||
from = from ?? cacheItem.LastData[0].DateTime;
|
||||
|
||||
return new DatesRangeDto { From = from.Value, To = to };
|
||||
return new DatesRangeDto {
|
||||
From = from.Value.ToUtcDateTimeOffset(cacheItem.TimezoneHours),
|
||||
To = to.ToUtcDateTimeOffset(cacheItem.TimezoneHours) };
|
||||
}
|
||||
|
||||
public DatesRangeDto? GetOrDefaultCachedDateRange(int idTelemetry)
|
||||
|
@ -146,6 +146,8 @@ public class OperationsStatService : IOperationsStatService
|
||||
|
||||
private async Task<StatWellDto> CalcWellStatAsync(Well well, CancellationToken token)
|
||||
{
|
||||
var timezone = wellService.GetTimezone(well.Id);
|
||||
|
||||
var wellType = (await memoryCache
|
||||
.GetOrCreateBasicAsync(db.Set<WellType>(), token))
|
||||
.FirstOrDefault(t => t.Id == well.IdWellType);
|
||||
@ -170,9 +172,8 @@ public class OperationsStatService : IOperationsStatService
|
||||
if (!wellOperations.Any())
|
||||
return statWellDto;
|
||||
|
||||
var timezoneOffsetH = wellService.GetTimezone(well.Id).Hours;
|
||||
statWellDto.Sections = CalcSectionsStats(wellOperations, timezoneOffsetH);
|
||||
statWellDto.Total = GetStatTotal(wellOperations, well.IdState, timezoneOffsetH);
|
||||
statWellDto.Sections = CalcSectionsStats(wellOperations, timezone.Hours);
|
||||
statWellDto.Total = GetStatTotal(wellOperations, well.IdState, timezone.Hours);
|
||||
statWellDto.TvdLagDays = CalcTvdLagDays(wellOperations);
|
||||
statWellDto.TvdDrillingDays = CalcDrillingDays(wellOperations);
|
||||
|
||||
@ -288,8 +289,8 @@ public class OperationsStatService : IOperationsStatService
|
||||
|
||||
var section = new StatOperationsDto
|
||||
{
|
||||
Start = operations.FirstOrDefault()?.DateStart.ToRemoteDateTime(timezoneOffsetHours),
|
||||
End = operations.Max(o => o.DateStart.ToRemoteDateTime(timezoneOffsetHours).AddHours(o.DurationHours)),
|
||||
Start = operations.FirstOrDefault()?.DateStart.ToOffset(TimeSpan.FromHours(timezoneOffsetHours)),
|
||||
End = operations.Max(o => o.DateStart.ToOffset(TimeSpan.FromHours(timezoneOffsetHours)).AddHours(o.DurationHours)),
|
||||
WellDepthStart = operations.Min(o => o.DepthStart),
|
||||
WellDepthEnd = operations.Max(o => o.DepthStart),
|
||||
Rop = CalcROP(operations),
|
||||
|
@ -63,12 +63,12 @@ namespace AsbCloudInfrastructure.Services
|
||||
private void DropCacheRelationCompanyWell()
|
||||
=> memoryCache.DropBasic<RelationCompanyWell>();
|
||||
|
||||
public DateTime GetLastTelemetryDate(int idWell)
|
||||
public DateTimeOffset GetLastTelemetryDate(int idWell)
|
||||
{
|
||||
var well = GetOrDefault(idWell);
|
||||
|
||||
if (well?.IdTelemetry is null)
|
||||
return DateTime.MinValue;
|
||||
return DateTimeOffset.MinValue;
|
||||
|
||||
var datesRange = telemetryService.GetDatesRange(well.IdTelemetry.Value);
|
||||
return datesRange.To.DateTime;
|
||||
@ -279,7 +279,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
dto.Cluster = entity.Cluster.Caption;
|
||||
dto.Deposit = entity.Cluster.Deposit.Caption;
|
||||
if (entity.IdTelemetry is not null)
|
||||
dto.LastTelemetryDate = telemetryService.GetDatesRange(entity.IdTelemetry.Value).To.DateTime;
|
||||
dto.LastTelemetryDate = telemetryService.GetDatesRange(entity.IdTelemetry.Value).To.ToOffset(dto.Timezone.Offset);
|
||||
dto.Companies = entity.RelationCompaniesWells
|
||||
.Select(r => Convert(r.Company))
|
||||
.ToList();
|
||||
@ -297,47 +297,10 @@ namespace AsbCloudInfrastructure.Services
|
||||
|
||||
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.");
|
||||
return GetTimezone(well);
|
||||
}
|
||||
|
||||
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}");
|
||||
return cacheItem.Timezone.Adapt<SimpleTimezoneDto>();
|
||||
}
|
||||
|
||||
private bool IsTelemetryAssignedToDifferentWell(WellDto wellDto)
|
||||
@ -350,7 +313,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
|
||||
if (existingWellWithAssignedTelemetry is null)
|
||||
return false;
|
||||
|
||||
|
||||
return existingWellWithAssignedTelemetry.Id != wellDto.Id;
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@ using AsbCloudApp.Repositories;
|
||||
using AsbCloudApp.Requests;
|
||||
using AsbCloudApp.Services;
|
||||
using AsbCloudApp.Services.ProcessMaps.WellDrilling;
|
||||
using AsbCloudDb.Model;
|
||||
using AsbCloudInfrastructure.Services.DailyReport;
|
||||
using NSubstitute;
|
||||
using System;
|
||||
@ -114,7 +115,7 @@ public class DailyReportServiceTest
|
||||
private readonly ProcessMapReportDataSaubStatDto fakeProcessMapReportWellDrilling = new()
|
||||
{
|
||||
DrillingMode = "Ротор",
|
||||
DateStart = new DateTime(2023, 10, 26),
|
||||
DateStart = new DateTimeOffset(2023, 10, 26, 0, 0, 0, TimeSpan.Zero),
|
||||
DeltaDepth = 500,
|
||||
Rop = new PlanFactDto<double?>
|
||||
{
|
||||
@ -179,8 +180,8 @@ public class DailyReportServiceTest
|
||||
IdWell = idWell,
|
||||
ShiftStart = new TimeDto(1),
|
||||
ShiftEnd = new TimeDto(5),
|
||||
DrillStart = new DateTime(2023, 01, 26),
|
||||
DrillEnd = new DateTime(2023, 12, 26),
|
||||
DrillStart = new DateTimeOffset(2023, 01, 26, 0, 0, 0, TimeSpan.Zero),
|
||||
DrillEnd = new DateTimeOffset(2023, 12, 26, 0, 0, 0, TimeSpan.Zero),
|
||||
Driller = new()
|
||||
{
|
||||
Name = "Иван",
|
||||
@ -283,7 +284,7 @@ public class DailyReportServiceTest
|
||||
subsystemServiceMock.GetStatAsync(Arg.Any<SubsystemRequest>(), Arg.Any<CancellationToken>())
|
||||
.ReturnsForAnyArgs(new[] { fakeSubsystemsStat });
|
||||
|
||||
scheduleRepositoryMock.GetAsync(Arg.Any<int>(), Arg.Any<DateTime>(), Arg.Any<CancellationToken>())
|
||||
scheduleRepositoryMock.GetAsync(Arg.Any<int>(), Arg.Any<DateTimeOffset>(), Arg.Any<CancellationToken>())
|
||||
.ReturnsForAnyArgs(new[] { fakeShedule });
|
||||
|
||||
processMapReportWellDrillingServiceMock.GetAsync(Arg.Any<int>(), fakeRequest, Arg.Any<CancellationToken>())
|
||||
@ -524,12 +525,12 @@ public class DailyReportServiceTest
|
||||
.Returns(datesRange);
|
||||
|
||||
//act
|
||||
var result = await dailyReportService.GetDatesRangeAsync(idWell, CancellationToken.None);
|
||||
var result = await wellOperationRepositoryMock.GetDatesRangeAsync(idWell, WellOperation.IdOperationTypeFact, CancellationToken.None);
|
||||
|
||||
//assert
|
||||
Assert.NotNull(result);
|
||||
Assert.True(result.From <= result.To);
|
||||
Assert.True(result.To < DateTime.UtcNow.Date);
|
||||
Assert.True(result.To < DateTimeOffset.UtcNow);
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> DateDailyReport()
|
||||
|
@ -39,7 +39,7 @@ public class FileServiceTest
|
||||
IdCategory = idCategory,
|
||||
Name = fileName,
|
||||
Size = 0,
|
||||
UploadDate = DateTime.Now
|
||||
UploadDate = DateTimeOffset.Now
|
||||
};
|
||||
|
||||
private static FileMarkDto fileMark = new()
|
||||
|
@ -26,7 +26,7 @@ namespace AsbCloudWebApi.Tests.Services.Notification
|
||||
IdUser = 1,
|
||||
IdTransportType = 1,
|
||||
IdState = 0,
|
||||
RegistrationDate = DateTime.Now,
|
||||
RegistrationDate = DateTimeOffset.Now,
|
||||
IdNotificationCategory = 10000,
|
||||
};
|
||||
private readonly UserExtendedDto user = new UserExtendedDto()
|
||||
|
@ -34,7 +34,7 @@ namespace AsbCloudWebApi.Tests.Services.Trajectory
|
||||
IdUser = 1,
|
||||
IdWell = 4,
|
||||
Radius = 3,
|
||||
UpdateDate = DateTime.Now,
|
||||
UpdateDate = DateTimeOffset.Now,
|
||||
VerticalDepth = 100,
|
||||
WellboreDepth = 100,
|
||||
ZenithAngle = 10
|
||||
@ -47,7 +47,7 @@ namespace AsbCloudWebApi.Tests.Services.Trajectory
|
||||
IdUser = 1,
|
||||
IdWell = 4,
|
||||
Radius = 3,
|
||||
UpdateDate = DateTime.Now,
|
||||
UpdateDate = DateTimeOffset.Now,
|
||||
VerticalDepth = 100,
|
||||
WellboreDepth = 100,
|
||||
ZenithAngle = 10
|
||||
@ -62,7 +62,7 @@ namespace AsbCloudWebApi.Tests.Services.Trajectory
|
||||
Comment = "комментарий",
|
||||
IdUser = 1,
|
||||
IdWell = 4,
|
||||
UpdateDate = DateTime.Now,
|
||||
UpdateDate = DateTimeOffset.Now,
|
||||
VerticalDepth = 100,
|
||||
WellboreDepth = 100,
|
||||
ZenithAngle = 10
|
||||
@ -74,7 +74,7 @@ namespace AsbCloudWebApi.Tests.Services.Trajectory
|
||||
Comment = "комментарий",
|
||||
IdUser = 1,
|
||||
IdWell = 4,
|
||||
UpdateDate = DateTime.Now,
|
||||
UpdateDate = DateTimeOffset.Now,
|
||||
VerticalDepth = 100,
|
||||
WellboreDepth = 100,
|
||||
ZenithAngle = 10
|
||||
|
@ -21,7 +21,7 @@ public class WellboreServiceTest
|
||||
Id = 1,
|
||||
IdState = 1,
|
||||
IdTelemetry = 1,
|
||||
LastTelemetryDate = DateTime.Now,
|
||||
LastTelemetryDate = DateTimeOffset.Now,
|
||||
Caption = "well 1"
|
||||
};
|
||||
|
||||
@ -30,7 +30,7 @@ public class WellboreServiceTest
|
||||
Id = 2,
|
||||
IdState = 1,
|
||||
IdTelemetry = 100,
|
||||
LastTelemetryDate = DateTime.Now,
|
||||
LastTelemetryDate = DateTimeOffset.Now,
|
||||
Caption = "well 2"
|
||||
};
|
||||
|
||||
|
@ -13,6 +13,7 @@ using AsbCloudApp.Repositories;
|
||||
using AsbCloudApp.Requests;
|
||||
using AsbCloudApp.Services;
|
||||
using AsbCloudApp.Services.DailyReport;
|
||||
using AsbCloudDb.Model;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@ -156,7 +157,7 @@ public class DailyReportController : ControllerBase
|
||||
{
|
||||
await AssertUserAccessToWell(idWell, cancellationToken);
|
||||
|
||||
var datesRanges = await dailyReportService.GetDatesRangeAsync(idWell, cancellationToken);
|
||||
var datesRanges = await wellOperationRepository.GetDatesRangeAsync(idWell, WellOperation.IdOperationTypeFact, cancellationToken);
|
||||
|
||||
return Ok(datesRanges);
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
/// <param name="token"></param>
|
||||
/// <returns>бурильщик</returns>
|
||||
[HttpGet("driller")]
|
||||
public async Task<ActionResult<DrillerDto?>> GetDrillerAsync(int idWell, DateTime workTime, CancellationToken token)
|
||||
public async Task<ActionResult<DrillerDto?>> GetDrillerAsync(int idWell, DateTimeOffset workTime, CancellationToken token)
|
||||
{
|
||||
if (!await UserHasAccesToWellAsync(idWell, token))
|
||||
return Forbid();
|
||||
|
@ -35,7 +35,7 @@ public class NotificationPublisher
|
||||
{
|
||||
foreach (var notification in groupedNotifications)
|
||||
{
|
||||
notification.SentDate = DateTime.UtcNow;
|
||||
notification.SentDate = DateTimeOffset.UtcNow;
|
||||
}
|
||||
|
||||
var notifications = groupedNotifications.Select(n => n);
|
||||
|
Loading…
Reference in New Issue
Block a user