From b929e95108f219b571b35edf3b4b13115f7b49c6 Mon Sep 17 00:00:00 2001 From: wenlele Date: Thu, 24 Aug 2023 17:15:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=91=A8=E8=BE=B9=E8=B7=AF=E5=86=B5=E6=83=85?= =?UTF-8?q?=E5=86=B5=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/superScreen/fire.js | 11 +- api/config.js | 12 +- .../assets/images/homepage/bigscreen/road.png | Bin 0 -> 7944 bytes .../fire-control/components/Right-top2.js | 182 +++++++++++++----- 4 files changed, 146 insertions(+), 59 deletions(-) create mode 100644 super-screen/client/assets/images/homepage/bigscreen/road.png diff --git a/api/app/lib/controllers/superScreen/fire.js b/api/app/lib/controllers/superScreen/fire.js index 9a11675..5bfdfa5 100644 --- a/api/app/lib/controllers/superScreen/fire.js +++ b/api/app/lib/controllers/superScreen/fire.js @@ -169,10 +169,11 @@ function videoList (opts) { function getDetails (opts) { return async function (ctx) { try { - const res = await request.get('https://jiaotong.baidu.com/trafficindex/city/details/?cityCode=163') + const { app, yingshiTokenRes } = ctx + const res = await app.fs.baiDuJiaotong.get('trafficindex/city/details/?cityCode=163') ctx.status = 200 - ctx.body = res.body || {} + ctx.body = res || {} } catch (error) { ctx.fs.logger.error(`path: ${ctx.path}, error: error`); @@ -235,16 +236,16 @@ function getSurroundingConditions (opts) { const { app, yingshiTokenRes } = ctx const { center } = ctx.query; - const res = await app.fs.baiDu.get('/traffic/v1/around', { ak: opts.baiduAK, radius: 1000, center: center }) + const res = await app.fs.baiDu.get(`traffic/v1/around?ak=${opts.baiduAK}¢er=${center}&radius=1000`) ctx.status = 200 - ctx.body = res.body || {} + ctx.body = res && JSON.parse(res) || {} } catch (error) { ctx.fs.logger.error(`path: ${ctx.path}, error: error`); ctx.status = 400; ctx.body = { - message: '获取南昌市道路数据失败' + message: '获取周边路况数据失败' } } } diff --git a/api/config.js b/api/config.js index 714d054..2520c03 100644 --- a/api/config.js +++ b/api/config.js @@ -46,6 +46,7 @@ const YINGSHI_SECRET = process.env.YINGSHI_SECRET || flags.yingshiSecret; // 萤石服务的地址 const YINGSHI_URL = process.env.YINGSHI_URL || flags.yingshiUrl || 'https://open.ys7.com/api'; +const BAIDU_JIAOTONG_API = process.env.BAIDU_JIAOTONG_API || flags.baiDuJiaotong || 'https://jiaotong.baidu.com'; const BAIDU_API = process.env.BAIDU_API || flags.baiDu || 'https://api.map.baidu.com'; const BAIDU_AK = process.env.BAIDU_AK || flags.baiDuAk || 'AeSOcqC282tdSUVOfYxe68nEcNF1CTj7'; @@ -76,7 +77,7 @@ const product = { dev, yingshiKey: YINGSHI_KEY, yingshiSecret: YINGSHI_SECRET, - baiduAK: BAIDU_AK, + baiduAK: BAIDU_AK, exclude: [ // "*" ], // 不做认证的路由,也可以使用 exclude: ["*"] 跳过所有路由 @@ -111,7 +112,14 @@ const product = { { name: 'baiDu', root: BAIDU_API, - params: {} + params: {}, + dataWord: 'text' + }, + { + name: 'baiDuJiaotong', + root: BAIDU_JIAOTONG_API, + params: {}, + dataWord: '' },], } }, { diff --git a/super-screen/client/assets/images/homepage/bigscreen/road.png b/super-screen/client/assets/images/homepage/bigscreen/road.png new file mode 100644 index 0000000000000000000000000000000000000000..04e4896dbffed610460971888fdf517c4dba160a GIT binary patch literal 7944 zcmV+jANSyiP)Py8!bwCyRCr#+e0z*s*LmOfednBe@67D%gWOp@M47ZKOZKiE+o2s>5fIT;;KsIG zw*jP}X!}nSv_O%@Xj-&+AfO2wj`K%h{}H5Ug91&10!ea!1V&iTILyLayHaJkEeB)5ZI?Ck99%ss#PeZTK{4#NM(n~30Rd3!{Z z*Yf|9|NELQIw7yM}X5ifO)kFVj#EeLjei0(+Zd3o?6?&euL}^9AZ)PU=uw#b^y^RlV!Mq1y4Vx2a<+j>ON(&z z#pkQ*c=Ns6v*HKOmyhp0c(0r~bsFaG8Hv8e{+*1VJyn0%DT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`TS0pzS}O4ZGh&`MM{*mIHKNcSh{QjBOdR_1()8m3BB*Y2tvK$$xu2 yj#Ii55cIh>^%{5jVq5j(PXGV)r23t{_x}ZN$GCStp(?xp0000 { const [videoList, setVideoList] = useState([]) - const [options, setOptions] = useState([]) + const [roadData, setRoadData] = useState({}) const [traffic, setTraffic] = useState({}) let weeks = { 1: '周一', 2: '周二', 3: '周三', 4: '周四', 5: '周五', 6: '周六', 7: '周日' } @@ -18,17 +20,65 @@ const DataTop5 = ({ dispatch, actions, longitudeLatitude }) => { 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(() => { - dispatch(actions.firecontrol.getSurroundingConditions({ center: `${longitudeLatitude?.longitude},${longitudeLatitude?.latitude}` })).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, + }); + } + }, [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]) - console.log(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 ? <> - {/*
-
-
= 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?.road_network_speed || '--'}
km/h
-
-
-
拥堵距离
-
{traffic?.yongdu_length_4 || '--'}
km
-
-
-
-
-
较10分钟前拥堵趋势:
-
-
-
- 持平 + { + (roadData?.description || roadData?.road_traffic?.length > 0 || roadData?.evaluation?.status_desc) ? <> +
+
+ + 路况描述:
+
+
路况整体评价
+
{evaluation[roadData?.evaluation?.status] || '--'}
-
-
与1设法厕任务v
- -
-
-
-
路况描述:
-
dewbfdhuihseacf dsjhcf ewdcjaiopsdc op sadc jwe dcfp weopdcf ujew fdc
- -
*/} +
+ {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
+
+
+
+ ) + } + + : <>) + : +
+ 暂无具体道路信息 +
+ } +
+ + : +
+ 暂无数据 +
} : <>