Commit 24c296db authored by 陈龙's avatar 陈龙

fix: 修复历史曲线中,异常数据导致的bug

parent 22fabdf0
......@@ -33,6 +33,8 @@
},
"dependencies": {
"@babel/runtime": "^7.17.9",
"antd-mobile": "5.10.4"
"antd-mobile": "5.10.4",
"rc-resize-observer": "1.4.0",
"react-window": "1.8.9"
}
}
......@@ -26,21 +26,17 @@ path: /
## 单图表-状态
[//]: # (<code src="./demos/indexForStatus.js"></code>)
[//]: # '<code src="./demos/indexForStatus.js"></code>'
## 单图表-频率
[//]: # (<code src="./demos/indexForFrequency.js"></code>)
[//]: # (## 移动端)
[//]: # (<code src="./demos/mobile.js"></code>)
[//]: # '<code src="./demos/indexForFrequency.js"></code>'
[//]: # '## 移动端'
[//]: # '<code src="./demos/mobile.js"></code>'
## 多图表
<code src="./demos/GridDemo.js"></code>
<!-- <code src="./demos/GridDemo.js"></code> -->
## API
......
import React from 'react';
import HistoryView from '../index';
import { MobileHistoryChart } from "../mobile";
import { MobileHistoryChart } from '../mobile';
const deviceParams = [
/*10.182*/
/* {
/* {
"deviceCode": "EGBF00000136",
"sensors": "进水压力,出水压力,出水瞬时流量,今日供水量,1#水箱液位,视频报警",
// "sensors": "视频报警",
// "sensors": "进水压力,出水压力,出水瞬时流量,今日供水量,1#水箱液位,视频报警",
"sensors": "视频报警",
"deviceType": "二供泵房"
},*/
/* {
}, */
/* {
"deviceCode": "EGJZ00000158",
// "sensors": "进水压力,出水压力,泵1状态",
"sensors": "进水压力",
// "sensors": "泵1状态",
"deviceType": "二供机组"
} */
/* {
/* {
deviceCode: 'EGBF00000141',
// sensors: '进水压力,出水瞬时流量,出水累计流量',
sensors: '进水压力',
deviceType: '熊猫二供泵房',
pointAddressID: 208,
},*/
/* {
/* {
"deviceCode": "SYJ00000008",
"sensors": "瞬时流量",
"deviceType": "水源井"
},*/
/* {
/* {
deviceCode: 'EGJZ00000197',
sensors: '进水压力,出水压力,出水瞬时流量,出水累计流量',
// sensors: '1#变频器运行频率',
......@@ -71,7 +71,7 @@ const deviceParams = [
"deviceType": "二供机组"
}*/
// 邳州张楼水厂
/* {
/* {
"deviceCode": "SC00000023",
"sensors": "瞬时流量",
"deviceType": "水厂"
......@@ -82,7 +82,7 @@ const deviceParams = [
"deviceType": "加矾间"
}, */
/* {
/* {
"deviceCode": "QSBF00000001",
"sensors": "取水浊度",
"deviceType": "取水泵房"
......@@ -102,37 +102,42 @@ const deviceParams = [
"sensors": "瞬时流量",
"deviceType": "流量计"
},*/
/* {
/* {
deviceCode: 'EGJZ00000027',
sensors: '2#变频器运行频率',
deviceType: '二供机组',
}, */
/*确山*/
/*泵3状态*/
/* {
/* {
// EGJZ00000003
deviceCode: 'EGJZ00000003',
// sensors: '3#频率',
sensors: '出1累计流量',
deviceType: '二供机组',
},*/
/* {
/* {
"deviceCode": "EGBF00000006",
"sensors": "出1累计流量",
"deviceType": "二供泵房"
}*/
// 永吉
/* {
// 永吉
/* {
"deviceCode": "SZJCY00000001",
"sensors": "pH",
"deviceType": "水质监测仪"
}*/
// 滦州
{
// 滦州
/* {
"deviceCode": "XMSB00000015",
"sensors": "今日出水量",
"deviceType": "熊猫水表"
}
} */
{
deviceCode: 'SYJ00000003',
sensors: '站点在线状态',
deviceType: '水源井',
},
];
const Demo = () => {
......@@ -140,7 +145,8 @@ const Demo = () => {
<>
<div>
<div style={{ height: 700 }}>
<HistoryView deviceParams={deviceParams} defaultModel="table" />
{/* <HistoryView deviceParams={deviceParams} defaultModel="table" /> */}
<HistoryView deviceParams={deviceParams} defaultModel="curve" />
</div>
</div>
</>
......
......@@ -39,7 +39,7 @@ import './index.less';
import { globalConfig } from 'antd/lib/config-provider';
import { getSensorType } from './apis/index';
import { ExportExcel } from '@wisdom-components/exportexcel';
import VirtualTable from "./VirtualTable";
import VirtualTable from './VirtualTable';
const { RangePicker } = DatePicker;
const { Option } = Select;
......@@ -853,8 +853,7 @@ const HistoryView = (props) => {
aDom.click();
aDom.remove();
})
.catch((err) => {
});
.catch((err) => {});
});
};
const exportFeatureBtn = () => {
......@@ -1105,7 +1104,9 @@ const HistoryView = (props) => {
let zoomParam =
activeTabKey === 'curve'
? handleDataThinKey(diffYears, diffDays, diffHours, lineDataType)
: (!isDilute ? { zoom: '', unit: '' } : {});// 表格也支持全数据模式;
: !isDilute
? { zoom: '', unit: '' }
: {}; // 表格也支持全数据模式;
requestArr.push(getHistoryInfo({ ...param, ...zoomParam }));
});
......@@ -1122,12 +1123,13 @@ const HistoryView = (props) => {
d.dateFrom = dateFrom || '';
d.dateTo = dateTo || '';
/**
* @Date: 2023年10月25日
* @date: 2023年10月25日
* @description: 数据连续补点之后,首值、尾值、最大值、最小值不会补,都为null。
* 为保证显示,将补点之后的数据的首值、尾值、最大值、最小值同时为null的情况变更为点的值。
*
* 请注意,此项为重要变更,此变更会影响原始数据。
* */
d.dataModel = d.dataModel.map(item => {
*/
d.dataModel = d.dataModel.map((item) => {
let { firstPV, lastPV, maxPV, minPV, pv } = item;
if (firstPV === null && lastPV === null && maxPV === null && minPV === null) {
firstPV = pv;
......@@ -1141,8 +1143,8 @@ const HistoryView = (props) => {
lastPV,
maxPV,
minPV,
}
})
};
});
});
deviceParams.forEach((p) => {
// 返回数据按查询指标顺序排序
......@@ -1234,7 +1236,7 @@ const HistoryView = (props) => {
// scroll={{ x: 'max-content', y: 'calc(100% - 40px)' }}
scroll={{
x: 'max-content',
y: tableRef.current ? tableRef.current.getBoundingClientRect().height - 40 : 0
y: tableRef.current ? tableRef.current.getBoundingClientRect().height - 40 : 0,
}}
/>
) : (
......@@ -1243,7 +1245,16 @@ const HistoryView = (props) => {
</div>
</>
);
}, [timeOrder, chartDataSource, columns, tableProps, tableData, isSingleStatusSensor, dateRange, tableRef.current]);
}, [
timeOrder,
chartDataSource,
columns,
tableProps,
tableData,
isSingleStatusSensor,
dateRange,
tableRef.current,
]);
const returnLongestPeriod = (data) => {
let _earliest = '';
let _latest = '';
......@@ -1465,7 +1476,7 @@ const HistoryView = (props) => {
<>
<Button type="link" onClick={exportFeatureBtn}>
<DownloadOutlined />
特征数据
下载
</Button>
{/* 保留此处代码,当项目需要表格定制时需要使用 */}
{/*<Button type="link" onClick={exportExcelBtn}>
......
......@@ -1143,7 +1143,7 @@ const optionGenerator = (
}
// 单曲线需要标记最大值、最小值的情况下,需要增加自定义的series,将最大最小值显示在图表上
if (dataSource?.[0]?.dataModel?.length && chartType === 'lineChart') {
let _dataSource = dataSource?.filter(item => item.pv);
let _dataSource = dataSource?.filter((item) => item?.dataModel?.length);
if (_dataSource?.length) {
let _customSeries = returnCustomSeries(dataSource);
series.push(_customSeries);
......@@ -1178,7 +1178,6 @@ const handleDataSource = (dataSource) => {
let _temp = null;
let _data = [];
let _dataLength = dataSource[0].dataModel.length;
// handleSpecial2()
dataSource[0].dataModel.forEach((item, index) => {
if (index === 0) {
_data.push(item);
......@@ -1221,7 +1220,7 @@ const handleSpecial2 = (special, sensorName, sensorType, data1, data2) => {
final[_arr[0]] = _arr[1];
return final;
}, {});
name = _valDescMap[data1.pv];
name = _valDescMap[data1.pv || 0];
color = _colorMap[name];
}
......@@ -1235,8 +1234,8 @@ const handleSpecial2 = (special, sensorName, sensorType, data1, data2) => {
0: '关',
1: '开',
};
name = _switchNameMap[data1.pv];
color = _switchColorMap[data1.pv];
name = _switchNameMap[data1.pv || 0];
color = _switchColorMap[data1.pv || 0];
}
value1 = moment(data1.pt).valueOf();
......
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