2022-01-24 21:16:50 +05:00
|
|
|
|
import moment from 'moment'
|
|
|
|
|
import { DatePicker } from 'antd'
|
2021-07-21 15:36:08 +05:00
|
|
|
|
import { useState, useEffect } from 'react'
|
2022-01-24 21:16:50 +05:00
|
|
|
|
import { useParams } from 'react-router-dom'
|
|
|
|
|
|
|
|
|
|
import LoaderPortal from '@components/LoaderPortal'
|
|
|
|
|
import { invokeWebApiWrapperAsync } from '@components/factory'
|
|
|
|
|
import { TelemetryAnalyticsService } from '@api'
|
2021-07-21 15:36:08 +05:00
|
|
|
|
import { ChartOperationTime } from './charts/ChartOperationTime'
|
|
|
|
|
|
|
|
|
|
const { RangePicker } = DatePicker
|
|
|
|
|
|
2022-01-24 21:16:50 +05:00
|
|
|
|
const lines = [{ labelAccessorName: 'processName', pieceAccessorName: 'duration' }]
|
2021-07-21 15:36:08 +05:00
|
|
|
|
|
2022-01-24 21:16:50 +05:00
|
|
|
|
export const AnalysisOperationTime = () => {
|
|
|
|
|
const { id } = useParams()
|
2021-07-21 15:36:08 +05:00
|
|
|
|
const [operationTimeData, setOperationTimeData] = useState([])
|
|
|
|
|
const [loader, setLoader] = useState(false)
|
2021-07-27 14:05:32 +05:00
|
|
|
|
const [range, setRange] = useState([moment().subtract(1,'days'), moment()])
|
2021-07-21 15:36:08 +05:00
|
|
|
|
|
2022-01-24 21:16:50 +05:00
|
|
|
|
useEffect(() => invokeWebApiWrapperAsync(
|
|
|
|
|
async () => {
|
|
|
|
|
const begin = range?.length > 1 ? range[0].toISOString() : null
|
|
|
|
|
const end = range?.length > 1 ? range[1].toISOString() : null
|
|
|
|
|
const summary = await TelemetryAnalyticsService.getOperationsSummary(id, begin, end)
|
|
|
|
|
setOperationTimeData(summary)
|
|
|
|
|
},
|
|
|
|
|
setLoader,
|
2022-02-07 17:44:46 +05:00
|
|
|
|
`Не удалось получить данные для анализа Операция-Время по скважине '${id}' за период с ${begin} по ${end}`,
|
|
|
|
|
'Получение данных для анализа Операция-Время по скважине'
|
2022-01-24 21:16:50 +05:00
|
|
|
|
), [id, range])
|
2021-07-21 15:36:08 +05:00
|
|
|
|
|
|
|
|
|
return (
|
2021-07-27 14:05:32 +05:00
|
|
|
|
<LoaderPortal show={loader}>
|
2022-01-24 21:16:50 +05:00
|
|
|
|
<RangePicker showTime onChange={(range) => setRange(range)} />
|
|
|
|
|
<ChartOperationTime data={operationTimeData} lines={lines} />
|
2021-07-27 14:05:32 +05:00
|
|
|
|
</LoaderPortal>
|
2021-07-21 15:36:08 +05:00
|
|
|
|
)
|
2022-01-24 21:16:50 +05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default AnalysisOperationTime
|