Removed 'Cluster' tables functions from 'Table' folder to Cluster index

This commit is contained in:
KharchenkoVV 2021-08-30 11:26:00 +05:00
parent 47c76b5a88
commit e063fac9ad
6 changed files with 81 additions and 80 deletions

View File

@ -134,40 +134,6 @@ export const makeNumericColumnPlanFact = (title: any, dataIndex: any, filters: a
makeNumericColumn('ф', dataIndex + 'Fact', filters, width), makeNumericColumn('ф', dataIndex + 'Fact', filters, width),
]) ])
export const calcAndUpdateStats = (data: any, keys: any) => {
let mins: any = {}
let maxs: any = {}
keys.forEach((key: any) => {
maxs[key] = Number.MIN_VALUE
mins[key] = Number.MAX_VALUE
})
data.forEach((item: any) => {
keys.forEach((key: any) => {
if (mins[key] > item[key]) mins[key] = item[key]
if (maxs[key] < item[key]) maxs[key] = item[key]
})
})
for (let i = 0; i < data.length; i++) {
keys.forEach((key: any) => {
data[i][maxPrefix + key] = data[i][key] === maxs[key]
data[i][minPrefix + key] = data[i][key] === mins[key]
})
}
}
export const calcAndUpdateStatsBySections = (data: any, keys: any) => {
const sectionTypes = new Set()
data.forEach((item: any) => sectionTypes.add(item.sectionType))
sectionTypes.forEach(sectionType => {
const filteredBySectionData = data.filter((item: any) => item.sectionType === sectionType)
calcAndUpdateStats(filteredBySectionData, keys)
})
}
type PaginationContainer = { type PaginationContainer = {
skip?: number; skip?: number;
take?: number; take?: number;

View File

@ -68,8 +68,8 @@ const defaultOptions = {
reverse:true, reverse:true,
display: true, display: true,
title: { title: {
display: true, display: false,
text: 'Value' text: ''
}, },
} }
}, },
@ -111,7 +111,7 @@ const makeDataset = (data, label, color, width=1.5, dash) => ({
borderDash: dash, borderDash: dash,
}) })
export default function DepthToDay({dataPlan, dataFact, dataForecast}) { export default function ChartDepthToDay({dataPlan, dataFact, dataForecast}) {
const chartRef = useRef(null) const chartRef = useRef(null)
const [chart, setChart] = useState() const [chart, setChart] = useState()

View File

@ -4,9 +4,9 @@ import { LineChartOutlined, ProfileOutlined } from "@ant-design/icons";
import { useState, useEffect } from "react"; import { useState, useEffect } from "react";
import { import {
makeTextColumn, makeTextColumn,
makeNumericColumnPlanFact, makeNumericColumnPlanFact
calcAndUpdateStatsBySections,
} from "../../components/Table"; } from "../../components/Table";
import { calcAndUpdateStatsBySections } from "./index";
const filtersMinMax = [ const filtersMinMax = [
{ {

View File

@ -6,12 +6,12 @@ import {
makeTextColumn, makeTextColumn,
makeGroupColumn, makeGroupColumn,
makeNumericColumn, makeNumericColumn,
makeNumericColumnPlanFact, makeNumericColumnPlanFact
calcAndUpdateStatsBySections,
} from "../../components/Table"; } from "../../components/Table";
import { calcAndUpdateStatsBySections } from "./index";
import { invokeWebApiWrapperAsync } from '../../components/factory'; import { invokeWebApiWrapperAsync } from '../../components/factory';
import { WellOperationStatService } from '../../services/api'; import { WellOperationStatService } from '../../services/api';
import DepthToDay from '../../components/charts/DepthToDay'; import ChartDepthToDay from '../../components/charts/ChartDepthToDay';
const filtersMinMax = [ const filtersMinMax = [
{ {
@ -45,6 +45,7 @@ export default function ClusterWells({ clusterData }) {
const [dataForecast, setDataForecast] = useState([]); const [dataForecast, setDataForecast] = useState([]);
useEffect(() => { useEffect(() => {
if (selectedWellId > 0) {
invokeWebApiWrapperAsync( invokeWebApiWrapperAsync(
async () => { async () => {
const operations = await WellOperationStatService.getTvd(selectedWellId); const operations = await WellOperationStatService.getTvd(selectedWellId);
@ -70,6 +71,7 @@ export default function ClusterWells({ clusterData }) {
null, null,
`Не удалось загрузить операции по скважине "${selectedWellId}"`, `Не удалось загрузить операции по скважине "${selectedWellId}"`,
); );
}
}, [selectedWellId]); }, [selectedWellId]);
const closeModal = () => { const closeModal = () => {
@ -98,15 +100,11 @@ export default function ClusterWells({ clusterData }) {
factStart: new Date(el.total.fact.start).toLocaleString(), factStart: new Date(el.total.fact.start).toLocaleString(),
factEnd: new Date(el.total.fact.end).toLocaleString(), factEnd: new Date(el.total.fact.end).toLocaleString(),
periodPlan: ( periodPlan: (
Math.abs( new Date(el.total.plan.start) - new Date(el.total.plan.end) /
new Date(el.total.plan.start) - new Date(el.total.plan.end)
) /
(1000 * 60 * 60 * 24) (1000 * 60 * 60 * 24)
).toFixed(2), ).toFixed(2),
periodFact: ( periodFact: (
Math.abs( new Date(el.total.fact.start) - new Date(el.total.fact.end) /
new Date(el.total.fact.start) - new Date(el.total.fact.end)
) /
(1000 * 60 * 60 * 24) (1000 * 60 * 60 * 24)
).toFixed(2), ).toFixed(2),
rateOfPenetrationPlan: el.total.plan.rop.toFixed(2), rateOfPenetrationPlan: el.total.plan.rop.toFixed(2),
@ -167,14 +165,14 @@ export default function ClusterWells({ clusterData }) {
/> />
<Modal <Modal
title='Modal' title='TVD'
centered centered
visible={isModalVisible} visible={isModalVisible}
onOk={closeModal} onOk={closeModal}
onCancel={closeModal} onCancel={closeModal}
width={800} width={1500}
> >
<DepthToDay <ChartDepthToDay
dataPlan={dataPlan} dataPlan={dataPlan}
dataFact={dataFact} dataFact={dataFact}
dataForecast={dataForecast} /> dataForecast={dataForecast} />

View File

@ -9,6 +9,43 @@ import { WellOperationStatService } from "../../services/api";
const { Content } = Layout; const { Content } = Layout;
const maxPrefix = "isMax"
const minPrefix = "isMin"
export const calcAndUpdateStats = (data, keys) => {
let mins = {}
let maxs = {}
keys.forEach((key) => {
maxs[key] = Number.MIN_VALUE
mins[key] = Number.MAX_VALUE
})
data.forEach((item) => {
keys.forEach((key) => {
if (mins[key] > item[key]) mins[key] = item[key]
if (maxs[key] < item[key]) maxs[key] = item[key]
})
})
for (let i = 0; i < data.length; i++) {
keys.forEach((key) => {
data[i][maxPrefix + key] = data[i][key] === maxs[key]
data[i][minPrefix + key] = data[i][key] === mins[key]
})
}
}
export const calcAndUpdateStatsBySections = (data, keys) => {
const sectionTypes = new Set()
data.forEach((item) => sectionTypes.add(item.sectionType))
sectionTypes.forEach(sectionType => {
const filteredBySectionData = data.filter((item) => item.sectionType === sectionType)
calcAndUpdateStats(filteredBySectionData, keys)
})
}
export default function Cluster() { export default function Cluster() {
let { idClaster, tab } = useParams(); let { idClaster, tab } = useParams();
const [data, setData] = useState([]); const [data, setData] = useState([]);

View File

@ -1,4 +1,4 @@
import DepthToDay from '../../components/charts/DepthToDay'; import ChartDepthToDay from '../../components/charts/ChartDepthToDay';
import { useState, useEffect } from 'react'; import { useState, useEffect } from 'react';
import { invokeWebApiWrapperAsync } from '../../components/factory'; import { invokeWebApiWrapperAsync } from '../../components/factory';
import { WellOperationStatService } from '../../services/api'; import { WellOperationStatService } from '../../services/api';
@ -39,7 +39,7 @@ export const Tvd = ({ idWell }) => {
<div className="container"> <div className="container">
<div> <div>
<h2 className={'mt-20px'}>График Глубина-день</h2> <h2 className={'mt-20px'}>График Глубина-день</h2>
<DepthToDay <ChartDepthToDay
dataPlan={dataPlan} dataPlan={dataPlan}
dataFact={dataFact} dataFact={dataFact}
dataForecast={dataForecast} /> dataForecast={dataForecast} />