diff --git a/src/components/Common/TodayFaultTotal/index.jsx b/src/components/Common/TodayFaultTotal/index.jsx index 92da1aa..03d7aae 100644 --- a/src/components/Common/TodayFaultTotal/index.jsx +++ b/src/components/Common/TodayFaultTotal/index.jsx @@ -85,18 +85,31 @@ function preHandleStatisticData(data, legend) { data: [], })); - const seriesData = []; legend.forEach((item, index) => { series[index].name = item; data.forEach((d, idx) => { - // if (index == 0) { - // series[index].label = { + if (index == legend.length - 1) { + series[index].label = { + show: true, + position: "top", + distance: 10, + color: "#fffc", + formatter: (params) => data[params.dataIndex].sum, + }; + } + // const sum = d.sum; + // console.log("d", d, sum); + // series[index].label = ((fff) => { + // console.log("===>", fff); + // return { // show: true, // position: "top", // distance: 10, // color: "#fffc", + // formatter: "asdf" + fff, // }; - // } + // })(sum); + series[index].data.push(obj[d.name][item] || 0); }); }); @@ -107,9 +120,10 @@ function preHandleStatisticData(data, legend) { function getOptions(series, isra, currentStatistic) { return { color: ["#2760FF", "#8167F6", "#5B9BFF", "#99D66C", "#FFD160", "#FF8A40"], - grid: { top: 42, right: 12, bottom: 20, left: 48 }, + grid: { top: 80, right: 12, bottom: 20, left: 48 }, legend: { top: 10, + left: 60, padding: 5, itemWidth: 12, itemHeight: 12, diff --git a/src/utils/cutting.ts b/src/utils/cutting.ts index 4dc3128..6db47d5 100644 --- a/src/utils/cutting.ts +++ b/src/utils/cutting.ts @@ -21,7 +21,7 @@ export default function handler(msg: MessageEvent) { console.log("[*] websocket: [unable to serialize] ---> ", msg); } - // console.log("[CUTTING DATA] ---> ", serializedData); + console.log("[CUTTING DATA] ---> ", serializedData); if (serializedData == null) return; diff --git a/src/utils/index.ts b/src/utils/index.ts index 5145797..e1b0fae 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -70,7 +70,8 @@ new XClient( // 烟气处理相关数据 new XClient( // "ws://10.70.27.122:8080/websocket/message?userId=CUTTING", - "ws://10.70.2.2:8080/websocket/message?userId=GAS" + newUser, + // "ws://10.70.2.2:8080/websocket/message?userId=GAS" + newUser, + "ws://192.168.1.62:48082/websocket/message?userId=GAS" + newUser, "SMOKE_DATA", smokeHandler ); diff --git a/src/utils/smoke.ts b/src/utils/smoke.ts index 8ad03d7..5c1c3ca 100644 --- a/src/utils/smoke.ts +++ b/src/utils/smoke.ts @@ -1,7 +1,89 @@ import { store } from "../store"; +type SmokeMessageItem = { + type: string; + realtime: { + SO2_float: number; + NOX_float: number; + O2_float: number; + dust_float: number; + }; + dayTrend: { + SO2_float: Array<{ + time: string; + value: number; + }>; + NOX_float: Array<{ + time: string; + value: number; + }>; + O2_float: Array<{ + time: string; + value: number; + }>; + dust_float: Array<{ + time: string; + value: number; + }>; + }; + weekTrend: { + SO2_float: Array<{ + time: string; + value: number; + }>; + NOX_float: Array<{ + time: string; + value: number; + }>; + O2_float: Array<{ + time: string; + value: number; + }>; + dust_float: Array<{ + time: string; + value: number; + }>; + }; + monthTrend: { + SO2_float: Array<{ + time: string; + value: number; + }>; + NOX_float: Array<{ + time: string; + value: number; + }>; + O2_float: Array<{ + time: string; + value: number; + }>; + dust_float: Array<{ + time: string; + value: number; + }>; + }; + yearTrend: { + SO2_float: Array<{ + time: string; + value: number; + }>; + NOX_float: Array<{ + time: string; + value: number; + }>; + O2_float: Array<{ + time: string; + value: number; + }>; + dust_float: Array<{ + time: string; + value: number; + }>; + }; +}; + export default function handler(msg: MessageEvent) { - let serializedData: { type: string; data: any } | null = null; + let serializedData: SmokeMessageItem | null = null; try { serializedData = JSON.parse(msg.data); } catch (error) { @@ -11,9 +93,17 @@ export default function handler(msg: MessageEvent) { case "exhaustGas": { store.dispatch({ type: "smoke/setInfo", - payload: serializedData.data.realtime, + payload: serializedData.realtime, + }); + store.dispatch({ + type: "smoke/setTrend", + payload: { + dayTrend: serializedData.dayTrend, + weekTrend: serializedData.weekTrend, + monthTrend: serializedData.monthTrend, + yearTrend: serializedData.yearTrend, + }, }); - store.dispatch({ type: "smoke/setTrend", payload: serializedData.data }); break; }