Правки после ревью

This commit is contained in:
Степанов Дмитрий 2024-03-26 11:35:36 +03:00
parent e9386b5897
commit 945cd10baa
9 changed files with 101 additions and 9536 deletions

View File

@ -76,14 +76,6 @@ namespace AsbCloudApp.Repositories
/// <returns></returns>
Task<IEnumerable<SectionByOperationsDto>> GetSectionsAsync(IEnumerable<int> idsWells, CancellationToken token);
/// <summary>
/// Получить диапазон дат выполнения операций
/// </summary>
/// <param name="idWell"></param>
/// <param name="idType"></param>
/// <returns></returns>
DatesRangeDto? GetDatesRange(int idWell, int idType);
/// <summary>
/// Получить диапазон дат выполнения операций
/// </summary>

File diff suppressed because it is too large Load Diff

View File

@ -1,37 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace AsbCloudDb.Migrations
{
/// <inheritdoc />
public partial class Update_ItemInfo : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<DateTimeOffset>(
name: "LastUpdateDate",
table: "t_well_operation",
type: "timestamp with time zone",
nullable: true,
oldClrType: typeof(DateTimeOffset),
oldType: "timestamp with time zone");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<DateTimeOffset>(
name: "LastUpdateDate",
table: "t_well_operation",
type: "timestamp with time zone",
nullable: false,
defaultValue: new DateTimeOffset(new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)),
oldClrType: typeof(DateTimeOffset),
oldType: "timestamp with time zone",
oldNullable: true);
}
}
}

View File

