forked from ddrilling/asb_cloud_front
Removed 'Cluster' tables functions from 'Table' folder to Cluster index
This commit is contained in:
parent
47c76b5a88
commit
e063fac9ad
@ -134,40 +134,6 @@ export const makeNumericColumnPlanFact = (title: any, dataIndex: any, filters: a
|
||||
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 = {
|
||||
skip?: number;
|
||||
take?: number;
|
||||
|
@ -68,8 +68,8 @@ const defaultOptions = {
|
||||
reverse:true,
|
||||
display: true,
|
||||
title: {
|
||||
display: true,
|
||||
text: 'Value'
|
||||
display: false,
|
||||
text: ''
|
||||
},
|
||||
}
|
||||
},
|
||||
@ -111,7 +111,7 @@ const makeDataset = (data, label, color, width=1.5, dash) => ({
|
||||
borderDash: dash,
|
||||
})
|
||||
|
||||
export default function DepthToDay({dataPlan, dataFact, dataForecast}) {
|
||||
export default function ChartDepthToDay({dataPlan, dataFact, dataForecast}) {
|
||||
const chartRef = useRef(null)
|
||||
const [chart, setChart] = useState()
|
||||
|
@ -4,9 +4,9 @@ import { LineChartOutlined, ProfileOutlined } from "@ant-design/icons";
|
||||
import { useState, useEffect } from "react";
|
||||
import {
|
||||
makeTextColumn,
|
||||
makeNumericColumnPlanFact,
|
||||
calcAndUpdateStatsBySections,
|
||||
makeNumericColumnPlanFact
|
||||
} from "../../components/Table";
|
||||
import { calcAndUpdateStatsBySections } from "./index";
|
||||
|
||||
const filtersMinMax = [
|
||||
{
|
||||
|
@ -6,12 +6,12 @@ import {
|
||||
makeTextColumn,
|
||||
makeGroupColumn,
|
||||
makeNumericColumn,
|
||||
makeNumericColumnPlanFact,
|
||||
calcAndUpdateStatsBySections,
|
||||
makeNumericColumnPlanFact
|
||||
} from "../../components/Table";
|
||||
import { calcAndUpdateStatsBySections } from "./index";
|
||||
import { invokeWebApiWrapperAsync } from '../../components/factory';
|
||||
import { WellOperationStatService } from '../../services/api';
|
||||
import DepthToDay from '../../components/charts/DepthToDay';
|
||||
import ChartDepthToDay from '../../components/charts/ChartDepthToDay';
|
||||
|
||||
const filtersMinMax = [
|
||||
{
|
||||
@ -45,31 +45,33 @@ export default function ClusterWells({ clusterData }) {
|
||||
const [dataForecast, setDataForecast] = useState([]);
|
||||
|
||||
useEffect(() => {
|
||||
invokeWebApiWrapperAsync(
|
||||
async () => {
|
||||
const operations = await WellOperationStatService.getTvd(selectedWellId);
|
||||
if (selectedWellId > 0) {
|
||||
invokeWebApiWrapperAsync(
|
||||
async () => {
|
||||
const operations = await WellOperationStatService.getTvd(selectedWellId);
|
||||
|
||||
const planData = operations.map(el => {
|
||||
return {key: el.plan?.id, depth: el.plan?.wellDepth, date: el.plan?.startDate}
|
||||
}).filter(el => el.key)
|
||||
const planData = operations.map(el => {
|
||||
return {key: el.plan?.id, depth: el.plan?.wellDepth, date: el.plan?.startDate}
|
||||
}).filter(el => el.key)
|
||||
|
||||
setDataPlan(planData)
|
||||
setDataPlan(planData)
|
||||
|
||||
const factData = operations.map(el => {
|
||||
return {key: el.fact?.id, depth: el.fact?.wellDepth, date: el.fact?.startDate}
|
||||
}).filter(el => el.key)
|
||||
const factData = operations.map(el => {
|
||||
return {key: el.fact?.id, depth: el.fact?.wellDepth, date: el.fact?.startDate}
|
||||
}).filter(el => el.key)
|
||||
|
||||
setDataFact(factData)
|
||||
setDataFact(factData)
|
||||
|
||||
const predictData = operations.map(el => {
|
||||
return {key: el.predict?.id, depth: el.predict?.wellDepth, date: el.predict?.startDate}
|
||||
}).filter(el => el.key)
|
||||
const predictData = operations.map(el => {
|
||||
return {key: el.predict?.id, depth: el.predict?.wellDepth, date: el.predict?.startDate}
|
||||
}).filter(el => el.key)
|
||||
|
||||
setDataForecast(predictData)
|
||||
},
|
||||
null,
|
||||
`Не удалось загрузить операции по скважине "${selectedWellId}"`,
|
||||
);
|
||||
setDataForecast(predictData)
|
||||
},
|
||||
null,
|
||||
`Не удалось загрузить операции по скважине "${selectedWellId}"`,
|
||||
);
|
||||
}
|
||||
}, [selectedWellId]);
|
||||
|
||||
const closeModal = () => {
|
||||
@ -98,16 +100,12 @@ export default function ClusterWells({ clusterData }) {
|
||||
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)
|
||||
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)
|
||||
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),
|
||||
@ -167,14 +165,14 @@ export default function ClusterWells({ clusterData }) {
|
||||
/>
|
||||
|
||||
<Modal
|
||||
title='Modal'
|
||||
title='TVD'
|
||||
centered
|
||||
visible={isModalVisible}
|
||||
onOk={closeModal}
|
||||
onCancel={closeModal}
|
||||
width={800}
|
||||
width={1500}
|
||||
>
|
||||
<DepthToDay
|
||||
<ChartDepthToDay
|
||||
dataPlan={dataPlan}
|
||||
dataFact={dataFact}
|
||||
dataForecast={dataForecast} />
|
||||
|
@ -9,6 +9,43 @@ import { WellOperationStatService } from "../../services/api";
|
||||
|
||||
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() {
|
||||
let { idClaster, tab } = useParams();
|
||||
const [data, setData] = useState([]);
|
||||
|
@ -1,4 +1,4 @@
|
||||
import DepthToDay from '../../components/charts/DepthToDay';
|
||||
import ChartDepthToDay from '../../components/charts/ChartDepthToDay';
|
||||
import { useState, useEffect } from 'react';
|
||||
import { invokeWebApiWrapperAsync } from '../../components/factory';
|
||||
import { WellOperationStatService } from '../../services/api';
|
||||
@ -39,7 +39,7 @@ export const Tvd = ({ idWell }) => {
|
||||
<div className="container">
|
||||
<div>
|
||||
<h2 className={'mt-20px'}>График Глубина-день</h2>
|
||||
<DepthToDay
|
||||
<ChartDepthToDay
|
||||
dataPlan={dataPlan}
|
||||
dataFact={dataFact}
|
||||
dataForecast={dataForecast} />
|
||||
|
Loading…
Reference in New Issue
Block a user