forked from ddrilling/AsbCloudServer
Фиксы
This commit is contained in:
parent
cf40bb85a1
commit
28788bde1f
@ -62,13 +62,11 @@ public interface IWellOperationRepository
|
||||
Task<DatesRangeDto?> GetDatesRangeAsync(int idWell, int idType, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Возвращает первую и последнюю операцию
|
||||
/// Возвращает первую и последнюю фактическую операцию
|
||||
/// </summary>
|
||||
/// <param name="idWell"></param>
|
||||
/// <param name="idType"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<(WellOperationBaseDto First, WellOperationBaseDto Last)?> GetFirstAndLastAsync(int idWell, int idType, CancellationToken token);
|
||||
(WellOperationBaseDto First, WellOperationBaseDto Last)? GetFirstAndLastFact(int idWell);
|
||||
|
||||
/// <summary>
|
||||
/// Получить список операций по запросу
|
||||
|
@ -195,13 +195,13 @@ public class WellOperationRepository : CrudRepositoryBase<WellOperationBaseDto,
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<(WellOperationBaseDto First, WellOperationBaseDto Last)?> GetFirstAndLastAsync(int idWell, int idType, CancellationToken token)
|
||||
public (WellOperationBaseDto First, WellOperationBaseDto Last)? GetFirstAndLastFact(int idWell)
|
||||
{
|
||||
var cachedDictionary = await memoryCache.GetOrCreateAsync(cacheKeyWellOperations, async (entry) =>
|
||||
var cachedDictionary = memoryCache.GetOrCreate(cacheKeyWellOperations, (entry) =>
|
||||
{
|
||||
entry.AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(5);
|
||||
var query = dbContext.Set<WellOperation>()
|
||||
.Where(o => o.IdType == idType)
|
||||
.Where(o => o.IdType == WellOperation.IdOperationTypeFact)
|
||||
.GroupBy(o => o.IdWell)
|
||||
.Select(group => new
|
||||
{
|
||||
@ -210,16 +210,18 @@ public class WellOperationRepository : CrudRepositoryBase<WellOperationBaseDto,
|
||||
LastFact = group.OrderBy(o => o.DateStart).Last(),
|
||||
});
|
||||
|
||||
var entities = await query.ToArrayAsync(token);
|
||||
var entities = query.ToArray();
|
||||
|
||||
var dictionary = entities.ToDictionary(s => s.IdWell, s => (Convert(s.FirstFact), Convert(s.LastFact)));
|
||||
entry.Value = dictionary;
|
||||
|
||||
return dictionary;
|
||||
|
||||
})!;
|
||||
|
||||
var firstAndLast = cachedDictionary?.GetValueOrDefault(idWell);
|
||||
var firstAndLast = cachedDictionary.GetValueOrDefault(idWell);
|
||||
return firstAndLast;
|
||||
|
||||
}
|
||||
|
||||
public override async Task<int> DeleteAsync(int id, CancellationToken token)
|
||||
|
@ -274,7 +274,7 @@ public class WellService : CrudCacheRepositoryBase<WellDto, Well>, IWellService
|
||||
dto.Timezone = GetTimezone(entity.Id);
|
||||
|
||||
dto.StartDate = wellOperationRepository
|
||||
.GetFirstAndLast(entity.Id)?.First?.DateStart;
|
||||
.GetFirstAndLastFact(entity.Id)?.First?.DateStart;
|
||||
dto.WellType = entity.WellType.Caption;
|
||||
dto.Cluster = entity.Cluster.Caption;
|
||||
dto.Deposit = entity.Cluster.Deposit.Caption;
|
||||
|
@ -15,8 +15,11 @@ public static class XLExtentions
|
||||
workbook.Worksheets.FirstOrDefault(ws => string.Equals(ws.Name.Trim(), sheetName.Trim(), StringComparison.CurrentCultureIgnoreCase))
|
||||
?? throw new FileFormatException(string.Format(NotFoundSheetTemplate, sheetName));
|
||||
|
||||
public static IXLCell SetCellValue<T>(this IXLCell cell, T value, string? format = null)
|
||||
public static IXLCell SetCellValue<T>(this IXLCell cell, T? value, string? format = null)
|
||||
{
|
||||
if (value == null)
|
||||
return cell;
|
||||
|
||||
if (value is DateTime || value is DateTimeOffset)
|
||||
{
|
||||
cell.Style.DateFormat.Format = format ?? "DD.MM.YYYY HH:MM:SS";
|
||||
|
Loading…
Reference in New Issue
Block a user