forked from ddrilling/asb_cloud_front
Moved reusing TVD request to .getOperations() function
This commit is contained in:
parent
73968646e6
commit
322aa42c63
@ -1,16 +1,19 @@
|
|||||||
import { Table, Tag, Button, Badge, Divider, Modal } from "antd";
|
import { Table, Tag, Button, Badge, Divider, Modal } from "antd";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import { LineChartOutlined, ProfileOutlined } from "@ant-design/icons";
|
import { LineChartOutlined, ProfileOutlined } from "@ant-design/icons";
|
||||||
import { useState } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import {
|
import {
|
||||||
makeTextColumn,
|
makeTextColumn,
|
||||||
makeNumericColumnPlanFact
|
makeNumericColumnPlanFact
|
||||||
} from "../../components/Table";
|
} from "../../components/Table";
|
||||||
import { invokeWebApiWrapperAsync } from '../../components/factory';
|
import { invokeWebApiWrapperAsync } from '../../components/factory';
|
||||||
import { WellOperationStatService } from '../../services/api';
|
|
||||||
import ChartDepthToDay from '../../components/charts/ChartDepthToDay';
|
import ChartDepthToDay from '../../components/charts/ChartDepthToDay';
|
||||||
import WellOperationsTable from './WellOperationsTable'
|
import WellOperationsTable from './WellOperationsTable'
|
||||||
import { calcAndUpdateStatsBySections, makeFilterMinMaxFunction } from "./functions";
|
import {
|
||||||
|
calcAndUpdateStatsBySections,
|
||||||
|
makeFilterMinMaxFunction,
|
||||||
|
getOperations
|
||||||
|
} from "./functions";
|
||||||
|
|
||||||
|
|
||||||
const filtersMinMax = [
|
const filtersMinMax = [
|
||||||
@ -29,6 +32,7 @@ const filtersSectionsType = [];
|
|||||||
|
|
||||||
export default function ClusterSections({ clusterData }) {
|
export default function ClusterSections({ clusterData }) {
|
||||||
|
|
||||||
|
const [selectedWellId, setSelectedWellId] = useState(0)
|
||||||
const [selectedWells, setSelectedWells] = useState([]);
|
const [selectedWells, setSelectedWells] = useState([]);
|
||||||
const [selectedWellsKeys, setSelectedWellsKeys] = useState([]);
|
const [selectedWellsKeys, setSelectedWellsKeys] = useState([]);
|
||||||
const [isTVDModalVisible, setIsTVDModalVisible] = useState(false)
|
const [isTVDModalVisible, setIsTVDModalVisible] = useState(false)
|
||||||
@ -38,35 +42,25 @@ export default function ClusterSections({ clusterData }) {
|
|||||||
const [tvdDataForecast, setTvdDataForecast] = useState([]);
|
const [tvdDataForecast, setTvdDataForecast] = useState([]);
|
||||||
const [wellOperations, setWellOperations] = useState([]);
|
const [wellOperations, setWellOperations] = useState([]);
|
||||||
|
|
||||||
const getOperations = (wellId) => {
|
useEffect(() => {
|
||||||
invokeWebApiWrapperAsync(
|
if (selectedWellId > 0) {
|
||||||
async () => {
|
invokeWebApiWrapperAsync(
|
||||||
const operations = await WellOperationStatService.getTvd(wellId);
|
async () => {
|
||||||
|
const operations = await getOperations(selectedWellId);
|
||||||
setWellOperations(operations)
|
|
||||||
|
setWellOperations(operations.operations)
|
||||||
const tvdPlanData = operations.map(el => {
|
|
||||||
return {key: el.caption, depth: el.plan?.wellDepth, date: el.plan?.startDate}
|
setTvdDataPlan(operations.plan)
|
||||||
}).filter(el => el.key)
|
|
||||||
|
setTvdDataFact(operations.fact)
|
||||||
setTvdDataPlan(tvdPlanData)
|
|
||||||
|
setTvdDataForecast(operations.predict)
|
||||||
const tvdFactData = operations.map(el => {
|
},
|
||||||
return {key: el.caption, depth: el.fact?.wellDepth, date: el.fact?.startDate}
|
null,
|
||||||
}).filter(el => el.key)
|
`Не удалось загрузить операции по скважине "${selectedWellId}"`,
|
||||||
|
);
|
||||||
setTvdDataFact(tvdFactData)
|
}
|
||||||
|
}, [selectedWellId]);
|
||||||
const tvdPredictData = operations.map(el => {
|
|
||||||
return {key: el.caption, depth: el.predict?.wellDepth, date: el.predict?.startDate}
|
|
||||||
}).filter(el => el.key)
|
|
||||||
|
|
||||||
setTvdDataForecast(tvdPredictData)
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
`Не удалось загрузить операции по скважине "${wellId}"`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
let rows = [];
|
let rows = [];
|
||||||
|
|
||||||
@ -214,7 +208,7 @@ export default function ClusterSections({ clusterData }) {
|
|||||||
{
|
{
|
||||||
title: "TVD",
|
title: "TVD",
|
||||||
render: (value) => <Button onClick={()=> {
|
render: (value) => <Button onClick={()=> {
|
||||||
getOperations(value.id)
|
setSelectedWellId(value.id)
|
||||||
setIsTVDModalVisible(true)
|
setIsTVDModalVisible(true)
|
||||||
}}><LineChartOutlined /></Button>,
|
}}><LineChartOutlined /></Button>,
|
||||||
align: 'center'
|
align: 'center'
|
||||||
@ -222,7 +216,7 @@ export default function ClusterSections({ clusterData }) {
|
|||||||
{
|
{
|
||||||
title: "Операции",
|
title: "Операции",
|
||||||
render: (value) => <Button onClick={()=> {
|
render: (value) => <Button onClick={()=> {
|
||||||
getOperations(value.id)
|
setSelectedWellId(value.id)
|
||||||
setIsOpsModalVisible(true)
|
setIsOpsModalVisible(true)
|
||||||
}}><ProfileOutlined /></Button>,
|
}}><ProfileOutlined /></Button>,
|
||||||
align: 'center'
|
align: 'center'
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import { useState } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { Table, Tag, Button, Modal } from "antd";
|
import { Table, Tag, Button, Modal } from "antd";
|
||||||
import { LineChartOutlined, ProfileOutlined } from "@ant-design/icons";
|
import { LineChartOutlined, ProfileOutlined } from "@ant-design/icons";
|
||||||
import {
|
import {
|
||||||
@ -11,9 +11,9 @@ import {
|
|||||||
} from "../../components/Table";
|
} from "../../components/Table";
|
||||||
import { calcAndUpdateStatsBySections, makeFilterMinMaxFunction } from "./functions";
|
import { calcAndUpdateStatsBySections, makeFilterMinMaxFunction } from "./functions";
|
||||||
import { invokeWebApiWrapperAsync } from '../../components/factory';
|
import { invokeWebApiWrapperAsync } from '../../components/factory';
|
||||||
import { WellOperationStatService } from '../../services/api';
|
|
||||||
import ChartDepthToDay from '../../components/charts/ChartDepthToDay';
|
import ChartDepthToDay from '../../components/charts/ChartDepthToDay';
|
||||||
import WellOperationsTable from './WellOperationsTable'
|
import WellOperationsTable from './WellOperationsTable'
|
||||||
|
import { getOperations } from "./functions";
|
||||||
|
|
||||||
const filtersMinMax = [
|
const filtersMinMax = [
|
||||||
{
|
{
|
||||||
@ -30,6 +30,7 @@ const filtersWellsType = [];
|
|||||||
|
|
||||||
export default function ClusterWells({clusterData}) {
|
export default function ClusterWells({clusterData}) {
|
||||||
|
|
||||||
|
const [selectedWellId, setSelectedWellId] = useState(0)
|
||||||
const [isTVDModalVisible, setIsTVDModalVisible] = useState(false)
|
const [isTVDModalVisible, setIsTVDModalVisible] = useState(false)
|
||||||
const [isOpsModalVisible, setIsOpsModalVisible] = useState(false)
|
const [isOpsModalVisible, setIsOpsModalVisible] = useState(false)
|
||||||
const [tvdDataPlan, setTvdDataPlan] = useState([]);
|
const [tvdDataPlan, setTvdDataPlan] = useState([]);
|
||||||
@ -37,35 +38,25 @@ export default function ClusterWells({clusterData}) {
|
|||||||
const [tvdDataForecast, setTvdDataForecast] = useState([]);
|
const [tvdDataForecast, setTvdDataForecast] = useState([]);
|
||||||
const [wellOperations, setWellOperations] = useState([]);
|
const [wellOperations, setWellOperations] = useState([]);
|
||||||
|
|
||||||
const getOperations = (wellId) => {
|
useEffect(() => {
|
||||||
|
if (selectedWellId > 0) {
|
||||||
invokeWebApiWrapperAsync(
|
invokeWebApiWrapperAsync(
|
||||||
async () => {
|
async () => {
|
||||||
const operations = await WellOperationStatService.getTvd(wellId);
|
const operations = await getOperations(selectedWellId);
|
||||||
|
|
||||||
setWellOperations(operations)
|
setWellOperations(operations.operations)
|
||||||
|
|
||||||
const tvdPlanData = operations.map(el => {
|
|
||||||
return {key: el.caption, depth: el.plan?.wellDepth, date: el.plan?.startDate}
|
|
||||||
}).filter(el => el.key)
|
|
||||||
|
|
||||||
setTvdDataPlan(tvdPlanData)
|
setTvdDataPlan(operations.plan)
|
||||||
|
|
||||||
const tvdFactData = operations.map(el => {
|
setTvdDataFact(operations.fact)
|
||||||
return {key: el.caption, depth: el.fact?.wellDepth, date: el.fact?.startDate}
|
|
||||||
}).filter(el => el.key)
|
|
||||||
|
|
||||||
setTvdDataFact(tvdFactData)
|
setTvdDataForecast(operations.predict)
|
||||||
|
|
||||||
const tvdPredictData = operations.map(el => {
|
|
||||||
return {key: el.caption, depth: el.predict?.wellDepth, date: el.predict?.startDate}
|
|
||||||
}).filter(el => el.key)
|
|
||||||
|
|
||||||
setTvdDataForecast(tvdPredictData)
|
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
`Не удалось загрузить операции по скважине "${wellId}"`,
|
`Не удалось загрузить операции по скважине "${selectedWellId}"`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}, [selectedWellId]);
|
||||||
|
|
||||||
let tableData = clusterData.statsWells?.map((well) => {
|
let tableData = clusterData.statsWells?.map((well) => {
|
||||||
|
|
||||||
@ -173,7 +164,7 @@ export default function ClusterWells({clusterData}) {
|
|||||||
title: "TVD",
|
title: "TVD",
|
||||||
key: "tvd",
|
key: "tvd",
|
||||||
render: (value) => <Button onClick={()=> {
|
render: (value) => <Button onClick={()=> {
|
||||||
getOperations(value.id)
|
setSelectedWellId(value.id)
|
||||||
setIsTVDModalVisible(true)
|
setIsTVDModalVisible(true)
|
||||||
}}><LineChartOutlined /></Button>,
|
}}><LineChartOutlined /></Button>,
|
||||||
align: 'center'
|
align: 'center'
|
||||||
@ -182,7 +173,7 @@ export default function ClusterWells({clusterData}) {
|
|||||||
title: "Операции",
|
title: "Операции",
|
||||||
key: "operations",
|
key: "operations",
|
||||||
render: (value) => <Button onClick={()=> {
|
render: (value) => <Button onClick={()=> {
|
||||||
getOperations(value.id)
|
setSelectedWellId(value.id)
|
||||||
setIsOpsModalVisible(true)
|
setIsOpsModalVisible(true)
|
||||||
}}><ProfileOutlined /></Button>,
|
}}><ProfileOutlined /></Button>,
|
||||||
align: 'center'
|
align: 'center'
|
||||||
|
@ -1,6 +1,26 @@
|
|||||||
|
import { WellOperationStatService } from '../../services/api';
|
||||||
|
|
||||||
const maxPrefix = "isMax"
|
const maxPrefix = "isMax"
|
||||||
const minPrefix = "isMin"
|
const minPrefix = "isMin"
|
||||||
|
|
||||||
|
export const getOperations = async (idWell) => {
|
||||||
|
const ops = await WellOperationStatService.getTvd(idWell);
|
||||||
|
|
||||||
|
const planData = ops.map(el => {
|
||||||
|
return {key: el.plan?.id, depth: el.plan?.wellDepth, date: el.plan?.startDate}
|
||||||
|
}).filter(el => el.key)
|
||||||
|
|
||||||
|
const factData = ops.map(el => {
|
||||||
|
return {key: el.fact?.id, depth: el.fact?.wellDepth, date: el.fact?.startDate}
|
||||||
|
}).filter(el => el.key)
|
||||||
|
|
||||||
|
const predictData = ops.map(el => {
|
||||||
|
return {key: el.predict?.id, depth: el.predict?.wellDepth, date: el.predict?.startDate}
|
||||||
|
}).filter(el => el.key)
|
||||||
|
|
||||||
|
return { operations: ops, plan: planData, fact: factData, predict: predictData }
|
||||||
|
}
|
||||||
|
|
||||||
export const makeFilterMinMaxFunction = (key) => (filterValue,
|
export const makeFilterMinMaxFunction = (key) => (filterValue,
|
||||||
dataItem) =>
|
dataItem) =>
|
||||||
filterValue === "max"
|
filterValue === "max"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import ChartDepthToDay from '../../components/charts/ChartDepthToDay';
|
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 { getOperations } from '../Cluster/functions';
|
||||||
|
|
||||||
|
|
||||||
export const Tvd = ({ idWell }) => {
|
export const Tvd = ({ idWell }) => {
|
||||||
@ -12,23 +12,13 @@ export const Tvd = ({ idWell }) => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
invokeWebApiWrapperAsync(
|
invokeWebApiWrapperAsync(
|
||||||
async () => {
|
async () => {
|
||||||
const operations = await WellOperationStatService.getTvd(idWell);
|
const operations = await getOperations(idWell);
|
||||||
|
|
||||||
const planData = operations.map(el => {
|
setDataPlan(operations.plan)
|
||||||
return {key: el.plan?.id, depth: el.plan?.wellDepth, date: el.plan?.startDate}
|
|
||||||
}).filter(el => el.key)
|
|
||||||
|
|
||||||
setDataPlan(planData)
|
setDataFact(operations.fact)
|
||||||
const factData = operations.map(el => {
|
|
||||||
return {key: el.fact?.id, depth: el.fact?.wellDepth, date: el.fact?.startDate}
|
|
||||||
}).filter(el => el.key)
|
|
||||||
|
|
||||||
setDataFact(factData)
|
setDataForecast(operations.predict)
|
||||||
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,
|
null,
|
||||||
`Не удалось загрузить операции по скважине "${idWell}"`,
|
`Не удалось загрузить операции по скважине "${idWell}"`,
|
||||||
|
Loading…
Reference in New Issue
Block a user