From 0521809e6e71a44d593955f8f25351f6295abd35 Mon Sep 17 00:00:00 2001 From: ngfrolov Date: Tue, 29 Mar 2022 10:36:18 +0500 Subject: [PATCH] fix timezone in tvd --- .../OperationsStatService.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/AsbCloudInfrastructure/Services/WellOperationService/OperationsStatService.cs b/AsbCloudInfrastructure/Services/WellOperationService/OperationsStatService.cs index 1a30c1d9..9a6f3ed6 100644 --- a/AsbCloudInfrastructure/Services/WellOperationService/OperationsStatService.cs +++ b/AsbCloudInfrastructure/Services/WellOperationService/OperationsStatService.cs @@ -379,6 +379,8 @@ namespace AsbCloudInfrastructure.Services.WellOperationService .Select(o => o.IdWellSectionType) .Distinct(); + var tzOffsetHours = wellService.GetTimezone(idWell).Hours; + if (!wellOperationsPlan.Any()) return null; @@ -402,8 +404,8 @@ namespace AsbCloudInfrastructure.Services.WellOperationService var planFactPredict = new PlanFactPredictBase { - Plan = plan?.Adapt(WellOperationDtoMutation), - Fact = fact?.Adapt(WellOperationDtoMutation), + Plan = Convert(plan, tzOffsetHours), + Fact = Convert(fact, tzOffsetHours), Predict = null, }; @@ -438,7 +440,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService { if (merged[i].Item1 is null) continue; - tvd[i].Predict = merged[i].Item1.Adapt(); + tvd[i].Predict = Convert(merged[i].Item1, tzOffsetHours); tvd[i].Predict.IdType = 2; tvd[i].Predict.DateStart = tvd[i].Predict.DateStart + startOffset; tvd[i].Predict.Day = (tvd[i].Predict.DateStart - dateStart).TotalDays; @@ -539,10 +541,15 @@ namespace AsbCloudInfrastructure.Services.WellOperationService return m; } - private static readonly Action WellOperationDtoMutation = (WellOperationDto dest, WellOperation source) => + private static WellOperationDto Convert(WellOperation source, double tzOffsetHours) { + if(source is null) + return null; + var dest = source.Adapt(); dest.CategoryName = source.OperationCategory?.Name; dest.WellSectionTypeName = source.WellSectionType?.Caption; - }; + dest.DateStart = source.DateStart.ToRemoteDateTime(tzOffsetHours); + return dest; + } } }