实现 SCADA 设备列表数据对接;监测点优化,实现传感器定位;爆管分析,属性面板新增计算属性的获取;更新部分图标;爆管分析定位,更改时间轴样式。

This commit is contained in:
JIANG
2025-10-29 16:39:23 +08:00
parent 86e7349c85
commit a5954624a0
22 changed files with 474 additions and 170 deletions

View File

@@ -25,8 +25,9 @@ import { PlayArrow, Pause, Stop, Refresh } from "@mui/icons-material";
import { TbRewindBackward15, TbRewindForward15 } from "react-icons/tb";
import { FiSkipBack, FiSkipForward } from "react-icons/fi";
import { useData } from "../MapComponent";
import { config } from "@/config/config";
import { config, NETWORK_NAME } from "@/config/config";
import { useMap } from "../MapComponent";
import { Network } from "inspector/promises";
const backendUrl = config.backendUrl;
interface TimelineProps {
@@ -69,6 +70,7 @@ const Timeline: React.FC<TimelineProps> = ({
const [isPlaying, setIsPlaying] = useState<boolean>(false);
const [playInterval, setPlayInterval] = useState<number>(5000); // 毫秒
const [calculatedInterval, setCalculatedInterval] = useState<number>(15); // 分钟
const [isCalculating, setIsCalculating] = useState<boolean>(false);
// 计算时间轴范围
const minTime = timeRange
@@ -105,6 +107,7 @@ const Timeline: React.FC<TimelineProps> = ({
// 检查node缓存
if (junctionProperties !== "") {
const nodeCacheKey = `${query_time}_${junctionProperties}_${schemeName}`;
console.log("Node Cache Key:", nodeCacheKey);
if (nodeCacheRef.current.has(nodeCacheKey)) {
nodeRecords = nodeCacheRef.current.get(nodeCacheKey)!;
} else {
@@ -121,7 +124,7 @@ const Timeline: React.FC<TimelineProps> = ({
// 检查link缓存
if (pipeProperties !== "") {
const linkCacheKey = `${query_time}_${pipeProperties}`;
const linkCacheKey = `${query_time}_${pipeProperties}_${schemeName}`;
if (linkCacheRef.current.has(linkCacheKey)) {
linkRecords = linkCacheRef.current.get(linkCacheKey)!;
} else {
@@ -148,9 +151,9 @@ const Timeline: React.FC<TimelineProps> = ({
if (!nodeResponse.ok)
throw new Error(`Node fetch failed: ${nodeResponse.status}`);
nodeRecords = await nodeResponse.json();
// 缓存数据
// 缓存数据(修复键以包含 schemeName
nodeCacheRef.current.set(
`${query_time}_${junctionProperties}`,
`${query_time}_${junctionProperties}_${schemeName}`,
nodeRecords || []
);
}
@@ -159,9 +162,9 @@ const Timeline: React.FC<TimelineProps> = ({
if (!linkResponse.ok)
throw new Error(`Link fetch failed: ${linkResponse.status}`);
linkRecords = await linkResponse.json();
// 缓存数据
// 缓存数据(修复键以包含 schemeName
linkCacheRef.current.set(
`${query_time}_${pipeProperties}`,
`${query_time}_${pipeProperties}_${schemeName}`,
linkRecords || []
);
}
@@ -429,6 +432,63 @@ const Timeline: React.FC<TimelineProps> = ({
}
}, [map, handlePause]);
const handleForceCalculate = async () => {
if (!NETWORK_NAME) {
open?.({
type: "error",
message: "方案名称未设置,无法进行强制计算。",
});
return;
}
setIsCalculating(true);
// 显示处理中的通知
open?.({
type: "progress",
message: "正在强制计算,请稍候...",
undoableTimeout: 3,
});
try {
const body = {
name: NETWORK_NAME,
simulation_date: selectedDate.toISOString().split("T")[0], // YYYY-MM-DD
start_time: `${formatTime(currentTime)}:00`, // HH:MM:00
duration: calculatedInterval,
};
const response = await fetch(
`${backendUrl}/runsimulationmanuallybydate/`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(body),
}
);
if (response.ok) {
open?.({
type: "success",
message: "重新计算成功",
});
} else {
open?.({
type: "error",
message: "重新计算失败",
});
}
} catch (error) {
console.error("Recalculation failed:", error);
open?.({
type: "error",
message: "重新计算时发生错误",
});
} finally {
setIsCalculating(false);
}
};
return (
<div className="absolute bottom-4 left-1/2 -translate-x-1/2 z-10 w-[920px] opacity-90 hover:opacity-100 transition-opacity duration-300">
<LocalizationProvider dateAdapter={AdapterDateFns} adapterLocale={zhCN}>
@@ -574,7 +634,8 @@ const Timeline: React.FC<TimelineProps> = ({
variant="outlined"
size="small"
startIcon={<Refresh />}
// onClick={onRefresh}
onClick={handleForceCalculate}
disabled={isCalculating}
>
</Button>
@@ -610,6 +671,7 @@ const Timeline: React.FC<TimelineProps> = ({
"& .MuiSlider-track": {
backgroundColor: "primary.main",
height: 6,
display: timeRange ? "none" : "block",
},
"& .MuiSlider-rail": {
backgroundColor: "grey.300",