@ -482,7 +482,7 @@ namespace AsbCloudDb.Migrations
b.HasKey("Id");
b.ToTable("t_deposit", t =>
b.ToTable("t_deposit", null, t =>
{
t.HasComment("Месторождение");
});
@ -553,7 +553,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdTelemetry");
b.ToTable("t_detected_operation", t =>
b.ToTable("t_detected_operation", null, t =>
{
t.HasComment("автоматически определенные операции по телеметрии");
});
@ -591,7 +591,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdTelemetry");
b.ToTable("t_drill_test", t =>
b.ToTable("t_drill_test", null, t =>
{
t.HasComment("Drill_test");
});
@ -629,7 +629,7 @@ namespace AsbCloudDb.Migrations
b.HasKey("Id");
b.ToTable("t_driller", t =>
b.ToTable("t_driller", null, t =>
{
t.HasComment("Бурильщик");
});
@ -659,7 +659,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWell", "IdFileCategory")
.IsUnique();
b.ToTable("t_drilling_program_part", t =>
b.ToTable("t_drilling_program_part", null, t =>
{
t.HasComment("части программ бурения");
});
@ -737,7 +737,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdAuthorQuestion");
b.ToTable("t_faq", t =>
b.ToTable("t_faq", null, t =>
{
t.HasComment("вопросы пользователей");
});
@ -765,7 +765,7 @@ namespace AsbCloudDb.Migrations
b.HasKey("Id");
b.ToTable("t_file_category", t =>
b.ToTable("t_file_category", null, t =>
{
t.HasComment("Категории файлов");
});
@ -1166,7 +1166,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWell");
b.ToTable("t_file_info", t =>
b.ToTable("t_file_info", null, t =>
{
t.HasComment("Файлы всех категорий");
});
@ -1218,7 +1218,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdUser");
b.ToTable("t_file_mark", t =>
b.ToTable("t_file_mark", null, t =>
{
t.HasComment("Действия с файлами.");
});
@ -1248,7 +1248,7 @@ namespace AsbCloudDb.Migrations
b.HasKey("IdTelemetry", "IdRecord", "IdItem", "DateTime");
b.ToTable("t_wits_float", t =>
b.ToTable("t_wits_float", null, t =>
{
t.HasComment("таблица данных ГТИ с типом значения float");
});
@ -1278,7 +1278,7 @@ namespace AsbCloudDb.Migrations
b.HasKey("IdTelemetry", "IdRecord", "IdItem", "DateTime");
b.ToTable("t_wits_int", t =>
b.ToTable("t_wits_int", null, t =>
{
t.HasComment("таблица данных ГТИ с типом значения int");
});
@ -1309,7 +1309,7 @@ namespace AsbCloudDb.Migrations
b.HasKey("IdTelemetry", "IdRecord", "IdItem", "DateTime");
b.ToTable("t_wits_string", t =>
b.ToTable("t_wits_string", null, t =>
{
t.HasComment("таблица данных ГТИ с типом значения string");
});
@ -1350,7 +1350,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdCategory");
b.ToTable("t_help_page", t =>
b.ToTable("t_help_page", null, t =>
{
t.HasComment("Справки");
});
@ -1393,7 +1393,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdTelemetry");
b.ToTable("t_limiting_parameter", t =>
b.ToTable("t_limiting_parameter", null, t =>
{
t.HasComment("Ограничения по параметрам телеметрии");
});
@ -1442,7 +1442,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdDirectory");
b.ToTable("t_manual", t =>
b.ToTable("t_manual", null, t =>
{
t.HasComment("Инструкции");
});
@ -1472,7 +1472,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdParent");
b.ToTable("t_manual_directory", t =>
b.ToTable("t_manual_directory", null, t =>
{
t.HasComment("Директория для инструкций");
});
@ -1519,7 +1519,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWell");
b.ToTable("t_measure", t =>
b.ToTable("t_measure", null, t =>
{
t.HasComment("Таблица c данными для вкладки 'Последние данные'");
});
@ -1547,7 +1547,7 @@ namespace AsbCloudDb.Migrations
b.HasKey("Id");
b.ToTable("t_measure_category", t =>
b.ToTable("t_measure_category", null, t =>
{
t.HasComment("Категория последних данных");
});
@ -1630,7 +1630,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdUser");
b.ToTable("t_notification", t =>
b.ToTable("t_notification", null, t =>
{
t.HasComment("Уведомления");
});
@ -1652,7 +1652,7 @@ namespace AsbCloudDb.Migrations
b.HasKey("Id");
b.ToTable("t_notification_category", t =>
b.ToTable("t_notification_category", null, t =>
{
t.HasComment("Категории уведомлений");
});
@ -1711,7 +1711,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWell");
b.ToTable("t_operationvalue", t =>
b.ToTable("t_operationvalue", null, t =>
{
t.HasComment("Целевые/нормативные показатели операции");
});
@ -1741,7 +1741,7 @@ namespace AsbCloudDb.Migrations
b.HasKey("Id");
b.ToTable("t_permission", t =>
b.ToTable("t_permission", null, t =>
{
t.HasComment("Разрешения на доступ к данным");
});
@ -2768,7 +2768,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWellSectionType");
b.ToTable("t_process_map_plan_drilling", t =>
b.ToTable("t_process_map_plan_drilling", null, t =>
{
t.HasComment("РТК план бурение");
});
@ -2889,7 +2889,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWellSectionType");
b.ToTable("t_process_map_plan_ream", t =>
b.ToTable("t_process_map_plan_ream", null, t =>
{
t.HasComment("РТК проработка скважины");
});
@ -2909,7 +2909,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWell");
b.ToTable("t_relation_company_well", t =>
b.ToTable("t_relation_company_well", null, t =>
{
t.HasComment("отношение скважин и компаний");
});
@ -2929,7 +2929,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdUser");
b.ToTable("t_relation_contact_well");
b.ToTable("t_relation_contact_well", (string)null);
});
modelBuilder.Entity("AsbCloudDb.Model.RelationUserDrillingProgramPart", b =>
@ -2952,7 +2952,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdDrillingProgramPart");
b.ToTable("t_relation_user_drilling_program_part", t =>
b.ToTable("t_relation_user_drilling_program_part", null, t =>
{
t.HasComment("Отношение пользователей и частей ПБ");
});
@ -2972,7 +2972,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdPermission");
b.ToTable("t_relation_user_role_permission", t =>
b.ToTable("t_relation_user_role_permission", null, t =>
{
t.HasComment("Отношение ролей пользователей и разрешений доступа");
});
@ -4290,7 +4290,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdInclude");
b.ToTable("t_relation_user_role_user_role", t =>
b.ToTable("t_relation_user_role_user_role", null, t =>
{
t.HasComment("Отношение ролей к ролям");
});
@ -4582,7 +4582,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdUserRole");
b.ToTable("t_relation_user_user_role", t =>
b.ToTable("t_relation_user_user_role", null, t =>
{
t.HasComment("Отношение пользователей и ролей");
});
@ -4639,7 +4639,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWell");
b.ToTable("t_report_property", t =>
b.ToTable("t_report_property", null, t =>
{
t.HasComment("Отчеты с данными по буровым");
});
@ -4691,7 +4691,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWell");
b.ToTable("t_schedule", t =>
b.ToTable("t_schedule", null, t =>
{
t.HasComment("График работы бурильщика");
});
@ -4747,7 +4747,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWell");
b.ToTable("t_setpoints_rquest", t =>
b.ToTable("t_setpoints_rquest", null, t =>
{
t.HasComment("Запросы на изменение уставок панели оператора");
});
@ -4775,7 +4775,7 @@ namespace AsbCloudDb.Migrations
b.HasKey("Id");
b.ToTable("t_subsystem", t =>
b.ToTable("t_subsystem", null, t =>
{
t.HasComment("Описание подсистем");
});
@ -4844,7 +4844,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex(new[] { "RemoteUid" }, "t_telemetry_remote_uid_index");
b.ToTable("t_telemetry", t =>
b.ToTable("t_telemetry", null, t =>
{
t.HasComment("таблица привязки телеметрии от комплектов к конкретной скважине.");
});
@ -5063,7 +5063,7 @@ namespace AsbCloudDb.Migrations
b.HasKey("IdTelemetry", "DateTime");
b.ToTable("t_telemetry_data_saub", t =>
b.ToTable("t_telemetry_data_saub", null, t =>
{
t.HasComment("набор основных данных по SAUB");
});
@ -5163,7 +5163,7 @@ namespace AsbCloudDb.Migrations
b.HasKey("IdTelemetry", "DateTime");
b.ToTable("t_telemetry_data_spin", t =>
b.ToTable("t_telemetry_data_spin", null, t =>
{
t.HasComment("набор основных данных по SpinMaster");
});
@ -5190,7 +5190,7 @@ namespace AsbCloudDb.Migrations
b.HasKey("IdTelemetry", "IdEvent");
b.ToTable("t_telemetry_event", t =>
b.ToTable("t_telemetry_event", null, t =>
{
t.HasComment("Справочник событий. События формируют сообщения. Разделено по версиям посылок от телеметрии.");
});
@ -5251,7 +5251,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdTelemetry");
b.ToTable("t_telemetry_message", t =>
b.ToTable("t_telemetry_message", null, t =>
{
t.HasComment("Сообщения на буровых");
});
@ -5289,7 +5289,7 @@ namespace AsbCloudDb.Migrations
b.HasKey("IdTelemetry", "IdUser");
b.ToTable("t_telemetry_user", t =>
b.ToTable("t_telemetry_user", null, t =>
{
t.HasComment("Пользователи панели САУБ. Для сообщений.");
});
@ -5332,7 +5332,7 @@ namespace AsbCloudDb.Migrations
b.HasKey("IdTelemetry");
b.ToTable("t_telemetry_wireline_run_out", t =>
b.ToTable("t_telemetry_wireline_run_out", null, t =>
{
t.HasComment("Наработка талевого каната");
});
@ -5398,7 +5398,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWell");
b.ToTable("t_trajectory_fact", t =>
b.ToTable("t_trajectory_fact", null, t =>
{
t.HasComment("Загрузка фактической траектории");
});
@ -5469,7 +5469,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWell");
b.ToTable("t_trajectory_plan", t =>
b.ToTable("t_trajectory_plan", null, t =>
{
t.HasComment("Загрузка плановой траектории");
});
@ -5550,7 +5550,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("Login")
.IsUnique();
b.ToTable("t_user", t =>
b.ToTable("t_user", null, t =>
{
t.HasComment("Пользователи облака");
});
@ -5591,7 +5591,7 @@ namespace AsbCloudDb.Migrations
b.HasKey("Id");
b.ToTable("t_user_role", t =>
b.ToTable("t_user_role", null, t =>
{
t.HasComment("Роли пользователей в системе");
});
@ -5930,7 +5930,7 @@ namespace AsbCloudDb.Migrations
b.HasKey("IdUser", "Key");
b.ToTable("t_user_settings", t =>
b.ToTable("t_user_settings", null, t =>
{
t.HasComment("настройки интерфейса пользователя");
});
@ -5976,9 +5976,7 @@ namespace AsbCloudDb.Migrations
b.HasKey("IdTelemetry", "DateTime");
b.ToTable("t_telemetry_wits_base");
b.UseTptMappingStrategy();
b.ToTable("t_telemetry_wits_base", (string)null);
});
modelBuilder.Entity("AsbCloudDb.Model.Well", b =>
@ -6036,7 +6034,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWellType");
b.ToTable("t_well", t =>
b.ToTable("t_well", null, t =>
{
t.HasComment("скважины");
});
@ -6065,7 +6063,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWellSrc");
b.ToTable("t_well_composite", t =>
b.ToTable("t_well_composite", null, t =>
{
t.HasComment("Композитная скважина");
});
@ -6092,7 +6090,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdUser");
b.ToTable("t_well_final_documents", t =>
b.ToTable("t_well_final_documents", null, t =>
{
t.HasComment("Дело скважины");
});
@ -6165,7 +6163,7 @@ namespace AsbCloudDb.Migrations
.HasColumnName("id_well_section_type")
.HasComment("Id тип секции скважины");
b.Property<DateTimeOffset?>("LastUpdateDate")
b.Property<DateTimeOffset>("LastUpdateDate")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
@ -6182,7 +6180,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWellSectionType");
b.ToTable("t_well_operation", t =>
b.ToTable("t_well_operation", null, t =>
{
t.HasComment("Данные по операциям на скважине");
});
@ -6224,7 +6222,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdParent");
b.ToTable("t_well_operation_category", t =>
b.ToTable("t_well_operation_category", null, t =>
{
t.HasComment("Справочник операций на скважине");
});
@ -7337,7 +7335,7 @@ namespace AsbCloudDb.Migrations
b.HasKey("Id");
b.ToTable("t_well_section_type", t =>
b.ToTable("t_well_section_type", null, t =>
{
t.HasComment("конструкция секции скважины");
});
@ -7629,7 +7627,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWell", "IdSectionType")
.IsUnique();
b.ToTable("t_well_section_plan");
b.ToTable("t_well_section_plan", (string)null);
});
modelBuilder.Entity("AsbCloudDb.Model.WellType", b =>
@ -7650,7 +7648,7 @@ namespace AsbCloudDb.Migrations
b.HasKey("Id");
b.ToTable("t_well_type", t =>
b.ToTable("t_well_type", null, t =>
{
t.HasComment("конструкция скважины");
});
@ -7829,7 +7827,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("TelemetryId");
b.ToTable("t_telemetry_wits_1");
b.ToTable("t_telemetry_wits_1", (string)null);
});
modelBuilder.Entity("AsbCloudDb.Model.WITS.Record50", b =>
@ -7917,7 +7915,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("TelemetryId");
b.ToTable("t_telemetry_wits_50");
b.ToTable("t_telemetry_wits_50", (string)null);
});
modelBuilder.Entity("AsbCloudDb.Model.WITS.Record60", b =>
@ -7969,7 +7967,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("TelemetryId");
b.ToTable("t_telemetry_wits_60");
b.ToTable("t_telemetry_wits_60", (string)null);
});
modelBuilder.Entity("AsbCloudDb.Model.WITS.Record61", b =>
@ -8025,7 +8023,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("TelemetryId");
b.ToTable("t_telemetry_wits_61");
b.ToTable("t_telemetry_wits_61", (string)null);
});
modelBuilder.Entity("AsbCloudDb.Model.WITS.Record7", b =>
@ -8113,7 +8111,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("TelemetryId");
b.ToTable("t_telemetry_wits_7");
b.ToTable("t_telemetry_wits_7", (string)null);
});
modelBuilder.Entity("AsbCloudDb.Model.WITS.Record8", b =>
@ -8317,7 +8315,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("TelemetryId");
b.ToTable("t_telemetry_wits_8");
b.ToTable("t_telemetry_wits_8", (string)null);
});
modelBuilder.Entity("AsbCloudDb.Model.Cluster", b =>

View File

@ -12,6 +12,6 @@ namespace AsbCloudDb.Model
/// <summary>
/// дата последнего обновления блока
/// </summary>
public DateTimeOffset? LastUpdateDate { get; set; }
public DateTimeOffset LastUpdateDate { get; set; } = DateTimeOffset.UtcNow;
}
}

View File

@ -76,9 +76,4 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Remove="Services\ProcessMapPlan\Parser\ProcessMapPlanExcelReamParser.cs" />
<Compile Remove="Services\ProcessMapPlan\Parser\ProcessMapPlanExcelParser.cs" />
<Compile Remove="Services\ProcessMapPlan\Parser\ProcessMapPlanExcelDrillingParser.cs" />
</ItemGroup>
</Project>

View File

@ -7,6 +7,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore.ChangeTracking;
namespace AsbCloudInfrastructure.Repository
{
@ -86,7 +87,7 @@ namespace AsbCloudInfrastructure.Repository
entity.Id = 0;
return entity;
});
var entries = new List<Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry>(items.Count());
var entries = new List<EntityEntry>(items.Count());
foreach (var entity in entities)
{
var entry = dbSet.Add(entity);
@ -130,9 +131,10 @@ namespace AsbCloudInfrastructure.Repository
return ICrudRepository<TDto>.ErrorIdNotFound;
var entities = dtos.Select(Convert);
dbContext.Set<TEntity>().UpdateRange(entities);
return await dbContext.SaveChangesAsync(token);
var entries = entities.Select(entity => dbSet.Update(entity)).Cast<EntityEntry>().ToList();
var affected = await dbContext.SaveChangesAsync(token);
entries.ForEach(e => e.State = EntityState.Detached);
return affected;
}
/// <inheritdoc/>
@ -151,10 +153,21 @@ namespace AsbCloudInfrastructure.Repository
public virtual async Task<int> DeleteRangeAsync(IEnumerable<int> ids, CancellationToken token)
{
var query = dbContext.Set<TEntity>().Where(e => ids.Contains(e.Id));
dbContext.Set<TEntity>().RemoveRange(query);
if (!ids.Any())
return 0;
var countExistingEntities = await dbSet
.Where(d => ids.Contains(d.Id))
.CountAsync(token);
return await dbContext.SaveChangesAsync(token);
if (ids.Count() > countExistingEntities)
return ICrudRepository<TDto>.ErrorIdNotFound;
var entities = dbContext.Set<TEntity>().Where(e => ids.Contains(e.Id));
var entries = entities.Select(entity => dbSet.Remove(entity)).Cast<EntityEntry>().ToList();
var affected = await dbContext.SaveChangesAsync(token);
entries.ForEach(e => e.State = EntityState.Detached);
return affected;
}
protected virtual TDto Convert(TEntity src) => src.Adapt<TDto>();

View File

@ -44,8 +44,15 @@ public class WellOperationRepository : CrudRepositoryBase<WellOperationDto, Well
public async Task<IEnumerable<WellOperationDto>> GetAsync(WellOperationRequest request, CancellationToken token)
{
var entities = await BuildQuery(request)
.AsNoTracking()
var query = BuildQuery(request);
if (request.Skip.HasValue)
query = query.Skip(request.Skip.Value);
if (request.Take.HasValue)
query = query.Take(request.Take.Value);
var entities = await query.AsNoTracking()
.ToArrayAsync(token);
var dtos = entities.Select(Convert);
@ -180,6 +187,7 @@ public class WellOperationRepository : CrudRepositoryBase<WellOperationDto, Well
var query = GetQuery()
.Where(e => request.IdsWell != null && request.IdsWell.Contains(e.IdWell))
.OrderBy(e => e.DateStart)
.Select(o => new WellOperation
{
Id = o.Id,
@ -314,23 +322,6 @@ public class WellOperationRepository : CrudRepositoryBase<WellOperationDto, Well
return sections;
}
public DatesRangeDto? GetDatesRange(int idWell, int idType)
{
var query = dbContext.WellOperations.Where(o => o.IdWell == idWell && o.IdType == idType);
if (!query.Any())
return null;
var minDate = query.Min(o => o.DateStart);
var maxDate = query.Max(o => o.DateStart);
return new DatesRangeDto
{
From = minDate.ToOffset(minDate.Offset),
To = maxDate.ToOffset(minDate.Offset)
};
}
public async Task<DatesRangeDto?> GetDatesRangeAsync(int idWell, int idType, CancellationToken cancellationToken)
{
var query = dbContext.WellOperations.Where(o => o.IdWell == idWell && o.IdType == idType);
@ -338,20 +329,21 @@ public class WellOperationRepository : CrudRepositoryBase<WellOperationDto, Well
if (!await query.AnyAsync(cancellationToken))
return null;
var timeZoneOffset = wellService.GetTimezone(idWell).Offset;
var minDate = await query.MinAsync(o => o.DateStart, cancellationToken);
var maxDate = await query.MaxAsync(o => o.DateStart, cancellationToken);
return new DatesRangeDto
{
From = minDate.ToOffset(minDate.Offset),
To = maxDate.ToOffset(minDate.Offset)
From = minDate.ToOffset(timeZoneOffset),
To = maxDate.ToOffset(timeZoneOffset)
};
}
protected override WellOperation Convert(WellOperationDto src)
{
var entity = src.Adapt<WellOperation>();
entity.LastUpdateDate = src.LastUpdateDate?.UtcDateTime;
entity.DateStart = src.DateStart.UtcDateTime;
return entity;
}
@ -363,7 +355,7 @@ public class WellOperationRepository : CrudRepositoryBase<WellOperationDto, Well
var timeZoneOffset = wellService.GetTimezone(src.IdWell).Offset;
var dto = src.Adapt<WellOperationDto>();
dto.DateStart = src.DateStart.ToOffset(timeZoneOffset);
dto.LastUpdateDate = src.LastUpdateDate?.ToOffset(timeZoneOffset);
dto.LastUpdateDate = src.LastUpdateDate.ToOffset(timeZoneOffset);
return dto;
}
}

View File

@ -272,8 +272,9 @@ namespace AsbCloudInfrastructure.Services
if (entity.Timezone is null)
dto.Timezone = GetTimezone(entity.Id);
dto.StartDate = wellOperationRepository.GetDatesRange(entity.Id, WellOperation.IdOperationTypeFact)?.From.ToRemoteDateTime(dto.Timezone.Hours);
dto.StartDate = dbContext.WellOperations.Where(e => e.IdType == WellOperation.IdOperationTypeFact)
.MinOrDefault(e => e.DateStart)?.ToRemoteDateTime(dto.Timezone.Hours);
dto.WellType = entity.WellType.Caption;
dto.Cluster = entity.Cluster.Caption;
dto.Deposit = entity.Cluster.Deposit.Caption;