diff --git a/src/pages/Telemetry/OperationTime/index.tsx b/src/pages/Telemetry/OperationTime/index.tsx index 8764d34..d442d29 100644 --- a/src/pages/Telemetry/OperationTime/index.tsx +++ b/src/pages/Telemetry/OperationTime/index.tsx @@ -2,7 +2,7 @@ import React, { ReactNode, useEffect, useState } from 'react' import { Col, Row, Select } from 'antd' import { Moment } from 'moment' -import { DateRangeWrapper, makeColumn, Table } from '@components/Table' +import { DateRangeWrapper, makeColumn, makeNumericRender, Table } from '@components/Table' import LoaderPortal from '@components/LoaderPortal' import { arrayOrDefault, wrapPrivateComponent } from '@utils' import D3HorizontalChart from '@components/d3/D3HorizontalChart' @@ -17,68 +17,10 @@ type DataType = { subsystemName: string usedTimeHours: number kUsage: number - k2: number + sumDepthInterval: number + operationCount: number } -const _data: DataType[] = [ - { - "idSubsystem": 1, - "subsystemName": "Keруррурk", - "usedTimeHours": 2, - "kUsage": 0.45, - "k2": 1 - }, - { - "idSubsystem": 2, - "subsystemName": "Lol", - "usedTimeHours": 0, - "kUsage": 0.24, - "k2": 0 - }, - { - "idSubsystem": 3, - "subsystemName": "kek", - "usedTimeHours": 0, - "kUsage": 0.37, - "k2": 0 - }, - { - "idSubsystem": 4, - "subsystemName": "keklol", - "usedTimeHours": 0, - "kUsage": 0.73, - "k2": 0 - }, - { - "idSubsystem": 5, - "subsystemName": "Keруррурk1", - "usedTimeHours": 2, - "kUsage": 0.45, - "k2": 1 - }, - { - "idSubsystem": 6, - "subsystemName": "Lol2", - "usedTimeHours": 0, - "kUsage": 0.24, - "k2": 0 - }, - { - "idSubsystem": 7, - "subsystemName": "kek3", - "usedTimeHours": 0, - "kUsage": 0.37, - "k2": 0 - }, - { - "idSubsystem": 8, - "subsystemName": "keklol4", - "usedTimeHours": 0, - "kUsage": 0.73, - "k2": 0 - }, -] - const subsystemColors = [ '#1abc9c', '#16a085', @@ -107,14 +49,15 @@ const tableColumns = [
) }), makeColumn('Подсистема', 'subsystemName'), - makeColumn('Время работы, ч', 'usedTimeHours'), - makeColumn('Активность, %', 'kUsage', { render: (d) => d * 100 }) + makeColumn('% использования', 'kUsage', { render: val => (+val * 100).toFixed(2) }), + makeColumn('Проходка, м', 'sumDepthInterval', {render: makeNumericRender(2)}), + makeColumn('Время работы, ч', 'usedTimeHours', {render: makeNumericRender(2)}), + makeColumn('Кол-во запусков', 'operationCount'), ] const OperationTime = () => { const [showLoader, setShowLoader] = useState(false) - const [data1, setData1] = useState([]) - const [data, setData] = useState(_data) + const [data, setData] = useState([]) const [dateRange, setDateRange] = useState([]) const [childrenData, setChildrenData] = useState([]) const [well] = useWell() @@ -127,14 +70,14 @@ const OperationTime = () => { async () => { if (!well.id) return try { - setData1(arrayOrDefault(await SubsystemOperationTimeService.getStat( + setData(arrayOrDefault(await SubsystemOperationTimeService.getStat( well.id, undefined, dateRange[1] ? dateRange[0]?.toISOString() : undefined, dateRange[1]?.toISOString(), ))) } catch(e) { - setData1([]) + setData([]) throw e } }, @@ -145,7 +88,7 @@ const OperationTime = () => { }, [dateRange]) useEffect(() => { - setChildrenData(_data.map((item) => ( + setChildrenData(data.map((item) => ( @@ -154,7 +97,7 @@ const OperationTime = () => { const selectChange = (value: string[]) => { - setData(_data.reduce((previousValue: DataType[], currentValue) => { + setData(data.reduce((previousValue: DataType[], currentValue) => { if (value.includes(currentValue.subsystemName)) { previousValue.push(currentValue) }