2021-07-21 15:36:08 +05:00
|
|
|
|
import { useParams } from "react-router-dom"
|
2021-08-17 13:01:13 +05:00
|
|
|
|
import { DatePicker } from 'antd';
|
2021-08-20 10:49:20 +05:00
|
|
|
|
import { notify } from "../components/factory"
|
2021-07-21 15:36:08 +05:00
|
|
|
|
import { useState, useEffect } from 'react'
|
2021-08-17 10:44:41 +05:00
|
|
|
|
import { TelemetryAnalyticsService } from '../services/api'
|
2021-07-21 15:36:08 +05:00
|
|
|
|
import { ChartOperationTime } from './charts/ChartOperationTime'
|
2021-07-27 14:05:32 +05:00
|
|
|
|
import LoaderPortal from '../components/LoaderPortal'
|
|
|
|
|
import moment from 'moment'
|
2021-07-21 15:36:08 +05:00
|
|
|
|
|
|
|
|
|
const { RangePicker } = DatePicker
|
|
|
|
|
|
|
|
|
|
const lines = [{ labelAccessorName: "processName", pieceAccessorName: "duration" }]
|
|
|
|
|
|
|
|
|
|
export function AnalysisOperationTime() {
|
|
|
|
|
let { id } = useParams()
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
const onChangeRange = (range) => {
|
|
|
|
|
setRange(range)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleReceiveOperationTimeData = (data) => {
|
|
|
|
|
setOperationTimeData(data)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
setLoader(true)
|
2021-07-27 14:05:32 +05:00
|
|
|
|
let begin = null
|
|
|
|
|
let end = null
|
2021-07-21 15:36:08 +05:00
|
|
|
|
if (range?.length > 1) {
|
|
|
|
|
begin = range[0].toISOString()
|
|
|
|
|
end = range[1].toISOString()
|
|
|
|
|
}
|
2021-08-17 10:44:41 +05:00
|
|
|
|
TelemetryAnalyticsService.getOperationsSummary(id, begin, end)
|
2021-07-21 15:36:08 +05:00
|
|
|
|
.then(handleReceiveOperationTimeData)
|
|
|
|
|
.catch(error => {
|
|
|
|
|
notify(`Не удалось получить данные для Анализа Операция-Время по скважине "${id}" за период с ${begin} по ${end}`,
|
|
|
|
|
'warning')
|
|
|
|
|
console.log(error)
|
|
|
|
|
})
|
|
|
|
|
.finally(setLoader(false))
|
|
|
|
|
}, [id, range])
|
|
|
|
|
|
|
|
|
|
return (
|
2021-07-27 14:05:32 +05:00
|
|
|
|
<LoaderPortal show={loader}>
|
2021-08-17 13:01:13 +05:00
|
|
|
|
<RangePicker
|
|
|
|
|
showTime
|
|
|
|
|
onChange={onChangeRange}
|
|
|
|
|
/>
|
2021-07-21 15:36:08 +05:00
|
|
|
|
<ChartOperationTime
|
|
|
|
|
data={operationTimeData}
|
|
|
|
|
lines={lines}
|
|
|
|
|
/>
|
2021-07-27 14:05:32 +05:00
|
|
|
|
</LoaderPortal>
|
2021-07-21 15:36:08 +05:00
|
|
|
|
)
|
|
|
|
|
}
|