2021-08-27 14:21:48 +05:00
|
|
|
|
import { Link } from "react-router-dom";
|
2021-09-02 09:52:57 +05:00
|
|
|
|
import { useState } from "react";
|
2021-08-29 14:43:02 +05:00
|
|
|
|
import { Table, Tag, Button, Modal } from "antd";
|
2021-08-31 16:41:13 +05:00
|
|
|
|
import { LineChartOutlined, ProfileOutlined } from "@ant-design/icons";
|
2021-08-27 14:21:48 +05:00
|
|
|
|
import {
|
|
|
|
|
makeTextColumn,
|
|
|
|
|
makeGroupColumn,
|
2021-08-31 16:53:46 +05:00
|
|
|
|
makeColumn,
|
|
|
|
|
makeNumericColumnPlanFact,
|
|
|
|
|
makeDateSorter
|
2021-08-27 14:21:48 +05:00
|
|
|
|
} from "../../components/Table";
|
2021-08-30 12:13:30 +05:00
|
|
|
|
import { calcAndUpdateStatsBySections, makeFilterMinMaxFunction } from "./functions";
|
2021-08-29 14:43:02 +05:00
|
|
|
|
import { invokeWebApiWrapperAsync } from '../../components/factory';
|
|
|
|
|
import { WellOperationStatService } from '../../services/api';
|
2021-08-30 11:26:00 +05:00
|
|
|
|
import ChartDepthToDay from '../../components/charts/ChartDepthToDay';
|
2021-08-31 11:14:35 +05:00
|
|
|
|
import WellOperationsTable from './WellOperationsTable'
|
2021-08-27 14:21:48 +05:00
|
|
|
|
|
|
|
|
|
const filtersMinMax = [
|
|
|
|
|
{
|
|
|
|
|
text: "min",
|
|
|
|
|
value: "min",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
text: "max",
|
|
|
|
|
value: "max",
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
2021-08-31 16:41:13 +05:00
|
|
|
|
const filtersWellsType = [];
|
2021-08-27 14:21:48 +05:00
|
|
|
|
|
2021-09-02 09:52:57 +05:00
|
|
|
|
export default function ClusterWells({clusterData}) {
|
|
|
|
|
|
2021-08-31 11:14:35 +05:00
|
|
|
|
const [isTVDModalVisible, setIsTVDModalVisible] = useState(false)
|
|
|
|
|
const [isOpsModalVisible, setIsOpsModalVisible] = useState(false)
|
|
|
|
|
const [tvdDataPlan, setTvdDataPlan] = useState([]);
|
|
|
|
|
const [tvdDataFact, setTvdDataFact] = useState([]);
|
|
|
|
|
const [tvdDataForecast, setTvdDataForecast] = useState([]);
|
|
|
|
|
const [wellOperations, setWellOperations] = useState([]);
|
2021-08-29 14:43:02 +05:00
|
|
|
|
|
2021-09-02 09:52:57 +05:00
|
|
|
|
const getOperations = (wellId) => {
|
|
|
|
|
invokeWebApiWrapperAsync(
|
|
|
|
|
async () => {
|
|
|
|
|
const operations = await WellOperationStatService.getTvd(wellId);
|
|
|
|
|
|
|
|
|
|
setWellOperations(operations)
|
|
|
|
|
|
|
|
|
|
const tvdPlanData = operations.map(el => {
|
|
|
|
|
return {key: el.plan?.id, depth: el.plan?.wellDepth, date: el.plan?.startDate}
|
|
|
|
|
}).filter(el => el.key)
|
|
|
|
|
|
|
|
|
|
setTvdDataPlan(tvdPlanData)
|
|
|
|
|
|
|
|
|
|
const tvdFactData = operations.map(el => {
|
|
|
|
|
return {key: el.fact?.id, depth: el.fact?.wellDepth, date: el.fact?.startDate}
|
|
|
|
|
}).filter(el => el.key)
|
|
|
|
|
|
|
|
|
|
setTvdDataFact(tvdFactData)
|
|
|
|
|
|
|
|
|
|
const tvdPredictData = operations.map(el => {
|
|
|
|
|
return {key: el.predict?.id, depth: el.predict?.wellDepth, date: el.predict?.startDate}
|
|
|
|
|
}).filter(el => el.key)
|
|
|
|
|
|
|
|
|
|
setTvdDataForecast(tvdPredictData)
|
|
|
|
|
},
|
|
|
|
|
null,
|
|
|
|
|
`Не удалось загрузить операции по скважине "${wellId}"`,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let tableData = clusterData.statsWells?.map((well) => {
|
|
|
|
|
|
|
|
|
|
if (!filtersWellsType.some((el) => el.text === well.wellType))
|
|
|
|
|
filtersWellsType.push({
|
|
|
|
|
text: well.wellType,
|
|
|
|
|
value: well.wellType,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
key: well.id,
|
|
|
|
|
id: well.id,
|
|
|
|
|
caption: well.caption,
|
|
|
|
|
wellType: well.wellType,
|
|
|
|
|
factStart: well.total?.fact?.start,
|
|
|
|
|
factEnd: well.total?.fact?.end,
|
|
|
|
|
periodPlan: (
|
|
|
|
|
(new Date(well.total?.plan?.end) - new Date(well.total?.plan?.start)) /
|
|
|
|
|
(1000 * 60 * 60 * 24)
|
|
|
|
|
),
|
|
|
|
|
periodFact: (
|
|
|
|
|
(new Date(well.total?.fact?.end) - new Date(well.total?.fact?.start)) /
|
|
|
|
|
(1000 * 60 * 60 * 24)
|
|
|
|
|
),
|
|
|
|
|
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,
|
|
|
|
|
companies: well.companies,
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
calcAndUpdateStatsBySections(tableData ?? [], [
|
2021-08-31 16:41:13 +05:00
|
|
|
|
"factStart",
|
|
|
|
|
"factEnd",
|
|
|
|
|
"periodPlan",
|
|
|
|
|
"periodFact",
|
|
|
|
|
"rateOfPenetrationPlan",
|
|
|
|
|
"rateOfPenetrationFact",
|
|
|
|
|
"routeSpeedPlan",
|
|
|
|
|
"routeSpeedFact",
|
|
|
|
|
"notProductiveTime",
|
|
|
|
|
]);
|
|
|
|
|
|
2021-08-27 14:21:48 +05:00
|
|
|
|
const columns = [
|
2021-08-31 16:41:13 +05:00
|
|
|
|
makeTextColumn("скв №", "caption", null, null,
|
|
|
|
|
(_, item) => (<Link to={`/well/${item.id}`}>{item.caption ?? '-'}</Link>
|
2021-08-27 14:21:48 +05:00
|
|
|
|
)),
|
2021-08-31 16:41:13 +05:00
|
|
|
|
makeTextColumn("Тип скв.", "wellType", filtersWellsType, null,
|
|
|
|
|
(text) => text ?? '-'
|
|
|
|
|
),
|
2021-08-27 14:21:48 +05:00
|
|
|
|
makeGroupColumn("Фактические сроки", [
|
2021-08-31 16:53:46 +05:00
|
|
|
|
makeColumn("начало", "factStart",
|
|
|
|
|
{
|
|
|
|
|
sorter: makeDateSorter('factStart'),
|
|
|
|
|
render: (dateString) => !Number.isNaN(new Date(dateString).getTime())
|
|
|
|
|
? new Date(dateString).toLocaleString()
|
|
|
|
|
: '-'
|
|
|
|
|
}
|
|
|
|
|
),
|
|
|
|
|
makeColumn("окончание", "factEnd",
|
|
|
|
|
{
|
|
|
|
|
sorter: makeDateSorter('factEnd'),
|
|
|
|
|
render: (dateString) => !Number.isNaN(new Date(dateString).getTime())
|
|
|
|
|
? new Date(dateString).toLocaleString()
|
|
|
|
|
: '-'
|
|
|
|
|
}
|
|
|
|
|
),
|
2021-08-27 14:21:48 +05:00
|
|
|
|
]),
|
2021-08-31 16:41:13 +05:00
|
|
|
|
makeNumericColumnPlanFact(
|
|
|
|
|
"Продолжительность",
|
|
|
|
|
"period",
|
|
|
|
|
filtersMinMax,
|
|
|
|
|
makeFilterMinMaxFunction,
|
|
|
|
|
(number) => (!Number.isNaN(number) && number !== undefined)
|
|
|
|
|
? number.toFixed(2)
|
|
|
|
|
: '-'),
|
|
|
|
|
makeNumericColumnPlanFact(
|
|
|
|
|
"МСП",
|
|
|
|
|
"rateOfPenetration",
|
|
|
|
|
filtersMinMax,
|
|
|
|
|
makeFilterMinMaxFunction,
|
|
|
|
|
(number) => (!Number.isNaN(number) && number !== undefined)
|
|
|
|
|
? number.toFixed(2)
|
|
|
|
|
: '-'),
|
|
|
|
|
makeNumericColumnPlanFact(
|
|
|
|
|
"Рейсовая скорость",
|
|
|
|
|
"routeSpeed",
|
|
|
|
|
filtersMinMax,
|
|
|
|
|
makeFilterMinMaxFunction,
|
|
|
|
|
(number) => (!Number.isNaN(number) && number !== undefined)
|
|
|
|
|
? number.toFixed(2)
|
|
|
|
|
: '-'),
|
|
|
|
|
makeNumericColumnPlanFact(
|
|
|
|
|
"НПВ, сут",
|
|
|
|
|
"notProductiveTime",
|
|
|
|
|
filtersMinMax,
|
|
|
|
|
makeFilterMinMaxFunction,
|
|
|
|
|
(number) => (!Number.isNaN(number) && number !== undefined)
|
|
|
|
|
? number.toFixed(2)
|
|
|
|
|
: '-'),
|
2021-08-27 14:21:48 +05:00
|
|
|
|
{
|
2021-08-31 16:41:13 +05:00
|
|
|
|
title: "TVD",
|
2021-08-31 11:14:35 +05:00
|
|
|
|
render: (value) => <Button onClick={()=> {
|
2021-09-02 09:52:57 +05:00
|
|
|
|
getOperations(value.id)
|
2021-08-31 11:14:35 +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-08-31 16:41:13 +05:00
|
|
|
|
title: "Операции",
|
2021-08-31 11:14:35 +05:00
|
|
|
|
render: (value) => <Button onClick={()=> {
|
2021-09-02 09:52:57 +05:00
|
|
|
|
getOperations(value.id)
|
2021-08-31 11:14:35 +05:00
|
|
|
|
setIsOpsModalVisible(true)
|
2021-08-31 16:41:13 +05:00
|
|
|
|
}}><ProfileOutlined /></Button>,
|
|
|
|
|
align: 'center'
|
2021-08-27 14:21:48 +05:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: "Подрядчики",
|
|
|
|
|
key: "companies",
|
|
|
|
|
dataIndex: "companies",
|
|
|
|
|
render: (item) =>
|
|
|
|
|
item.map((company) => <Tag color="blue">{company.caption}</Tag>),
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
return (
|
2021-08-29 14:43:02 +05:00
|
|
|
|
<div>
|
|
|
|
|
<Table
|
|
|
|
|
columns={columns}
|
2021-09-02 09:52:57 +05:00
|
|
|
|
dataSource={tableData}
|
2021-08-29 14:43:02 +05:00
|
|
|
|
size={"small"}
|
|
|
|
|
bordered
|
|
|
|
|
pagination={false}
|
|
|
|
|
rowKey={(record) => record.id}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<Modal
|
2021-08-31 11:14:35 +05:00
|
|
|
|
title='TVD'
|
|
|
|
|
centered
|
|
|
|
|
visible={isTVDModalVisible}
|
|
|
|
|
onCancel={() => setIsTVDModalVisible(false)}
|
|
|
|
|
width={1500}
|
|
|
|
|
footer={null}
|
2021-08-29 14:43:02 +05:00
|
|
|
|
>
|
2021-08-30 11:26:00 +05:00
|
|
|
|
<ChartDepthToDay
|
2021-08-31 11:14:35 +05:00
|
|
|
|
dataPlan={tvdDataPlan}
|
|
|
|
|
dataFact={tvdDataFact}
|
2021-09-02 09:52:57 +05:00
|
|
|
|
dataForecast={tvdDataForecast}
|
|
|
|
|
/>
|
2021-08-31 11:14:35 +05:00
|
|
|
|
</Modal>
|
|
|
|
|
|
|
|
|
|
<Modal
|
|
|
|
|
title='Операции'
|
|
|
|
|
centered
|
|
|
|
|
visible={isOpsModalVisible}
|
|
|
|
|
onCancel={() => setIsOpsModalVisible(false)}
|
|
|
|
|
width={1500}
|
|
|
|
|
footer={null}
|
|
|
|
|
>
|
|
|
|
|
<WellOperationsTable
|
|
|
|
|
wellOperations={wellOperations}
|
|
|
|
|
/>
|
2021-08-29 14:43:02 +05:00
|
|
|
|
</Modal>
|
|
|
|
|
</div>
|
2021-08-27 14:21:48 +05:00
|
|
|
|
);
|
|
|
|
|
}
|