From e142e1eff57f45809aaf1aa7b44c9e057d48427e Mon Sep 17 00:00:00 2001 From: Olga Nemt Date: Fri, 31 Mar 2023 15:20:27 +0500 Subject: [PATCH 01/16] =?UTF-8?q?=D0=97=D0=B0=D0=BF=D0=B8=D1=81=D1=8C=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D1=84=D0=BE=D1=80=D0=BC=D0=B8=D1=80=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=BE=D1=82=D1=87=D0=B5=D1=82?= =?UTF-8?q?=D0=B0=20=D0=A0=D0=A2=D0=9A=20-=20=D0=BF=D0=BB=D0=BE=D1=81?= =?UTF-8?q?=D0=BA=D0=B8=D0=B9=20=D1=81=D0=BF=D0=B8=D1=81=D0=BE=D0=BA:=201.?= =?UTF-8?q?=20=D0=A3=D0=B1=D1=80=D0=B0=D0=BD=D1=8B=20=D0=BD=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=B3=D0=B0=D1=86=D0=B8=D0=BE=D0=BD=D0=BD=D1=8B=D0=B5=20?= =?UTF-8?q?=D1=81=D0=B2=D0=BE=D0=B9=D1=81=D1=82=D0=B2=D0=B0=20Rotor=20?= =?UTF-8?q?=D0=B8=20Slide=20(=D0=B8=20=D1=81=D0=BE=D0=BE=D1=82=D0=B2=D0=B5?= =?UTF-8?q?=D1=82=D1=81=D1=82=D0=B2=D1=83=D1=8E=D1=89=D0=B0=D1=8F=20DTO)?= =?UTF-8?q?=202.=20=D0=97=D0=B0=D0=BA=D0=BE=D0=BC=D0=BC=D0=B5=D0=BD=D1=82?= =?UTF-8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=20=D0=BA=D0=BE=D0=B4=20?= =?UTF-8?q?=D1=84=D0=BE=D1=80=D0=BC=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=BE=D1=82=D1=87=D0=B5=D1=82=D0=B0=20=D0=A0?= =?UTF-8?q?=D0=A2=D0=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Data/ProcessMap/ProcessMapReportDto.cs | 45 ++++-- .../Data/ProcessMap/ProcessMapReportRowDto.cs | 43 ------ .../ProcessMap/ProcessMapReportService.cs | 56 +++---- .../Services/ProcessMap/ProcessMapService.cs | 146 +++++++++--------- 4 files changed, 136 insertions(+), 154 deletions(-) delete mode 100644 AsbCloudApp/Data/ProcessMap/ProcessMapReportRowDto.cs diff --git a/AsbCloudApp/Data/ProcessMap/ProcessMapReportDto.cs b/AsbCloudApp/Data/ProcessMap/ProcessMapReportDto.cs index 6af7c3ec..7d9b9c03 100644 --- a/AsbCloudApp/Data/ProcessMap/ProcessMapReportDto.cs +++ b/AsbCloudApp/Data/ProcessMap/ProcessMapReportDto.cs @@ -33,16 +33,6 @@ namespace AsbCloudApp.Data.ProcessMap /// public double MechDrillingHours { get; set; } - /// - /// Слайд - /// - public ProcessMapReportRowDto Slide { get; set; } = null!; - - /// - /// Ротор - /// - public ProcessMapReportRowDto Rotor { get; set; } = null!; - /// /// название секции скважины /// @@ -52,5 +42,40 @@ namespace AsbCloudApp.Data.ProcessMap /// название секции скважины /// public string WellSectionTypeName { get; set; } = null!; + + /// + /// Проходка, м + /// + public double? DeltaDepth { get; set; } + + /// + /// Перепад давления, атм + /// + public ProcessMapReportParamsDto PressureDiff { get; set; } = new(); + + /// + /// Нагрузка, т + /// + public ProcessMapReportParamsDto AxialLoad { get; set; } = new(); + + /// + /// Момент на ВСП, кНхМ + /// + public ProcessMapReportParamsDto TopDriveTorque { get; set; } = new(); + + /// + /// Ограничение скорости, м/ч + /// + public ProcessMapReportParamsDto SpeedL​imit { get; set; } = new(); + + /// + /// Процент использования системы АПД, % + /// + public double Usage { get; set; } + + /// + /// Фактическая механическая скорость, м/ч + /// + public double Rop { get; set; } } } diff --git a/AsbCloudApp/Data/ProcessMap/ProcessMapReportRowDto.cs b/AsbCloudApp/Data/ProcessMap/ProcessMapReportRowDto.cs deleted file mode 100644 index 331df5da..00000000 --- a/AsbCloudApp/Data/ProcessMap/ProcessMapReportRowDto.cs +++ /dev/null @@ -1,43 +0,0 @@ -namespace AsbCloudApp.Data.ProcessMap -{ - /// - /// Строки РТК - /// - public class ProcessMapReportRowDto - { - /// - /// Проходка, м - /// - public double? DeltaDepth { get; set; } - - /// - /// Перепад давления, атм - /// - public ProcessMapReportParamsDto PressureDiff { get; set; } = new(); - - /// - /// Нагрузка, т - /// - public ProcessMapReportParamsDto AxialLoad { get; set; } = new(); - - /// - /// Момент на ВСП, кНхМ - /// - public ProcessMapReportParamsDto TopDriveTorque { get; set; } = new(); - - /// - /// Ограничение скорости, м/ч - /// - public ProcessMapReportParamsDto SpeedL​imit { get; set; } = new(); - - /// - /// Процент использования системы АПД, % - /// - public double Usage { get; set; } - - /// - /// Фактическая механическая скорость, м/ч - /// - public double Rop { get; set; } - } -} diff --git a/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportService.cs b/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportService.cs index 923a6bf5..cacb341d 100644 --- a/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportService.cs +++ b/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportService.cs @@ -107,45 +107,45 @@ namespace AsbCloudInfrastructure.Services.ProcessMap .Merge().FirstCell() .SetVal(interval.MechDrillingHours); - row = FillIntervalModeData(sheet, "Ротор", interval.Rotor, columnMode, row); - row = FillIntervalModeData(sheet, "Слайд", interval.Slide, columnMode, row); + //row = FillIntervalModeData(sheet, "Ротор", interval.Rotor, columnMode, row); + //row = FillIntervalModeData(sheet, "Слайд", interval.Slide, columnMode, row); return row; } - private static int FillIntervalModeData(IXLWorksheet sheet, string modeName, ProcessMapReportRowDto modeData, int column, int row) - { - int columnDeltaDepth = column + 1; - int columnPressure = columnDeltaDepth + 1; - int columnLoad = columnPressure + 5; - int columnTorque = columnLoad + 5; - int columnSpeed = columnTorque + 5; - int columnUsagePlan = columnSpeed + 5; - int columnUsageFact = columnUsagePlan + 1; - int columnRop = columnUsageFact + 12; + //private static int FillIntervalModeData(IXLWorksheet sheet, string modeName, ProcessMapReportRowDto modeData, int column, int row) + //{ + // int columnDeltaDepth = column + 1; + // int columnPressure = columnDeltaDepth + 1; + // int columnLoad = columnPressure + 5; + // int columnTorque = columnLoad + 5; + // int columnSpeed = columnTorque + 5; + // int columnUsagePlan = columnSpeed + 5; + // int columnUsageFact = columnUsagePlan + 1; + // int columnRop = columnUsageFact + 12; - sheet.Cell(row, column) - .SetVal(modeName); + // sheet.Cell(row, column) + // .SetVal(modeName); - sheet.Cell(row, columnDeltaDepth) - .SetVal(modeData.DeltaDepth); + // sheet.Cell(row, columnDeltaDepth) + // .SetVal(modeData.DeltaDepth); - FillIntervalModeDataParam(sheet, modeData.PressureDiff, columnPressure, row); - FillIntervalModeDataParam(sheet, modeData.AxialLoad, columnLoad, row); - FillIntervalModeDataParam(sheet, modeData.TopDriveTorque, columnTorque, row); - FillIntervalModeDataSpeed(sheet, modeData.SpeedLimit, columnSpeed, row); + // FillIntervalModeDataParam(sheet, modeData.PressureDiff, columnPressure, row); + // FillIntervalModeDataParam(sheet, modeData.AxialLoad, columnLoad, row); + // FillIntervalModeDataParam(sheet, modeData.TopDriveTorque, columnTorque, row); + // FillIntervalModeDataSpeed(sheet, modeData.SpeedLimit, columnSpeed, row); - sheet.Cell(row, columnUsagePlan) - .SetVal(100); + // sheet.Cell(row, columnUsagePlan) + // .SetVal(100); - sheet.Cell(row, columnUsageFact) - .SetVal(modeData.Usage); + // sheet.Cell(row, columnUsageFact) + // .SetVal(modeData.Usage); - sheet.Cell(row, columnRop) - .SetVal(modeData.Rop); + // sheet.Cell(row, columnRop) + // .SetVal(modeData.Rop); - return row + 1; - } + // return row + 1; + //} private static void FillIntervalModeDataParam(IXLWorksheet sheet, ProcessMapReportParamsDto dataParam, int column, int row) { diff --git a/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapService.cs b/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapService.cs index 0c1769c7..a8228d7e 100644 --- a/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapService.cs +++ b/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapService.cs @@ -146,8 +146,8 @@ namespace AsbCloudInfrastructure.Services.ProcessMap var slideOperations = intervalOperations.Where(o => o.IdCategory == WellOperationCategory.IdSlide); var rotorOperations = intervalOperations.Where(o => o.IdCategory == WellOperationCategory.IdRotor); - dto.Slide = CalcDrillModeStat(depthInterval, slideOperations, intervalProcessMap, intervalTelemetryDataStat, intervalLimitingParametrs, intervalSubsystemsOperationTime); - dto.Rotor = CalcDrillModeStat(depthInterval, rotorOperations, intervalProcessMap, intervalTelemetryDataStat, intervalLimitingParametrs, intervalSubsystemsOperationTime); + //dto.Slide = CalcDrillModeStat(depthInterval, slideOperations, intervalProcessMap, intervalTelemetryDataStat, intervalLimitingParametrs, intervalSubsystemsOperationTime); + //dto.Rotor = CalcDrillModeStat(depthInterval, rotorOperations, intervalProcessMap, intervalTelemetryDataStat, intervalLimitingParametrs, intervalSubsystemsOperationTime); return dto; } @@ -201,91 +201,91 @@ namespace AsbCloudInfrastructure.Services.ProcessMap return result; } - private static ProcessMapReportRowDto CalcDrillModeStat( - (double min, double max) depthInterval, - IEnumerable intervalModeOperations, - IEnumerable intervalProcessMap, - TelemetryDataSaubStatDto? telemetryDataStat, - IEnumerable intervalLimitingParametrs, - IEnumerable intervalSubsystemsOperationTime) - { - var dto = new ProcessMapReportRowDto(); - if (intervalModeOperations.Any()) - { - var deltaDepth = CalcDeltaDepth(depthInterval, intervalModeOperations); - dto.DeltaDepth = deltaDepth; - dto.Rop = deltaDepth / CalcHours(depthInterval, intervalModeOperations); - }; + //private static ProcessMapReportRowDto CalcDrillModeStat( + // (double min, double max) depthInterval, + // IEnumerable intervalModeOperations, + // IEnumerable intervalProcessMap, + // TelemetryDataSaubStatDto? telemetryDataStat, + // IEnumerable intervalLimitingParametrs, + // IEnumerable intervalSubsystemsOperationTime) + //{ + // var dto = new ProcessMapReportRowDto(); + // if (intervalModeOperations.Any()) + // { + // var deltaDepth = CalcDeltaDepth(depthInterval, intervalModeOperations); + // dto.DeltaDepth = deltaDepth; + // dto.Rop = deltaDepth / CalcHours(depthInterval, intervalModeOperations); + // }; - if (intervalProcessMap.Any()) - { - var processMapFirst = intervalProcessMap.First(); - dto.PressureDiff.SetpointPlan = processMapFirst.Pressure.Plan; - dto.AxialLoad.SetpointPlan = processMapFirst.AxialLoad.Plan; - dto.TopDriveTorque.SetpointPlan = processMapFirst.TopDriveTorque.Plan; - //dto.SpeedLimit.SetpointPlan = null; - } + // if (intervalProcessMap.Any()) + // { + // var processMapFirst = intervalProcessMap.First(); + // dto.PressureDiff.SetpointPlan = processMapFirst.Pressure.Plan; + // dto.AxialLoad.SetpointPlan = processMapFirst.AxialLoad.Plan; + // dto.TopDriveTorque.SetpointPlan = processMapFirst.TopDriveTorque.Plan; + // //dto.SpeedLimit.SetpointPlan = null; + // } - if (telemetryDataStat is not null) - { - dto.PressureDiff.SetpointFact = telemetryDataStat.PressureSp; - dto.PressureDiff.Fact = telemetryDataStat.PressureDelta; - dto.PressureDiff.Limit = telemetryDataStat.PressureDeltaLimitMax; + // if (telemetryDataStat is not null) + // { + // dto.PressureDiff.SetpointFact = telemetryDataStat.PressureSp; + // dto.PressureDiff.Fact = telemetryDataStat.PressureDelta; + // dto.PressureDiff.Limit = telemetryDataStat.PressureDeltaLimitMax; - dto.AxialLoad.SetpointFact = telemetryDataStat.AxialLoadSp; - dto.AxialLoad.Fact = telemetryDataStat.AxialLoad; - dto.AxialLoad.Limit = telemetryDataStat.AxialLoadLimitMax; + // dto.AxialLoad.SetpointFact = telemetryDataStat.AxialLoadSp; + // dto.AxialLoad.Fact = telemetryDataStat.AxialLoad; + // dto.AxialLoad.Limit = telemetryDataStat.AxialLoadLimitMax; - dto.TopDriveTorque.SetpointFact = telemetryDataStat.RotorTorqueSp; - dto.TopDriveTorque.Fact = telemetryDataStat.RotorTorque; - dto.TopDriveTorque.Limit = telemetryDataStat.RotorTorqueLimitMax; + // dto.TopDriveTorque.SetpointFact = telemetryDataStat.RotorTorqueSp; + // dto.TopDriveTorque.Fact = telemetryDataStat.RotorTorque; + // dto.TopDriveTorque.Limit = telemetryDataStat.RotorTorqueLimitMax; - dto.SpeedLimit.SetpointFact = telemetryDataStat.BlockSpeedSp; - dto.SpeedLimit.Fact = telemetryDataStat.BlockSpeed; - //dto.SpeedLimit.Limit = mull; - } + // dto.SpeedLimit.SetpointFact = telemetryDataStat.BlockSpeedSp; + // dto.SpeedLimit.Fact = telemetryDataStat.BlockSpeed; + // //dto.SpeedLimit.Limit = mull; + // } - if(intervalLimitingParametrs.Any()) - { - const int idLimParamRop = 1; - const int idLimParamPressure = 2; - const int idLimParamAxialLoad = 3; - const int idLimParamTorque = 4; + // if(intervalLimitingParametrs.Any()) + // { + // const int idLimParamRop = 1; + // const int idLimParamPressure = 2; + // const int idLimParamAxialLoad = 3; + // const int idLimParamTorque = 4; - var intervalLimitingParametrsStat = intervalLimitingParametrs - .GroupBy(p => p.IdFeedRegulator) - .Select(g => new - { - IdLimParam = g.Key, - SumDepth = g.Sum(p => p.DepthEnd - p.DepthStart), - }); + // var intervalLimitingParametrsStat = intervalLimitingParametrs + // .GroupBy(p => p.IdFeedRegulator) + // .Select(g => new + // { + // IdLimParam = g.Key, + // SumDepth = g.Sum(p => p.DepthEnd - p.DepthStart), + // }); - var totalDepth = intervalLimitingParametrsStat - .Sum(s => s.SumDepth); + // var totalDepth = intervalLimitingParametrsStat + // .Sum(s => s.SumDepth); - if (totalDepth > 0) - { - dto.AxialLoad.PercDrillingSetpoint = intervalLimitingParametrsStat - .FirstOrDefault(s => s.IdLimParam == idLimParamAxialLoad)?.SumDepth / totalDepth; + // if (totalDepth > 0) + // { + // dto.AxialLoad.PercDrillingSetpoint = intervalLimitingParametrsStat + // .FirstOrDefault(s => s.IdLimParam == idLimParamAxialLoad)?.SumDepth / totalDepth; - dto.PressureDiff.PercDrillingSetpoint = intervalLimitingParametrsStat - .FirstOrDefault(s => s.IdLimParam == idLimParamPressure)?.SumDepth / totalDepth; + // dto.PressureDiff.PercDrillingSetpoint = intervalLimitingParametrsStat + // .FirstOrDefault(s => s.IdLimParam == idLimParamPressure)?.SumDepth / totalDepth; - dto.TopDriveTorque.PercDrillingSetpoint = intervalLimitingParametrsStat - .FirstOrDefault(s => s.IdLimParam == idLimParamTorque)?.SumDepth / totalDepth; + // dto.TopDriveTorque.PercDrillingSetpoint = intervalLimitingParametrsStat + // .FirstOrDefault(s => s.IdLimParam == idLimParamTorque)?.SumDepth / totalDepth; - dto.SpeedLimit.PercDrillingSetpoint = intervalLimitingParametrsStat - .FirstOrDefault(s => s.IdLimParam == idLimParamRop)?.SumDepth / totalDepth; - } - } + // dto.SpeedLimit.PercDrillingSetpoint = intervalLimitingParametrsStat + // .FirstOrDefault(s => s.IdLimParam == idLimParamRop)?.SumDepth / totalDepth; + // } + // } - if (intervalSubsystemsOperationTime.Any() && dto.DeltaDepth > 0) - { - dto.Usage = intervalSubsystemsOperationTime.Sum(t => t.DepthEnd - t.DepthStart) / dto.DeltaDepth.Value; - } + // if (intervalSubsystemsOperationTime.Any() && dto.DeltaDepth > 0) + // { + // dto.Usage = intervalSubsystemsOperationTime.Sum(t => t.DepthEnd - t.DepthStart) / dto.DeltaDepth.Value; + // } - return dto; - } + // return dto; + //} private static double CalcDeltaDepth((double min, double max) depthInterval, IEnumerable intervalOperations) { From 4d32b57390f6061ae81e615015c8d8040bc20c16 Mon Sep 17 00:00:00 2001 From: ngfrolov Date: Fri, 31 Mar 2023 16:40:34 +0500 Subject: [PATCH 02/16] Add Example.http --- AsbCloudWebApi/Rest/Example.http | 35 ++++++++++++++++++++++++++++++++ AsbCloudWebApi/Rest/Readme.md | 7 +++++++ 2 files changed, 42 insertions(+) create mode 100644 AsbCloudWebApi/Rest/Example.http create mode 100644 AsbCloudWebApi/Rest/Readme.md diff --git a/AsbCloudWebApi/Rest/Example.http b/AsbCloudWebApi/Rest/Example.http new file mode 100644 index 00000000..bd156b32 --- /dev/null +++ b/AsbCloudWebApi/Rest/Example.http @@ -0,0 +1,35 @@ +@baseUrl = http://127.0.0.1:5000 +@contentType = application/json +@auth = Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImN0eSI6IkpXVCJ9.eyJpZCI6IjEiLCJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiZGV2IiwiaWRDb21wYW55IjoiMSIsImh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vd3MvMjAwOC8wNi9pZGVudGl0eS9jbGFpbXMvcm9sZSI6InJvb3QiLCJuYmYiOjE2NjI1NDgxNjIsImV4cCI6MTY5NDEwNTc2MiwiaXNzIjoiYSIsImF1ZCI6ImEifQ.OEAlNzxi7Jat6pzDBTAjTbChskc-tdJthJexyWwwUKE + +# https://marketplace.visualstudio.com/items?itemName=humao.rest-client + +### +GET {{baseUrl}}/api/schedule/test +Content-Type: {{contentType}} +accept: */* +Authorization: {{auth}} + +### +POST {{baseUrl}}/api/schedule/test +Content-Type: {{contentType}} +accept: */* +Authorization: {{auth}} + +{ + "id": 0, + "items": [ + { + "id": 1, + "value": 0.1 + }, + { + "id": 2, + "value": 1. + }, + { + "id": 3, + "value": 2.0 + } + ] +} \ No newline at end of file diff --git a/AsbCloudWebApi/Rest/Readme.md b/AsbCloudWebApi/Rest/Readme.md new file mode 100644 index 00000000..92f52c05 --- /dev/null +++ b/AsbCloudWebApi/Rest/Readme.md @@ -0,0 +1,7 @@ +# / web-api. + + *.http ( *.rest) endpoint api swagger ( postman). + +[ ](https://marketplace.visualstudio.com/items?itemName=humao.rest-client) + + 1 1 . From 225d6ef827437c88d527a4698bc0347d54d5ec4b Mon Sep 17 00:00:00 2001 From: ngfrolov Date: Fri, 31 Mar 2023 16:57:20 +0500 Subject: [PATCH 03/16] =?UTF-8?q?=D0=9D=D0=B5=D0=B7=D0=BD=D0=B0=D1=87?= =?UTF-8?q?=D0=B8=D1=82=D0=B5=D0=BB=D1=8C=D0=BD=D1=8B=D0=B5=20=D0=BF=D0=B5?= =?UTF-8?q?=D1=80=D0=B5=D0=B8=D0=BC=D0=B5=D0=BD=D0=BE=D0=B2=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...{ProcessMapDto.cs => ProcessMapPlanDto.cs} | 3 +- .../Data/ProcessMap/ProcessMapReportDto.cs | 31 +++++++++++++------ .../ProcessMap/ProcessMapReportParamsDto.cs | 2 +- .../Repositories/IProcessMapRepository.cs | 6 ++-- .../Repositories/IWellCompositeRepository.cs | 2 +- .../Repository/ProcessMapRepository.cs | 16 +++++----- .../Repository/WellCompositeRepository.cs | 2 +- .../ProcessMap/ProcessMapReportService.cs | 4 +-- .../Services/ProcessMap/ProcessMapService.cs | 4 +-- .../Services/WellInfoService.cs | 2 +- .../Controllers/ProcessMapController.cs | 12 +++---- .../Controllers/WellCompositeController.cs | 2 +- 12 files changed, 49 insertions(+), 37 deletions(-) rename AsbCloudApp/Data/ProcessMap/{ProcessMapDto.cs => ProcessMapPlanDto.cs} (96%) diff --git a/AsbCloudApp/Data/ProcessMap/ProcessMapDto.cs b/AsbCloudApp/Data/ProcessMap/ProcessMapPlanDto.cs similarity index 96% rename from AsbCloudApp/Data/ProcessMap/ProcessMapDto.cs rename to AsbCloudApp/Data/ProcessMap/ProcessMapPlanDto.cs index 94989d70..ce64f1a3 100644 --- a/AsbCloudApp/Data/ProcessMap/ProcessMapDto.cs +++ b/AsbCloudApp/Data/ProcessMap/ProcessMapPlanDto.cs @@ -1,13 +1,12 @@ using System; using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; namespace AsbCloudApp.Data.ProcessMap { /// /// РТК /// - public class ProcessMapDto : IId, IWellRelated + public class ProcessMapPlanDto : IId, IWellRelated { /// public int Id { get; set; } diff --git a/AsbCloudApp/Data/ProcessMap/ProcessMapReportDto.cs b/AsbCloudApp/Data/ProcessMap/ProcessMapReportDto.cs index 7d9b9c03..9e753c01 100644 --- a/AsbCloudApp/Data/ProcessMap/ProcessMapReportDto.cs +++ b/AsbCloudApp/Data/ProcessMap/ProcessMapReportDto.cs @@ -13,16 +13,34 @@ namespace AsbCloudApp.Data.ProcessMap public int IdWell { get; set; } /// - /// Глубина по стволу, м + /// название секции скважины + /// + public int IdWellSectionType { get; set; } + + /// + /// название секции скважины + /// + public string WellSectionTypeName { get; set; } = null!; + + /// + /// Глубина по стволу от, м /// /// на начало интервала /// /// public double DepthStart { get; set; } + /// + /// Глубина по стволу до, м + /// + /// на конец интервала + /// + /// + public double DepthEnd { get; set; } + /// /// Дата/ время - /// + /// /// на начало интервала /// /// @@ -34,14 +52,9 @@ namespace AsbCloudApp.Data.ProcessMap public double MechDrillingHours { get; set; } /// - /// название секции скважины + /// Режим бурения (Ротор/слайд/ручной) /// - public int IdWellSectionType { get; set; } - - /// - /// название секции скважины - /// - public string WellSectionTypeName { get; set; } = null!; + public string DrillingMode { get; set; } = null!; /// /// Проходка, м diff --git a/AsbCloudApp/Data/ProcessMap/ProcessMapReportParamsDto.cs b/AsbCloudApp/Data/ProcessMap/ProcessMapReportParamsDto.cs index 6557283f..da002d5c 100644 --- a/AsbCloudApp/Data/ProcessMap/ProcessMapReportParamsDto.cs +++ b/AsbCloudApp/Data/ProcessMap/ProcessMapReportParamsDto.cs @@ -34,6 +34,6 @@ namespace AsbCloudApp.Data.ProcessMap /// /// Процент бурения по уставке, % /// - public double? PercDrillingSetpoint { get; set; } + public double? PercDrillingBySetpoint { get; set; } } } diff --git a/AsbCloudApp/Repositories/IProcessMapRepository.cs b/AsbCloudApp/Repositories/IProcessMapRepository.cs index 3a1da4d5..c0f347e2 100644 --- a/AsbCloudApp/Repositories/IProcessMapRepository.cs +++ b/AsbCloudApp/Repositories/IProcessMapRepository.cs @@ -11,7 +11,7 @@ namespace AsbCloudApp.Repositories /// /// /// - public interface IProcessMapRepository : IRepositoryWellRelated + public interface IProcessMapRepository : IRepositoryWellRelated { /// /// . @@ -20,7 +20,7 @@ namespace AsbCloudApp.Repositories /// /// /// - Task> GetAllAsync(int idWell, + Task> GetAllAsync(int idWell, DateTime? updateFrom, CancellationToken token = default); /// @@ -29,6 +29,6 @@ namespace AsbCloudApp.Repositories /// /// /// - Task> GetProcessMapAsync(IEnumerable requests, CancellationToken token); + Task> GetProcessMapAsync(IEnumerable requests, CancellationToken token); } } \ No newline at end of file diff --git a/AsbCloudApp/Repositories/IWellCompositeRepository.cs b/AsbCloudApp/Repositories/IWellCompositeRepository.cs index 06413176..c54c7e27 100644 --- a/AsbCloudApp/Repositories/IWellCompositeRepository.cs +++ b/AsbCloudApp/Repositories/IWellCompositeRepository.cs @@ -34,6 +34,6 @@ namespace AsbCloudApp.Repositories /// /// /// - Task> GetCompositeProcessMap(int idWell, CancellationToken token); + Task> GetCompositeProcessMap(int idWell, CancellationToken token); } } diff --git a/AsbCloudInfrastructure/Repository/ProcessMapRepository.cs b/AsbCloudInfrastructure/Repository/ProcessMapRepository.cs index 35d51724..dc0539c7 100644 --- a/AsbCloudInfrastructure/Repository/ProcessMapRepository.cs +++ b/AsbCloudInfrastructure/Repository/ProcessMapRepository.cs @@ -18,7 +18,7 @@ using System.Threading.Tasks; namespace AsbCloudInfrastructure.Repository { #nullable enable - public class ProcessMapRepository : CrudWellRelatedRepositoryBase, + public class ProcessMapRepository : CrudWellRelatedRepositoryBase, IProcessMapRepository { private readonly IWellService wellService; @@ -32,7 +32,7 @@ namespace AsbCloudInfrastructure.Repository this.wellService = wellService; } - public async Task> GetAllAsync(int idWell, + public async Task> GetAllAsync(int idWell, DateTime? updateFrom, CancellationToken token) { var requests = new[] @@ -53,7 +53,7 @@ namespace AsbCloudInfrastructure.Repository return dtos; } - public async Task> GetProcessMapAsync(IEnumerable requests, CancellationToken token) + public async Task> GetProcessMapAsync(IEnumerable requests, CancellationToken token) { var entities = await BuildQuery(requests) .ToListAsync(token) @@ -62,7 +62,7 @@ namespace AsbCloudInfrastructure.Repository return dtos; } - public override async Task InsertAsync(ProcessMapDto dto, + public override async Task InsertAsync(ProcessMapPlanDto dto, CancellationToken token) { dto.LastUpdate = DateTime.UtcNow; @@ -70,7 +70,7 @@ namespace AsbCloudInfrastructure.Repository return result; } - public override async Task UpdateAsync(ProcessMapDto dto, + public override async Task UpdateAsync(ProcessMapPlanDto dto, CancellationToken token) { dto.LastUpdate = DateTime.UtcNow; @@ -105,9 +105,9 @@ namespace AsbCloudInfrastructure.Repository } return query; } - protected override ProcessMapDto Convert(ProcessMap entity) + protected override ProcessMapPlanDto Convert(ProcessMap entity) { - var dto = entity.Adapt(); + var dto = entity.Adapt(); dto.LastUpdate = entity.LastUpdate.ToRemoteDateTime(entity.Well.Timezone.Hours); dto.AxialLoad = new PlanLimitDto { @@ -137,7 +137,7 @@ namespace AsbCloudInfrastructure.Repository return dto; } - protected override ProcessMap Convert(ProcessMapDto dto) + protected override ProcessMap Convert(ProcessMapPlanDto dto) { var entity = dto.Adapt(); entity.AxialLoadPlan = dto.AxialLoad.Plan; diff --git a/AsbCloudInfrastructure/Repository/WellCompositeRepository.cs b/AsbCloudInfrastructure/Repository/WellCompositeRepository.cs index 5fd50aaf..0ec8d6b9 100644 --- a/AsbCloudInfrastructure/Repository/WellCompositeRepository.cs +++ b/AsbCloudInfrastructure/Repository/WellCompositeRepository.cs @@ -50,7 +50,7 @@ namespace AsbCloudInfrastructure.Repository } /// - public async Task> GetCompositeProcessMap(int idWell, CancellationToken token) + public async Task> GetCompositeProcessMap(int idWell, CancellationToken token) { var dtos = await GetAsync(idWell, token); diff --git a/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportService.cs b/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportService.cs index cacb341d..430da7b4 100644 --- a/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportService.cs +++ b/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportService.cs @@ -168,7 +168,7 @@ namespace AsbCloudInfrastructure.Services.ProcessMap .SetVal(dataParam.Limit); sheet.Cell(row, column + columnOffsetPercent) - .SetVal(dataParam.PercDrillingSetpoint); + .SetVal(dataParam.PercDrillingBySetpoint); } private static void FillIntervalModeDataSpeed(IXLWorksheet sheet, ProcessMapReportParamsDto dataParam, int column, int row) @@ -192,7 +192,7 @@ namespace AsbCloudInfrastructure.Services.ProcessMap .SetVal(dataParam.Limit); sheet.Cell(row, column + columnOffsetPercent) - .SetVal(dataParam.PercDrillingSetpoint); + .SetVal(dataParam.PercDrillingBySetpoint); } private static Stream GetExcelTemplateStream() diff --git a/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapService.cs b/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapService.cs index a8228d7e..5688e0ff 100644 --- a/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapService.cs +++ b/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapService.cs @@ -96,7 +96,7 @@ namespace AsbCloudInfrastructure.Services.ProcessMap private static IEnumerable HandleSection( IEnumerable sectionOperations, - IEnumerable sectionProcessMap, + IEnumerable sectionProcessMap, IEnumerable telemetryDataStat, IEnumerable limitingParameters, IEnumerable subsystemsOperationTime) @@ -116,7 +116,7 @@ namespace AsbCloudInfrastructure.Services.ProcessMap private static ProcessMapReportDto MakeProcessMapReportDto( (double min, double max) depthInterval, IEnumerable sectionOperations, - IEnumerable sectionProcessMap, + IEnumerable sectionProcessMap, IEnumerable telemetryDataStat, IEnumerable limitingParameters, IEnumerable subsystemsOperationTime) diff --git a/AsbCloudInfrastructure/Services/WellInfoService.cs b/AsbCloudInfrastructure/Services/WellInfoService.cs index d627dc4e..79d59003 100644 --- a/AsbCloudInfrastructure/Services/WellInfoService.cs +++ b/AsbCloudInfrastructure/Services/WellInfoService.cs @@ -105,7 +105,7 @@ namespace AsbCloudInfrastructure.Services int? idSection = wellLastFactSection?.Id; - ProcessMapDto? welllProcessMap; + ProcessMapPlanDto? welllProcessMap; if (idSection is not null) { welllProcessMap = wellProcessMaps.FirstOrDefault(p => p.IdWellSectionType == idSection); diff --git a/AsbCloudWebApi/Controllers/ProcessMapController.cs b/AsbCloudWebApi/Controllers/ProcessMapController.cs index 2837af73..9f5617a2 100644 --- a/AsbCloudWebApi/Controllers/ProcessMapController.cs +++ b/AsbCloudWebApi/Controllers/ProcessMapController.cs @@ -18,7 +18,7 @@ namespace AsbCloudWebApi.Controllers [ApiController] [Route("api/[controller]")] [Authorize] - public class ProcessMapController : CrudWellRelatedController + public class ProcessMapController : CrudWellRelatedController { private readonly ITelemetryService telemetryService; private readonly IProcessMapReportService processMapReportService; @@ -49,14 +49,14 @@ namespace AsbCloudWebApi.Controllers [Obsolete("use GetByUidAsync(..) instead")] [Route("/api/telemetry/{uid}/drillFlowChart")] [AllowAnonymous] - [ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)] + [ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)] public IActionResult GetByTelemetry(string uid, DateTime updateFrom, CancellationToken token) { var idWell = telemetryService.GetIdWellByTelemetryUid(uid); if (idWell is null) return BadRequest($"Wrong uid {uid}"); - var dto = Enumerable.Empty(); + var dto = Enumerable.Empty(); return Ok(dto); } @@ -70,7 +70,7 @@ namespace AsbCloudWebApi.Controllers [HttpGet] [Route("/api/telemetry/{uid}/processMap")] [AllowAnonymous] - [ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)] + [ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)] public async Task GetByUidAsync(string uid, DateTime updateFrom, CancellationToken token) { var idWell = telemetryService.GetIdWellByTelemetryUid(uid); @@ -133,7 +133,7 @@ namespace AsbCloudWebApi.Controllers /// /// [HttpPost] - public override async Task> InsertAsync([FromBody] ProcessMapDto value, CancellationToken token) + public override async Task> InsertAsync([FromBody] ProcessMapPlanDto value, CancellationToken token) { value.IdUser = User.GetUserId() ?? -1; return await base.InsertAsync(value, token); @@ -146,7 +146,7 @@ namespace AsbCloudWebApi.Controllers /// /// 1 - успешно отредактировано, 0 - нет [HttpPut] - public override async Task> UpdateAsync([FromBody] ProcessMapDto value, CancellationToken token) + public override async Task> UpdateAsync([FromBody] ProcessMapPlanDto value, CancellationToken token) { value.IdUser = User.GetUserId() ?? -1; return await base.UpdateAsync(value, token); diff --git a/AsbCloudWebApi/Controllers/WellCompositeController.cs b/AsbCloudWebApi/Controllers/WellCompositeController.cs index 66a0d65b..0bfe40c1 100644 --- a/AsbCloudWebApi/Controllers/WellCompositeController.cs +++ b/AsbCloudWebApi/Controllers/WellCompositeController.cs @@ -73,7 +73,7 @@ namespace AsbCloudWebApi.Controllers /// [HttpGet("getCompositeProcessMap")] [Permission] - [ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)] + [ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)] public async Task GetCompositeProcessMap(int idWell, CancellationToken token = default) { if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false)) From 9b794311c43bdc33eafe76b50dc2218c26470814 Mon Sep 17 00:00:00 2001 From: ngfrolov Date: Mon, 3 Apr 2023 14:59:59 +0500 Subject: [PATCH 04/16] Rename processMaps to processMapPlan, processMapReport, processMapReportMaker. --- .../Data/SAUB/TelemetryDataSaubStatDto.cs | 18 +- .../Repositories/IProcessMapRepository.cs | 2 +- ...ce.cs => IProcessMapReportMakerService.cs} | 2 +- AsbCloudApp/Services/IProcessMapService.cs | 2 +- AsbCloudInfrastructure/DependencyInjection.cs | 4 +- .../Repository/ProcessMapRepository.cs | 4 +- .../Repository/WellCompositeRepository.cs | 4 +- .../ProcessMapReportMakerService.cs | 216 +++++++++++ .../ProcessMap/ProcessMapReportService.cs | 250 ++++--------- .../Services/ProcessMap/ProcessMapService.cs | 348 ------------------ .../Services/SAUB/TelemetryDataSaubService.cs | 13 +- .../Services/WellInfoService.cs | 2 +- .../Controllers/ProcessMapController.cs | 12 +- .../Rest/{Example.http => ProcessMap.http} | 28 +- 14 files changed, 314 insertions(+), 591 deletions(-) rename AsbCloudApp/Services/{IProcessMapReportService.cs => IProcessMapReportMakerService.cs} (90%) create mode 100644 AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportMakerService.cs delete mode 100644 AsbCloudInfrastructure/Services/ProcessMap/ProcessMapService.cs rename AsbCloudWebApi/Rest/{Example.http => ProcessMap.http} (66%) diff --git a/AsbCloudApp/Data/SAUB/TelemetryDataSaubStatDto.cs b/AsbCloudApp/Data/SAUB/TelemetryDataSaubStatDto.cs index 2ca5293c..40514429 100644 --- a/AsbCloudApp/Data/SAUB/TelemetryDataSaubStatDto.cs +++ b/AsbCloudApp/Data/SAUB/TelemetryDataSaubStatDto.cs @@ -47,16 +47,6 @@ namespace AsbCloudApp.Data.SAUB /// public float PressureIdle { get; set; } - /// - /// задание давления для роторного режима - /// - public float PressureSpRotor { get; set; } - - /// - /// задание давления для режима слайда - /// - public float PressureSpSlide { get; set; } - /// /// ограничение макс перепада давления /// @@ -108,13 +98,13 @@ namespace AsbCloudApp.Data.SAUB public float BlockSpeedSp { get; set; } /// - /// Талевый блок. Задание скорости для роторного бурения + /// Режим САУБ /// - public float BlockSpeedSpRotor { get; set; } + public short Mode { get; set; } /// - /// Талевый блок. Задание скорости для режима слайда + /// Текущий критерий бурения /// - public float BlockSpeedSpSlide { get; set; } + public short? IdFeedRegulator { get; set; } } } diff --git a/AsbCloudApp/Repositories/IProcessMapRepository.cs b/AsbCloudApp/Repositories/IProcessMapRepository.cs index c0f347e2..b126e18a 100644 --- a/AsbCloudApp/Repositories/IProcessMapRepository.cs +++ b/AsbCloudApp/Repositories/IProcessMapRepository.cs @@ -11,7 +11,7 @@ namespace AsbCloudApp.Repositories /// /// /// - public interface IProcessMapRepository : IRepositoryWellRelated + public interface IProcessMapPlanRepository : IRepositoryWellRelated { /// /// . diff --git a/AsbCloudApp/Services/IProcessMapReportService.cs b/AsbCloudApp/Services/IProcessMapReportMakerService.cs similarity index 90% rename from AsbCloudApp/Services/IProcessMapReportService.cs rename to AsbCloudApp/Services/IProcessMapReportMakerService.cs index a4bf783b..0fea6d7b 100644 --- a/AsbCloudApp/Services/IProcessMapReportService.cs +++ b/AsbCloudApp/Services/IProcessMapReportMakerService.cs @@ -7,7 +7,7 @@ namespace AsbCloudApp.Services /// /// Сервис формирования РТК. /// - public interface IProcessMapReportService + public interface IProcessMapReportMakerService { /// /// Сформировать. diff --git a/AsbCloudApp/Services/IProcessMapService.cs b/AsbCloudApp/Services/IProcessMapService.cs index 63a611c8..954d899a 100644 --- a/AsbCloudApp/Services/IProcessMapService.cs +++ b/AsbCloudApp/Services/IProcessMapService.cs @@ -8,7 +8,7 @@ namespace AsbCloudApp.Services /// /// Сервис формирования РТК /// - public interface IProcessMapService + public interface IProcessMapReportService { /// /// Получение моделей РТК diff --git a/AsbCloudInfrastructure/DependencyInjection.cs b/AsbCloudInfrastructure/DependencyInjection.cs index f74de38e..62fa5d3f 100644 --- a/AsbCloudInfrastructure/DependencyInjection.cs +++ b/AsbCloudInfrastructure/DependencyInjection.cs @@ -107,7 +107,7 @@ namespace AsbCloudInfrastructure services.AddTransient(); services.AddTransient(); - services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -133,8 +133,8 @@ namespace AsbCloudInfrastructure services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); - services.AddTransient(); services.AddTransient(); // admin crud services: diff --git a/AsbCloudInfrastructure/Repository/ProcessMapRepository.cs b/AsbCloudInfrastructure/Repository/ProcessMapRepository.cs index dc0539c7..4b6305ca 100644 --- a/AsbCloudInfrastructure/Repository/ProcessMapRepository.cs +++ b/AsbCloudInfrastructure/Repository/ProcessMapRepository.cs @@ -4,10 +4,8 @@ using AsbCloudApp.Repositories; using AsbCloudApp.Requests; using AsbCloudApp.Services; using AsbCloudDb.Model; -using DocumentFormat.OpenXml.Spreadsheet; using Mapster; using Microsoft.EntityFrameworkCore; -using Org.BouncyCastle.Asn1.Ocsp; using System; using System.Collections.Generic; using System.Linq; @@ -19,7 +17,7 @@ namespace AsbCloudInfrastructure.Repository { #nullable enable public class ProcessMapRepository : CrudWellRelatedRepositoryBase, - IProcessMapRepository + IProcessMapPlanRepository { private readonly IWellService wellService; diff --git a/AsbCloudInfrastructure/Repository/WellCompositeRepository.cs b/AsbCloudInfrastructure/Repository/WellCompositeRepository.cs index 0ec8d6b9..f57326fa 100644 --- a/AsbCloudInfrastructure/Repository/WellCompositeRepository.cs +++ b/AsbCloudInfrastructure/Repository/WellCompositeRepository.cs @@ -17,9 +17,9 @@ namespace AsbCloudInfrastructure.Repository public class WellCompositeRepository : IWellCompositeRepository { private readonly IAsbCloudDbContext db; - private readonly IProcessMapRepository processMapRepository; + private readonly IProcessMapPlanRepository processMapRepository; - public WellCompositeRepository(IAsbCloudDbContext db, IProcessMapRepository processMapRepository) + public WellCompositeRepository(IAsbCloudDbContext db, IProcessMapPlanRepository processMapRepository) { this.db = db; this.processMapRepository = processMapRepository; diff --git a/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportMakerService.cs b/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportMakerService.cs new file mode 100644 index 00000000..8e444a08 --- /dev/null +++ b/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportMakerService.cs @@ -0,0 +1,216 @@ +using AsbCloudApp.Data.ProcessMap; +using AsbCloudApp.Services; +using ClosedXML.Excel; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; + +namespace AsbCloudInfrastructure.Services.ProcessMap +{ +#nullable enable + public class ProcessMapReportMakerService : IProcessMapReportMakerService + { + const int firstColumn = 2; + const int lastColumn = 61; + + const int headerRowsCount = 8; + + private readonly IProcessMapReportService processMapService; + + public ProcessMapReportMakerService(IProcessMapReportService processMapService) + { + this.processMapService = processMapService; + } + + public async Task MakeReportAsync(int idWell, CancellationToken token) + { + var stream = GetExcelTemplateStream(); + using var workbook = new XLWorkbook(stream, XLEventTracking.Disabled); + + var data = await processMapService.GetProcessMapAsync(idWell, token); + + FillProcessMapToWorkbook(workbook, data); + + MemoryStream memoryStream = new MemoryStream(); + workbook.SaveAs(memoryStream, new SaveOptions { }); + memoryStream.Seek(0, SeekOrigin.Begin); + return memoryStream; + } + + private static void FillProcessMapToWorkbook(XLWorkbook workbook, IEnumerable data) + { + var sheet = workbook.Worksheets.FirstOrDefault(); + if (sheet is null) + return; + var dataBySections = data.GroupBy(p => p.IdWellSectionType); + FillSheet(sheet, dataBySections); + } + + private static void FillSheet(IXLWorksheet sheet, IEnumerable> dataBySections) + { + var startRow = headerRowsCount + 1; + foreach (var sectionData in dataBySections) + { + if(sectionData.Any()) + startRow = FillSection(sheet, sectionData, startRow); + } + } + + private static int FillSection(IXLWorksheet sheet, IGrouping sectionData, int row) + { + var rowStart = row; + + var sectionName = sectionData.FirstOrDefault()?.WellSectionTypeName + ?? sectionData.Key.ToString(); + + sheet.Range(row, firstColumn, row, lastColumn) + .Merge() + .FirstCell() + .SetVal(sectionName) + .Style + .Fill.SetBackgroundColor(XLColor.LightGray); + + row++; + + foreach (var interval in sectionData) + row = FillIntervalData(sheet, interval, row); + + var sectionStyle = sheet.Range(rowStart, firstColumn, row - 1, lastColumn).Style; + SetBorders(sectionStyle); + return row; + } + + private static int FillIntervalData(IXLWorksheet sheet, ProcessMapReportDto interval, int row) + { + const int columnDepth = firstColumn + 1; + const int columnDate = firstColumn + 2; + const int columnRopTime = firstColumn + 3; + const int columnMode = firstColumn + 4; + + int rowRotor = row; + int rowSlide = row + 1; + + sheet.Range(rowRotor, firstColumn, rowSlide, firstColumn) + .Merge(); + + sheet.Range(rowRotor, columnDepth, rowSlide, columnDepth) + .Merge().FirstCell() + .SetVal(interval.DepthStart, "0.0"); + + sheet.Range(rowRotor, columnDate, rowSlide, columnDate) + .Merge().FirstCell() + .SetVal(interval.DateStart); + + sheet.Range(rowRotor, columnRopTime, rowSlide, columnRopTime) + .Merge().FirstCell() + .SetVal(interval.MechDrillingHours); + + //row = FillIntervalModeData(sheet, "Ротор", interval.Rotor, columnMode, row); + //row = FillIntervalModeData(sheet, "Слайд", interval.Slide, columnMode, row); + + return row; + } + + //private static int FillIntervalModeData(IXLWorksheet sheet, string modeName, ProcessMapReportRowDto modeData, int column, int row) + //{ + // int columnDeltaDepth = column + 1; + // int columnPressure = columnDeltaDepth + 1; + // int columnLoad = columnPressure + 5; + // int columnTorque = columnLoad + 5; + // int columnSpeed = columnTorque + 5; + // int columnUsagePlan = columnSpeed + 5; + // int columnUsageFact = columnUsagePlan + 1; + // int columnRop = columnUsageFact + 12; + + // sheet.Cell(row, column) + // .SetVal(modeName); + + // sheet.Cell(row, columnDeltaDepth) + // .SetVal(modeData.DeltaDepth); + + // FillIntervalModeDataParam(sheet, modeData.PressureDiff, columnPressure, row); + // FillIntervalModeDataParam(sheet, modeData.AxialLoad, columnLoad, row); + // FillIntervalModeDataParam(sheet, modeData.TopDriveTorque, columnTorque, row); + // FillIntervalModeDataSpeed(sheet, modeData.SpeedLimit, columnSpeed, row); + + // sheet.Cell(row, columnUsagePlan) + // .SetVal(100); + + // sheet.Cell(row, columnUsageFact) + // .SetVal(modeData.Usage); + + // sheet.Cell(row, columnRop) + // .SetVal(modeData.Rop); + + // return row + 1; + //} + + private static void FillIntervalModeDataParam(IXLWorksheet sheet, ProcessMapReportParamsDto dataParam, int column, int row) + { + const int columnOffsetSpPlan = 0; + const int columnOffsetSpFact = 1; + const int columnOffsetFact = 2; + const int columnOffsetLimit = 3; + const int columnOffsetPercent = 4; + + sheet.Cell(row, column + columnOffsetSpPlan) + .SetVal(dataParam.SetpointPlan); + + sheet.Cell(row, column + columnOffsetSpFact) + .SetVal(dataParam.SetpointFact); + + sheet.Cell(row, column + columnOffsetFact) + .SetVal(dataParam.Fact); + + sheet.Cell(row, column + columnOffsetLimit) + .SetVal(dataParam.Limit); + + sheet.Cell(row, column + columnOffsetPercent) + .SetVal(dataParam.PercDrillingBySetpoint); + } + + private static void FillIntervalModeDataSpeed(IXLWorksheet sheet, ProcessMapReportParamsDto dataParam, int column, int row) + { + const int columnOffsetSpPlan = 0; + const int columnOffsetSpFact = 1; + const int columnOffsetFact = 2; + const int columnOffsetLimit = 3; + const int columnOffsetPercent = 4; + + sheet.Cell(row, column + columnOffsetSpPlan) + .SetVal(dataParam.SetpointPlan); + + sheet.Cell(row, column + columnOffsetSpFact) + .SetVal(dataParam.SetpointFact); + + sheet.Cell(row, column + columnOffsetFact) + .SetVal(dataParam.Fact); + + sheet.Cell(row, column + columnOffsetLimit) + .SetVal(dataParam.Limit); + + sheet.Cell(row, column + columnOffsetPercent) + .SetVal(dataParam.PercDrillingBySetpoint); + } + + private static Stream GetExcelTemplateStream() + { + var stream = System.Reflection.Assembly.GetExecutingAssembly() + .GetManifestResourceStream("AsbCloudInfrastructure.Services.ProcessMap.ProcessMapReportTemplate.xlsx"); + return stream!; + } + + private static IXLStyle SetBorders(IXLStyle style) + { + style.Border.RightBorder = XLBorderStyleValues.Thin ; + style.Border.LeftBorder = XLBorderStyleValues.Thin; + style.Border.TopBorder = XLBorderStyleValues.Thin ; + style.Border.BottomBorder = XLBorderStyleValues.Thin ; + style.Border.InsideBorder = XLBorderStyleValues.Thin ; + return style; + } + } +#nullable disable +} \ No newline at end of file diff --git a/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportService.cs b/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportService.cs index 430da7b4..9cd63e0e 100644 --- a/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportService.cs +++ b/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportService.cs @@ -1,8 +1,15 @@ -using AsbCloudApp.Data.ProcessMap; +using AsbCloudApp.Data; +using AsbCloudApp.Data.ProcessMap; +using AsbCloudApp.Data.SAUB; +using AsbCloudApp.Exceptions; +using AsbCloudApp.Repositories; +using AsbCloudApp.Requests; using AsbCloudApp.Services; -using ClosedXML.Excel; +using AsbCloudApp.Services.Subsystems; +using AsbCloudDb.Model; +using AsbCloudApp.Data.Subsystems; +using System; using System.Collections.Generic; -using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -10,207 +17,86 @@ using System.Threading.Tasks; namespace AsbCloudInfrastructure.Services.ProcessMap { #nullable enable - public class ProcessMapReportService : IProcessMapReportService + public partial class ProcessMapReportService : IProcessMapReportService { - const int firstColumn = 2; - const int lastColumn = 61; + private readonly IWellService wellService; + private readonly IWellOperationRepository wellOperationRepository; + private readonly IProcessMapPlanRepository processMapPlanRepository; + private readonly ITelemetryDataSaubService telemetryDataSaubService; + private readonly ILimitingParameterRepository limitingParameterRepository; + private readonly ISubsystemOperationTimeService subsystemOperationTimeService; - const int headerRowsCount = 8; - - private readonly IProcessMapService processMapService; - - public ProcessMapReportService(IProcessMapService processMapService) + public ProcessMapReportService( + IWellService wellService, + IWellOperationRepository wellOperationService, + IProcessMapPlanRepository processMapPlanRepository, + ITelemetryDataSaubService telemetryDataSaubService, + ILimitingParameterRepository limitingParameterRepository, + ISubsystemOperationTimeService subsystemOperationTimeService) { - this.processMapService = processMapService; + this.wellService = wellService; + this.wellOperationRepository = wellOperationService; + this.processMapPlanRepository = processMapPlanRepository; + this.telemetryDataSaubService = telemetryDataSaubService; + this.limitingParameterRepository = limitingParameterRepository; + this.subsystemOperationTimeService = subsystemOperationTimeService; } - public async Task MakeReportAsync(int idWell, CancellationToken token) + /// + public async Task> GetProcessMapAsync(int idWell, CancellationToken token) { - var stream = GetExcelTemplateStream(); - using var workbook = new XLWorkbook(stream, XLEventTracking.Disabled); + var well = wellService.GetOrDefault(idWell) + ?? throw new ArgumentInvalidException("idWell not found", nameof(idWell)); - var data = await processMapService.GetProcessMapAsync(idWell, token); + var idTelemetry = well.IdTelemetry + ?? throw new ArgumentInvalidException("telemetry by well not found", nameof(idWell)); - FillProcessMapToWorkbook(workbook, data); + var processMapPlan = await processMapPlanRepository.GetByIdWellAsync(idWell, token); - MemoryStream memoryStream = new MemoryStream(); - workbook.SaveAs(memoryStream, new SaveOptions { }); - memoryStream.Seek(0, SeekOrigin.Begin); - return memoryStream; + if(!processMapPlan.Any()) + return Enumerable.Empty(); + + var telemetryDataStat = await telemetryDataSaubService.GetTelemetryDataStatAsync(idTelemetry, token); + + var result = CalcByIntervals(processMapPlan, telemetryDataStat); + + return result; } - private static void FillProcessMapToWorkbook(XLWorkbook workbook, IEnumerable data) + private IEnumerable CalcByIntervals(IEnumerable processMapPlan, IEnumerable telemetryDataStat) { - var sheet = workbook.Worksheets.FirstOrDefault(); - if (sheet is null) - return; - var dataBySections = data.GroupBy(p => p.IdWellSectionType); - FillSheet(sheet, dataBySections); - } - - private static void FillSheet(IXLWorksheet sheet, IEnumerable> dataBySections) - { - var startRow = headerRowsCount + 1; - foreach (var sectionData in dataBySections) - { - if(sectionData.Any()) - startRow = FillSection(sheet, sectionData, startRow); - } - } - - private static int FillSection(IXLWorksheet sheet, IGrouping sectionData, int row) - { - var rowStart = row; - - var sectionName = sectionData.FirstOrDefault()?.WellSectionTypeName - ?? sectionData.Key.ToString(); - - sheet.Range(row, firstColumn, row, lastColumn) - .Merge() - .FirstCell() - .SetVal(sectionName) - .Style - .Fill.SetBackgroundColor(XLColor.LightGray); - - row++; - - foreach (var interval in sectionData) - row = FillIntervalData(sheet, interval, row); - - var sectionStyle = sheet.Range(rowStart, firstColumn, row - 1, lastColumn).Style; - SetBorders(sectionStyle); - return row; - } - - private static int FillIntervalData(IXLWorksheet sheet, ProcessMapReportDto interval, int row) - { - const int columnDepth = firstColumn + 1; - const int columnDate = firstColumn + 2; - const int columnRopTime = firstColumn + 3; - const int columnMode = firstColumn + 4; - - int rowRotor = row; - int rowSlide = row + 1; - - sheet.Range(rowRotor, firstColumn, rowSlide, firstColumn) - .Merge(); - - sheet.Range(rowRotor, columnDepth, rowSlide, columnDepth) - .Merge().FirstCell() - .SetVal(interval.DepthStart, "0.0"); - - sheet.Range(rowRotor, columnDate, rowSlide, columnDate) - .Merge().FirstCell() - .SetVal(interval.DateStart); - - sheet.Range(rowRotor, columnRopTime, rowSlide, columnRopTime) - .Merge().FirstCell() - .SetVal(interval.MechDrillingHours); - - //row = FillIntervalModeData(sheet, "Ротор", interval.Rotor, columnMode, row); - //row = FillIntervalModeData(sheet, "Слайд", interval.Slide, columnMode, row); - - return row; - } - - //private static int FillIntervalModeData(IXLWorksheet sheet, string modeName, ProcessMapReportRowDto modeData, int column, int row) - //{ - // int columnDeltaDepth = column + 1; - // int columnPressure = columnDeltaDepth + 1; - // int columnLoad = columnPressure + 5; - // int columnTorque = columnLoad + 5; - // int columnSpeed = columnTorque + 5; - // int columnUsagePlan = columnSpeed + 5; - // int columnUsageFact = columnUsagePlan + 1; - // int columnRop = columnUsageFact + 12; - - // sheet.Cell(row, column) - // .SetVal(modeName); - - // sheet.Cell(row, columnDeltaDepth) - // .SetVal(modeData.DeltaDepth); - - // FillIntervalModeDataParam(sheet, modeData.PressureDiff, columnPressure, row); - // FillIntervalModeDataParam(sheet, modeData.AxialLoad, columnLoad, row); - // FillIntervalModeDataParam(sheet, modeData.TopDriveTorque, columnTorque, row); - // FillIntervalModeDataSpeed(sheet, modeData.SpeedLimit, columnSpeed, row); - - // sheet.Cell(row, columnUsagePlan) - // .SetVal(100); - - // sheet.Cell(row, columnUsageFact) - // .SetVal(modeData.Usage); - - // sheet.Cell(row, columnRop) - // .SetVal(modeData.Rop); - - // return row + 1; - //} - - private static void FillIntervalModeDataParam(IXLWorksheet sheet, ProcessMapReportParamsDto dataParam, int column, int row) - { - const int columnOffsetSpPlan = 0; - const int columnOffsetSpFact = 1; - const int columnOffsetFact = 2; - const int columnOffsetLimit = 3; - const int columnOffsetPercent = 4; - - sheet.Cell(row, column + columnOffsetSpPlan) - .SetVal(dataParam.SetpointPlan); + var result = new List(processMapPlan.Count() * 4); + var intervals = GetProcessMapIntervals(processMapPlan); - sheet.Cell(row, column + columnOffsetSpFact) - .SetVal(dataParam.SetpointFact); - - sheet.Cell(row, column + columnOffsetFact) - .SetVal(dataParam.Fact); - - sheet.Cell(row, column + columnOffsetLimit) - .SetVal(dataParam.Limit); - - sheet.Cell(row, column + columnOffsetPercent) - .SetVal(dataParam.PercDrillingBySetpoint); + return result; } - private static void FillIntervalModeDataSpeed(IXLWorksheet sheet, ProcessMapReportParamsDto dataParam, int column, int row) + private IEnumerable<(double, double)> GetProcessMapIntervals(IEnumerable processMapPlan) { - const int columnOffsetSpPlan = 0; - const int columnOffsetSpFact = 1; - const int columnOffsetFact = 2; - const int columnOffsetLimit = 3; - const int columnOffsetPercent = 4; - - sheet.Cell(row, column + columnOffsetSpPlan) - .SetVal(dataParam.SetpointPlan); - - sheet.Cell(row, column + columnOffsetSpFact) - .SetVal(dataParam.SetpointFact); - - sheet.Cell(row, column + columnOffsetFact) - .SetVal(dataParam.Fact); - - sheet.Cell(row, column + columnOffsetLimit) - .SetVal(dataParam.Limit); - - sheet.Cell(row, column + columnOffsetPercent) - .SetVal(dataParam.PercDrillingBySetpoint); + + return Enumerable.Empty<(double, double)>(); } - private static Stream GetExcelTemplateStream() + private static DateTime GetInterpolatedDate(WellOperationDto operation, double depth) { - var stream = System.Reflection.Assembly.GetExecutingAssembly() - .GetManifestResourceStream("AsbCloudInfrastructure.Services.ProcessMap.ProcessMapReportTemplate.xlsx"); - return stream!; + var ratio = (depth - operation.DepthStart) / (operation.DepthEnd - operation.DepthStart); + var deltaHours = operation.DurationHours * ratio; + var interpolatedDate = operation.DateStart + TimeSpan.FromHours(deltaHours); + return interpolatedDate; } - private static IXLStyle SetBorders(IXLStyle style) + private static IEnumerable<(double min, double max)> SplitByIntervals(double min, double max) { - style.Border.RightBorder = XLBorderStyleValues.Thin ; - style.Border.LeftBorder = XLBorderStyleValues.Thin; - style.Border.TopBorder = XLBorderStyleValues.Thin ; - style.Border.BottomBorder = XLBorderStyleValues.Thin ; - style.Border.InsideBorder = XLBorderStyleValues.Thin ; - return style; + const double step = 100; + var iMin = min; + var iMax = (1 + (int)(min / step)) * step; + for (; iMax < max; iMax += step) + { + yield return (iMin, iMax); + iMin = iMax; + } + yield return (iMin, max); } } #nullable disable -} \ No newline at end of file +} diff --git a/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapService.cs b/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapService.cs deleted file mode 100644 index 5688e0ff..00000000 --- a/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapService.cs +++ /dev/null @@ -1,348 +0,0 @@ -using AsbCloudApp.Data; -using AsbCloudApp.Data.ProcessMap; -using AsbCloudApp.Data.SAUB; -using AsbCloudApp.Exceptions; -using AsbCloudApp.Repositories; -using AsbCloudApp.Requests; -using AsbCloudApp.Services; -using AsbCloudApp.Services.Subsystems; -using AsbCloudDb.Model; -using AsbCloudApp.Data.Subsystems; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using AsbCloudInfrastructure.Services.Subsystems; - -namespace AsbCloudInfrastructure.Services.ProcessMap -{ -#nullable enable - public partial class ProcessMapService : IProcessMapService - { - private readonly IWellService wellService; - private readonly IWellOperationRepository wellOperationRepository; - private readonly IProcessMapRepository processMapRepository; - private readonly ITelemetryDataSaubService telemetryDataSaubService; - private readonly ILimitingParameterRepository limitingParameterRepository; - private readonly ISubsystemOperationTimeService subsystemOperationTimeService; - - public ProcessMapService( - IWellService wellService, - IWellOperationRepository wellOperationService, - IProcessMapRepository processMapRepository, - ITelemetryDataSaubService telemetryDataSaubService, - ILimitingParameterRepository limitingParameterRepository, - ISubsystemOperationTimeService subsystemOperationTimeService) - { - this.wellService = wellService; - this.wellOperationRepository = wellOperationService; - this.processMapRepository = processMapRepository; - this.telemetryDataSaubService = telemetryDataSaubService; - this.limitingParameterRepository = limitingParameterRepository; - this.subsystemOperationTimeService = subsystemOperationTimeService; - } - - /// - public async Task> GetProcessMapAsync(int idWell, CancellationToken token) - { - var well = wellService.GetOrDefault(idWell) - ?? throw new ArgumentInvalidException("idWell not found", nameof(idWell)); - var idTelemetry = well.IdTelemetry - ?? throw new ArgumentInvalidException("telemetry by well not found", nameof(idWell)); - - var processMap = (await processMapRepository.GetByIdWellAsync(idWell, token))!; - var factDrillingOperations = await GetFactDrillingOperationsAsync(idWell, token); - var telemetryDataStat = await telemetryDataSaubService.GetTelemetryDataStatAsync(idTelemetry, token); - var limitingParameters = await limitingParameterRepository.GetLimitingParametersAsync(new(), well, token); - var subsystemsOperationTime = await GetOperationTimeAsync(idWell, token); - - var result = factDrillingOperations - .GroupBy(o => o.IdWellSectionType) - .SelectMany(sectionOperations => - { - var sectionProcessMap = processMap.Where(p => p.IdWellSectionType == sectionOperations.Key); - return HandleSection(sectionOperations, sectionProcessMap, telemetryDataStat, limitingParameters, subsystemsOperationTime!); - }) - .ToList(); - - return result; - } - - private Task?> GetOperationTimeAsync(int idWell, CancellationToken token) - { - var request = new SubsystemOperationTimeRequest - { - IdWell = idWell, - IdsSubsystems = new int[] { SubsystemOperationTimeService.IdSubsystemAKB, SubsystemOperationTimeService.IdSubsystemSpin }, - }; - return subsystemOperationTimeService.GetOperationTimeAsync(request, token); - } - - private async Task> GetFactDrillingOperationsAsync(int idWell, CancellationToken token) - { - var operationsRequest = new WellOperationRequest - { - IdWell = idWell, - OperationCategoryIds = WellOperationCategory.MechanicalDrillingSubIds, - OperationType = WellOperation.IdOperationTypeFact, - SortFields = new[] { nameof(WellOperation.DateStart) } - }; - - var allFactDrillingOperations = await wellOperationRepository.GetAsync(operationsRequest, token); - var factDrillingOperations = allFactDrillingOperations.Where(o => o.DepthEnd > o.DepthStart); - return factDrillingOperations; - } - - private static IEnumerable HandleSection( - IEnumerable sectionOperations, - IEnumerable sectionProcessMap, - IEnumerable telemetryDataStat, - IEnumerable limitingParameters, - IEnumerable subsystemsOperationTime) - { - var minDepth = sectionOperations.Min(o => o.DepthStart); - var maxDepth = sectionOperations.Max(o => o.DepthEnd); - - var depthIntervals = SplitByIntervals(minDepth, maxDepth).ToArray(); - var result = new ProcessMapReportDto[depthIntervals.Length]; - - for (var i = 0; i < depthIntervals.Length; i++ ) - result[i] = MakeProcessMapReportDto(depthIntervals[i], sectionOperations, sectionProcessMap, telemetryDataStat, limitingParameters, subsystemsOperationTime); - - return result; - } - - private static ProcessMapReportDto MakeProcessMapReportDto( - (double min, double max) depthInterval, - IEnumerable sectionOperations, - IEnumerable sectionProcessMap, - IEnumerable telemetryDataStat, - IEnumerable limitingParameters, - IEnumerable subsystemsOperationTime) - { - var dto = new ProcessMapReportDto{ - DepthStart = depthInterval.min - }; - - // TODO: trim items by detpth intervals. Use linear interpolation. - var intervalOperations = sectionOperations.Where(o => o.DepthEnd >= depthInterval.min && o.DepthStart <= depthInterval.max); - var intervalProcessMap = sectionProcessMap.Where(map => map.DepthEnd >= depthInterval.min && map.DepthStart <= depthInterval.max); - var intervalTelemetryDataStat = CalcIntervalTelemetryDataStat(depthInterval, telemetryDataStat); - var intervalLimitingParametrs = limitingParameters.Where(l => l.DepthEnd >= depthInterval.min && l.DepthStart <= depthInterval.max); - var intervalSubsystemsOperationTime = subsystemsOperationTime.Where(o => o.DepthEnd >= depthInterval.min && o.DepthStart <= depthInterval.max); - - var firstIntervalOperation = intervalOperations.FirstOrDefault(); - if (firstIntervalOperation is not null) - { - dto.DateStart = GetInterpolatedDate(firstIntervalOperation, depthInterval.min); - dto.IdWell = firstIntervalOperation.IdWell; - dto.IdWellSectionType = firstIntervalOperation.IdWellSectionType; - dto.WellSectionTypeName = firstIntervalOperation.WellSectionTypeName ?? string.Empty; - dto.MechDrillingHours = CalcHours(depthInterval, intervalOperations); - } - - // TODO: Разделить интервальные коллекции на ротор и слайд. Пока нет готовой методики. - var slideOperations = intervalOperations.Where(o => o.IdCategory == WellOperationCategory.IdSlide); - var rotorOperations = intervalOperations.Where(o => o.IdCategory == WellOperationCategory.IdRotor); - - //dto.Slide = CalcDrillModeStat(depthInterval, slideOperations, intervalProcessMap, intervalTelemetryDataStat, intervalLimitingParametrs, intervalSubsystemsOperationTime); - //dto.Rotor = CalcDrillModeStat(depthInterval, rotorOperations, intervalProcessMap, intervalTelemetryDataStat, intervalLimitingParametrs, intervalSubsystemsOperationTime); - - return dto; - } - - private static TelemetryDataSaubStatDto? CalcIntervalTelemetryDataStat((double min, double max) depthInterval, IEnumerable telemetryDataStat) - { - TelemetryDataSaubStatDto[] data = telemetryDataStat - .Where(d => d.WellDepthMin <= depthInterval.max && d.WellDepthMax >= depthInterval.min) - .ToArray(); - - if (!data.Any()) - return null; - - if (data.Length == 1) - return data.First(); - - var result = new TelemetryDataSaubStatDto - { - WellDepthMin = data.Min(d => d.WellDepthMin), - WellDepthMax = data.Max(d => d.WellDepthMax), - DateMin = data.Min(d => d.DateMin), - DateMax = data.Max(d => d.DateMax), - }; - - var intervalDeltaDepth = result.WellDepthMax - result.WellDepthMin; - - foreach (var item in data) - { - var itemWeight = (item.WellDepthMax - item.WellDepthMin) / intervalDeltaDepth; - - result.Pressure += item.Pressure * itemWeight; - result.PressureSp += item.PressureSp * itemWeight; - result.PressureSpRotor += item.PressureSpSlide * itemWeight; - result.PressureIdle += item.PressureIdle * itemWeight; - result.PressureDelta += item.PressureDelta * itemWeight; - - result.AxialLoad += item.AxialLoad * itemWeight; - result.AxialLoadSp += item.AxialLoadSp * itemWeight; - result.AxialLoadLimitMax += item.AxialLoadLimitMax * itemWeight; - - result.RotorTorque += item.RotorTorque * itemWeight; - result.RotorTorqueSp += item.RotorTorqueSp * itemWeight; - result.RotorTorqueLimitMax += item.RotorTorqueLimitMax * itemWeight; - - result.BlockSpeed += item.BlockSpeed * itemWeight; - result.BlockSpeedSp += item.BlockSpeedSp * itemWeight; - result.BlockSpeedSpRotor += item.BlockSpeedSpRotor * itemWeight; - result.BlockSpeedSpSlide += item.BlockSpeedSpSlide * itemWeight; - } - - return result; - } - - //private static ProcessMapReportRowDto CalcDrillModeStat( - // (double min, double max) depthInterval, - // IEnumerable intervalModeOperations, - // IEnumerable intervalProcessMap, - // TelemetryDataSaubStatDto? telemetryDataStat, - // IEnumerable intervalLimitingParametrs, - // IEnumerable intervalSubsystemsOperationTime) - //{ - // var dto = new ProcessMapReportRowDto(); - // if (intervalModeOperations.Any()) - // { - // var deltaDepth = CalcDeltaDepth(depthInterval, intervalModeOperations); - // dto.DeltaDepth = deltaDepth; - // dto.Rop = deltaDepth / CalcHours(depthInterval, intervalModeOperations); - // }; - - // if (intervalProcessMap.Any()) - // { - // var processMapFirst = intervalProcessMap.First(); - // dto.PressureDiff.SetpointPlan = processMapFirst.Pressure.Plan; - // dto.AxialLoad.SetpointPlan = processMapFirst.AxialLoad.Plan; - // dto.TopDriveTorque.SetpointPlan = processMapFirst.TopDriveTorque.Plan; - // //dto.SpeedLimit.SetpointPlan = null; - // } - - // if (telemetryDataStat is not null) - // { - // dto.PressureDiff.SetpointFact = telemetryDataStat.PressureSp; - // dto.PressureDiff.Fact = telemetryDataStat.PressureDelta; - // dto.PressureDiff.Limit = telemetryDataStat.PressureDeltaLimitMax; - - // dto.AxialLoad.SetpointFact = telemetryDataStat.AxialLoadSp; - // dto.AxialLoad.Fact = telemetryDataStat.AxialLoad; - // dto.AxialLoad.Limit = telemetryDataStat.AxialLoadLimitMax; - - // dto.TopDriveTorque.SetpointFact = telemetryDataStat.RotorTorqueSp; - // dto.TopDriveTorque.Fact = telemetryDataStat.RotorTorque; - // dto.TopDriveTorque.Limit = telemetryDataStat.RotorTorqueLimitMax; - - // dto.SpeedLimit.SetpointFact = telemetryDataStat.BlockSpeedSp; - // dto.SpeedLimit.Fact = telemetryDataStat.BlockSpeed; - // //dto.SpeedLimit.Limit = mull; - // } - - // if(intervalLimitingParametrs.Any()) - // { - // const int idLimParamRop = 1; - // const int idLimParamPressure = 2; - // const int idLimParamAxialLoad = 3; - // const int idLimParamTorque = 4; - - // var intervalLimitingParametrsStat = intervalLimitingParametrs - // .GroupBy(p => p.IdFeedRegulator) - // .Select(g => new - // { - // IdLimParam = g.Key, - // SumDepth = g.Sum(p => p.DepthEnd - p.DepthStart), - // }); - - // var totalDepth = intervalLimitingParametrsStat - // .Sum(s => s.SumDepth); - - // if (totalDepth > 0) - // { - // dto.AxialLoad.PercDrillingSetpoint = intervalLimitingParametrsStat - // .FirstOrDefault(s => s.IdLimParam == idLimParamAxialLoad)?.SumDepth / totalDepth; - - // dto.PressureDiff.PercDrillingSetpoint = intervalLimitingParametrsStat - // .FirstOrDefault(s => s.IdLimParam == idLimParamPressure)?.SumDepth / totalDepth; - - // dto.TopDriveTorque.PercDrillingSetpoint = intervalLimitingParametrsStat - // .FirstOrDefault(s => s.IdLimParam == idLimParamTorque)?.SumDepth / totalDepth; - - // dto.SpeedLimit.PercDrillingSetpoint = intervalLimitingParametrsStat - // .FirstOrDefault(s => s.IdLimParam == idLimParamRop)?.SumDepth / totalDepth; - // } - // } - - // if (intervalSubsystemsOperationTime.Any() && dto.DeltaDepth > 0) - // { - // dto.Usage = intervalSubsystemsOperationTime.Sum(t => t.DepthEnd - t.DepthStart) / dto.DeltaDepth.Value; - // } - - // return dto; - //} - - private static double CalcDeltaDepth((double min, double max) depthInterval, IEnumerable intervalOperations) - { - var ddepth = 0d; - foreach (var operation in intervalOperations) - { - var depthStart = operation.DepthStart > depthInterval.min - ? operation.DepthStart - : depthInterval.min; - - var depthEnd = operation.DepthEnd < depthInterval.max - ? operation.DepthEnd - : depthInterval.max; - - ddepth += (depthEnd - depthEnd); - } - return ddepth; - } - - private static double CalcHours((double min, double max) depthInterval, IEnumerable intervalOperations) - { - var hours = 0d; - foreach (var operation in intervalOperations) - { - var dateStart = operation.DepthStart > depthInterval.min - ? operation.DateStart - : GetInterpolatedDate(operation, depthInterval.min); - - var dateEnd = operation.DepthEnd < depthInterval.max - ? operation.DateStart + TimeSpan.FromHours(operation.DurationHours) - : GetInterpolatedDate(operation, depthInterval.max); - - hours += (dateEnd - dateStart).TotalHours; - } - return hours; - } - - private static DateTime GetInterpolatedDate(WellOperationDto operation, double depth) - { - var ratio = (depth - operation.DepthStart) / (operation.DepthEnd - operation.DepthStart); - var deltaHours = operation.DurationHours * ratio; - var interpolatedDate = operation.DateStart + TimeSpan.FromHours(deltaHours); - return interpolatedDate; - } - - private static IEnumerable<(double min, double max)> SplitByIntervals(double min, double max) - { - const double step = 100; - var iMin = min; - var iMax = (1 + (int)(min / step)) * step; - for (; iMax < max; iMax += step) - { - yield return (iMin, iMax); - iMin = iMax; - } - yield return (iMin, max); - } - } -#nullable disable -} diff --git a/AsbCloudInfrastructure/Services/SAUB/TelemetryDataSaubService.cs b/AsbCloudInfrastructure/Services/SAUB/TelemetryDataSaubService.cs index 0d34b80c..6d9a140b 100644 --- a/AsbCloudInfrastructure/Services/SAUB/TelemetryDataSaubService.cs +++ b/AsbCloudInfrastructure/Services/SAUB/TelemetryDataSaubService.cs @@ -42,10 +42,17 @@ namespace AsbCloudInfrastructure.Services.SAUB .Where(t => t.BlockPosition > 0.0001) .Where(t => t.WellDepth > 0.0001) .Where(t => t.WellDepth - t.BitDepth < 0.01) - .GroupBy(t => new { H = t.DateTime.Hour, W = Math.Truncate(t.WellDepth!.Value) }) + .Where(t => t.Mode != null) + .GroupBy(t => new { + t.DateTime.Hour, + WellDepthX10 = Math.Truncate(t.WellDepth!.Value * 10), + t.Mode, + t.IdFeedRegulator}) .Select(g => new TelemetryDataSaubStatDto { Count = g.Count(), + Mode = g.Key.Mode??0, + IdFeedRegulator = g.Key.IdFeedRegulator, DateMin = DateTime.SpecifyKind(g.Min(t => t.DateTime.UtcDateTime) + timezoneOffset, DateTimeKind.Unspecified), DateMax = DateTime.SpecifyKind(g.Max(t => t.DateTime.UtcDateTime) + timezoneOffset, DateTimeKind.Unspecified), @@ -55,8 +62,6 @@ namespace AsbCloudInfrastructure.Services.SAUB Pressure = g.Average(t => t.Pressure!.Value), PressureSp = g.Average(t => t.PressureSp!.Value), - PressureSpRotor = g.Average(t => t.PressureSpRotor!.Value), - PressureSpSlide = g.Average(t => t.PressureSpSlide!.Value), PressureIdle = g.Average(t => t.PressureIdle!.Value), PressureDeltaLimitMax = g.Average(t => t.PressureDeltaLimitMax!.Value), PressureDelta = g.Average(t => t.Pressure!.Value - t.PressureIdle!.Value), @@ -71,8 +76,6 @@ namespace AsbCloudInfrastructure.Services.SAUB BlockSpeed = g.Average(t => t.BlockSpeed!.Value), BlockSpeedSp = g.Average(t => t.BlockSpeedSp!.Value), - BlockSpeedSpRotor = g.Average(t => t.BlockSpeedSpRotor!.Value), - BlockSpeedSpSlide = g.Average(t => t.BlockSpeedSpSlide!.Value), }) .Where(s => s.WellDepthMin != s.WellDepthMax) .Where(s => s.Count > 3) diff --git a/AsbCloudInfrastructure/Services/WellInfoService.cs b/AsbCloudInfrastructure/Services/WellInfoService.cs index 79d59003..998a40f3 100644 --- a/AsbCloudInfrastructure/Services/WellInfoService.cs +++ b/AsbCloudInfrastructure/Services/WellInfoService.cs @@ -44,7 +44,7 @@ namespace AsbCloudInfrastructure.Services var db = serviceProvider.GetRequiredService(); var wellService = serviceProvider.GetRequiredService(); var operationsStatService = serviceProvider.GetRequiredService(); - var processMapRepository = serviceProvider.GetRequiredService(); + var processMapRepository = serviceProvider.GetRequiredService(); var subsystemOperationTimeService = serviceProvider.GetRequiredService(); var activeWells = await wellService.GetAsync(new() {IdState = 1}, token); diff --git a/AsbCloudWebApi/Controllers/ProcessMapController.cs b/AsbCloudWebApi/Controllers/ProcessMapController.cs index 9f5617a2..3613f32c 100644 --- a/AsbCloudWebApi/Controllers/ProcessMapController.cs +++ b/AsbCloudWebApi/Controllers/ProcessMapController.cs @@ -18,17 +18,17 @@ namespace AsbCloudWebApi.Controllers [ApiController] [Route("api/[controller]")] [Authorize] - public class ProcessMapController : CrudWellRelatedController + public class ProcessMapController : CrudWellRelatedController { private readonly ITelemetryService telemetryService; - private readonly IProcessMapReportService processMapReportService; - private readonly IProcessMapService processMapService; + private readonly IProcessMapReportMakerService processMapReportService; + private readonly IProcessMapReportService processMapService; public ProcessMapController( IWellService wellService, - IProcessMapRepository repository, - IProcessMapReportService processMapReportService, - IProcessMapService processMapService, + IProcessMapPlanRepository repository, + IProcessMapReportMakerService processMapReportService, + IProcessMapReportService processMapService, ITelemetryService telemetryService) : base(wellService, repository) { diff --git a/AsbCloudWebApi/Rest/Example.http b/AsbCloudWebApi/Rest/ProcessMap.http similarity index 66% rename from AsbCloudWebApi/Rest/Example.http rename to AsbCloudWebApi/Rest/ProcessMap.http index bd156b32..9a7d487e 100644 --- a/AsbCloudWebApi/Rest/Example.http +++ b/AsbCloudWebApi/Rest/ProcessMap.http @@ -2,34 +2,12 @@ @contentType = application/json @auth = Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImN0eSI6IkpXVCJ9.eyJpZCI6IjEiLCJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiZGV2IiwiaWRDb21wYW55IjoiMSIsImh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vd3MvMjAwOC8wNi9pZGVudGl0eS9jbGFpbXMvcm9sZSI6InJvb3QiLCJuYmYiOjE2NjI1NDgxNjIsImV4cCI6MTY5NDEwNTc2MiwiaXNzIjoiYSIsImF1ZCI6ImEifQ.OEAlNzxi7Jat6pzDBTAjTbChskc-tdJthJexyWwwUKE +@wellId = 1 + # https://marketplace.visualstudio.com/items?itemName=humao.rest-client ### -GET {{baseUrl}}/api/schedule/test +GET {{baseUrl}}/api/processMap/getDrillProcessMap/{{wellId}} Content-Type: {{contentType}} accept: */* Authorization: {{auth}} - -### -POST {{baseUrl}}/api/schedule/test -Content-Type: {{contentType}} -accept: */* -Authorization: {{auth}} - -{ - "id": 0, - "items": [ - { - "id": 1, - "value": 0.1 - }, - { - "id": 2, - "value": 1. - }, - { - "id": 3, - "value": 2.0 - } - ] -} \ No newline at end of file From be0d171973bc923b785ad3671e3727c7e3af959f Mon Sep 17 00:00:00 2001 From: Olga Nemt Date: Tue, 4 Apr 2023 12:52:11 +0500 Subject: [PATCH 05/16] =?UTF-8?q?=D0=97=D0=B0=D0=BF=D0=B8=D1=81=D1=8C=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5?= =?UTF-8?q?=D0=BB=D1=8F,=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8=D0=B2?= =?UTF-8?q?=D1=88=D0=B5=D0=B3=D0=BE=20/=20=D1=81=D0=BE=D0=B7=D0=B4=D0=B0?= =?UTF-8?q?=D0=B2=D1=88=D0=B5=D0=B3=D0=BE=20=D0=BE=D0=BF=D1=80=D0=B5=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D1=8E=20=D0=B2=20=D0=91=D0=94=20+=20=D0=B7=D0=B0?= =?UTF-8?q?=D0=BF=D0=B8=D1=81=D1=8C=20=D0=B4=D0=B0=D1=82=D1=8B=20=D0=B8?= =?UTF-8?q?=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F=20/=20=D1=81?= =?UTF-8?q?=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Data/{DailyReport => }/ItemInfoDto.cs | 2 +- AsbCloudApp/Data/WellOperationDto.cs | 2 +- AsbCloudApp/Services/IDailyReportService.cs | 5 +- ...rEditor_To_WellOperation_Table.Designer.cs | 7824 +++++++++++++++++ ...1_Add_UserEditor_To_WellOperation_Table.cs | 37 + .../AsbCloudDbContextModelSnapshot.cs | 6 + AsbCloudDb/Model/WellOperation.cs | 2 +- .../Repository/WellOperationRepository.cs | 4 +- .../DailyReport/DailyReportService.cs | 14 +- .../Controllers/DailyReportController.cs | 3 +- .../Controllers/WellOperationController.cs | 6 + 11 files changed, 7894 insertions(+), 11 deletions(-) rename AsbCloudApp/Data/{DailyReport => }/ItemInfoDto.cs (96%) create mode 100644 AsbCloudDb/Migrations/20230404045901_Add_UserEditor_To_WellOperation_Table.Designer.cs create mode 100644 AsbCloudDb/Migrations/20230404045901_Add_UserEditor_To_WellOperation_Table.cs diff --git a/AsbCloudApp/Data/DailyReport/ItemInfoDto.cs b/AsbCloudApp/Data/ItemInfoDto.cs similarity index 96% rename from AsbCloudApp/Data/DailyReport/ItemInfoDto.cs rename to AsbCloudApp/Data/ItemInfoDto.cs index 0c9d9269..95a07e8d 100644 --- a/AsbCloudApp/Data/DailyReport/ItemInfoDto.cs +++ b/AsbCloudApp/Data/ItemInfoDto.cs @@ -1,6 +1,6 @@ using System; -namespace AsbCloudApp.Data.DailyReport +namespace AsbCloudApp.Data { /// /// хранение дополнительной информации о записи diff --git a/AsbCloudApp/Data/WellOperationDto.cs b/AsbCloudApp/Data/WellOperationDto.cs index db7ceab7..35b7cae9 100644 --- a/AsbCloudApp/Data/WellOperationDto.cs +++ b/AsbCloudApp/Data/WellOperationDto.cs @@ -6,7 +6,7 @@ namespace AsbCloudApp.Data /// /// Операции на скважине (заведенные пользователем) /// - public class WellOperationDto : IId, IWellRelated + public class WellOperationDto : ItemInfoDto, IId, IWellRelated { diff --git a/AsbCloudApp/Services/IDailyReportService.cs b/AsbCloudApp/Services/IDailyReportService.cs index 67cfcc4e..66e7bd71 100644 --- a/AsbCloudApp/Services/IDailyReportService.cs +++ b/AsbCloudApp/Services/IDailyReportService.cs @@ -1,4 +1,5 @@ -using AsbCloudApp.Data.DailyReport; +using AsbCloudApp.Data; +using AsbCloudApp.Data.DailyReport; using System; using System.Collections.Generic; using System.IO; @@ -31,7 +32,7 @@ namespace AsbCloudApp.Services /// /// Task AddAsync(int idWell, DateOnly startDate, int idUser, CancellationToken token); - + /// /// Сформировать файл рапорта /// diff --git a/AsbCloudDb/Migrations/20230404045901_Add_UserEditor_To_WellOperation_Table.Designer.cs b/AsbCloudDb/Migrations/20230404045901_Add_UserEditor_To_WellOperation_Table.Designer.cs new file mode 100644 index 00000000..33afd7b9 --- /dev/null +++ b/AsbCloudDb/Migrations/20230404045901_Add_UserEditor_To_WellOperation_Table.Designer.cs @@ -0,0 +1,7824 @@ +// +using System; +using System.Text.Json; +using AsbCloudDb.Model; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace AsbCloudDb.Migrations +{ + [DbContext(typeof(AsbCloudDbContext))] + [Migration("20230404045901_Add_UserEditor_To_WellOperation_Table")] + partial class Add_UserEditor_To_WellOperation_Table + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Russian_Russia.1251") + .HasAnnotation("ProductVersion", "6.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "adminpack"); + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("AsbCloudDb.Model.Cluster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Caption") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("caption") + .HasComment("Название"); + + b.Property("IdDeposit") + .HasColumnType("integer") + .HasColumnName("id_deposit"); + + b.Property("Latitude") + .HasColumnType("double precision") + .HasColumnName("latitude"); + + b.Property("Longitude") + .HasColumnType("double precision") + .HasColumnName("longitude"); + + b.Property("Timezone") + .IsRequired() + .HasColumnType("jsonb") + .HasColumnName("timezone") + .HasComment("Смещение часового пояса от UTC"); + + b.HasKey("Id"); + + b.HasIndex("IdDeposit"); + + b.ToTable("t_cluster"); + + b.HasComment("Кусты"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.Company", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Caption") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("caption"); + + b.Property("IdCompanyType") + .HasMaxLength(255) + .HasColumnType("integer") + .HasColumnName("id_company_type") + .HasComment("вид деятельности"); + + b.HasKey("Id"); + + b.HasIndex("IdCompanyType"); + + b.ToTable("t_company"); + + b.HasData( + new + { + Id = 1, + Caption = "ООО \"АСБ\"", + IdCompanyType = 3 + }); + }); + + modelBuilder.Entity("AsbCloudDb.Model.CompanyType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Caption") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("caption"); + + b.HasKey("Id"); + + b.ToTable("t_company_type"); + + b.HasData( + new + { + Id = 1, + Caption = "Недрапользователь" + }, + new + { + Id = 2, + Caption = "Буровой подрядчик" + }, + new + { + Id = 3, + Caption = "Сервис автоматизации бурения" + }); + }); + + modelBuilder.Entity("AsbCloudDb.Model.DailyReport.DailyReport", b => + { + b.Property("IdWell") + .HasColumnType("integer") + .HasColumnName("id_well") + .HasComment("ID скважины"); + + b.Property("StartDate") + .HasColumnType("date") + .HasColumnName("start_date") + .HasComment("Дата отчёта"); + + b.Property("Info") + .IsRequired() + .HasColumnType("jsonb") + .HasColumnName("info") + .HasComment("Список параметров для отчёта"); + + b.HasKey("IdWell", "StartDate") + .HasName("t_id_well_date_start_pk"); + + b.ToTable("t_daily_report"); + + b.HasComment("Ежедневные отчёты"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.Deposit", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Caption") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("caption"); + + b.Property("Latitude") + .HasColumnType("double precision") + .HasColumnName("latitude"); + + b.Property("Longitude") + .HasColumnType("double precision") + .HasColumnName("longitude"); + + b.Property("Timezone") + .IsRequired() + .HasColumnType("jsonb") + .HasColumnName("timezone") + .HasComment("Смещение часового пояса от UTC"); + + b.HasKey("Id"); + + b.ToTable("t_deposit"); + + b.HasComment("Месторождение"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.DetectedOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DateEnd") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_end") + .HasComment("Дата начала операции"); + + b.Property("DateStart") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_start") + .HasComment("Дата начала операции"); + + b.Property("DepthEnd") + .HasColumnType("double precision") + .HasColumnName("depth_end") + .HasComment("Глубина после завершения операции, м"); + + b.Property("DepthStart") + .HasColumnType("double precision") + .HasColumnName("depth_start") + .HasComment("Глубина на начало операции, м"); + + b.Property("IdCategory") + .HasColumnType("integer") + .HasColumnName("id_category") + .HasComment("Id категории операции"); + + b.Property("IdReasonOfEnd") + .HasColumnType("integer") + .HasColumnName("id_reason_of_end") + .HasComment("Код признака окончания операции"); + + b.Property("IdTelemetry") + .HasColumnType("integer") + .HasColumnName("id_telemetry"); + + b.Property("IdUsersAtStart") + .HasColumnType("integer") + .HasColumnName("id_user") + .HasComment("Id пользователя по телеметрии на момент начала операции"); + + b.Property("Value") + .HasColumnType("double precision") + .HasColumnName("value") + .HasComment("Ключевой показатель операции"); + + b.HasKey("Id"); + + b.HasIndex("IdCategory"); + + b.HasIndex("IdTelemetry"); + + b.ToTable("t_detected_operation"); + + b.HasComment("автоматически определенные операции по телеметрии"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.Driller", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id") + .HasComment("Идентификатор"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("name") + .HasComment("Имя"); + + b.Property("Patronymic") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("patronymic") + .HasComment("Отчество"); + + b.Property("Surname") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("surname") + .HasComment("Фамилия"); + + b.HasKey("Id"); + + b.ToTable("t_driller"); + + b.HasComment("Бурильщик"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.DrillingProgramPart", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("IdFileCategory") + .HasColumnType("integer") + .HasColumnName("id_file_category"); + + b.Property("IdWell") + .HasColumnType("integer") + .HasColumnName("id_well"); + + b.HasKey("Id"); + + b.HasIndex("IdFileCategory"); + + b.HasIndex("IdWell", "IdFileCategory") + .IsUnique(); + + b.ToTable("t_drilling_program_part"); + + b.HasComment("части программ бурения"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.FileCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("text") + .HasColumnName("name") + .HasComment("Название категории"); + + b.Property("ShortName") + .HasColumnType("text") + .HasColumnName("short_name") + .HasComment("Короткое название категории"); + + b.HasKey("Id"); + + b.ToTable("t_file_category"); + + b.HasComment("Категории файлов"); + + b.HasData( + new + { + Id = 1, + Name = "Растворный сервис", + ShortName = "fluidService" + }, + new + { + Id = 2, + Name = "Цементирование", + ShortName = "cement" + }, + new + { + Id = 3, + Name = "ННБ", + ShortName = "nnb" + }, + new + { + Id = 4, + Name = "ГТИ", + ShortName = "gti" + }, + new + { + Id = 5, + Name = "Документы по скважине", + ShortName = "wellDocuments" + }, + new + { + Id = 6, + Name = "Супервайзер", + ShortName = "supervisor" + }, + new + { + Id = 7, + Name = "Мастер", + ShortName = "master" + }, + new + { + Id = 8, + Name = "Долотный сервис", + ShortName = "toolService" + }, + new + { + Id = 9, + Name = "Буровой подрядчик", + ShortName = "drillService" + }, + new + { + Id = 10, + Name = "Сервис по заканчиванию скважины", + ShortName = "closingService" + }, + new + { + Id = 12, + Name = "Рапорт", + ShortName = "report" + }, + new + { + Id = 1000, + Name = "Программа бурения" + }, + new + { + Id = 1001, + Name = "Задание от геологов" + }, + new + { + Id = 1002, + Name = "Профиль ствола скважины (ННБ)" + }, + new + { + Id = 1003, + Name = "Технологические расчеты (ННБ)" + }, + new + { + Id = 1004, + Name = "Долотная программа" + }, + new + { + Id = 1005, + Name = "Программа по растворам" + }, + new + { + Id = 1006, + Name = "Программа геофизических исследований" + }, + new + { + Id = 1007, + Name = "Планы спусков обсадных колонн" + }, + new + { + Id = 1008, + Name = "Программы цементирования обсадных колонн" + }, + new + { + Id = 10000, + Name = "Проект на бурение транспортного и горизонтального участков скважины" + }, + new + { + Id = 10001, + Name = "Программа на бурение транспортного и горизонтального участков скважины" + }, + new + { + Id = 10002, + Name = "Акт о начале бурения" + }, + new + { + Id = 10003, + Name = "План работ спуска и цементирования направления" + }, + new + { + Id = 10004, + Name = "Программа цементирования направления" + }, + new + { + Id = 10005, + Name = "Мера обсадных труб (направление)" + }, + new + { + Id = 10006, + Name = "Акт на выполненные работы по цементированию направления" + }, + new + { + Id = 10007, + Name = "Отчет по цементированию направления (график)" + }, + new + { + Id = 10008, + Name = "План работ спуска и цементирования кондуктора" + }, + new + { + Id = 10009, + Name = "Программа цементирования (кондуктор)" + }, + new + { + Id = 10010, + Name = "Мера обсадных труб (кондуктор)" + }, + new + { + Id = 10011, + Name = "Карта крепления кондуктора" + }, + new + { + Id = 10012, + Name = "Акт на выполненные работы по цементированию кондуктора" + }, + new + { + Id = 10013, + Name = "Отчет по цементированию кондуктора (график)" + }, + new + { + Id = 10014, + Name = "Акт о замере расстояния от стола ротора до муфты кондуктора" + }, + new + { + Id = 10015, + Name = "Акт опресовки цементного кольца за кондуктором" + }, + new + { + Id = 10016, + Name = "Акт опресовки ППГ с глухими плашками совместно с кондуктором" + }, + new + { + Id = 10017, + Name = "Акт опресовки ПУГ, ППГ с трубными плашками совместно с кондуктором" + }, + new + { + Id = 10018, + Name = "План работ на крепление обсадной колонны (эк. колонна)" + }, + new + { + Id = 10019, + Name = "Программа цементирования (эк. колонна)" + }, + new + { + Id = 10020, + Name = "Мера труб эксплуатационной колонны" + }, + new + { + Id = 10021, + Name = "Карта по креплению скважины (эк. колонна)" + }, + new + { + Id = 10022, + Name = "Акт на установку пружинных центраторов" + }, + new + { + Id = 10023, + Name = "Отчет по цементированию эксплуатационной колонны (график)" + }, + new + { + Id = 10024, + Name = "Акт на выполненные работы по цементированию эксплуатационной колонны" + }, + new + { + Id = 10025, + Name = "Акт об испытании эк. колонны на герметичность (СТОП)" + }, + new + { + Id = 10026, + Name = "Акт опресовки ППГ с глухими плашками совместно с э/колонной" + }, + new + { + Id = 10027, + Name = "Акт опресовки ПУГ, ППГ с трубными плашками совместно с э/колонной" + }, + new + { + Id = 10028, + Name = "Акт на вскрытие продуктивного пласта" + }, + new + { + Id = 10029, + Name = "Акт замера параметров раствора при бурении горизонтального участка" + }, + new + { + Id = 10030, + Name = "Разрешение на спуск «хвостовика» (телефонограмма)" + }, + new + { + Id = 10031, + Name = "План работ на спуск «хвостовика»" + }, + new + { + Id = 10032, + Name = "Акт готовности бурового и энергетического оборудования к спуску «хвостовика»" + }, + new + { + Id = 10033, + Name = "Акт шаблонировки ствола скважины перед спуском «хвостовика»" + }, + new + { + Id = 10034, + Name = "Мера обсадных труб (хвостовик)" + }, + new + { + Id = 10035, + Name = "Акт выполненных работ по спуску хвостовика с закачкой (нефти, солевого раствора" + }, + new + { + Id = 10036, + Name = "Акт о переводе скважины на тех. воду" + }, + new + { + Id = 10037, + Name = "Акт об окончании бурения" + }, + new + { + Id = 10038, + Name = "Акт на передачу скважины в освоение (КРС)" + }, + new + { + Id = 10039, + Name = "Акт на опресовку межколонного пространства с КРС" + }, + new + { + Id = 10040, + Name = "Акт на сдачу скважины в ЦДНГ" + }, + new + { + Id = 10041, + Name = "Паспорт ОУС (заполняется геологами)" + }, + new + { + Id = 10042, + Name = "Паспорт скважины (заполняется геологами)" + }, + new + { + Id = 10043, + Name = "Фактические данные бурения (вставляются в паспорт скважины)" + }); + }); + + modelBuilder.Entity("AsbCloudDb.Model.FileInfo", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("IdAuthor") + .HasColumnType("integer") + .HasColumnName("id_author") + .HasComment("Id пользователя, загрузившего файл"); + + b.Property("IdCategory") + .HasColumnType("integer") + .HasColumnName("id_category") + .HasComment("id категории файла"); + + b.Property("IdWell") + .HasColumnType("integer") + .HasColumnName("id_well") + .HasComment("id скважины"); + + b.Property("IsDeleted") + .HasColumnType("boolean") + .HasColumnName("is_deleted") + .HasComment("Удален ли файл"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text") + .HasColumnName("name") + .HasComment("Название файла"); + + b.Property("Size") + .HasColumnType("bigint") + .HasColumnName("file_size") + .HasComment("Размер файла"); + + b.Property("UploadDate") + .HasColumnType("timestamp with time zone") + .HasColumnName("date"); + + b.HasKey("Id"); + + b.HasIndex("IdAuthor"); + + b.HasIndex("IdCategory"); + + b.HasIndex("IdWell"); + + b.ToTable("t_file_info"); + + b.HasComment("Файлы всех категорий"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.FileMark", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Comment") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("comment") + .HasComment("Комментарий"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_created") + .HasComment("Дата совершенного действия"); + + b.Property("IdFile") + .HasColumnType("integer") + .HasColumnName("id_file") + .HasComment("id файла"); + + b.Property("IdMarkType") + .HasColumnType("integer") + .HasColumnName("id_mark_type") + .HasComment("0 - отклонен, 1 - согласован"); + + b.Property("IdUser") + .HasColumnType("integer") + .HasColumnName("id_user") + .HasComment("id пользователя"); + + b.Property("IsDeleted") + .HasColumnType("boolean") + .HasColumnName("is_deleted") + .HasComment("Помечен ли файл как удаленный"); + + b.HasKey("Id"); + + b.HasIndex("IdFile"); + + b.HasIndex("IdUser"); + + b.ToTable("t_file_mark"); + + b.HasComment("Действия с файлами."); + }); + + modelBuilder.Entity("AsbCloudDb.Model.LimitingParameter", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DateEnd") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_end"); + + b.Property("DateStart") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_start"); + + b.Property("DepthEnd") + .HasColumnType("real") + .HasColumnName("depth_end"); + + b.Property("DepthStart") + .HasColumnType("real") + .HasColumnName("depth_start"); + + b.Property("IdFeedRegulator") + .HasColumnType("smallint") + .HasColumnName("id_feed_regulator"); + + b.Property("IdTelemetry") + .HasColumnType("integer") + .HasColumnName("id_telemetry"); + + b.HasKey("Id"); + + b.HasIndex("IdTelemetry"); + + b.ToTable("t_limiting_parameter"); + + b.HasComment("Ограничения по параметрам телеметрии"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.Measure", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Data") + .IsRequired() + .HasColumnType("jsonb") + .HasColumnName("data") + .HasComment("Данные таблицы последних данных"); + + b.Property("IdCategory") + .HasColumnType("integer") + .HasColumnName("id_category") + .HasComment("id категории"); + + b.Property("IdWell") + .HasColumnType("integer") + .HasColumnName("id_well") + .HasComment("id скважины"); + + b.Property("IsDeleted") + .HasColumnType("boolean") + .HasColumnName("is_deleted") + .HasComment("Пометка удаленным"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone") + .HasColumnName("timestamp") + .HasComment("время добавления"); + + b.HasKey("Id"); + + b.HasIndex("IdCategory"); + + b.HasIndex("IdWell"); + + b.ToTable("t_measure"); + + b.HasComment("Таблица c данными для вкладки 'Последние данные'"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.MeasureCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("text") + .HasColumnName("name") + .HasComment("Название категории"); + + b.Property("ShortName") + .HasColumnType("text") + .HasColumnName("short_name") + .HasComment("Короткое название категории"); + + b.HasKey("Id"); + + b.ToTable("t_measure_category"); + + b.HasComment("Категория последних данных"); + + b.HasData( + new + { + Id = 1, + Name = "Показатели бурового раствора", + ShortName = "Раствор" + }, + new + { + Id = 2, + Name = "Шламограмма", + ShortName = "Шламограмма" + }, + new + { + Id = 3, + Name = "ННБ", + ShortName = "ННБ" + }); + }); + + modelBuilder.Entity("AsbCloudDb.Model.OperationValue", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id") + .HasComment("Идентификатор"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DepthEnd") + .HasColumnType("double precision") + .HasColumnName("depth_end") + .HasComment("Конечная глубина"); + + b.Property("DepthStart") + .HasColumnType("double precision") + .HasColumnName("depth_start") + .HasComment("Старотовая глубина"); + + b.Property("IdOperationCategory") + .HasColumnType("integer") + .HasColumnName("id_operation_category") + .HasComment("Ид категории операции"); + + b.Property("IdWell") + .HasColumnType("integer") + .HasColumnName("id_well") + .HasComment("Ид скважины"); + + b.Property("StandardValue") + .HasColumnType("double precision") + .HasColumnName("standard_value") + .HasComment("Нормативный показатель"); + + b.Property("TargetValue") + .HasColumnType("double precision") + .HasColumnName("target_value") + .HasComment("Целевой показатель"); + + b.HasKey("Id"); + + b.HasIndex("IdOperationCategory"); + + b.HasIndex("IdWell"); + + b.ToTable("t_operationvalue"); + + b.HasComment("Целевые/нормативные показатели операции"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.Permission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Description") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("description") + .HasComment("Краткое описание"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("name") + .HasComment("Название"); + + b.HasKey("Id"); + + b.ToTable("t_permission"); + + b.HasComment("Разрешения на доступ к данным"); + + b.HasData( + new + { + Id = 100, + Description = "Разрешение удалять админ. Кусты", + Name = "AdminCluster.delete" + }, + new + { + Id = 101, + Description = "Разрешение редактировать админ. Кусты", + Name = "AdminCluster.edit" + }, + new + { + Id = 102, + Description = "Разрешение просматривать админ. Кусты", + Name = "AdminCluster.get" + }, + new + { + Id = 103, + Description = "Разрешение удалять админ. Компании", + Name = "AdminCompany.delete" + }, + new + { + Id = 104, + Description = "Разрешение редактировать админ. Компании", + Name = "AdminCompany.edit" + }, + new + { + Id = 105, + Description = "Разрешение просматривать админ. Компании", + Name = "AdminCompany.get" + }, + new + { + Id = 106, + Description = "Разрешение удалять админ. Типы компаний", + Name = "AdminCompanyType.delete" + }, + new + { + Id = 107, + Description = "Разрешение редактировать админ. Типы компаний", + Name = "AdminCompanyType.edit" + }, + new + { + Id = 108, + Description = "Разрешение просматривать админ. Типы компаний", + Name = "AdminCompanyType.get" + }, + new + { + Id = 109, + Description = "Разрешение удалять админ. Месторождения", + Name = "AdminDeposit.delete" + }, + new + { + Id = 110, + Description = "Разрешение редактировать админ. Месторождения", + Name = "AdminDeposit.edit" + }, + new + { + Id = 111, + Description = "Разрешение просматривать админ. Месторождения", + Name = "AdminDeposit.get" + }, + new + { + Id = 112, + Description = "Разрешение удалять админ. Разрешения", + Name = "AdminPermission.delete" + }, + new + { + Id = 113, + Description = "Разрешение редактировать админ. Разрешения", + Name = "AdminPermission.edit" + }, + new + { + Id = 114, + Description = "Разрешение просматривать админ. Разрешения", + Name = "AdminPermission.get" + }, + new + { + Id = 115, + Description = "Разрешение удалять админ. Телеметрию", + Name = "AdminTelemetry.delete" + }, + new + { + Id = 116, + Description = "Разрешение редактировать админ. Телеметрию", + Name = "AdminTelemetry.edit" + }, + new + { + Id = 117, + Description = "Разрешение просматривать админ. Телеметрию", + Name = "AdminTelemetry.get" + }, + new + { + Id = 118, + Description = "Разрешение удалять админ. Пользователей", + Name = "AdminUser.delete" + }, + new + { + Id = 119, + Description = "Разрешение редактировать админ. Пользователей", + Name = "AdminUser.edit" + }, + new + { + Id = 120, + Description = "Разрешение просматривать админ. Пользователей", + Name = "AdminUser.get" + }, + new + { + Id = 121, + Description = "Разрешение удалять админ. Роли пользователей", + Name = "AdminUserRole.delete" + }, + new + { + Id = 122, + Description = "Разрешение редактировать админ. Роли пользователей", + Name = "AdminUserRole.edit" + }, + new + { + Id = 123, + Description = "Разрешение просматривать админ. Роли пользователей", + Name = "AdminUserRole.get" + }, + new + { + Id = 124, + Description = "Разрешение удалять админ. Скважины", + Name = "AdminWell.delete" + }, + new + { + Id = 125, + Description = "Разрешение редактировать админ. Скважины", + Name = "AdminWell.edit" + }, + new + { + Id = 126, + Description = "Разрешение просматривать админ. Скважины", + Name = "AdminWell.get" + }, + new + { + Id = 127, + Description = "Разрешение удалять админ. Подсистемы", + Name = "AdminSubsytem.delete" + }, + new + { + Id = 128, + Description = "Разрешение редактировать админ. Подсистемы", + Name = "AdminSubsytem.edit" + }, + new + { + Id = 129, + Description = "Разрешение просматривать админ. Подсистемы", + Name = "AdminSubsytem.get" + }, + new + { + Id = 200, + Description = "Разрешение редактировать 0", + Name = "Auth.edit" + }, + new + { + Id = 201, + Description = "Разрешение просматривать 0", + Name = "Auth.get" + }, + new + { + Id = 202, + Description = "Разрешение просматривать Кусты", + Name = "Cluster.get" + }, + new + { + Id = 203, + Description = "Разрешение просматривать Месторождения", + Name = "Deposit.get" + }, + new + { + Id = 204, + Description = "Разрешение удалять РТК", + Name = "DrillFlowChart.delete" + }, + new + { + Id = 205, + Description = "Разрешение редактировать РТК", + Name = "DrillFlowChart.edit" + }, + new + { + Id = 206, + Description = "Разрешение просматривать РТК", + Name = "DrillFlowChart.get" + }, + new + { + Id = 207, + Description = "Разрешение удалять Программу бурения", + Name = "DrillingProgram.delete" + }, + new + { + Id = 208, + Description = "Разрешение редактировать Программу бурения", + Name = "DrillingProgram.edit" + }, + new + { + Id = 209, + Description = "Разрешение просматривать Программу бурения", + Name = "DrillingProgram.get" + }, + new + { + Id = 210, + Description = "Разрешение удалять Режимы бурения", + Name = "DrillParams.delete" + }, + new + { + Id = 211, + Description = "Разрешение редактировать Режимы бурения", + Name = "DrillParams.edit" + }, + new + { + Id = 212, + Description = "Разрешение просматривать Режимы бурения", + Name = "DrillParams.get" + }, + new + { + Id = 213, + Description = "Разрешение удалять Файлы", + Name = "File.delete" + }, + new + { + Id = 214, + Description = "Разрешение редактировать Файлы", + Name = "File.edit" + }, + new + { + Id = 215, + Description = "Разрешение просматривать Файлы", + Name = "File.get" + }, + new + { + Id = 216, + Description = "Разрешение удалять Измерения", + Name = "Measure.delete" + }, + new + { + Id = 217, + Description = "Разрешение редактировать Измерения", + Name = "Measure.edit" + }, + new + { + Id = 218, + Description = "Разрешение просматривать Измерения", + Name = "Measure.get" + }, + new + { + Id = 219, + Description = "Разрешение просматривать Сообщения телеметрии", + Name = "Message.get" + }, + new + { + Id = 220, + Description = "Разрешение просматривать Статистику по операциям", + Name = "OperationStat.get" + }, + new + { + Id = 221, + Description = "Разрешение редактировать Рапорта", + Name = "Report.edit" + }, + new + { + Id = 222, + Description = "Разрешение просматривать Рапорта", + Name = "Report.get" + }, + new + { + Id = 223, + Description = "Разрешение просматривать админ. Системная статистика", + Name = "RequestTracker.get" + }, + new + { + Id = 224, + Description = "Разрешение удалять Рекомендации уставок", + Name = "Setpoints.delete" + }, + new + { + Id = 225, + Description = "Разрешение редактировать Рекомендации уставок", + Name = "Setpoints.edit" + }, + new + { + Id = 226, + Description = "Разрешение просматривать Рекомендации уставок", + Name = "Setpoints.get" + }, + new + { + Id = 227, + Description = "Разрешение редактировать Телеметрии", + Name = "Telemetry.edit" + }, + new + { + Id = 228, + Description = "Разрешение просматривать Анализ телеметрии", + Name = "TelemetryAnalytics.get" + }, + new + { + Id = 229, + Description = "Разрешение редактировать Данные телеметрии по САУБ", + Name = "TelemetryDataSaub.edit" + }, + new + { + Id = 230, + Description = "Разрешение просматривать Данные телеметрии по САУБ", + Name = "TelemetryDataSaub.get" + }, + new + { + Id = 231, + Description = "Разрешение редактировать Данные телеметрии по SpinMaster", + Name = "TelemetryDataSpin.edit" + }, + new + { + Id = 232, + Description = "Разрешение просматривать Данные телеметрии по SpinMaster", + Name = "TelemetryDataSpin.get" + }, + new + { + Id = 233, + Description = "Разрешение редактировать Скважины", + Name = "Well.edit" + }, + new + { + Id = 234, + Description = "Разрешение просматривать Скважины", + Name = "Well.get" + }, + new + { + Id = 235, + Description = "Разрешение редактировать Композитные скважины", + Name = "WellComposite.edit" + }, + new + { + Id = 236, + Description = "Разрешение просматривать Композитные скважины", + Name = "WellComposite.get" + }, + new + { + Id = 237, + Description = "Разрешение удалять Операции по скважинам", + Name = "WellOperation.delete" + }, + new + { + Id = 238, + Description = "Разрешение редактировать Операции по скважинам", + Name = "WellOperation.edit" + }, + new + { + Id = 239, + Description = "Разрешение просматривать Операции по скважинам", + Name = "WellOperation.get" + }, + new + { + Id = 240, + Description = "Разрешение редактировать Файлы категории 1 (Растворный сервис)", + Name = "File.edit1" + }, + new + { + Id = 241, + Description = "Разрешение редактировать Файлы категории 2 (Цементирование)", + Name = "File.edit2" + }, + new + { + Id = 242, + Description = "Разрешение редактировать Файлы категории 3 (ННБ)", + Name = "File.edit3" + }, + new + { + Id = 243, + Description = "Разрешение редактировать Файлы категории 4 (ГТИ)", + Name = "File.edit4" + }, + new + { + Id = 244, + Description = "Разрешение редактировать Файлы категории 5 (Документы по скважине)", + Name = "File.edit5" + }, + new + { + Id = 245, + Description = "Разрешение редактировать Файлы категории 6 (Супервайзер)", + Name = "File.edit6" + }, + new + { + Id = 246, + Description = "Разрешение редактировать Файлы категории 7 (Мастер)", + Name = "File.edit7" + }, + new + { + Id = 247, + Description = "Разрешение редактировать Файлы категории 8 (Долотный сервис)", + Name = "File.edit8" + }, + new + { + Id = 248, + Description = "Разрешение редактировать Файлы категории 9 (Буровой подрядчик)", + Name = "File.edit9" + }, + new + { + Id = 249, + Description = "Разрешение редактировать Файлы категории 10 (Сервис по заканчиванию скважины)", + Name = "File.edit10" + }, + new + { + Id = 250, + Description = "Разрешение редактировать Файлы категории 11 (Рапорт)", + Name = "File.edit11" + }, + new + { + Id = 251, + Description = "Разрешение редактировать Файлы категории 12", + Name = "File.edit12" + }, + new + { + Id = 252, + Description = "Разрешение редактировать Файлы категории 12", + Name = "File.edit13" + }, + new + { + Id = 253, + Description = "Разрешение редактировать Файлы категории 13", + Name = "File.edit14" + }, + new + { + Id = 254, + Description = "Разрешение редактировать Файлы категории 14", + Name = "File.edit15" + }, + new + { + Id = 255, + Description = "Разрешение редактировать Файлы категории 15", + Name = "File.edit16" + }, + new + { + Id = 256, + Description = "Разрешение редактировать Файлы категории 16", + Name = "File.edit17" + }, + new + { + Id = 257, + Description = "Разрешение редактировать Файлы категории 17", + Name = "File.edit18" + }, + new + { + Id = 258, + Description = "Разрешение редактировать Файлы категории 18", + Name = "File.edit19" + }, + new + { + Id = 259, + Description = "Разрешение редактировать Файлы категории 19", + Name = "File.edit20" + }, + new + { + Id = 260, + Description = "Разрешение редактировать Файлы категории 20", + Name = "File.edit21" + }, + new + { + Id = 261, + Description = "Разрешение редактировать Файлы категории 21", + Name = "File.edit22" + }, + new + { + Id = 262, + Description = "Разрешение редактировать Файлы категории 22", + Name = "File.edit23" + }, + new + { + Id = 263, + Description = "Разрешение редактировать Файлы категории 23", + Name = "File.edit24" + }, + new + { + Id = 264, + Description = "Разрешение редактировать Файлы категории 24", + Name = "File.edit25" + }, + new + { + Id = 265, + Description = "Разрешение редактировать Файлы категории 25", + Name = "File.edit26" + }, + new + { + Id = 266, + Description = "Разрешение редактировать Файлы категории 26", + Name = "File.edit27" + }, + new + { + Id = 267, + Description = "Разрешение редактировать Файлы категории 27", + Name = "File.edit28" + }, + new + { + Id = 268, + Description = "Разрешение редактировать Файлы категории 28", + Name = "File.edit29" + }, + new + { + Id = 269, + Description = "Разрешение редактировать Файлы категории 29", + Name = "File.edit30" + }, + new + { + Id = 380, + Description = "Разрешение просматривать список бурильщиков", + Name = "Driller.get" + }, + new + { + Id = 381, + Description = "Разрешение редактировать бурильщика", + Name = "Driller.edit" + }, + new + { + Id = 382, + Description = "Разрешение удалять бурильщик", + Name = "Driller.delete" + }, + new + { + Id = 383, + Description = "Разрешение просматривать графики бурильщиков", + Name = "Schedule.get" + }, + new + { + Id = 384, + Description = "Разрешение редактировать график бурильщика", + Name = "Schedule.edit" + }, + new + { + Id = 385, + Description = "Разрешение удалять график бурильщика", + Name = "Schedule.delete" + }, + new + { + Id = 386, + Description = "Разрешение просматривать суточный рапорт", + Name = "DailyReport.get" + }, + new + { + Id = 387, + Description = "Разрешение редактировать суточный рапорт", + Name = "DailyReport.edit" + }, + new + { + Id = 388, + Description = "Разрешение просматривать авто. определенные операции", + Name = "DetectedOperation.get" + }, + new + { + Id = 389, + Description = "Разрешение просматривать целевые значения", + Name = "OperationValue.get" + }, + new + { + Id = 390, + Description = "Разрешение редактировать целевые значения", + Name = "OperationValue.edit" + }, + new + { + Id = 391, + Description = "Разрешение удалять целевые значения", + Name = "OperationValue.delete" + }, + new + { + Id = 400, + Description = "Разрешение просматривать инфо по wits параметрам", + Name = "WitsInfo.get" + }, + new + { + Id = 401, + Description = "Разрешение просматривать WITS record 1", + Name = "WitsRecord1.get" + }, + new + { + Id = 407, + Description = "Разрешение просматривать WITS record 7", + Name = "WitsRecord7.get" + }, + new + { + Id = 408, + Description = "Разрешение просматривать WITS record 8", + Name = "WitsRecord8.get" + }, + new + { + Id = 450, + Description = "Разрешение просматривать WITS record 50", + Name = "WitsRecord50.get" + }, + new + { + Id = 460, + Description = "Разрешение просматривать WITS record 60", + Name = "WitsRecord60.get" + }, + new + { + Id = 461, + Description = "Разрешение просматривать WITS record 61", + Name = "WitsRecord61.get" + }, + new + { + Id = 500, + Description = "Разрешение удалять Категорий документов файлов", + Name = "FileCategory.delete" + }, + new + { + Id = 501, + Description = "Разрешение редактировать Категорий документов файлов", + Name = "FileCategory.edit" + }, + new + { + Id = 502, + Description = "Разрешение просматривать Категорий документов файлов", + Name = "FileCategory.get" + }, + new + { + Id = 503, + Description = "Разрешение удалять Дело скважины", + Name = "WellFinalDocuments.delete" + }, + new + { + Id = 504, + Description = "Разрешение редактировать Дело скважины", + Name = "WellFinalDocuments.edit" + }, + new + { + Id = 505, + Description = "Разрешение просматривать Дело скважины", + Name = "WellFinalDocuments.get" + }, + new + { + Id = 506, + Description = "Разрешение редактировать ответственных за загрузку файла Дело скважины", + Name = "WellFinalDocuments.editPublisher" + }, + new + { + Id = 507, + Description = "Разрешение просматривать наработка талевого каната", + Name = "TelemetryWirelineRunOut.get" + }, + new + { + Id = 510, + Description = "Разрешение просматривать плановая траектория", + Name = "PlannedTrajectory.get" + }, + new + { + Id = 511, + Description = "Разрешение редактировать плановая траектория", + Name = "PlannedTrajectory.edit" + }, + new + { + Id = 512, + Description = "Разрешение удалять плановая траектория", + Name = "PlannedTrajectory.delete" + }, + new + { + Id = 513, + Description = "Разрешение просматривать РТК", + Name = "ProcessMap.get" + }, + new + { + Id = 514, + Description = "Разрешение редактировать РТК", + Name = "ProcessMap.edit" + }, + new + { + Id = 515, + Description = "Разрешение удалять РТК", + Name = "ProcessMap.delete" + }); + }); + + modelBuilder.Entity("AsbCloudDb.Model.PlannedTrajectory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AbsoluteMark") + .HasColumnType("double precision") + .HasColumnName("absolute_mark") + .HasComment("Абсолютная отметка"); + + b.Property("AngleIntensity") + .HasColumnType("double precision") + .HasColumnName("angle_intensity") + .HasComment("Интенсивность по углу"); + + b.Property("AzimuthGeo") + .HasColumnType("double precision") + .HasColumnName("azimuth_geo") + .HasComment("Азимут Географ."); + + b.Property("AzimuthIntensity") + .HasColumnType("double precision") + .HasColumnName("azimuth_intensity") + .HasComment("Интенсивность по азимуту"); + + b.Property("AzimuthMagnetic") + .HasColumnType("double precision") + .HasColumnName("azimuth_magnetic") + .HasComment("Азимут Магнитный"); + + b.Property("Comment") + .HasColumnType("text") + .HasColumnName("comment") + .HasComment("Комментарии"); + + b.Property("EastCartographic") + .HasColumnType("double precision") + .HasColumnName("east_cartographic") + .HasComment("Восток картографический"); + + b.Property("EastOrifice") + .HasColumnType("double precision") + .HasColumnName("east_orifice") + .HasComment("Восток отн-но устья"); + + b.Property("IdUser") + .HasColumnType("integer") + .HasColumnName("id_user") + .HasComment("ID пользователя который внес/изменил запись"); + + b.Property("IdWell") + .HasColumnType("integer") + .HasColumnName("id_well") + .HasComment("ID скважины"); + + b.Property("NorthCartographic") + .HasColumnType("double precision") + .HasColumnName("north_cartographic") + .HasComment("Север картографический"); + + b.Property("NorthOrifice") + .HasColumnType("double precision") + .HasColumnName("north_orifice") + .HasComment("Север отн-но устья"); + + b.Property("OrificeOffset") + .HasColumnType("double precision") + .HasColumnName("orifice_offset") + .HasComment("Смещение от устья"); + + b.Property("SpatialIntensity") + .HasColumnType("double precision") + .HasColumnName("spatial_intensity") + .HasComment("Пространственная интенсивность"); + + b.Property("UpdateDate") + .HasColumnType("timestamp with time zone") + .HasColumnName("update_date") + .HasComment("Дата загрузки траектории"); + + b.Property("VerticalDepth") + .HasColumnType("double precision") + .HasColumnName("vertical_depth") + .HasComment("Глубина вертикальная"); + + b.Property("WellboreDepth") + .HasColumnType("double precision") + .HasColumnName("wellbore_depth") + .HasComment("Глубина по стволу"); + + b.Property("ZenithAngle") + .HasColumnType("double precision") + .HasColumnName("zenith_angle") + .HasComment("Угол зенитный"); + + b.HasKey("Id"); + + b.HasIndex("IdUser"); + + b.HasIndex("IdWell"); + + b.ToTable("t_planned_trajectory"); + + b.HasComment("Загрузка плановой траектории"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.ProcessMap", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AxialLoadLimitMax") + .HasColumnType("double precision") + .HasColumnName("axial_load_limit_max") + .HasComment("Нагрузка, допустимый максимум"); + + b.Property("AxialLoadPlan") + .HasColumnType("double precision") + .HasColumnName("axial_load_plan") + .HasComment("Нагрузка, план"); + + b.Property("DepthEnd") + .HasColumnType("double precision") + .HasColumnName("depth_end") + .HasComment("Глубина окончания интервала"); + + b.Property("DepthStart") + .HasColumnType("double precision") + .HasColumnName("depth_start") + .HasComment("Стартовая глубина"); + + b.Property("FlowLimitMax") + .HasColumnType("double precision") + .HasColumnName("flow_limit_max") + .HasComment("Расход, допустимый максимум"); + + b.Property("FlowPlan") + .HasColumnType("double precision") + .HasColumnName("flow_plan") + .HasComment("Расход, план"); + + b.Property("IdMode") + .HasColumnType("integer") + .HasColumnName("id_mode") + .HasComment("Id режима (1- ротор, 2 слайд)"); + + b.Property("IdUser") + .HasColumnType("integer") + .HasColumnName("id_user") + .HasComment("Id пользователя"); + + b.Property("IdWell") + .HasColumnType("integer") + .HasColumnName("well_id") + .HasComment("Id скважины"); + + b.Property("IdWellSectionType") + .HasColumnType("integer") + .HasColumnName("id_wellsection_type") + .HasComment("Тип секции"); + + b.Property("LastUpdate") + .HasColumnType("timestamp with time zone") + .HasColumnName("last_update") + .HasComment("Дата последнего изменения"); + + b.Property("PressureLimitMax") + .HasColumnType("double precision") + .HasColumnName("pressure_limit_max") + .HasComment("Перепад давления, допустимый максимум"); + + b.Property("PressurePlan") + .HasColumnType("double precision") + .HasColumnName("pressure_plan") + .HasComment("Перепад давления, план"); + + b.Property("RopPlan") + .HasColumnType("double precision") + .HasColumnName("rop_plan") + .HasComment("Плановая механическая скорость, м/ч"); + + b.Property("TopDriveSpeedLimitMax") + .HasColumnType("double precision") + .HasColumnName("top_drive_speed_limit_max") + .HasComment("Обороты на ВСП, допустимый максимум"); + + b.Property("TopDriveSpeedPlan") + .HasColumnType("double precision") + .HasColumnName("top_drive_speed_plan") + .HasComment("Обороты на ВСП, план"); + + b.Property("TopDriveTorqueLimitMax") + .HasColumnType("double precision") + .HasColumnName("top_drive_torque_limit_max") + .HasComment("Момент на ВСП, допустимый максимум"); + + b.Property("TopDriveTorquePlan") + .HasColumnType("double precision") + .HasColumnName("top_drive_torque_plan") + .HasComment("Момент на ВСП, план"); + + b.Property("UsageSaub") + .HasColumnType("double precision") + .HasColumnName("usage_saub") + .HasComment("Плановый процент использования АКБ"); + + b.Property("UsageSpin") + .HasColumnType("double precision") + .HasColumnName("usage_spin") + .HasComment("Плановый процент использования spin master"); + + b.HasKey("Id"); + + b.HasIndex("IdWell"); + + b.HasIndex("IdWellSectionType"); + + b.ToTable("t_process_map"); + + b.HasComment("Операции по скважине – РТК"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.RelationCompanyWell", b => + { + b.Property("IdCompany") + .HasColumnType("integer") + .HasColumnName("id_company"); + + b.Property("IdWell") + .HasColumnType("integer") + .HasColumnName("id_well"); + + b.HasKey("IdCompany", "IdWell"); + + b.HasIndex("IdWell"); + + b.ToTable("t_relation_company_well"); + + b.HasComment("отношение скважин и компаний"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.RelationUserDrillingProgramPart", b => + { + b.Property("IdUser") + .HasColumnType("integer") + .HasColumnName("id_user"); + + b.Property("IdDrillingProgramPart") + .HasColumnType("integer") + .HasColumnName("id_drilling_program_part"); + + b.Property("IdUserRole") + .HasColumnType("integer") + .HasColumnName("id_role") + .HasComment("1 - publisher, 2 - approver"); + + b.HasKey("IdUser", "IdDrillingProgramPart") + .HasName("t_relation_user_drilling_program_part_pk"); + + b.HasIndex("IdDrillingProgramPart"); + + b.ToTable("t_relation_user_drilling_program_part"); + + b.HasComment("Отношение пользователей и частей ПБ"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.RelationUserRolePermission", b => + { + b.Property("IdUserRole") + .HasColumnType("integer") + .HasColumnName("id_user_role"); + + b.Property("IdPermission") + .HasColumnType("integer") + .HasColumnName("id_permission"); + + b.HasKey("IdUserRole", "IdPermission"); + + b.HasIndex("IdPermission"); + + b.ToTable("t_relation_user_role_permission"); + + b.HasComment("Отношение ролей пользователей и разрешений доступа"); + + b.HasData( + new + { + IdUserRole = 1100, + IdPermission = 102 + }, + new + { + IdUserRole = 1100, + IdPermission = 111 + }, + new + { + IdUserRole = 1101, + IdPermission = 101 + }, + new + { + IdUserRole = 1101, + IdPermission = 100 + }, + new + { + IdUserRole = 1102, + IdPermission = 105 + }, + new + { + IdUserRole = 1102, + IdPermission = 108 + }, + new + { + IdUserRole = 1103, + IdPermission = 104 + }, + new + { + IdUserRole = 1103, + IdPermission = 103 + }, + new + { + IdUserRole = 1104, + IdPermission = 108 + }, + new + { + IdUserRole = 1105, + IdPermission = 107 + }, + new + { + IdUserRole = 1105, + IdPermission = 106 + }, + new + { + IdUserRole = 1106, + IdPermission = 111 + }, + new + { + IdUserRole = 1107, + IdPermission = 110 + }, + new + { + IdUserRole = 1107, + IdPermission = 109 + }, + new + { + IdUserRole = 1108, + IdPermission = 114 + }, + new + { + IdUserRole = 1109, + IdPermission = 113 + }, + new + { + IdUserRole = 1109, + IdPermission = 112 + }, + new + { + IdUserRole = 1110, + IdPermission = 123 + }, + new + { + IdUserRole = 1110, + IdPermission = 114 + }, + new + { + IdUserRole = 1111, + IdPermission = 122 + }, + new + { + IdUserRole = 1111, + IdPermission = 121 + }, + new + { + IdUserRole = 1112, + IdPermission = 117 + }, + new + { + IdUserRole = 1113, + IdPermission = 105 + }, + new + { + IdUserRole = 1113, + IdPermission = 123 + }, + new + { + IdUserRole = 1113, + IdPermission = 120 + }, + new + { + IdUserRole = 1114, + IdPermission = 119 + }, + new + { + IdUserRole = 1114, + IdPermission = 118 + }, + new + { + IdUserRole = 1114, + IdPermission = 200 + }, + new + { + IdUserRole = 1115, + IdPermission = 223 + }, + new + { + IdUserRole = 1116, + IdPermission = 105 + }, + new + { + IdUserRole = 1116, + IdPermission = 102 + }, + new + { + IdUserRole = 1116, + IdPermission = 117 + }, + new + { + IdUserRole = 1116, + IdPermission = 126 + }, + new + { + IdUserRole = 1117, + IdPermission = 125 + }, + new + { + IdUserRole = 1117, + IdPermission = 124 + }, + new + { + IdUserRole = 1200, + IdPermission = 203 + }, + new + { + IdUserRole = 1200, + IdPermission = 230 + }, + new + { + IdUserRole = 1201, + IdPermission = 202 + }, + new + { + IdUserRole = 1201, + IdPermission = 203 + }, + new + { + IdUserRole = 1201, + IdPermission = 220 + }, + new + { + IdUserRole = 1202, + IdPermission = 203 + }, + new + { + IdUserRole = 1202, + IdPermission = 220 + }, + new + { + IdUserRole = 1202, + IdPermission = 236 + }, + new + { + IdUserRole = 1202, + IdPermission = 212 + }, + new + { + IdUserRole = 1203, + IdPermission = 235 + }, + new + { + IdUserRole = 1204, + IdPermission = 202 + }, + new + { + IdUserRole = 1204, + IdPermission = 203 + }, + new + { + IdUserRole = 1205, + IdPermission = 215 + }, + new + { + IdUserRole = 1206, + IdPermission = 203 + }, + new + { + IdUserRole = 1206, + IdPermission = 206 + }, + new + { + IdUserRole = 1207, + IdPermission = 205 + }, + new + { + IdUserRole = 1208, + IdPermission = 218 + }, + new + { + IdUserRole = 1209, + IdPermission = 217 + }, + new + { + IdUserRole = 1210, + IdPermission = 203 + }, + new + { + IdUserRole = 1210, + IdPermission = 230 + }, + new + { + IdUserRole = 1210, + IdPermission = 219 + }, + new + { + IdUserRole = 1211, + IdPermission = 203 + }, + new + { + IdUserRole = 1211, + IdPermission = 220 + }, + new + { + IdUserRole = 1211, + IdPermission = 239 + }, + new + { + IdUserRole = 1212, + IdPermission = 238 + }, + new + { + IdUserRole = 1212, + IdPermission = 237 + }, + new + { + IdUserRole = 1213, + IdPermission = 203 + }, + new + { + IdUserRole = 1213, + IdPermission = 239 + }, + new + { + IdUserRole = 1213, + IdPermission = 212 + }, + new + { + IdUserRole = 1214, + IdPermission = 211 + }, + new + { + IdUserRole = 1214, + IdPermission = 210 + }, + new + { + IdUserRole = 1215, + IdPermission = 203 + }, + new + { + IdUserRole = 1215, + IdPermission = 222 + }, + new + { + IdUserRole = 1216, + IdPermission = 221 + }, + new + { + IdUserRole = 1217, + IdPermission = 226 + }, + new + { + IdUserRole = 1218, + IdPermission = 225 + }, + new + { + IdUserRole = 1218, + IdPermission = 224 + }, + new + { + IdUserRole = 1219, + IdPermission = 203 + }, + new + { + IdUserRole = 1219, + IdPermission = 206 + }, + new + { + IdUserRole = 1219, + IdPermission = 230 + }, + new + { + IdUserRole = 1219, + IdPermission = 232 + }, + new + { + IdUserRole = 1220, + IdPermission = 203 + }, + new + { + IdUserRole = 1220, + IdPermission = 228 + }, + new + { + IdUserRole = 1221, + IdPermission = 202 + }, + new + { + IdUserRole = 1221, + IdPermission = 203 + }, + new + { + IdUserRole = 1221, + IdPermission = 220 + }, + new + { + IdUserRole = 1221, + IdPermission = 234 + }, + new + { + IdUserRole = 1500, + IdPermission = 507 + }, + new + { + IdUserRole = 1500, + IdPermission = 510 + }, + new + { + IdUserRole = 1501, + IdPermission = 214 + }, + new + { + IdUserRole = 1501, + IdPermission = 213 + }, + new + { + IdUserRole = 1502, + IdPermission = 207 + }, + new + { + IdUserRole = 1502, + IdPermission = 208 + }, + new + { + IdUserRole = 2000, + IdPermission = 205 + }, + new + { + IdUserRole = 2000, + IdPermission = 204 + }, + new + { + IdUserRole = 2000, + IdPermission = 245 + }, + new + { + IdUserRole = 2001, + IdPermission = 244 + }, + new + { + IdUserRole = 2001, + IdPermission = 245 + }, + new + { + IdUserRole = 2002, + IdPermission = 244 + }, + new + { + IdUserRole = 2002, + IdPermission = 246 + }, + new + { + IdUserRole = 2002, + IdPermission = 237 + }, + new + { + IdUserRole = 2002, + IdPermission = 238 + }, + new + { + IdUserRole = 2003, + IdPermission = 240 + }, + new + { + IdUserRole = 2003, + IdPermission = 217 + }, + new + { + IdUserRole = 2003, + IdPermission = 216 + }, + new + { + IdUserRole = 2004, + IdPermission = 242 + }, + new + { + IdUserRole = 2004, + IdPermission = 217 + }, + new + { + IdUserRole = 2004, + IdPermission = 216 + }, + new + { + IdUserRole = 2004, + IdPermission = 205 + }, + new + { + IdUserRole = 2004, + IdPermission = 204 + }, + new + { + IdUserRole = 2005, + IdPermission = 247 + }, + new + { + IdUserRole = 2005, + IdPermission = 205 + }, + new + { + IdUserRole = 2005, + IdPermission = 204 + }, + new + { + IdUserRole = 2006, + IdPermission = 243 + }, + new + { + IdUserRole = 2006, + IdPermission = 205 + }, + new + { + IdUserRole = 2006, + IdPermission = 204 + }, + new + { + IdUserRole = 2007, + IdPermission = 241 + }, + new + { + IdUserRole = 2007, + IdPermission = 205 + }, + new + { + IdUserRole = 2007, + IdPermission = 204 + }, + new + { + IdUserRole = 1, + IdPermission = 100 + }, + new + { + IdUserRole = 1, + IdPermission = 101 + }, + new + { + IdUserRole = 1, + IdPermission = 102 + }, + new + { + IdUserRole = 1, + IdPermission = 103 + }, + new + { + IdUserRole = 1, + IdPermission = 104 + }, + new + { + IdUserRole = 1, + IdPermission = 105 + }, + new + { + IdUserRole = 1, + IdPermission = 106 + }, + new + { + IdUserRole = 1, + IdPermission = 107 + }, + new + { + IdUserRole = 1, + IdPermission = 108 + }, + new + { + IdUserRole = 1, + IdPermission = 109 + }, + new + { + IdUserRole = 1, + IdPermission = 110 + }, + new + { + IdUserRole = 1, + IdPermission = 111 + }, + new + { + IdUserRole = 1, + IdPermission = 112 + }, + new + { + IdUserRole = 1, + IdPermission = 113 + }, + new + { + IdUserRole = 1, + IdPermission = 114 + }, + new + { + IdUserRole = 1, + IdPermission = 115 + }, + new + { + IdUserRole = 1, + IdPermission = 116 + }, + new + { + IdUserRole = 1, + IdPermission = 117 + }, + new + { + IdUserRole = 1, + IdPermission = 118 + }, + new + { + IdUserRole = 1, + IdPermission = 119 + }, + new + { + IdUserRole = 1, + IdPermission = 120 + }, + new + { + IdUserRole = 1, + IdPermission = 121 + }, + new + { + IdUserRole = 1, + IdPermission = 122 + }, + new + { + IdUserRole = 1, + IdPermission = 123 + }, + new + { + IdUserRole = 1, + IdPermission = 124 + }, + new + { + IdUserRole = 1, + IdPermission = 125 + }, + new + { + IdUserRole = 1, + IdPermission = 126 + }, + new + { + IdUserRole = 1, + IdPermission = 127 + }, + new + { + IdUserRole = 1, + IdPermission = 128 + }, + new + { + IdUserRole = 1, + IdPermission = 129 + }, + new + { + IdUserRole = 1, + IdPermission = 200 + }, + new + { + IdUserRole = 1, + IdPermission = 201 + }, + new + { + IdUserRole = 1, + IdPermission = 202 + }, + new + { + IdUserRole = 1, + IdPermission = 203 + }, + new + { + IdUserRole = 1, + IdPermission = 204 + }, + new + { + IdUserRole = 1, + IdPermission = 205 + }, + new + { + IdUserRole = 1, + IdPermission = 206 + }, + new + { + IdUserRole = 1, + IdPermission = 207 + }, + new + { + IdUserRole = 1, + IdPermission = 208 + }, + new + { + IdUserRole = 1, + IdPermission = 209 + }, + new + { + IdUserRole = 1, + IdPermission = 210 + }, + new + { + IdUserRole = 1, + IdPermission = 211 + }, + new + { + IdUserRole = 1, + IdPermission = 212 + }, + new + { + IdUserRole = 1, + IdPermission = 213 + }, + new + { + IdUserRole = 1, + IdPermission = 214 + }, + new + { + IdUserRole = 1, + IdPermission = 215 + }, + new + { + IdUserRole = 1, + IdPermission = 216 + }, + new + { + IdUserRole = 1, + IdPermission = 217 + }, + new + { + IdUserRole = 1, + IdPermission = 218 + }, + new + { + IdUserRole = 1, + IdPermission = 219 + }, + new + { + IdUserRole = 1, + IdPermission = 220 + }, + new + { + IdUserRole = 1, + IdPermission = 221 + }, + new + { + IdUserRole = 1, + IdPermission = 222 + }, + new + { + IdUserRole = 1, + IdPermission = 223 + }, + new + { + IdUserRole = 1, + IdPermission = 224 + }, + new + { + IdUserRole = 1, + IdPermission = 225 + }, + new + { + IdUserRole = 1, + IdPermission = 226 + }, + new + { + IdUserRole = 1, + IdPermission = 227 + }, + new + { + IdUserRole = 1, + IdPermission = 228 + }, + new + { + IdUserRole = 1, + IdPermission = 229 + }, + new + { + IdUserRole = 1, + IdPermission = 230 + }, + new + { + IdUserRole = 1, + IdPermission = 231 + }, + new + { + IdUserRole = 1, + IdPermission = 232 + }, + new + { + IdUserRole = 1, + IdPermission = 233 + }, + new + { + IdUserRole = 1, + IdPermission = 234 + }, + new + { + IdUserRole = 1, + IdPermission = 235 + }, + new + { + IdUserRole = 1, + IdPermission = 236 + }, + new + { + IdUserRole = 1, + IdPermission = 237 + }, + new + { + IdUserRole = 1, + IdPermission = 238 + }, + new + { + IdUserRole = 1, + IdPermission = 239 + }, + new + { + IdUserRole = 1, + IdPermission = 240 + }, + new + { + IdUserRole = 1, + IdPermission = 241 + }, + new + { + IdUserRole = 1, + IdPermission = 242 + }, + new + { + IdUserRole = 1, + IdPermission = 243 + }, + new + { + IdUserRole = 1, + IdPermission = 244 + }, + new + { + IdUserRole = 1, + IdPermission = 245 + }, + new + { + IdUserRole = 1, + IdPermission = 246 + }, + new + { + IdUserRole = 1, + IdPermission = 247 + }, + new + { + IdUserRole = 1, + IdPermission = 248 + }, + new + { + IdUserRole = 1, + IdPermission = 249 + }, + new + { + IdUserRole = 1, + IdPermission = 250 + }, + new + { + IdUserRole = 1, + IdPermission = 251 + }, + new + { + IdUserRole = 1, + IdPermission = 252 + }, + new + { + IdUserRole = 1, + IdPermission = 253 + }, + new + { + IdUserRole = 1, + IdPermission = 254 + }, + new + { + IdUserRole = 1, + IdPermission = 255 + }, + new + { + IdUserRole = 1, + IdPermission = 256 + }, + new + { + IdUserRole = 1, + IdPermission = 257 + }, + new + { + IdUserRole = 1, + IdPermission = 258 + }, + new + { + IdUserRole = 1, + IdPermission = 259 + }, + new + { + IdUserRole = 1, + IdPermission = 260 + }, + new + { + IdUserRole = 1, + IdPermission = 261 + }, + new + { + IdUserRole = 1, + IdPermission = 262 + }, + new + { + IdUserRole = 1, + IdPermission = 263 + }, + new + { + IdUserRole = 1, + IdPermission = 264 + }, + new + { + IdUserRole = 1, + IdPermission = 265 + }, + new + { + IdUserRole = 1, + IdPermission = 266 + }, + new + { + IdUserRole = 1, + IdPermission = 267 + }, + new + { + IdUserRole = 1, + IdPermission = 268 + }, + new + { + IdUserRole = 1, + IdPermission = 269 + }, + new + { + IdUserRole = 1, + IdPermission = 380 + }, + new + { + IdUserRole = 1, + IdPermission = 381 + }, + new + { + IdUserRole = 1, + IdPermission = 382 + }, + new + { + IdUserRole = 1, + IdPermission = 383 + }, + new + { + IdUserRole = 1, + IdPermission = 384 + }, + new + { + IdUserRole = 1, + IdPermission = 385 + }, + new + { + IdUserRole = 1, + IdPermission = 386 + }, + new + { + IdUserRole = 1, + IdPermission = 387 + }, + new + { + IdUserRole = 1, + IdPermission = 388 + }, + new + { + IdUserRole = 1, + IdPermission = 389 + }, + new + { + IdUserRole = 1, + IdPermission = 390 + }, + new + { + IdUserRole = 1, + IdPermission = 391 + }, + new + { + IdUserRole = 1, + IdPermission = 400 + }, + new + { + IdUserRole = 1, + IdPermission = 401 + }, + new + { + IdUserRole = 1, + IdPermission = 407 + }, + new + { + IdUserRole = 1, + IdPermission = 408 + }, + new + { + IdUserRole = 1, + IdPermission = 450 + }, + new + { + IdUserRole = 1, + IdPermission = 460 + }, + new + { + IdUserRole = 1, + IdPermission = 461 + }, + new + { + IdUserRole = 1, + IdPermission = 500 + }, + new + { + IdUserRole = 1, + IdPermission = 501 + }, + new + { + IdUserRole = 1, + IdPermission = 502 + }, + new + { + IdUserRole = 1, + IdPermission = 503 + }, + new + { + IdUserRole = 1, + IdPermission = 504 + }, + new + { + IdUserRole = 1, + IdPermission = 505 + }, + new + { + IdUserRole = 1, + IdPermission = 506 + }, + new + { + IdUserRole = 1, + IdPermission = 507 + }, + new + { + IdUserRole = 1, + IdPermission = 510 + }, + new + { + IdUserRole = 1, + IdPermission = 511 + }, + new + { + IdUserRole = 1, + IdPermission = 512 + }, + new + { + IdUserRole = 1, + IdPermission = 513 + }, + new + { + IdUserRole = 1, + IdPermission = 514 + }, + new + { + IdUserRole = 1, + IdPermission = 515 + }); + }); + + modelBuilder.Entity("AsbCloudDb.Model.RelationUserRoleUserRole", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id_user_role"); + + b.Property("IdInclude") + .HasColumnType("integer") + .HasColumnName("id_include_user_role"); + + b.HasKey("Id", "IdInclude") + .HasName("t_relation_user_role_user_role_pk"); + + b.HasIndex("IdInclude"); + + b.ToTable("t_relation_user_role_user_role"); + + b.HasComment("Отношение ролей к ролям"); + + b.HasData( + new + { + Id = 1101, + IdInclude = 1100 + }, + new + { + Id = 1103, + IdInclude = 1102 + }, + new + { + Id = 1105, + IdInclude = 1104 + }, + new + { + Id = 1107, + IdInclude = 1106 + }, + new + { + Id = 1109, + IdInclude = 1108 + }, + new + { + Id = 1111, + IdInclude = 1110 + }, + new + { + Id = 1114, + IdInclude = 1113 + }, + new + { + Id = 1117, + IdInclude = 1116 + }, + new + { + Id = 1203, + IdInclude = 1202 + }, + new + { + Id = 1207, + IdInclude = 1206 + }, + new + { + Id = 1209, + IdInclude = 1208 + }, + new + { + Id = 1212, + IdInclude = 1211 + }, + new + { + Id = 1214, + IdInclude = 1213 + }, + new + { + Id = 1216, + IdInclude = 1215 + }, + new + { + Id = 1218, + IdInclude = 1217 + }, + new + { + Id = 2000, + IdInclude = 1200 + }, + new + { + Id = 2000, + IdInclude = 1201 + }, + new + { + Id = 2000, + IdInclude = 1202 + }, + new + { + Id = 2000, + IdInclude = 1204 + }, + new + { + Id = 2000, + IdInclude = 1205 + }, + new + { + Id = 2000, + IdInclude = 1206 + }, + new + { + Id = 2000, + IdInclude = 1208 + }, + new + { + Id = 2000, + IdInclude = 1210 + }, + new + { + Id = 2000, + IdInclude = 1211 + }, + new + { + Id = 2000, + IdInclude = 1213 + }, + new + { + Id = 2000, + IdInclude = 1215 + }, + new + { + Id = 2000, + IdInclude = 1217 + }, + new + { + Id = 2000, + IdInclude = 1219 + }, + new + { + Id = 2000, + IdInclude = 1220 + }, + new + { + Id = 2000, + IdInclude = 1221 + }, + new + { + Id = 2000, + IdInclude = 1500 + }, + new + { + Id = 2000, + IdInclude = 1501 + }, + new + { + Id = 2000, + IdInclude = 1502 + }, + new + { + Id = 2001, + IdInclude = 1500 + }, + new + { + Id = 2001, + IdInclude = 1501 + }, + new + { + Id = 2001, + IdInclude = 1502 + }, + new + { + Id = 2002, + IdInclude = 1500 + }, + new + { + Id = 2002, + IdInclude = 1501 + }, + new + { + Id = 2002, + IdInclude = 1502 + }, + new + { + Id = 2003, + IdInclude = 1500 + }, + new + { + Id = 2003, + IdInclude = 1501 + }, + new + { + Id = 2003, + IdInclude = 1502 + }, + new + { + Id = 2004, + IdInclude = 1500 + }, + new + { + Id = 2004, + IdInclude = 1501 + }, + new + { + Id = 2004, + IdInclude = 1502 + }, + new + { + Id = 2005, + IdInclude = 1500 + }, + new + { + Id = 2005, + IdInclude = 1501 + }, + new + { + Id = 2005, + IdInclude = 1502 + }, + new + { + Id = 2006, + IdInclude = 1500 + }, + new + { + Id = 2006, + IdInclude = 1501 + }, + new + { + Id = 2006, + IdInclude = 1502 + }, + new + { + Id = 2007, + IdInclude = 1500 + }, + new + { + Id = 2007, + IdInclude = 1501 + }, + new + { + Id = 2007, + IdInclude = 1502 + }); + }); + + modelBuilder.Entity("AsbCloudDb.Model.RelationUserUserRole", b => + { + b.Property("IdUser") + .HasColumnType("integer") + .HasColumnName("id_user"); + + b.Property("IdUserRole") + .HasColumnType("integer") + .HasColumnName("id_user_role"); + + b.HasKey("IdUser", "IdUserRole"); + + b.HasIndex("IdUserRole"); + + b.ToTable("t_relation_user_user_role"); + + b.HasComment("Отношение пользователей и ролей"); + + b.HasData( + new + { + IdUser = 1, + IdUserRole = 1 + }); + }); + + modelBuilder.Entity("AsbCloudDb.Model.ReportProperty", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Begin") + .HasColumnType("timestamp with time zone") + .HasColumnName("begin"); + + b.Property("End") + .HasColumnType("timestamp with time zone") + .HasColumnName("end") + .HasComment("timestamp with time zone"); + + b.Property("Format") + .HasColumnType("integer") + .HasColumnName("format") + .HasComment("Формат отчета"); + + b.Property("IdFile") + .HasColumnType("integer") + .HasColumnName("id_file") + .HasComment("id файла-родителя"); + + b.Property("IdWell") + .HasColumnType("integer") + .HasColumnName("id_well") + .HasComment("id скважины"); + + b.Property("Step") + .HasColumnType("integer") + .HasColumnName("step") + .HasComment("размер шага в секундах"); + + b.HasKey("Id"); + + b.HasIndex("IdFile"); + + b.HasIndex("IdWell"); + + b.ToTable("t_report_property"); + + b.HasComment("Отчеты с данными по буровым"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.Schedule", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id") + .HasComment("Идентификатор"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DrillEnd") + .HasColumnType("timestamp with time zone") + .HasColumnName("drill_end") + .HasComment("Конец вахты"); + + b.Property("DrillStart") + .HasColumnType("timestamp with time zone") + .HasColumnName("drill_start") + .HasComment("Начало вахты"); + + b.Property("IdDriller") + .HasColumnType("integer") + .HasColumnName("id_driller") + .HasComment("Идентификатор бурильщика"); + + b.Property("IdWell") + .HasColumnType("integer") + .HasColumnName("id_well") + .HasComment("Идентификатор скважины"); + + b.Property("ShiftEnd") + .HasColumnType("time without time zone") + .HasColumnName("shift_end") + .HasComment("Конец смены"); + + b.Property("ShiftStart") + .HasColumnType("time without time zone") + .HasColumnName("shift_start") + .HasComment("Начало смены"); + + b.HasKey("Id"); + + b.HasIndex("IdDriller"); + + b.HasIndex("IdWell"); + + b.ToTable("t_schedule"); + + b.HasComment("График работы бурильщика"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.SetpointsRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Comment") + .HasColumnType("text") + .HasColumnName("comment") + .HasComment("комментарий для оператора"); + + b.Property("IdAuthor") + .HasColumnType("integer") + .HasColumnName("id_author") + .HasComment("Id пользователя, загрузившего файл"); + + b.Property("IdState") + .HasColumnType("integer") + .HasColumnName("id_state") + .HasComment("0: неизвестно, 1:ожидает отправки, 2: отправлено, 3: принято оператором, 4: отклонено оператором, 5: устарело"); + + b.Property("IdWell") + .HasColumnType("integer") + .HasColumnName("id_well") + .HasComment("id скважины"); + + b.Property("ObsolescenceSec") + .HasColumnType("integer") + .HasColumnName("obsolescence") + .HasComment("сек. до устаревания"); + + b.Property("Setpoints") + .IsRequired() + .HasColumnType("jsonb") + .HasColumnName("setpoint_set") + .HasComment("Набор уставок"); + + b.Property("UploadDate") + .HasColumnType("timestamp with time zone") + .HasColumnName("date"); + + b.HasKey("Id"); + + b.HasIndex("IdAuthor"); + + b.HasIndex("IdWell"); + + b.ToTable("t_setpoints_rquest"); + + b.HasComment("Запросы на изменение уставок панели оператора"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.Subsystems.Subsystem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Description") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("description"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("name"); + + b.HasKey("Id"); + + b.ToTable("t_subsystem"); + + b.HasComment("Описание подсистем"); + + b.HasData( + new + { + Id = 1, + Description = "Совместная работа режимов \"Бурение в роторе\" и \"Бурение в слайде\"", + Name = "АКБ" + }, + new + { + Id = 2, + Description = "Алгоритм поиска оптимальных параметров бурения САУБ", + Name = "MSE" + }, + new + { + Id = 65536, + Description = "Spin master", + Name = "Spin master" + }, + new + { + Id = 65537, + Description = "Torque master", + Name = "Torque master" + }); + }); + + modelBuilder.Entity("AsbCloudDb.Model.Subsystems.SubsystemOperationTime", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DateEnd") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_end") + .HasComment("дата/время выключения подсистемы"); + + b.Property("DateStart") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_start") + .HasComment("дата/время включения подсистемы"); + + b.Property("DepthEnd") + .HasColumnType("real") + .HasColumnName("depth_end") + .HasComment("глубина забоя на момент выключения подсистемы"); + + b.Property("DepthStart") + .HasColumnType("real") + .HasColumnName("depth_start") + .HasComment("глубина забоя на момент включения подсистемы"); + + b.Property("IdSubsystem") + .HasColumnType("integer") + .HasColumnName("id_subsystem"); + + b.Property("IdTelemetry") + .HasColumnType("integer") + .HasColumnName("id_telemetry") + .HasComment("ИД телеметрии по которой выдается информация"); + + b.HasKey("Id"); + + b.HasIndex("IdSubsystem"); + + b.HasIndex("IdTelemetry"); + + b.ToTable("t_subsystem_operation_time"); + + b.HasComment("наработки подсистем"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.Telemetry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Info") + .IsRequired() + .HasColumnType("jsonb") + .HasColumnName("info") + .HasComment("Информация с панели о скважине"); + + b.Property("RemoteUid") + .IsRequired() + .HasColumnType("text") + .HasColumnName("remote_uid") + .HasComment("Идентификатор передающего устройства. Может повторяться в списке, так как комплекты оборудования переезжают от скв. к скв."); + + b.Property("TimeZone") + .IsRequired() + .HasColumnType("jsonb") + .HasColumnName("timezone") + .HasComment("Смещение часового пояса от UTC"); + + b.HasKey("Id"); + + b.HasIndex(new[] { "RemoteUid" }, "t_telemetry_remote_uid_index"); + + b.ToTable("t_telemetry"); + + b.HasComment("таблица привязки телеметрии от комплектов к конкретной скважине."); + }); + + modelBuilder.Entity("AsbCloudDb.Model.TelemetryDataSaub", b => + { + b.Property("IdTelemetry") + .HasColumnType("integer") + .HasColumnName("id_telemetry"); + + b.Property("DateTime") + .HasColumnType("timestamp with time zone") + .HasColumnName("date") + .HasComment("'2021-10-19 18:23:54+05'"); + + b.Property("AxialLoad") + .HasColumnType("real") + .HasColumnName("axial_load") + .HasComment("Осевая нагрузка"); + + b.Property("AxialLoadLimitMax") + .HasColumnType("real") + .HasColumnName("axial_load_limit_max") + .HasComment("Осевая нагрузка. Аварийная макс."); + + b.Property("AxialLoadSp") + .HasColumnType("real") + .HasColumnName("axial_load_sp") + .HasComment("Осевая нагрузка. Задание"); + + b.Property("BitDepth") + .HasColumnType("real") + .HasColumnName("bit_depth") + .HasComment("Положение инструмента"); + + b.Property("BlockPosition") + .HasColumnType("real") + .HasColumnName("block_position") + .HasComment("Высота талевого блока"); + + b.Property("BlockPositionMax") + .HasColumnType("real") + .HasColumnName("block_position_max") + .HasComment("Талевый блок. Макс положение"); + + b.Property("BlockPositionMin") + .HasColumnType("real") + .HasColumnName("block_position_min") + .HasComment("Талевый блок. Мин положение"); + + b.Property("BlockSpeed") + .HasColumnType("real") + .HasColumnName("block_speed") + .HasComment("Скорость талевого блока"); + + b.Property("BlockSpeedSp") + .HasColumnType("real") + .HasColumnName("block_speed_sp") + .HasComment("Скорости талевого блока. Задание"); + + b.Property("BlockSpeedSpDevelop") + .HasColumnType("real") + .HasColumnName("block_speed_sp_develop") + .HasComment("Талевый блок. Задание скорости для проработки"); + + b.Property("BlockSpeedSpRotor") + .HasColumnType("real") + .HasColumnName("block_speed_sp_rotor") + .HasComment("Талевый блок. Задание скорости для роторного бурения"); + + b.Property("BlockSpeedSpSlide") + .HasColumnType("real") + .HasColumnName("block_speed_sp_slide") + .HasComment("Талевый блок. Задание скорости для режима слайда"); + + b.Property("Flow") + .HasColumnType("real") + .HasColumnName("flow") + .HasComment("Расход"); + + b.Property("FlowDeltaLimitMax") + .HasColumnType("real") + .HasColumnName("flow_delta_limit_max") + .HasComment("Расход. Аварийный макс."); + + b.Property("FlowIdle") + .HasColumnType("real") + .HasColumnName("flow_idle") + .HasComment("Расход. Холостой ход"); + + b.Property("HookWeight") + .HasColumnType("real") + .HasColumnName("hook_weight") + .HasComment("Вес на крюке"); + + b.Property("HookWeightIdle") + .HasColumnType("real") + .HasColumnName("hook_weight_idle") + .HasComment("Вес на крюке. Холостой ход"); + + b.Property("HookWeightLimitMax") + .HasColumnType("real") + .HasColumnName("hook_weight_limit_max") + .HasComment("Вес на крюке. Затяжка"); + + b.Property("HookWeightLimitMin") + .HasColumnType("real") + .HasColumnName("hook_weight_limit_min") + .HasComment("Вес на крюке. Посадка"); + + b.Property("IdFeedRegulator") + .HasColumnType("smallint") + .HasColumnName("id_feed_regulator") + .HasComment("Текущий критерий бурения"); + + b.Property("IdUser") + .HasColumnType("integer") + .HasColumnName("id_user") + .HasComment("Пользователь САУБ"); + + b.Property("Mode") + .HasColumnType("smallint") + .HasColumnName("mode") + .HasComment("Режим САУБ"); + + b.Property("Mse") + .HasColumnType("real") + .HasColumnName("mse") + .HasComment("MSE"); + + b.Property("MseState") + .HasColumnType("smallint") + .HasColumnName("mse_state") + .HasComment("Текущее состояние работы MSE"); + + b.Property("Pressure") + .HasColumnType("real") + .HasColumnName("pressure") + .HasComment("Давление"); + + b.Property("PressureDeltaLimitMax") + .HasColumnType("real") + .HasColumnName("pressure_delta_limit_max") + .HasComment("Давление дифф. Аварийное макс."); + + b.Property("PressureIdle") + .HasColumnType("real") + .HasColumnName("pressure_idle") + .HasComment("Давление. Холостой ход"); + + b.Property("PressureSp") + .HasColumnType("real") + .HasColumnName("pressure_sp") + .HasComment("Давление. Задание"); + + b.Property("PressureSpDevelop") + .HasColumnType("real") + .HasColumnName("pressure_sp_develop") + .HasComment("Давление. Задание для проработки"); + + b.Property("PressureSpRotor") + .HasColumnType("real") + .HasColumnName("pressure_sp_rotor") + .HasComment("Давление. Задание для роторного бурения"); + + b.Property("PressureSpSlide") + .HasColumnType("real") + .HasColumnName("pressure_sp_slide") + .HasComment("Давление. Задание для режима слайда"); + + b.Property("RotorSpeed") + .HasColumnType("real") + .HasColumnName("rotor_speed") + .HasComment("Обороты ротора"); + + b.Property("RotorTorque") + .HasColumnType("real") + .HasColumnName("rotor_torque") + .HasComment("Момент на роторе"); + + b.Property("RotorTorqueIdle") + .HasColumnType("real") + .HasColumnName("rotor_torque_idle") + .HasComment("Момент на роторе. Холостой ход"); + + b.Property("RotorTorqueLimitMax") + .HasColumnType("real") + .HasColumnName("rotor_torque_limit_max") + .HasComment("Момент на роторе. Аварийный макс."); + + b.Property("RotorTorqueSp") + .HasColumnType("real") + .HasColumnName("rotor_torque_sp") + .HasComment("Момент на роторе. Задание"); + + b.Property("WellDepth") + .HasColumnType("real") + .HasColumnName("well_depth") + .HasComment("Глубина забоя"); + + b.HasKey("IdTelemetry", "DateTime"); + + b.ToTable("t_telemetry_data_saub"); + + b.HasComment("набор основных данных по SAUB"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.TelemetryDataSaubStat", b => + { + b.Property("Count") + .HasColumnType("bigint") + .HasColumnName("count_items"); + + b.Property("DateMax") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_max"); + + b.Property("DateMin") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_min"); + + b.Property("DepthMax") + .HasColumnType("real") + .HasColumnName("depth_max"); + + b.Property("DepthMin") + .HasColumnType("real") + .HasColumnName("depth_min"); + + b.Property("IdTelemetry") + .HasColumnType("integer") + .HasColumnName("id_telemetry"); + + b.ToView("mw_telemetry_datas_saub_stat"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.TelemetryDataSpin", b => + { + b.Property("IdTelemetry") + .HasColumnType("integer") + .HasColumnName("id_telemetry"); + + b.Property("DateTime") + .HasColumnType("timestamp with time zone") + .HasColumnName("date") + .HasComment("'2021-10-19 18:23:54+05'"); + + b.Property("Mode") + .HasColumnType("smallint") + .HasColumnName("mode") + .HasComment("Выбранный режим управления"); + + b.Property("PositionRight") + .HasColumnType("real") + .HasColumnName("position_right") + .HasComment("Крайний правый угол осцилляции"); + + b.Property("PositionZero") + .HasColumnType("real") + .HasColumnName("position_zero") + .HasComment("Нулевая позиция осцилляции"); + + b.Property("RevolsLeftLimit") + .HasColumnType("real") + .HasColumnName("revols_left_limit") + .HasComment("Ограничение числа оборотов влево"); + + b.Property("RevolsLeftTotal") + .HasColumnType("real") + .HasColumnName("revols_left_total") + .HasComment("Суммарное количество оборотов влево"); + + b.Property("RevolsRightLimit") + .HasColumnType("real") + .HasColumnName("revols_right_limit") + .HasComment("Ограничение числа оборотов вправо"); + + b.Property("RevolsRightTotal") + .HasColumnType("real") + .HasColumnName("revols_right_total") + .HasComment("Суммарное количество оборотов вправо"); + + b.Property("SpeedLeftSp") + .HasColumnType("real") + .HasColumnName("speed_left_sp") + .HasComment("Заданная скорость вращения влево"); + + b.Property("SpeedRightSp") + .HasColumnType("real") + .HasColumnName("speed_right_sp") + .HasComment("Заданная скорость вращения вправо"); + + b.Property("State") + .HasColumnType("smallint") + .HasColumnName("state") + .HasComment("Переменная этапа"); + + b.HasKey("IdTelemetry", "DateTime"); + + b.ToTable("t_telemetry_data_spin"); + + b.HasComment("набор основных данных по SpinMaster"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.TelemetryEvent", b => + { + b.Property("IdTelemetry") + .HasColumnType("integer") + .HasColumnName("id_telemetry"); + + b.Property("IdEvent") + .HasColumnType("integer") + .HasColumnName("id_event"); + + b.Property("IdCategory") + .HasColumnType("integer") + .HasColumnName("id_category"); + + b.Property("MessageTemplate") + .IsRequired() + .HasColumnType("text") + .HasColumnName("message_template"); + + b.HasKey("IdTelemetry", "IdEvent"); + + b.ToTable("t_telemetry_event"); + + b.HasComment("Справочник событий. События формируют сообщения. Разделено по версиям посылок от телеметрии."); + }); + + modelBuilder.Entity("AsbCloudDb.Model.TelemetryMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Arg0") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("arg0") + .HasComment("Аргумент №0 для вставки в шаблон сообщения"); + + b.Property("Arg1") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("arg1"); + + b.Property("Arg2") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("arg2"); + + b.Property("Arg3") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("arg3"); + + b.Property("DateTime") + .HasColumnType("timestamp with time zone") + .HasColumnName("date"); + + b.Property("IdEvent") + .HasColumnType("integer") + .HasColumnName("id_event"); + + b.Property("IdTelemetry") + .HasColumnType("integer") + .HasColumnName("id_telemetry"); + + b.Property("IdTelemetryUser") + .HasColumnType("integer") + .HasColumnName("id_telemetry_user") + .HasComment("Пользователь панели отправляющей телеметрию. не пользователь облака."); + + b.Property("WellDepth") + .HasColumnType("double precision") + .HasColumnName("well_depth"); + + b.HasKey("Id"); + + b.HasIndex("IdTelemetry"); + + b.ToTable("t_telemetry_message"); + + b.HasComment("Сообщения на буровых"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.TelemetryUser", b => + { + b.Property("IdTelemetry") + .HasColumnType("integer") + .HasColumnName("id_telemetry"); + + b.Property("IdUser") + .HasColumnType("integer") + .HasColumnName("id_user"); + + b.Property("Level") + .HasColumnType("integer") + .HasColumnName("level"); + + b.Property("Name") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("name"); + + b.Property("Patronymic") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("patronymic"); + + b.Property("Surname") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("surname"); + + b.HasKey("IdTelemetry", "IdUser"); + + b.ToTable("t_telemetry_user"); + + b.HasComment("Пользователи панели САУБ. Для сообщений."); + }); + + modelBuilder.Entity("AsbCloudDb.Model.TelemetryWirelineRunOut", b => + { + b.Property("IdTelemetry") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id_telemetry") + .HasComment("Идентификатор телеметрии"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("IdTelemetry")); + + b.Property("DateTime") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_time") + .HasComment("Отметка времени"); + + b.Property("Hauling") + .HasColumnType("real") + .HasColumnName("hauling") + .HasComment("Наработка талевого каната с момента перетяжки каната, т*км"); + + b.Property("HaulingWarnSp") + .HasColumnType("real") + .HasColumnName("hauling_warn_sp") + .HasComment("Наработка талевого каната до сигнализации о необходимости перетяжки, т*км"); + + b.Property("Replace") + .HasColumnType("real") + .HasColumnName("replace") + .HasComment("Наработка талевого каната с момента замены каната, т*км"); + + b.Property("ReplaceWarnSp") + .HasColumnType("real") + .HasColumnName("replace_warn_sp") + .HasComment("Наработка талевого каната до сигнализации о необходимости замены, т*км"); + + b.HasKey("IdTelemetry"); + + b.ToTable("t_telemetry_wireline_run_out"); + + b.HasComment("Наработка талевого каната"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("email") + .HasComment("должность"); + + b.Property("IdCompany") + .HasColumnType("integer") + .HasColumnName("id_company"); + + b.Property("IdState") + .HasColumnType("smallint") + .HasColumnName("state") + .HasComment("состояние:\n100 - удален"); + + b.Property("Login") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("login"); + + b.Property("Name") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("name") + .HasComment("имя"); + + b.Property("PasswordHash") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("password_hash") + .HasComment("соленый хэш пароля.\nпервые 5 символов - соль"); + + b.Property("Patronymic") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("patronymic") + .HasComment("отчество"); + + b.Property("Phone") + .HasMaxLength(50) + .HasColumnType("character varying(50)") + .HasColumnName("phone") + .HasComment("номер телефона"); + + b.Property("Position") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("position") + .HasComment("email"); + + b.Property("Surname") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("surname") + .HasComment("фамилия"); + + b.HasKey("Id"); + + b.HasIndex("IdCompany"); + + b.HasIndex("Login") + .IsUnique(); + + b.ToTable("t_user"); + + b.HasComment("Пользователи облака"); + + b.HasData( + new + { + Id = 1, + Email = "", + IdCompany = 1, + Login = "dev", + Name = "Разработчик", + PasswordHash = "Vlcj|4fa529103dde7ff72cfe76185f344d4aa87931f8e1b2044e8a7739947c3d18923464eaad93843e4f809c5e126d013072" + }); + }); + + modelBuilder.Entity("AsbCloudDb.Model.UserRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Caption") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("caption") + .HasComment("Название"); + + b.Property("IdType") + .HasColumnType("integer") + .HasColumnName("id_type") + .HasComment("0-роль из стандартной матрицы, \n1-специальная роль для какого-либо пользователя"); + + b.HasKey("Id"); + + b.ToTable("t_user_role"); + + b.HasComment("Роли пользователей в системе"); + + b.HasData( + new + { + Id = 1, + Caption = "root", + IdType = 1 + }, + new + { + Id = 1100, + Caption = "admin_cluster.view", + IdType = 1 + }, + new + { + Id = 1101, + Caption = "admin_cluster.edit", + IdType = 1 + }, + new + { + Id = 1102, + Caption = "admin_company.view", + IdType = 1 + }, + new + { + Id = 1103, + Caption = "admin_company.edit", + IdType = 1 + }, + new + { + Id = 1104, + Caption = "admin_company_type.view", + IdType = 1 + }, + new + { + Id = 1105, + Caption = "admin_company_type.edit", + IdType = 1 + }, + new + { + Id = 1106, + Caption = "admin_deposit.view", + IdType = 1 + }, + new + { + Id = 1107, + Caption = "admin_deposit.edit", + IdType = 1 + }, + new + { + Id = 1108, + Caption = "admin_permission.view", + IdType = 1 + }, + new + { + Id = 1109, + Caption = "admin_permission.edit", + IdType = 1 + }, + new + { + Id = 1110, + Caption = "admin_role.view", + IdType = 1 + }, + new + { + Id = 1111, + Caption = "admin_role.edit", + IdType = 1 + }, + new + { + Id = 1112, + Caption = "admin_telemetry.view", + IdType = 1 + }, + new + { + Id = 1113, + Caption = "admin_user.view", + IdType = 1 + }, + new + { + Id = 1114, + Caption = "admin_user.edit", + IdType = 1 + }, + new + { + Id = 1115, + Caption = "admin_visit_log.view", + IdType = 1 + }, + new + { + Id = 1116, + Caption = "admin_well.view", + IdType = 1 + }, + new + { + Id = 1117, + Caption = "admin_well.edit", + IdType = 1 + }, + new + { + Id = 1200, + Caption = "archive.view", + IdType = 1 + }, + new + { + Id = 1201, + Caption = "cluster.view", + IdType = 1 + }, + new + { + Id = 1202, + Caption = "composite.view", + IdType = 1 + }, + new + { + Id = 1203, + Caption = "composite.edit", + IdType = 1 + }, + new + { + Id = 1204, + Caption = "deposit.view", + IdType = 1 + }, + new + { + Id = 1205, + Caption = "document.view", + IdType = 1 + }, + new + { + Id = 1206, + Caption = "drillProcessFlow.view", + IdType = 1 + }, + new + { + Id = 1207, + Caption = "drillProcessFlow.edit", + IdType = 1 + }, + new + { + Id = 1208, + Caption = "measure.view", + IdType = 1 + }, + new + { + Id = 1209, + Caption = "measure.edit", + IdType = 1 + }, + new + { + Id = 1210, + Caption = "message.view", + IdType = 1 + }, + new + { + Id = 1211, + Caption = "operations.view", + IdType = 1 + }, + new + { + Id = 1212, + Caption = "operations.edit", + IdType = 1 + }, + new + { + Id = 1213, + Caption = "params.view", + IdType = 1 + }, + new + { + Id = 1214, + Caption = "params.edit", + IdType = 1 + }, + new + { + Id = 1215, + Caption = "report.view", + IdType = 1 + }, + new + { + Id = 1216, + Caption = "report.edit", + IdType = 1 + }, + new + { + Id = 1217, + Caption = "setpoints.view", + IdType = 1 + }, + new + { + Id = 1218, + Caption = "setpoints.edit", + IdType = 1 + }, + new + { + Id = 1219, + Caption = "telemetry.view", + IdType = 1 + }, + new + { + Id = 1220, + Caption = "telemetryAnalysis.view", + IdType = 1 + }, + new + { + Id = 1221, + Caption = "well.view", + IdType = 1 + }, + new + { + Id = 1500, + Caption = "Просмотр всего", + IdType = 1 + }, + new + { + Id = 1501, + Caption = "file.edit", + IdType = 1 + }, + new + { + Id = 1502, + Caption = "drillingProgram.edit", + IdType = 1 + }, + new + { + Id = 2000, + Caption = "Заказчик", + IdType = 0 + }, + new + { + Id = 2001, + Caption = "Супервайзер", + IdType = 0 + }, + new + { + Id = 2002, + Caption = "Буровой подрядчик", + IdType = 0 + }, + new + { + Id = 2003, + Caption = "Растворщик", + IdType = 0 + }, + new + { + Id = 2004, + Caption = "Телеметрист", + IdType = 0 + }, + new + { + Id = 2005, + Caption = "Долотный сервис", + IdType = 0 + }, + new + { + Id = 2006, + Caption = "ГТИ", + IdType = 0 + }, + new + { + Id = 2007, + Caption = "Цементирование", + IdType = 0 + }); + }); + + modelBuilder.Entity("AsbCloudDb.Model.UserSetting", b => + { + b.Property("IdUser") + .HasColumnType("integer") + .HasColumnName("id_user"); + + b.Property("Key") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("key") + .HasComment("Ключ настроек пользователя"); + + b.Property("Value") + .HasColumnType("jsonb") + .HasColumnName("setting_value") + .HasComment("Значение настроек пользователя"); + + b.HasKey("IdUser", "Key"); + + b.ToTable("t_user_settings"); + + b.HasComment("настройки интерфейса пользователя"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.Well", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Caption") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("caption"); + + b.Property("IdCluster") + .HasColumnType("integer") + .HasColumnName("id_cluster"); + + b.Property("IdState") + .HasColumnType("integer") + .HasColumnName("state") + .HasComment("0 - неизвестно, 1 - в работе, 2 - завершена"); + + b.Property("IdTelemetry") + .HasColumnType("integer") + .HasColumnName("id_telemetry"); + + b.Property("IdWellType") + .HasColumnType("integer") + .HasColumnName("id_well_type"); + + b.Property("Latitude") + .HasColumnType("double precision") + .HasColumnName("latitude"); + + b.Property("Longitude") + .HasColumnType("double precision") + .HasColumnName("longitude"); + + b.Property("Timezone") + .IsRequired() + .HasColumnType("jsonb") + .HasColumnName("timezone") + .HasComment("Смещение часового пояса от UTC"); + + b.HasKey("Id"); + + b.HasIndex("IdCluster"); + + b.HasIndex("IdTelemetry") + .IsUnique(); + + b.HasIndex("IdWellType"); + + b.ToTable("t_well"); + + b.HasComment("скважины"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.WellComposite", b => + { + b.Property("IdWell") + .HasColumnType("integer") + .HasColumnName("id_well") + .HasComment("Id скважины получателя"); + + b.Property("IdWellSrc") + .HasColumnType("integer") + .HasColumnName("id_well_src") + .HasComment("Id скважины композита"); + + b.Property("IdWellSectionType") + .HasColumnType("integer") + .HasColumnName("id_well_section_type") + .HasComment("Id тип секции композита"); + + b.HasKey("IdWell", "IdWellSrc", "IdWellSectionType"); + + b.HasIndex("IdWellSectionType"); + + b.HasIndex("IdWellSrc"); + + b.ToTable("t_well_composite"); + + b.HasComment("Композитная скважина"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.WellFinalDocument", b => + { + b.Property("IdWell") + .HasColumnType("integer") + .HasColumnName("id_well"); + + b.Property("IdUser") + .HasColumnType("integer") + .HasColumnName("id_user"); + + b.Property("IdCategory") + .HasColumnType("integer") + .HasColumnName("id_category"); + + b.HasKey("IdWell", "IdUser", "IdCategory") + .HasName("t_well_final_documents_pk"); + + b.HasIndex("IdCategory"); + + b.HasIndex("IdUser"); + + b.ToTable("t_well_final_documents"); + + b.HasComment("Дело скважины"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.WellOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CategoryInfo") + .HasColumnType("text") + .HasColumnName("category_info") + .HasComment("Доп. информация к выбраной категории"); + + b.Property("Comment") + .HasColumnType("text") + .HasColumnName("comment") + .HasComment("Комментарий"); + + b.Property("DateStart") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_start") + .HasComment("Дата начала операции"); + + b.Property("DepthEnd") + .HasColumnType("double precision") + .HasColumnName("depth_end") + .HasComment("Глубина после завершения операции, м"); + + b.Property("DepthStart") + .HasColumnType("double precision") + .HasColumnName("depth_start") + .HasComment("Глубина на начало операции, м"); + + b.Property("DurationHours") + .HasColumnType("double precision") + .HasColumnName("duration_hours") + .HasComment("Продолжительность, часы"); + + b.Property("IdCategory") + .HasColumnType("integer") + .HasColumnName("id_category") + .HasComment("Id категории операции"); + + b.Property("IdPlan") + .HasColumnType("integer") + .HasColumnName("id_plan") + .HasComment("Id плановой операции"); + + b.Property("IdType") + .HasColumnType("integer") + .HasColumnName("id_type") + .HasComment("0 = План или 1 = Факт"); + + b.Property("IdUser") + .HasColumnType("integer"); + + b.Property("IdWell") + .HasColumnType("integer") + .HasColumnName("id_well") + .HasComment("Id скважины"); + + b.Property("IdWellSectionType") + .HasColumnType("integer") + .HasColumnName("id_well_section_type") + .HasComment("Id тип секции скважины"); + + b.Property("LastUpdateDate") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("DateStart"); + + b.HasIndex("DepthEnd"); + + b.HasIndex("IdCategory"); + + b.HasIndex("IdPlan"); + + b.HasIndex("IdWell"); + + b.HasIndex("IdWellSectionType"); + + b.ToTable("t_well_operation"); + + b.HasComment("Данные по операциям на скважине"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.WellOperationCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("IdParent") + .HasColumnType("integer") + .HasColumnName("id_parent") + .HasComment("id родительской категории"); + + b.Property("KeyValueName") + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasColumnName("key_value_name") + .HasComment("Название ключевого показателя операции"); + + b.Property("KeyValueUnits") + .HasMaxLength(16) + .HasColumnType("character varying(16)") + .HasColumnName("key_value_units") + .HasComment("Единицы измерения ключевого показателя операции"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text") + .HasColumnName("name") + .HasComment("Название категории операции"); + + b.HasKey("Id"); + + b.HasIndex("IdParent"); + + b.ToTable("t_well_operation_category"); + + b.HasComment("Справочник операций на скважине"); + + b.HasData( + new + { + Id = 3000, + KeyValueName = "dT", + KeyValueUnits = "м/ч", + Name = "БУРЕНИЕ" + }, + new + { + Id = 3001, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "СПО" + }, + new + { + Id = 3002, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "КРЕПЛЕНИЕ" + }, + new + { + Id = 3003, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "ГФР" + }, + new + { + Id = 3004, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Вспомогательные операции" + }, + new + { + Id = 3005, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Непроизводительное время (НПВ)" + }, + new + { + Id = 4000, + IdParent = 3000, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "КНБК" + }, + new + { + Id = 4001, + IdParent = 3000, + KeyValueName = "dT", + KeyValueUnits = "м/ч", + Name = "Механическое. бурение" + }, + new + { + Id = 4002, + IdParent = 3000, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Статический замер" + }, + new + { + Id = 4003, + IdParent = 3000, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Нормализация диаметра скважины" + }, + new + { + Id = 4004, + IdParent = 3000, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Наращивание" + }, + new + { + Id = 4005, + IdParent = 3001, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "СПО" + }, + new + { + Id = 4006, + IdParent = 3002, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Спуск обсадной колонны" + }, + new + { + Id = 4007, + IdParent = 3002, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Цементирование" + }, + new + { + Id = 4008, + IdParent = 3002, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Вспомогательные работы при креплении" + }, + new + { + Id = 4009, + IdParent = 3003, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Сборка/разборка приборов ГИС" + }, + new + { + Id = 4010, + IdParent = 3003, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "СПО" + }, + new + { + Id = 4011, + IdParent = 3003, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "ГИС" + }, + new + { + Id = 4012, + IdParent = 3004, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Промывка, ОБР" + }, + new + { + Id = 4013, + IdParent = 3004, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Вспомогательные работы" + }, + new + { + Id = 4014, + IdParent = 3005, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Ремонт оборудования" + }, + new + { + Id = 4015, + IdParent = 3005, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Аварийные работы" + }, + new + { + Id = 4016, + IdParent = 3005, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Осложнение" + }, + new + { + Id = 4017, + IdParent = 3005, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Незаложенные в ГГД операции" + }, + new + { + Id = 5000, + IdParent = 4000, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Разборка КНБК" + }, + new + { + Id = 5001, + IdParent = 4000, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Сборка КНБК" + }, + new + { + Id = 5002, + IdParent = 4001, + KeyValueName = "МСП", + KeyValueUnits = "м/ч", + Name = "Бурение слайдом" + }, + new + { + Id = 5003, + IdParent = 4001, + KeyValueName = "МСП", + KeyValueUnits = "м/ч", + Name = "Бурение ротором" + }, + new + { + Id = 5004, + IdParent = 4002, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Замер ЗТС (запись MWD)" + }, + new + { + Id = 5005, + IdParent = 4003, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Промывка перед наращиванием" + }, + new + { + Id = 5006, + IdParent = 4003, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Проработка во время бурения" + }, + new + { + Id = 5007, + IdParent = 4003, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Проработка перед наращиванием" + }, + new + { + Id = 5008, + IdParent = 4003, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Шаблонировка во время бурения" + }, + new + { + Id = 5009, + IdParent = 4003, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Шаблонировка перед наращиванием" + }, + new + { + Id = 5010, + IdParent = 4004, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Наращивание" + }, + new + { + Id = 5011, + IdParent = 4004, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Удержание в клиньях" + }, + new + { + Id = 5012, + IdParent = 4005, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Подъем инструмента" + }, + new + { + Id = 5013, + IdParent = 4005, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Подъем КНБК" + }, + new + { + Id = 5014, + IdParent = 4005, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Спуск инструмента" + }, + new + { + Id = 5015, + IdParent = 4005, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Спуск КНБК" + }, + new + { + Id = 5016, + IdParent = 4006, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Промывка при спуске ОК" + }, + new + { + Id = 5017, + IdParent = 4006, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Спуск ОК" + }, + new + { + Id = 5018, + IdParent = 4007, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "ОЗЦ" + }, + new + { + Id = 5019, + IdParent = 4007, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Цементирование" + }, + new + { + Id = 5020, + IdParent = 4008, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Опрессовка БИ" + }, + new + { + Id = 5021, + IdParent = 4008, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Опрессовка ОК" + }, + new + { + Id = 5022, + IdParent = 4008, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "ПЗР при спуске ОК" + }, + new + { + Id = 5023, + IdParent = 4008, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "ПЗР при цементировании" + }, + new + { + Id = 5024, + IdParent = 4009, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Разборка комплекса приборов ГИС" + }, + new + { + Id = 5025, + IdParent = 4009, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Сборка комплекса приборов ГИС" + }, + new + { + Id = 5026, + IdParent = 4010, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Подъем приборов ГИС (на трубах)" + }, + new + { + Id = 5027, + IdParent = 4010, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Спуск приборов ГИС (на трубах)" + }, + new + { + Id = 5028, + IdParent = 4011, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Комплекс ГИС на жестком кабеле" + }, + new + { + Id = 5029, + IdParent = 4011, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Комплекс ГИС на кабеле" + }, + new + { + Id = 5030, + IdParent = 4011, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Комплекс ГИС на трубах" + }, + new + { + Id = 5031, + IdParent = 4012, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Закачка/прокачка пачки" + }, + new + { + Id = 5032, + IdParent = 4012, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Обработка БР" + }, + new + { + Id = 5033, + IdParent = 4012, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Ориентирование ТС при бурении" + }, + new + { + Id = 5034, + IdParent = 4012, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Перезапись гаммы-каротажа" + }, + new + { + Id = 5035, + IdParent = 4012, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Приготовление БР" + }, + new + { + Id = 5036, + IdParent = 4012, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Промывка" + }, + new + { + Id = 5037, + IdParent = 4012, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Разбуривание тех.оснастки" + }, + new + { + Id = 5038, + IdParent = 4012, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Спуск инструмента с проработкой" + }, + new + { + Id = 5039, + IdParent = 4013, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "ВМР" + }, + new + { + Id = 5040, + IdParent = 4013, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Демонтаж ПВО" + }, + new + { + Id = 5041, + IdParent = 4013, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Долив затруба при подъёме" + }, + new + { + Id = 5042, + IdParent = 4013, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Монтаж ПВО" + }, + new + { + Id = 5043, + IdParent = 4013, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Наработка жёлоба" + }, + new + { + Id = 5044, + IdParent = 4013, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Обвязка устья с циркуляционной системой" + }, + new + { + Id = 5045, + IdParent = 4013, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Оборудование устья" + }, + new + { + Id = 5046, + IdParent = 4013, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Опрессовка ПВО" + }, + new + { + Id = 5047, + IdParent = 4013, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Перемонтаж ПВО " + }, + new + { + Id = 5048, + IdParent = 4013, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Перетяжка талевого каната" + }, + new + { + Id = 5049, + IdParent = 4013, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "ПЗР при сборке КНБК" + }, + new + { + Id = 5050, + IdParent = 4013, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Полная замена талевого каната" + }, + new + { + Id = 5051, + IdParent = 4013, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "ПР перед забуркой направления" + }, + new + { + Id = 5052, + IdParent = 4013, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Продувка манифольда" + }, + new + { + Id = 5053, + IdParent = 4013, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Срезка" + }, + new + { + Id = 5054, + IdParent = 4013, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Тайм-дриллинг" + }, + new + { + Id = 5055, + IdParent = 4013, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Тех.отстой" + }, + new + { + Id = 5056, + IdParent = 4013, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Учебная тревога \"Выброс\"" + }, + new + { + Id = 5057, + IdParent = 4013, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Чистка ЦСГО/емкостного блока" + }, + new + { + Id = 5058, + IdParent = 4014, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Ремонт бурового оборудования" + }, + new + { + Id = 5059, + IdParent = 4015, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Ловильные работы" + }, + new + { + Id = 5060, + IdParent = 4015, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Ожидание" + }, + new + { + Id = 5061, + IdParent = 4015, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Определение места прихвата и ЛМ" + }, + new + { + Id = 5062, + IdParent = 4015, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Работа яссом" + }, + new + { + Id = 5063, + IdParent = 4015, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Расхаживание" + }, + new + { + Id = 5064, + IdParent = 4015, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "СПО - колокол" + }, + new + { + Id = 5065, + IdParent = 4015, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "СПО - метчик" + }, + new + { + Id = 5066, + IdParent = 4015, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "СПО - овершот" + }, + new + { + Id = 5067, + IdParent = 4015, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "СПО - труболовка" + }, + new + { + Id = 5068, + IdParent = 4015, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Торпедирование (встряхивание)" + }, + new + { + Id = 5069, + IdParent = 4015, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Торпедирование (отстрел)" + }, + new + { + Id = 5070, + IdParent = 4015, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Установка ванн" + }, + new + { + Id = 5071, + IdParent = 4015, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Фрезеровка" + }, + new + { + Id = 5072, + IdParent = 4016, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Контролируемое ГНВП" + }, + new + { + Id = 5073, + IdParent = 4016, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Поглощение" + }, + new + { + Id = 5074, + IdParent = 4016, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Сальникообразование" + }, + new + { + Id = 5075, + IdParent = 4016, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Утяжеление БР" + }, + new + { + Id = 5076, + IdParent = 4017, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "НПВ / прочее" + }, + new + { + Id = 5077, + IdParent = 4017, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Обработка раствора (несоответствие параметров)" + }, + new + { + Id = 5078, + IdParent = 4017, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "подъем ОК" + }, + new + { + Id = 5079, + IdParent = 4017, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Ревизия КНБК/инструмента/ЗТС" + }, + new + { + Id = 5082, + IdParent = 4000, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Сборка устройства ориентирования КО" + }, + new + { + Id = 5083, + IdParent = 4003, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Проработка принудительная" + }, + new + { + Id = 5084, + IdParent = 4005, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Шаблонировка подъем БИ, продувка" + }, + new + { + Id = 5085, + IdParent = 4005, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Спуск бурильного инструмента со сборкой с мостков" + }, + new + { + Id = 5086, + IdParent = 4005, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Подъем БИ с выбросом на мостки" + }, + new + { + Id = 5087, + IdParent = 4005, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Спуск БИ со сборкой с мостков" + }, + new + { + Id = 5088, + IdParent = 4005, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Сборка и спуск ТБТ" + }, + new + { + Id = 5089, + IdParent = 4005, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Спуск КО на транспотрной колонне" + }, + new + { + Id = 5090, + IdParent = 4008, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Отворот допускной трубы" + }, + new + { + Id = 5091, + IdParent = 4008, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Активация подвески, опрессовка" + }, + new + { + Id = 5092, + IdParent = 4008, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Монтаж, опрессовка ФА" + }, + new + { + Id = 5093, + IdParent = 4008, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Сборка хвостовика 114мм (согласно схеме)" + }, + new + { + Id = 5094, + IdParent = 4008, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "ПЗР к спуску УЭЦН" + }, + new + { + Id = 5095, + IdParent = 4008, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Активация подвески (потайной колонны, хвостовика)" + }, + new + { + Id = 5096, + IdParent = 4008, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Шаблонирование перед спуском" + }, + new + { + Id = 5097, + IdParent = 4012, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Промывка - перевод скважины на новый раствор" + }, + new + { + Id = 5098, + IdParent = 4013, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Сборка БИ с мостков на подсвечник" + }, + new + { + Id = 5099, + IdParent = 4013, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Подготовка ствола скважины. Перезапись ГК в интервале установки КО." + }, + new + { + Id = 5100, + IdParent = 4013, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Смена рабочего переводника ВСП" + }, + new + { + Id = 5101, + IdParent = 4014, + KeyValueName = "dT", + KeyValueUnits = "мин", + Name = "Ремонт" + }); + }); + + modelBuilder.Entity("AsbCloudDb.Model.WellSectionType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Caption") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("caption") + .HasComment("Название"); + + b.HasKey("Id"); + + b.ToTable("t_well_section_type"); + + b.HasComment("конструкция секции скважины"); + + b.HasData( + new + { + Id = 1, + Caption = "Пилотный ствол" + }, + new + { + Id = 2, + Caption = "Направление" + }, + new + { + Id = 3, + Caption = "Кондуктор" + }, + new + { + Id = 4, + Caption = "Эксплуатационная колонна" + }, + new + { + Id = 5, + Caption = "Транспортный ствол" + }, + new + { + Id = 6, + Caption = "Хвостовик" + }, + new + { + Id = 7, + Caption = "Пилотный ствол 2" + }, + new + { + Id = 8, + Caption = "Направление 2" + }, + new + { + Id = 9, + Caption = "Кондуктор 2" + }, + new + { + Id = 10, + Caption = "Эксплуатационная колонна 2" + }, + new + { + Id = 11, + Caption = "Транспортный ствол 2" + }, + new + { + Id = 12, + Caption = "Хвостовик 2" + }, + new + { + Id = 13, + Caption = "Пилотный ствол 3" + }, + new + { + Id = 14, + Caption = "Направление 3" + }, + new + { + Id = 15, + Caption = "Кондуктор 3" + }, + new + { + Id = 16, + Caption = "Эксплуатационная колонна 3" + }, + new + { + Id = 17, + Caption = "Транспортный ствол 3" + }, + new + { + Id = 18, + Caption = "Хвостовик 3" + }, + new + { + Id = 19, + Caption = "Пилотный ствол 4" + }, + new + { + Id = 20, + Caption = "Направление 4" + }, + new + { + Id = 21, + Caption = "Кондуктор 4" + }, + new + { + Id = 22, + Caption = "Эксплуатационная колонна 4" + }, + new + { + Id = 23, + Caption = "Транспортный ствол 4" + }, + new + { + Id = 24, + Caption = "Хвостовик 4" + }, + new + { + Id = 25, + Caption = "Пилотный ствол 5" + }, + new + { + Id = 26, + Caption = "Направление 5" + }, + new + { + Id = 27, + Caption = "Кондуктор 5" + }, + new + { + Id = 28, + Caption = "Эксплуатационная колонна 5" + }, + new + { + Id = 29, + Caption = "Транспортный ствол 5" + }, + new + { + Id = 30, + Caption = "Хвостовик 5" + }, + new + { + Id = 31, + Caption = "Техническая колонна" + }, + new + { + Id = 32, + Caption = "Техническая колонна 2" + }, + new + { + Id = 33, + Caption = "Техническая колонна 3" + }); + }); + + modelBuilder.Entity("AsbCloudDb.Model.WellType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Caption") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("caption") + .HasComment("Название"); + + b.HasKey("Id"); + + b.ToTable("t_well_type"); + + b.HasComment("конструкция скважины"); + + b.HasData( + new + { + Id = 1, + Caption = "Наклонно-направленная" + }, + new + { + Id = 2, + Caption = "Горизонтальная" + }); + }); + + modelBuilder.Entity("AsbCloudDb.Model.WITS.RecordBase", b => + { + b.Property("IdTelemetry") + .HasColumnType("integer") + .HasColumnName("id_telemetry"); + + b.Property("DateTime") + .HasColumnType("timestamp with time zone") + .HasColumnName("date"); + + b.Property("Actcod") + .HasColumnType("smallint") + .HasColumnName("ACTCOD"); + + b.Property("Date") + .HasColumnType("integer") + .HasColumnName("DATE"); + + b.Property("Recid") + .HasColumnType("smallint") + .HasColumnName("RECID"); + + b.Property("Seqid") + .HasColumnType("integer") + .HasColumnName("SEQID"); + + b.Property("Stknum") + .HasColumnType("smallint") + .HasColumnName("STKNUM"); + + b.Property("Time") + .HasColumnType("integer") + .HasColumnName("TIME"); + + b.Property("Wellid") + .HasColumnType("text") + .HasColumnName("WELLID"); + + b.HasKey("IdTelemetry", "DateTime"); + + b.ToTable("t_telemetry_wits_base"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.WITS.Record1", b => + { + b.HasBaseType("AsbCloudDb.Model.WITS.RecordBase"); + + b.Property("Blkpos") + .HasColumnType("real") + .HasColumnName("BLKPOS"); + + b.Property("Chkp") + .HasColumnType("real") + .HasColumnName("CHKP"); + + b.Property("Deptbitm") + .HasColumnType("real") + .HasColumnName("DEPTBITM"); + + b.Property("Deptbitv") + .HasColumnType("real") + .HasColumnName("DEPTBITV"); + + b.Property("Deptmeas") + .HasColumnType("real") + .HasColumnName("DEPTMEAS"); + + b.Property("Deptretm") + .HasColumnType("real") + .HasColumnName("DEPTRETM"); + + b.Property("Deptvert") + .HasColumnType("real") + .HasColumnName("DEPTVERT"); + + b.Property("Gasa") + .HasColumnType("real") + .HasColumnName("GASA"); + + b.Property("Hkla") + .HasColumnType("real") + .HasColumnName("HKLA"); + + b.Property("Hklx") + .HasColumnType("real") + .HasColumnName("HKLX"); + + b.Property("Lagstks") + .HasColumnType("smallint") + .HasColumnName("LAGSTKS"); + + b.Property("Mcia") + .HasColumnType("real") + .HasColumnName("MCIA"); + + b.Property("Mcoa") + .HasColumnType("real") + .HasColumnName("MCOA"); + + b.Property("Mdia") + .HasColumnType("real") + .HasColumnName("MDIA"); + + b.Property("Mdoa") + .HasColumnType("real") + .HasColumnName("MDOA"); + + b.Property("Mfia") + .HasColumnType("real") + .HasColumnName("MFIA"); + + b.Property("Mfoa") + .HasColumnType("real") + .HasColumnName("MFOA"); + + b.Property("Mfop") + .HasColumnType("smallint") + .HasColumnName("MFOP"); + + b.Property("Mtia") + .HasColumnType("real") + .HasColumnName("MTIA"); + + b.Property("Mtoa") + .HasColumnType("real") + .HasColumnName("MTOA"); + + b.Property("Ropa") + .HasColumnType("real") + .HasColumnName("ROPA"); + + b.Property("Rpma") + .HasColumnType("smallint") + .HasColumnName("RPMA"); + + b.Property("Spare1") + .HasColumnType("real") + .HasColumnName("SPARE1"); + + b.Property("Spare2") + .HasColumnType("real") + .HasColumnName("SPARE2"); + + b.Property("Spare3") + .HasColumnType("real") + .HasColumnName("SPARE3"); + + b.Property("Spare4") + .HasColumnType("real") + .HasColumnName("SPARE4"); + + b.Property("Spare5") + .HasColumnType("real") + .HasColumnName("SPARE5"); + + b.Property("Spm1") + .HasColumnType("smallint") + .HasColumnName("SPM1"); + + b.Property("Spm2") + .HasColumnType("smallint") + .HasColumnName("SPM2"); + + b.Property("Spm3") + .HasColumnType("smallint") + .HasColumnName("SPM3"); + + b.Property("Sppa") + .HasColumnType("real") + .HasColumnName("SPPA"); + + b.Property("Stkc") + .HasColumnType("integer") + .HasColumnName("STKC"); + + b.Property("TelemetryId") + .HasColumnType("integer"); + + b.Property("Torqa") + .HasColumnType("real") + .HasColumnName("TORQA"); + + b.Property("Torqx") + .HasColumnType("real") + .HasColumnName("TORQX"); + + b.Property("Tvolact") + .HasColumnType("real") + .HasColumnName("TVOLACT"); + + b.Property("Tvolcact") + .HasColumnType("real") + .HasColumnName("TVOLCACT"); + + b.Property("Woba") + .HasColumnType("real") + .HasColumnName("WOBA"); + + b.Property("Wobx") + .HasColumnType("real") + .HasColumnName("WOBX"); + + b.HasIndex("TelemetryId"); + + b.ToTable("t_telemetry_wits_1"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.WITS.Record50", b => + { + b.HasBaseType("AsbCloudDb.Model.WITS.RecordBase"); + + b.Property("Deptbitm") + .HasColumnType("real") + .HasColumnName("DEPTBITM"); + + b.Property("DeptmeasGdpMc") + .HasColumnType("real") + .HasColumnName("DEPTMEAS_GDP_mc"); + + b.Property("DeptmeasMcrstat") + .HasColumnType("real") + .HasColumnName("DEPTMEAS_MCRSTAT"); + + b.Property("DeptmeasRa33Mc") + .HasColumnType("real") + .HasColumnName("DEPTMEAS_RA33_mc"); + + b.Property("DeptmeasRa33f2Mc") + .HasColumnType("real") + .HasColumnName("DEPTMEAS_RA33F2_mc"); + + b.Property("DeptmeasRa33f4Mc") + .HasColumnType("real") + .HasColumnName("DEPTMEAS_RA33F4_mc"); + + b.Property("DeptmeasRp33Mc") + .HasColumnType("real") + .HasColumnName("DEPTMEAS_RP33_mc"); + + b.Property("DeptmeasRp33f2Mc") + .HasColumnType("real") + .HasColumnName("DEPTMEAS_RP33F2_mc"); + + b.Property("DeptmeasRp33f4Mc") + .HasColumnType("real") + .HasColumnName("DEPTMEAS_RP33F4_mc"); + + b.Property("DeptmeasSlvlMc") + .HasColumnType("real") + .HasColumnName("DEPTMEAS_SLVL_mc"); + + b.Property("GdpMc") + .HasColumnType("real") + .HasColumnName("GDP_mc"); + + b.Property("Mcrstat") + .HasColumnType("real") + .HasColumnName("MCRSTAT"); + + b.Property("Ra33Mc") + .HasColumnType("real") + .HasColumnName("RA33_mc"); + + b.Property("Ra33f2Mc") + .HasColumnType("real") + .HasColumnName("RA33F2_mc"); + + b.Property("Ra33f4Mc") + .HasColumnType("real") + .HasColumnName("RA33F4_mc"); + + b.Property("Rp33Mc") + .HasColumnType("real") + .HasColumnName("RP33_mc"); + + b.Property("Rp33f2Mc") + .HasColumnType("real") + .HasColumnName("RP33F2_mc"); + + b.Property("Rp33f4Mc") + .HasColumnType("real") + .HasColumnName("RP33F4_mc"); + + b.Property("SlvlMc") + .HasColumnType("real") + .HasColumnName("SLVL_mc"); + + b.Property("TelemetryId") + .HasColumnType("integer"); + + b.HasIndex("TelemetryId"); + + b.ToTable("t_telemetry_wits_50"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.WITS.Record60", b => + { + b.HasBaseType("AsbCloudDb.Model.WITS.RecordBase"); + + b.Property("Btot") + .HasColumnType("real") + .HasColumnName("Btot"); + + b.Property("Bx") + .HasColumnType("real") + .HasColumnName("Bx"); + + b.Property("By") + .HasColumnType("real") + .HasColumnName("By"); + + b.Property("Bz") + .HasColumnType("real") + .HasColumnName("Bz"); + + b.Property("Deptbitm") + .HasColumnType("real") + .HasColumnName("DEPTBITM"); + + b.Property("Deptmeas") + .HasColumnType("real") + .HasColumnName("DEPTMEAS"); + + b.Property("Gtot") + .HasColumnType("real") + .HasColumnName("Gtot"); + + b.Property("Gx") + .HasColumnType("real") + .HasColumnName("Gx"); + + b.Property("Gy") + .HasColumnType("real") + .HasColumnName("Gy"); + + b.Property("Gz") + .HasColumnType("real") + .HasColumnName("Gz"); + + b.Property("TelemetryId") + .HasColumnType("integer"); + + b.HasIndex("TelemetryId"); + + b.ToTable("t_telemetry_wits_60"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.WITS.Record61", b => + { + b.HasBaseType("AsbCloudDb.Model.WITS.RecordBase"); + + b.Property("Att06h") + .HasColumnType("real") + .HasColumnName("ATT06H"); + + b.Property("Att06l") + .HasColumnType("real") + .HasColumnName("ATT06L"); + + b.Property("Att10h") + .HasColumnType("real") + .HasColumnName("ATT10H"); + + b.Property("Att10l") + .HasColumnType("real") + .HasColumnName("ATT10L"); + + b.Property("Deptbitm") + .HasColumnType("real") + .HasColumnName("DEPTBITM"); + + b.Property("Deptmeas") + .HasColumnType("real") + .HasColumnName("DEPTMEAS"); + + b.Property("Phl1f1") + .HasColumnType("real") + .HasColumnName("PHL1F1"); + + b.Property("Phl1f2") + .HasColumnType("real") + .HasColumnName("PHL1F2"); + + b.Property("Phl2f1") + .HasColumnType("real") + .HasColumnName("PHL2F1"); + + b.Property("Phl2f2") + .HasColumnType("real") + .HasColumnName("PHL2F2"); + + b.Property("Status") + .HasColumnType("real") + .HasColumnName("Status"); + + b.Property("TelemetryId") + .HasColumnType("integer"); + + b.HasIndex("TelemetryId"); + + b.ToTable("t_telemetry_wits_61"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.WITS.Record7", b => + { + b.HasBaseType("AsbCloudDb.Model.WITS.RecordBase"); + + b.Property("Deptmeas") + .HasColumnType("real") + .HasColumnName("DEPTMEAS"); + + b.Property("Deptsvym") + .HasColumnType("real") + .HasColumnName("DEPTSVYM"); + + b.Property("Deptsvyv") + .HasColumnType("real") + .HasColumnName("DEPTSVYV"); + + b.Property("Passnum") + .HasColumnType("smallint") + .HasColumnName("PASSNUM"); + + b.Property("Spare1") + .HasColumnType("real") + .HasColumnName("SPARE1"); + + b.Property("Spare2") + .HasColumnType("real") + .HasColumnName("SPARE2"); + + b.Property("Spare3") + .HasColumnType("real") + .HasColumnName("SPARE3"); + + b.Property("Spare4") + .HasColumnType("real") + .HasColumnName("SPARE4"); + + b.Property("Spare5") + .HasColumnType("real") + .HasColumnName("SPARE5"); + + b.Property("Svyazc") + .HasColumnType("real") + .HasColumnName("SVYAZC"); + + b.Property("Svyazu") + .HasColumnType("real") + .HasColumnName("SVYAZU"); + + b.Property("Svydls") + .HasColumnType("real") + .HasColumnName("SVYDLS"); + + b.Property("Svyew") + .HasColumnType("real") + .HasColumnName("SVYEW"); + + b.Property("Svygtf") + .HasColumnType("real") + .HasColumnName("SVYGTF"); + + b.Property("Svyinc") + .HasColumnType("real") + .HasColumnName("SVYINC"); + + b.Property("Svymtf") + .HasColumnType("real") + .HasColumnName("SVYMTF"); + + b.Property("Svyns") + .HasColumnType("real") + .HasColumnName("SVYNS"); + + b.Property("Svytype") + .HasColumnType("text") + .HasColumnName("SVYTYPE"); + + b.Property("Svywalk") + .HasColumnType("real") + .HasColumnName("SVYWALK"); + + b.Property("TelemetryId") + .HasColumnType("integer"); + + b.HasIndex("TelemetryId"); + + b.ToTable("t_telemetry_wits_7"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.WITS.Record8", b => + { + b.HasBaseType("AsbCloudDb.Model.WITS.RecordBase"); + + b.Property("Deptbitm") + .HasColumnType("real") + .HasColumnName("DEPTBITM"); + + b.Property("Deptbitv") + .HasColumnType("real") + .HasColumnName("DEPTBITV"); + + b.Property("Deptcalm") + .HasColumnType("real") + .HasColumnName("DEPTCALM"); + + b.Property("Deptcalv") + .HasColumnType("real") + .HasColumnName("DEPTCALV"); + + b.Property("Deptfdm") + .HasColumnType("real") + .HasColumnName("DEPTFDM"); + + b.Property("Deptfdv") + .HasColumnType("real") + .HasColumnName("DEPTFDV"); + + b.Property("Deptgr1m") + .HasColumnType("real") + .HasColumnName("DEPTGR1M"); + + b.Property("Deptgr1v") + .HasColumnType("real") + .HasColumnName("DEPTGR1V"); + + b.Property("Deptgr2m") + .HasColumnType("real") + .HasColumnName("DEPTGR2M"); + + b.Property("Deptgr2v") + .HasColumnType("real") + .HasColumnName("DEPTGR2V"); + + b.Property("Deptmeas") + .HasColumnType("real") + .HasColumnName("DEPTMEAS"); + + b.Property("Deptp1m") + .HasColumnType("real") + .HasColumnName("DEPTP1M"); + + b.Property("Deptp1v") + .HasColumnType("real") + .HasColumnName("DEPTP1V"); + + b.Property("Deptp2m") + .HasColumnType("real") + .HasColumnName("DEPTP2M"); + + b.Property("Deptp2v") + .HasColumnType("real") + .HasColumnName("DEPTP2V"); + + b.Property("Deptrs1m") + .HasColumnType("real") + .HasColumnName("DEPTRS1M"); + + b.Property("Deptrs1v") + .HasColumnType("real") + .HasColumnName("DEPTRS1V"); + + b.Property("Deptrs2m") + .HasColumnType("real") + .HasColumnName("DEPTRS2M"); + + b.Property("Deptrs2v") + .HasColumnType("real") + .HasColumnName("DEPTRS2V"); + + b.Property("Deptvert") + .HasColumnType("real") + .HasColumnName("DEPTVERT"); + + b.Property("Mclp") + .HasColumnType("real") + .HasColumnName("MCLP"); + + b.Property("Mfd") + .HasColumnType("real") + .HasColumnName("MFD"); + + b.Property("Mffp") + .HasColumnType("real") + .HasColumnName("MFFP"); + + b.Property("Mfpp") + .HasColumnType("real") + .HasColumnName("MFPP"); + + b.Property("Mfrann") + .HasColumnType("real") + .HasColumnName("MFRANN"); + + b.Property("Mfrpipe") + .HasColumnType("real") + .HasColumnName("MFRPIPE"); + + b.Property("Mftann") + .HasColumnType("real") + .HasColumnName("MFTANN"); + + b.Property("Mftpipe") + .HasColumnType("real") + .HasColumnName("MFTPIPE"); + + b.Property("Mg1") + .HasColumnType("real") + .HasColumnName("MG1"); + + b.Property("Mg1c") + .HasColumnType("real") + .HasColumnName("MG1C"); + + b.Property("Mg2") + .HasColumnType("real") + .HasColumnName("MG2"); + + b.Property("Mg2c") + .HasColumnType("real") + .HasColumnName("MG2C"); + + b.Property("Mpo1") + .HasColumnType("real") + .HasColumnName("MPO1"); + + b.Property("Mpo2") + .HasColumnType("real") + .HasColumnName("MPO2"); + + b.Property("Mr1") + .HasColumnType("real") + .HasColumnName("MR1"); + + b.Property("Mr1c") + .HasColumnType("real") + .HasColumnName("MR1C"); + + b.Property("Mr2") + .HasColumnType("real") + .HasColumnName("MR2"); + + b.Property("Mr2c") + .HasColumnType("real") + .HasColumnName("MR2C"); + + b.Property("Passnum") + .HasColumnType("smallint") + .HasColumnName("PASSNUM"); + + b.Property("Spare1") + .HasColumnType("real") + .HasColumnName("SPARE1"); + + b.Property("Spare2") + .HasColumnType("real") + .HasColumnName("SPARE2"); + + b.Property("Spare3") + .HasColumnType("real") + .HasColumnName("SPARE3"); + + b.Property("Spare4") + .HasColumnType("real") + .HasColumnName("SPARE4"); + + b.Property("Spare5") + .HasColumnType("real") + .HasColumnName("SPARE5"); + + b.Property("Spare6") + .HasColumnType("real") + .HasColumnName("SPARE6"); + + b.Property("Spare7") + .HasColumnType("real") + .HasColumnName("SPARE7"); + + b.Property("Spare8") + .HasColumnType("real") + .HasColumnName("SPARE8"); + + b.Property("Spare9") + .HasColumnType("real") + .HasColumnName("SPARE9"); + + b.Property("TelemetryId") + .HasColumnType("integer"); + + b.HasIndex("TelemetryId"); + + b.ToTable("t_telemetry_wits_8"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.Cluster", b => + { + b.HasOne("AsbCloudDb.Model.Deposit", "Deposit") + .WithMany("Clusters") + .HasForeignKey("IdDeposit") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("t_cluster_t_deposit_id_fk"); + + b.Navigation("Deposit"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.Company", b => + { + b.HasOne("AsbCloudDb.Model.CompanyType", "CompanyType") + .WithMany("Companies") + .HasForeignKey("IdCompanyType") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CompanyType"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.DailyReport.DailyReport", b => + { + b.HasOne("AsbCloudDb.Model.Well", "Well") + .WithMany() + .HasForeignKey("IdWell") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Well"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.DetectedOperation", b => + { + b.HasOne("AsbCloudDb.Model.WellOperationCategory", "OperationCategory") + .WithMany() + .HasForeignKey("IdCategory") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AsbCloudDb.Model.Telemetry", "Telemetry") + .WithMany() + .HasForeignKey("IdTelemetry") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("OperationCategory"); + + b.Navigation("Telemetry"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.DrillingProgramPart", b => + { + b.HasOne("AsbCloudDb.Model.FileCategory", "FileCategory") + .WithMany() + .HasForeignKey("IdFileCategory") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AsbCloudDb.Model.Well", "Well") + .WithMany("DrillingProgramParts") + .HasForeignKey("IdWell") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FileCategory"); + + b.Navigation("Well"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.FileInfo", b => + { + b.HasOne("AsbCloudDb.Model.User", "Author") + .WithMany("Files") + .HasForeignKey("IdAuthor"); + + b.HasOne("AsbCloudDb.Model.FileCategory", "FileCategory") + .WithMany() + .HasForeignKey("IdCategory") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AsbCloudDb.Model.Well", "Well") + .WithMany() + .HasForeignKey("IdWell") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + + b.Navigation("FileCategory"); + + b.Navigation("Well"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.FileMark", b => + { + b.HasOne("AsbCloudDb.Model.FileInfo", "FileInfo") + .WithMany("FileMarks") + .HasForeignKey("IdFile") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("t_file_mark_t_file_info_fk"); + + b.HasOne("AsbCloudDb.Model.User", "User") + .WithMany("FileMarks") + .HasForeignKey("IdUser") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("t_user_t_file_mark_fk"); + + b.Navigation("FileInfo"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.LimitingParameter", b => + { + b.HasOne("AsbCloudDb.Model.Telemetry", "Telemetry") + .WithMany() + .HasForeignKey("IdTelemetry") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Telemetry"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.Measure", b => + { + b.HasOne("AsbCloudDb.Model.MeasureCategory", "Category") + .WithMany("Measures") + .HasForeignKey("IdCategory") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AsbCloudDb.Model.Well", "Well") + .WithMany() + .HasForeignKey("IdWell") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Category"); + + b.Navigation("Well"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.OperationValue", b => + { + b.HasOne("AsbCloudDb.Model.WellOperationCategory", "OperationCategory") + .WithMany() + .HasForeignKey("IdOperationCategory") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AsbCloudDb.Model.Well", "Well") + .WithMany() + .HasForeignKey("IdWell") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("OperationCategory"); + + b.Navigation("Well"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.PlannedTrajectory", b => + { + b.HasOne("AsbCloudDb.Model.User", "User") + .WithMany() + .HasForeignKey("IdUser") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AsbCloudDb.Model.Well", "Well") + .WithMany() + .HasForeignKey("IdWell") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + + b.Navigation("Well"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.ProcessMap", b => + { + b.HasOne("AsbCloudDb.Model.Well", "Well") + .WithMany("ProcessMaps") + .HasForeignKey("IdWell") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AsbCloudDb.Model.WellSectionType", "WellSectionType") + .WithMany() + .HasForeignKey("IdWellSectionType") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Well"); + + b.Navigation("WellSectionType"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.RelationCompanyWell", b => + { + b.HasOne("AsbCloudDb.Model.Company", "Company") + .WithMany("RelationCompaniesWells") + .HasForeignKey("IdCompany") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("t_relation_company_well_t_company_id_fk"); + + b.HasOne("AsbCloudDb.Model.Well", "Well") + .WithMany("RelationCompaniesWells") + .HasForeignKey("IdWell") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("t_relation_company_well_t_well_id_fk"); + + b.Navigation("Company"); + + b.Navigation("Well"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.RelationUserDrillingProgramPart", b => + { + b.HasOne("AsbCloudDb.Model.DrillingProgramPart", "DrillingProgramPart") + .WithMany("RelatedUsers") + .HasForeignKey("IdDrillingProgramPart") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AsbCloudDb.Model.User", "User") + .WithMany() + .HasForeignKey("IdUser") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DrillingProgramPart"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.RelationUserRolePermission", b => + { + b.HasOne("AsbCloudDb.Model.Permission", "Permission") + .WithMany("RelationUserRolePermissions") + .HasForeignKey("IdPermission") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AsbCloudDb.Model.UserRole", "UserRole") + .WithMany("RelationUserRolePermissions") + .HasForeignKey("IdUserRole") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Permission"); + + b.Navigation("UserRole"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.RelationUserRoleUserRole", b => + { + b.HasOne("AsbCloudDb.Model.UserRole", "Role") + .WithMany("RelationUserRoleUserRoles") + .HasForeignKey("Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AsbCloudDb.Model.UserRole", "IncludeRole") + .WithMany() + .HasForeignKey("IdInclude") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IncludeRole"); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.RelationUserUserRole", b => + { + b.HasOne("AsbCloudDb.Model.User", "User") + .WithMany("RelationUsersUserRoles") + .HasForeignKey("IdUser") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AsbCloudDb.Model.UserRole", "UserRole") + .WithMany("RelationUsersUserRoles") + .HasForeignKey("IdUserRole") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + + b.Navigation("UserRole"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.ReportProperty", b => + { + b.HasOne("AsbCloudDb.Model.FileInfo", "File") + .WithMany() + .HasForeignKey("IdFile") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AsbCloudDb.Model.Well", "Well") + .WithMany() + .HasForeignKey("IdWell") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("File"); + + b.Navigation("Well"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.Schedule", b => + { + b.HasOne("AsbCloudDb.Model.Driller", "Driller") + .WithMany("Schedule") + .HasForeignKey("IdDriller") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("t_schedule_t_driller_id_driller"); + + b.HasOne("AsbCloudDb.Model.Well", "Well") + .WithMany() + .HasForeignKey("IdWell") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Driller"); + + b.Navigation("Well"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.SetpointsRequest", b => + { + b.HasOne("AsbCloudDb.Model.User", "Author") + .WithMany() + .HasForeignKey("IdAuthor") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AsbCloudDb.Model.Well", "Well") + .WithMany() + .HasForeignKey("IdWell") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + + b.Navigation("Well"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.Subsystems.SubsystemOperationTime", b => + { + b.HasOne("AsbCloudDb.Model.Subsystems.Subsystem", "Subsystem") + .WithMany() + .HasForeignKey("IdSubsystem") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AsbCloudDb.Model.Telemetry", "Telemetry") + .WithMany() + .HasForeignKey("IdTelemetry") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Subsystem"); + + b.Navigation("Telemetry"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.TelemetryDataSaub", b => + { + b.HasOne("AsbCloudDb.Model.Telemetry", "Telemetry") + .WithMany("DataSaub") + .HasForeignKey("IdTelemetry") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("t_telemetry_data_saub_t_telemetry_id_fk"); + + b.Navigation("Telemetry"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.TelemetryDataSpin", b => + { + b.HasOne("AsbCloudDb.Model.Telemetry", "Telemetry") + .WithMany("DataSpin") + .HasForeignKey("IdTelemetry") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("t_telemetry_data_spin_t_telemetry_id_fk"); + + b.Navigation("Telemetry"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.TelemetryEvent", b => + { + b.HasOne("AsbCloudDb.Model.Telemetry", "Telemetry") + .WithMany("Events") + .HasForeignKey("IdTelemetry") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("t_event_t_telemetry_id_fk"); + + b.Navigation("Telemetry"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.TelemetryMessage", b => + { + b.HasOne("AsbCloudDb.Model.Telemetry", "Telemetry") + .WithMany("Messages") + .HasForeignKey("IdTelemetry") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("t_messages_t_telemetry_id_fk"); + + b.Navigation("Telemetry"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.TelemetryUser", b => + { + b.HasOne("AsbCloudDb.Model.Telemetry", "Telemetry") + .WithMany("Users") + .HasForeignKey("IdTelemetry") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("t_telemetry_user_t_telemetry_id_fk"); + + b.Navigation("Telemetry"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.User", b => + { + b.HasOne("AsbCloudDb.Model.Company", "Company") + .WithMany("Users") + .HasForeignKey("IdCompany") + .OnDelete(DeleteBehavior.SetNull) + .IsRequired() + .HasConstraintName("t_user_t_company_id_fk"); + + b.Navigation("Company"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.UserSetting", b => + { + b.HasOne("AsbCloudDb.Model.User", "User") + .WithMany() + .HasForeignKey("IdUser") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.Well", b => + { + b.HasOne("AsbCloudDb.Model.Cluster", "Cluster") + .WithMany("Wells") + .HasForeignKey("IdCluster") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("t_well_t_cluster_id_fk"); + + b.HasOne("AsbCloudDb.Model.Telemetry", "Telemetry") + .WithOne("Well") + .HasForeignKey("AsbCloudDb.Model.Well", "IdTelemetry") + .OnDelete(DeleteBehavior.SetNull) + .HasConstraintName("t_well_t_telemetry_id_fk"); + + b.HasOne("AsbCloudDb.Model.WellType", "WellType") + .WithMany("Wells") + .HasForeignKey("IdWellType") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("Telemetry"); + + b.Navigation("WellType"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.WellComposite", b => + { + b.HasOne("AsbCloudDb.Model.Well", "Well") + .WithMany("WellComposites") + .HasForeignKey("IdWell") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("t_well_сomposite_t_well_id_fk"); + + b.HasOne("AsbCloudDb.Model.WellSectionType", "WellSectionType") + .WithMany("WellComposites") + .HasForeignKey("IdWellSectionType") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("t_well_сomposite_t_well_section_type_id_fk"); + + b.HasOne("AsbCloudDb.Model.Well", "WellSrc") + .WithMany("WellCompositeSrcs") + .HasForeignKey("IdWellSrc") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("t_well_сomposite_src_t_well_id_fk"); + + b.Navigation("Well"); + + b.Navigation("WellSectionType"); + + b.Navigation("WellSrc"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.WellFinalDocument", b => + { + b.HasOne("AsbCloudDb.Model.FileCategory", "Category") + .WithMany() + .HasForeignKey("IdCategory") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AsbCloudDb.Model.User", "User") + .WithMany() + .HasForeignKey("IdUser") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AsbCloudDb.Model.Well", "Well") + .WithMany() + .HasForeignKey("IdWell") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Category"); + + b.Navigation("User"); + + b.Navigation("Well"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.WellOperation", b => + { + b.HasOne("AsbCloudDb.Model.WellOperationCategory", "OperationCategory") + .WithMany() + .HasForeignKey("IdCategory") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AsbCloudDb.Model.WellOperation", "OperationPlan") + .WithMany() + .HasForeignKey("IdPlan"); + + b.HasOne("AsbCloudDb.Model.Well", "Well") + .WithMany("WellOperations") + .HasForeignKey("IdWell") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AsbCloudDb.Model.WellSectionType", "WellSectionType") + .WithMany("WellOperations") + .HasForeignKey("IdWellSectionType") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("OperationCategory"); + + b.Navigation("OperationPlan"); + + b.Navigation("Well"); + + b.Navigation("WellSectionType"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.WellOperationCategory", b => + { + b.HasOne("AsbCloudDb.Model.WellOperationCategory", "Parent") + .WithMany() + .HasForeignKey("IdParent"); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.WITS.Record1", b => + { + b.HasOne("AsbCloudDb.Model.Telemetry", "Telemetry") + .WithMany() + .HasForeignKey("TelemetryId"); + + b.HasOne("AsbCloudDb.Model.WITS.RecordBase", null) + .WithOne() + .HasForeignKey("AsbCloudDb.Model.WITS.Record1", "IdTelemetry", "DateTime") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Telemetry"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.WITS.Record50", b => + { + b.HasOne("AsbCloudDb.Model.Telemetry", "Telemetry") + .WithMany() + .HasForeignKey("TelemetryId"); + + b.HasOne("AsbCloudDb.Model.WITS.RecordBase", null) + .WithOne() + .HasForeignKey("AsbCloudDb.Model.WITS.Record50", "IdTelemetry", "DateTime") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Telemetry"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.WITS.Record60", b => + { + b.HasOne("AsbCloudDb.Model.Telemetry", "Telemetry") + .WithMany() + .HasForeignKey("TelemetryId"); + + b.HasOne("AsbCloudDb.Model.WITS.RecordBase", null) + .WithOne() + .HasForeignKey("AsbCloudDb.Model.WITS.Record60", "IdTelemetry", "DateTime") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Telemetry"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.WITS.Record61", b => + { + b.HasOne("AsbCloudDb.Model.Telemetry", "Telemetry") + .WithMany() + .HasForeignKey("TelemetryId"); + + b.HasOne("AsbCloudDb.Model.WITS.RecordBase", null) + .WithOne() + .HasForeignKey("AsbCloudDb.Model.WITS.Record61", "IdTelemetry", "DateTime") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Telemetry"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.WITS.Record7", b => + { + b.HasOne("AsbCloudDb.Model.Telemetry", "Telemetry") + .WithMany() + .HasForeignKey("TelemetryId"); + + b.HasOne("AsbCloudDb.Model.WITS.RecordBase", null) + .WithOne() + .HasForeignKey("AsbCloudDb.Model.WITS.Record7", "IdTelemetry", "DateTime") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Telemetry"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.WITS.Record8", b => + { + b.HasOne("AsbCloudDb.Model.Telemetry", "Telemetry") + .WithMany() + .HasForeignKey("TelemetryId"); + + b.HasOne("AsbCloudDb.Model.WITS.RecordBase", null) + .WithOne() + .HasForeignKey("AsbCloudDb.Model.WITS.Record8", "IdTelemetry", "DateTime") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Telemetry"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.Cluster", b => + { + b.Navigation("Wells"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.Company", b => + { + b.Navigation("RelationCompaniesWells"); + + b.Navigation("Users"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.CompanyType", b => + { + b.Navigation("Companies"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.Deposit", b => + { + b.Navigation("Clusters"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.Driller", b => + { + b.Navigation("Schedule"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.DrillingProgramPart", b => + { + b.Navigation("RelatedUsers"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.FileInfo", b => + { + b.Navigation("FileMarks"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.MeasureCategory", b => + { + b.Navigation("Measures"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.Permission", b => + { + b.Navigation("RelationUserRolePermissions"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.Telemetry", b => + { + b.Navigation("DataSaub"); + + b.Navigation("DataSpin"); + + b.Navigation("Events"); + + b.Navigation("Messages"); + + b.Navigation("Users"); + + b.Navigation("Well"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.User", b => + { + b.Navigation("FileMarks"); + + b.Navigation("Files"); + + b.Navigation("RelationUsersUserRoles"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.UserRole", b => + { + b.Navigation("RelationUserRolePermissions"); + + b.Navigation("RelationUserRoleUserRoles"); + + b.Navigation("RelationUsersUserRoles"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.Well", b => + { + b.Navigation("DrillingProgramParts"); + + b.Navigation("ProcessMaps"); + + b.Navigation("RelationCompaniesWells"); + + b.Navigation("WellCompositeSrcs"); + + b.Navigation("WellComposites"); + + b.Navigation("WellOperations"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.WellSectionType", b => + { + b.Navigation("WellComposites"); + + b.Navigation("WellOperations"); + }); + + modelBuilder.Entity("AsbCloudDb.Model.WellType", b => + { + b.Navigation("Wells"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/AsbCloudDb/Migrations/20230404045901_Add_UserEditor_To_WellOperation_Table.cs b/AsbCloudDb/Migrations/20230404045901_Add_UserEditor_To_WellOperation_Table.cs new file mode 100644 index 00000000..09871f08 --- /dev/null +++ b/AsbCloudDb/Migrations/20230404045901_Add_UserEditor_To_WellOperation_Table.cs @@ -0,0 +1,37 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace AsbCloudDb.Migrations +{ + public partial class Add_UserEditor_To_WellOperation_Table : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "IdUser", + table: "t_well_operation", + type: "integer", + nullable: true); + + migrationBuilder.AddColumn( + 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))); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "IdUser", + table: "t_well_operation"); + + migrationBuilder.DropColumn( + name: "LastUpdateDate", + table: "t_well_operation"); + } + } +} diff --git a/AsbCloudDb/Migrations/AsbCloudDbContextModelSnapshot.cs b/AsbCloudDb/Migrations/AsbCloudDbContextModelSnapshot.cs index 1046c583..f8169896 100644 --- a/AsbCloudDb/Migrations/AsbCloudDbContextModelSnapshot.cs +++ b/AsbCloudDb/Migrations/AsbCloudDbContextModelSnapshot.cs @@ -5047,6 +5047,9 @@ namespace AsbCloudDb.Migrations .HasColumnName("id_type") .HasComment("0 = План или 1 = Факт"); + b.Property("IdUser") + .HasColumnType("integer"); + b.Property("IdWell") .HasColumnType("integer") .HasColumnName("id_well") @@ -5057,6 +5060,9 @@ namespace AsbCloudDb.Migrations .HasColumnName("id_well_section_type") .HasComment("Id тип секции скважины"); + b.Property("LastUpdateDate") + .HasColumnType("timestamp with time zone"); + b.HasKey("Id"); b.HasIndex("DateStart"); diff --git a/AsbCloudDb/Model/WellOperation.cs b/AsbCloudDb/Model/WellOperation.cs index c21c8706..4997526b 100644 --- a/AsbCloudDb/Model/WellOperation.cs +++ b/AsbCloudDb/Model/WellOperation.cs @@ -7,7 +7,7 @@ using System.Text.Json.Serialization; namespace AsbCloudDb.Model { [Table("t_well_operation"), Comment("Данные по операциям на скважине")] - public class WellOperation : IId + public class WellOperation : ItemInfo, IId { public const int IdOperationTypePlan = 0; public const int IdOperationTypeFact = 1; diff --git a/AsbCloudInfrastructure/Repository/WellOperationRepository.cs b/AsbCloudInfrastructure/Repository/WellOperationRepository.cs index 94ebc6e0..2c8944a4 100644 --- a/AsbCloudInfrastructure/Repository/WellOperationRepository.cs +++ b/AsbCloudInfrastructure/Repository/WellOperationRepository.cs @@ -373,7 +373,9 @@ namespace AsbCloudInfrastructure.Repository .Where(subOp => subOp.IdType == o.IdType) .Where(subOp => subOp.DateStart <= o.DateStart) .Min(subOp => subOp.DateStart)) - .TotalDays + .TotalDays, + IdUser = o.IdUser, + LastUpdateDate = o.LastUpdateDate.ToOffset(TimeSpan.FromHours(timezone.Hours)) }); if (request.SortFields?.Any() == true) diff --git a/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs b/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs index 11be6762..de64103a 100644 --- a/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs +++ b/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs @@ -186,18 +186,24 @@ namespace AsbCloudInfrastructure.Services.DailyReport var dto = entity.Info.Adapt(); dto.StartDate = entity.StartDate; - var dailyFactOperation = factOperationsForDtos + var dailyFactOperations = factOperationsForDtos .Where(o => DateOnly.FromDateTime(o.DateStart) == dto.StartDate) - .Where(o => o.IdParentCategory is not null) + .Where(o => o.IdParentCategory is not null); + + var lastDailyFactOperation = dailyFactOperations + .OrderByDescending(o => o.LastUpdateDate) + .FirstOrDefault(); + dto.TimeBalance.IdUser = lastDailyFactOperation?.IdUser; + dto.TimeBalance.LastUpdateDate = lastDailyFactOperation?.LastUpdateDate; + dto.TimeBalance.OperationsStat = dailyFactOperations .GroupBy(o => o.IdParentCategory!.Value) .ToDictionary(g => g.Key, g => g.Sum(o => o.DurationHours)); - dto.TimeBalance.OperationsStat = dailyFactOperation; - var blocks = new ItemInfoDto[] { dto.Head, dto.Bha, dto.NoDrilling, + dto.TimeBalance, dto.Saub, dto.Sign }; diff --git a/AsbCloudWebApi/Controllers/DailyReportController.cs b/AsbCloudWebApi/Controllers/DailyReportController.cs index 11183a4e..a7ef385b 100644 --- a/AsbCloudWebApi/Controllers/DailyReportController.cs +++ b/AsbCloudWebApi/Controllers/DailyReportController.cs @@ -1,4 +1,5 @@ -using AsbCloudApp.Data.DailyReport; +using AsbCloudApp.Data; +using AsbCloudApp.Data.DailyReport; using AsbCloudApp.Exceptions; using AsbCloudApp.Repositories; using AsbCloudApp.Services; diff --git a/AsbCloudWebApi/Controllers/WellOperationController.cs b/AsbCloudWebApi/Controllers/WellOperationController.cs index ba91097b..ae1943a6 100644 --- a/AsbCloudWebApi/Controllers/WellOperationController.cs +++ b/AsbCloudWebApi/Controllers/WellOperationController.cs @@ -209,7 +209,11 @@ namespace AsbCloudWebApi.Controllers return Forbid(); foreach (var value in values) + { value.IdWell = idWell; + value.LastUpdateDate = DateTimeOffset.UtcNow; + value.IdUser = User.GetUserId(); + } var result = await operationRepository.InsertRangeAsync(values, token) .ConfigureAwait(false); @@ -236,6 +240,8 @@ namespace AsbCloudWebApi.Controllers value.IdWell = idWell; value.Id = idOperation; + value.LastUpdateDate = DateTimeOffset.UtcNow; + value.IdUser = User.GetUserId(); var result = await operationRepository.UpdateAsync(value, token) .ConfigureAwait(false); From 1dee25442751eb21db9680f617e8962d6eb8c1e5 Mon Sep 17 00:00:00 2001 From: ngfrolov Date: Wed, 5 Apr 2023 13:35:05 +0500 Subject: [PATCH 06/16] TelemetryDataSaubService.GetTelemetryDataStatAsync(..) Add filterBy modes to query. --- .../Services/SAUB/TelemetryDataSaubService.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/AsbCloudInfrastructure/Services/SAUB/TelemetryDataSaubService.cs b/AsbCloudInfrastructure/Services/SAUB/TelemetryDataSaubService.cs index 6d9a140b..8bf021b8 100644 --- a/AsbCloudInfrastructure/Services/SAUB/TelemetryDataSaubService.cs +++ b/AsbCloudInfrastructure/Services/SAUB/TelemetryDataSaubService.cs @@ -36,6 +36,7 @@ namespace AsbCloudInfrastructure.Services.SAUB { var timezone = telemetryService.GetTimezone(idTelemetry); var timezoneOffset = TimeSpan.FromHours(timezone.Hours); + int[] modes = new int[] { 0, 1, 3 }; var query = db.Set() .Where(t => t.IdTelemetry == idTelemetry) @@ -43,6 +44,7 @@ namespace AsbCloudInfrastructure.Services.SAUB .Where(t => t.WellDepth > 0.0001) .Where(t => t.WellDepth - t.BitDepth < 0.01) .Where(t => t.Mode != null) + .Where(t => modes.Contains(t.Mode.Value)) .GroupBy(t => new { t.DateTime.Hour, WellDepthX10 = Math.Truncate(t.WellDepth!.Value * 10), @@ -51,7 +53,7 @@ namespace AsbCloudInfrastructure.Services.SAUB .Select(g => new TelemetryDataSaubStatDto { Count = g.Count(), - Mode = g.Key.Mode??0, + IdMode = g.Key.Mode??0, IdFeedRegulator = g.Key.IdFeedRegulator, DateMin = DateTime.SpecifyKind(g.Min(t => t.DateTime.UtcDateTime) + timezoneOffset, DateTimeKind.Unspecified), From 08e3e34162cf7fa73dcd877f8cd48d7dfd80baa5 Mon Sep 17 00:00:00 2001 From: ngfrolov Date: Wed, 5 Apr 2023 13:35:54 +0500 Subject: [PATCH 07/16] Add BinarySearch extension for Span --- AsbCloudInfrastructure/DateTimeExtentions.cs | 39 ++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/AsbCloudInfrastructure/DateTimeExtentions.cs b/AsbCloudInfrastructure/DateTimeExtentions.cs index 181740a5..01a994b9 100644 --- a/AsbCloudInfrastructure/DateTimeExtentions.cs +++ b/AsbCloudInfrastructure/DateTimeExtentions.cs @@ -37,5 +37,44 @@ namespace AsbCloudInfrastructure var dateTz = date.ToOffset(TimeSpan.FromHours(remoteTimezoneOffsetHours)); return dateTz.DateTime; } + + /// + /// Поиск индекса близкого к value значения в span. + /// Элементы в span должны быть отсортированы по возрастанию по полю propertyGetter. + /// + /// + /// + /// + /// метод получения свойства из объекта класса T + /// искомое значение + /// максимальное кол-во итераций. Прим.: + /// в span из 4000 записей достаточно 9-ти итераций + /// 8_000 => 10 итераций; + /// 16_000 => 11; + /// ... + /// 256_000 => 15; + /// При недостаточном кол-ве итераций индекс может оказаться близко, но это будет не ближайшее значение + /// + /// + public static int BinarySearch(this Span span, Func propertyGetter, TProp value, int maxIterations = 16) + where TProp : IComparable + { + if (span.Length < 2 || --maxIterations < 0) + return 0; + + var indexOfMiddle = span.Length >> 1; + + var comparison = value.CompareTo(propertyGetter(span[indexOfMiddle])); + + if (comparison > 0) + { + var index = indexOfMiddle + 1 + BinarySearch(span[(indexOfMiddle + 1)..], propertyGetter, value, maxIterations); + return index < span.Length ? index : span.Length - 1; + } + else if (comparison < 0) + return BinarySearch(span[..(indexOfMiddle)], propertyGetter, value, maxIterations); + else //if (comparison == 0) + return indexOfMiddle; + } } } From 1f904a7434065a31187782e59e53071d966aa04c Mon Sep 17 00:00:00 2001 From: ngfrolov Date: Wed, 5 Apr 2023 13:36:56 +0500 Subject: [PATCH 08/16] ProcessMapReportService implement all calculations (not tested) --- .../Data/SAUB/TelemetryDataSaubStatDto.cs | 2 +- .../ProcessMap/ProcessMapReportService.cs | 319 +++++++++++++++--- .../Services/SAUB/TelemetryDataSaubService.cs | 2 +- 3 files changed, 280 insertions(+), 43 deletions(-) diff --git a/AsbCloudApp/Data/SAUB/TelemetryDataSaubStatDto.cs b/AsbCloudApp/Data/SAUB/TelemetryDataSaubStatDto.cs index 40514429..8c7b3198 100644 --- a/AsbCloudApp/Data/SAUB/TelemetryDataSaubStatDto.cs +++ b/AsbCloudApp/Data/SAUB/TelemetryDataSaubStatDto.cs @@ -100,7 +100,7 @@ namespace AsbCloudApp.Data.SAUB /// /// Режим САУБ /// - public short Mode { get; set; } + public short IdMode { get; set; } /// /// Текущий критерий бурения diff --git a/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportService.cs b/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportService.cs index 9cd63e0e..9cd788a8 100644 --- a/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportService.cs +++ b/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportService.cs @@ -1,13 +1,8 @@ -using AsbCloudApp.Data; -using AsbCloudApp.Data.ProcessMap; +using AsbCloudApp.Data.ProcessMap; using AsbCloudApp.Data.SAUB; using AsbCloudApp.Exceptions; using AsbCloudApp.Repositories; -using AsbCloudApp.Requests; using AsbCloudApp.Services; -using AsbCloudApp.Services.Subsystems; -using AsbCloudDb.Model; -using AsbCloudApp.Data.Subsystems; using System; using System.Collections.Generic; using System.Linq; @@ -23,23 +18,17 @@ namespace AsbCloudInfrastructure.Services.ProcessMap private readonly IWellOperationRepository wellOperationRepository; private readonly IProcessMapPlanRepository processMapPlanRepository; private readonly ITelemetryDataSaubService telemetryDataSaubService; - private readonly ILimitingParameterRepository limitingParameterRepository; - private readonly ISubsystemOperationTimeService subsystemOperationTimeService; public ProcessMapReportService( IWellService wellService, - IWellOperationRepository wellOperationService, + IWellOperationRepository wellOperationRepository, IProcessMapPlanRepository processMapPlanRepository, - ITelemetryDataSaubService telemetryDataSaubService, - ILimitingParameterRepository limitingParameterRepository, - ISubsystemOperationTimeService subsystemOperationTimeService) + ITelemetryDataSaubService telemetryDataSaubService) { this.wellService = wellService; - this.wellOperationRepository = wellOperationService; + this.wellOperationRepository = wellOperationRepository; this.processMapPlanRepository = processMapPlanRepository; this.telemetryDataSaubService = telemetryDataSaubService; - this.limitingParameterRepository = limitingParameterRepository; - this.subsystemOperationTimeService = subsystemOperationTimeService; } /// @@ -53,50 +42,298 @@ namespace AsbCloudInfrastructure.Services.ProcessMap var processMapPlan = await processMapPlanRepository.GetByIdWellAsync(idWell, token); - if(!processMapPlan.Any()) + if (!processMapPlan.Any()) return Enumerable.Empty(); - var telemetryDataStat = await telemetryDataSaubService.GetTelemetryDataStatAsync(idTelemetry, token); + var telemetryDataStat = (await telemetryDataSaubService.GetTelemetryDataStatAsync(idTelemetry, token)).ToArray(); + if (!telemetryDataStat.Any()) + return Enumerable.Empty(); var result = CalcByIntervals(processMapPlan, telemetryDataStat); return result; } - private IEnumerable CalcByIntervals(IEnumerable processMapPlan, IEnumerable telemetryDataStat) + private IEnumerable CalcByIntervals(IEnumerable processMapPlan, TelemetryDataSaubStatDto[] telemetryDataStat) { - var result = new List(processMapPlan.Count() * 4); - var intervals = GetProcessMapIntervals(processMapPlan); - + var processMapIntervals = processMapPlan + .Select(p => (p.DepthStart, p.DepthEnd)) + .Distinct() + .OrderBy(i => i.DepthStart); + + var result = new List(processMapIntervals.Count() * 4); + + var telemetryIndexStart = Array.FindIndex(telemetryDataStat, t => t.WellDepthMin >= processMapIntervals.First().DepthStart); + if (telemetryIndexStart < 0) + return Enumerable.Empty(); + + IDictionary sectionTypes = wellOperationRepository.GetSectionTypes(); + + foreach (var interval in processMapIntervals) + { + var processMapPlanInterval = processMapPlan + .Where(p => p.DepthStart >= interval.DepthStart && p.DepthEnd <= interval.DepthEnd); + + var telemetryIndexEnd = Array.FindIndex(telemetryDataStat, telemetryIndexStart, t => t.WellDepthMin >= interval.DepthEnd); + var telemetryDataInterval = telemetryDataStat.AsSpan(telemetryIndexStart, telemetryIndexEnd - telemetryIndexStart); + + IEnumerable subIntervalsResult = CalcSubIntervals(interval, processMapPlanInterval, telemetryDataInterval, sectionTypes); + + result.AddRange(subIntervalsResult); + telemetryIndexStart = telemetryIndexEnd; + } + return result; } - private IEnumerable<(double, double)> GetProcessMapIntervals(IEnumerable processMapPlan) + private IEnumerable CalcSubIntervals( + (double DepthStart, double DepthEnd) interval, + IEnumerable processMapPlanInterval, + Span telemetryDataInterval, + IDictionary sectionTypes) { - - return Enumerable.Empty<(double, double)>(); - } + var telemetryDataIntervalLength = telemetryDataInterval.Length; + if (telemetryDataInterval.Length == 0) + return Enumerable.Empty(); - private static DateTime GetInterpolatedDate(WellOperationDto operation, double depth) - { - var ratio = (depth - operation.DepthStart) / (operation.DepthEnd - operation.DepthStart); - var deltaHours = operation.DurationHours * ratio; - var interpolatedDate = operation.DateStart + TimeSpan.FromHours(deltaHours); - return interpolatedDate; - } + var result = new List(); + var telemetryIndexStart = 0; + var subInterval = interval; - private static IEnumerable<(double min, double max)> SplitByIntervals(double min, double max) - { - const double step = 100; - var iMin = min; - var iMax = (1 + (int)(min / step)) * step; - for (; iMax < max; iMax += step) + for (var i = telemetryIndexStart; i < telemetryDataIntervalLength; i++) { - yield return (iMin, iMax); - iMin = iMax; + if (!IsSimilar(telemetryDataInterval[telemetryIndexStart], telemetryDataInterval[i])) + { + subInterval.DepthEnd = telemetryDataInterval[i].WellDepthMax; + + var intervalReportRow = CalcSubIntervalReportRow(subInterval, processMapPlanInterval, telemetryDataInterval[telemetryIndexStart..i], sectionTypes); + result.Add(intervalReportRow); + telemetryIndexStart = i; + subInterval.DepthStart = subInterval.DepthEnd; + } } - yield return (iMin, max); + + subInterval.DepthEnd = interval.DepthEnd; + var intervalReportRowLast = CalcSubIntervalReportRow(subInterval, processMapPlanInterval, telemetryDataInterval[telemetryIndexStart..telemetryDataIntervalLength], sectionTypes); + result.Add(intervalReportRowLast); + return result; } + + private ProcessMapReportDto CalcSubIntervalReportRow( + (double DepthStart, double DepthEnd) subInterval, + IEnumerable processMap, + Span telemetryRowSpan, + IDictionary sectionTypes) + { + var telemetryFirst = telemetryRowSpan[0]; + var telemetryLast = telemetryRowSpan[^1]; + var mode = GetIdMode(telemetryRowSpan); + var processMapByMode = processMap.FirstOrDefault(p => p.IdMode == mode.IdMode); + var processMapFirst = processMap.First(); + var idWellSectionType = processMapByMode?.IdWellSectionType ?? processMapFirst.IdWellSectionType; + + var telemetryStat = AnalyzeTelemetry(telemetryRowSpan); + + var result = new ProcessMapReportDto + { + IdWell = processMapByMode?.IdWell ?? processMapFirst.IdWell, + IdWellSectionType = idWellSectionType, + WellSectionTypeName = sectionTypes[idWellSectionType], + + DepthStart = subInterval.DepthStart, + DepthEnd = subInterval.DepthEnd, + DateStart = telemetryFirst.DateMin, + + MechDrillingHours = (telemetryLast.DateMax - telemetryFirst.DateMin).TotalHours, + DrillingMode = mode.ModeName, + + DeltaDepth = telemetryLast.WellDepthMax - telemetryFirst.WellDepthMin, + + PressureDiff = telemetryStat.Pressure.MakeParams(processMapByMode?.Pressure.Plan), + AxialLoad = telemetryStat.AxialLoad.MakeParams(processMapByMode?.AxialLoad.Plan), + TopDriveTorque = telemetryStat.RotorTorque.MakeParams(processMapByMode?.TopDriveTorque.Plan), + SpeedL​imit = telemetryStat.BlockSpeed.MakeParams(processMapByMode?.RopPlan), + + Rop = telemetryStat.Rop, + Usage = telemetryStat.UsageSaub, + }; + return result; + } + + private static TelemetryStat AnalyzeTelemetry(Span telemetry) + { + var stat = new TelemetryStat(); + + for (int i = 0; i < telemetry.Length; i++) + stat.UpdateStat(telemetry[i]); + + return stat; + } + + private static (int IdMode, string ModeName) GetIdMode(Span telemetryRowSpan) + { + /// Режим работы САУБ в телеметрии: + /// 0 - "РУЧНОЙ" + /// 1 - "БУРЕНИЕ В РОТОРЕ" + /// 3 - "БУРЕНИЕ В СЛАЙДЕ" + + for (int i = 0; i < telemetryRowSpan.Length; i++) + { + var idMode = telemetryRowSpan[i].IdMode; + + if (idMode == 0) + return (0, "Ручной"); + + if (idMode == 1) + return (1, "Ротор"); + + if (idMode == 3) + return (2, "Слайд"); + } + + return (0, "Ручной"); + } + + private static bool IsSimilar(TelemetryDataSaubStatDto telemetry1, TelemetryDataSaubStatDto telemetry2) + { + if (telemetry1.IdMode != telemetry2.IdMode) + return false; + + if (Math.Abs(telemetry1.PressureSp - telemetry2.PressureSp) > 5d) + return false; + + if (Math.Abs(telemetry1.AxialLoadSp - telemetry2.AxialLoadSp) > 1d) + return false; + + if (Math.Abs(telemetry1.RotorTorqueSp - telemetry2.RotorTorqueSp) > 5d) + return false; + + var blockSpeedSpDiff = Math.Abs(telemetry1.BlockSpeedSp - telemetry2.BlockSpeedSp); + if (blockSpeedSpDiff > 5d) + { + if (telemetry1.BlockSpeedSp < 30) + return false; + else if (telemetry1.BlockSpeedSp > 30 && blockSpeedSpDiff > 15d) + return false; + else if (telemetry1.BlockSpeedSp > 80 && blockSpeedSpDiff > 20d) + return false; + } + + return true; + } + } + + class ParamStat + { + private double spWSum; + private double pvWSum; + private double? limitMaxWSum; + private double spUsageDepth; + + private double deltaDepthSum; + + private readonly Func getterSp; + private readonly Func getterPv; + private readonly Func? getterLimitMax; + + private readonly int idFeedRegulator; + + private TelemetryDataSaubStatDto? previous; + + public ParamStat(Func getterSp, + Func getterPv, + Func? getterLimitMax, + int idFeedRegulator) + { + this.getterSp = getterSp; + this.getterPv = getterPv; + this.getterLimitMax = getterLimitMax; + this.idFeedRegulator = idFeedRegulator; + } + + public void UpdateStat(TelemetryDataSaubStatDto current) + { + if(previous is not null) + { + var deltaDepth = current.WellDepthMin - previous.WellDepthMin; + if (deltaDepth > 0) + { + var deltaDepthHalf = deltaDepth / 2; + double CalculateWeight(Func getter) => (getter(previous!) + getter(current)) * deltaDepthHalf; + + spWSum = CalculateWeight(getterSp); + pvWSum = CalculateWeight(getterPv); + if(getterLimitMax is not null) + limitMaxWSum = CalculateWeight(getterLimitMax!); + + if (current.IdFeedRegulator == idFeedRegulator) + spUsageDepth += deltaDepth; + + deltaDepthSum += deltaDepth; + } + } + + previous = current; + } + + public ProcessMapReportParamsDto MakeParams(double? spPlan) + => new ProcessMapReportParamsDto + { + SetpointPlan = spPlan, + SetpointFact = spWSum / deltaDepthSum, + Fact = pvWSum / deltaDepthSum, + Limit = limitMaxWSum / deltaDepthSum, + PercDrillingBySetpoint = spUsageDepth / deltaDepthSum, + }; + } + + class TelemetryStat { + public ParamStat Pressure { get; } + public ParamStat AxialLoad {get; } + public ParamStat RotorTorque {get; } + public ParamStat BlockSpeed {get; } + + private TelemetryDataSaubStatDto? previous; + private double depthSum = 0d; + private double hoursSum = 0d; + + public double Rop => depthSum / hoursSum; + + private double depthWithSaub = 0d; + public double UsageSaub => depthWithSaub / depthSum; + + public TelemetryStat() + { + BlockSpeed = new(t => t.BlockSpeedSp, t => t.BlockSpeed, null, 1); + Pressure = new(t => t.PressureSp, t => t.Pressure, t=>t.PressureDeltaLimitMax, 2); + RotorTorque = new(t => t.RotorTorqueSp, t => t.RotorTorque, t=>t.RotorTorqueLimitMax, 3); + AxialLoad = new(t => t.AxialLoadSp, t => t.AxialLoad, t=>t.AxialLoadLimitMax, 4); + } + + public void UpdateStat(TelemetryDataSaubStatDto current) + { + if(previous is not null) + { + var deltaDepth = current.WellDepthMin - previous.WellDepthMin; + if(deltaDepth > 0) + { + var deltaHours = (current.DateMin - previous.DateMax).TotalHours; + depthSum += deltaDepth; + hoursSum += deltaHours; + + if(current.IdMode == 1 || current.IdMode == 3) + depthWithSaub += deltaDepth; + } + } + previous = current; + + Pressure.UpdateStat(current); + AxialLoad.UpdateStat(current); + RotorTorque.UpdateStat(current); + BlockSpeed.UpdateStat(current); + } + }; + #nullable disable } diff --git a/AsbCloudInfrastructure/Services/SAUB/TelemetryDataSaubService.cs b/AsbCloudInfrastructure/Services/SAUB/TelemetryDataSaubService.cs index 8bf021b8..ddebda4b 100644 --- a/AsbCloudInfrastructure/Services/SAUB/TelemetryDataSaubService.cs +++ b/AsbCloudInfrastructure/Services/SAUB/TelemetryDataSaubService.cs @@ -42,9 +42,9 @@ namespace AsbCloudInfrastructure.Services.SAUB .Where(t => t.IdTelemetry == idTelemetry) .Where(t => t.BlockPosition > 0.0001) .Where(t => t.WellDepth > 0.0001) - .Where(t => t.WellDepth - t.BitDepth < 0.01) .Where(t => t.Mode != null) .Where(t => modes.Contains(t.Mode.Value)) + .Where(t => t.WellDepth - t.BitDepth < 0.01) .GroupBy(t => new { t.DateTime.Hour, WellDepthX10 = Math.Truncate(t.WellDepth!.Value * 10), From 40a3d3ab50472c41045510d63635247be1658bcc Mon Sep 17 00:00:00 2001 From: ngfrolov Date: Thu, 6 Apr 2023 10:25:51 +0500 Subject: [PATCH 09/16] Debugged --- .../Data/ProcessMap/ProcessMapReportDto.cs | 4 +- .../ProcessMap/ProcessMapReportParamsDto.cs | 10 +- AsbCloudApp/Services/IProcessMapService.cs | 2 +- .../ProcessMapReportMakerService.cs | 6 +- .../ProcessMap/ProcessMapReportService.cs | 137 ++++++++++++------ .../Controllers/ProcessMapController.cs | 2 +- AsbCloudWebApi/Rest/ProcessMap.http | 1 + 7 files changed, 99 insertions(+), 63 deletions(-) diff --git a/AsbCloudApp/Data/ProcessMap/ProcessMapReportDto.cs b/AsbCloudApp/Data/ProcessMap/ProcessMapReportDto.cs index 9e753c01..e9192d2c 100644 --- a/AsbCloudApp/Data/ProcessMap/ProcessMapReportDto.cs +++ b/AsbCloudApp/Data/ProcessMap/ProcessMapReportDto.cs @@ -79,7 +79,7 @@ namespace AsbCloudApp.Data.ProcessMap /// /// Ограничение скорости, м/ч /// - public ProcessMapReportParamsDto SpeedL​imit { get; set; } = new(); + public ProcessMapReportParamsDto SpeedLimit { get; set; } = new(); /// /// Процент использования системы АПД, % @@ -89,6 +89,6 @@ namespace AsbCloudApp.Data.ProcessMap /// /// Фактическая механическая скорость, м/ч /// - public double Rop { get; set; } + public double? Rop { get; set; } } } diff --git a/AsbCloudApp/Data/ProcessMap/ProcessMapReportParamsDto.cs b/AsbCloudApp/Data/ProcessMap/ProcessMapReportParamsDto.cs index da002d5c..175de955 100644 --- a/AsbCloudApp/Data/ProcessMap/ProcessMapReportParamsDto.cs +++ b/AsbCloudApp/Data/ProcessMap/ProcessMapReportParamsDto.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace AsbCloudApp.Data.ProcessMap +namespace AsbCloudApp.Data.ProcessMap { /// /// Параметры РТК @@ -34,6 +28,6 @@ namespace AsbCloudApp.Data.ProcessMap /// /// Процент бурения по уставке, % /// - public double? PercDrillingBySetpoint { get; set; } + public double? SetpointUsage { get; set; } } } diff --git a/AsbCloudApp/Services/IProcessMapService.cs b/AsbCloudApp/Services/IProcessMapService.cs index 954d899a..d405869a 100644 --- a/AsbCloudApp/Services/IProcessMapService.cs +++ b/AsbCloudApp/Services/IProcessMapService.cs @@ -16,6 +16,6 @@ namespace AsbCloudApp.Services /// /// /// - Task> GetProcessMapAsync(int idWell, CancellationToken token); + Task> GetProcessMapReportAsync(int idWell, CancellationToken token); } } diff --git a/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportMakerService.cs b/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportMakerService.cs index 8e444a08..71faec0e 100644 --- a/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportMakerService.cs +++ b/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportMakerService.cs @@ -29,7 +29,7 @@ namespace AsbCloudInfrastructure.Services.ProcessMap var stream = GetExcelTemplateStream(); using var workbook = new XLWorkbook(stream, XLEventTracking.Disabled); - var data = await processMapService.GetProcessMapAsync(idWell, token); + var data = await processMapService.GetProcessMapReportAsync(idWell, token); FillProcessMapToWorkbook(workbook, data); @@ -168,7 +168,7 @@ namespace AsbCloudInfrastructure.Services.ProcessMap .SetVal(dataParam.Limit); sheet.Cell(row, column + columnOffsetPercent) - .SetVal(dataParam.PercDrillingBySetpoint); + .SetVal(dataParam.SetpointUsage); } private static void FillIntervalModeDataSpeed(IXLWorksheet sheet, ProcessMapReportParamsDto dataParam, int column, int row) @@ -192,7 +192,7 @@ namespace AsbCloudInfrastructure.Services.ProcessMap .SetVal(dataParam.Limit); sheet.Cell(row, column + columnOffsetPercent) - .SetVal(dataParam.PercDrillingBySetpoint); + .SetVal(dataParam.SetpointUsage); } private static Stream GetExcelTemplateStream() diff --git a/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportService.cs b/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportService.cs index 9cd788a8..1a444f32 100644 --- a/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportService.cs +++ b/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportService.cs @@ -32,7 +32,7 @@ namespace AsbCloudInfrastructure.Services.ProcessMap } /// - public async Task> GetProcessMapAsync(int idWell, CancellationToken token) + public async Task> GetProcessMapReportAsync(int idWell, CancellationToken token) { var well = wellService.GetOrDefault(idWell) ?? throw new ArgumentInvalidException("idWell not found", nameof(idWell)); @@ -56,10 +56,7 @@ namespace AsbCloudInfrastructure.Services.ProcessMap private IEnumerable CalcByIntervals(IEnumerable processMapPlan, TelemetryDataSaubStatDto[] telemetryDataStat) { - var processMapIntervals = processMapPlan - .Select(p => (p.DepthStart, p.DepthEnd)) - .Distinct() - .OrderBy(i => i.DepthStart); + var processMapIntervals = CalcDepthIntervals(processMapPlan); var result = new List(processMapIntervals.Count() * 4); @@ -75,6 +72,8 @@ namespace AsbCloudInfrastructure.Services.ProcessMap .Where(p => p.DepthStart >= interval.DepthStart && p.DepthEnd <= interval.DepthEnd); var telemetryIndexEnd = Array.FindIndex(telemetryDataStat, telemetryIndexStart, t => t.WellDepthMin >= interval.DepthEnd); + if (telemetryIndexEnd < 0) + telemetryIndexEnd = telemetryDataStat.Length - 1; var telemetryDataInterval = telemetryDataStat.AsSpan(telemetryIndexStart, telemetryIndexEnd - telemetryIndexStart); IEnumerable subIntervalsResult = CalcSubIntervals(interval, processMapPlanInterval, telemetryDataInterval, sectionTypes); @@ -86,7 +85,24 @@ namespace AsbCloudInfrastructure.Services.ProcessMap return result; } - private IEnumerable CalcSubIntervals( + private static IEnumerable<(double DepthStart, double DepthEnd)> CalcDepthIntervals(IEnumerable processMapPlan) + { + if(!processMapPlan.Any()) + yield break; + + var intervalStarts = processMapPlan + .OrderBy(i => i.DepthStart) + .Select(p => p.DepthStart) + .Distinct() + .ToArray(); + + for (var i = 1; i < intervalStarts.Length; i++) + yield return (intervalStarts[i - 1], intervalStarts[i]); + + yield return (intervalStarts[^1], processMapPlan.Max(p=>p.DepthEnd)); + } + + private static IEnumerable CalcSubIntervals( (double DepthStart, double DepthEnd) interval, IEnumerable processMapPlanInterval, Span telemetryDataInterval, @@ -100,14 +116,17 @@ namespace AsbCloudInfrastructure.Services.ProcessMap var telemetryIndexStart = 0; var subInterval = interval; - for (var i = telemetryIndexStart; i < telemetryDataIntervalLength; i++) + for (var i = telemetryIndexStart + 1; i < telemetryDataIntervalLength; i++) { - if (!IsSimilar(telemetryDataInterval[telemetryIndexStart], telemetryDataInterval[i])) + if (IsDifferent(telemetryDataInterval[telemetryIndexStart], telemetryDataInterval[i])) { - subInterval.DepthEnd = telemetryDataInterval[i].WellDepthMax; - - var intervalReportRow = CalcSubIntervalReportRow(subInterval, processMapPlanInterval, telemetryDataInterval[telemetryIndexStart..i], sectionTypes); - result.Add(intervalReportRow); + subInterval.DepthEnd = telemetryDataInterval[i - 1].WellDepthMax; + var telemetryRowSpan = telemetryDataInterval[telemetryIndexStart..(i - 1)]; + if (!telemetryRowSpan.IsEmpty) + { + var intervalReportRow = CalcSubIntervalReportRow(subInterval, processMapPlanInterval, telemetryRowSpan, sectionTypes); + result.Add(intervalReportRow); + } telemetryIndexStart = i; subInterval.DepthStart = subInterval.DepthEnd; } @@ -119,7 +138,7 @@ namespace AsbCloudInfrastructure.Services.ProcessMap return result; } - private ProcessMapReportDto CalcSubIntervalReportRow( + private static ProcessMapReportDto CalcSubIntervalReportRow( (double DepthStart, double DepthEnd) subInterval, IEnumerable processMap, Span telemetryRowSpan, @@ -149,10 +168,10 @@ namespace AsbCloudInfrastructure.Services.ProcessMap DeltaDepth = telemetryLast.WellDepthMax - telemetryFirst.WellDepthMin, - PressureDiff = telemetryStat.Pressure.MakeParams(processMapByMode?.Pressure.Plan), - AxialLoad = telemetryStat.AxialLoad.MakeParams(processMapByMode?.AxialLoad.Plan), - TopDriveTorque = telemetryStat.RotorTorque.MakeParams(processMapByMode?.TopDriveTorque.Plan), - SpeedL​imit = telemetryStat.BlockSpeed.MakeParams(processMapByMode?.RopPlan), + PressureDiff = telemetryStat.Pressure.MakeParams(processMapByMode?.Pressure.Plan, telemetryStat.SpUsageDepthTotal), + AxialLoad = telemetryStat.AxialLoad.MakeParams(processMapByMode?.AxialLoad.Plan, telemetryStat.SpUsageDepthTotal), + TopDriveTorque = telemetryStat.RotorTorque.MakeParams(processMapByMode?.TopDriveTorque.Plan, telemetryStat.SpUsageDepthTotal), + SpeedLimit = telemetryStat.BlockSpeed.MakeParams(processMapByMode?.RopPlan, telemetryStat.SpUsageDepthTotal), Rop = telemetryStat.Rop, Usage = telemetryStat.UsageSaub, @@ -194,32 +213,35 @@ namespace AsbCloudInfrastructure.Services.ProcessMap return (0, "Ручной"); } - private static bool IsSimilar(TelemetryDataSaubStatDto telemetry1, TelemetryDataSaubStatDto telemetry2) + private static bool IsDifferent(TelemetryDataSaubStatDto intervalStart, TelemetryDataSaubStatDto current) { - if (telemetry1.IdMode != telemetry2.IdMode) - return false; + if (intervalStart.WellDepthMin > current.WellDepthMin) + return true; - if (Math.Abs(telemetry1.PressureSp - telemetry2.PressureSp) > 5d) - return false; + if (intervalStart.IdMode != current.IdMode) + return true; - if (Math.Abs(telemetry1.AxialLoadSp - telemetry2.AxialLoadSp) > 1d) - return false; + if (Math.Abs(intervalStart.PressureSp - current.PressureSp) > 5d) + return true; - if (Math.Abs(telemetry1.RotorTorqueSp - telemetry2.RotorTorqueSp) > 5d) - return false; + if (Math.Abs(intervalStart.AxialLoadSp - current.AxialLoadSp) > 1d) + return true; - var blockSpeedSpDiff = Math.Abs(telemetry1.BlockSpeedSp - telemetry2.BlockSpeedSp); + if (Math.Abs(intervalStart.RotorTorqueSp - current.RotorTorqueSp) > 5d) + return true; + + var blockSpeedSpDiff = Math.Abs(intervalStart.BlockSpeedSp - current.BlockSpeedSp); if (blockSpeedSpDiff > 5d) { - if (telemetry1.BlockSpeedSp < 30) - return false; - else if (telemetry1.BlockSpeedSp > 30 && blockSpeedSpDiff > 15d) - return false; - else if (telemetry1.BlockSpeedSp > 80 && blockSpeedSpDiff > 20d) - return false; + if (intervalStart.BlockSpeedSp <= 30) + return true; + else if (intervalStart.BlockSpeedSp > 30 && blockSpeedSpDiff > 15d) + return true; + else if (intervalStart.BlockSpeedSp > 80 && blockSpeedSpDiff > 20d) + return true; } - return true; + return false; } } @@ -228,8 +250,7 @@ namespace AsbCloudInfrastructure.Services.ProcessMap { private double spWSum; private double pvWSum; - private double? limitMaxWSum; - private double spUsageDepth; + private double limitMaxWSum; private double deltaDepthSum; @@ -238,9 +259,11 @@ namespace AsbCloudInfrastructure.Services.ProcessMap private readonly Func? getterLimitMax; private readonly int idFeedRegulator; - + private TelemetryDataSaubStatDto? previous; + public double SpUsageDepth { get; private set; } + public ParamStat(Func getterSp, Func getterPv, Func? getterLimitMax, @@ -262,13 +285,22 @@ namespace AsbCloudInfrastructure.Services.ProcessMap var deltaDepthHalf = deltaDepth / 2; double CalculateWeight(Func getter) => (getter(previous!) + getter(current)) * deltaDepthHalf; - spWSum = CalculateWeight(getterSp); - pvWSum = CalculateWeight(getterPv); + spWSum += CalculateWeight(getterSp); + pvWSum += CalculateWeight(getterPv); if(getterLimitMax is not null) - limitMaxWSum = CalculateWeight(getterLimitMax!); + limitMaxWSum += CalculateWeight(getterLimitMax!); - if (current.IdFeedRegulator == idFeedRegulator) - spUsageDepth += deltaDepth; + if (current.IdFeedRegulator is not null) + { + if(current.IdFeedRegulator == idFeedRegulator) + SpUsageDepth += deltaDepth; + } + else + { + var pvErr = (getterSp(current) - getterPv(current)) / getterSp(current); + if (pvErr < 0.03d) //3% + SpUsageDepth += deltaDepth; + } deltaDepthSum += deltaDepth; } @@ -277,15 +309,22 @@ namespace AsbCloudInfrastructure.Services.ProcessMap previous = current; } - public ProcessMapReportParamsDto MakeParams(double? spPlan) + public ProcessMapReportParamsDto MakeParams(double? spPlan, double SpUsageDepthTotal) => new ProcessMapReportParamsDto { SetpointPlan = spPlan, - SetpointFact = spWSum / deltaDepthSum, - Fact = pvWSum / deltaDepthSum, - Limit = limitMaxWSum / deltaDepthSum, - PercDrillingBySetpoint = spUsageDepth / deltaDepthSum, + SetpointFact = DivideValByDepth(spWSum), + Fact = DivideValByDepth(pvWSum), + Limit = (getterLimitMax is not null) ? DivideValByDepth(limitMaxWSum) : null, + SetpointUsage = deltaDepthSum > 0d ? SpUsageDepth / SpUsageDepthTotal : null, }; + + private double? DivideValByDepth(double? val) + { + if(val is null || val == 0d || deltaDepthSum == 0d) + return null; + return val / deltaDepthSum; + } } class TelemetryStat { @@ -294,11 +333,13 @@ namespace AsbCloudInfrastructure.Services.ProcessMap public ParamStat RotorTorque {get; } public ParamStat BlockSpeed {get; } + public double SpUsageDepthTotal => Pressure.SpUsageDepth + AxialLoad.SpUsageDepth + RotorTorque.SpUsageDepth + BlockSpeed.SpUsageDepth; + private TelemetryDataSaubStatDto? previous; private double depthSum = 0d; private double hoursSum = 0d; - public double Rop => depthSum / hoursSum; + public double? Rop => hoursSum == 0d ? null : depthSum / hoursSum; private double depthWithSaub = 0d; public double UsageSaub => depthWithSaub / depthSum; diff --git a/AsbCloudWebApi/Controllers/ProcessMapController.cs b/AsbCloudWebApi/Controllers/ProcessMapController.cs index 3613f32c..e2a87c71 100644 --- a/AsbCloudWebApi/Controllers/ProcessMapController.cs +++ b/AsbCloudWebApi/Controllers/ProcessMapController.cs @@ -122,7 +122,7 @@ namespace AsbCloudWebApi.Controllers [ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)] public async Task GetDrillProcessMap(int wellId, CancellationToken token) { - var data = await processMapService.GetProcessMapAsync(wellId, token); + var data = await processMapService.GetProcessMapReportAsync(wellId, token); return Ok(data); } diff --git a/AsbCloudWebApi/Rest/ProcessMap.http b/AsbCloudWebApi/Rest/ProcessMap.http index 9a7d487e..48c0b582 100644 --- a/AsbCloudWebApi/Rest/ProcessMap.http +++ b/AsbCloudWebApi/Rest/ProcessMap.http @@ -11,3 +11,4 @@ GET {{baseUrl}}/api/processMap/getDrillProcessMap/{{wellId}} Content-Type: {{contentType}} accept: */* Authorization: {{auth}} +l \ No newline at end of file From 93a8a7bd7ffa823d988ebd0e54d91fad4407f465 Mon Sep 17 00:00:00 2001 From: Olga Nemt Date: Thu, 6 Apr 2023 15:18:29 +0500 Subject: [PATCH 10/16] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=BF=D0=BE=20=D0=BE=D1=82=D1=87=D0=B5=D1=82=D1=83=20-=20?= =?UTF-8?q?=D1=80=D1=82=D0=BA=201.=20=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D1=88=D0=B0=D0=BF=D0=BA=D0=B0=20=D0=BE=D1=82?= =?UTF-8?q?=D1=87=D0=B5=D1=82=D0=B0=202.=20=D0=94=D0=B0=D0=BD=D0=BD=D1=8B?= =?UTF-8?q?=D0=B5=20=D0=BE=D1=82=D1=87=D0=B5=D1=82=D0=B0=20-=20=D1=8D?= =?UTF-8?q?=D1=82=D0=BE=20=D0=BF=D0=BB=D0=BE=D1=81=D0=BA=D0=B8=D0=B9=20?= =?UTF-8?q?=D1=81=D0=BF=D0=B8=D1=81=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProcessMapReportMakerService.cs | 77 ++++++++---------- .../ProcessMap/ProcessMapReportTemplate.xlsx | Bin 9177 -> 7628 bytes .../Services/ProcessMap/XLExtentions.cs | 31 ++----- 3 files changed, 44 insertions(+), 64 deletions(-) diff --git a/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportMakerService.cs b/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportMakerService.cs index 71faec0e..01f215ee 100644 --- a/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportMakerService.cs +++ b/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportMakerService.cs @@ -13,9 +13,9 @@ namespace AsbCloudInfrastructure.Services.ProcessMap public class ProcessMapReportMakerService : IProcessMapReportMakerService { const int firstColumn = 2; - const int lastColumn = 61; + const int lastColumn = 49; - const int headerRowsCount = 8; + const int headerRowsCount = 6; private readonly IProcessMapReportService processMapService; @@ -89,63 +89,56 @@ namespace AsbCloudInfrastructure.Services.ProcessMap const int columnRopTime = firstColumn + 3; const int columnMode = firstColumn + 4; - int rowRotor = row; - int rowSlide = row + 1; + sheet.Cell(row, firstColumn) + .SetVal(interval.DepthStart, "0.0"); - sheet.Range(rowRotor, firstColumn, rowSlide, firstColumn) - .Merge(); + sheet.Cell(row, columnDepth) + .SetVal(interval.DepthEnd, "0.0"); - sheet.Range(rowRotor, columnDepth, rowSlide, columnDepth) - .Merge().FirstCell() - .SetVal(interval.DepthStart, "0.0"); - - sheet.Range(rowRotor, columnDate, rowSlide, columnDate) - .Merge().FirstCell() + sheet.Cell(row, columnDate) .SetVal(interval.DateStart); - sheet.Range(rowRotor, columnRopTime, rowSlide, columnRopTime) - .Merge().FirstCell() + sheet.Cell(row, columnRopTime) .SetVal(interval.MechDrillingHours); - //row = FillIntervalModeData(sheet, "Ротор", interval.Rotor, columnMode, row); - //row = FillIntervalModeData(sheet, "Слайд", interval.Slide, columnMode, row); + row = FillIntervalModeData(sheet, interval, columnMode, row); return row; } - //private static int FillIntervalModeData(IXLWorksheet sheet, string modeName, ProcessMapReportRowDto modeData, int column, int row) - //{ - // int columnDeltaDepth = column + 1; - // int columnPressure = columnDeltaDepth + 1; - // int columnLoad = columnPressure + 5; - // int columnTorque = columnLoad + 5; - // int columnSpeed = columnTorque + 5; - // int columnUsagePlan = columnSpeed + 5; - // int columnUsageFact = columnUsagePlan + 1; - // int columnRop = columnUsageFact + 12; + private static int FillIntervalModeData(IXLWorksheet sheet, ProcessMapReportDto modeData, int column, int row) + { + int columnDeltaDepth = column + 1; + int columnPressure = columnDeltaDepth + 1; + int columnLoad = columnPressure + 5; + int columnTorque = columnLoad + 5; + int columnSpeed = columnTorque + 5; + int columnUsagePlan = columnSpeed + 5; + int columnUsageFact = columnUsagePlan + 1; + int columnRop = columnUsageFact + 12; - // sheet.Cell(row, column) - // .SetVal(modeName); + sheet.Cell(row, column) + .SetVal(modeData.DrillingMode); - // sheet.Cell(row, columnDeltaDepth) - // .SetVal(modeData.DeltaDepth); + sheet.Cell(row, columnDeltaDepth) + .SetVal(modeData.DeltaDepth); - // FillIntervalModeDataParam(sheet, modeData.PressureDiff, columnPressure, row); - // FillIntervalModeDataParam(sheet, modeData.AxialLoad, columnLoad, row); - // FillIntervalModeDataParam(sheet, modeData.TopDriveTorque, columnTorque, row); - // FillIntervalModeDataSpeed(sheet, modeData.SpeedLimit, columnSpeed, row); + FillIntervalModeDataParam(sheet, modeData.PressureDiff, columnPressure, row); + FillIntervalModeDataParam(sheet, modeData.AxialLoad, columnLoad, row); + FillIntervalModeDataParam(sheet, modeData.TopDriveTorque, columnTorque, row); + FillIntervalModeDataSpeed(sheet, modeData.SpeedLimit, columnSpeed, row); - // sheet.Cell(row, columnUsagePlan) - // .SetVal(100); + sheet.Cell(row, columnUsagePlan) + .SetVal(100); - // sheet.Cell(row, columnUsageFact) - // .SetVal(modeData.Usage); + sheet.Cell(row, columnUsageFact) + .SetVal(modeData.Usage); - // sheet.Cell(row, columnRop) - // .SetVal(modeData.Rop); + sheet.Cell(row, columnRop) + .SetVal(modeData.Rop); - // return row + 1; - //} + return row + 1; + } private static void FillIntervalModeDataParam(IXLWorksheet sheet, ProcessMapReportParamsDto dataParam, int column, int row) { diff --git a/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportTemplate.xlsx b/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportTemplate.xlsx index 65b418cc90308c683f9812d869fd5e0f7ddc45ae..352ecbfabb3e3833dab496122e9b53602b5b3c91 100644 GIT binary patch delta 5947 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 IB!Be(4^W=nbpQYW delta 7606 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 A>;M1& diff --git a/AsbCloudInfrastructure/Services/ProcessMap/XLExtentions.cs b/AsbCloudInfrastructure/Services/ProcessMap/XLExtentions.cs index 7117e1cf..b5443037 100644 --- a/AsbCloudInfrastructure/Services/ProcessMap/XLExtentions.cs +++ b/AsbCloudInfrastructure/Services/ProcessMap/XLExtentions.cs @@ -5,27 +5,6 @@ namespace AsbCloudInfrastructure.Services.ProcessMap; internal static class XLExtentions { - public static IXLCell SetVal(this IXLCell cell, object value) - { - switch (value) - { - case DateTime dateTime: - cell.SetVal(dateTime); - break; - case IFormattable formattable: - cell.SetVal(formattable); - break; - case string valueString: - cell.SetVal(valueString); - break; - default: - cell.Value = value; - break; - } - - return cell; - } - public static IXLCell SetVal(this IXLCell cell, string value, bool adaptRowHeight = false) { cell.Value = value; @@ -53,11 +32,19 @@ internal static class XLExtentions return cell; } - public static IXLCell SetVal(this IXLCell cell, IFormattable value, string format = "0.00") + public static IXLCell SetVal(this IXLCell cell, int? value, string format = "0.00") { cell.Value = value; cell.DataType = XLDataType.Number; cell.Style.NumberFormat.Format = format; return cell; } + + public static IXLCell SetVal(this IXLCell cell, double? value, string format = "0.00") + { + cell.Value = (value is not null && double.IsFinite(value.Value)) ? value : null; + cell.DataType = XLDataType.Number; + cell.Style.NumberFormat.Format = format; + return cell; + } } From af72eceb4756072a849c711458d6b99bec9a9729 Mon Sep 17 00:00:00 2001 From: ngfrolov Date: Thu, 6 Apr 2023 16:20:21 +0500 Subject: [PATCH 11/16] nit report design fixes --- .../ProcessMapReportMakerService.cs | 2 +- .../ProcessMap/ProcessMapReportTemplate.xlsx | Bin 7628 -> 7785 bytes AsbCloudWebApi/Rest/ProcessMap.http | 8 +++++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportMakerService.cs b/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportMakerService.cs index 01f215ee..f4a1da24 100644 --- a/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportMakerService.cs +++ b/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportMakerService.cs @@ -15,7 +15,7 @@ namespace AsbCloudInfrastructure.Services.ProcessMap const int firstColumn = 2; const int lastColumn = 49; - const int headerRowsCount = 6; + const int headerRowsCount = 5; private readonly IProcessMapReportService processMapService; diff --git a/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportTemplate.xlsx b/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportTemplate.xlsx index 352ecbfabb3e3833dab496122e9b53602b5b3c91..a97e8e640777e200dbbfe3daa50a5cee4e71c953 100644 GIT binary patch delta 5145 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 diff --git a/AsbCloudWebApi/Rest/ProcessMap.http b/AsbCloudWebApi/Rest/ProcessMap.http index 48c0b582..f1816d21 100644 --- a/AsbCloudWebApi/Rest/ProcessMap.http +++ b/AsbCloudWebApi/Rest/ProcessMap.http @@ -11,4 +11,10 @@ GET {{baseUrl}}/api/processMap/getDrillProcessMap/{{wellId}} Content-Type: {{contentType}} accept: */* Authorization: {{auth}} -l \ No newline at end of file + + +### +GET {{baseUrl}}/api/processMap/getReportFile/{{wellId}} +Content-Type: {{contentType}} +accept: */* +Authorization: {{auth}} \ No newline at end of file From 5e8df2e29fa8d904e06792a852be04da2efb549e Mon Sep 17 00:00:00 2001 From: ngfrolov Date: Thu, 6 Apr 2023 17:16:53 +0500 Subject: [PATCH 12/16] Fix calculations --- .../Data/ProcessMap/ProcessMapPlanDto.cs | 2 +- .../ProcessMap/ProcessMapReportService.cs | 148 ++++++++++-------- 2 files changed, 81 insertions(+), 69 deletions(-) diff --git a/AsbCloudApp/Data/ProcessMap/ProcessMapPlanDto.cs b/AsbCloudApp/Data/ProcessMap/ProcessMapPlanDto.cs index ce64f1a3..29a2a63e 100644 --- a/AsbCloudApp/Data/ProcessMap/ProcessMapPlanDto.cs +++ b/AsbCloudApp/Data/ProcessMap/ProcessMapPlanDto.cs @@ -23,7 +23,7 @@ namespace AsbCloudApp.Data.ProcessMap /// /// Id режима 1-ротор, 2 - слайд /// - [Range(1, 2, ErrorMessage = "Id режима должен быть либо 1-ротор либо 2-слайд")] + [Range(0, 2, ErrorMessage = "Id режима должен быть либо 0-ручной либо, 1-ротор либо 2-слайд")] public int IdMode { get; set; } /// diff --git a/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportService.cs b/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportService.cs index 1a444f32..ef9da1c4 100644 --- a/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportService.cs +++ b/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportService.cs @@ -6,6 +6,7 @@ using AsbCloudApp.Services; using System; using System.Collections.Generic; using System.Linq; +using System.Numerics; using System.Threading; using System.Threading.Tasks; @@ -144,15 +145,11 @@ namespace AsbCloudInfrastructure.Services.ProcessMap Span telemetryRowSpan, IDictionary sectionTypes) { - var telemetryFirst = telemetryRowSpan[0]; - var telemetryLast = telemetryRowSpan[^1]; - var mode = GetIdMode(telemetryRowSpan); - var processMapByMode = processMap.FirstOrDefault(p => p.IdMode == mode.IdMode); + var telemetryStat = new TelemetryStat(telemetryRowSpan); + var processMapByMode = processMap.FirstOrDefault(p => p.IdMode == telemetryStat.IdMode); var processMapFirst = processMap.First(); var idWellSectionType = processMapByMode?.IdWellSectionType ?? processMapFirst.IdWellSectionType; - - var telemetryStat = AnalyzeTelemetry(telemetryRowSpan); - + var result = new ProcessMapReportDto { IdWell = processMapByMode?.IdWell ?? processMapFirst.IdWell, @@ -161,17 +158,17 @@ namespace AsbCloudInfrastructure.Services.ProcessMap DepthStart = subInterval.DepthStart, DepthEnd = subInterval.DepthEnd, - DateStart = telemetryFirst.DateMin, + DateStart = telemetryStat.DateStart, - MechDrillingHours = (telemetryLast.DateMax - telemetryFirst.DateMin).TotalHours, - DrillingMode = mode.ModeName, + MechDrillingHours = telemetryStat.MechDrillingHours, + DrillingMode = telemetryStat.ModeName, - DeltaDepth = telemetryLast.WellDepthMax - telemetryFirst.WellDepthMin, + DeltaDepth = telemetryStat.DeltaDepth, - PressureDiff = telemetryStat.Pressure.MakeParams(processMapByMode?.Pressure.Plan, telemetryStat.SpUsageDepthTotal), - AxialLoad = telemetryStat.AxialLoad.MakeParams(processMapByMode?.AxialLoad.Plan, telemetryStat.SpUsageDepthTotal), - TopDriveTorque = telemetryStat.RotorTorque.MakeParams(processMapByMode?.TopDriveTorque.Plan, telemetryStat.SpUsageDepthTotal), - SpeedLimit = telemetryStat.BlockSpeed.MakeParams(processMapByMode?.RopPlan, telemetryStat.SpUsageDepthTotal), + PressureDiff = telemetryStat.Pressure.MakeParams(processMapByMode?.Pressure.Plan), + AxialLoad = telemetryStat.AxialLoad.MakeParams(processMapByMode?.AxialLoad.Plan), + TopDriveTorque = telemetryStat.RotorTorque.MakeParams(processMapByMode?.TopDriveTorque.Plan), + SpeedLimit = telemetryStat.BlockSpeed.MakeParams(processMapByMode?.RopPlan), Rop = telemetryStat.Rop, Usage = telemetryStat.UsageSaub, @@ -179,40 +176,6 @@ namespace AsbCloudInfrastructure.Services.ProcessMap return result; } - private static TelemetryStat AnalyzeTelemetry(Span telemetry) - { - var stat = new TelemetryStat(); - - for (int i = 0; i < telemetry.Length; i++) - stat.UpdateStat(telemetry[i]); - - return stat; - } - - private static (int IdMode, string ModeName) GetIdMode(Span telemetryRowSpan) - { - /// Режим работы САУБ в телеметрии: - /// 0 - "РУЧНОЙ" - /// 1 - "БУРЕНИЕ В РОТОРЕ" - /// 3 - "БУРЕНИЕ В СЛАЙДЕ" - - for (int i = 0; i < telemetryRowSpan.Length; i++) - { - var idMode = telemetryRowSpan[i].IdMode; - - if (idMode == 0) - return (0, "Ручной"); - - if (idMode == 1) - return (1, "Ротор"); - - if (idMode == 3) - return (2, "Слайд"); - } - - return (0, "Ручной"); - } - private static bool IsDifferent(TelemetryDataSaubStatDto intervalStart, TelemetryDataSaubStatDto current) { if (intervalStart.WellDepthMin > current.WellDepthMin) @@ -259,20 +222,24 @@ namespace AsbCloudInfrastructure.Services.ProcessMap private readonly Func? getterLimitMax; private readonly int idFeedRegulator; - + private readonly int idMode; private TelemetryDataSaubStatDto? previous; public double SpUsageDepth { get; private set; } + private static double spUsageTotal; public ParamStat(Func getterSp, Func getterPv, Func? getterLimitMax, - int idFeedRegulator) + int idFeedRegulator, + int idMode) { this.getterSp = getterSp; this.getterPv = getterPv; this.getterLimitMax = getterLimitMax; this.idFeedRegulator = idFeedRegulator; + this.idMode = idMode; + spUsageTotal = 0d; } public void UpdateStat(TelemetryDataSaubStatDto current) @@ -292,14 +259,20 @@ namespace AsbCloudInfrastructure.Services.ProcessMap if (current.IdFeedRegulator is not null) { - if(current.IdFeedRegulator == idFeedRegulator) + if (current.IdFeedRegulator == idFeedRegulator) + { SpUsageDepth += deltaDepth; + spUsageTotal += deltaDepth; + } } else { var pvErr = (getterSp(current) - getterPv(current)) / getterSp(current); if (pvErr < 0.03d) //3% + { SpUsageDepth += deltaDepth; + spUsageTotal += deltaDepth; + } } deltaDepthSum += deltaDepth; @@ -309,16 +282,30 @@ namespace AsbCloudInfrastructure.Services.ProcessMap previous = current; } - public ProcessMapReportParamsDto MakeParams(double? spPlan, double SpUsageDepthTotal) - => new ProcessMapReportParamsDto + public ProcessMapReportParamsDto MakeParams(double? spPlan) + { + var result = new ProcessMapReportParamsDto { SetpointPlan = spPlan, - SetpointFact = DivideValByDepth(spWSum), Fact = DivideValByDepth(pvWSum), - Limit = (getterLimitMax is not null) ? DivideValByDepth(limitMaxWSum) : null, - SetpointUsage = deltaDepthSum > 0d ? SpUsageDepth / SpUsageDepthTotal : null, }; + if (idMode == 0) + { + result.SetpointFact = null; + result.Limit = null; + result.SetpointUsage = null; + } + else + { + result.SetpointFact = DivideValByDepth(spWSum); + result.Limit = (getterLimitMax is not null) ? DivideValByDepth(limitMaxWSum) : null; + result.SetpointUsage = deltaDepthSum > 0d ? SpUsageDepth / spUsageTotal : null; + } + + return result; + } + private double? DivideValByDepth(double? val) { if(val is null || val == 0d || deltaDepthSum == 0d) @@ -333,8 +320,6 @@ namespace AsbCloudInfrastructure.Services.ProcessMap public ParamStat RotorTorque {get; } public ParamStat BlockSpeed {get; } - public double SpUsageDepthTotal => Pressure.SpUsageDepth + AxialLoad.SpUsageDepth + RotorTorque.SpUsageDepth + BlockSpeed.SpUsageDepth; - private TelemetryDataSaubStatDto? previous; private double depthSum = 0d; private double hoursSum = 0d; @@ -342,17 +327,37 @@ namespace AsbCloudInfrastructure.Services.ProcessMap public double? Rop => hoursSum == 0d ? null : depthSum / hoursSum; private double depthWithSaub = 0d; - public double UsageSaub => depthWithSaub / depthSum; + public double UsageSaub { get; private set; } + + public DateTime DateStart { get; private set; } + public float DeltaDepth { get; private set; } + public int IdMode { get; private set; } + public string ModeName { get; private set; } + public double MechDrillingHours { get; private set; } - public TelemetryStat() + public TelemetryStat(Span telemetry) { - BlockSpeed = new(t => t.BlockSpeedSp, t => t.BlockSpeed, null, 1); - Pressure = new(t => t.PressureSp, t => t.Pressure, t=>t.PressureDeltaLimitMax, 2); - RotorTorque = new(t => t.RotorTorqueSp, t => t.RotorTorque, t=>t.RotorTorqueLimitMax, 3); - AxialLoad = new(t => t.AxialLoadSp, t => t.AxialLoad, t=>t.AxialLoadLimitMax, 4); + var telemetryFirst = telemetry[0]; + var telemetryLast = telemetry[^1]; + + IdMode = telemetryFirst.IdMode; + ModeName = GetModeName(IdMode); + DateStart = telemetryFirst.DateMin; + DeltaDepth = telemetryLast.WellDepthMax - telemetryFirst.WellDepthMin; + MechDrillingHours = (telemetryLast.DateMax - telemetryFirst.DateMin).TotalHours; + + BlockSpeed = new(t => t.BlockSpeedSp, t => t.BlockSpeed, null, 1, IdMode); + Pressure = new(t => t.PressureSp, t => t.Pressure, t=>t.PressureDeltaLimitMax, 2, IdMode); + RotorTorque = new(t => t.RotorTorqueSp, t => t.RotorTorque, t=>t.RotorTorqueLimitMax, 3, IdMode); + AxialLoad = new(t => t.AxialLoadSp, t => t.AxialLoad, t=>t.AxialLoadLimitMax, 4, IdMode); + + for (int i = 0; i < telemetry.Length; i++) + UpdateStat(telemetry[i]); + + UsageSaub = depthWithSaub / depthSum; } - public void UpdateStat(TelemetryDataSaubStatDto current) + private void UpdateStat(TelemetryDataSaubStatDto current) { if(previous is not null) { @@ -367,14 +372,21 @@ namespace AsbCloudInfrastructure.Services.ProcessMap depthWithSaub += deltaDepth; } } - previous = current; + previous = current; Pressure.UpdateStat(current); AxialLoad.UpdateStat(current); RotorTorque.UpdateStat(current); BlockSpeed.UpdateStat(current); } - }; + private static string GetModeName(int idMode) + => idMode switch + { + 1 => "Ротор", + 3 => "Слайд", + _ => "Ручной", + }; + } #nullable disable } From 577b699663728db872789d8a927ec2a8b2210889 Mon Sep 17 00:00:00 2001 From: ngfrolov Date: Thu, 6 Apr 2023 17:27:31 +0500 Subject: [PATCH 13/16] Add ProcessMapReportDto.UsagePlan; Fix % (mult 100); --- .../Data/ProcessMap/ProcessMapReportDto.cs | 9 ++++++-- .../ProcessMapReportMakerService.cs | 4 ++-- .../ProcessMap/ProcessMapReportService.cs | 22 ++++++++++--------- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/AsbCloudApp/Data/ProcessMap/ProcessMapReportDto.cs b/AsbCloudApp/Data/ProcessMap/ProcessMapReportDto.cs index e9192d2c..cc7f950a 100644 --- a/AsbCloudApp/Data/ProcessMap/ProcessMapReportDto.cs +++ b/AsbCloudApp/Data/ProcessMap/ProcessMapReportDto.cs @@ -82,9 +82,14 @@ namespace AsbCloudApp.Data.ProcessMap public ProcessMapReportParamsDto SpeedLimit { get; set; } = new(); /// - /// Процент использования системы АПД, % + /// Процент использования системы АПД план, % /// - public double Usage { get; set; } + public double UsagePlan { get; set; } + + /// + /// Процент использования системы АПД факт, % + /// + public double UsageFact { get; set; } /// /// Фактическая механическая скорость, м/ч diff --git a/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportMakerService.cs b/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportMakerService.cs index f4a1da24..aea0e8e6 100644 --- a/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportMakerService.cs +++ b/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportMakerService.cs @@ -129,10 +129,10 @@ namespace AsbCloudInfrastructure.Services.ProcessMap FillIntervalModeDataSpeed(sheet, modeData.SpeedLimit, columnSpeed, row); sheet.Cell(row, columnUsagePlan) - .SetVal(100); + .SetVal(modeData.UsagePlan); sheet.Cell(row, columnUsageFact) - .SetVal(modeData.Usage); + .SetVal(modeData.UsageFact); sheet.Cell(row, columnRop) .SetVal(modeData.Rop); diff --git a/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportService.cs b/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportService.cs index ef9da1c4..f0c69468 100644 --- a/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportService.cs +++ b/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapReportService.cs @@ -171,7 +171,8 @@ namespace AsbCloudInfrastructure.Services.ProcessMap SpeedLimit = telemetryStat.BlockSpeed.MakeParams(processMapByMode?.RopPlan), Rop = telemetryStat.Rop, - Usage = telemetryStat.UsageSaub, + UsagePlan = processMapByMode?.UsageSaub ?? telemetryStat.UsagePredictPlan, + UsageFact = telemetryStat.UsageSaub, }; return result; } @@ -300,7 +301,7 @@ namespace AsbCloudInfrastructure.Services.ProcessMap { result.SetpointFact = DivideValByDepth(spWSum); result.Limit = (getterLimitMax is not null) ? DivideValByDepth(limitMaxWSum) : null; - result.SetpointUsage = deltaDepthSum > 0d ? SpUsageDepth / spUsageTotal : null; + result.SetpointUsage = deltaDepthSum > 0d ? 100d * SpUsageDepth / spUsageTotal : null; } return result; @@ -327,13 +328,13 @@ namespace AsbCloudInfrastructure.Services.ProcessMap public double? Rop => hoursSum == 0d ? null : depthSum / hoursSum; private double depthWithSaub = 0d; - public double UsageSaub { get; private set; } - - public DateTime DateStart { get; private set; } - public float DeltaDepth { get; private set; } - public int IdMode { get; private set; } - public string ModeName { get; private set; } - public double MechDrillingHours { get; private set; } + public double UsageSaub { get; } + public double UsagePredictPlan { get; } + public DateTime DateStart { get; } + public float DeltaDepth { get; } + public int IdMode { get; } + public string ModeName { get; } + public double MechDrillingHours { get; } public TelemetryStat(Span telemetry) { @@ -354,7 +355,8 @@ namespace AsbCloudInfrastructure.Services.ProcessMap for (int i = 0; i < telemetry.Length; i++) UpdateStat(telemetry[i]); - UsageSaub = depthWithSaub / depthSum; + UsageSaub = 100d * depthWithSaub / depthSum; + UsagePredictPlan = IdMode != 0 ? 100d : 0d; } private void UpdateStat(TelemetryDataSaubStatDto current) From 312d653aec96e14799a4f9eb19b429274435cd18 Mon Sep 17 00:00:00 2001 From: ngfrolov Date: Fri, 7 Apr 2023 16:49:28 +0500 Subject: [PATCH 14/16] fix #9844930; Enable nullable for OperationsStatService. --- .../Services/IOperationsStatService.cs | 6 +- .../Services/SAUB/TelemetryDataSaubService.cs | 2 +- .../OperationsStatService.cs | 178 +++++++++--------- .../Services/WellOperationService/Race.cs | 3 +- .../Controllers/OperationStatController.cs | 10 +- .../Controllers/WellOperationController.cs | 2 +- AsbCloudWebApi/Rest/OperationStat.http | 46 +++++ 7 files changed, 147 insertions(+), 100 deletions(-) create mode 100644 AsbCloudWebApi/Rest/OperationStat.http diff --git a/AsbCloudApp/Services/IOperationsStatService.cs b/AsbCloudApp/Services/IOperationsStatService.cs index 6ceb76e1..a92d0553 100644 --- a/AsbCloudApp/Services/IOperationsStatService.cs +++ b/AsbCloudApp/Services/IOperationsStatService.cs @@ -16,7 +16,7 @@ namespace AsbCloudApp.Services /// /// /// - Task GetRopStatAsync(int idWell, CancellationToken token); + Task GetOrDefaultRopStatAsync(int idWell, CancellationToken token); /// /// Получить статистику по скважинам куста, которые доступны компании @@ -25,7 +25,7 @@ namespace AsbCloudApp.Services /// /// /// - Task GetStatClusterAsync(int idCluster, int idCompany, CancellationToken token = default); + Task GetOrDefaultStatClusterAsync(int idCluster, int idCompany, CancellationToken token); /// /// получить статистику по скважине @@ -33,7 +33,7 @@ namespace AsbCloudApp.Services /// /// /// - Task GetWellStatAsync(int idWell, CancellationToken token = default); + Task GetOrDefaultWellStatAsync(int idWell, CancellationToken token); /// /// Получить данные для графика TVD diff --git a/AsbCloudInfrastructure/Services/SAUB/TelemetryDataSaubService.cs b/AsbCloudInfrastructure/Services/SAUB/TelemetryDataSaubService.cs index ddebda4b..af16e2a1 100644 --- a/AsbCloudInfrastructure/Services/SAUB/TelemetryDataSaubService.cs +++ b/AsbCloudInfrastructure/Services/SAUB/TelemetryDataSaubService.cs @@ -43,7 +43,7 @@ namespace AsbCloudInfrastructure.Services.SAUB .Where(t => t.BlockPosition > 0.0001) .Where(t => t.WellDepth > 0.0001) .Where(t => t.Mode != null) - .Where(t => modes.Contains(t.Mode.Value)) + .Where(t => modes.Contains(t.Mode!.Value)) .Where(t => t.WellDepth - t.BitDepth < 0.01) .GroupBy(t => new { t.DateTime.Hour, diff --git a/AsbCloudInfrastructure/Services/WellOperationService/OperationsStatService.cs b/AsbCloudInfrastructure/Services/WellOperationService/OperationsStatService.cs index 1e1dd035..68368e63 100644 --- a/AsbCloudInfrastructure/Services/WellOperationService/OperationsStatService.cs +++ b/AsbCloudInfrastructure/Services/WellOperationService/OperationsStatService.cs @@ -7,12 +7,12 @@ using Microsoft.Extensions.Caching.Memory; using System; using System.Collections.Generic; using System.Linq; -using System.Numerics; using System.Threading; using System.Threading.Tasks; namespace AsbCloudInfrastructure.Services.WellOperationService { +#nullable enable public class OperationsStatService : IOperationsStatService { private readonly IAsbCloudDbContext db; @@ -26,8 +26,15 @@ namespace AsbCloudInfrastructure.Services.WellOperationService this.wellService = wellService; } - public async Task GetStatClusterAsync(int idCluster, int idCompany, CancellationToken token = default) + public async Task GetOrDefaultStatClusterAsync(int idCluster, int idCompany, CancellationToken token) { + var cluster = (await memoryCache + .GetOrCreateBasicAsync(db.Set(), token)) + .FirstOrDefault(c => c.Id == idCluster); + + if (cluster is null) + return null; + var allWellsByCompany = await wellService.GetAsync(new() { IdCompany = idCompany }, token).ConfigureAwait(false); var idWellsByCompany = allWellsByCompany.Select(w => w.Id).Distinct(); @@ -41,9 +48,6 @@ namespace AsbCloudInfrastructure.Services.WellOperationService var statsWells = await GetWellsStatAsync(wells, token).ConfigureAwait(false); - var cluster = (await memoryCache - .GetOrCreateBasicAsync(db.Set(), token)) - .FirstOrDefault(c => c.Id == idCluster); var statClusterDto = new StatClusterDto { Id = idCluster, @@ -71,7 +75,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService return statsWells; } - public async Task GetWellStatAsync(int idWell, + public async Task GetOrDefaultWellStatAsync(int idWell, CancellationToken token = default) { var well = await db.Wells @@ -79,11 +83,14 @@ namespace AsbCloudInfrastructure.Services.WellOperationService .FirstOrDefaultAsync(w => w.Id == idWell, token) .ConfigureAwait(false); + if(well is null) + return null; + var statWellDto = await CalcWellStatAsync(well, token); return statWellDto; } - public async Task GetRopStatAsync(int idWell, CancellationToken token) + public async Task GetOrDefaultRopStatAsync(int idWell, CancellationToken token) { var clusterWellsIds = await wellService.GetClusterWellsIdsAsync(idWell, token) .ConfigureAwait(false); @@ -110,13 +117,15 @@ namespace AsbCloudInfrastructure.Services.WellOperationService .ToListAsync(token) .ConfigureAwait(false); - var statsList = clusterWellsIds.Select(clusterWellId => + var statsList = new List(clusterWellsIds.Count()); + foreach (var clusterWellId in clusterWellsIds) { var currentWellOps = operations.Where(o => o.IdWell == clusterWellId); - var timezoneOffsetH = wellService.GetTimezone(clusterWellId).Hours; - var stat = CalcStat(currentWellOps, timezoneOffsetH); - return stat; - }).Where(c => c is not null); + var timezoneOffsetHours = wellService.GetTimezone(clusterWellId).Hours; + var stat = CalcStat(currentWellOps, timezoneOffsetHours); + if(stat is not null) + statsList.Add(stat); + }; if (!statsList.Any()) return null; @@ -130,7 +139,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService return clusterRops; } - private async Task CalcWellStatAsync(Well well, CancellationToken token = default) + private async Task CalcWellStatAsync(Well well, CancellationToken token) { var wellType = (await memoryCache .GetOrCreateBasicAsync(db.Set(), token)) @@ -164,7 +173,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService return statWellDto; } - private double CalcTvdLagDays(IOrderedEnumerable wellOperations) + private static double CalcTvdLagDays(IOrderedEnumerable wellOperations) { var operationsOrdered = wellOperations .OrderBy(o => o.DateStart); @@ -178,9 +187,13 @@ namespace AsbCloudInfrastructure.Services.WellOperationService if (lastCorrespondingFactOperation is null) return 0d; - var lastCorrespondingPlanOperation = wellOperations.FirstOrDefault(o => o.Id == lastCorrespondingFactOperation.IdPlan); + var lastCorrespondingPlanOperation = wellOperations + .FirstOrDefault(o => o.Id == lastCorrespondingFactOperation.IdPlan); - var lastFactOperation = factOperations.LastOrDefault(); + if (lastCorrespondingPlanOperation is null) + return 0d; + + var lastFactOperation = factOperations.Last(); var remainingPlanOperations = operationsOrdered .Where(o => o.IdType == WellOperation.IdOperationTypePlan) @@ -240,27 +253,27 @@ namespace AsbCloudInfrastructure.Services.WellOperationService return section; } - private static StatOperationsDto CalcSectionStat(IEnumerable operations, int idSectionType, double timezoneOffsetH) + private static StatOperationsDto? CalcSectionStat(IEnumerable operations, int idSectionType, double timezoneOffsetHours) { var sectionOperations = operations .Where(o => o.IdWellSectionType == idSectionType) .OrderBy(o => o.DateStart) .ThenBy(o => o.DepthStart); - return CalcStat(sectionOperations, timezoneOffsetH); + return CalcStat(sectionOperations, timezoneOffsetHours); } - private static StatOperationsDto CalcStat(IEnumerable operations, double timezoneOffsetH) + private static StatOperationsDto? CalcStat(IEnumerable operations, double timezoneOffsetHours) { if (!operations.Any()) return null; - var races = GetCompleteRaces(operations, timezoneOffsetH); + var races = GetCompleteRaces(operations, timezoneOffsetHours); var section = new StatOperationsDto { - Start = operations.FirstOrDefault()?.DateStart.ToRemoteDateTime(timezoneOffsetH), - End = operations.Max(o => o.DateStart.ToRemoteDateTime(timezoneOffsetH).AddHours(o.DurationHours)), + Start = operations.FirstOrDefault()?.DateStart.ToRemoteDateTime(timezoneOffsetHours), + End = operations.Max(o => o.DateStart.ToRemoteDateTime(timezoneOffsetHours).AddHours(o.DurationHours)), WellDepthStart = operations.Min(o => o.DepthStart), WellDepthEnd = operations.Max(o => o.DepthStart), Rop = CalcROP(operations), @@ -356,7 +369,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService { var dDepth = 0d; var dHours = 0d; - foreach (var race in races) + foreach (Race race in races) { dDepth += race.StartWellDepth; for (var i = 0; i < race.Operations.Count; i++) @@ -417,78 +430,71 @@ namespace AsbCloudInfrastructure.Services.WellOperationService var tzOffsetHours = wellService.GetTimezone(idWell).Hours; - if (!wellOperationsPlan.Any()) - return null; - - var merged = MergeArraysBySections(sectionsIds, wellOperationsPlan, wellOperationsFact); + var merged = MergeArraysBySections(sectionsIds, wellOperationsPlan, wellOperationsFact).ToList(); var tvd = new List>(merged.Count); - var firstPoint = merged.First(); - var dateStart = firstPoint.Item1?.DateStart ?? firstPoint.Item2.DateStart; - int iLastMatch = 0; + var (Plan, Fact) = merged.First(); + var dateStart = Plan?.DateStart ?? Fact!.DateStart; + int? iLastMatch = null; int iLastFact = 0; var nptHours = 0d; for (int i = 0; i < merged.Count; i++) { var item = merged[i]; - var plan = item.Item1; - var fact = item.Item2; + var plan = item.Plan; + var fact = item.Fact; - if (fact is not null && WellOperationCategory.NonProductiveTimeSubIds.Contains(fact.IdCategory)) + var planFactPredict = new PlanFactPredictBase(); + if (plan is not null) { - nptHours += fact.DurationHours; + planFactPredict.Plan = Convert(plan, tzOffsetHours); + planFactPredict.Plan.Day = (planFactPredict.Plan.DateStart - dateStart).TotalDays; + if (fact is not null) + iLastMatch = i; } - var planFactPredict = new PlanFactPredictBase + if (fact is not null) { - Plan = Convert(plan, tzOffsetHours), - Fact = Convert(fact, tzOffsetHours), - Predict = null, - }; + if(WellOperationCategory.NonProductiveTimeSubIds.Contains(fact.IdCategory)) + nptHours += fact.DurationHours; - if (planFactPredict.Plan is not null) - planFactPredict.Plan.Day = (planFactPredict.Plan.DateStart - dateStart).TotalDays; - - if (planFactPredict.Fact is not null) - { + planFactPredict.Fact = Convert(fact, tzOffsetHours); planFactPredict.Fact.Day = (planFactPredict.Fact.DateStart - dateStart).TotalDays; planFactPredict.Fact.NptHours = nptHours; + iLastFact = i; } - tvd.Add(planFactPredict); - if ((plan is not null) && (fact is not null)) - iLastMatch = i; - if (fact is not null) - iLastFact = i; + tvd.Add(planFactPredict); } - if (iLastMatch == 0 || iLastMatch == merged.Count - 1) + if (iLastMatch is null || iLastMatch == merged.Count - 1) return tvd; - var lastMatchPlan = merged[iLastMatch].Item1; + var lastMatchPlan = merged[iLastMatch.Value].Plan!; var lastMatchPlanOperationEnd = lastMatchPlan.DateStart.AddHours(lastMatchPlan.DurationHours); - var lastFact = merged[iLastFact].Item2; + var lastFact = merged[iLastFact].Fact!; var lastFactDateEnd = lastFact.DateStart.AddHours(lastFact.DurationHours); var startOffset = lastFactDateEnd - lastMatchPlanOperationEnd; - for (int i = iLastMatch + 1; i < merged.Count; i++) + for (int i = iLastMatch.Value + 1; i < merged.Count; i++) { - if (merged[i].Item1 is null) + if (merged[i].Plan is null) continue; - 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; + var predict = Convert(merged[i].Plan!, tzOffsetHours); + predict.IdType = 2; + predict.DateStart = predict.DateStart + startOffset; + predict.Day = (predict.DateStart - dateStart).TotalDays; + tvd[i].Predict = predict; } return tvd; } - private static List> MergeArraysBySections( + private static IEnumerable<(WellOperation? Plan, WellOperation? Fact)> MergeArraysBySections( IEnumerable sectionsIds, IOrderedEnumerable wellOperationsPlan, IOrderedEnumerable wellOperationsFact) { - var merged = new List>(wellOperationsPlan.Count()); + var merged = new List<(WellOperation? Plan, WellOperation? Fact)>(wellOperationsPlan.Count()); foreach (var sectionId in sectionsIds) { var sectionOperationsPlan = wellOperationsPlan @@ -501,46 +507,38 @@ namespace AsbCloudInfrastructure.Services.WellOperationService return merged; } - private static List> MergeArrays(IEnumerable operationsPlan, IEnumerable operationsFact) + private static IEnumerable<(WellOperation? Plan, WellOperation? Fact)> MergeArrays(IEnumerable operationsPlan, IEnumerable operationsFact) { - var result = new List>(); + var operationsFactWithNoPlan = operationsFact.Where(x => x.IdPlan == null).ToArray(); + var operationsFactWithPlan = operationsFact.Where(x => x.IdPlan != null).ToArray(); - var oparationsFactWithNoPlan = operationsFact - .Where(x => x.IdPlan == null) - .Select(x => new Tuple(null, x)); + var idsPlanWithFact = operationsFact.Where(x => x.IdPlan is not null).Select(x => x.IdPlan).Distinct(); + var operationsPlanWithNoFact = operationsPlan.Where(x => !idsPlanWithFact.Contains(x.IdPlan)).ToArray(); - var oparationsFactWithPlan = operationsFact - .Where(x => x.IdPlan != null) - .Select(x => new Tuple(x.OperationPlan, x)); + var result = new List<(WellOperation? Plan, WellOperation? Fact)>(operationsFactWithNoPlan.Length + operationsFactWithPlan.Length + operationsPlanWithNoFact.Length); - var idsPlanWithFact = operationsFact - .Where(x => x.IdPlan is not null) - .Select(x => x.IdPlan) - .Distinct(); - var oparationsPlanWithNoFact = operationsPlan - .Where(x => !idsPlanWithFact.Contains(x.IdPlan)) - .Select(x => new Tuple(x, null)); + foreach (var operation in operationsFactWithPlan) + result.Add((operation.OperationPlan, operation)); - result.AddRange(oparationsFactWithNoPlan); - result.AddRange(oparationsFactWithPlan); - result.AddRange(oparationsPlanWithNoFact); + foreach (var operation in operationsFactWithNoPlan) + result.Add((null, operation)); - result = result - .OrderBy(x => x.Item1?.DateStart) - .ThenBy(x => x.Item2?.DateStart) - .ToList(); - return result; + foreach (var operation in operationsPlanWithNoFact) + result.Add((operation, null)); + + return result + .OrderBy(x => x.Plan?.DateStart) + .ThenBy(x => x.Fact?.DateStart); } 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; + var destination = source.Adapt(); + destination.CategoryName = source.OperationCategory?.Name; + destination.WellSectionTypeName = source.WellSectionType?.Caption; + destination.DateStart = source.DateStart.ToRemoteDateTime(tzOffsetHours); + return destination; } } +#nullable disable } diff --git a/AsbCloudInfrastructure/Services/WellOperationService/Race.cs b/AsbCloudInfrastructure/Services/WellOperationService/Race.cs index e279111d..182ac88d 100644 --- a/AsbCloudInfrastructure/Services/WellOperationService/Race.cs +++ b/AsbCloudInfrastructure/Services/WellOperationService/Race.cs @@ -1,6 +1,7 @@ using AsbCloudDb.Model; using System; using System.Collections.Generic; +using System.Linq; namespace AsbCloudInfrastructure.Services.WellOperationService { @@ -60,7 +61,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService /// /// Список операций за рейс /// - public List? Operations { get; internal set; } + public List Operations { get; internal set; } = new List(); } #nullable disable } diff --git a/AsbCloudWebApi/Controllers/OperationStatController.cs b/AsbCloudWebApi/Controllers/OperationStatController.cs index cce509fb..d32ea4b7 100644 --- a/AsbCloudWebApi/Controllers/OperationStatController.cs +++ b/AsbCloudWebApi/Controllers/OperationStatController.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; namespace AsbCloudWebApi.Controllers { +#nullable enable /// /// Статистика по операциям (заведенным вручную) на скважине /// @@ -41,7 +42,7 @@ namespace AsbCloudWebApi.Controllers if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false)) return Forbid(); - var result = await operationsStatService.GetRopStatAsync( + var result = await operationsStatService.GetOrDefaultRopStatAsync( idWell, token).ConfigureAwait(false); return Ok(result); @@ -64,7 +65,7 @@ namespace AsbCloudWebApi.Controllers if (idWell is null) return NoContent(); - var result = await operationsStatService.GetRopStatAsync( + var result = await operationsStatService.GetOrDefaultRopStatAsync( (int)idWell, token).ConfigureAwait(false); return Ok(result); @@ -87,7 +88,7 @@ namespace AsbCloudWebApi.Controllers if (idCompany is null) return Forbid(); - var result = await operationsStatService.GetStatClusterAsync(idCluster, idCompany.Value, token) + var result = await operationsStatService.GetOrDefaultStatClusterAsync(idCluster, idCompany.Value, token) .ConfigureAwait(false); return Ok(result); } @@ -132,7 +133,7 @@ namespace AsbCloudWebApi.Controllers if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false)) return Forbid(); - var result = await operationsStatService.GetWellStatAsync(idWell, token) + var result = await operationsStatService.GetOrDefaultWellStatAsync(idWell, token) .ConfigureAwait(false); return Ok(result); } @@ -165,4 +166,5 @@ namespace AsbCloudWebApi.Controllers idWell, token).ConfigureAwait(false); } } +#nullable disable } diff --git a/AsbCloudWebApi/Controllers/WellOperationController.cs b/AsbCloudWebApi/Controllers/WellOperationController.cs index ae1943a6..c5174f2c 100644 --- a/AsbCloudWebApi/Controllers/WellOperationController.cs +++ b/AsbCloudWebApi/Controllers/WellOperationController.cs @@ -378,7 +378,7 @@ namespace AsbCloudWebApi.Controllers [Route("template")] [AllowAnonymous] [ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK)] - public IActionResult GetTamplate() + public IActionResult GetTemplate() { var stream = wellOperationImportService.GetExcelTemplateStream(); var fileName = "ЕЦП_шаблон_файла_операций.xlsx"; diff --git a/AsbCloudWebApi/Rest/OperationStat.http b/AsbCloudWebApi/Rest/OperationStat.http new file mode 100644 index 00000000..975f54b5 --- /dev/null +++ b/AsbCloudWebApi/Rest/OperationStat.http @@ -0,0 +1,46 @@ +@baseUrl = http://127.0.0.1:5000 +@contentType = application/json +@auth = Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImN0eSI6IkpXVCJ9.eyJpZCI6IjEiLCJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiZGV2IiwiaWRDb21wYW55IjoiMSIsImh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vd3MvMjAwOC8wNi9pZGVudGl0eS9jbGFpbXMvcm9sZSI6InJvb3QiLCJuYmYiOjE2NjI1NDgxNjIsImV4cCI6MTY5NDEwNTc2MiwiaXNzIjoiYSIsImF1ZCI6ImEifQ.OEAlNzxi7Jat6pzDBTAjTbChskc-tdJthJexyWwwUKE + +@uid = 20210910_012752700 +@idCluster = 1 +@idWell = 1 +#295 + +# https://marketplace.visualstudio.com/items?itemName=humao.rest-client + +### +GET {{baseUrl}}/api/well/{{idWell}}/ropStat +Content-Type: {{contentType}} +accept: */* +Authorization: {{auth}} + +### +GET {{baseUrl}}/api/telemetry/{{uid}}/ropStat +Content-Type: {{contentType}} +accept: */* +Authorization: {{auth}} + +### +GET {{baseUrl}}/api/cluster/{{idCluster}}/stat +Content-Type: {{contentType}} +accept: */* +Authorization: {{auth}} + +### +GET {{baseUrl}}/api/wellsStats?idWells=1&idWells={{idWell}} +Content-Type: {{contentType}} +accept: */* +Authorization: {{auth}} + +### +GET {{baseUrl}}/api/well/{{idWell}}/stat +Content-Type: {{contentType}} +accept: */* +Authorization: {{auth}} + +### +GET {{baseUrl}}/api/well/{{idWell}}/tvd +Content-Type: {{contentType}} +accept: */* +Authorization: {{auth}} From 9e9e7a6f5aa178778938ae18b38b206d5e39dc4f Mon Sep 17 00:00:00 2001 From: Olga Nemt Date: Tue, 11 Apr 2023 09:25:35 +0500 Subject: [PATCH 15/16] =?UTF-8?q?=D0=98=D0=B5=D1=80=D0=B0=D1=80=D1=85?= =?UTF-8?q?=D0=B8=D1=87=D0=B5=D1=81=D0=BA=D0=B8=D0=B9=20=D1=81=D0=BF=D0=B8?= =?UTF-8?q?=D1=81=D0=BE=D0=BA=20=D0=B2=20=D0=BF=D0=BB=D0=B0=D0=BD=D0=BE?= =?UTF-8?q?=D0=B2=D1=8B=D1=85=20=D0=B8=20=D1=84=D0=B0=D0=BA=D1=82=D0=B8?= =?UTF-8?q?=D1=87=D0=B5=D1=81=D0=BA=D0=B8=D1=85=20=D0=BE=D0=BF=D0=B5=D1=80?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D1=8F=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AsbCloudWebApi/Controllers/WellOperationController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AsbCloudWebApi/Controllers/WellOperationController.cs b/AsbCloudWebApi/Controllers/WellOperationController.cs index ae1943a6..972bcceb 100644 --- a/AsbCloudWebApi/Controllers/WellOperationController.cs +++ b/AsbCloudWebApi/Controllers/WellOperationController.cs @@ -58,7 +58,7 @@ namespace AsbCloudWebApi.Controllers [ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)] public IActionResult GetCategories() { - var result = operationRepository.GetCategories(false); + var result = operationRepository.GetCategories(true); return Ok(result); } From b93c5e4299570aa62c32452052a93e1896f6be58 Mon Sep 17 00:00:00 2001 From: Olga Nemt Date: Tue, 11 Apr 2023 10:42:56 +0500 Subject: [PATCH 16/16] =?UTF-8?q?=D0=9F=D0=B0=D1=80=D0=B0=D0=BC=D0=B5?= =?UTF-8?q?=D1=82=D1=80=20includeParents=20=D0=BA=D0=BE=D0=BD=D1=82=D1=80?= =?UTF-8?q?=D0=BE=D0=BB=D0=BB=D0=B5=D1=80=D0=B0=20WellOperationController?= =?UTF-8?q?=20=D0=B2=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D0=B5=20GetCategorie?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AsbCloudWebApi/Controllers/WellOperationController.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/AsbCloudWebApi/Controllers/WellOperationController.cs b/AsbCloudWebApi/Controllers/WellOperationController.cs index 972bcceb..153c5ccc 100644 --- a/AsbCloudWebApi/Controllers/WellOperationController.cs +++ b/AsbCloudWebApi/Controllers/WellOperationController.cs @@ -51,14 +51,15 @@ namespace AsbCloudWebApi.Controllers /// /// Возвращает список имен типов операций на скважине /// + /// флаг, нужно ли включать родителей в список /// [HttpGet] [Route("categories")] [Permission] [ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)] - public IActionResult GetCategories() + public IActionResult GetCategories(bool includeParents = true) { - var result = operationRepository.GetCategories(true); + var result = operationRepository.GetCategories(includeParents); return Ok(result); }