2021-08-27 14:21:48 +05:00
|
|
|
|
import { useParams } from "react-router-dom";
|
|
|
|
|
import { Link } from "react-router-dom";
|
|
|
|
|
import { useState, useEffect } 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,
|
|
|
|
|
makeNumericColumn,
|
2021-08-30 11:26:00 +05:00
|
|
|
|
makeNumericColumnPlanFact
|
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
|
|
|
|
|
|
|
|
|
export default function ClusterWells({ clusterData }) {
|
|
|
|
|
let { id } = useParams();
|
|
|
|
|
const [wellsStat, setWellsStat] = useState([]);
|
2021-08-31 11:14:35 +05:00
|
|
|
|
const [selectedWellId, setSelectedWellId] = useState([]);
|
|
|
|
|
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-08-31 16:41:13 +05:00
|
|
|
|
calcAndUpdateStatsBySections(wellsStat ?? [], [
|
|
|
|
|
"factStart",
|
|
|
|
|
"factEnd",
|
|
|
|
|
"periodPlan",
|
|
|
|
|
"periodFact",
|
|
|
|
|
"rateOfPenetrationPlan",
|
|
|
|
|
"rateOfPenetrationFact",
|
|
|
|
|
"routeSpeedPlan",
|
|
|
|
|
"routeSpeedFact",
|
|
|
|
|
"notProductiveTime",
|
|
|
|
|
]);
|
|
|
|
|
|
2021-08-29 14:43:02 +05:00
|
|
|
|
useEffect(() => {
|
2021-08-30 11:26:00 +05:00
|
|
|
|
if (selectedWellId > 0) {
|
|
|
|
|
invokeWebApiWrapperAsync(
|
|
|
|
|
async () => {
|
|
|
|
|
const operations = await WellOperationStatService.getTvd(selectedWellId);
|
2021-08-31 11:14:35 +05:00
|
|
|
|
|
|
|
|
|
setWellOperations(operations)
|
|
|
|
|
|
|
|
|
|
const tvdPlanData = operations.map(el => {
|
2021-08-30 11:26:00 +05:00
|
|
|
|
return {key: el.plan?.id, depth: el.plan?.wellDepth, date: el.plan?.startDate}
|
|
|
|
|
}).filter(el => el.key)
|
2021-08-31 11:14:35 +05:00
|
|
|
|
|
|
|
|
|
setTvdDataPlan(tvdPlanData)
|
2021-08-30 11:26:00 +05:00
|
|
|
|
|
2021-08-31 11:14:35 +05:00
|
|
|
|
const tvdFactData = operations.map(el => {
|
2021-08-30 11:26:00 +05:00
|
|
|
|
return {key: el.fact?.id, depth: el.fact?.wellDepth, date: el.fact?.startDate}
|
|
|
|
|
}).filter(el => el.key)
|
|
|
|
|
|
2021-08-31 11:14:35 +05:00
|
|
|
|
setTvdDataFact(tvdFactData)
|
2021-08-30 11:26:00 +05:00
|
|
|
|
|
2021-08-31 11:14:35 +05:00
|
|
|
|
const tvdPredictData = operations.map(el => {
|
2021-08-30 11:26:00 +05:00
|
|
|
|
return {key: el.predict?.id, depth: el.predict?.wellDepth, date: el.predict?.startDate}
|
|
|
|
|
}).filter(el => el.key)
|
|
|
|
|
|
2021-08-31 11:14:35 +05:00
|
|
|
|
setTvdDataForecast(tvdPredictData)
|
2021-08-30 11:26:00 +05:00
|
|
|
|
},
|
|
|
|
|
null,
|
|
|
|
|
`Не удалось загрузить операции по скважине "${selectedWellId}"`,
|
|
|
|
|
);
|
|
|
|
|
}
|
2021-08-29 14:43:02 +05:00
|
|
|
|
}, [selectedWellId]);
|
|
|
|
|
|
2021-08-27 14:21:48 +05:00
|
|
|
|
useEffect(() => {
|
2021-08-30 12:13:30 +05:00
|
|
|
|
let tableData = clusterData.statsWells?.map((well) => {
|
2021-08-31 16:41:13 +05:00
|
|
|
|
|
|
|
|
|
if (!filtersWellsType.some((el) => el.text === well.wellType))
|
|
|
|
|
filtersWellsType.push({
|
|
|
|
|
text: well.wellType,
|
|
|
|
|
value: well.wellType,
|
|
|
|
|
});
|
|
|
|
|
|
2021-08-27 14:21:48 +05:00
|
|
|
|
return {
|
2021-08-30 12:13:30 +05:00
|
|
|
|
key: well.id,
|
|
|
|
|
id: well.id,
|
|
|
|
|
caption: well.caption,
|
|
|
|
|
wellType: well.wellType,
|
2021-08-31 16:41:13 +05:00
|
|
|
|
factStart: well.total?.fact?.start,
|
|
|
|
|
factEnd: well.total?.fact?.end,
|
2021-08-27 14:21:48 +05:00
|
|
|
|
periodPlan: (
|
2021-08-31 16:41:13 +05:00
|
|
|
|
(new Date(well.total?.plan?.end) - new Date(well.total?.plan?.start)) /
|
2021-08-30 11:26:00 +05:00
|
|
|
|
(1000 * 60 * 60 * 24)
|
2021-08-31 16:41:13 +05:00
|
|
|
|
),
|
2021-08-27 14:21:48 +05:00
|
|
|
|
periodFact: (
|
2021-08-31 16:41:13 +05:00
|
|
|
|
(new Date(well.total?.fact?.end) - new Date(well.total?.fact?.start)) /
|
2021-08-30 11:26:00 +05:00
|
|
|
|
(1000 * 60 * 60 * 24)
|
2021-08-31 16:41:13 +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-08-30 12:13:30 +05:00
|
|
|
|
companies: well.companies,
|
2021-08-27 14:21:48 +05:00
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
setWellsStat(tableData);
|
|
|
|
|
}, [id, clusterData]);
|
|
|
|
|
|
|
|
|
|
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:41:13 +05:00
|
|
|
|
makeNumericColumn("начало", "factStart", null, null, (dateString) => !Number.isNaN(new Date(dateString).getTime()) ? new Date(dateString).toLocaleString() : '-'),
|
|
|
|
|
makeNumericColumn("окончание", "factEnd", null, null, (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={()=> {
|
|
|
|
|
setSelectedWellId(value.id)
|
|
|
|
|
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={()=> {
|
|
|
|
|
setSelectedWellId(value.id)
|
|
|
|
|
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}
|
|
|
|
|
dataSource={wellsStat}
|
|
|
|
|
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}
|
|
|
|
|
dataForecast={tvdDataForecast} />
|
|
|
|
|
</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
|
|
|
|
);
|
|
|
|
|
}
|