Commit 837c1f15 authored by 陈龙's avatar 陈龙

fix: 优化获取点表的逻辑,修复因逻辑问题导致的异常

parent 742989d8
......@@ -37,7 +37,7 @@ path: /
## 多图表
[//]: # (<code src="./demos/GridDemo.js"></code>)
<code src="./demos/GridDemo.js"></code>
## API
......
......@@ -29,7 +29,6 @@ const GridChart = memo((props) => {
} = props;
const {prefixCls} = props;
const [gridData, setGridData] = useState([]);
const [pointAddressData, setPointAddressData] = useState(null);
const [pointAddressEntryData, setPointAddressEntryData] = useState(null);
const [sensorType, setSensorType] = useState(null);
// 新增逻辑:需要区分出哪些是统计值
......@@ -40,6 +39,7 @@ const GridChart = memo((props) => {
const handleDataSource = async (dataSource) => {
props.setLoading(true);
// 1. 统计设备
try {
let _deviceTypes = [];
let _deviceCodes = dataSource.reduce((final, cur) => {
if (!final.includes(cur.stationCode) && !_deviceTypes.includes(cur.deviceType)) {
......@@ -50,13 +50,8 @@ const GridChart = memo((props) => {
}, []);
// 2. 获取对应的版本id
let _ids = [];
if (pointAddressData !== null) {
_ids = pointAddressData;
} else {
let _idRequest = await getPointAddress({code: _deviceCodes.join(',')});
_ids = _idRequest?.data ?? [];
setPointAddressData(_ids)
}
// 3. 获取对应的点表
let _map = {};
for await (let item of _ids) {
......@@ -162,6 +157,9 @@ const GridChart = memo((props) => {
}
props.setLoading(false);
return _dataSource
} catch (e) {
props.setLoading(false);
}
};
const returnDateType = (date) => {
let {dateFrom, dateTo} = date;
......
......@@ -72,6 +72,11 @@ import HistoryView from '../index';
]*/
const deviceParams = [
{
"deviceCode": "EGBF00000141",
"sensors": "进水压力,出水瞬时流量,今日用电量",
"deviceType": "二供泵房"
}
/* {
"deviceCode": "EGBF00000244",
"sensors": "进水压力,出水瞬时流量,今日用电量,今日供水量",
"deviceType": "二供泵房"
......@@ -85,7 +90,7 @@ const deviceParams = [
"deviceCode": "EGBF00000184",
"sensors": "进水压力,出水瞬时流量,今日用电量,今日供水量",
"deviceType": "二供泵房"
}
}*/
];
const Demo = () => {
return <div style={{height: 700}}>
......
......@@ -191,10 +191,22 @@ import { MobileHistoryChart } from '../mobile';
}
];*/
const deviceParams = [
{
// 预测的
/* {
"deviceCode": "YLB00000041",
"sensors": "进水压力",
"deviceType": "压力表"
}*/
/* {
"deviceCode": "SSBF00000001",
"sensors": "出水压力",
"deviceType": "送水泵房"
}*/
//预测结束
{
"deviceCode": "EGBF00000141",
"sensors": "进水压力,出水瞬时流量,今日用电量",
"deviceType": "二供泵房"
}
]
const Demo = () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment