2021-10-15 10:52:01 +05:00
|
|
|
|
import { Link } from 'react-router-dom'
|
|
|
|
|
import { useState, useEffect } from 'react'
|
2021-10-15 16:03:36 +05:00
|
|
|
|
import { Tag, Button, Modal } from 'antd'
|
2021-10-15 10:52:01 +05:00
|
|
|
|
import { LineChartOutlined, ProfileOutlined } from '@ant-design/icons'
|
2021-12-28 14:41:23 +05:00
|
|
|
|
|
2021-08-27 14:21:48 +05:00
|
|
|
|
import {
|
|
|
|
|
makeTextColumn,
|
|
|
|
|
makeGroupColumn,
|
2021-08-31 16:53:46 +05:00
|
|
|
|
makeColumn,
|
2021-10-08 17:02:15 +05:00
|
|
|
|
makeDateSorter,
|
2021-12-28 14:41:23 +05:00
|
|
|
|
makeNumericColumnPlanFact,
|
|
|
|
|
Table,
|
|
|
|
|
} from '../../components/Table'
|
2021-10-15 10:52:01 +05:00
|
|
|
|
import { invokeWebApiWrapperAsync } from '../../components/factory'
|
|
|
|
|
import LoaderPortal from '../../components/LoaderPortal'
|
2021-11-18 10:42:02 +05:00
|
|
|
|
import PointerIcon from '../../components/icons/PointerIcon'
|
2021-12-28 14:41:23 +05:00
|
|
|
|
import { CompanyView } from '../../components/Views'
|
|
|
|
|
|
|
|
|
|
import { Tvd } from '../WellOperations/Tvd'
|
|
|
|
|
import {
|
|
|
|
|
getOperations,
|
|
|
|
|
calcAndUpdateStatsBySections,
|
|
|
|
|
makeFilterMinMaxFunction
|
|
|
|
|
} from './functions'
|
|
|
|
|
import WellOperationsTable from './WellOperationsTable'
|
2021-08-27 14:21:48 +05:00
|
|
|
|
|
|
|
|
|
const filtersMinMax = [
|
2021-10-15 10:52:01 +05:00
|
|
|
|
{ text: 'min', value: 'min' },
|
|
|
|
|
{ text: 'max', value: 'max' },
|
|
|
|
|
]
|
2021-08-27 14:21:48 +05:00
|
|
|
|
|
2021-10-15 10:52:01 +05:00
|
|
|
|
const filtersWellsType = []
|
2021-11-18 10:42:02 +05:00
|
|
|
|
const DAY_IN_MS = 86_400_000
|
|
|
|
|
const ONLINE_DEADTIME = 600_000
|
2021-08-27 14:21:48 +05:00
|
|
|
|
|
2021-10-13 16:32:01 +05:00
|
|
|
|
export default function ClusterWells({statsWells}) {
|
2021-09-02 09:52:57 +05:00
|
|
|
|
|
2021-09-02 17:09:14 +05:00
|
|
|
|
const [selectedWellId, setSelectedWellId] = useState(0)
|
2021-08-31 11:14:35 +05:00
|
|
|
|
const [isTVDModalVisible, setIsTVDModalVisible] = useState(false)
|
|
|
|
|
const [isOpsModalVisible, setIsOpsModalVisible] = useState(false)
|
2021-10-15 10:52:01 +05:00
|
|
|
|
const [wellOperations, setWellOperations] = useState([])
|
2021-10-13 16:32:01 +05:00
|
|
|
|
const [tableData, setTableData] = useState([])
|
|
|
|
|
const [showLoader, setShowLoader] = useState(false)
|
2021-08-29 14:43:02 +05:00
|
|
|
|
|
2021-10-13 16:32:01 +05:00
|
|
|
|
useEffect(() => {
|
2021-10-15 10:52:01 +05:00
|
|
|
|
if (!isOpsModalVisible || selectedWellId <= 0) {
|
2021-10-13 16:32:01 +05:00
|
|
|
|
setWellOperations([])
|
2021-10-15 10:52:01 +05:00
|
|
|
|
return
|
2021-10-13 16:32:01 +05:00
|
|
|
|
}
|
2021-10-15 10:52:01 +05:00
|
|
|
|
invokeWebApiWrapperAsync(
|
|
|
|
|
async () => {
|
|
|
|
|
const operations = await getOperations(selectedWellId)
|
|
|
|
|
setWellOperations(operations.operations)
|
|
|
|
|
},
|
|
|
|
|
setShowLoader,
|
|
|
|
|
`Не удалось загрузить операции по скважине "${selectedWellId}"`,
|
|
|
|
|
)
|
|
|
|
|
}, [selectedWellId, isOpsModalVisible])
|
2021-09-02 09:52:57 +05:00
|
|
|
|
|
2021-10-13 16:32:01 +05:00
|
|
|
|
useEffect(() => {
|
|
|
|
|
let data = statsWells?.map((well) => {
|
|
|
|
|
if (!filtersWellsType.some((el) => el.text === well.wellType))
|
2021-10-15 10:52:01 +05:00
|
|
|
|
filtersWellsType.push({ text: well.wellType, value: well.wellType,})
|
2021-11-18 10:42:02 +05:00
|
|
|
|
|
2021-12-21 16:38:30 +05:00
|
|
|
|
let periodPlanValue = well.total?.plan?.start && well.total?.plan?.end
|
|
|
|
|
? (new Date(well.total?.plan?.end) - new Date(well.total?.plan?.start)) / DAY_IN_MS
|
|
|
|
|
: '-'
|
|
|
|
|
let periodFactValue = well.total?.fact?.start && well.total?.fact?.end
|
|
|
|
|
? (new Date(well.total?.fact?.end) - new Date(well.total?.fact?.start)) / DAY_IN_MS
|
|
|
|
|
: '-'
|
|
|
|
|
|
2021-10-13 16:32:01 +05:00
|
|
|
|
return {
|
|
|
|
|
key: well.caption,
|
|
|
|
|
id: well.id,
|
|
|
|
|
caption: well.caption,
|
|
|
|
|
wellType: well.wellType,
|
|
|
|
|
factStart: well.total?.fact?.start,
|
|
|
|
|
factEnd: well.total?.fact?.end,
|
2021-12-21 16:38:30 +05:00
|
|
|
|
periodPlan: periodPlanValue,
|
|
|
|
|
periodFact: periodFactValue,
|
2021-10-13 16:32:01 +05:00
|
|
|
|
rateOfPenetrationPlan: well.total?.plan?.rop,
|
|
|
|
|
rateOfPenetrationFact: well.total?.fact?.rop,
|
|
|
|
|
routeSpeedPlan: well.total?.plan?.routeSpeed,
|
|
|
|
|
routeSpeedFact: well.total?.fact?.routeSpeed,
|
|
|
|
|
notProductiveTimePlan: well.total?.plan?.nonProductiveHours,
|
|
|
|
|
notProductiveTimeFact: well.total?.fact?.nonProductiveHours,
|
2021-10-20 14:32:18 +05:00
|
|
|
|
companies: well.companies,
|
2021-10-20 17:02:51 +05:00
|
|
|
|
lastTelemetryDate: well.lastTelemetryDate,
|
|
|
|
|
idState: well.idState
|
2021-10-15 10:52:01 +05:00
|
|
|
|
}
|
|
|
|
|
})
|
2021-11-18 10:42:02 +05:00
|
|
|
|
|
2021-10-13 16:32:01 +05:00
|
|
|
|
calcAndUpdateStatsBySections(data ?? [], [
|
2021-10-15 10:52:01 +05:00
|
|
|
|
'factStart',
|
|
|
|
|
'factEnd',
|
|
|
|
|
'periodPlan',
|
|
|
|
|
'periodFact',
|
|
|
|
|
'rateOfPenetrationPlan',
|
|
|
|
|
'rateOfPenetrationFact',
|
|
|
|
|
'routeSpeedPlan',
|
|
|
|
|
'routeSpeedFact',
|
|
|
|
|
'notProductiveTime',
|
|
|
|
|
])
|
2021-09-02 09:52:57 +05:00
|
|
|
|
|
2021-10-13 16:32:01 +05:00
|
|
|
|
setTableData(data)
|
|
|
|
|
}, [statsWells])
|
2021-09-02 09:52:57 +05:00
|
|
|
|
|
2021-12-21 16:38:30 +05:00
|
|
|
|
const getDate = (str) => Number.isNaN(+new Date(str)) || +new Date(str) === 0
|
|
|
|
|
? '-'
|
|
|
|
|
: new Date(str).toLocaleString()
|
2021-08-31 16:41:13 +05:00
|
|
|
|
|
2021-08-27 14:21:48 +05:00
|
|
|
|
const columns = [
|
2021-11-18 10:42:02 +05:00
|
|
|
|
makeTextColumn('скв №', 'caption', null, null,
|
2021-10-20 14:32:18 +05:00
|
|
|
|
(_, item) => (
|
|
|
|
|
<Link to={`/well/${item.id}`} style={{display: 'flex', alignItems: 'center'}}>
|
|
|
|
|
<PointerIcon
|
2021-11-18 10:42:02 +05:00
|
|
|
|
state={item.idState === 1 ? 'active' : 'unknown'}
|
|
|
|
|
width={32}
|
|
|
|
|
height={38}
|
|
|
|
|
online={item.lastTelemetryDate && (Date.now() - Date.parse(item.lastTelemetryDate) < ONLINE_DEADTIME)}
|
2021-10-20 14:32:18 +05:00
|
|
|
|
/>
|
|
|
|
|
{item.caption ?? '-'}
|
|
|
|
|
</Link>
|
|
|
|
|
)
|
|
|
|
|
),
|
2021-10-15 10:52:01 +05:00
|
|
|
|
makeTextColumn('Тип скв.', 'wellType', filtersWellsType, null, (text) => text ?? '-'),
|
|
|
|
|
makeGroupColumn('Фактические сроки', [
|
|
|
|
|
makeColumn('начало', 'factStart', { sorter: makeDateSorter('factStart'), render: getDate }),
|
2021-12-27 15:18:20 +05:00
|
|
|
|
makeColumn('окончание', 'factEnd', { sorter: makeDateSorter('factEnd'), render: getDate }),
|
2021-08-27 14:21:48 +05:00
|
|
|
|
]),
|
2021-12-27 15:18:20 +05:00
|
|
|
|
makeNumericColumnPlanFact('Продолжительность, сут', 'period', filtersMinMax, makeFilterMinMaxFunction),
|
|
|
|
|
makeNumericColumnPlanFact('МСП, м/ч', 'rateOfPenetration', filtersMinMax, makeFilterMinMaxFunction),
|
|
|
|
|
makeNumericColumnPlanFact('Рейсовая скорость, м/ч', 'routeSpeed', filtersMinMax, makeFilterMinMaxFunction),
|
2021-10-18 11:48:07 +05:00
|
|
|
|
makeNumericColumnPlanFact('НПВ, сут', 'notProductiveTime', filtersMinMax, makeFilterMinMaxFunction),
|
2021-08-27 14:21:48 +05:00
|
|
|
|
{
|
2021-10-15 10:52:01 +05:00
|
|
|
|
title: 'TVD',
|
|
|
|
|
key: 'tvd',
|
2021-08-31 11:14:35 +05:00
|
|
|
|
render: (value) => <Button onClick={()=> {
|
2021-09-02 17:09:14 +05:00
|
|
|
|
setSelectedWellId(value.id)
|
2021-11-18 10:42:02 +05:00
|
|
|
|
setIsTVDModalVisible(true)
|
2021-08-31 16:41:13 +05:00
|
|
|
|
}}><LineChartOutlined /></Button>,
|
|
|
|
|
align: 'center'
|
2021-08-27 14:21:48 +05:00
|
|
|
|
},
|
|
|
|
|
{
|
2021-10-15 10:52:01 +05:00
|
|
|
|
title: 'Операции',
|
|
|
|
|
key: 'operations',
|
2021-08-31 11:14:35 +05:00
|
|
|
|
render: (value) => <Button onClick={()=> {
|
2021-09-02 17:09:14 +05:00
|
|
|
|
setSelectedWellId(value.id)
|
2021-11-18 10:42:02 +05:00
|
|
|
|
setIsOpsModalVisible(true)
|
2021-08-31 16:41:13 +05:00
|
|
|
|
}}><ProfileOutlined /></Button>,
|
|
|
|
|
align: 'center'
|
2021-08-27 14:21:48 +05:00
|
|
|
|
},
|
|
|
|
|
{
|
2021-10-19 10:08:32 +05:00
|
|
|
|
title: 'Участники',
|
2021-10-15 10:52:01 +05:00
|
|
|
|
key: 'companies',
|
|
|
|
|
dataIndex: 'companies',
|
2021-12-28 14:41:23 +05:00
|
|
|
|
render: (item) => item?.map((company) => (
|
|
|
|
|
<Tag key={company.caption} color='blue'>
|
|
|
|
|
<CompanyView company={company} />
|
|
|
|
|
</Tag>
|
|
|
|
|
)) ?? '-',
|
2021-08-27 14:21:48 +05:00
|
|
|
|
},
|
2021-10-15 10:52:01 +05:00
|
|
|
|
]
|
2021-08-27 14:21:48 +05:00
|
|
|
|
|
|
|
|
|
return (
|
2021-10-13 16:32:01 +05:00
|
|
|
|
<>
|
2021-08-29 14:43:02 +05:00
|
|
|
|
<Table
|
|
|
|
|
columns={columns}
|
2021-09-02 09:52:57 +05:00
|
|
|
|
dataSource={tableData}
|
2021-10-15 10:52:01 +05:00
|
|
|
|
size={'small'}
|
2021-08-29 14:43:02 +05:00
|
|
|
|
bordered
|
|
|
|
|
pagination={false}
|
2021-09-02 11:37:28 +05:00
|
|
|
|
rowKey={(record) => record.caption}
|
2021-08-29 14:43:02 +05:00
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<Modal
|
2021-10-15 10:52:01 +05:00
|
|
|
|
title={'TVD'}
|
2021-08-31 11:14:35 +05:00
|
|
|
|
centered
|
|
|
|
|
visible={isTVDModalVisible}
|
|
|
|
|
onCancel={() => setIsTVDModalVisible(false)}
|
|
|
|
|
width={1500}
|
|
|
|
|
footer={null}
|
2021-08-29 14:43:02 +05:00
|
|
|
|
>
|
2021-10-15 10:52:01 +05:00
|
|
|
|
<Tvd idWell={selectedWellId} />
|
2021-08-31 11:14:35 +05:00
|
|
|
|
</Modal>
|
|
|
|
|
|
|
|
|
|
<Modal
|
2021-10-15 10:52:01 +05:00
|
|
|
|
title={'Операции'}
|
2021-08-31 11:14:35 +05:00
|
|
|
|
centered
|
|
|
|
|
visible={isOpsModalVisible}
|
|
|
|
|
onCancel={() => setIsOpsModalVisible(false)}
|
|
|
|
|
width={1500}
|
|
|
|
|
footer={null}
|
|
|
|
|
>
|
2021-10-13 16:32:01 +05:00
|
|
|
|
<LoaderPortal show={showLoader}>
|
|
|
|
|
<WellOperationsTable wellOperations={wellOperations} />
|
|
|
|
|
</LoaderPortal>
|
2021-08-29 14:43:02 +05:00
|
|
|
|
</Modal>
|
2021-10-13 16:32:01 +05:00
|
|
|
|
</>
|
2021-10-15 10:52:01 +05:00
|
|
|
|
)
|
2021-08-27 14:21:48 +05:00
|
|
|
|
}
|