forked from ddrilling/asb_cloud_front
CF2-55: Moved reusing code to table config
This commit is contained in:
parent
81fcd3c0e5
commit
36bd376b7a
@ -66,6 +66,100 @@ export const makeColumnsPlanFact = (title:string, key:string|string[], columsOth
|
||||
}
|
||||
}
|
||||
|
||||
const maxPrefix = "isMax"
|
||||
const minPrefix = "isMin"
|
||||
|
||||
export const makeFilterMinMaxFunction = (key: string | number) => (filterValue: string | number,
|
||||
dataItem: any) =>
|
||||
filterValue === "max"
|
||||
? dataItem[maxPrefix + key]
|
||||
: filterValue === "min"
|
||||
? dataItem[minPrefix + key]
|
||||
: false
|
||||
|
||||
export const makeFilterTextMatch = (key: string | number) => (filterValue: string | number, dataItem: any) =>
|
||||
dataItem[key] === filterValue
|
||||
|
||||
export const makeNumericSorter = (key: any) => (a: any, b: any) => a[key] - b[key]
|
||||
|
||||
export const makeStringSorter = (key: any) => (a: any, b: any) =>
|
||||
{
|
||||
for (let i = 0; i < a.length; i++) {
|
||||
if (isNaN(b.charCodeAt(i)) || (a.charCodeAt(i) > b.charCodeAt(i)))
|
||||
return 1
|
||||
|
||||
if (a.charCodeAt(i) > b.charCodeAt(i))
|
||||
return -1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
export const makeGroupColumn = (title: any, children: any) => ({
|
||||
title: title,
|
||||
children: children,
|
||||
})
|
||||
|
||||
export const makeTextColumn = (title: any, dataIndex: any, filters: any, sorter: any, render: any, other: any) => ({
|
||||
title: title,
|
||||
dataIndex: dataIndex,
|
||||
key: dataIndex,
|
||||
filters: filters,
|
||||
onFilter: filters ? makeFilterTextMatch(dataIndex) : null,
|
||||
sorter: sorter ? makeStringSorter(dataIndex) : null,
|
||||
render: render,
|
||||
...other
|
||||
})
|
||||
|
||||
export const makeNumericColumn = (title: any, dataIndex: any, filters: any, width: string) => ({
|
||||
title: title,
|
||||
dataIndex: dataIndex,
|
||||
key: dataIndex,
|
||||
filters: filters,
|
||||
onFilter: makeFilterMinMaxFunction(dataIndex),
|
||||
sorter: makeNumericSorter(dataIndex),
|
||||
width: width
|
||||
})
|
||||
|
||||
export const makeNumericColumnPlanFact = (title: any, dataIndex: any, filters: any) =>
|
||||
makeGroupColumn( title, [
|
||||
makeNumericColumn('п', dataIndex + 'Plan', filters, ''),
|
||||
makeNumericColumn('ф', dataIndex + 'Fact', filters, ''),
|
||||
])
|
||||
|
||||
export const calcAndUpdateStats = (data: any, keys: any) => {
|
||||
let mins: any = {}
|
||||
let maxs: any = {}
|
||||
|
||||
keys.forEach((key: any) => {
|
||||
maxs[key] = Number.MIN_VALUE
|
||||
mins[key] = Number.MAX_VALUE
|
||||
})
|
||||
|
||||
data.forEach((item: any) => {
|
||||
keys.forEach((key: any) => {
|
||||
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: any) => {
|
||||
data[i][maxPrefix + key] = data[i][key] === maxs[key]
|
||||
data[i][minPrefix + key] = data[i][key] === mins[key]
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export const calcAndUpdateStatsBySections = (data: any, keys: any) => {
|
||||
const sectionTypes = new Set()
|
||||
data.forEach((item: any) => sectionTypes.add(item.sectionType))
|
||||
sectionTypes.forEach(sectionType => {
|
||||
const filteredBySectionData = data.filter((item: any) => item.sectionType === sectionType)
|
||||
calcAndUpdateStats(filteredBySectionData, keys)
|
||||
})
|
||||
}
|
||||
|
||||
type PaginationContainer = {
|
||||
skip?: number;
|
||||
take?: number;
|
||||
|
@ -1,9 +1,8 @@
|
||||
import { Table, Tag, Button, Badge, Divider, Modal} from "antd"
|
||||
import { LineChartOutlined, ProfileOutlined } from '@ant-design/icons'
|
||||
import { useState } from "react"
|
||||
import { makeTextColumn, makeGroupColumn, makeNumericColumn, makeNumericColumnPlanFact, calcAndUpdateStatsBySections } from '../components/Table/index'
|
||||
|
||||
const isMaxPrefix = "isMax"
|
||||
const isMinPrefix = "isMin"
|
||||
|
||||
const filtersMinMax = [
|
||||
{
|
||||
@ -35,61 +34,6 @@ const filtersSectionsType = [
|
||||
},
|
||||
]
|
||||
|
||||
const makeFilterMinMaxFunction = (key) => (filterValue, dataItem) =>
|
||||
filterValue === "max"
|
||||
? dataItem[isMaxPrefix + key]
|
||||
: filterValue === "min"
|
||||
? dataItem[isMinPrefix + key]
|
||||
: false
|
||||
|
||||
const makeFilterTextMatch = (key) => (filterValue, dataItem) =>
|
||||
dataItem[key] === filterValue
|
||||
|
||||
const makeNumericSorter = (key) => (a, b) => a[key] - b[key]
|
||||
|
||||
const makeStringSorter = (key) => (a, b) =>
|
||||
{
|
||||
for (let i = 0; i < a.length; i++) {
|
||||
if (isNaN(b.charCodeAt(i)) || (a.charCodeAt(i) > b.charCodeAt(i)))
|
||||
return 1
|
||||
|
||||
if (a.charCodeAt(i) > b.charCodeAt(i))
|
||||
return -1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
const makeGroupColumn = (title, children) => ({
|
||||
title: title,
|
||||
children: children,
|
||||
})
|
||||
|
||||
const makeTextColumn = (title, dataIndex, filters, sorter, render, other) => ({
|
||||
title: title,
|
||||
dataIndex: dataIndex,
|
||||
key: dataIndex,
|
||||
filters: filters,
|
||||
onFilter: filters ? makeFilterTextMatch(dataIndex) : null,
|
||||
sorter: sorter ? makeStringSorter(dataIndex) : null,
|
||||
render: render,
|
||||
...other
|
||||
})
|
||||
|
||||
const makeNumericColumn = (title, dataIndex, filters) => ({
|
||||
title: title,
|
||||
dataIndex: dataIndex,
|
||||
key: dataIndex,
|
||||
filters: filters,
|
||||
onFilter: makeFilterMinMaxFunction(dataIndex),
|
||||
sorter: makeNumericSorter(dataIndex)
|
||||
})
|
||||
|
||||
const makeNumericColumnPlanFact = (title, dataIndex, filters) =>
|
||||
makeGroupColumn( title, [
|
||||
makeNumericColumn('п', dataIndex + 'Plan', filters),
|
||||
makeNumericColumn('ф', dataIndex + 'Fact', filters),
|
||||
])
|
||||
|
||||
const ModalWindowButton = ({buttonIcon, buttonText, modalTitle, modalContent}) =>{
|
||||
const [isModalVisible, setIsModalVisible] = useState(false)
|
||||
|
||||
@ -129,7 +73,7 @@ const columns = [
|
||||
makeNumericColumnPlanFact('Подъем КНБК', 'sectionBhaUpSpeed', filtersMinMax),//Скорость подъема КНБК
|
||||
makeNumericColumnPlanFact('Скорость спуска ОК', 'sectionCasingDownSpeed', filtersMinMax),
|
||||
]),
|
||||
makeNumericColumn('НПВ, сут', 'notProductiveTime', filtersMinMax),
|
||||
makeNumericColumn('НПВ, сут', 'notProductiveTime', filtersMinMax, '80px'),
|
||||
{
|
||||
title: "TVD",
|
||||
render: (_, record) => <ModalWindowButton
|
||||
@ -160,51 +104,17 @@ const contractors = [
|
||||
]
|
||||
|
||||
const wellsStat = [
|
||||
{ key:1, caption :'42669', sectionType :'Направление', sectionWellDepthPlan :80.0, sectionWellDepthFact :79.0, sectionBuildDaysPlan :19.0, sectionBuildDaysFact :10.3, sectionRateOfPenetrationPlan :60.0, sectionRateOfPenetrationFact :158.0, rateOfPenetrationPlan :60.0, rateOfPenetrationFact :63.7, sectionRouteSpeedPlan :4.2, sectionRouteSpeedFact :7.7, routeSpeedPlan :9.7, routeSpeedFact :9.2, sectionBhaDownSpeedPlan :1.0, sectionBhaDownSpeedFact :0.3, sectionBhaUpSpeedPlan :1.0, sectionBhaUpSpeedFact :0.3, sectionCasingDownSpeedPlan :2.0, sectionCasingDownSpeedFact :1.0, companies :contractors },
|
||||
{ key:2, caption :'42669', sectionType :'Кондуктор', sectionWellDepthPlan :1280.0, sectionWellDepthFact :1284.0, sectionBuildDaysPlan :90.0, sectionBuildDaysFact :138.3, sectionRateOfPenetrationPlan :60.0, sectionRateOfPenetrationFact :85.5, rateOfPenetrationPlan :60.0, rateOfPenetrationFact :63.7, sectionRouteSpeedPlan :14.2, sectionRouteSpeedFact :9.3, routeSpeedPlan :9.7, routeSpeedFact :9.2, sectionBhaDownSpeedPlan :12.5, sectionBhaDownSpeedFact :5.8, sectionBhaUpSpeedPlan :11.0, sectionBhaUpSpeedFact :10.5, sectionCasingDownSpeedPlan :10.0, sectionCasingDownSpeedFact :14.0, companies :contractors },
|
||||
{ key:3, caption :'42669', sectionType :'Транспорт. Ствол', sectionWellDepthPlan :3615.9, sectionWellDepthFact :3616.0, sectionBuildDaysPlan :406.1, sectionBuildDaysFact :391.0, sectionRateOfPenetrationPlan :60.0, sectionRateOfPenetrationFact :57.7, rateOfPenetrationPlan :60.0, rateOfPenetrationFact :63.7, sectionRouteSpeedPlan :8.9, sectionRouteSpeedFact :9.2, routeSpeedPlan :9.7, routeSpeedFact :9.2, sectionBhaDownSpeedPlan :50.0, sectionBhaDownSpeedFact :40.5, sectionBhaUpSpeedPlan :52.0, sectionBhaUpSpeedFact :57.2, sectionCasingDownSpeedPlan :14.0, sectionCasingDownSpeedFact :16.3, companies :contractors },
|
||||
{ key:4, caption :'16311', sectionType :'Направление', sectionWellDepthPlan :80.0, sectionWellDepthFact :81.0, sectionBuildDaysPlan :10.8, sectionBuildDaysFact :11.0, sectionRateOfPenetrationPlan :60.0, sectionRateOfPenetrationFact :81.0, rateOfPenetrationPlan :60.0, rateOfPenetrationFact :63.7, sectionRouteSpeedPlan :7.4, sectionRouteSpeedFact :7.4, routeSpeedPlan :9.7, routeSpeedFact :9.2, sectionBhaDownSpeedPlan :1.0, sectionBhaDownSpeedFact :0.5, sectionBhaUpSpeedPlan :1.0, sectionBhaUpSpeedFact :0.5, sectionCasingDownSpeedPlan :1.0, sectionCasingDownSpeedFact :2.3, companies :contractors },
|
||||
{ key:5, caption :'16311', sectionType :'Кондуктор', sectionWellDepthPlan :1411.0, sectionWellDepthFact :1412.0, sectionBuildDaysPlan :107.8, sectionBuildDaysFact :99.0, sectionRateOfPenetrationPlan :60.0, sectionRateOfPenetrationFact :96.4, rateOfPenetrationPlan :60.0, rateOfPenetrationFact :63.7, sectionRouteSpeedPlan :13.1, sectionRouteSpeedFact :14.3, routeSpeedPlan :9.7, routeSpeedFact :9.2, sectionBhaDownSpeedPlan :12.5, sectionBhaDownSpeedFact :0.3, sectionBhaUpSpeedPlan :11.0, sectionBhaUpSpeedFact :8.8, sectionCasingDownSpeedPlan :9.0, sectionCasingDownSpeedFact :12.8, companies :contractors },
|
||||
{ key:6, caption :'16311', sectionType :'Транспорт. Ствол', sectionWellDepthPlan :3181.0, sectionWellDepthFact :3181.0, sectionBuildDaysPlan :171.6, sectionBuildDaysFact :171.0, sectionRateOfPenetrationPlan :35.0, sectionRateOfPenetrationFact :80.9, rateOfPenetrationPlan :60.0, rateOfPenetrationFact :63.7, sectionRouteSpeedPlan :18.5, sectionRouteSpeedFact :18.6, routeSpeedPlan :9.7, routeSpeedFact :9.2, sectionBhaDownSpeedPlan :14.0, sectionBhaDownSpeedFact :4.8, sectionBhaUpSpeedPlan :23.0, sectionBhaUpSpeedFact :14.8, sectionCasingDownSpeedPlan :15.0, sectionCasingDownSpeedFact :16.5, companies :contractors },
|
||||
{ key:7, caption :'16311', sectionType :'Хвостовик', sectionWellDepthPlan :4181.0, sectionWellDepthFact :4187.0, sectionBuildDaysPlan :271.9, sectionBuildDaysFact :220.0, sectionRateOfPenetrationPlan :20.0, sectionRateOfPenetrationFact :32.9, rateOfPenetrationPlan :60.0, rateOfPenetrationFact :63.7, sectionRouteSpeedPlan :15.4, sectionRouteSpeedFact :19.0, routeSpeedPlan :9.7, routeSpeedFact :9.2, sectionBhaDownSpeedPlan :61.5, sectionBhaDownSpeedFact :34.0, sectionBhaUpSpeedPlan :40.0, sectionBhaUpSpeedFact :36.5, sectionCasingDownSpeedPlan :24.5, sectionCasingDownSpeedFact :9.0, companies :contractors },
|
||||
{ key:8, caption :'16315', sectionType :'Направление', sectionWellDepthPlan :80.0, sectionWellDepthFact :80.0, sectionBuildDaysPlan :21.1, sectionBuildDaysFact :23.0, sectionRateOfPenetrationPlan :60.0, sectionRateOfPenetrationFact :53.3, rateOfPenetrationPlan :27.2, rateOfPenetrationFact :30.1, sectionRouteSpeedPlan :3.8, sectionRouteSpeedFact :3.5, routeSpeedPlan :14.4, routeSpeedFact :7.5, sectionBhaDownSpeedPlan :1.0, sectionBhaDownSpeedFact :0.5, sectionBhaUpSpeedPlan :1.0, sectionBhaUpSpeedFact :1.0, sectionCasingDownSpeedPlan :2.0, sectionCasingDownSpeedFact :2.0, companies :contractors },
|
||||
{ key:9, caption :'16315', sectionType :'Кондуктор', sectionWellDepthPlan :1500.0, sectionWellDepthFact :1505.0, sectionBuildDaysPlan :130.3, sectionBuildDaysFact :150.5, sectionRateOfPenetrationPlan :60.0, sectionRateOfPenetrationFact :58.2, rateOfPenetrationPlan :27.2, rateOfPenetrationFact :30.1, sectionRouteSpeedPlan :11.5, sectionRouteSpeedFact :10.0, routeSpeedPlan :14.4, routeSpeedFact :7.5, sectionBhaDownSpeedPlan :8.3, sectionBhaDownSpeedFact :0.5, sectionBhaUpSpeedPlan :11.0, sectionBhaUpSpeedFact :6.5, sectionCasingDownSpeedPlan :10.0, sectionCasingDownSpeedFact :11.0, companies :contractors }
|
||||
{ key:1, caption :'42669', sectionType :'Направление', sectionWellDepthPlan :80.0, sectionWellDepthFact :79.0, sectionBuildDaysPlan :19.0, sectionBuildDaysFact :10.3, sectionRateOfPenetrationPlan :60.0, sectionRateOfPenetrationFact :158.0, rateOfPenetrationPlan :60.0, rateOfPenetrationFact :63.7, sectionRouteSpeedPlan :4.2, sectionRouteSpeedFact :7.7, routeSpeedPlan :9.7, routeSpeedFact :9.2, sectionBhaDownSpeedPlan :1.0, sectionBhaDownSpeedFact :0.3, sectionBhaUpSpeedPlan :1.0, sectionBhaUpSpeedFact :0.3, sectionCasingDownSpeedPlan :2.0, sectionCasingDownSpeedFact :1.0, notProductiveTime: 10, companies :contractors },
|
||||
{ key:2, caption :'42669', sectionType :'Кондуктор', sectionWellDepthPlan :1280.0, sectionWellDepthFact :1284.0, sectionBuildDaysPlan :90.0, sectionBuildDaysFact :138.3, sectionRateOfPenetrationPlan :60.0, sectionRateOfPenetrationFact :85.5, rateOfPenetrationPlan :60.0, rateOfPenetrationFact :63.7, sectionRouteSpeedPlan :14.2, sectionRouteSpeedFact :9.3, routeSpeedPlan :9.7, routeSpeedFact :9.2, sectionBhaDownSpeedPlan :12.5, sectionBhaDownSpeedFact :5.8, sectionBhaUpSpeedPlan :11.0, sectionBhaUpSpeedFact :10.5, sectionCasingDownSpeedPlan :10.0, sectionCasingDownSpeedFact :14.0, notProductiveTime: 11, companies :contractors },
|
||||
{ key:3, caption :'42669', sectionType :'Транспорт. Ствол', sectionWellDepthPlan :3615.9, sectionWellDepthFact :3616.0, sectionBuildDaysPlan :406.1, sectionBuildDaysFact :391.0, sectionRateOfPenetrationPlan :60.0, sectionRateOfPenetrationFact :57.7, rateOfPenetrationPlan :60.0, rateOfPenetrationFact :63.7, sectionRouteSpeedPlan :8.9, sectionRouteSpeedFact :9.2, routeSpeedPlan :9.7, routeSpeedFact :9.2, sectionBhaDownSpeedPlan :50.0, sectionBhaDownSpeedFact :40.5, sectionBhaUpSpeedPlan :52.0, sectionBhaUpSpeedFact :57.2, sectionCasingDownSpeedPlan :14.0, sectionCasingDownSpeedFact :16.3, notProductiveTime: 12, companies :contractors },
|
||||
{ key:4, caption :'16311', sectionType :'Направление', sectionWellDepthPlan :80.0, sectionWellDepthFact :81.0, sectionBuildDaysPlan :10.8, sectionBuildDaysFact :11.0, sectionRateOfPenetrationPlan :60.0, sectionRateOfPenetrationFact :81.0, rateOfPenetrationPlan :60.0, rateOfPenetrationFact :63.7, sectionRouteSpeedPlan :7.4, sectionRouteSpeedFact :7.4, routeSpeedPlan :9.7, routeSpeedFact :9.2, sectionBhaDownSpeedPlan :1.0, sectionBhaDownSpeedFact :0.5, sectionBhaUpSpeedPlan :1.0, sectionBhaUpSpeedFact :0.5, sectionCasingDownSpeedPlan :1.0, sectionCasingDownSpeedFact :2.3, notProductiveTime: 13, companies :contractors },
|
||||
{ key:5, caption :'16311', sectionType :'Кондуктор', sectionWellDepthPlan :1411.0, sectionWellDepthFact :1412.0, sectionBuildDaysPlan :107.8, sectionBuildDaysFact :99.0, sectionRateOfPenetrationPlan :60.0, sectionRateOfPenetrationFact :96.4, rateOfPenetrationPlan :60.0, rateOfPenetrationFact :63.7, sectionRouteSpeedPlan :13.1, sectionRouteSpeedFact :14.3, routeSpeedPlan :9.7, routeSpeedFact :9.2, sectionBhaDownSpeedPlan :12.5, sectionBhaDownSpeedFact :0.3, sectionBhaUpSpeedPlan :11.0, sectionBhaUpSpeedFact :8.8, sectionCasingDownSpeedPlan :9.0, sectionCasingDownSpeedFact :12.8, notProductiveTime: 14, companies :contractors },
|
||||
{ key:6, caption :'16311', sectionType :'Транспорт. Ствол', sectionWellDepthPlan :3181.0, sectionWellDepthFact :3181.0, sectionBuildDaysPlan :171.6, sectionBuildDaysFact :171.0, sectionRateOfPenetrationPlan :35.0, sectionRateOfPenetrationFact :80.9, rateOfPenetrationPlan :60.0, rateOfPenetrationFact :63.7, sectionRouteSpeedPlan :18.5, sectionRouteSpeedFact :18.6, routeSpeedPlan :9.7, routeSpeedFact :9.2, sectionBhaDownSpeedPlan :14.0, sectionBhaDownSpeedFact :4.8, sectionBhaUpSpeedPlan :23.0, sectionBhaUpSpeedFact :14.8, sectionCasingDownSpeedPlan :15.0, sectionCasingDownSpeedFact :16.5, notProductiveTime: 15, companies :contractors },
|
||||
{ key:7, caption :'16311', sectionType :'Хвостовик', sectionWellDepthPlan :4181.0, sectionWellDepthFact :4187.0, sectionBuildDaysPlan :271.9, sectionBuildDaysFact :220.0, sectionRateOfPenetrationPlan :20.0, sectionRateOfPenetrationFact :32.9, rateOfPenetrationPlan :60.0, rateOfPenetrationFact :63.7, sectionRouteSpeedPlan :15.4, sectionRouteSpeedFact :19.0, routeSpeedPlan :9.7, routeSpeedFact :9.2, sectionBhaDownSpeedPlan :61.5, sectionBhaDownSpeedFact :34.0, sectionBhaUpSpeedPlan :40.0, sectionBhaUpSpeedFact :36.5, sectionCasingDownSpeedPlan :24.5, sectionCasingDownSpeedFact :9.0, notProductiveTime: 16, companies :contractors },
|
||||
{ key:8, caption :'16315', sectionType :'Направление', sectionWellDepthPlan :80.0, sectionWellDepthFact :80.0, sectionBuildDaysPlan :21.1, sectionBuildDaysFact :23.0, sectionRateOfPenetrationPlan :60.0, sectionRateOfPenetrationFact :53.3, rateOfPenetrationPlan :27.2, rateOfPenetrationFact :30.1, sectionRouteSpeedPlan :3.8, sectionRouteSpeedFact :3.5, routeSpeedPlan :14.4, routeSpeedFact :7.5, sectionBhaDownSpeedPlan :1.0, sectionBhaDownSpeedFact :0.5, sectionBhaUpSpeedPlan :1.0, sectionBhaUpSpeedFact :1.0, sectionCasingDownSpeedPlan :2.0, sectionCasingDownSpeedFact :2.0, notProductiveTime: 17, companies :contractors },
|
||||
{ key:9, caption :'16315', sectionType :'Кондуктор', sectionWellDepthPlan :1500.0, sectionWellDepthFact :1505.0, sectionBuildDaysPlan :130.3, sectionBuildDaysFact :150.5, sectionRateOfPenetrationPlan :60.0, sectionRateOfPenetrationFact :58.2, rateOfPenetrationPlan :27.2, rateOfPenetrationFact :30.1, sectionRouteSpeedPlan :11.5, sectionRouteSpeedFact :10.0, routeSpeedPlan :14.4, routeSpeedFact :7.5, sectionBhaDownSpeedPlan :8.3, sectionBhaDownSpeedFact :0.5, sectionBhaUpSpeedPlan :11.0, sectionBhaUpSpeedFact :6.5, sectionCasingDownSpeedPlan :10.0, sectionCasingDownSpeedFact :11.0, notProductiveTime: 18, companies :contractors }
|
||||
]
|
||||
|
||||
const calcAndUpdateStats = (data, keys) => {
|
||||
let mins = {}
|
||||
let 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][isMaxPrefix + key] = data[i][key] === maxs[key]
|
||||
data[i][isMinPrefix + key] = data[i][key] === mins[key]
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
})
|
||||
}
|
||||
|
||||
calcAndUpdateStatsBySections(wellsStat, [
|
||||
"sectionWellDepthPlan",
|
||||
"sectionWellDepthFact",
|
||||
@ -220,6 +130,7 @@ calcAndUpdateStatsBySections(wellsStat, [
|
||||
"sectionBhaUpSpeedFact",
|
||||
"sectionCasingDownSpeedPlan",
|
||||
"sectionCasingDownSpeedFact",
|
||||
"notProductiveTime"
|
||||
])
|
||||
|
||||
export default function ClusterStat() {
|
||||
@ -236,7 +147,6 @@ export default function ClusterStat() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<h2 className={'mt-20px mb-20px'}>Статистика по секциям</h2>
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={wellsStat}
|
||||
@ -245,6 +155,7 @@ export default function ClusterStat() {
|
||||
scroll={{ x: true, y: 620}}
|
||||
rowSelection={rowSelection}
|
||||
pagination={false}
|
||||
className={'mt-20px'}
|
||||
/>
|
||||
<Divider/>
|
||||
<Badge.Ribbon text="комбинированная скважина" color="gray">
|
||||
|
@ -5,9 +5,8 @@ import { useState, useEffect } from "react";
|
||||
import { ClusterService } from '../services/api'
|
||||
import { notify } from "../components/factory"
|
||||
import { Table, Tag, Button } from 'antd';
|
||||
import { makeTextColumn, makeGroupColumn, makeNumericColumn, makeNumericColumnPlanFact, calcAndUpdateStatsBySections } from '../components/Table/index'
|
||||
|
||||
const isMaxPrefix = "isMax"
|
||||
const isMinPrefix = "isMin"
|
||||
|
||||
const filtersMinMax = [
|
||||
{
|
||||
@ -23,72 +22,48 @@ const filtersMinMax = [
|
||||
const filtersWellsType = [
|
||||
{
|
||||
text: "Наклонно-направленная",
|
||||
value: "sidelong",
|
||||
value: "Наклонно-направленная",
|
||||
},
|
||||
{
|
||||
text: "Горизонтальная",
|
||||
value: "horizontal",
|
||||
value: "Горизонтальная",
|
||||
}
|
||||
]
|
||||
|
||||
const makeFilterMinMaxFunction = (key) => (filterValue, dataItem) =>
|
||||
filterValue === "max"
|
||||
? dataItem[isMaxPrefix + key]
|
||||
: filterValue === "min"
|
||||
? dataItem[isMinPrefix + key]
|
||||
: false
|
||||
const contractors = [
|
||||
{ type: "Буровой подрядчик", caption: 'ООО "НГ-Бурение"' },
|
||||
// { type: "ННБ", caption: 'ООО НПП "Буринтех"' },
|
||||
// { type: "Растворный сревис", caption: 'ООО НПП "Буринтех"' },
|
||||
// { type: "Цементирование", caption: "Норд-Сервис" },
|
||||
]
|
||||
|
||||
const makeFilterTextMatch = (key) => (filterValue, dataItem) =>
|
||||
dataItem[key] === filterValue
|
||||
const wellsStatDefault = [
|
||||
{ key:1, caption :'42669', wellType :'Наклонно-направленная', factStart: 5, factEnd: 12, periodPlan :80.0, periodFact :79.0, rateOfPenetrationPlan :19.0, rateOfPenetrationFact :10.3, routeSpeedPlan :60.0, routeSpeedFact :158.0, notProductiveTime: 10, companies :contractors },
|
||||
{ key:2, caption :'42669', wellType :'Горизонтальная', factStart: 7, factEnd: 11, periodPlan :1280.0, periodFact :1284.0, rateOfPenetrationPlan :90.0, rateOfPenetrationFact :138.3, routeSpeedPlan :60.0, routeSpeedFact :85.5, notProductiveTime: 11, companies :contractors },
|
||||
{ key:3, caption :'42669', wellType :'Наклонно-направленная', factStart: 8, factEnd: 13, periodPlan :3615.9, periodFact :3616.0, rateOfPenetrationPlan :406.1, rateOfPenetrationFact :391.0, routeSpeedPlan :60.0, routeSpeedFact :57.7, notProductiveTime: 12, companies :contractors },
|
||||
{ key:4, caption :'16311', wellType :'Наклонно-направленная', factStart: 9, factEnd: 17, periodPlan :80.0, periodFact :81.0, rateOfPenetrationPlan :10.8, rateOfPenetrationFact :11.0, routeSpeedPlan :60.0, routeSpeedFact :81.0, notProductiveTime: 13, companies :contractors },
|
||||
{ key:5, caption :'16314', wellType :'Горизонтальная', factStart: 15, factEnd: 15, periodPlan :1411.0, periodFact :1412.0, rateOfPenetrationPlan :107.8, rateOfPenetrationFact :99.0, routeSpeedPlan :60.0, routeSpeedFact :96.4, notProductiveTime: 14, companies :contractors },
|
||||
{ key:6, caption :'16311', wellType :'Наклонно-направленная', factStart: 14, factEnd: 20, periodPlan :3181.0, periodFact :3181.0, rateOfPenetrationPlan :171.6, rateOfPenetrationFact :171.0, routeSpeedPlan :35.0, routeSpeedFact :80.9, notProductiveTime: 15, companies :contractors },
|
||||
{ key:7, caption :'16311', wellType :'Горизонтальная', factStart: 12, factEnd: 21, periodPlan :4181.0, periodFact :4187.0, rateOfPenetrationPlan :271.9, rateOfPenetrationFact :220.0, routeSpeedPlan :20.0, routeSpeedFact :32.9, notProductiveTime: 16, companies :contractors },
|
||||
{ key:8, caption :'16315', wellType :'Наклонно-направленная', factStart: 13, factEnd: 22, periodPlan :80.0, periodFact :80.0, rateOfPenetrationPlan :21.1, rateOfPenetrationFact :23.0, routeSpeedPlan :60.0, routeSpeedFact :53.3, notProductiveTime: 17, companies :contractors },
|
||||
{ key:9, caption :'16315', wellType :'Горизонтальная', factStart: 11, factEnd: 23, periodPlan :1500.0, periodFact :1505.0, rateOfPenetrationPlan :130.3, rateOfPenetrationFact :150.5, routeSpeedPlan :60.0, routeSpeedFact :58.2, notProductiveTime: 18, companies :contractors }
|
||||
]
|
||||
|
||||
const makeNumericSorter = (key) => (a, b) => a[key] - b[key]
|
||||
|
||||
const makeStringSorter = (key) => (a, b) =>
|
||||
{
|
||||
for (let i = 0; i < a.length; i++) {
|
||||
if (isNaN(b.charCodeAt(i)) || (a.charCodeAt(i) > b.charCodeAt(i)))
|
||||
return 1
|
||||
|
||||
if (a.charCodeAt(i) > b.charCodeAt(i))
|
||||
return -1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
const makeGroupColumn = (title, children) => ({
|
||||
title: title,
|
||||
children: children,
|
||||
})
|
||||
|
||||
const makeTextColumn = (title, dataIndex, filters, sorter, render, other) => ({
|
||||
title: title,
|
||||
dataIndex: dataIndex,
|
||||
key: dataIndex,
|
||||
filters: filters,
|
||||
onFilter: filters ? makeFilterTextMatch(dataIndex) : null,
|
||||
sorter: sorter ? makeStringSorter(dataIndex) : null,
|
||||
render: render,
|
||||
...other
|
||||
})
|
||||
|
||||
const makeNumericColumn = (title, dataIndex, filters) => ({
|
||||
title: title,
|
||||
dataIndex: dataIndex,
|
||||
key: dataIndex,
|
||||
filters: filters,
|
||||
onFilter: makeFilterMinMaxFunction(dataIndex),
|
||||
sorter: makeNumericSorter(dataIndex)
|
||||
})
|
||||
|
||||
const makeNumericColumnPlanFact = (title, dataIndex, filters) =>
|
||||
makeGroupColumn( title, [
|
||||
makeNumericColumn('п', dataIndex + 'Plan', filters),
|
||||
makeNumericColumn('ф', dataIndex + 'Fact', filters),
|
||||
calcAndUpdateStatsBySections(wellsStatDefault, [
|
||||
"factStart",
|
||||
"factEnd",
|
||||
"periodPlan",
|
||||
"periodFact",
|
||||
"rateOfPenetrationPlan",
|
||||
"rateOfPenetrationFact",
|
||||
"routeSpeedPlan",
|
||||
"routeSpeedFact",
|
||||
"notProductiveTime"
|
||||
])
|
||||
|
||||
export default function Cluster() {
|
||||
let { id } = useParams()
|
||||
const [wellsStat, setWellsStat] = useState(null)
|
||||
const [wellsStat, setWellsStat] = useState(wellsStatDefault)
|
||||
const [showLoader, setShowLoader] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
@ -143,7 +118,6 @@ export default function Cluster() {
|
||||
|
||||
return (
|
||||
<LoaderPortal show={showLoader}>
|
||||
<h2 className={'mt-20px mb-20px'}>Статистика по скважинам</h2>
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={wellsStat}
|
||||
@ -151,6 +125,7 @@ export default function Cluster() {
|
||||
bordered
|
||||
pagination={false}
|
||||
rowKey={(record) => record.id}
|
||||
className={'mt-20px'}
|
||||
/>
|
||||
</LoaderPortal>)
|
||||
}
|
Loading…
Reference in New Issue
Block a user