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,11 +1,11 @@
import React, { useEffect,useState } from 'react'; import React, { useEffect, useState } from 'react';
import { Form, Input, Button, DatePicker, InputNumber } from 'antd'; import { Form, Input, Button, DatePicker, InputNumber } from 'antd';
import NormalSelect from '../../components/Form/NormalSelect'; import NormalSelect from '../../components/Form/NormalSelect';
import moment from 'moment'; import moment from 'moment';
const { RangePicker } = DatePicker; const { RangePicker } = DatePicker;
const ToolBar = ({ setSearchVal, setType, save, form1 }) => { const ToolBar = ({ setSearchVal, setType, save, form1 }) => {
const types = [ const types = [
{ {
label: "hjw", label: "hjw",
@ -51,7 +51,7 @@ const ToolBar = ({ setSearchVal, setType, save, form1 }) => {
value: "24h" value: "24h"
} }
] ]
const [form] = Form.useForm(); const [form] = Form.useForm();
const onFinish = (values) => { const onFinish = (values) => {
@ -63,14 +63,13 @@ const ToolBar = ({ setSearchVal, setType, save, form1 }) => {
} }
} }
delete values.tm delete values.tm
// setSearchVal({...values, dateTimeRangeSo}); setSearchVal({...values, start: dateTimeRangeSo.start,end: dateTimeRangeSo.end});
save()
} }
const onValuesChange = (val,o) =>{ const onValuesChange = (val, o) => {
if ('time' in val) { if ('time' in val) {
setSearchVal({time: val.time}) setSearchVal({ time: val.time })
setType({time: val.time}) setType({ time: val.time })
form1.resetFields() form1.resetFields()
} }
if ('code' in val) { if ('code' in val) {
@ -81,28 +80,41 @@ const ToolBar = ({ setSearchVal, setType, save, form1 }) => {
} }
} }
useEffect(() => { 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 = { const params = {
code: "hjw", 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) setSearchVal(params)
setType({ time: "1h" }) setType({ time: "1h" })
}, []) }, [])
return ( 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 form={form} className='toolbarBox' layout="inline" onFinish={onFinish} onValuesChange={onValuesChange}>
<Form.Item label="水库" name="code"> <Form.Item label="水库" name="code">
<NormalSelect allowClear style={{ width: '150px' }} options={types} /> <NormalSelect allowClear style={{ width: '150px' }} options={types} />
</Form.Item> </Form.Item>
<Form.Item label="预见期" name="time"> {/* <Form.Item label="" name="time">
<NormalSelect allowClear style={{ width: '150px' }} options={timeType} /> <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>
{/* <Form.Item>
{/* <Form.Item>
<Button type="primary" htmlType="submit">生成</Button> <Button type="primary" htmlType="submit">生成</Button>
</Form.Item> */} </Form.Item> */}
</Form> </Form>

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")
}))