2021-05-19 16:05:01 +05:00
|
|
|
import { useState, useEffect } from 'react';
|
2021-04-16 15:50:01 +05:00
|
|
|
import { Row, Col, Select, } from 'antd'
|
2021-05-19 16:05:01 +05:00
|
|
|
import { ChartTimeOnline } from '../components/charts/ChartTimeOnline'
|
|
|
|
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'
|
|
|
|
import moment from 'moment'
|
|
|
|
import { Table } from 'antd';
|
|
|
|
import { MessageService } from '../services/api'
|
|
|
|
import Loader from '../components/Loader'
|
|
|
|
|
|
|
|
import { useParams } from 'react-router-dom'
|
|
|
|
import { Subscribe } from '../services/signalr'
|
|
|
|
import { DataService } from '../services/api'
|
|
|
|
import '../styles/message_telemetry.css'
|
|
|
|
|
|
|
|
const { Option } = Select
|
|
|
|
|
|
|
|
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-19 16:05:01 +05:00
|
|
|
linePv: { label: "blockHeight", units: 'м', xAccessorName: "blockHeight", yAccessorName: "date", color: '#333' },
|
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-19 16:05:01 +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,
|
|
|
|
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-19 16:05:01 +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-19 16:05:01 +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-19 16:05:01 +05:00
|
|
|
{ label: "axialLoadLimitMax", units: 'т', xAccessorName: "axialLoadLimitMax", yAccessorName: "date", color: '#00a' },
|
2021-04-16 15:50:01 +05:00
|
|
|
],
|
|
|
|
}
|
|
|
|
|
|
|
|
const hookWeightGroup = {
|
2021-05-19 16:05:01 +05:00
|
|
|
label: "Ввес на крюке",
|
2021-04-16 15:50:01 +05:00
|
|
|
yDisplay: false,
|
2021-05-19 16:05:01 +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-19 16:05:01 +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-19 16:05:01 +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-19 16:05:01 +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-05-19 16:05:01 +05:00
|
|
|
export const Column = ({ lineGroup, data, interval }) => {
|
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-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-05-19 16:05:01 +05:00
|
|
|
<Display
|
2021-04-16 15:50:01 +05:00
|
|
|
label={lineGroup.label}
|
|
|
|
value={pv}
|
2021-05-19 16:05:01 +05:00
|
|
|
suffix={lineGroup.linePv?.units} />
|
|
|
|
<ChartTimeOnline
|
2021-04-16 15:50:01 +05:00
|
|
|
data={data}
|
|
|
|
yDisplay={lineGroup.yDisplay}
|
|
|
|
lines={lines}
|
2021-05-19 16:05:01 +05:00
|
|
|
interval={interval} />
|
|
|
|
<ChartTimeOnlineFooter
|
2021-04-16 15:50:01 +05:00
|
|
|
data={dataLast}
|
|
|
|
{...lineGroup} />
|
|
|
|
</>)
|
|
|
|
}
|
|
|
|
|
2021-05-19 16:05:01 +05:00
|
|
|
// Словарь категорий для строк таблицы
|
|
|
|
const categoryDictionary = {
|
|
|
|
1: { title: 'Авария' },
|
|
|
|
2: { title: 'Предупреждение' },
|
|
|
|
3: { title: 'Информация' },
|
|
|
|
}
|
|
|
|
|
|
|
|
// Конфигурация таблицы
|
|
|
|
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',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
export default function TelemetryView(props) {
|
|
|
|
let { id } = useParams()
|
2021-04-16 15:50:01 +05:00
|
|
|
const [saubData, setSaubData] = useState([])
|
2021-05-19 16:05:01 +05:00
|
|
|
const [chartInterval, setChartInterval] = useState(600)
|
|
|
|
const [messages, setMessages] = useState([])
|
|
|
|
|
|
|
|
const [loader] = useState(false) // , setLoader
|
2021-04-16 15:50:01 +05:00
|
|
|
|
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) {
|
|
|
|
setMessages(messages.items.splice(0, 3))
|
|
|
|
}
|
|
|
|
}
|
2021-04-16 15:50:01 +05:00
|
|
|
|
2021-05-19 16:05:01 +05:00
|
|
|
useEffect(() => {
|
|
|
|
DataService.getData(id)
|
|
|
|
.then(handleReceiveDataSaub)
|
|
|
|
.catch(error => console.error(error))
|
|
|
|
|
|
|
|
MessageService.getMessage(id)
|
|
|
|
.then(handleReceiveMessages)
|
|
|
|
.catch(error => console.error(error))
|
|
|
|
|
|
|
|
let unSubscribeDataSaubHub = Subscribe('ReceiveDataSaub', `well_${id}`, handleReceiveDataSaub)
|
|
|
|
let unSubscribeMessagesHub = Subscribe('ReceiveMessages', `well_${id}`, handleReceiveMessages)
|
|
|
|
return () => {
|
|
|
|
unSubscribeDataSaubHub()
|
|
|
|
unSubscribeMessagesHub()
|
|
|
|
}
|
|
|
|
}, [id]);
|
|
|
|
|
|
|
|
const colSpan = 24 / (paramsGroups.length)
|
|
|
|
|
|
|
|
return (<div>
|
2021-04-16 15:50:01 +05:00
|
|
|
{/* <div>Well id: {id}; points count: {saubData.length}</div> */}
|
2021-05-19 16:05:01 +05:00
|
|
|
<Row style={{ marginBottom: '1rem' }}>
|
|
|
|
<Col>
|
|
|
|
<ModeDisplay data={saubData} />
|
|
|
|
</Col>
|
2021-04-16 15:50:01 +05:00
|
|
|
<Col>
|
2021-05-19 16:05:01 +05:00
|
|
|
Интервал:
|
|
|
|
<Select defaultValue="600" onChange={setChartInterval}>
|
|
|
|
<Option value='600'>10 минут</Option>
|
|
|
|
<Option value='1800'>30 минут</Option>
|
|
|
|
<Option value='3600'>1 час</Option>
|
|
|
|
<Option value='21600'>6 час</Option>
|
|
|
|
<Option value='86400'>1 день</Option>
|
|
|
|
</Select>
|
2021-04-16 15:50:01 +05:00
|
|
|
</Col>
|
2021-05-19 16:05:01 +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>
|
|
|
|
<Col span={2} >
|
|
|
|
<CustomColumn data={saubData} />
|
|
|
|
</Col>
|
|
|
|
<Col span={24 - 2}>
|
|
|
|
<Row>
|
2021-05-19 16:05:01 +05:00
|
|
|
{paramsGroups.map(group =>
|
|
|
|
<Col span={colSpan} className='border_small' key={group.label}>
|
|
|
|
<Column data={saubData} lineGroup={group} interval={chartInterval} />
|
|
|
|
</Col>)}
|
2021-04-16 15:50:01 +05:00
|
|
|
</Row>
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2021-05-19 16:05:01 +05:00
|
|
|
<Table
|
|
|
|
showHeader={false}
|
|
|
|
columns={columns}
|
|
|
|
dataSource={messages}
|
|
|
|
rowClassName={(record) => `event_message_${record.categoryId}`}
|
|
|
|
size={'small'}
|
|
|
|
pagination={false}
|
|
|
|
rowKey={(record) => record.id}
|
|
|
|
/>
|
|
|
|
{loader && <Loader />}
|
2021-04-16 15:50:01 +05:00
|
|
|
</div>)
|
|
|
|
}
|