forked from ddrilling/asb_cloud_front
WellOperationStatService переименован
This commit is contained in:
parent
5ad3bd5e07
commit
43a01bd57f
@ -25,7 +25,7 @@ interface TreeNodeData {
|
|||||||
children?: TreeNodeData[]
|
children?: TreeNodeData[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export const WellTreeSelector = (): React.ReactNode => {
|
export const WellTreeSelector = () => {
|
||||||
const [wellsTree, setWellsTree] = useState<TreeNodeData[]>([])
|
const [wellsTree, setWellsTree] = useState<TreeNodeData[]>([])
|
||||||
const [showLoader, setShowLoader] = useState<boolean>(false)
|
const [showLoader, setShowLoader] = useState<boolean>(false)
|
||||||
const history = useHistory()
|
const history = useHistory()
|
||||||
|
@ -1,21 +1,20 @@
|
|||||||
import { WellOperationStatService } from '../../services/api';
|
import { OperationStatService } from '../../services/api'
|
||||||
|
|
||||||
const maxPrefix = "isMax"
|
const maxPrefix = 'isMax'
|
||||||
const minPrefix = "isMin"
|
const minPrefix = 'isMin'
|
||||||
|
|
||||||
export const getPrecision = (number) => Number.isNaN(number ?? NaN) ? '-' : number.toFixed(2)
|
export const getPrecision = (number) => Number.isNaN(number ?? NaN) ? '-' : number.toFixed(2)
|
||||||
|
|
||||||
export const getOperations = async (idWell) => {
|
export const getOperations = async (idWell) => {
|
||||||
const ops = await WellOperationStatService.getTvd(idWell);
|
const ops = await OperationStatService.getTvd(idWell)
|
||||||
|
|
||||||
if (!ops) return [];
|
if (!ops) return []
|
||||||
|
|
||||||
const convert = wellOperationDto =>
|
const convert = wellOperationDto => ({
|
||||||
({
|
key: wellOperationDto?.id,
|
||||||
key: wellOperationDto?.id,
|
depth: wellOperationDto?.depthStart,
|
||||||
depth: wellOperationDto?.depthStart,
|
date: wellOperationDto?.dateStart
|
||||||
date: wellOperationDto?.dateStart
|
})
|
||||||
})
|
|
||||||
|
|
||||||
const planData = ops
|
const planData = ops
|
||||||
.map(item => convert(item.plan))
|
.map(item => convert(item.plan))
|
||||||
@ -26,23 +25,23 @@ export const getOperations = async (idWell) => {
|
|||||||
.filter(el => el.key)
|
.filter(el => el.key)
|
||||||
|
|
||||||
const predictData = ops
|
const predictData = ops
|
||||||
.map(item => convert(item.predict))
|
.map(item => convert(item.predict))
|
||||||
.filter(el => el.key)
|
.filter(el => el.key)
|
||||||
|
|
||||||
return { operations: ops, plan: planData, fact: factData, predict: predictData }
|
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'
|
||||||
? dataItem[maxPrefix + key]
|
? dataItem[maxPrefix + key]
|
||||||
: filterValue === "min"
|
: filterValue === 'min'
|
||||||
? dataItem[minPrefix + key]
|
? dataItem[minPrefix + key]
|
||||||
: false
|
: false
|
||||||
|
|
||||||
export const calcAndUpdateStats = (data, keys) => {
|
export const calcAndUpdateStats = (data, keys) => {
|
||||||
let mins = {}
|
const mins = {}
|
||||||
let maxs = {}
|
const maxs = {}
|
||||||
|
|
||||||
keys.forEach((key) => {
|
keys.forEach((key) => {
|
||||||
maxs[key] = Number.MIN_VALUE
|
maxs[key] = Number.MIN_VALUE
|
||||||
@ -52,7 +51,6 @@ export const calcAndUpdateStats = (data, keys) => {
|
|||||||
data.forEach((item) => {
|
data.forEach((item) => {
|
||||||
keys.forEach((key) => {
|
keys.forEach((key) => {
|
||||||
if (mins[key] > item[key]) mins[key] = item[key]
|
if (mins[key] > item[key]) mins[key] = item[key]
|
||||||
|
|
||||||
if (maxs[key] < item[key]) maxs[key] = item[key]
|
if (maxs[key] < item[key]) maxs[key] = item[key]
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -64,7 +62,7 @@ export const calcAndUpdateStats = (data, keys) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const calcAndUpdateStatsBySections = (data, keys) => {
|
export const calcAndUpdateStatsBySections = (data, keys) => {
|
||||||
const sectionTypes = new Set()
|
const sectionTypes = new Set()
|
||||||
data.forEach((item) => sectionTypes.add(item.sectionType))
|
data.forEach((item) => sectionTypes.add(item.sectionType))
|
||||||
|
@ -3,7 +3,7 @@ import { useState, useEffect } from 'react'
|
|||||||
import ClusterWells from './ClusterWells'
|
import ClusterWells from './ClusterWells'
|
||||||
import LoaderPortal from '../../components/LoaderPortal'
|
import LoaderPortal from '../../components/LoaderPortal'
|
||||||
import { invokeWebApiWrapperAsync } from '../../components/factory'
|
import { invokeWebApiWrapperAsync } from '../../components/factory'
|
||||||
import { WellOperationStatService } from '../../services/api'
|
import { OperationStatService } from '../../services/api'
|
||||||
|
|
||||||
|
|
||||||
export const Cluster = () => {
|
export const Cluster = () => {
|
||||||
@ -13,7 +13,7 @@ export const Cluster = () => {
|
|||||||
|
|
||||||
useEffect(() => invokeWebApiWrapperAsync(
|
useEffect(() => invokeWebApiWrapperAsync(
|
||||||
async () => {
|
async () => {
|
||||||
const clusterData = await WellOperationStatService.getStatCluster(idClaster)
|
const clusterData = await OperationStatService.getStatCluster(idClaster)
|
||||||
setData(clusterData?.statsWells ?? [])
|
setData(clusterData?.statsWells ?? [])
|
||||||
},
|
},
|
||||||
setShowLoader,
|
setShowLoader,
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
import { useEffect, useState } from "react"
|
import { useEffect, useState } from 'react'
|
||||||
import { invokeWebApiWrapperAsync } from "../../../components/factory"
|
import { invokeWebApiWrapperAsync } from '../../../components/factory'
|
||||||
import LoaderPortal from "../../../components/LoaderPortal";
|
import LoaderPortal from '../../../components/LoaderPortal'
|
||||||
import { WellOperationStatService } from "../../../services/api";
|
import { OperationStatService } from '../../../services/api'
|
||||||
import ClusterWells from "../../Cluster/ClusterWells";
|
import ClusterWells from '../../Cluster/ClusterWells'
|
||||||
|
|
||||||
export const WellCompositeInfo = ({idWell, selectedIdWells}) => {
|
export const WellCompositeInfo = ({idWell, selectedIdWells}) => {
|
||||||
const [showLoader, setShowLoader] = useState(false);
|
const [showLoader, setShowLoader] = useState(false)
|
||||||
const [statsWells, setStatsWells] = useState([]);
|
const [statsWells, setStatsWells] = useState([])
|
||||||
|
|
||||||
useEffect(() => invokeWebApiWrapperAsync(
|
useEffect(() => invokeWebApiWrapperAsync(
|
||||||
async () => {
|
async () => {
|
||||||
const operations = await WellOperationStatService.getWellsStat(selectedIdWells)
|
const operations = await OperationStatService.getWellsStat(selectedIdWells)
|
||||||
setStatsWells(operations)
|
setStatsWells(operations)
|
||||||
},
|
},
|
||||||
setShowLoader,
|
setShowLoader,
|
||||||
|
@ -5,14 +5,14 @@ import { DepositService, WellCompositeService } from '../../../services/api'
|
|||||||
import { invokeWebApiWrapperAsync } from '../../../components/factory'
|
import { invokeWebApiWrapperAsync } from '../../../components/factory'
|
||||||
import LoaderPortal from '../../../components/LoaderPortal'
|
import LoaderPortal from '../../../components/LoaderPortal'
|
||||||
import { WellCompositeSections } from './WellCompositeSections'
|
import { WellCompositeSections } from './WellCompositeSections'
|
||||||
import { WellOperationStatService } from '../../../services/api'
|
import { OperationStatService } from '../../../services/api'
|
||||||
import ClusterWells from '../../Cluster/ClusterWells'
|
import ClusterWells from '../../Cluster/ClusterWells'
|
||||||
|
|
||||||
const { Content } = Layout
|
const { Content } = Layout
|
||||||
|
|
||||||
export const WellCompositeEditor = ({idWell}) => {
|
export const WellCompositeEditor = ({idWell}) => {
|
||||||
const { tab } = useParams()
|
const { tab } = useParams()
|
||||||
const rootPath = `/well/${idWell}/operations/composite`;
|
const rootPath = `/well/${idWell}/operations/composite`
|
||||||
|
|
||||||
const [wellsTree, setWellsTree] = useState([])
|
const [wellsTree, setWellsTree] = useState([])
|
||||||
const [showLoader, setShowLoader] = useState(false)
|
const [showLoader, setShowLoader] = useState(false)
|
||||||
@ -68,7 +68,7 @@ export const WellCompositeEditor = ({idWell}) => {
|
|||||||
|
|
||||||
useEffect(() => invokeWebApiWrapperAsync(
|
useEffect(() => invokeWebApiWrapperAsync(
|
||||||
async () => {
|
async () => {
|
||||||
const stats = await WellOperationStatService.getWellsStat(selectedIdWells)
|
const stats = await OperationStatService.getWellsStat(selectedIdWells)
|
||||||
setStatsWells(Array.isArray(stats) ? stats : [])
|
setStatsWells(Array.isArray(stats) ? stats : [])
|
||||||
},
|
},
|
||||||
setShowTabLoader,
|
setShowTabLoader,
|
||||||
@ -98,24 +98,24 @@ export const WellCompositeEditor = ({idWell}) => {
|
|||||||
</Col>
|
</Col>
|
||||||
<Col span={6}>
|
<Col span={6}>
|
||||||
<Menu
|
<Menu
|
||||||
mode="horizontal"
|
mode={'horizontal'}
|
||||||
selectable={true}
|
selectable={true}
|
||||||
className="well_menu"
|
className={'well_menu'}
|
||||||
selectedKeys={[tab]}
|
selectedKeys={[tab]}
|
||||||
>
|
>
|
||||||
<Menu.Item key="wells">
|
<Menu.Item key={'wells'}>
|
||||||
<Link to={`${rootPath}/wells`}>Статистика по скважинам</Link>
|
<Link to={`${rootPath}/wells`}>Статистика по скважинам</Link>
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
<Menu.Item key="sections">
|
<Menu.Item key={'sections'}>
|
||||||
<Link to={`${rootPath}/sections`}>Статистика по секциям</Link>
|
<Link to={`${rootPath}/sections`}>Статистика по секциям</Link>
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
</Menu>
|
</Menu>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
<Layout>
|
<Layout>
|
||||||
<Content className="site-layout-background">
|
<Content className={'site-layout-background'}>
|
||||||
<LoaderPortal show={showTabLoader}>
|
<LoaderPortal show={showTabLoader}>
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route path={`${rootPath}/wells`}>
|
<Route path={`${rootPath}/wells`}>
|
||||||
<ClusterWells statsWells={statsWells}/>
|
<ClusterWells statsWells={statsWells}/>
|
||||||
</Route>
|
</Route>
|
||||||
@ -135,4 +135,4 @@ export const WellCompositeEditor = ({idWell}) => {
|
|||||||
</Layout>
|
</Layout>
|
||||||
</LoaderPortal>
|
</LoaderPortal>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -2,28 +2,28 @@ import { useState, useEffect } from 'react'
|
|||||||
import LoaderPortal from '../../components/LoaderPortal'
|
import LoaderPortal from '../../components/LoaderPortal'
|
||||||
import { invokeWebApiWrapperAsync } from '../../components/factory'
|
import { invokeWebApiWrapperAsync } from '../../components/factory'
|
||||||
import { Table, makeColumn, makeColumnsPlanFact } from '../../components/Table'
|
import { Table, makeColumn, makeColumnsPlanFact } from '../../components/Table'
|
||||||
import { WellOperationStatService } from '../../services/api'
|
import { OperationStatService } from '../../services/api'
|
||||||
|
|
||||||
const makeNumberRender = format => value => {
|
const makeNumberRender = value => {
|
||||||
const v = +value
|
const v = +value
|
||||||
if(Number.isFinite(v))
|
if(Number.isFinite(v))
|
||||||
return v.toFixed(format)
|
return v.toFixed(2)
|
||||||
return '-'
|
return '-'
|
||||||
}
|
}
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
makeColumn('Тип секции','sectionType'),
|
makeColumn('Тип секции', 'sectionType'),
|
||||||
makeColumnsPlanFact('Глубина' ,'wellDepth', {render:makeNumberRender(2)}),
|
makeColumnsPlanFact('Глубина' ,'wellDepth', {render:makeNumberRender}),
|
||||||
makeColumnsPlanFact('Часы' ,'duration', {render:makeNumberRender(2)}),
|
makeColumnsPlanFact('Часы' ,'duration', {render:makeNumberRender}),
|
||||||
makeColumnsPlanFact('МСП' ,'rop', {render:makeNumberRender(2)}),
|
makeColumnsPlanFact('МСП' ,'rop', {render:makeNumberRender}),
|
||||||
makeColumnsPlanFact('Рейсовая скорость' ,'routeSpeed', {render:makeNumberRender(2)}),
|
makeColumnsPlanFact('Рейсовая скорость' ,'routeSpeed', {render:makeNumberRender}),
|
||||||
makeColumnsPlanFact('Подъем КНБК' ,'bhaUpSpeed', {render:makeNumberRender(2)}),
|
makeColumnsPlanFact('Подъем КНБК' ,'bhaUpSpeed', {render:makeNumberRender}),
|
||||||
makeColumnsPlanFact('Спуск КНБК' ,'bhaDownSpeed', {render:makeNumberRender(2)}),
|
makeColumnsPlanFact('Спуск КНБК' ,'bhaDownSpeed', {render:makeNumberRender}),
|
||||||
makeColumnsPlanFact('Спуск ОК' ,'casingDownSpeed', {render:makeNumberRender(2)}),
|
makeColumnsPlanFact('Спуск ОК' ,'casingDownSpeed', {render:makeNumberRender}),
|
||||||
]
|
]
|
||||||
|
|
||||||
const calcDuration = (start, end) => {
|
const calcDuration = (start, end) => {
|
||||||
const msInDay = 1000*60*60*24
|
const msInDay = 1000 * 60 * 60 * 24
|
||||||
const startD = new Date(start)
|
const startD = new Date(start)
|
||||||
const endD = new Date(end)
|
const endD = new Date(end)
|
||||||
const ms = endD - startD
|
const ms = endD - startD
|
||||||
@ -36,11 +36,11 @@ export const WellSectionsStat = ({idWell}) => {
|
|||||||
|
|
||||||
useEffect(() => invokeWebApiWrapperAsync(
|
useEffect(() => invokeWebApiWrapperAsync(
|
||||||
async () => {
|
async () => {
|
||||||
const sectionsResponse = await WellOperationStatService.getStatWell(idWell)
|
const sectionsResponse = await OperationStatService.getStatWell(idWell)
|
||||||
|
|
||||||
if(sectionsResponse?.sections){
|
if(sectionsResponse?.sections){
|
||||||
const sections = sectionsResponse.sections
|
const sections = sectionsResponse.sections
|
||||||
.map(s=>({
|
.map(s => ({
|
||||||
key: s.id,
|
key: s.id,
|
||||||
sectionType: s.caption,
|
sectionType: s.caption,
|
||||||
wellDepthPlan: s.plan?.wellDepthEnd,
|
wellDepthPlan: s.plan?.wellDepthEnd,
|
||||||
@ -51,26 +51,29 @@ export const WellSectionsStat = ({idWell}) => {
|
|||||||
bhaDownSpeedPlan: s.plan?.bhaDownSpeed,
|
bhaDownSpeedPlan: s.plan?.bhaDownSpeed,
|
||||||
casingDownSpeedPlan: s.plan?.casingDownSpeed,
|
casingDownSpeedPlan: s.plan?.casingDownSpeed,
|
||||||
|
|
||||||
wellDepthFact : s.fact?.wellDepthEnd,
|
wellDepthFact: s.fact?.wellDepthEnd,
|
||||||
durationFact : calcDuration(s.fact?.start, s.fact?.end),
|
durationFact: calcDuration(s.fact?.start, s.fact?.end),
|
||||||
ropFact : s.fact?.rop,
|
ropFact: s.fact?.rop,
|
||||||
routeSpeedFact : s.fact?.routeSpeed,
|
routeSpeedFact: s.fact?.routeSpeed,
|
||||||
bhaUpSpeedFact : s.fact?.bhaUpSpeed,
|
bhaUpSpeedFact: s.fact?.bhaUpSpeed,
|
||||||
bhaDownSpeedFact : s.fact?.bhaDownSpeed,
|
bhaDownSpeedFact: s.fact?.bhaDownSpeed,
|
||||||
casingDownSpeedFact : s.fact?.casingDownSpeed,
|
casingDownSpeedFact: s.fact?.casingDownSpeed,
|
||||||
}))
|
}))
|
||||||
.sort((a,b) => a.wellDepthPlan - b.wellDepthPlan)
|
.sort((a,b) => a.wellDepthPlan - b.wellDepthPlan)
|
||||||
setSections(sections)
|
setSections(sections)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setShowLoader
|
setShowLoader
|
||||||
),[idWell])
|
), [idWell])
|
||||||
|
|
||||||
return <LoaderPortal show={showLoader}>
|
return (
|
||||||
<Table
|
<LoaderPortal show={showLoader}>
|
||||||
bordered
|
<Table
|
||||||
size='small'
|
bordered
|
||||||
columns={columns}
|
size={'small'}
|
||||||
dataSource={sections}/>
|
columns={columns}
|
||||||
</LoaderPortal>
|
dataSource={sections}
|
||||||
}
|
/>
|
||||||
|
</LoaderPortal>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user