import React, { useEffect, useState } from 'react' import { connect } from 'react-redux'; import { Box, YSIframePlayer } from '$components'; import { Select } from 'antd'; import PerfectScrollbar from "perfect-scrollbar"; import { ArrowDownOutlined, ArrowUpOutlined } from '@ant-design/icons'; import './style.less'; let roadScrollbar let describeScrollbar const DataTop5 = ({ dispatch, actions, longitudeLatitude }) => { const [videoList, setVideoList] = useState([]) const [roadData, setRoadData] = useState({}) const [traffic, setTraffic] = useState({}) let weeks = { 1: '周一', 2: '周二', 3: '周三', 4: '周四', 5: '周五', 6: '周六', 7: '周日' } useEffect(() => { dispatch(actions.firecontrol.getDetails()).then(res => { if (res.success) { setTraffic(res.payload.data?.data?.detail || {}); } }) const dom1 = document.getElementById("road"); if (dom1) { roadScrollbar = new PerfectScrollbar("#road", { suppressScrollX: true, }); } const dom2 = document.getElementById("describe"); if (dom2) { describeScrollbar = new PerfectScrollbar("#describe", { suppressScrollX: true, }); } }, []) useEffect(() => { const dom1 = document.getElementById("road"); if (dom1) { roadScrollbar = new PerfectScrollbar("#road", { suppressScrollX: true, }); } const dom2 = document.getElementById("describe"); if (dom2) { describeScrollbar = new PerfectScrollbar("#describe", { suppressScrollX: true, }); } }, [roadData]) useEffect(() => { const dom1 = document.getElementById("road"); if (dom1 && roadScrollbar) { roadScrollbar.update(); } const dom2 = document.getElementById("describe"); if (dom2 && describeScrollbar) { describeScrollbar.update(); } }) useEffect(() => { if (longitudeLatitude?.latitude && longitudeLatitude?.longitude) { dispatch(actions.firecontrol.getSurroundingConditions({ // center: `30.576279,104.071216` center: `${longitudeLatitude?.latitude},${longitudeLatitude?.longitude}` })).then(res => { if (res.success) { setRoadData(res.payload.data || {}) } }) } }, [longitudeLatitude]) let evaluation = { 0: '未知路况', 1: '畅通', 2: '缓行', 3: '拥堵', 4: '严重拥堵' } let evaluationColor = { 0: 'rgb(151 175 164)', 1: '#00FF87', 2: '#FFCC00', 3: '#DE0102', 4: '#8E0E0B' } let trend = { SAME: '持平', BETTER: '缓解', WORSE: '加重' } return
周边路况实时数据
{longitudeLatitude?.longitude ? <> { (roadData?.description || roadData?.road_traffic?.length > 0 || roadData?.evaluation?.status_desc) ? <>
路况描述:
路况整体评价
{evaluation[roadData?.evaluation?.status] || '--'}
{roadData?.description || '暂无描述'}
{roadData.road_traffic?.find(f => f.congestion_sections?.length > 0) ? roadData?.road_traffic?.map(v => (v.congestion_sections?.length > 0) ? <>
{v.road_name}:
{ v.congestion_sections?.map(s => <>
{s.section_desc || "暂无路段拥堵语义化描述"}
= 1 && traffic?.index < 1.5) ? "#00FF87" : (traffic?.index >= 1.5 && traffic?.index < 1.8) ? "#FFCC00;" : (traffic?.index >= 1.8 && traffic?.index < 2) ? "#DE0102;" : (traffic?.index >= 2) ? "#8E0E0B;" : "" }}>{trend[s.congestion_trend] || "--"}
{ s.congestion_trend == "SAME" ? '与10分钟前变化不大' : s.congestion_trend == 'BETTER' ? '较10分钟前拥堵有所缓解' : s.congestion_trend == 'WORSE' ? '较10分钟前拥堵加重' : '--' }
平均通行速度
{s.speed || '--'}
km/h
拥堵距离
{s.congestion_distance || '--'}
m
) } : <>) :
暂无具体道路信息
}
:
暂无数据
} : <>
南昌市
NANCHANG CITY
= 1 && traffic?.index < 1.5) ? "#00FF87" : (traffic?.index >= 1.5 && traffic?.index < 1.8) ? "#FFCC00;" : (traffic?.index >= 1.8 && traffic?.index < 2) ? "#DE0102;" : (traffic?.index >= 2) ? "#8E0E0B;" : "" }}>{ (traffic?.index >= 1 && traffic?.index < 1.5) ? "畅通" : (traffic?.index >= 1.5 && traffic?.index < 1.8) ? "缓行" : (traffic?.index >= 1.8 && traffic?.index < 2) ? "拥堵" : (traffic?.index >= 2) ? "严重拥堵" : "" }
路况整体评价
实时拥堵指数
{traffic?.index || '--'}
较上周同期{traffic?.last_index > traffic?.index ? "下降" : '上升'} {((traffic?.last_index > traffic?.index ? (traffic?.last_index - traffic?.index) / traffic?.last_index : (traffic?.index - traffic?.last_index) / traffic?.last_index) * 100).toFixed(2)}%
{traffic?.last_index > traffic?.index ? : }
实时拥堵排行
{traffic?.rank || '--'}
/{traffic?.count || '--'}
全国重点城市拥堵排行
实时平均速度
{traffic?.road_network_speed || '--'}
km/h
实时严重拥堵里程
{traffic?.yongdu_length_4 || '--'}
km
近30日最高拥堵指数
{traffic?.month_max_yongdu_index?.toFixed(3) || '--'}
{traffic?.month_max_congest_time} {weeks[traffic?.month_max_week_day]}
}
} function mapStateToProps(state) { const { auth, global } = state return { user: auth.user, actions: global.actions, } } export default connect(mapStateToProps)(DataTop5);