From 4937dddf872d3e9405176e9eeca2e807b268e07c Mon Sep 17 00:00:00 2001 From: goodmice Date: Wed, 20 Oct 2021 17:02:51 +0500 Subject: [PATCH] =?UTF-8?q?=D0=9E=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=81=D1=82=D0=B0=D1=82=D1=83=D1=81?= =?UTF-8?q?=D0=B0=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Cluster/ClusterWells.jsx | 5 ++-- src/pages/TelemetryView/index.jsx | 32 +++++++++++++++++++++++- src/services/api/models/StatWellDto.ts | 1 + src/services/api/models/WellDto.ts | 1 + src/services/api/services/WellService.ts | 19 ++++++++++++++ 5 files changed, 55 insertions(+), 3 deletions(-) diff --git a/src/pages/Cluster/ClusterWells.jsx b/src/pages/Cluster/ClusterWells.jsx index 6cabc16..4674a9f 100644 --- a/src/pages/Cluster/ClusterWells.jsx +++ b/src/pages/Cluster/ClusterWells.jsx @@ -71,7 +71,8 @@ export default function ClusterWells({statsWells}) { notProductiveTimePlan: well.total?.plan?.nonProductiveHours, notProductiveTimeFact: well.total?.fact?.nonProductiveHours, companies: well.companies, - lastTelemetryDate: well.lastTelemetryDate + lastTelemetryDate: well.lastTelemetryDate, + idState: well.idState } }) @@ -97,7 +98,7 @@ export default function ClusterWells({statsWells}) { (_, item) => ( ) @@ -301,6 +302,27 @@ export default function TelemetryView({ idWell }) { } }, [idWell, chartInterval]) + useEffect(() => invokeWebApiWrapperAsync( + async () => { + const well = await WellService.get(idWell) + setWellData(well ?? {}) + }, + setShowLoader, + `Не удалось загрузить данные по скважине "${idWell}"` + ), [idWell]) + + const onStatusChanged = (value) => { + invokeWebApiWrapperAsync( + async () => { + const well = {...wellData, idState: value} + await WellService.updateWell(idWell, well) + setWellData(well) + }, + setShowLoader, + `Не удалось задать состояние скважины "${idWell}"` + ) + } + return ( @@ -313,6 +335,14 @@ export default function TelemetryView({ idWell }) { {options} +
+ Статус:  + +
  {'TorqueMaster'} {'SpinMaster'} diff --git a/src/services/api/models/StatWellDto.ts b/src/services/api/models/StatWellDto.ts index 9e2353f..0ef8103 100644 --- a/src/services/api/models/StatWellDto.ts +++ b/src/services/api/models/StatWellDto.ts @@ -10,6 +10,7 @@ export type StatWellDto = { id?: number; caption?: string | null; wellType?: string | null; + idState?: number; state?: string | null; lastTelemetryDate?: string; sections?: Array | null; diff --git a/src/services/api/models/WellDto.ts b/src/services/api/models/WellDto.ts index c1ad790..ebc03bc 100644 --- a/src/services/api/models/WellDto.ts +++ b/src/services/api/models/WellDto.ts @@ -12,6 +12,7 @@ export type WellDto = { latitude?: number | null; longitude?: number | null; wellType?: string | null; + idWellType?: number; idState?: number; lastTelemetryDate?: string; telemetry?: TelemetryDto; diff --git a/src/services/api/services/WellService.ts b/src/services/api/services/WellService.ts index c5ff465..d71b14c 100644 --- a/src/services/api/services/WellService.ts +++ b/src/services/api/services/WellService.ts @@ -44,6 +44,25 @@ export class WellService { return result.body; } + /** + * Возвращает информацию о требуемой скважине + * @param idWell Id требуемой скважины + * @returns WellDto Success + * @throws ApiError + */ + public static async get( + idWell?: number, + ): Promise { + const result = await __request({ + method: 'GET', + path: `/api/well/getWell`, + query: { + 'idWell': idWell, + }, + }); + return result.body; + } + /** * Возвращает список скважин, передающих телеметрию в данный момент * @returns WellDto Success