Number.isFinite(number) ? number.toFixed(2) : '-'
-
-export const getOperations = async (idWell) => {
- const ops = await OperationStatService.getTvd(idWell)
-
- if (!ops) return []
-
- const convert = wellOperationDto => ({
- key: wellOperationDto?.id,
- depth: wellOperationDto?.depthStart,
- date: wellOperationDto?.dateStart,
- day: wellOperationDto?.day,
- })
-
- const planData = ops
- .map(item => convert(item.plan))
- .filter(el => el.key)
-
- const factData = ops
- .map(item => convert(item.fact))
- .filter(el => el.key)
-
- const predictData = ops
- .map(item => convert(item.predict))
- .filter(el => el.key)
-
- return { operations: ops, plan: planData, fact: factData, predict: predictData }
-}
-
-export const makeFilterMinMaxFunction = (key) => (filterValue,
- dataItem) =>
- filterValue === 'max'
- ? dataItem[maxPrefix + key]
- : filterValue === 'min'
- ? dataItem[minPrefix + key]
- : false
-
-export const calcAndUpdateStats = (data, keys) => {
- const mins = {}
- const 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)
- })
-}
diff --git a/src/pages/Measure/MeasureTable.jsx b/src/pages/Measure/MeasureTable.jsx
index 2cdf50a..af0be5d 100644
--- a/src/pages/Measure/MeasureTable.jsx
+++ b/src/pages/Measure/MeasureTable.jsx
@@ -138,20 +138,20 @@ export const MeasureTable = memo(({ idWell, group, updateMeasuresFunc, additiona
- {data.map((item, index) =>
+ {data.map((item, index) => (
setDisplayedValues(item)}
- dot={item?.id === displayedValues?.id &&
+ dot={item?.id === displayedValues?.id && (
- }
+ )}
>
- {formatDate(item.timestamp, true) ?? 'Нет данных'}
+ {formatDate(item.timestamp) ?? 'Нет данных'}
- )}
+ ))}
diff --git a/src/pages/Well.jsx b/src/pages/Well.jsx
index 1885889..c16b00c 100644
--- a/src/pages/Well.jsx
+++ b/src/pages/Well.jsx
@@ -6,7 +6,6 @@ import {
FilePdfOutlined,
DatabaseOutlined,
ExperimentOutlined,
- FundProjectionScreenOutlined,
} from '@ant-design/icons'
import { Layout, Menu } from 'antd'
import { Switch, useParams } from 'react-router-dom'
diff --git a/src/pages/WellOperations/Tvd.jsx b/src/pages/WellOperations/Tvd.jsx
index e58743c..0f6f5e4 100644
--- a/src/pages/WellOperations/Tvd.jsx
+++ b/src/pages/WellOperations/Tvd.jsx
@@ -16,8 +16,7 @@ import ChartDataLabels from 'chartjs-plugin-datalabels'
import LoaderPortal from '@components/LoaderPortal'
import { invokeWebApiWrapperAsync } from '@components/factory'
-
-import { getOperations } from '@pages/Cluster/functions'
+import { getOperations } from '@utils/functions'
Chart.register(TimeScale, LinearScale, LineController, LineElement, PointElement, Legend, ChartDataLabels, zoomPlugin)
diff --git a/src/pages/WellOperations/WellCompositeEditor/WellCompositeSections.jsx b/src/pages/WellOperations/WellCompositeEditor/WellCompositeSections.jsx
index cc08b2d..44927da 100644
--- a/src/pages/WellOperations/WellCompositeEditor/WellCompositeSections.jsx
+++ b/src/pages/WellOperations/WellCompositeEditor/WellCompositeSections.jsx
@@ -14,7 +14,7 @@ import {
calcAndUpdateStatsBySections,
makeFilterMinMaxFunction,
getOperations
-} from '@pages/Cluster/functions'
+} from '@utils/functions'
import WellOperationsTable from '@pages/Cluster/WellOperationsTable'
import { Tvd } from '../Tvd'
import { getColumns } from '../WellDrillParams'
diff --git a/src/utils/functions.tsx b/src/utils/functions.tsx
new file mode 100644
index 0000000..453eb07
--- /dev/null
+++ b/src/utils/functions.tsx
@@ -0,0 +1,86 @@
+import { OperationStatService, WellOperationDto, WellOperationDtoPlanFactPredictBase } from '@api'
+
+const maxPrefix = 'isMax'
+const minPrefix = 'isMin'
+
+export const getPrecision = (number: number) => Number.isFinite(number) ? number.toFixed(2) : '-'
+
+export type KeyType = number | string
+
+export type SaubData = {
+ key?: number
+ depth?: number
+ date?: string
+ day?: number
+}
+
+export const getOperations = async (idWell: number): Promise<{
+ operations?: WellOperationDtoPlanFactPredictBase[],
+ plan?: SaubData[]
+ fact?: SaubData[]
+ predict?: SaubData[]
+}> => {
+ const ops = await OperationStatService.getTvd(idWell)
+
+ if (!ops) return {}
+
+ const convert = (operation?: WellOperationDto): SaubData => ({
+ key: operation?.id,
+ depth: operation?.depthStart,
+ date: operation?.dateStart,
+ day: operation?.day,
+ })
+
+ const planData = ops
+ .map(item => convert(item.plan))
+ .filter(el => el.key)
+
+ const factData = ops
+ .map(item => convert(item.fact))
+ .filter(el => el.key)
+
+ const predictData = ops
+ .map(item => convert(item.predict))
+ .filter(el => el.key)
+
+ return { operations: ops, plan: planData, fact: factData, predict: predictData }
+}
+
+export const makeFilterMinMaxFunction = (key: KeyType) => (filterValue: string, dataItem: Record) => {
+ if (filterValue === 'max') return dataItem[maxPrefix + key]
+ if (filterValue === 'min') return dataItem[minPrefix + key]
+ return false
+}
+
+export const calcAndUpdateStats = (data: Record[], keys: KeyType[]) => {
+ const mins: Record = {}
+ const maxs: Record = {}
+
+ 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: { sectionType: any }[], keys: KeyType[]) => {
+ 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)
+ })
+}
diff --git a/src/utils/table.ts b/src/utils/table.ts
index 12ff435..dcf0e2d 100644
--- a/src/utils/table.ts
+++ b/src/utils/table.ts
@@ -1,5 +1,11 @@
export const makeTextOnFilter = (key: string) =>
- (value: string, record?: Record) => record?.[key]?.startsWith(value)
+ (value: string, record?: Record) => String(record?.[key]).startsWith(value)
+
+export const makeArrayOnFilter = (key: string) =>
+ (value: string, record?: Record) => (!value && (record?.[key]?.length ?? 0) <= 0) || record?.[key]?.includes(value)
+
+export const makeObjectOnFilter = (field: string, key: string) =>
+ (value: string, record?: Record>) => String(record?.[field]?.[key]).startsWith(value)
export const makeTextFilters = (array: Record[], keys: string[]) => {
const filters: string[][] = Array(keys.length)