移除正常时间参数,简化分析参数逻辑
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import React, { useCallback, useMemo, useState } from "react";
|
||||
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
|
||||
import RefreshIcon from "@mui/icons-material/Refresh";
|
||||
import {
|
||||
@@ -59,12 +59,6 @@ const AnalysisParameters: React.FC<Props> = ({ onResult }) => {
|
||||
const [burstEndTime, setBurstEndTime] = useState<Dayjs | null>(
|
||||
dayjs().subtract(5, "minute"),
|
||||
);
|
||||
const [normalStartTime, setNormalStartTime] = useState<Dayjs | null>(
|
||||
dayjs().subtract(2, "hour"),
|
||||
);
|
||||
const [normalEndTime, setNormalEndTime] = useState<Dayjs | null>(
|
||||
dayjs().subtract(90, "minute"),
|
||||
);
|
||||
const [minDpressure, setMinDpressure] = useState<number>(2);
|
||||
const [basicPressure, setBasicPressure] = useState<number>(10);
|
||||
const [advancedOpen, setAdvancedOpen] = useState(false);
|
||||
@@ -78,16 +72,8 @@ const AnalysisParameters: React.FC<Props> = ({ onResult }) => {
|
||||
|
||||
setBurstStartTime(start);
|
||||
setBurstEndTime(end);
|
||||
setNormalStartTime(start);
|
||||
setNormalEndTime(end);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!isSimulationMode) return;
|
||||
setNormalStartTime(burstStartTime);
|
||||
setNormalEndTime(burstEndTime);
|
||||
}, [burstEndTime, burstStartTime, isSimulationMode]);
|
||||
|
||||
const fetchSchemes = useCallback(
|
||||
async ({ force = false, notify = false }: { force?: boolean; notify?: boolean } = {}) => {
|
||||
if (schemeLoading || (!force && schemes.length > 0)) return;
|
||||
@@ -152,35 +138,24 @@ const AnalysisParameters: React.FC<Props> = ({ onResult }) => {
|
||||
|
||||
const isValid = useMemo(() => {
|
||||
if (!Number.isFinite(burstLeakage) || burstLeakage <= 0) return false;
|
||||
if (!burstStartTime || !burstEndTime || !normalStartTime || !normalEndTime) {
|
||||
if (!burstStartTime || !burstEndTime) {
|
||||
return false;
|
||||
}
|
||||
if (dataSource === "simulation" && !selectedSchemeId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (
|
||||
burstStartTime.isBefore(burstEndTime) &&
|
||||
normalStartTime.isBefore(normalEndTime)
|
||||
);
|
||||
return burstStartTime.isBefore(burstEndTime);
|
||||
}, [
|
||||
burstLeakage,
|
||||
burstStartTime,
|
||||
burstEndTime,
|
||||
normalStartTime,
|
||||
normalEndTime,
|
||||
dataSource,
|
||||
selectedSchemeId,
|
||||
]);
|
||||
|
||||
const handleRun = async () => {
|
||||
if (
|
||||
!isValid ||
|
||||
!burstStartTime ||
|
||||
!burstEndTime ||
|
||||
!normalStartTime ||
|
||||
!normalEndTime
|
||||
) {
|
||||
if (!isValid || !burstStartTime || !burstEndTime) {
|
||||
open?.({ type: "error", message: "请完善参数并确认时间范围合法" });
|
||||
return;
|
||||
}
|
||||
@@ -210,8 +185,6 @@ const AnalysisParameters: React.FC<Props> = ({ onResult }) => {
|
||||
basic_pressure: basicPressure,
|
||||
scada_burst_start: burstStartTime.toISOString(),
|
||||
scada_burst_end: burstEndTime.toISOString(),
|
||||
scada_normal_start: normalStartTime.toISOString(),
|
||||
scada_normal_end: normalEndTime.toISOString(),
|
||||
use_scada_flow: enableFlow || undefined,
|
||||
simulation_scheme_name: selectedScheme?.scheme_name,
|
||||
simulation_scheme_type: selectedScheme?.scheme_type,
|
||||
@@ -347,32 +320,6 @@ const AnalysisParameters: React.FC<Props> = ({ onResult }) => {
|
||||
slotProps={{ textField: { size: "small", fullWidth: true } }}
|
||||
/>
|
||||
</Box>
|
||||
<Box>
|
||||
<Typography variant="subtitle2" className="mb-1 font-medium">
|
||||
正常开始时间
|
||||
</Typography>
|
||||
<DateTimePicker
|
||||
value={normalStartTime}
|
||||
onChange={setNormalStartTime}
|
||||
maxDateTime={normalEndTime ?? undefined}
|
||||
disabled={isSimulationMode}
|
||||
format="YYYY-MM-DD HH:mm"
|
||||
slotProps={{ textField: { size: "small", fullWidth: true } }}
|
||||
/>
|
||||
</Box>
|
||||
<Box>
|
||||
<Typography variant="subtitle2" className="mb-1 font-medium">
|
||||
正常结束时间
|
||||
</Typography>
|
||||
<DateTimePicker
|
||||
value={normalEndTime}
|
||||
onChange={setNormalEndTime}
|
||||
minDateTime={normalStartTime ?? undefined}
|
||||
disabled={isSimulationMode}
|
||||
format="YYYY-MM-DD HH:mm"
|
||||
slotProps={{ textField: { size: "small", fullWidth: true } }}
|
||||
/>
|
||||
</Box>
|
||||
</Box>
|
||||
</LocalizationProvider>
|
||||
|
||||
|
||||
@@ -23,8 +23,6 @@ export interface BurstLocationResult {
|
||||
scada_window?: {
|
||||
burst_start?: string;
|
||||
burst_end?: string;
|
||||
normal_start?: string;
|
||||
normal_end?: string;
|
||||
};
|
||||
pressure_samples?: {
|
||||
burst?: number;
|
||||
@@ -53,8 +51,6 @@ export interface BurstLocationSchemeDetail {
|
||||
scada_window?: {
|
||||
burst_start?: string;
|
||||
burst_end?: string;
|
||||
normal_start?: string;
|
||||
normal_end?: string;
|
||||
};
|
||||
result_summary?: {
|
||||
located_pipe?: string;
|
||||
|
||||
Reference in New Issue
Block a user