forked from ddrilling/asb_cloud_front
126 lines
3.6 KiB
React
126 lines
3.6 KiB
React
|
import { useParams } from "react-router-dom";
|
||
|
import { Link } from "react-router-dom";
|
||
|
import { useState, useEffect } from "react";
|
||
|
import { Table, Tag, Button } from "antd";
|
||
|
import {
|
||
|
makeTextColumn,
|
||
|
makeGroupColumn,
|
||
|
makeNumericColumn,
|
||
|
makeNumericColumnPlanFact,
|
||
|
calcAndUpdateStatsBySections,
|
||
|
} from "../../components/Table";
|
||
|
|
||
|
const filtersMinMax = [
|
||
|
{
|
||
|
text: "min",
|
||
|
value: "min",
|
||
|
},
|
||
|
{
|
||
|
text: "max",
|
||
|
value: "max",
|
||
|
},
|
||
|
];
|
||
|
|
||
|
const filtersWellsType = [
|
||
|
{
|
||
|
text: "Наклонно-направленная",
|
||
|
value: "Наклонно-направленная",
|
||
|
},
|
||
|
{
|
||
|
text: "Горизонтальная",
|
||
|
value: "Горизонтальная",
|
||
|
},
|
||
|
];
|
||
|
|
||
|
export default function ClusterWells({ clusterData }) {
|
||
|
let { id } = useParams();
|
||
|
const [wellsStat, setWellsStat] = useState([]);
|
||
|
|
||
|
calcAndUpdateStatsBySections(wellsStat ?? [], [
|
||
|
"factStart",
|
||
|
"factEnd",
|
||
|
"periodPlan",
|
||
|
"periodFact",
|
||
|
"rateOfPenetrationPlan",
|
||
|
"rateOfPenetrationFact",
|
||
|
"routeSpeedPlan",
|
||
|
"routeSpeedFact",
|
||
|
"notProductiveTime",
|
||
|
]);
|
||
|
|
||
|
useEffect(() => {
|
||
|
let tableData = clusterData.statsWells?.map((el) => {
|
||
|
return {
|
||
|
key: el.id,
|
||
|
id: el.id,
|
||
|
caption: el.caption,
|
||
|
wellType: el.wellType,
|
||
|
factStart: new Date(el.total.fact.start).toLocaleString(),
|
||
|
factEnd: new Date(el.total.fact.end).toLocaleString(),
|
||
|
periodPlan: (
|
||
|
Math.abs(
|
||
|
new Date(el.total.plan.start) - new Date(el.total.plan.end)
|
||
|
) /
|
||
|
(1000 * 60 * 60 * 24)
|
||
|
).toFixed(2),
|
||
|
periodFact: (
|
||
|
Math.abs(
|
||
|
new Date(el.total.fact.start) - new Date(el.total.fact.end)
|
||
|
) /
|
||
|
(1000 * 60 * 60 * 24)
|
||
|
).toFixed(2),
|
||
|
rateOfPenetrationPlan: el.total.plan.rop.toFixed(2),
|
||
|
rateOfPenetrationFact: el.total.fact.rop.toFixed(2),
|
||
|
routeSpeedPlan: el.total.plan.routeSpeed.toFixed(2),
|
||
|
routeSpeedFact: el.total.fact.routeSpeed.toFixed(2),
|
||
|
notProductiveTimePlan: el.total.plan.nonProductiveHours.toFixed(2),
|
||
|
notProductiveTimeFact: el.total.fact.nonProductiveHours.toFixed(2),
|
||
|
companies: el.companies,
|
||
|
};
|
||
|
});
|
||
|
|
||
|
setWellsStat(tableData);
|
||
|
}, [id, clusterData]);
|
||
|
|
||
|
const columns = [
|
||
|
makeTextColumn("скв №", "caption", null, null, (_, item) => (
|
||
|
<Link to={`/well/${item.id}`}>{item.caption}</Link>
|
||
|
)),
|
||
|
makeTextColumn("Тип скв.", "wellType", filtersWellsType),
|
||
|
makeGroupColumn("Фактические сроки", [
|
||
|
makeNumericColumn("начало", "factStart"),
|
||
|
makeNumericColumn("окончание", "factEnd"),
|
||
|
]),
|
||
|
makeNumericColumnPlanFact("Продолжительность", "period", filtersMinMax),
|
||
|
makeNumericColumnPlanFact("МСП", "rateOfPenetration", filtersMinMax),
|
||
|
makeNumericColumnPlanFact("Рейсовая скорость", "routeSpeed", filtersMinMax),
|
||
|
makeNumericColumnPlanFact("НПВ, сут", "notProductiveTime", filtersMinMax),
|
||
|
{
|
||
|
title: "График глубина-день",
|
||
|
render: (_, item) => <Button>Открыть</Button>,
|
||
|
},
|
||
|
{
|
||
|
title: "Таблица по операциям",
|
||
|
render: (_) => <Button>Открыть</Button>,
|
||
|
},
|
||
|
{
|
||
|
title: "Подрядчики",
|
||
|
key: "companies",
|
||
|
dataIndex: "companies",
|
||
|
render: (item) =>
|
||
|
item.map((company) => <Tag color="blue">{company.caption}</Tag>),
|
||
|
},
|
||
|
];
|
||
|
|
||
|
return (
|
||
|
<Table
|
||
|
columns={columns}
|
||
|
dataSource={wellsStat}
|
||
|
size={"small"}
|
||
|
bordered
|
||
|
pagination={false}
|
||
|
rowKey={(record) => record.id}
|
||
|
/>
|
||
|
);
|
||
|
}
|