2021-05-27 13:46:46 +05:00
|
|
|
|
import {useState, useEffect} from 'react'
|
|
|
|
|
import {useParams} from 'react-router-dom'
|
2021-05-27 12:53:42 +05:00
|
|
|
|
import {Row, Col, Select, Table} from 'antd'
|
2021-05-27 13:46:46 +05:00
|
|
|
|
import {ChartTimeOnline} from '../components/charts/ChartTimeOnline'
|
2021-06-02 11:38:27 +05:00
|
|
|
|
import LoaderPortal from '../components/LoaderPortal'
|
2021-05-27 13:46:46 +05:00
|
|
|
|
import {ChartTimeOnlineFooter} from '../components/ChartTimeOnlineFooter'
|
|
|
|
|
import {CustomColumn} from '../components/CustomColumn'
|
|
|
|
|
import {UserOfWells} from '../components/UserOfWells'
|
|
|
|
|
import {ModeDisplay} from '../components/ModeDisplay'
|
|
|
|
|
import {Display} from '../components/Display'
|
2021-05-19 16:05:01 +05:00
|
|
|
|
import moment from 'moment'
|
2021-05-27 13:46:46 +05:00
|
|
|
|
import {Subscribe} from '../services/signalr'
|
|
|
|
|
import {DataService, MessageService} from '../services/api'
|
2021-05-27 12:53:42 +05:00
|
|
|
|
import '../styles/message.css'
|
2021-07-23 17:15:33 +05:00
|
|
|
|
import notify from "../components/notify"
|
2021-05-19 16:05:01 +05:00
|
|
|
|
|
2021-05-27 13:46:46 +05:00
|
|
|
|
const {Option} = Select
|
2021-05-19 16:05:01 +05:00
|
|
|
|
|
|
|
|
|
const dash = [7, 3]
|
2021-04-16 15:50:01 +05:00
|
|
|
|
|
|
|
|
|
const blockHeightGroup = {
|
2021-05-19 16:05:01 +05:00
|
|
|
|
label: "Высота блока",
|
2021-04-16 15:50:01 +05:00
|
|
|
|
yDisplay: false,
|
2021-05-27 16:59:05 +05:00
|
|
|
|
linePv: { label: "blockPosition", units: 'м', xAccessorName: "blockPosition", yAccessorName: "date", color: '#333' },
|
|
|
|
|
lineOther: { label: "wellDepth", units: 'м', xAccessorName: "wellDepth", yAccessorName: "date", color: '#333', showLine: false, xConstValue:30 },
|
2021-04-16 15:50:01 +05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const blockSpeedGroup = {
|
2021-05-19 16:05:01 +05:00
|
|
|
|
label: "Скорость блока",
|
2021-04-16 15:50:01 +05:00
|
|
|
|
yDisplay: false,
|
2021-05-27 13:46:46 +05:00
|
|
|
|
linePv: {label: "blockSpeed", units: 'м/ч', xAccessorName: "blockSpeed", yAccessorName: "date", color: '#0a0'},
|
|
|
|
|
lineSp: {label: "blockSpeedSp", units: 'м/ч', xAccessorName: "blockSpeedSp", yAccessorName: "date", color: '#0a0'},
|
2021-04-16 15:50:01 +05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const pressureGroup = {
|
2021-05-19 16:05:01 +05:00
|
|
|
|
label: "Давление",
|
|
|
|
|
yDisplay: false,
|
2021-05-27 13:46:46 +05:00
|
|
|
|
linePv: {label: "pressure", units: 'атм', xAccessorName: "pressure", yAccessorName: "date", color: '#c00'},
|
|
|
|
|
lineSp: {label: "pressureSp", units: 'атм', xAccessorName: "pressureSp", yAccessorName: "date", color: '#c00'},
|
|
|
|
|
lineIdle: {label: "pressureIdle", units: 'атм', xAccessorName: "pressureIdle", yAccessorName: "date", color: '#c00'},
|
2021-04-16 15:50:01 +05:00
|
|
|
|
linesOther: [
|
2021-05-27 13:46:46 +05:00
|
|
|
|
{
|
|
|
|
|
label: "мекс. перепад",
|
|
|
|
|
units: 'атм',
|
|
|
|
|
xAccessorName: "pressureDeltaLimitMax",
|
|
|
|
|
yAccessorName: "date",
|
|
|
|
|
color: '#c00'
|
|
|
|
|
},
|
2021-04-16 15:50:01 +05:00
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-19 16:05:01 +05:00
|
|
|
|
const axialLoadGroup = {
|
|
|
|
|
label: "Осевая нагрузка",
|
2021-04-16 15:50:01 +05:00
|
|
|
|
yDisplay: false,
|
2021-05-27 13:46:46 +05:00
|
|
|
|
linePv: {label: "axialLoad", units: 'т', xAccessorName: "axialLoad", yAccessorName: "date", color: '#00a'},
|
|
|
|
|
lineSp: {label: "axialLoadSp", units: 'т', xAccessorName: "axialLoadSp", yAccessorName: "date", color: '#00a', dash},
|
2021-04-16 15:50:01 +05:00
|
|
|
|
linesOther: [
|
2021-05-27 13:46:46 +05:00
|
|
|
|
{label: "axialLoadLimitMax", units: 'т', xAccessorName: "axialLoadLimitMax", yAccessorName: "date", color: '#00a'},
|
2021-04-16 15:50:01 +05:00
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const hookWeightGroup = {
|
2021-07-23 17:15:33 +05:00
|
|
|
|
label: "Вес на крюке",
|
2021-04-16 15:50:01 +05:00
|
|
|
|
yDisplay: false,
|
2021-05-27 13:46:46 +05:00
|
|
|
|
linePv: {label: "hookWeight", units: 'т', xAccessorName: "hookWeight", yAccessorName: "date", color: '#0aa'},
|
|
|
|
|
lineIdle: {
|
|
|
|
|
label: "hookWeightIdle",
|
|
|
|
|
units: 'т',
|
|
|
|
|
xAccessorName: "hookWeightIdle",
|
|
|
|
|
yAccessorName: "date",
|
|
|
|
|
color: '#0aa',
|
|
|
|
|
dash
|
|
|
|
|
},
|
2021-04-16 15:50:01 +05:00
|
|
|
|
linesOther: [
|
2021-05-27 13:46:46 +05:00
|
|
|
|
{
|
|
|
|
|
label: "hookWeightLimitMin",
|
|
|
|
|
units: 'т',
|
|
|
|
|
xAccessorName: "hookWeightLimitMin",
|
|
|
|
|
yAccessorName: "date",
|
|
|
|
|
color: '#0aa'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "hookWeightLimitMax",
|
|
|
|
|
units: 'т',
|
|
|
|
|
xAccessorName: "hookWeightLimitMax",
|
|
|
|
|
yAccessorName: "date",
|
|
|
|
|
color: '#0aa'
|
|
|
|
|
},
|
2021-04-16 15:50:01 +05:00
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const rotorTorqueGroup = {
|
2021-05-19 16:05:01 +05:00
|
|
|
|
label: "Момент на роторе",
|
2021-04-16 15:50:01 +05:00
|
|
|
|
yDisplay: false,
|
2021-05-27 13:46:46 +05:00
|
|
|
|
linePv: {label: "rotorTorque", units: 'кН·м', xAccessorName: "rotorTorque", yAccessorName: "date", color: '#a0a'},
|
|
|
|
|
lineSp: {label: "rotorTorqueSp", units: 'кН·м', xAccessorName: "rotorTorqueSp", yAccessorName: "date", color: '#a0a'},
|
|
|
|
|
lineIdle: {
|
|
|
|
|
label: "rotorTorqueIdle",
|
|
|
|
|
units: 'кН·м',
|
|
|
|
|
xAccessorName: "rotorTorqueIdle",
|
|
|
|
|
yAccessorName: "date",
|
|
|
|
|
color: '#a0a'
|
|
|
|
|
},
|
2021-04-16 15:50:01 +05:00
|
|
|
|
linesOther: [
|
2021-05-27 13:46:46 +05:00
|
|
|
|
{
|
|
|
|
|
label: "rotorTorqueLimitMax",
|
|
|
|
|
units: 'кН·м',
|
|
|
|
|
xAccessorName: "rotorTorqueLimitMax",
|
|
|
|
|
yAccessorName: "date",
|
|
|
|
|
color: '#a0a'
|
|
|
|
|
},
|
2021-04-16 15:50:01 +05:00
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const paramsGroups = [blockHeightGroup, blockSpeedGroup, pressureGroup, axialLoadGroup, hookWeightGroup, rotorTorqueGroup]
|
|
|
|
|
|
2021-07-23 17:15:33 +05:00
|
|
|
|
export const Column = ({lineGroup, data, interval, showBorder}) => {
|
2021-04-16 15:50:01 +05:00
|
|
|
|
let lines = [lineGroup.linePv]
|
|
|
|
|
|
2021-05-19 16:05:01 +05:00
|
|
|
|
if (lineGroup.lineSp)
|
2021-04-16 15:50:01 +05:00
|
|
|
|
lines.push(lineGroup.lineSp)
|
|
|
|
|
|
2021-05-27 16:59:05 +05:00
|
|
|
|
if (lineGroup.lineOther)
|
|
|
|
|
lines.push(lineGroup.lineOther)
|
|
|
|
|
|
2021-07-23 17:15:33 +05:00
|
|
|
|
if (lineGroup.lineAvg)
|
|
|
|
|
lines.push(lineGroup.lineAvg)
|
|
|
|
|
|
|
|
|
|
if (lineGroup.lineMax)
|
|
|
|
|
lines.push(lineGroup.lineMax)
|
|
|
|
|
|
2021-05-19 16:05:01 +05:00
|
|
|
|
let dataLast = null
|
2021-04-16 15:50:01 +05:00
|
|
|
|
let pv = null
|
2021-05-19 16:05:01 +05:00
|
|
|
|
if (data?.length > 0) {
|
2021-04-16 15:50:01 +05:00
|
|
|
|
dataLast = data[data.length - 1];
|
2021-05-19 16:05:01 +05:00
|
|
|
|
if (lineGroup.linePv)
|
2021-04-16 15:50:01 +05:00
|
|
|
|
pv = dataLast[lineGroup.linePv?.xAccessorName]
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-19 16:05:01 +05:00
|
|
|
|
return (
|
2021-04-16 15:50:01 +05:00
|
|
|
|
<>
|
2021-07-23 17:15:33 +05:00
|
|
|
|
<div style={{boxShadow: showBorder ? "inset 0px 0px 0px 3px black" : ""}}>
|
|
|
|
|
<Display
|
|
|
|
|
label={lineGroup.label}
|
|
|
|
|
value={pv}
|
|
|
|
|
suffix={lineGroup.linePv?.units} isArrowVisible={false}/>
|
|
|
|
|
</div>
|
2021-05-19 16:05:01 +05:00
|
|
|
|
<ChartTimeOnline
|
2021-04-16 15:50:01 +05:00
|
|
|
|
data={data}
|
|
|
|
|
yDisplay={lineGroup.yDisplay}
|
|
|
|
|
lines={lines}
|
2021-05-27 13:46:46 +05:00
|
|
|
|
interval={interval}/>
|
2021-05-19 16:05:01 +05:00
|
|
|
|
<ChartTimeOnlineFooter
|
2021-04-16 15:50:01 +05:00
|
|
|
|
data={dataLast}
|
|
|
|
|
{...lineGroup} />
|
|
|
|
|
</>)
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-19 16:05:01 +05:00
|
|
|
|
// Словарь категорий для строк таблицы
|
|
|
|
|
const categoryDictionary = {
|
2021-06-24 16:20:48 +05:00
|
|
|
|
1: {title: 'Важное'},
|
2021-05-27 13:46:46 +05:00
|
|
|
|
2: {title: 'Предупреждение'},
|
|
|
|
|
3: {title: 'Информация'},
|
2021-05-19 16:05:01 +05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Конфигурация таблицы
|
|
|
|
|
const columns = [
|
|
|
|
|
{
|
|
|
|
|
title: 'Дата',
|
|
|
|
|
dataIndex: 'date',
|
|
|
|
|
render: (item) => moment(item).format('DD MMM YYYY, HH:MM:ss'),
|
|
|
|
|
sorter: (a, b) => new Date(b.date) - new Date(a.date),
|
|
|
|
|
sortDirections: ['descend', 'ascend'],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'Категория',
|
|
|
|
|
dataIndex: 'categoryId',
|
|
|
|
|
render: (_, item) => categoryDictionary[item.categoryId].title,
|
|
|
|
|
style: (_, item) => categoryDictionary[item.categoryId].style,
|
|
|
|
|
sorter: (a, b) => a.categoryId - b.categoryId,
|
|
|
|
|
sortDirections: ['descend', 'ascend'],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'Сообщение',
|
|
|
|
|
dataIndex: 'message',
|
|
|
|
|
onFilter: (value, record) => record.name.indexOf(value) === 0,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'Пользователь',
|
|
|
|
|
dataIndex: 'user',
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
2021-07-20 16:15:44 +05:00
|
|
|
|
const timePeriodCollection = [
|
|
|
|
|
{value: '60', label: '1 минута'},
|
|
|
|
|
{value: '300', label: '5 минут'},
|
|
|
|
|
{value: '600', label: '10 минут'},
|
|
|
|
|
{value: '1800', label: '30 минут'},
|
|
|
|
|
{value: '3600', label: '1 час'},
|
|
|
|
|
{value: '21600', label: '6 часов'},
|
|
|
|
|
{value: '43200', label: '12 часов'},
|
|
|
|
|
{value: '86400', label: '24 часа'}
|
|
|
|
|
]
|
|
|
|
|
|
2021-05-19 16:05:01 +05:00
|
|
|
|
export default function TelemetryView(props) {
|
2021-05-27 13:46:46 +05:00
|
|
|
|
let {id} = useParams()
|
2021-04-16 15:50:01 +05:00
|
|
|
|
const [saubData, setSaubData] = useState([])
|
2021-07-23 17:15:33 +05:00
|
|
|
|
const [chartInterval, setChartInterval] = useState(defaultInterval)
|
2021-05-19 16:05:01 +05:00
|
|
|
|
const [messages, setMessages] = useState([])
|
|
|
|
|
|
2021-07-23 17:15:33 +05:00
|
|
|
|
const [loader, setLoader] = useState(false)
|
|
|
|
|
|
|
|
|
|
const periods = intervalSteps.map((line) => <Option key={line.value} value={line.value}>{line.label}</Option>)
|
2021-04-16 15:50:01 +05:00
|
|
|
|
|
2021-07-20 16:15:44 +05:00
|
|
|
|
const children = timePeriodCollection.map((line) => <Option key={line.value}>{line.label}</Option>)
|
|
|
|
|
|
2021-05-19 16:05:01 +05:00
|
|
|
|
const handleReceiveDataSaub = (data) => {
|
|
|
|
|
if (data) {
|
2021-04-16 15:50:01 +05:00
|
|
|
|
setSaubData(data)
|
2021-05-19 16:05:01 +05:00
|
|
|
|
}
|
2021-04-16 15:50:01 +05:00
|
|
|
|
}
|
|
|
|
|
|
2021-05-19 16:05:01 +05:00
|
|
|
|
const handleReceiveMessages = (messages) => {
|
|
|
|
|
if (messages) {
|
2021-05-25 12:02:39 +05:00
|
|
|
|
setMessages(messages.items.splice(0, 4))
|
2021-05-19 16:05:01 +05:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-04-16 15:50:01 +05:00
|
|
|
|
|
2021-05-19 16:05:01 +05:00
|
|
|
|
useEffect(() => {
|
2021-06-02 11:38:27 +05:00
|
|
|
|
setLoader(true)
|
|
|
|
|
let promiseData = DataService.getData(id)
|
2021-05-27 13:46:46 +05:00
|
|
|
|
.then(handleReceiveDataSaub)
|
|
|
|
|
.catch((ex) => {
|
2021-05-31 15:10:35 +05:00
|
|
|
|
notify(`Не удалось загрузить данные по скважине "${id}"`, 'error')
|
2021-05-27 13:46:46 +05:00
|
|
|
|
console.log(ex)
|
|
|
|
|
})
|
2021-05-27 12:53:42 +05:00
|
|
|
|
|
2021-06-02 11:38:27 +05:00
|
|
|
|
let promiseMessages = MessageService.getMessage(id)
|
2021-05-27 13:46:46 +05:00
|
|
|
|
.then(handleReceiveMessages)
|
|
|
|
|
.catch((ex) => {
|
2021-05-31 15:10:35 +05:00
|
|
|
|
notify(`Не удалось загрузить сообщения по скважине "${id}"`, 'error')
|
2021-05-27 13:46:46 +05:00
|
|
|
|
console.log(ex)
|
|
|
|
|
})
|
2021-05-19 16:05:01 +05:00
|
|
|
|
|
2021-06-02 11:38:27 +05:00
|
|
|
|
Promise.all([promiseData, promiseMessages]).then(()=>setLoader(false))
|
|
|
|
|
|
2021-06-04 09:22:25 +05:00
|
|
|
|
let unSubscribeDataSaubHub = Subscribe('hubs/telemetry', 'ReceiveDataSaub', `well_${id}`, handleReceiveDataSaub)
|
|
|
|
|
let unSubscribeMessagesHub = Subscribe('hubs/telemetry','ReceiveMessages', `well_${id}`, handleReceiveMessages)
|
2021-05-19 16:05:01 +05:00
|
|
|
|
return () => {
|
|
|
|
|
unSubscribeDataSaubHub()
|
|
|
|
|
unSubscribeMessagesHub()
|
|
|
|
|
}
|
|
|
|
|
}, [id]);
|
|
|
|
|
|
2021-05-25 14:20:58 +05:00
|
|
|
|
useEffect(() => {
|
2021-06-02 11:38:27 +05:00
|
|
|
|
setLoader(true)
|
2021-05-25 14:20:58 +05:00
|
|
|
|
DataService.getData(id, null, chartInterval)
|
|
|
|
|
.then(handleReceiveDataSaub)
|
|
|
|
|
.catch(error => console.error(error))
|
2021-06-02 11:38:27 +05:00
|
|
|
|
.finally(()=>setLoader(false))
|
2021-05-28 14:33:57 +05:00
|
|
|
|
}, [id, chartInterval]);
|
2021-05-25 14:20:58 +05:00
|
|
|
|
|
2021-05-19 16:05:01 +05:00
|
|
|
|
const colSpan = 24 / (paramsGroups.length)
|
|
|
|
|
|
2021-06-02 11:38:27 +05:00
|
|
|
|
return (<LoaderPortal show={loader}>
|
2021-05-27 13:46:46 +05:00
|
|
|
|
<Row style={{marginBottom: '1rem'}}>
|
2021-05-19 16:05:01 +05:00
|
|
|
|
<Col>
|
2021-05-27 13:46:46 +05:00
|
|
|
|
<ModeDisplay data={saubData}/>
|
2021-05-19 16:05:01 +05:00
|
|
|
|
</Col>
|
2021-05-27 13:46:46 +05:00
|
|
|
|
<span style={{flexGrow: 0.1}}> </span>
|
2021-04-16 15:50:01 +05:00
|
|
|
|
<Col>
|
2021-05-19 16:05:01 +05:00
|
|
|
|
Интервал:
|
|
|
|
|
<Select defaultValue="600" onChange={setChartInterval}>
|
2021-07-20 16:15:44 +05:00
|
|
|
|
{children}
|
2021-05-19 16:05:01 +05:00
|
|
|
|
</Select>
|
2021-04-16 15:50:01 +05:00
|
|
|
|
</Col>
|
2021-05-27 13:46:46 +05:00
|
|
|
|
<span style={{flexGrow: 1}}> </span>
|
2021-04-16 15:50:01 +05:00
|
|
|
|
<Col>
|
2021-05-19 16:05:01 +05:00
|
|
|
|
<UserOfWells data={saubData}/>
|
2021-04-16 15:50:01 +05:00
|
|
|
|
</Col>
|
|
|
|
|
</Row>
|
|
|
|
|
<Row>
|
2021-07-23 17:15:33 +05:00
|
|
|
|
<Col span={3}>
|
2021-05-27 13:46:46 +05:00
|
|
|
|
<CustomColumn data={saubData}/>
|
2021-04-16 15:50:01 +05:00
|
|
|
|
</Col>
|
2021-07-23 17:15:33 +05:00
|
|
|
|
<Col span={24 - 3}>
|
2021-04-16 15:50:01 +05:00
|
|
|
|
<Row>
|
2021-07-23 17:15:33 +05:00
|
|
|
|
{paramsGroups.map((group, index) =>
|
2021-05-19 16:05:01 +05:00
|
|
|
|
<Col span={colSpan} className='border_small' key={group.label}>
|
2021-07-23 17:15:33 +05:00
|
|
|
|
<Column data={saubData} lineGroup={group} interval={chartInterval} showBorder = {saubData[saubData.length - 1]?.drillingBy === index}/>
|
2021-05-19 16:05:01 +05:00
|
|
|
|
</Col>)}
|
2021-04-16 15:50:01 +05:00
|
|
|
|
</Row>
|
|
|
|
|
</Col>
|
|
|
|
|
</Row>
|
2021-05-19 16:05:01 +05:00
|
|
|
|
<Table
|
2021-05-27 13:46:46 +05:00
|
|
|
|
showHeader={false}
|
|
|
|
|
columns={columns}
|
|
|
|
|
dataSource={messages}
|
|
|
|
|
rowClassName={(record) => `event_message_${record.categoryId} event_message`}
|
|
|
|
|
className={'message_table'}
|
|
|
|
|
size={'small'}
|
|
|
|
|
pagination={false}
|
|
|
|
|
rowKey={(record) => record.id}
|
|
|
|
|
/>
|
2021-06-02 11:38:27 +05:00
|
|
|
|
</LoaderPortal>)
|
2021-04-16 15:50:01 +05:00
|
|
|
|
}
|