Исправлены ошибки отображения и посчётов нпв

This commit is contained in:
goodmice 2022-04-28 16:59:14 +05:00
parent 6262507366
commit ec5b5e427b
3 changed files with 29 additions and 27 deletions

View File

@ -132,7 +132,7 @@ export const ClusterWells = memo(({ statsWells }) => {
makeNumericColumnPlanFact('Продолжительность, сут', 'period', filtersMinMax, makeFilterMinMaxFunction, numericRender),
makeNumericColumnPlanFact('МСП, м/ч', 'rateOfPenetration', filtersMinMax, makeFilterMinMaxFunction, numericRender),
makeNumericColumnPlanFact('Рейсовая скорость, м/ч', 'routeSpeed', filtersMinMax, makeFilterMinMaxFunction, numericRender),
makeNumericColumn('НПВ, ч', 'notProductiveTimeFact', filtersMinMax, makeFilterMinMaxFunction, (npt) => numericRender(npt * 24)),
makeNumericColumn('НПВ, ч', 'notProductiveTimeFact', filtersMinMax, makeFilterMinMaxFunction, numericRender),
makeColumn('TVD', 'tvd', { align: 'center', render: (_, value) => (
<Button onClick={() => { setSelectedWellId(value?.id); setIsTVDModalVisible(true) }} children={<LineChartOutlined />} />
) }),

View File

@ -1,4 +1,4 @@
import { memo, useCallback, useEffect, useState } from 'react'
import { memo, useCallback, useEffect, useMemo, useState } from 'react'
import { Grid, GridItem } from '@components/Grid'
import { makeDateSorter } from '@components/Table'
@ -31,17 +31,33 @@ const RemoveSimilar = (input, accessor) => {
const addPointData = (point) => ({ depth: point.wellDepth })
const ChartValues = memo(({ pv }) => pv?.map((v, idx) => {
const text = `${v.value?.toFixed(2) ?? '--'} ${v.unit}`
return (
<GridItem
key={idx}
row={idx + 1}
col={1}
className={'monitoring_value'}
style={{ color: v.color, padding: '0 4px' }}
data-before={text}
children={text}
/>
)
}))
export const MonitoringColumn = memo(({ lineGroup, data, flowChartData, interval, showBorder, style, headerHeight, pointCount = 2048, additionalLabels }) => {
const [dataStore, setDataStore] = useState([])
const [lineGroupWithoutShapes, setLineGroupWithoutShapes] = useState([])
const dataLast = data?.[data.length - 1]
const yStart = new Date((dataLast?.date ? +new Date(dataLast.date) : Date.now()) - interval * 0.97)
let pv = lineGroup.filter(line => line.showLabels).map(line => ({
const dataLast = useMemo(() => data?.[data.length - 1], [data])
const yStart = useMemo(() => new Date((dataLast?.date ? +new Date(dataLast.date) : Date.now()) - interval * 0.97), [dataLast, interval])
const pv = useMemo(() => lineGroup.filter(line => line.showLabels).map(line => ({
color: line.color,
label: line.label,
unit: line.units,
value: dataLast?.[line.xAccessorName]
}))
})), [lineGroup, dataLast])
const lineGroupWithoutShapes = useMemo(() => lineGroup.filter(cfg => !cfg.isShape), [lineGroup])
const postParsing = useCallback((data) => {
lineGroupWithoutShapes.forEach(lineCfg => {
@ -67,10 +83,6 @@ export const MonitoringColumn = memo(({ lineGroup, data, flowChartData, interval
})
}, [data, pointCount])
useEffect(() => {
setLineGroupWithoutShapes(lineGroup.filter(cfg => !cfg.isShape))
}, [lineGroup])
return (
<div style={style}>
<Grid style={{ height: headerHeight, boxShadow: showBorder ? 'inset 0px 0px 0px 3px black' : '', margin: 0 }}>
@ -80,20 +92,7 @@ export const MonitoringColumn = memo(({ lineGroup, data, flowChartData, interval
</Grid>
<div style={{ position: 'relative' }}>
<Grid className={'display_chart_values'}>
{pv?.map((v, idx) => {
const text = `${v.value?.toFixed(2) ?? '--'} ${v.unit}`
return (
<GridItem
key={idx}
row={idx + 1}
col={1}
className={'monitoring_value'}
style={{ color: v.color, padding: '0 4px' }}
data-before={text}
children={text}
/>
)
})}
<ChartValues pv={pv} />
{additionalLabels?.map((label, idx) => (
<GridItem
key={idx}

View File

@ -21,7 +21,10 @@ const printDate = (date) => formatDate(date) ?? '-'
export const AdditionalTables = memo(({ operations, xLabel, setIsLoading }) => {
const [additionalData, setAdditionalData] = useState({})
const nptSum = useMemo(() => operations.fact?.reduce((out, row) => out + (row?.durationHours ?? 0), 0), [operations.fact])
const nptSum = useMemo(() => operations.fact
?.filter((row) => row.isNPT)
.reduce((out, row) => out + (row?.durationHours ?? 0), 0)
, [operations.fact])
useEffect(() => invokeWebApiWrapperAsync(
async () => {
@ -51,7 +54,7 @@ export const AdditionalTables = memo(({ operations, xLabel, setIsLoading }) => {
<Descriptions bordered column={1} size={'small'} style={{ backgroundColor: 'white' }}>
<Item label={'Дата завершения'}>{printDate(additionalData.endDate)}</Item>
<Item label={'Отставание (сут)'}>{numericRender(additionalData.lag)}</Item>
<Item label={'Длительность НПВ (сут)'}>{numericRender(nptSum)}</Item>
<Item label={'Длительность НПВ (ч)'}>{numericRender(nptSum)}</Item>
</Descriptions>
</div>
<div className={'tvd-bl-table'} style={{ bottom: xLabel === 'day' ? '35px' : '85px' }}>