feat(): 预测水位功能开发

test
李神峰 2025-03-03 17:37:19 +08:00
parent c6fd00bb26
commit 2d60b17fbe
4 changed files with 293 additions and 2736 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
import React, { useEffect,useState } from 'react';
import React, { useEffect, useState } from 'react';
import { Form, Input, Button, DatePicker, InputNumber } from 'antd';
import NormalSelect from '../../components/Form/NormalSelect';
@ -63,14 +63,13 @@ const ToolBar = ({ setSearchVal, setType, save, form1 }) => {
}
}
delete values.tm
// setSearchVal({...values, dateTimeRangeSo});
save()
setSearchVal({...values, start: dateTimeRangeSo.start,end: dateTimeRangeSo.end});
}
const onValuesChange = (val,o) =>{
const onValuesChange = (val, o) => {
if ('time' in val) {
setSearchVal({time: val.time})
setType({time: val.time})
setSearchVal({ time: val.time })
setType({ time: val.time })
form1.resetFields()
}
if ('code' in val) {
@ -81,27 +80,40 @@ const ToolBar = ({ setSearchVal, setType, save, form1 }) => {
}
}
useEffect(() => {
const start = moment().subtract(7, 'days').format('YYYY-MM-DD 00:00:00')
const end = moment().format('YYYY-MM-DD 23:59:59')
const params = {
code: "hjw",
time:'1h'
time: '1h',
start,
end
}
form.setFieldsValue(params)
form.setFieldValue('name', params.code);
form.setFieldValue('tm', [moment(start), moment(end)]);
setSearchVal(params)
setType({ time: "1h" })
}, [])
return (
<>
<div style={{display:'flex',justifyContent:'space-between'}}>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<Form form={form} className='toolbarBox' layout="inline" onFinish={onFinish} onValuesChange={onValuesChange}>
<Form.Item label="水库" name="code">
<NormalSelect allowClear style={{ width: '150px' }} options={types} />
</Form.Item>
<Form.Item label="预见期" name="time">
{/* <Form.Item label="" name="time">
<NormalSelect allowClear style={{ width: '150px' }} options={timeType} />
</Form.Item> */}
<Form.Item label="时间" name="tm">
<RangePicker
allowClear
showTime
style={{ width: "330px" }}
format="YYYY-MM-DD HH:mm:ss"
/>
</Form.Item>
{/* <Form.Item>
<Button type="primary" htmlType="submit">生成</Button>
</Form.Item> */}

View File

@ -0,0 +1,35 @@
import moment from "moment";
/**
* 使用滑动窗口获取水文数据批次
* @param {Array} data - 后端返回的数据数组
* @returns {Array} - 返回数组每个元素包含600个点的数据
*/
export const getAllHydroBatches = (data) => {
if (!Array.isArray(data) || data.length < 600) {
return [];
}
const batches = [];
let startIndex = 0;
// 当剩余数据量大于等于600时继续处理
while (startIndex + 600 <= data.length) {
const slicedData = data.slice(startIndex, startIndex + 600);
batches.push({
rains: slicedData.map(item => item.rains),
waters: slicedData.map(item => item.waters),
lastTm: slicedData[599].tm // 记录第600个点的时间
});
// 每次向后移动1个位置
startIndex += 1;
}
return batches;
};
export const responseData = new Array(800).fill(0).map((item,index) => ({
rains: (Math.random() * 1).toFixed(2),
waters: (Math.random() * 100).toFixed(2),
tm:moment().clone().add(index, 'hours').format("YYYY-MM-DD HH:00:00")
}))