2021-08-27 14:21:48 +05:00
|
|
|
|
import { Link } from "react-router-dom";
|
2021-09-02 17:09:14 +05:00
|
|
|
|
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,
|
2021-08-31 16:53:46 +05:00
|
|
|
|
makeColumn,
|
2021-10-08 17:02:15 +05:00
|
|
|
|
makeDateSorter,
|
|
|
|
|
makeNumericColumnPlanFact} from "../../components/Table";
|
2021-10-13 16:32:01 +05:00
|
|
|
|
import { calcAndUpdateStatsBySections, makeFilterMinMaxFunction, getPrecision } from "./functions";
|
2021-08-29 14:43:02 +05:00
|
|
|
|
import { invokeWebApiWrapperAsync } from '../../components/factory';
|
2021-10-08 17:02:15 +05:00
|
|
|
|
import ChartTvD from '../WellOperations/ChartTvD';
|
2021-08-31 11:14:35 +05:00
|
|
|
|
import WellOperationsTable from './WellOperationsTable'
|
2021-09-02 17:09:14 +05:00
|
|
|
|
import { getOperations } from "./functions";
|
2021-10-13 16:32:01 +05:00
|
|
|
|
import LoaderPortal from "../../components/LoaderPortal";
|
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-10-13 16:32:01 +05:00
|
|
|
|
const DAY_IN_MS = 1000 * 60 * 60 * 24;
|
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)
|
|
|
|
|
const [tvdDataPlan, setTvdDataPlan] = useState([]);
|
|
|
|
|
const [tvdDataFact, setTvdDataFact] = useState([]);
|
|
|
|
|
const [tvdDataForecast, setTvdDataForecast] = useState([]);
|
|
|
|
|
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(() => {
|
|
|
|
|
if (selectedWellId > 0) {
|
|
|
|
|
invokeWebApiWrapperAsync(
|
|
|
|
|
async () => {
|
|
|
|
|
const operations = await getOperations(selectedWellId);
|
|
|
|
|
|
|
|
|
|
setWellOperations(operations.operations)
|
|
|
|
|
setTvdDataPlan(operations.plan)
|
|
|
|
|
setTvdDataFact(operations.fact)
|
|
|
|
|
setTvdDataForecast(operations.predict)
|
|
|
|
|
},
|
|
|
|
|
setShowLoader,
|
|
|
|
|
`Не удалось загрузить операции по скважине "${selectedWellId}"`,
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
setWellOperations([])
|
|
|
|
|
}
|
|
|
|
|
}, [selectedWellId]);
|
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))
|
|
|
|
|
filtersWellsType.push({ text: well.wellType, value: well.wellType,});
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
key: well.caption,
|
|
|
|
|
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)) / DAY_IN_MS,
|
|
|
|
|
periodFact: (new Date(well.total?.fact?.end) - new Date(well.total?.fact?.start)) / DAY_IN_MS,
|
|
|
|
|
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
|
|
|
|
|
};
|
2021-09-02 09:52:57 +05:00
|
|
|
|
});
|
2021-10-13 16:32:01 +05:00
|
|
|
|
|
|
|
|
|
calcAndUpdateStatsBySections(data ?? [], [
|
|
|
|
|
"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-10-13 16:32:01 +05:00
|
|
|
|
const getDate = (str) => Number.isNaN(new Date(str).getTime()) ? '-' : new Date(str).toLocaleString()
|
2021-08-31 16:41:13 +05:00
|
|
|
|
|
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-10-13 16:32:01 +05:00
|
|
|
|
makeTextColumn("Тип скв.", "wellType", filtersWellsType, null, (text) => text ?? '-'),
|
2021-08-27 14:21:48 +05:00
|
|
|
|
makeGroupColumn("Фактические сроки", [
|
2021-10-13 16:32:01 +05:00
|
|
|
|
makeColumn("начало", "factStart", { sorter: makeDateSorter('factStart'), render: getDate }),
|
|
|
|
|
makeColumn("окончание", "factEnd", { sorter: makeDateSorter('factEnd'), render: getDate })
|
2021-08-27 14:21:48 +05:00
|
|
|
|
]),
|
2021-10-13 16:32:01 +05:00
|
|
|
|
makeNumericColumnPlanFact("Продолжительность", "period", filtersMinMax, makeFilterMinMaxFunction, getPrecision),
|
|
|
|
|
makeNumericColumnPlanFact("МСП", "rateOfPenetration", filtersMinMax, makeFilterMinMaxFunction, getPrecision),
|
|
|
|
|
makeNumericColumnPlanFact("Рейсовая скорость", "routeSpeed", filtersMinMax, makeFilterMinMaxFunction, getPrecision),
|
|
|
|
|
makeNumericColumnPlanFact("НПВ, сут", "notProductiveTime", filtersMinMax, makeFilterMinMaxFunction, getPrecision),
|
2021-08-27 14:21:48 +05:00
|
|
|
|
{
|
2021-08-31 16:41:13 +05:00
|
|
|
|
title: "TVD",
|
2021-09-02 16:33:02 +05:00
|
|
|
|
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-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-09-02 16:33:02 +05:00
|
|
|
|
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-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",
|
2021-10-13 16:32:01 +05:00
|
|
|
|
render: (item) => item?.map((company) => <Tag key={company.caption} color="blue">{company.caption}</Tag>) ?? '-',
|
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-08-29 14:43:02 +05:00
|
|
|
|
size={"small"}
|
|
|
|
|
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-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-10-08 17:02:15 +05:00
|
|
|
|
<ChartTvD
|
2021-08-31 11:14:35 +05:00
|
|
|
|
dataPlan={tvdDataPlan}
|
|
|
|
|
dataFact={tvdDataFact}
|
2021-10-08 17:02:15 +05:00
|
|
|
|
dataPredict={tvdDataForecast}
|
2021-09-02 09:52:57 +05:00
|
|
|
|
/>
|
2021-08-31 11:14:35 +05:00
|
|
|
|
</Modal>
|
|
|
|
|
|
|
|
|
|
<Modal
|
|
|
|
|
title='Операции'
|
|
|
|
|
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-08-27 14:21:48 +05:00
|
|
|
|
);
|
|
|
|
|
}
|