新增关阀搜索面板;升级项目依赖;建立测试框架
This commit is contained in:
@@ -16,10 +16,12 @@ import {
|
||||
Analytics as AnalyticsIcon,
|
||||
Search as SearchIcon,
|
||||
MyLocation as MyLocationIcon,
|
||||
Handyman as HandymanIcon,
|
||||
} from "@mui/icons-material";
|
||||
import AnalysisParameters from "./AnalysisParameters";
|
||||
import SchemeQuery from "./SchemeQuery";
|
||||
import LocationResults from "./LocationResults";
|
||||
import ValveIsolation from "./ValveIsolation";
|
||||
import ContaminantAnalysisParameters from "../ContaminantSimulation/AnalysisParameters";
|
||||
import ContaminantSchemeQuery from "../ContaminantSimulation/SchemeQuery";
|
||||
import ContaminantResultsPanel from "../ContaminantSimulation/ResultsPanel";
|
||||
@@ -248,6 +250,13 @@ const BurstPipeAnalysisPanel: React.FC<BurstPipeAnalysisPanelProps> = ({
|
||||
iconPosition="start"
|
||||
label={isBurstMode ? "定位结果" : "模拟结果"}
|
||||
/>
|
||||
{isBurstMode && (
|
||||
<Tab
|
||||
icon={<HandymanIcon fontSize="small" />}
|
||||
iconPosition="start"
|
||||
label="关阀分析"
|
||||
/>
|
||||
)}
|
||||
</Tabs>
|
||||
</Box>
|
||||
|
||||
@@ -279,6 +288,12 @@ const BurstPipeAnalysisPanel: React.FC<BurstPipeAnalysisPanelProps> = ({
|
||||
<ContaminantResultsPanel schemeName={data?.schemeName} />
|
||||
)}
|
||||
</TabPanel>
|
||||
|
||||
{isBurstMode && (
|
||||
<TabPanel value={currentTab} index={3}>
|
||||
<ValveIsolation />
|
||||
</TabPanel>
|
||||
)}
|
||||
</Box>
|
||||
</Drawer>
|
||||
</>
|
||||
|
||||
119
src/components/olmap/BurstPipeAnalysis/ValveIsolation.tsx
Normal file
119
src/components/olmap/BurstPipeAnalysis/ValveIsolation.tsx
Normal file
@@ -0,0 +1,119 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState } from 'react';
|
||||
import { Box, TextField, Button, Typography, Card, CardContent, Chip } from '@mui/material';
|
||||
import axios from 'axios';
|
||||
import { config, NETWORK_NAME } from '@config/config';
|
||||
import { ValveIsolationResult } from './types';
|
||||
import { useNotification } from "@refinedev/core";
|
||||
|
||||
const ValveIsolation: React.FC = () => {
|
||||
const [pipeId, setPipeId] = useState('');
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [result, setResult] = useState<ValveIsolationResult | null>(null);
|
||||
const { open } = useNotification();
|
||||
|
||||
const handleAnalyze = async () => {
|
||||
if (!pipeId.trim()) {
|
||||
open?.({ type: 'error', message: '请输入管段ID' });
|
||||
return;
|
||||
}
|
||||
setLoading(true);
|
||||
setResult(null);
|
||||
try {
|
||||
const response = await axios.get(`${config.BACKEND_URL}/api/v1/valve_isolation_analysis`, {
|
||||
params: {
|
||||
network: NETWORK_NAME,
|
||||
accident_element: pipeId
|
||||
}
|
||||
});
|
||||
setResult(response.data);
|
||||
open?.({ type: 'success', message: '分析成功' });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
open?.({ type: 'error', message: '分析失败', description: '无法获取关阀分析结果' });
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Box className="flex flex-col h-full p-4">
|
||||
{/* Input Section */}
|
||||
<Box className="mb-4 flex gap-2 items-end">
|
||||
<TextField
|
||||
label="爆管管段ID"
|
||||
variant="outlined"
|
||||
size="small"
|
||||
fullWidth
|
||||
value={pipeId}
|
||||
onChange={(e) => setPipeId(e.target.value)}
|
||||
placeholder="请输入管段ID"
|
||||
/>
|
||||
<Button
|
||||
variant="contained"
|
||||
onClick={handleAnalyze}
|
||||
disabled={loading}
|
||||
className="bg-blue-600 h-[40px] min-w-[100px]"
|
||||
>
|
||||
{loading ? '分析中' : '开始分析'}
|
||||
</Button>
|
||||
</Box>
|
||||
|
||||
{/* Results Section */}
|
||||
{result && (
|
||||
<Box className="flex-1 overflow-auto space-y-4">
|
||||
<Card variant="outlined">
|
||||
<CardContent className="p-3">
|
||||
<Box className="flex justify-between items-center mb-2">
|
||||
<Typography variant="subtitle1" fontWeight="bold">分析结果</Typography>
|
||||
<Chip
|
||||
label={result.isolatable ? "可隔离" : "不可隔离"}
|
||||
color={result.isolatable ? "success" : "error"}
|
||||
size="small"
|
||||
/>
|
||||
</Box>
|
||||
<Typography variant="body2" color="text.secondary">事故类型: {result.accident_type}</Typography>
|
||||
<Typography variant="body2" color="text.secondary">受影响节点数: {result.affected_nodes?.length || 0}</Typography>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Box>
|
||||
<Typography variant="subtitle2" className="mb-2">必须关闭阀门 ({result.must_close_valves?.length || 0})</Typography>
|
||||
{result.must_close_valves?.length > 0 ? (
|
||||
<Box className="flex flex-wrap gap-2">
|
||||
{result.must_close_valves.map(v => (
|
||||
<Chip key={v} label={v} color="error" variant="outlined" size="small" />
|
||||
))}
|
||||
</Box>
|
||||
) : <Typography variant="caption" color="text.secondary">无</Typography>}
|
||||
</Box>
|
||||
|
||||
<Box>
|
||||
<Typography variant="subtitle2" className="mb-2">可选关闭阀门 ({result.optional_valves?.length || 0})</Typography>
|
||||
{result.optional_valves?.length > 0 ? (
|
||||
<Box className="flex flex-wrap gap-2">
|
||||
{result.optional_valves.map(v => (
|
||||
<Chip key={v} label={v} color="warning" variant="outlined" size="small" />
|
||||
))}
|
||||
</Box>
|
||||
) : <Typography variant="caption" color="text.secondary">无</Typography>}
|
||||
</Box>
|
||||
|
||||
<Box>
|
||||
<Typography variant="subtitle2" className="mb-2">受影响节点 ({result.affected_nodes?.length || 0})</Typography>
|
||||
{result.affected_nodes?.length > 0 ? (
|
||||
<Box className="bg-gray-50 p-2 rounded max-h-40 overflow-auto">
|
||||
<Typography variant="caption" className="break-all">
|
||||
{result.affected_nodes.join(', ')}
|
||||
</Typography>
|
||||
</Box>
|
||||
) : <Typography variant="caption" color="text.secondary">无</Typography>}
|
||||
</Box>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default ValveIsolation;
|
||||
@@ -36,3 +36,12 @@ export interface LocationResult {
|
||||
detect_time: string;
|
||||
locate_result: string[] | null;
|
||||
}
|
||||
|
||||
export interface ValveIsolationResult {
|
||||
accident_element: string;
|
||||
accident_type: string;
|
||||
affected_nodes: string[];
|
||||
must_close_valves: string[];
|
||||
optional_valves: string[];
|
||||
isolatable: boolean;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user