import React, { useEffect, useState } from 'react'; import { connect } from 'react-redux'; import { Select } from 'antd'; import moment from 'moment' import ReactECharts from 'echarts-for-react'; import General from '../components/realTime/general'; import LineBoxStatus from '../components/electrity/lineBoxStatus'; import SoftStart from '../components/realTime/softStart'; import Below from '../components/realTime/below'; import RunTime from '../components/realTime/runTime'; import AccumulateTime from '../components/realTime/accumulateTime'; const RealTime = ({ dispatch, actions, user, siteList, }) => { const { bigScreen } = actions const [strucId, setStrucId] = useState() //站点ID const [stations, setStations] = useState({}) //测点id const [softStartData, setSoftStartData] = useState([]) //软启动总用电数据 const [electro, setElectro] = useState({ week: 0, year: 0, day: 0 }) //用电概况 const [level, setLevel] = useState(0) //实时液位 useEffect(() => { const autoStructId = sessionStorage.getItem('structId'); let nextStructId = siteList[0]?.value; if (autoStructId) { for (let i = 0; i < siteList.length; i++) { if (autoStructId == siteList[i].value) { nextStructId = siteList[i].value; break; } } } setStrucId(nextStructId); }, [siteList]) useEffect(async () => { if (strucId) { let station = {} let week = 0 //本周 let year = 0 //年 let day = 0 //今日 await dispatch(bigScreen.axyData({ type: 'get', url: `structures/${strucId}/factors` })).then(async r => { if (r.success) { //水泵信息 let waterId = r.payload.data?.find(v => v.name == '泵站水泵')?.id if (waterId) { await dispatch(bigScreen.axyData({ type: 'get', url: `structures/${strucId}/stations`, params: { query: { factorId: waterId } } })).then(async p => { if (p.success) { let dataId = p.payload.data[0]?.groups[0]?.stations?.map(k => k.id) || [] station.pump = dataId if (dataId.length) { // 当前时间 await dispatch(bigScreen.axyData({ type: 'get', url: `stations/theme/data`, params: { query: { stations: dataId.join(), startTime: moment().startOf('day').format('YYYY/MM/DD HH:mm:ss'), endTime: moment().endOf('day').format('YYYY-MM-DD HH:mm:ss'), limit: 1 } } })).then(d => { if (d.success) { setSoftStartData(d.payload.data?.stations) } }) //今天 await dispatch(bigScreen.axyData({ type: 'get', url: `stations/data/theme`, params: { query: { stations: dataId.join(), begin: moment().startOf('day').format('x'), end: moment().endOf('day').format('x'), aggtype: "h", method: 'diff' } } })).then(d => { if (d.success) { d.payload.data[0]?.stations?.map(c => { c.data?.map(f => { if (!f.changData) { day += (f?.values?.eMotor_EQ || 0) week += (f?.values?.eMotor_EQ || 0) year += (f?.values?.eMotor_EQ || 0) } }) }) } }) //本周 await dispatch(bigScreen.axyData({ type: 'get', url: `stations/data/theme`, params: { query: { stations: dataId.join(), begin: moment().weekday(1).startOf('day').format('x'), end: moment().weekday(7).endOf('day').format('x'), aggtype: "d", method: 'diff' } } })).then(d => { if (d.success) { d.payload.data[0]?.stations?.map(c => { c.data?.map(f => { if (!f.changData) { week += (f?.values?.eMotor_EQ || 0) } }) }) } }) //今年 await dispatch(bigScreen.axyData({ type: 'get', url: `stations/data/theme`, params: { query: { stations: dataId.join(), begin: moment().startOf('year').format('x'), end: moment().endOf('year').format('x'), aggtype: "d", method: 'diff' } } })).then(d => { if (d.success) { d.payload.data[0]?.stations?.map(c => { c.data?.map(f => { if (!f.changData) { year += (f?.values?.eMotor_EQ || 0) } }) }) } }) } } }) } // 进线柜 let wireCabinetId = r.payload.data?.find(v => v.name == '泵站进线柜')?.id if (wireCabinetId) { await dispatch(bigScreen.axyData({ type: 'get', url: `structures/${strucId}/stations`, params: { query: { factorId: wireCabinetId } } })).then(async p => { if (p.success) { let dataId = [] p.payload.data?.map(v => { v.groups?.map(s => { s.stations?.map(f => { dataId.push(f.id) }) }) }) station.cabine = dataId if (dataId.length) { // // 今天 await dispatch(bigScreen.axyData({ type: 'get', url: `stations/data/theme`, params: { query: { stations: dataId.join(), begin: moment().startOf('day').format('x'), end: moment().endOf('day').format('x'), aggtype: "h", method: 'diff' } } })).then(d => { if (d.success) { d.payload.data[0]?.stations?.map(c => { c.data?.map(f => { if (!f.changData) { day += (f?.values?.eQF_EQ || 0) week += (f?.values?.eQF_EQ || 0) year += (f?.values?.eQF_EQ || 0) } }) }) } }) // // 本周 await dispatch(bigScreen.axyData({ type: 'get', url: `stations/data/theme`, params: { query: { stations: dataId.join(), begin: moment().weekday(1).startOf('day').format('x'), end: moment().weekday(7).endOf('day').format('x'), aggtype: "d", method: 'diff' } } })).then(d => { if (d.success) { d.payload.data[0]?.stations?.map(c => { c.data?.map(f => { if (!f.changData) { week += (f?.values?.eQF_EQ || 0) } }) }) } }) // // 今年 await dispatch(bigScreen.axyData({ type: 'get', url: `stations/data/theme`, params: { query: { stations: dataId.join(), begin: moment().startOf('year').format('x'), end: moment().endOf('year').format('x'), aggtype: "d", method: 'diff' } } })).then(d => { if (d.success) { d.payload.data[0]?.stations?.map(c => { c.data?.map(f => { if (!f.changData) { year += (f?.values?.eQF_EQ || 0) } }) }) } }) } } }) } //泵站信息 let informationId = r.payload.data?.find(v => v.name == '泵站信息')?.id if (informationId) { await dispatch(bigScreen.axyData({ type: 'get', url: `structures/${strucId}/stations`, params: { query: { factorId: informationId } } })).then(async p => { if (p.success) { // 液位趋势 await dispatch(bigScreen.axyData({ type: 'get', url: `stations/theme/data`, params: { query: { stations: p.payload.data[0]?.groups[0]?.stations[0]?.id, startTime: moment().startOf('day').format('YYYY-MM-DD HH:mm:ss'), endTime: moment().endOf('day').format('YYYY-MM-DD HH:mm:ss'), limit: 1 } } })).then(d => { if (d.success) { setLevel(d.payload.data?.stations[0]?.data[0]?.sLiquid_level || 0) } }) } }) } } }) setStations(station) setElectro({ day: day, week: week, year: year }) } }, [strucId]) return
本周用电量:{electro?.week?.toFixed(2)}
今年用电量:{electro?.year?.toFixed(2)}
今日用电量:{electro?.day?.toFixed(2)}
{siteList?.filter(v => v.value == strucId)[0]?.label}