Commit be2cfc13 authored by 陈龙's avatar 陈龙

feat: 历史曲线提供源数据下载和特征数据下载

parent 690358c7
......@@ -4,12 +4,12 @@ import { MobileHistoryChart } from "../mobile";
const deviceParams = [
/*10.182*/
/* {
{
"deviceCode": "EGBF00000136",
"sensors": "进水压力,出水瞬时流量,今日供水量,1#水箱液位,视频报警",
"sensors": "进水压力,出水压力,出水瞬时流量,今日供水量,1#水箱液位,视频报警",
// "sensors": "视频报警",
"deviceType": "二供泵房"
}, */
},
{
"deviceCode": "EGJZ00000158",
// "sensors": "进水压力,出水压力,泵1状态",
......
......@@ -35,7 +35,8 @@ import SingleChart from './SingleChart';
import GridChart from './GridChart';
import './index.less';
import { globalConfig } from 'antd/lib/config-provider';
import { getSensorType } from "@wisdom-components/ec_realtimeinfo/es/apis";
import { getSensorType } from "./apis/index";
import { ExportExcel } from '@wisdom-components/exportexcel';
const { RangePicker } = DatePicker;
const { Option } = Select;
......@@ -777,6 +778,7 @@ const HistoryView = (props) => {
};
const exportExcelBtn = () => {
message.info('报表生成中,请稍后~');
deviceParams.forEach((i, r) => {
let timeFrom = dateRange[r]?.dateFrom || moment().format(startFormat);
let timeTo = dateRange[r]?.dateTo || moment().format(timeFormat);
......@@ -804,7 +806,46 @@ const HistoryView = (props) => {
});
});
};
const exportFeatureBtn = () => {
message.info('报表生成中,请稍后~');
let _dataSource = tableData.sort((a, b) => {
let _a = a.time;
let _b = b.time
if (timeValue === 'contrast') {
if (contrastOption === 'day') {
_a = `2000-01-01 ${a.time}:00`;
_b = `2000-01-01 ${b.time}:00`;
}
if (contrastOption === 'month') {
_a = `2000-01-${a.time}:00`;
_b = `2000-01-${b.time}:00`;
}
}
return timeOrder === 'ascend' ? moment(_a) - moment(_b) : moment(_b) - moment(_a);
})
let _columns = columns;
let timeFrom = dateRange?.[0]?.dateFrom || moment().format(startFormat);
let timeTo = dateRange?.[0]?.dateTo || moment().format(timeFormat);
let fileName = `特征数据-${moment(timeFrom).format(
dateFormat,
)}${moment(timeTo).format(dateFormat)}`;
let _dataIndex = [];
let _titleWidth = [];
let _title = _columns.map(item => {
_dataIndex.push(item.dataIndex);
_titleWidth.push(item.title.length*1);
return item.title;
});
ExportExcel({
name: fileName,
content: [{
sheetData: _dataSource,
sheetFilter: _dataIndex,
sheetHeader: _title,
columnWidths:_titleWidth
}]
})
};
const handleTableData = useCallback((data) => {
// eslint-disable-next-line no-param-reassign
// data = data.filter(item => item.sensorName !== '是否在线');
......@@ -1236,7 +1277,7 @@ const HistoryView = (props) => {
// 标记sensor是什么类型的
if (_res2.code === 0) {
setAllSensorType(_res2.data);
let _sensorID = _res1.data?.find(item => item.name === sensors)?.sensorTypeID;
let _sensor = _res2.data?.find(item => item.id === _sensorID)?.type;
let _isStatusSensor = ['状态值', '开关值'].includes(_sensor);
......@@ -1248,7 +1289,7 @@ const HistoryView = (props) => {
};
useEffect(() => {
getDefaultOptions();
}, [])
}, [deviceParams])
let percentTimer = useRef({
timer: null
});
......@@ -1301,10 +1342,16 @@ const HistoryView = (props) => {
right: (
<div className={`${prefixCls}-extra-right`}>
{activeTabKey === 'table' && (
<Button type="link" onClick={exportExcelBtn}>
<DownloadOutlined />
下载
</Button>
<>
<Button type="link" onClick={exportFeatureBtn}>
<DownloadOutlined />
特征数据
</Button>
<Button type="link" onClick={exportExcelBtn}>
<DownloadOutlined />
原始数据
</Button>
</>
)}
</div>
),
......
......@@ -26,8 +26,8 @@
&-extra-right {
position: absolute;
top: 10px;
right: 40px;
width: 82px;
right: 20px;
// width: 82px;
}
.@{history-view}-spin,
......
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