WellOperationStatService переименован

This commit is contained in:
goodmice 2021-11-29 15:15:58 +05:00
parent 5ad3bd5e07
commit 43a01bd57f
6 changed files with 74 additions and 73 deletions

View File

@ -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()

View File

@ -1,17 +1,16 @@
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
@ -34,15 +33,15 @@ export const getOperations = async (idWell) => {
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]
}) })
}) })

View File

@ -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,

View File

@ -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,

View File

@ -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,22 +98,22 @@ 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`}>

View File

@ -2,24 +2,24 @@ 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) => {
@ -36,7 +36,7 @@ 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
@ -66,11 +66,14 @@ export const WellSectionsStat = ({idWell}) => {
setShowLoader setShowLoader
), [idWell]) ), [idWell])
return <LoaderPortal show={showLoader}> return (
<LoaderPortal show={showLoader}>
<Table <Table
bordered bordered
size='small' size={'small'}
columns={columns} columns={columns}
dataSource={sections}/> dataSource={sections}
/>
</LoaderPortal> </LoaderPortal>
)
} }